Android - VideoCall Module¶
The VideoCall module allows the customer to have a real-time video call with a customer representative using the back or front camera. During the call, the representative can initiate OCR, NFC, or Face operations as "Repeat Operation" if deemed necessary.
⚠️ Prerequisite: Before using the VideoCall Module, Maven access must be provided and the Core Module must be added to the project. To enable the repeat operations to work, the OCR, NFC, and Face modules must also be implemented.
Adding to the Project¶
1. Add to libs.versions.toml file:¶
[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:¶
3. Gradle Sync¶
Synchronize the Gradle files by clicking on 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:
<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 permission is not granted.
PiP (Picture-in-Picture) Support¶
To enable the PiP feature introduced in version 2.1.0.0, the following definition should be added to the AndroidManifest.xml of the Activity:
<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 full-screen covering FrameLayout must be added to the layout of the Activity where the VideoCall process will take place:
<FrameLayout
android:id="@+id/fragmentContainer"
android:layout_width="match_parent"
android:layout_height="match_parent" />
3. Addition of VideoCallCallbacks Interface¶
The VideoCallCallbacks interface must work with an Activity.
Adding to Class:
Overriding Callbacks:
class EnQualifyPlusActivity : AppCompatActivity(), VideoCallCallbacks {
override fun initializeCompleted(moduleName: EnModules) {
Log.i(tag, "${object {}.javaClass.enclosingMethod?.name}")
when (moduleName) {
EnModules.VideoCall -> {
// VideoCall operations 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}")
// Handle agent 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¶
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 | Runtime context of the application |
sessionModel | SessionModel | Session information to be used during the VideoCall process |
baseModel | BaseModel | Model carrying basic data during the validation process |
fragmentManager | FragmentManager | Manages VideoCall fragments |
containerID | Int | ID of the container where the VideoCall fragment will be added |
When the initialization is completed, initializeCompleted is triggered, and the call can be initiated.
VideoCall Operations¶
Functions¶
| Function | Description |
|---|---|
startVideoCall() | Initiates the video call; establishes Socket and WebRTC connections |
faceRetry() | Repeats the Face operation requested by the agent |
ocrRetry() | Repeats the OCR operation requested by the agent |
backToVideoCall() | Returns to the call after OCR or Face retry |
backToVideoCallAfterNfc() | Returns to the call after NFC retry |
endVideoCall() | Ends the video call |
updateSession(...) | Updates the session for the handicapped user |
addFragment(fragment) | Adds a new fragment over the existing fragment |
replaceFragment(fragment) | Replaces the current fragment with a new one |
addIntegration(integrationModel) | Adds integration data |
closeSession(isFinished: Boolean) | Closes the session |
clear() | Cleans up the SDK |
getSessionUId() | Returns the UId of the current session. |
Starting the Call¶
When a call is answered by an agent, callStarted is triggered:
Meeting Agent Requests (Repeat Operations)¶
When the representative sends a repeat operation request during the call, the agentRequest callback is triggered. The relevant SDK must have been initialized previously:
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)
}
}
Return to the call after retry:
// After OCR or Face retry
enQualifyVideoCall.backToVideoCall()
// After NFC retry
enQualifyVideoCall.backToVideoCallAfterNfc()
Ending the Call¶
override fun callResultCompleted(result: String, description: String, reference: String) {
// The call ended successfully
}
override fun callResultFailed(errorMessage: String) {
// An error occurred during ending
}
Updating Session for Handicapped User¶
To enable sign language during the call, it should be called before the meeting starts:
Closing and Clearing Session¶
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¶
Proguard Rules¶
Callback Reference¶
Token / Session / Settings¶
| Callback | Description |
|---|---|
tokenCreateCompleted(isNewCreatedToken: Boolean) | Triggered when the token is created |
tokenCreateFailed(errorMessage: String) | Token creation error |
sessionAddFailed(errorMessage: String) | Session creation error |
settingsGetFailed(errorMessage: String) | Triggered when 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) | Could not 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 operation request |
hangupConfirmation() | User pressed the hang up button |
callResultCompleted(result, description, reference) | Call ended successfully |
callResultFailed(errorMessage: String) | Error in ending the call |
cameraFailed() | Camera initialization error |
videoCallFailed(videoCallFailure, additionalMessage) | Error connecting to the call |
socketInitializeFailed() | Socket connection could not be established |
sessionRoomFailed(errorMessage: String) | Error creating room session |