Skip to content

Android - VideoCall Module

The VideoCall module allows the customer to make live video calls to a customer representative using either the front or back camera. During the call, the representative can initiate OCR, NFC, or Face processes as "Repeat Process" if deemed necessary.

⚠️ Prerequisite: Before using the VideoCall Module, Maven access must be provided, and the Core Module should be added to the project. To enable the repeat processes, the OCR, NFC, and Face modules must also be implemented.


Adding to the Project

1. Add to libs.versions.toml file:

Text Only
[versions]
...
enqualify-plus = "x.x.x.x"

[libraries]
...
enqualify-plus-videocall = {
    group = "com.enqualify.plus",
    name = "videocall",
    version.ref = "enqualify-plus"
}

2. Add dependency to build.gradle.kts file:

Text Only
implementation(libs.enqualify.plus.videocall)

3. Gradle Sync

Synchronize the Gradle files by clicking the "Sync Now" option.


Implementation

1. Permissions

Camera and microphone permissions are automatically added to the manifest by the SDK. The following lines are for informational purposes only:

Text Only
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />

The VideoCall module will not work if camera or microphone permissions are not granted.

PiP (Picture-in-Picture) Support

To enable the PiP feature introduced in version 2.1.0.0, the following definition must be added to the Activity's AndroidManifest.xml:

Text Only
<activity
    android:name="//Your Activity Package Name"
    android:resizeableActivity="true"
    android:supportsPictureInPicture="true"
    android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation|uiMode" />

2. Activity Layout — FrameLayout

A FrameLayout that covers the full screen must be added to the layout of the Activity where the VideoCall process will take place:

Text Only
<FrameLayout
    android:id="@+id/fragmentContainer"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

3. Adding VideoCallCallbacks Interface

The VideoCallCallbacks interface must work with an Activity.

Adding to the class:

Text Only
class EnQualifyPlusActivity : AppCompatActivity(), VideoCallCallbacks

Overriding the callbacks:

Text Only
class EnQualifyPlusActivity : AppCompatActivity(), VideoCallCallbacks {

    override fun initializeCompleted(moduleName: EnModules) {
        Log.i(tag, "${object {}.javaClass.enclosingMethod?.name}")
        when (moduleName) {
            EnModules.VideoCall -> {
                // VideoCall processes can be initiated
            }
        }
    }

    override fun initializeFailed(failureCode: FailureCode, additionalMessage: String) {
        Log.i(tag, "${object {}.javaClass.enclosingMethod?.name}")
    }

    override fun callStarted() {
        Log.i(tag, "${object {}.javaClass.enclosingMethod?.name}")
    }

    override fun agentRequest(agentRequestType: AgentRequestType) {
        Log.i(tag, "${object {}.javaClass.enclosingMethod?.name}")
        // Manage the agent's repeat requests here
    }

    override fun hangupConfirmation() {
        Log.i(tag, "${object {}.javaClass.enclosingMethod?.name}")
    }

    override fun callResultCompleted(result: String, description: String, reference: String) {
        Log.i(tag, "${object {}.javaClass.enclosingMethod?.name}")
    }

    override fun callResultFailed(errorMessage: String) {
        Log.i(tag, "${object {}.javaClass.enclosingMethod?.name}")
    }

    override fun cameraFailed() {
        Log.i(tag, "${object {}.javaClass.enclosingMethod?.name}")
    }

    override fun sessionAddFailed(errorMessage: String) {
        Log.i(tag, "${object {}.javaClass.enclosingMethod?.name}")
    }

    override fun sessionCloseCompleted(status: CallSessionTypeStatus) {
        Log.i(tag, "${object {}.javaClass.enclosingMethod?.name}")
    }

    override fun integrationAddCompleted() {
        Log.i(tag, "${object {}.javaClass.enclosingMethod?.name}")
    }

    override fun integrationAddFailed(errorMessage: String) {
        Log.i(tag, "${object {}.javaClass.enclosingMethod?.name}")
    }
}

4. Initializing EnQualifyVideoCall

Text Only
val sessionModel = SessionModel(
    callType = "NewCustomer",
    reference = UUID.randomUUID().toString()
)

val baseModel = BaseModel(
    baseURL = "https://deveqmapi.enqura.com",
    signallingCertificateList = listOf("enqura"),
    mapiCertificateList = listOf("enqura"),
    mobileUser = "mobile",
    countryCode = "TUR",
    locale = "TR",
    useEmbeddedLocalSound = false
)

EnQualifyVideoCall.initialize(
    context = this,
    fragmentManager = supportFragmentManager,
    containerID = R.id.fragmentContainer,
    sessionModel = sessionModel,
    baseModel = baseModel
)

Initialize Parameters

Parameter Type Description
context Context The runtime context of the application
sessionModel SessionModel Session information to be used during VideoCall
baseModel BaseModel Model containing base data during the authentication process
fragmentManager FragmentManager Manages the VideoCall fragments
containerID Int The ID of the container where the VideoCall fragment will be added

When initialization is complete, initializeCompleted is triggered and the call can be started.


VideoCall Operations

