> For the complete documentation index, see [llms.txt](https://docs.facephi.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.facephi.com/docs.facephi-en/sdks/sdk-mobile/android-sdk/componentes-modulos/videollamada.md).

# Video Call - Videocall

## Introduction <a href="#id-1-introduccion" id="id-1-introduccion"></a>

The video call is carried out using the ***VideoCall Component***.

This component manages communication between a user and an agent (video assistance). Its main processes are:

* Internal management of cameras, microphone, and permissions.
* Connection to services.

The [Simplified Launch](https://docs.facephi.com/docs.facephi-en/sdks/sdk-mobile/android-sdk/inicializacion/lanzamiento-simplificado.md) section describes the steps required for basic SDK integration. This section provides information about launching this component.

## Dependency

The component-specific dependency is:

```
implementation "com.facephi.androidsdk:videocall_component:$version"
```

***

## Available Controllers

| **Controller**          | **Description**                          |
| ----------------------- | ---------------------------------------- |
| VideoCallController     | Main video call controller               |
| StopVideoCallController | Stop screen sharing and the ongoing call |

## Simplified Launch <a href="#id-4-lanzamiento-simplificado" id="id-4-lanzamiento-simplificado"></a>

Once the SDK has been initialized and a new operation has been created, the component can be launched. You can use any of its controllers to execute its functionality.

Launch:

```kotlin
val response = SDKController.launch(
    VideoCallController(VideoCallConfigurationData(...))
)
when (response) {
    is SdkResult.Error -> Napier.d("ERROR - ${response.error.name}")
    is SdkResult.Success -> response.data
}
```

## Basic Configuration <a href="#id-5-configuracion-basica" id="id-5-configuracion-basica"></a>

To launch this component, you must create a *VideoCallConfigurationData* object, which contains the component controller's configuration.

The required basic configuration does not require any parameters:

```kotlin
VideoCallConfigurationData()
```

## Receiving the result

The launch returns information in SdkResult format. You can distinguish between a successful launch and an unsuccessful one:

```kotlin
when (response) {
    is SdkResult.Error -> Napier.d("ERROR - ${response.error}")
    is SdkResult.Success -> response.data
}
```

### Receiving errors <a href="#id-61-recepcion-de-errores" id="id-61-recepcion-de-errores"></a>

Errors are returned as a 'VideoCallError' object.

List of errors:

* `ACTIVITY_RESULT_MSG_ERROR` (`VCL_707`): The activity result is invalid
* `APPLICATION_CONTEXT_ERROR` (`VCL_708`): The required application context is null
* `CANCEL_BY_USER` (`VCL_000`): The user canceled the process
* `CANCEL_LAUNCH` (`VCL_007`): The SDK was canceled
* `COMPONENT_LICENSE_ERROR` (`VCL_002`): The component license is invalid
* `EMPTY_LICENSE` (`VCL_003`): The license string is empty
* `FETCH_DATA_ERROR` (`VCL_709`): Error retrieving the result
* `FLOW_ERROR` (`VCL_716`): Error in the flow process
* `INITIALIZATION_ERROR` (`VCL_004`): Initialization error
* `INTERNAL_ERROR` (`VCL_712`): Internal error
* `MANAGER_NOT_INITIALIZED` (`VCL_710`): Managers are null
* `NETWORK_CONNECTION` (`VCL_700`): Internet connection error
* `NO_DATA_ERROR` (`VCL_005`): Input data is null
* `OPERATION_NOT_CREATED` (`VCL_006`): No operation is in progress
* `PERMISSION_ERROR` (`VCL_711`): The user denied the permissions
* `SCREEN_SHARING_PERMISSION_ERROR` (`VCL_701`): The user denied screen-sharing permission
* `SOCKET_ERROR` (`VCL_702`): Error connecting to services
* `TIMEOUT` (`VCL_001`): Process timeout
* `VIDEO_ERROR` (`VCL_705`): Error processing video
* `UNKNOWN_ERROR` (`VCL_703`): Unknown error
* `VIDEO_CALL_ACTIVE` (`VCL_704`): Cannot start because a video call is already active
* `VIDEO_RECORDING_ACTIVE` (`VCL_706`): Cannot start because video recording is active

### Receiving the successful result - *data* <a href="#id-62-recepcion-del-resultado-correcto-data" id="id-62-recepcion-del-resultado-correcto-data"></a>

In the SdkResult.Success part - *data*, we will have the *VideoCallResult* class, which will have a single property.

* `sharingScreen`: Indicates whether the call is still active with screen sharing enabled.

When the result is Success and the flag *sharingScreen* is active, screen sharing can be enabled.

***

## Advanced information <a href="#id-7-informacion-avanzada" id="id-7-informacion-avanzada"></a>

This section provides additional information about the component.

### Advanced component configuration <a href="#id-71-configuracion-avanzada-del-componente" id="id-71-configuracion-avanzada-del-componente"></a>

To launch this component, you must create a *VideoCallConfigurationData* object, which contains the component controller's configuration.

All the fields that are part of this class are detailed below.

The fields included in the configuration usually **do not need to be provided** because they are populated internally using the license in use.

These fields are usually provided **only** when the **server** is **On-Premise**.

* `url`: Video socket path (`String?`, default `null`).
* `apiKey`: API key required to connect to the video socket (`String?`, default `null`).
* `tenantId`: Tenant identifier that refers to the current customer, required to connect to the video service (`String?`, default `null`).
* `activateScreenSharing`: Enable the screen-sharing option during the call (`Boolean`, default `false`).
* `timeout`: Timeout for an agent to answer the call (ms) (`Long`, default `60000`).

### Screen sharing <a href="#id-72-compartir-pantalla" id="id-72-compartir-pantalla"></a>

When the user enables screen sharing, the controller receives the result with "sharingScreen = true". This indicates that the call is still in progress.

```kotlin
val result = SDKController.launch(
    VideoCallController(VideoCallConfigurationData(activateScreenSharing = true)))

when (result) {
    is SdkResult.Error -> {
        Napier.d("VideoCall: ERROR - ${result.error.name}")
    }

    is SdkResult.Success -> {
            Napier.d("VideoCall: OK - ScreenSharing: ${result.data.sharingScreen}")
        }
    }

```

To end the call, use the StopVideoCallController controller.

```kotlin
val controller = StopVideoCallController()

controller.setOutput { state ->
    Napier.d { "VIDEOCALL: SCREEN SHARING STATE: ${state.name}" }
}
viewModelScope.launch {
    SDKController.launch(controller)
}
```

The possible states are:

```kotlin
AGENT_HANGUP,
PERMISSION_ERROR,
NETWORK_CONNECTION_ERROR,
UNKNOWN_ERROR,
SHARING,
CANCEL_BY_USER,
FINISH
```

The state indicating that the call has fully ended is FINISH.

***

## Customization of the component <a href="#id-8-personalizacion-del-componente" id="id-8-personalizacion-del-componente"></a>

Apart from the changes that can be made at the SDK level (explained in the document [SDK Customization](https://docs.facephi.com/docs.facephi-en/sdks/sdk-mobile/android-sdk/personalizacion.md)), this particular component also allows its interface to be modified.

### Text <a href="#id-81-textos" id="id-81-textos"></a>

The text can be customized by adding an XML resource file to the client application and overriding the default values.

```kotlin

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <!-- Video call -->
    <string name="video_widget_call_component_text_waiting_agent_title">Connecting with an assistant...</string>
    <string name="video_widget_call_component_local">You</string>
    <string name="video_widget_call_component_agent">Assistant</string>
    <string name="video_widget_call_component_exit">Exit</string>
    <string name="video_widget_call_component_text_finish">Video assistance is complete</string>
    <string name="video_widget_call_component_phone_button_alt">Phone</string>
    <string name="video_widget_call_component_switch_button_alt">Switch camera</string>
    <string name="video_widget_call_component_restart">RETRY</string>
    <string name="video_widget_call_component_timeout_title">Time exceeded</string>
    <string name="video_widget_call_component_timeout_desc">Unable to connect with an agent.</string>
    <string name="video_widget_call_component_internal_error_title">There was a technical problem</string>
    <string name="video_widget_call_component_internal_error_desc">An assistant could not be reached.</string>
    <string name="video_widget_call_component_close_button_alt">Close</string>
    <string name="video_widget_call_component_back_button_alt">Back</string>
    <string name="video_widget_call_component_exit_alert_question">Do you want to end the call?</string>
    <string name="video_widget_call_component_exit_alert_finish">End</string>
    <string name="video_widget_call_component_exit_alert_accept">Accept</string>
    <string name="video_widget_call_component_exit_alert_cancel">Cancel</string>
    <string name="video_widget_call_component_skip">SKIP</string>
    <string name="video_widget_call_component_share_button_alt">Share screen</string>
</resources>

```

### Colors <a href="#id-82-colores" id="id-82-colores"></a>

```xml
<color name="colorVideoCallActionsBackground">#30333d</color>
<color name="colorVideoCallButtonBackground">#FF526080</color>
```

### Animations <a href="#id-83-animaciones" id="id-83-animaciones"></a>

To modify the SDK animations (Lottie), include the animations with the same names in the application's res/raw/ folder.

```
video_call_anim_waiting.json
```
