DirectCallDelegate

@objc(SBCDirectCallDelegate)
public protocol DirectCallDelegate : AnyObject

DirectCallDelegate methods are invoked along the flow of the call. You should implement the delegate methods to adjust your app according to the changes to the states of the call.

override func viewDidLoad() {
   // ...
   call.delegate = self
}

// ...

Since

1.0.0
  • Called when the callee has accepted the call, but not yet connected to media streams.

    Since

    1.0.0

    Declaration

    Swift

    @objc
    optional func didEstablish(_ call: DirectCall)
  • Called when media streams between the caller and callee are connected and audio/video is enabled.

    func didConnect(_ call: DirectCall) {
       self.endButton.isEnabled = true
    }
    

    Since

    1.0.0

    Declaration

    Swift

    @objc
    func didConnect(_ call: DirectCall)
  • Called when DirectCall begins attempting to reconnect to the server after losing connection.

    Since

    1.0.0

    Declaration

    Swift

    @objc
    optional func didStartReconnecting(_ call: DirectCall)
  • Called when DirectCall successfully reconnects to the server.

    Since

    1.0.0

    Declaration

    Swift

    @objc
    optional func didReconnect(_ call: DirectCall)
  • Called when the remote user changes audio settings.

    class MyClass: DirectCallDelegate {
        ...
        func didRemoteAudioSettingsChange(_ call: DirectCall) {
            if (call.isRemoteAudioEnabled) {
                // The peer has been unmuted.
            } else {
                // The peer has been muted.
            }
        }
        ...
    }
    

    Since

    1.0.0

    Declaration

    Swift

    @objc
    optional func didRemoteAudioSettingsChange(_ call: DirectCall)
  • Called when the peer changes video settings.

    Since

    1.0.0

    Declaration

    Swift

    @objc
    optional func didRemoteVideoSettingsChange(_ call: DirectCall)
  • Called when the call has ended.

    func didEnd(_ call: DirectCall) {
       self.dismiss(animated: true, completion: nil)
    }
    

    Since

    1.0.0

    Declaration

    Swift

    @objc
    func didEnd(_ call: DirectCall)
  • Called when the audio device has been changed. To change audio route, see routePickerView(frame:)

    func didAudioDeviceChange(_ call: DirectCall, session: AVAudioSession, previousRoute: AVAudioSessionRouteDescription, reason: AVAudioSession.RouteChangeReason) {
       // You can get current audio I/O, available inputs from the session. You can also set preferred input.
    
       let currentRoute = session.currentRoute
       let outputs = currentRoute.outputs
       let inputs = currentRoute.inputs
    
       // Update your UI according to the changes to the audio devices, such as external speaker, bluetooth, and built-in speaker.
    }
    

    Since

    1.0.0

    See

    See Also:

    Declaration

    Swift

    @objc
    optional func didAudioDeviceChange(_ call: DirectCall, session: AVAudioSession, previousRoute: AVAudioSessionRouteDescription, reason: AVAudioSession.RouteChangeReason)

    Parameters

    call

    DirectCall object

    session

    A shared instance of AVAudiosession. You can get a current audio route containing inputs and outputs descriptions.

    previousRoute

    A previous audio route.

    reason

    The reason of system audio change.

  • Called when the custom items of the call are updated.

    Since

    1.0.0

    Declaration

    Swift

    @objc
    optional func didUpdateCustomItems(call: DirectCall, updatedKeys: [String])

    Parameters

    call

    DirectCall that has updated custom items.

    updatedKeys

    keys that have updated.

  • Called when the custom items of the call are deleted.

    Since

    1.0.0

    Declaration

    Swift

    @objc
    optional func didDeleteCustomItems(call: DirectCall, deletedKeys: [String])

    Parameters

    call

    DirectCall that has deleted custom items.

    deletedKeys

    keys that have deleted.

  • Called when the other user’s recording status is changed. You can check the recording status of the other user with DirectCall.remoteRecordingStatus.

    Since

    1.4.0

    Declaration

    Swift

    @objc
    optional func didRemoteRecordingStatusChange(_ call: DirectCall)

    Parameters

    call

    DirectCall that has updated remote recording status.

  • The local or remote user has put a call on hold or removed a hold from a call and their hold status has changed.

    Since

    1.8.0

    Declaration

    Swift

    @objc
    optional func didUserHoldStatusChange(_ call: DirectCall, isLocalUser: Bool, isUserOnHold: Bool)

    Parameters

    call

    DirectCall that has updated user hold status

    isLocalUser

    Returns true if the user whose hold status changed is local user

    isUserOnHold

    Returns true if the user’s hold status is changed to on hold