# Video Conference

The Video Conference module connects the user to a live agent over video and audio to conduct an identity verification interview. The agent can request that documents be shown on camera and complete any verifications needed to meet regulatory or business requirements. The SDK manages the queue, waiting-time updates, and the call UI. It requires camera and microphone access. See [Add Required Permissions](https://developer.incode.com/docs/setup-ios#add-required-permissions).

For an overview of this module and how it works, see [Video Conference](https://developer.incode.com/docs/video-conference).

How you use this module depends on your integration pattern. When the app defines the steps in code, you add the module to an `IncdOnboardingFlowConfiguration` as shown below; when the flow is defined in Dashboard, you reference it and let the back end drive the steps. See [Integration Approaches](https://developer.incode.com/docs/ios-flow-configuration).

**Availability:** The `-vc` variant. Calling it from a variant without `-vc` triggers a runtime variant assertion. This variant requires the vendored `OpenTok` dependency. See [Installation](https://developer.incode.com/docs/setup-ios).

**UI:** standalone.

Use this module when:

- Your verification process includes a human agent reviewing the user live.
- The agent needs to ask the user to show documents on camera during the call.
- You need queue and waiting-room behavior built into the flow.

## Add Video Conference

1. Add the following modules before Video Conference. The SDK throws if Video Conference is not placed after these modules.
   - A [Selfie](https://developer.incode.com/docs/module-selfie) module
   - Either of the following, with its matching validation:
     - An [ID Capture](https://developer.incode.com/docs/module-id-scan) module, validated with [Face Match](https://developer.incode.com/docs/module-face-match)
     - A [QR Scan](https://developer.incode.com/docs/module-qr-scan) module, validated with [Government Validation](https://developer.incode.com/docs/module-government-validation)
2. Add the module with `addVideoConference()`:
   ```swift
   // Default configuration
   flowConfig.addVideoConference()

   // Mute the microphone when the user enters the conference
   flowConfig.addVideoConference(disableMicOnCallStarted: true)
   ```

### Example

The example below adds Video Conference after the prerequisite capture and validation modules, mutes the microphone on entry, and listens for queue position, estimated wait time, and conference completion through `IncdOnboardingVideoConferenceDelegate`.

```swift
// Build the flow: prerequisite capture and validation modules first, then Conference.
flowConfig.addSelfieScan()
// ... add ID Capture + Face Match, or QR Scan + Government Validation ...
flowConfig.addVideoConference(disableMicOnCallStarted: true)

extension MyViewController: IncdOnboardingVideoConferenceDelegate {
    func onEstimatedWaitingTime(_ waitingTimeInSeconds: Int) {
        // Show the estimated wait before the agent connects.
    }

    func onQueuePositionChanged(_ newQueuePosition: Int) {
        // The user's position in the queue.
    }

    func onVideoConferenceCompleted(_ success: Bool, _ error: VideoConferenceError?) {
        // The video conference has finished.
    }

    func onCaptchaCompleted(_ result: CaptchaResult) {
        // Captcha step result, when presented.
    }
}
```

## Configuration Options

Configure the module with `addVideoConference()`.

| Option                    | Type    | Notes                                                                                          |
| ------------------------- | ------- | ---------------------------------------------------------------------------------------------- |
| `disableMicOnCallStarted` | `Bool?` | When `true`, the user's microphone is muted when they enter the conference. Defaults to `nil`. |

A `ConferenceQueue` can be supplied through `IncdOnboardingSessionConfiguration(queue:)` to route the user to a specific queue once the user reaches this step; if no queue is specified, the user goes to the default queue.

## Result

Video Conference does not deliver a result payload. Completion is signaled by a delegate callback:

```swift
func onVideoConferenceCompleted(_ success: Bool, _ error: VideoConferenceError?)
```

This callback is declared on both `IncdOnboardingDelegate` and `IncdOnboardingVideoConferenceDelegate`. While the user waits for an agent, `IncdOnboardingVideoConferenceDelegate` also delivers `onEstimatedWaitingTime(_:)` and `onQueuePositionChanged(_:)`.

Errors surface through the `error` parameter as a `VideoConferenceError`, which wraps an underlying `IncdError`.

<br />
