### Setup Join Call UI Source: https://www.mirrorfly.com/docs/audio-video/android/feature-join-call-via-link Initializes the join call setup within the Call SDK when the user is on the join call interface. This prepares the SDK for incoming call events and video rendering. ```APIDOC ## Setup Join Call UI ### Description Initializes the join call setup in the Call SDK when the user is on the join call UI. This method should be called before initializing video surfaces or setting up event listeners. ### Method POST ### Endpoint CallManager.setupJoinCallViaLink() ### Parameters None ### Request Example ```java CallManager.setupJoinCallViaLink(); ``` ### Response #### Success Response (200) Indicates successful initialization. No specific data is returned, but subsequent calls related to joining calls will function correctly. ### Post-Initialization Steps After calling `setupJoinCallViaLink()`, initialize your surface view for video preview: ```java YOUR_SURFACE_VIEW.init(CallManager.getRootEglBase().eglBaseContext, null); YOUR_SURFACE_VIEW.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_FILL); YOUR_SURFACE_VIEW.setZOrderMediaOverlay(true); YOUR_SURFACE_VIEW.setMirror(true); // Setting Target SurfaceViews to VideoSinks CallManager.getLocalProxyVideoSink()?.setTarget(YOUR_SURFACE_VIEW); ``` ``` -------------------------------- ### Install and Import MirrorFly SDK via NPM Source: https://www.mirrorfly.com/docs/audio-video/angular/quick-start Instructions for installing the MirrorFly SDK dependency using the Node Package Manager and importing it into your Angular application files. ```shell npm i mirrorfly-sdk ``` ```javascript import * as SDK from "mirrorfly-sdk"; ``` -------------------------------- ### Start Video Capture for Android Source: https://www.mirrorfly.com/docs/audio-video/android/v2/feature-join-call-via-link Initiates the device camera and microphone capture, requiring appropriate runtime permissions. ```Java CallManager.startVideoCapture(); ``` ```Kotlin CallManager.startVideoCapture() ``` -------------------------------- ### POST /makeVoiceCall Source: https://www.mirrorfly.com/docs/audio-video/android/v2/quick-start Initiates a one-to-one audio call to a specific user with optional metadata. ```APIDOC ## POST /makeVoiceCall ### Description Initiates a one-to-one audio call with another SDK user. The SDK automatically handles the UI presentation based on the activity class set via `CallManager.setCallActivityClass()`. ### Method POST ### Parameters #### Request Body - **TO_JID** (String) - Required - JID of the call receiver - **CALL_METADATA** (CallMetadata) - Optional - Metadata information (Max size 3) - **CALLBACK** (CallActionListener) - Required - Callback to observe action status ### Response #### Success Response (200) - **isSuccess** (Boolean) - Indicates if the call initiation was successful. ### Error Handling - **403 Forbidden** - Thrown if the one-to-one call feature is unavailable for your plan. ``` -------------------------------- ### POST /answerCall Source: https://www.mirrorfly.com/docs/audio-video/android/v2/quick-start Answers an incoming audio call and notifies the caller. ```APIDOC ## POST /answerCall ### Description Used to accept an incoming audio call. If required permissions are missing, the call will be automatically declined. ### Method POST ### Parameters #### Request Body - **CALLBACK** (CallActionListener) - Required - Callback to observe action status ### Response #### Success Response (200) - **isSuccess** (Boolean) - Indicates if the call was answered successfully. ``` -------------------------------- ### Initialize Join Call Setup for Android Source: https://www.mirrorfly.com/docs/audio-video/android/v2/feature-join-call-via-link Prepares the SDK for joining a call via link and configures the local surface view for video rendering. ```Java CallManager.setupJoinCallViaLink(); // Initialize surface view YOUR_SURFACE_VIEW.init(CallManager.getRootEglBase().getEglBaseContext(), null); YOUR_SURFACE_VIEW.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_FILL); YOUR_SURFACE_VIEW.setZOrderMediaOverlay(true); YOUR_SURFACE_VIEW.setMirror(true); CallManager.getLocalProxyVideoSink().setTarget(YOUR_SURFACE_VIEW); ``` ```Kotlin CallManager.setupJoinCallViaLink() // Initialize surface view YOUR_SURFACE_VIEW.init(CallManager.getRootEglBase()!!.eglBaseContext, null) YOUR_SURFACE_VIEW.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_FILL) YOUR_SURFACE_VIEW.setZOrderMediaOverlay(true) YOUR_SURFACE_VIEW.setMirror(true) CallManager.getLocalProxyVideoSink()?.setTarget(YOUR_SURFACE_VIEW) ``` -------------------------------- ### Initialize Join Call Setup Source: https://www.mirrorfly.com/docs/audio-video/android/feature-join-call-via-link Prepares the SDK for joining a call via link and configures the surface view for video rendering. Requires the Call SDK to be initialized prior to execution. ```Java CallManager.setupJoinCallViaLink(); // Initialize surface view YOUR_SURFACE_VIEW.init(CallManager.getRootEglBase().getEglBaseContext(), null); YOUR_SURFACE_VIEW.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_FILL); YOUR_SURFACE_VIEW.setZOrderMediaOverlay(true); YOUR_SURFACE_VIEW.setMirror(true); CallManager.getLocalProxyVideoSink().setTarget(YOUR_SURFACE_VIEW); ``` ```Kotlin CallManager.setupJoinCallViaLink() // Initialize surface view YOUR_SURFACE_VIEW.init(CallManager.getRootEglBase()!!.eglBaseContext, null) YOUR_SURFACE_VIEW.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_FILL) YOUR_SURFACE_VIEW.setZOrderMediaOverlay(true) YOUR_SURFACE_VIEW.setMirror(true) /* setting Target SurfaceViews to VideoSinks */ CallManager.getLocalProxyVideoSink()?.setTarget(YOUR_SURFACE_VIEW) ``` -------------------------------- ### Initiate Group Calls Source: https://www.mirrorfly.com/docs/audio-video/android/feature-make-a-call Methods to start group audio or video calls by providing a list of participant JIDs and the group identifier. ```Java CallManager.makeGroupVoiceCall(JID_LIST, GROUP_ID, (isSuccess, message) -> {}); CallManager.makeGroupVideoCall(JID_LIST, GROUP_ID, (isSuccess, message) -> {}); ``` ```Kotlin CallManager.makeGroupVoiceCall(JID_LIST, GROUP_ID, object : CallActionListener{ override fun onResponse(isSuccess: Boolean, message: String) {} }) CallManager.makeGroupVideoCall(JID_LIST, GROUP_ID, object : CallActionListener{ override fun onResponse(isSuccess: Boolean, message: String) {} }) ``` -------------------------------- ### POST /declineCall Source: https://www.mirrorfly.com/docs/audio-video/android/v2/quick-start Declines an incoming audio call. ```APIDOC ## POST /declineCall ### Description Declines an incoming audio call and notifies the caller. ### Method POST ``` -------------------------------- ### Initiate One-to-One Calls Source: https://www.mirrorfly.com/docs/audio-video/android/feature-make-a-call Methods to start a single user audio or video call. Requires the receiver's JID and a callback to handle the response status. ```Java CallManager.makeVoiceCall("TO_JID", (isSuccess, message) -> {}); CallManager.makeVideoCall("TO_JID", (isSuccess, message) -> {}); ``` ```Kotlin CallManager.makeVoiceCall("TO_JID", object : CallActionListener{ override fun onResponse(isSuccess: Boolean, message: String) {} }) CallManager.makeVideoCall("TO_JID", object : CallActionListener{ override fun onResponse(isSuccess: Boolean, message: String) {} }) ``` -------------------------------- ### Start Video Capture Source: https://www.mirrorfly.com/docs/audio-video/android/feature-join-call-via-link Initiates video capture for the current call. This method also enables the SDK to provide the video track via the `onLocalTrack` event in the `JoinCallListener`. ```APIDOC ## Start Video Capture ### Description Starts the video capture process for the current call. This method should be called when the user is ready to share their video. It also facilitates receiving the video track through the `onLocalTrack` event. ### Method POST ### Endpoint CallManager.startVideoCapture() ### Parameters None ### Required Permissions - `Manifest.permission.RECORD_AUDIO` - `Manifest.permission.CAMERA` - `Manifest.permission.READ_PHONE_STATE` ### Request Example ```java CallManager.startVideoCapture(); ``` ### Response #### Success Response (200) Indicates that video capture has been initiated successfully. The local video track will be available via the `onLocalTrack` event. ``` -------------------------------- ### Bind Call Service on Start Source: https://www.mirrorfly.com/docs/audio-video/android/quick-start Notifies the call SDK to remove the ongoing call notification when the call activity starts by calling `CallManager.bindCallService()`. This is typically done in the `onStart()` method. ```java CallManager.bindCallService(); ``` ```kotlin CallManager.bindCallService() ``` -------------------------------- ### Initialize Call SDK Source: https://www.mirrorfly.com/docs/audio-video/android/quick-start Configures the CallManager within the Application onCreate method. This setup includes defining the call activity, missed call listeners, and helper classes for notifications and display names. ```Java @Override public void onCreate() { super.onCreate(); CallManager.init(this); CallManager.setCallActivityClass(CALL_UI_ACTIVITY.class); CallManager.setMissedCallListener((isOneToOneCall, userJid, groupId, callType, userList) -> {}); CallManager.setCallHelper(new CallHelper() { @NonNull @Override public String getNotificationContent(@NonNull String callDirection) { return CallNotificationHelper.getNotificationMessage(); } @Override public void sendCallMessage(@NotNull GroupCallDetails details, @NotNull List users, @NotNull List invitedUsers) { CallMessenger.sendCallMessage(details, users, invitedUsers); } }); CallManager.setCallNameHelper(jid -> ContactManager.getDisplayName(jid)); } ``` ```Kotlin override fun onCreate() { super.onCreate() CallManager.init(this) CallManager.setCallActivityClass(CALL_UI_ACTIVITY::class.java) CallManager.setMissedCallListener(object : MissedCallListener { override fun onMissedCall(isOneToOneCall: Boolean, userJid: String, groupId: String?, callType: String, userList: ArrayList) {} }) CallManager.setCallHelper(object : CallHelper { override fun getNotificationContent(callDirection: String): String = CallNotificationHelper.getNotificationMessage() override fun sendCallMessage(details: GroupCallDetails, users: List, invitedUsers: List) { CallMessenger.sendCallMessage(details, users, invitedUsers) } }) CallManager.setCallNameHelper(object : CallNameHelper { override fun getDisplayName(jid: String): String = ContactManager.getDisplayName(jid) }) } ``` -------------------------------- ### Generate User JID Source: https://www.mirrorfly.com/docs/audio-video/android/v2/quick-start Utility method to generate a JID for a user based on their unique username obtained from the registration response. ```Java FlyUtils.getJid(USER_NAME); ``` ```Kotlin FlyUtils.getJid(USER_NAME) ``` -------------------------------- ### Initialize MirrorFly SDK Source: https://www.mirrorfly.com/docs/audio-video/angular/quick-start Initializes the SDK with a license key and a comprehensive set of callback listeners for handling call events and connection status. This is a mandatory step before performing any other SDK operations. ```javascript const incomingCallListener = (res) => {}; const callStatusListener = (res) => {}; const userTrackListener = (res) => {}; const muteStatusListener = (res) => {}; const missedCallListener = (res) => {}; const callSwitchListener = (res) => {}; const inviteUsersListener = (res) => {}; const mediaErrorListener = (res) => {}; const callSpeakingListener = (res) => {}; const callUsersUpdateListener = (res) => {}; const callUserJoinedListener = (res) => {}; const callUserLeftListener = (res) => {}; const callConnectionQualityListener = (res) => {}; const helper = {}; const initializeObj = { licenseKey: "XXXXXXXXXXXXXXXXX", callbackListeners: { connectionListener, incomingCallListener, callStatusListener, userTrackListener, muteStatusListener, missedCallListener, callSwitchListener, inviteUsersListener, mediaErrorListener, callSpeakingListener, callUsersUpdateListener, callUserJoinedListener, callUserLeftListener, callConnectionQualityListener, helper } }; await SDK.initializeSDK(initializeObj); ``` -------------------------------- ### Implement Speaking Indicators Source: https://www.mirrorfly.com/docs/audio-video/android/v2/call-features Handles speaking events to update the UI when a user starts or stops speaking. Provides the userJid and audio level for active speakers. ```Java @Override public void onUserSpeaking(@NonNull String userJid, int audioLevel) {} @Override public void onUserStoppedSpeaking(@NonNull String userJid) {} ``` ```Kotlin override fun onUserSpeaking(userJid: String, audioLevel: Int) {} override fun onUserStoppedSpeaking(userJid: String) {} ``` -------------------------------- ### Initialize MirrorFly SDK for Calls in Android Source: https://www.mirrorfly.com/docs/audio-video/android/v2/quick-start Initialize the MirrorFly SDK within your Application class's onCreate() method. This process requires your SDK license key and provides a callback to confirm successful initialization or report any errors. ```java ChatManager.initializeSDK("LICENSE_KEY", (isSuccess, throwable, data) -> { if(isSuccess){ Log.d("TAG", "initializeSDK success "); }else{ Log.d("TAG", "initializeSDK failed with reason "+data.get("message")); } }); ``` ```kotlin ChatManager.initializeSDK("LICENSE_KEY") { isSuccess, _, data -> if (isSuccess) { Log.d("TAG", "initializeSDK success ") } else { Log.d("TAG", "initializeSDK failed with error message"+ data["message"]) } } ``` -------------------------------- ### Initiate Voice and Video Calls with Mirrorfly SDK Source: https://www.mirrorfly.com/docs/audio-video/angular/making-a-call Methods to start one-to-one voice or video calls by providing the callee's JID. These methods require a metadata object and a callback function to handle the success or error response. ```javascript SDK.makeVoiceCall(['USER_JID'], null, metadata, (success, error) => { if (error) { // Error occured while making the call } if (success) { // Call has been made successfully } }); ``` ```javascript SDK.makeVideoCall(['USER_JID'], null, metadata, (success, error) => { if (error) { // Error occured while making the call } if (success) { // Call has been made successfully } }); ``` -------------------------------- ### Register New User Source: https://www.mirrorfly.com/docs/audio-video/angular/quick-start Registers a new user in the MirrorFly system to obtain credentials. Requires a unique identifier and supports optional metadata and forced session management. ```javascript await SDK.register("USER_IDENTIFIER"); ``` -------------------------------- ### Handle User Speaking Event (Java, Kotlin) Source: https://www.mirrorfly.com/docs/audio-video/android/call-features Callback method triggered when a user starts speaking in a call. Provides the user's ID and their audio level. ```Java @Override public void onUserSpeaking(@NonNull String userJid, int audioLevel) { } ``` ```Kotlin override fun onUserSpeaking(userJid: String, audioLevel: Int) { } ``` -------------------------------- ### Configure Call UI Activity in AndroidManifest Source: https://www.mirrorfly.com/docs/audio-video/android/v2/quick-start Defines the required activity configuration in the AndroidManifest.xml for the Call UI to handle incoming and ongoing calls correctly. ```XML ``` -------------------------------- ### Add Custom Application Class to AndroidManifest Source: https://www.mirrorfly.com/docs/audio-video/android/v2/quick-start Declare your custom Application class in the AndroidManifest.xml file. This ensures that your application uses the specified class for its application context, which is necessary for SDK initialization. ```xml ... ``` -------------------------------- ### Add MirrorFly SDK Dependencies for Android Source: https://www.mirrorfly.com/docs/audio-video/android/v2/quick-start Configure your project's Gradle files to include the MirrorFly SDK. This involves adding repository URLs in settings.gradle or root build.gradle and specifying the SDK dependency in the app/build.gradle file. Ensure `android.enableJetifier=true` is set in gradle.properties. ```gradle dependencyResolutionManagement { repositories { jcenter() maven { url "https://repo.mirrorfly.com/release" } } } allprojects { repositories { jcenter() maven { url "https://repo.mirrorfly.com/release" } } } ``` ```gradle dependencies { implementation 'com.mirrorfly.sdk:mirrorflysdk:7.13.32' } ``` ```properties android.enableJetifier=true ``` -------------------------------- ### Connect to MirrorFly Server Source: https://www.mirrorfly.com/docs/audio-video/angular/quick-start Establishes a connection to the MirrorFly server using the credentials obtained during the registration process. Successful connection returns a status code of 200. ```javascript await SDK.connect("USERNAME", "PASSWORD"); ``` -------------------------------- ### Make a Voice Call with Mirrorfly SDK Source: https://www.mirrorfly.com/docs/audio-video/android/v2/quick-start Initiates a one-to-one audio call to a specific user JID with optional metadata. Requires a CallActionListener to handle success or failure responses. ```Java CallManager.makeVoiceCall("TO_JID",CALL_METADATA, (isSuccess, flyException) -> { if(isSuccess){ Log.d("MakeCall","call success"); }else{ if(flyException!=null){ String errorMessage = flyException.getMessage(); Log.d("MakeCall","Call failed with error: "+errorMessage); } } }); ``` ```Kotlin CallManager.makeVoiceCall("TO_JID",CALL_METADATA, object : CallActionListener { override fun onResponse(isSuccess: Boolean, flyException: FlyException?) { if (isSuccess) { Log.d("MakeCall", "call success") } else { if (flyException != null) { val errorMessage = flyException.message Log.d("MakeCall", "Call failed with error: $errorMessage") } } } }) ``` -------------------------------- ### Initialize MirrorFly SDK in Angular Root Component Source: https://www.mirrorfly.com/docs/audio-video/angular/quick-start Steps to declare the SDK variable in the root component and initialize it within the ngOnInit lifecycle hook to enable call functionality. ```typescript declare var SDK: any; @Component({ // ... }) export class AppComponent implements OnInit { ngOnInit() { // Initialize SDK with license key and configuration SDK.init({ licenseKey: "YOUR_LICENSE_KEY" }); } } ``` -------------------------------- ### Initialize Call SDK in Application Class Source: https://www.mirrorfly.com/docs/audio-video/android/v2/quick-start Configures the CallManager within the onCreate method of the Application class. It sets the call activity, missed call listeners, and helpers for notifications and display names. ```Java @Override public void onCreate() { super.onCreate(); CallManager.setCallActivityClass(CALL_UI_ACTIVITY.class); CallManager.setMissedCallListener((isOneToOneCall, userJid, groupId, callType, userList, callMetaDataArray) -> { // show missed call notification }); CallManager.setCallHelper(new CallHelper() { @NonNull @Override public String getNotificationContent(@NonNull String callDirection, CallMetaData[] callMetaDataArray) { return CallNotificationHelper.getNotificationMessage(); } }); CallManager.setCallNameHelper(new CallNameHelper() { @NonNull @Override public String getDisplayName(@NonNull String jid, CallMetaData[] callMetaDataArray) { return ContactManager.getDisplayName(jid); } }); } ``` ```Kotlin override fun onCreate() { super.onCreate() CallManager.setCallActivityClass(CALL_UI_ACTIVITY::class.java) CallManager.setMissedCallListener(object : MissedCallListener { override fun onMissedCall(isOneToOneCall: Boolean, userJid: String, groupId: String?, callType: String, userList: ArrayList, callMetaDataArray: Array?) { // show missed call notification } }) CallManager.setCallHelper(object : CallHelper { override fun getNotificationContent(callDirection: String, callMetaDataArray: Array?): String { return CallNotificationHelper.getNotificationMessage() } }) CallManager.setCallNameHelper(object : CallNameHelper { override fun getDisplayName(jid: String, callMetaDataArray: Array?): String { return ContactManager.getDisplayName(jid) } }) } ``` -------------------------------- ### Register User with MirrorFly SDK Source: https://www.mirrorfly.com/docs/audio-video/android/v2/quick-start Registers a user with the MirrorFly chat server. The method accepts a unique user identifier and returns a callback containing success status, user JID, and metadata. ```Java FlyCore.registerUser(USER_IDENTIFIER, (isSuccess, throwable, data ) -> { if(isSuccess) { Boolean isNewUser = (Boolean) data.get("is_new_user"); String userJid = (String) data.get("userJid"); JSONObject responseObject = (JSONObject) data.get("data"); String username = responseObject.getString("username"); } else { // Register user failed } }); ``` ```Kotlin FlyCore.registerUser(USER_IDENTIFIER) { isSuccess, throwable, data -> if(isSuccess) { val isNewUser = data["is_new_user"] as Boolean val userJid = data["userJid"] as String val responseObject = data.get("data") as JSONObject val username = responseObject.getString("username") } else { // Register user failed } } ``` -------------------------------- ### Play Audio/Video Track in MirrorFly SDK Source: https://www.mirrorfly.com/docs/audio-video/angular/quick-start Provides sample JavaScript code to play audio or video tracks received from MirrorFly SDK callbacks. It demonstrates how to create a MediaStream from a track object and assign it to an HTML audio or video element. This is crucial for displaying received media streams during calls. ```javascript let stream = new MediaStream([track]); try { element.srcObject = stream; } catch (e) { try { element.src = URL.createObjectURL(stream); } catch (e) { console.error("Error attaching stream to element", e); } } ``` -------------------------------- ### Make a Voice Call with MirrorFly SDK Source: https://www.mirrorfly.com/docs/audio-video/angular/quick-start Initiates a voice call to a specified user JID. It utilizes a callback to handle the call status and potential errors. The `makeVoiceCall` method requires the callee's user JID, an optional group ID (null for one-to-one calls), and metadata. A `callStatusListener` callback is triggered upon successful initiation. ```javascript SDK.makeVoiceCall(['USER_JID'], null, metadata, (success, error) => { if (error) { // Error occured while making the call } if (success) { // Call has been made successfully } }); ``` -------------------------------- ### Initialize Chat SDK for Calls and Chat Functionality Source: https://www.mirrorfly.com/docs/audio-video/android/quick-start This code demonstrates how to initialize the Chat SDK in the `Application` class's `onCreate()` method. It uses the `ChatSDK.Builder` to set the domain base URL, license key, and specifies if it's a trial license. This initialization is critical for both call and chat functionalities. ```java //For chat logging LogMessage.enableDebugLogging(BuildConfig.DEBUG); ChatSDK.Builder() .setDomainBaseUrl(BuildConfig.SDK_BASE_URL) .setLicenseKey(BuildConfig.LICENSE) .setIsTrialLicenceKey(true) .build(); ``` ```kotlin //For chat logging LogMessage.enableDebugLogging(BuildConfig.DEBUG) ChatSDK.Builder() .setDomainBaseUrl(BuildConfig.SDK_BASE_URL) .setLicenseKey(BuildConfig.LICENSE) .setIsTrialLicenceKey(true) .build() ``` -------------------------------- ### POST /disconnectCall Source: https://www.mirrorfly.com/docs/audio-video/android/v2/quick-start Disconnects an ongoing or pending audio call. ```APIDOC ## POST /disconnectCall ### Description Disconnects the call before connection or ends an active conversation. ### Method POST ### Parameters #### Request Body - **CALLBACK** (CallActionListener) - Optional - Listener to receive disconnect success callback ``` -------------------------------- ### Configure Gradle Properties and Settings Source: https://www.mirrorfly.com/docs/audio-video/android/quick-start Sets up Jetifier and repository management in project-level configuration files. ```properties android.enableJetifier=true ``` ```gradle dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { google() mavenCentral() jcenter() } } ``` -------------------------------- ### Add SDK Third-Party Dependencies Source: https://www.mirrorfly.com/docs/audio-video/android/quick-start Lists the required third-party libraries including Dagger, Retrofit, Room, and Smack needed for the SDK to function correctly. ```gradle dependencies { configurations { all { exclude group: 'org.json', module: 'json' exclude group: 'xpp3', module: 'xpp3' } } implementation 'android.arch.lifecycle:extensions:1.1.1' annotationProcessor 'android.arch.lifecycle:compiler:1.1.1' implementation 'de.greenrobot:greendao:2.1.0' implementation 'com.google.code.gson:gson:2.8.1' implementation ('org.igniterealtime.smack:smack-android:4.4.6') implementation ('org.igniterealtime.smack:smack-tcp:4.4.6') implementation 'org.igniterealtime.smack:smack-im:4.4.6' implementation 'org.igniterealtime.smack:smack-extensions:4.4.6' implementation 'org.igniterealtime.smack:smack-sasl-provided:4.4.6' implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0' implementation 'androidx.multidex:multidex:2.0.1' implementation 'com.google.android.gms:play-services-location:17.0.0' api 'com.google.dagger:dagger:2.40.5' kapt 'com.google.dagger:dagger-compiler:2.40.5' api 'com.google.dagger:dagger-android:2.40.5' api 'com.google.dagger:dagger-android-support:2.40.5' kapt 'com.google.dagger:dagger-android-processor:2.40.5' implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.3' implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.3.3' implementation 'com.squareup.retrofit2:retrofit:2.6.1' implementation 'com.squareup.retrofit2:converter-gson:2.6.1' implementation 'com.squareup.okhttp3:okhttp:4.2.0' implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' implementation 'com.facebook.stetho:stetho-okhttp3:1.3.1' implementation 'com.squareup.okhttp3:logging-interceptor:3.14.3' implementation 'androidx.security:security-crypto:1.1.0-alpha03' implementation 'com.github.nkzawa:socket.io-client:0.6.0' implementation 'org.webrtc:google-webrtc:1.0.32006' implementation 'androidx.core:core-ktx:+' implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.31' implementation 'androidx.media:media:1.0.0' implementation 'androidx.room:room-runtime:2.2.5' kapt 'androidx.room:room-compiler:2.2.5' implementation "androidx.room:room-ktx:2.2.5" implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' kapt 'androidx.lifecycle:lifecycle-compiler:2.2.0' } ``` -------------------------------- ### Get Current Call Metadata Source: https://www.mirrorfly.com/docs/audio-video/android/v2/call-features Retrieves the metadata associated with the current active call. ```Java CallMetaData[] currentCallMetaData = CallManager.getCallMetaData(); ``` ```Kotlin val currentCallMetaData = CallManager.getCallMetaData() ``` -------------------------------- ### Register User with MirrorFly SDK Source: https://www.mirrorfly.com/docs/audio-video/android/quick-start This code snippet illustrates how to register a user with the MirrorFly SDK. It uses the `FlyCore.registerUser` method, which takes a unique user identifier and an optional callback. The callback handles the success or failure of the registration, providing user data or exception details. ```java FlyCore.registerUser(USER_IDENTIFIER, (isSuccess, throwable, data ) -> { if(isSuccess) { Boolean isNewUser = (Boolean) data.get("is_new_user"); JSONObject responseObject = (JSONObject) data.get("data"); // Get Username and password from the object } else { // Register user failed print throwable to find the exception details. } }); ``` ```kotlin FlyCore.registerUser(USER_IDENTIFIER) { isSuccess, throwable, data -> if(isSuccess) { val isNewUser = data["is_new_user"] as Boolean val responseObject = data.get("data") as JSONObject // Get Username and password from the object } else { // Register user failed print throwable to find the exception details. } } ``` -------------------------------- ### Get Call Logs Source: https://www.mirrorfly.com/docs/audio-video/angular/call-features Retrieve call log details by specifying the page number in the getCallLogs method. ```APIDOC ## Get Call Logs Details ### Description Retrieves call log details for a specific page. ### Method `getCallLogs(pageNumber)` ### Parameters #### Query Parameters - **pageNumber** (Number) - Required - The page number to retrieve logs from. ### Response Format ```json { "statusCode": "STATUS_CODE", "message": "ERROR|SUCCESS message", "data": { "callLogs": [ { "callMode": "onetoone|onetomany", "callState": 1, "callTime": 1687942398316000, "callType": "audio|video", "callerDevice": "WEB", "endTime": 1687942643614000, "fromUser": "FROM_USER_JID", "groupId": ""|GROUP_ID, "inviteUserList": "", "roomId": "937a8b33-fe33-4d93-b0e4-00716aed3cbb", "sessionStatus": "closed", "startTime": 1687942407172000, "toUser": "TO_USER_JID", "userList": "USER_JID" } ], "totalPages": "NUMBER" } } ``` #### Response Params - **data** (Object) - Object containing the array of call logs and total pages. - **statusCode** (Number) - Status code of the operation. - **message** (String) - Success or error message. ``` -------------------------------- ### Connect to Chat Server Source: https://www.mirrorfly.com/docs/audio-video/android/quick-start Establishes a connection to the chat server using the ChatManager. This method should be called only once in the application lifecycle and requires a ChatConnectionListener to handle connection states. ```Java ChatManager.connect(new ChatConnectionListener() { @Override public void onConnected() { // Write your success logic here } @Override public void onDisconnected() {} @Override public void onConnectionNotAuthorized() {} }); ``` ```Kotlin ChatManager.connect(object : ChatConnectionListener { override fun onConnected() { // Write your success logic here } override fun onDisconnected() {} override fun onConnectionNotAuthorized() {} }) ``` -------------------------------- ### GET /getUserName Source: https://www.mirrorfly.com/docs/audio-video/android/feature-join-call-via-link Retrieves the name of an unknown user who joined via a link using their user ID. ```APIDOC ## GET /getUserName ### Description Retrieves the display name of an unknown user who joined the call via a link. ### Method GET ### Endpoint CallManager.getUserName(USER_ID) ### Parameters #### Query Parameters - **USER_ID** (String) - Required - The unique identifier of the unknown user. ### Request Example ```java CallManager.getUserName("user_123"); ``` ### Response #### Success Response (200) - **String** - The name of the user associated with the provided ID. ``` -------------------------------- ### Configure Android Build Settings for MirrorFly Source: https://www.mirrorfly.com/docs/audio-video/android/quick-start This snippet shows how to configure the `app/build.gradle` file to include necessary build configurations for the MirrorFly SDK. It defines fields for the SDK base URL, license key, web chat login URL, and support email, which are crucial for the SDK's operation. ```gradle buildTypes { debug { buildConfigField 'String', 'SDK_BASE_URL', '"https://api-preprod-sandbox.mirrorfly.com/api/v1/"' buildConfigField 'String', 'LICENSE', '"xxxxxxxxxxxxxxxxxxxxxxxxx"' buildConfigField 'String', 'WEB_CHAT_LOGIN', '"https://webchat-preprod-sandbox.mirrorfly.com/"' buildConfigField "String", "SUPPORT_MAIL", '"contussupport@gmail.com"' } } ``` -------------------------------- ### Configure Build Gradle for MirrorFly SDK Source: https://www.mirrorfly.com/docs/audio-video/android/quick-start Configures the app-level build.gradle file to include necessary plugins, compiler options, and packaging exclusions required by the MirrorFly SDK. ```gradle plugins { id 'kotlin-android' id 'kotlin-kapt' } android { compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } kotlinOptions { jvmTarget = '1.8' } packagingOptions { exclude 'META-INF/AL2.0' exclude 'META-INF/DEPENDENCIES' exclude 'META-INF/LICENSE' exclude 'META-INF/LICENSE.txt' exclude 'META-INF/license.txt' exclude 'META-INF/NOTICE' exclude 'META-INF/NOTICE.txt' exclude 'META-INF/notice.txt' exclude 'META-INF/ASL2.0' exclude 'META-INF/LGPL2.1' exclude("META-INF/*.kotlin_module") } } ``` -------------------------------- ### Permission Management Source: https://www.mirrorfly.com/docs/audio-video/android/quick-start Methods to verify required runtime permissions for audio and notification functionality. ```APIDOC ## Permission Management ### Description Check for required runtime permissions including audio recording, phone state, and notifications. ### Methods - **CallManager.isAudioCallPermissionsGranted()**: Checks for RECORD_AUDIO and READ_PHONE_STATE. - **CallManager.isNotificationPermissionsGranted()**: Checks for POST_NOTIFICATIONS (Android 13+). ### Notes - Android 12+ requires BLUETOOTH_CONNECT for audio routing. - If permissions are not granted, `isSuccess` will return `false` in call callbacks. ``` -------------------------------- ### Get Current Contact Sync State Source: https://www.mirrorfly.com/docs/audio-video/android/v2/users Retrieves the current contact synchronization state directly from the LiveData object. ```Java Result contactSyncStateResult = FlyCore.getContactSyncState().getValue(); ``` ```Kotlin val contactSyncStateResult : Result = FlyCore.contactSyncState.value!! ``` -------------------------------- ### Generate User JID Source: https://www.mirrorfly.com/docs/audio-video/angular/quick-start Utility method to generate a unique JID for a user based on their username, which is required for messaging and communication. ```javascript const userJid = SDK.getJid(USER_NAME); ``` -------------------------------- ### Manage Call Activity Lifecycle Source: https://www.mirrorfly.com/docs/audio-video/android/v2/quick-start Methods to configure the call activity and bind/unbind the call service during the activity lifecycle to manage notifications. ```Java CallManager.configureCallActivity(ACTIVITY); CallManager.bindCallService(); CallManager.unbindCallService(); ``` ```Kotlin CallManager.configureCallActivity(ACTIVITY) CallManager.bindCallService() CallManager.unbindCallService() ``` -------------------------------- ### Get Session Identifiers Source: https://www.mirrorfly.com/docs/audio-video/android/v2/other-call-features Retrieves the current user's ID or the group ID associated with the ongoing call session. ```Java String userId = CallManager.getCurrentUserId(); String groupId = CallManager.getGroupID(); ``` ```Kotlin val userId : String = CallManager.getCurrentUserId() val groupId : String = CallManager.getGroupID() ``` -------------------------------- ### Get Group ID of Current Call - Java & Kotlin Source: https://www.mirrorfly.com/docs/audio-video/android/other-call-features Retrieves the group ID of the ongoing call. This method is accessible in Java and Kotlin. ```java String groupId = CallManager.getGroupID(); ``` ```kotlin val groupId : String = CallManager.getGroupID() ``` -------------------------------- ### Configure Call Activity on Create Source: https://www.mirrorfly.com/docs/audio-video/android/quick-start Initializes the call activity by calling `CallManager.configureCallActivity()` within the activity's `onCreate()` method. This step is crucial for setting up the call SDK environment. ```java CallManager.configureCallActivity(ACTIVITY); ``` ```kotlin CallManager.configureCallActivity(ACTIVITY) ``` -------------------------------- ### Get Current User ID - Java & Kotlin Source: https://www.mirrorfly.com/docs/audio-video/android/other-call-features Retrieves the user ID that was initially passed to the SDK. This method is available for both Java and Kotlin. ```java String userId = CallManager.getCurrentUserId(); ``` ```kotlin val userId : String = CallManager.getCurrentUserId() ``` -------------------------------- ### Get Call Link for Android Source: https://www.mirrorfly.com/docs/audio-video/android/v2/feature-join-call-via-link Retrieves the unique call link string during an ongoing audio/video call to share with other participants. ```Java CallManager.getCallLink(); ``` ```Kotlin CallManager.getCallLink() ``` -------------------------------- ### POST /joinCall Source: https://www.mirrorfly.com/docs/audio-video/android/feature-join-call-via-link Initiates the process of joining an ongoing audio or video call. ```APIDOC ## POST /joinCall ### Description Starts the joining process for an ongoing audio/video call. ### Method POST ### Endpoint CallManager.joinCall() ### Parameters #### Request Body - **JoinCallActionListener** (Object) - Required - Callback interface to handle success and failure events. ### Request Example ```java CallManager.joinCall(new JoinCallActionListener() { @Override public void onSuccess() {} @Override public void onFailure(@NonNull Error error) {} }); ``` ### Response #### Success Response (200) - **onSuccess** (void) - Triggered when the user successfully joins the call. #### Error Response (400) - **onFailure** (Error) - Triggered if the join operation fails. ``` -------------------------------- ### Answer an Incoming Voice Call Source: https://www.mirrorfly.com/docs/audio-video/android/v2/quick-start Accepts an incoming audio call from another user. This method should be triggered by the user's interaction with the call UI. ```Java CallManager.answerCall((isSuccess, flyException) -> { if(isSuccess){ Log.d("AnswerCall","call answered success"); }else{ if(flyException!=null){ String errorMessage = flyException.getMessage(); Log.d("AnswerCall","Call answered failed with error: "+errorMessage); } } }); ``` ```Kotlin CallManager.answerCall(object : CallActionListener { override fun onResponse(isSuccess: Boolean, flyException: FlyException?) { if (isSuccess) { Log.d("AnswerCall", "call answered success") } else { if (flyException != null) { val errorMessage = flyException.message Log.d("AnswerCall", "Call answered failed with error: $errorMessage") } } } }) ``` -------------------------------- ### Configure Video Bitrate Settings Source: https://www.mirrorfly.com/docs/audio-video/android/v2/call-features Methods to set the maximum and minimum video bitrates for call optimization. The SDK uses these values to adapt to network conditions. ```Java CallManager.setMaxVideoBitrate(MAX_BITRATE); CallManager.setMinVideoBitrate(MIN_BITRATE); ``` ```Kotlin CallManager.setMaxVideoBitrate(MAX_BITRATE) CallManager.setMinVideoBitrate(MIN_BITRATE) ``` -------------------------------- ### Get Call Link Source: https://www.mirrorfly.com/docs/audio-video/android/feature-join-call-via-link Retrieve the unique call link for an ongoing audio/video call. This link can be shared with other users to allow them to join the call. ```APIDOC ## GET Call Link ### Description Retrieves the call link for an ongoing audio/video call. This link can be shared with other users to join the call. ### Method GET ### Endpoint CallManager.getCallLink() ### Parameters None ### Request Example ```java String callLink = CallManager.getCallLink(); ``` ### Response #### Success Response (200) - **callLink** (String) - The unique URL for the ongoing call. #### Response Example ```json { "callLink": "https://your-domain.com/call/abcdef12345" } ``` ``` -------------------------------- ### POST /makeVoiceCall Source: https://www.mirrorfly.com/docs/audio-video/android/quick-start Initiates a one-to-one voice call to a specified user. ```APIDOC ## POST /makeVoiceCall ### Description Allows users to initiate a one-to-one audio call with another SDK user. ### Parameters - **TO_JID** (String) - Required - The JID of the call receiver. - **CALLBACK** (CallActionListener) - Required - Callback to observe the action status. ### Request Example CallManager.makeVoiceCall("TO_JID", (isSuccess, message) -> { }); ### Response #### Success Response (200) - **isSuccess** (Boolean) - Indicates if the call initiation was successful. - **message** (String) - Status message regarding the call request. ### Error Handling - **403 Exception**: Thrown if the one-to-one call feature is unavailable for your current plan. ``` -------------------------------- ### Default Video Resolution Adjuster Implementation (Kotlin) Source: https://www.mirrorfly.com/docs/audio-video/android/call-features Provides a default implementation for adjusting video resolution based on user count using Kotlin. Resolutions are in pixels and vary for 1-4 users and beyond. ```Kotlin /** * Default implementation of video width height adjuster */ object DefaultVideoWidthHeightAdjuster : VideoWidthHeightAdjuster { override fun getVideoHeightConstraint(usersCount: Int): Int { return when (usersCount) { 1, 2 -> 640 //px 3 -> 320 4 -> 240 else -> 160 } } override fun getVideoWidthConstraint(usersCount: Int): Int { return when (usersCount) { 1, 2 -> 360 //px 3 -> 240 4 -> 160 else -> 120 } } } ``` -------------------------------- ### Retrieve User List with Pagination and Search (Java, Kotlin) Source: https://www.mirrorfly.com/docs/audio-video/android/users Fetches a list of registered users with support for pagination and searching. It returns the total number of pages available. User presence and profile updates are only reflected after a message is sent to the user. ```Java FlyCore.getUserList(PAGE_NUMBER, PER_PAGE_RESULT_SIZE, SEARCH_TERM, (isSuccess, throwable, data) -> { if (isSuccess) { ArrayList userList = (ArrayList) data.get("data"); Integer totalPage = (Integer) data.get("total_page"); //User list fetched. Update the UI } else { //Get user list failed print throwable to find the details } }); ``` ```Kotlin FlyCore.getUserList(PAGE_NUMBER, PER_PAGE_RESULT_SIZE, SEARCH_TERM, flyCallback = { isSuccess, error, data -> if (isSuccess) { val userList : ArrayList = data["data"] as ArrayList val totalPage = data["total_page"] as Int //User list fetched. Update the UI } else { //Get user list failed print throwable to find the details } }) ``` -------------------------------- ### Initiate Video Call with Metadata Source: https://www.mirrorfly.com/docs/audio-video/android/v2/feature-make-a-call Initiates a one-to-one video call to a specific JID, including metadata. Requires camera and audio permissions to function correctly. ```java CallManager.makeVideoCall("TO_JID", CALL_METADATA, (isSuccess, flyException) -> { if(isSuccess){ Log.d("MakeCall","call success"); } else { if(flyException!=null){ String errorMessage = flyException.getMessage(); Log.d("MakeCall","Call failed with error: "+errorMessage); } } }); ``` ```kotlin CallManager.makeVideoCall("TO_JID", CALL_METADATA, object : CallActionListener { override fun onResponse(isSuccess: Boolean, flyException: FlyException?) { if (isSuccess) { Log.d("MakeCall", "call success") } else { if (flyException != null) { val errorMessage = flyException.message Log.d("MakeCall", "Call failed with error: $errorMessage") } } } }) ``` -------------------------------- ### Getting Missed Call Count Source: https://www.mirrorfly.com/docs/audio-video/android/v2/call-features Retrieve the count of unread missed calls stored locally by the SDK. This method allows you to display the number of missed calls to the user. ```APIDOC ## Getting Missed Call Count ### Description Retrieves the count of unread missed calls from the SDK's local database. ### Method `CallLogManager.getUnreadMissedCallCount()` ### Endpoint N/A (This is an SDK method) ### Response #### Success Response (200) - **count** (Integer) - The number of unread missed calls. ### Request Example ```java int missedCallCount = CallLogManager.getUnreadMissedCallCount(); ``` ``` -------------------------------- ### Import SDK AAR Libraries Source: https://www.mirrorfly.com/docs/audio-video/android/quick-start Defines the local AAR library dependencies within the app-level build.gradle file. ```gradle dependencies { implementation files('libs/appbase.aar') implementation files('libs/flycommons.aar') implementation files('libs/flynetwork.aar') implementation files('libs/flydatabase.aar') implementation files('libs/videocompression.aar') implementation files('libs/xmpp.aar') implementation files('libs/flywebrtc.aar') } ``` -------------------------------- ### Fetch and Upload Call Logs (Java, Kotlin) Source: https://www.mirrorfly.com/docs/audio-video/android/v2/other-call-features Fetches call logs from the local database and updates them to the server. This method synchronizes call log details. ```java CallLogManager.uploadUnSyncedCallLogs(); ``` ```kotlin CallLogManager.uploadUnSyncedCallLogs() ``` -------------------------------- ### Get All Users Video Mute State Source: https://www.mirrorfly.com/docs/audio-video/angular/helpers Retrieves the collective video mute state for all participants in the current call. Returns a boolean indicating if all users are muted. ```javascript SDK.isAllUsersVideoMuted(); ``` -------------------------------- ### Get User Call Status Source: https://www.mirrorfly.com/docs/audio-video/angular/helpers Fetches the current connection status of a specific user by their JID. Returns statuses such as 'ringing', 'connecting', 'connected', 'reconnecting', or 'disconnected'. ```javascript SDK.getUserCallStatus('USER_JID'); ```