RTCClient

class RTCClient : NSObject
extension RTCClient: RTCClientDelegate
extension RTCClient: RTCPeerConnectionDelegate

Class that manage all the RTC part of the SDK. It is used to setup the RTC connection of the call, generate offer/answer and handle in-call actions (mute, speaker on/off).

  • Default stun server

    Declaration

    Swift

    private let stunServerURL: String
  • Default media constraint. Set to only receive audio.

    Declaration

    Swift

    let mediaConstraints: RTCMediaConstraints
  • RTC peer connection.

    Declaration

    Swift

    var peerConnection: RTCPeerConnection?
  • RTC peer connection factory.

    Declaration

    Swift

    var connectionFactory: RTCPeerConnectionFactory?
  • RTC local stream.

    Declaration

    Swift

    var audioLocalStream: RTCMediaStream?
  • Undocumented

    Declaration

    Swift

    private let audioQueue: DispatchQueue
  • Undocumented

    Declaration

    Swift

    private let rtcAudioSession: RTCAudioSession
  • Undocumented

    Declaration

    Swift

    private var delegate: RTCClientDelegate?
  • The RTC Client initialization perfom two main tasks. It setups the RTC peer connection first then configure the RTC ausio session.

    Declaration

    Swift

    override init()
  • Setup the RTC peer connection. RTC configuration is locked for the moment and a default stun server is provided. Also create an audio local stream to add it to the peer connection.

    Declaration

    Swift

    func setupRTCPeerConnection()
  • Configures the audio session for the WebRTC connection setting the AVAudioSession mode to voice chat.

    Declaration

    Swift

    private func configureAudioSession()
  • Creates and configure a local stream that will be used linked to the peer connection.

    Declaration

    Swift

    private func createLocalStream() -> RTCMediaStream?
  • Add or remove local stream to the peer connection that enable microphone input.

    Declaration

    Swift

    public func setMicrophoneEnabled(_ enabled: Bool)

    Parameters

    enabled

    Boolean that defines whether the microphone is enabled or not.

SDP Handlers

  • Sets a SDP (RTCSessionDescription) as local session description.

    Declaration

    Swift

    func setLocalDescription(sessionDescription: RTCSessionDescription)

    Parameters

    sessionDescription

    The SDP that will be set as local SDP.

  • Sets a SDP (RTCSessionDescription) as remote session description.

    Declaration

    Swift

    func setRemoteDescription(type: RTCSdpType, sdp: String)

    Parameters

    type

    Is either an .Offer or .Answer according to the RTC Message.

    sdp

    The SDP that will be set as local SDP.

  • Uses the WebRTC peer connection to create an answer in order to respond to a received offer and initialize a call.

    Declaration

    Swift

    func createAnswer()
  • Uses the WebRTC peer connection to create an offer in order to initiate a call.

    Declaration

    Swift

    func createOffer() -> Promise<Void>

    Return Value

    A promise that is fulfilled when the offer is successfully created and the local SDP has been setted.

  • Adds a candidate to the peer connection.

    Declaration

    Swift

    private func addCandidate(candidateMessage: RTCCandidateMessage)

    Parameters

    candidateMessage

    The candidate that will be added to the peer connection.

RTC Client Delegates

  • Logs message whenever the RTC Client receive or send a message.

    Declaration

    Swift

    func logMessage(_ message: RTCMessage)

    Parameters

    message

    Message received

  • Triggered when the connection is terminated.

    Declaration

    Swift

    func closeConnection()

RTC Peer Connection Delegates

  • Undocumented

    Declaration

    Swift

    public func peerConnection(_ peerConnection: RTCPeerConnection, didAdd stream: RTCMediaStream)
  • Undocumented

    Declaration

    Swift

    public func peerConnection(_ peerConnection: RTCPeerConnection, didGenerate candidate: RTCIceCandidate)
  • Undocumented

    Declaration

    Swift

    public func peerConnection(_ peerConnection: RTCPeerConnection, didRemove stream: RTCMediaStream)
  • Undocumented

    Declaration

    Swift

    public func peerConnectionShouldNegotiate(_ peerConnection: RTCPeerConnection)
  • Undocumented

    Declaration

    Swift

    public func peerConnection(_ peerConnection: RTCPeerConnection, didChange newState: RTCIceConnectionState)
  • Undocumented

    Declaration

    Swift

    public func peerConnection(_ peerConnection: RTCPeerConnection, didChange newState: RTCIceGatheringState)
  • Undocumented

    Declaration

    Swift

    public func peerConnection(_ peerConnection: RTCPeerConnection, didRemove candidates: [RTCIceCandidate])
  • Undocumented

    Declaration

    Swift

    public func peerConnection(_ peerConnection: RTCPeerConnection, didChange stateChanged: RTCSignalingState)
  • Undocumented

    Declaration

    Swift

    public func peerConnection(_ peerConnection: RTCPeerConnection, didOpen dataChannel: RTCDataChannel)

Audio control

  • Fallback to the default playing device: headphones / bluetooth / ear speaker.

    Declaration

    Swift

    func speakerOff()
  • Set audio configuration to speaker.

    Declaration

    Swift

    func speakerOn()