Functions

Function Description
startVideoCall() Starts the video call; establishes Socket and WebRTC connections
faceRetry() Repeats the Face process requested by the agent
ocrRetry() Repeats the OCR process requested by the agent
backToVideoCall() Returns to the call after OCR or Face repeat
backToVideoCallAfterNfc() Returns to the call after NFC repeat
endVideoCall() Ends the video call
updateSession(...) Updates the session for disabled users
addFragment(fragment) Adds a new fragment on top of the current fragment
replaceFragment(fragment) Replaces the current fragment with a new one
addIntegration(integrationModel) Adds integration data
closeSession(isFinished: Boolean) Closes the session
clear() Clears the SDK
getSessionUId() Returns the UId of the current session.

Starting a Call

Text Only
enQualifyVideoCall.startVideoCall()

When the call is answered by an agent, callStarted is triggered:

Text Only
override fun callStarted() {
    Log.i(tag, "${object {}.javaClass.enclosingMethod?.name}")
}

Handling Agent Requests (Repeat Process)

When the representative sends a repeat process request during the call, the agentRequest callback is triggered. The related SDK must be previously initialized:

Text Only
lateinit var enQualifyOCR: EnQualifyOCR
lateinit var enQualifyNFC: EnQualifyNFC
lateinit var enQualifyFace: EnQualifyFace

fun setupOCRSdk() { enQualifyOCR = EnQualifyOCR.getInstance() }
fun setupNFCSdk() { enQualifyNFC = EnQualifyNFC.getInstance() }
fun setupFaceSdk() { enQualifyFace = EnQualifyFace.getInstance() }

override fun agentRequest(agentRequestType: AgentRequestType) {
    when (agentRequestType) {
        AgentRequestType.OCR  -> enQualifyVideoCall.ocrRetry()
        AgentRequestType.FACE -> enQualifyVideoCall.faceRetry()
        AgentRequestType.NFC  -> { /* Start NFC, return to backToVideoCallAfterNfc() when finished */ }
        AgentRequestType.BackToVideoCall -> enQualifyVideoCall.backToVideoCall()
        AgentRequestType.CamClose -> // The agent closed the camera, a video can be shown here.
        AgentRequestType.CamOpen -> // The agent opened the camera
        AgentRequestType.FlashOpen -> enQualifyVideoCall.openTorch(true)
        AgentRequestType.FlashClose -> enQualifyVideoCall.closeTorch(true)

    }
}

Returning to the call after repeat:

Text Only
// After OCR or Face repeat
enQualifyVideoCall.backToVideoCall()

// After NFC repeat
enQualifyVideoCall.backToVideoCallAfterNfc()

Ending the Call

Text Only
enQualifyVideoCall.endVideoCall()
Text Only
override fun callResultCompleted(result: String, description: String, reference: String) {
    // The call successfully ended
}

override fun callResultFailed(errorMessage: String) {
    // An error occurred during ending
}

Updating Session for Disabled Users

To enable sign language for the call, this should be called before the call starts:

Text Only
enQualifyVideoCall.updateSession(
    handicapped = true,
    visuallyHandicapped = false
)

Closing and Clearing the Session

Text Only
enQualifyVideoCall.closeSession(isFinished = true)

override fun sessionCloseCompleted(status: CallSessionTypeStatus) {
    Log.i(tag, "${object {}.javaClass.enclosingMethod?.name}")
}

override fun sessionCloseFailed(errorMessage: String) {
    Log.i(tag, "${object {}.javaClass.enclosingMethod?.name} $errorMessage")
}

enQualifyVideoCall.clear()

Getting Session Information

Text Only
// Function that returns SessionUId
enQualifyVideoCall.getSessionUId()

Proguard Rules

Text Only
-keep class org.webrtc.** { *; }

Callback Reference

Token / Session / Settings

Callback Description
tokenCreateCompleted(isNewCreatedToken: Boolean) Triggered when a token is created
tokenCreateFailed(errorMessage: String) Token creation error
sessionAddFailed(errorMessage: String) Session creation error
settingsGetFailed(errorMessage: String) Triggered when the settings cannot be retrieved
sessionCloseCompleted(status: CallSessionTypeStatus) Triggered when the session is closed
sessionCloseFailed(errorMessage: String) Session closing error
integrationAddCompleted() Integration data successfully added
integrationAddFailed(errorMessage: String) Failed to add integration data
initializeFailed(failureCode: FailureCode, additionalMessage: String) Core initialization error

VideoCall

Callback Description
initializeCompleted(module: EnModules) Initialization completed, VideoCall is ready
callStarted() Call answered by the agent
agentRequest(agentRequestType: AgentRequestType) Agent sent a repeat process request
hangupConfirmation() User pressed the hang-up button
callResultCompleted(result, description, reference) The call successfully ended
callResultFailed(errorMessage: String) Call ending error
cameraFailed() Camera initialization error
videoCallFailed(videoCallFailure, additionalMessage) Error connecting to the call
socketInitializeFailed() Socket connection could not be established
sessionRoomFailed(errorMessage: String) Room session creation error