CLASS
Call
public class Call
A Call represents an audio or video communication session between two endpoints: WebRTC Clients, SIP clients, or phone numbers. The Call object manages the entire lifecycle of a call, from initiation to termination, handling both outbound and inbound calls.
A Call object is created in two scenarios:
- When you initiate a new outbound call using TxClient's newCall method
 - When you receive an inbound call through the TxClientDelegate's onIncomingCall callback
 
Key Features 
- Audio and video call support
 - Call state management (NEW, CONNECTING, RINGING, ACTIVE, HELD, DONE)
 - Mute/unmute functionality
 - DTMF tone sending
 - Custom headers support for both INVITE and ANSWER messages
 - Call statistics reporting when debug mode is enabled
 
Examples 
Creating an Outbound Call: 
   // Initialize the client
   self.telnyxClient = TxClient()
   self.telnyxClient?.delegate = self
   // Connect the client (see TxClient documentation for connection options)
   self.telnyxClient?.connect(....)
   // Create and initiate a call
   self.currentCall = try self.telnyxClient?.newCall(
       callerName: "John Doe",           // The name to display for the caller
       callerNumber: "155531234567",     // The caller's phone number
       destinationNumber: "18004377950", // The target phone number or SIP URI
       callId: UUID.init(),              // Unique identifier for the call
       clientState: nil,                 // Optional client state information
       customHeaders: [:]                // Optional custom SIP headers
   )
Handling an Incoming Call: 
class CallHandler: TxClientDelegate {
    var activeCall: Call?
    func initTelnyxClient() {
        let client = TxClient()
        client.delegate = self
        client.connect(....)
    }
    func onIncomingCall(call: Call) {
        // Store the call reference
        self.activeCall = call
        // Option 1: Auto-answer the call
        call.answer()
        // Option 2: Answer with custom headers
        call.answer(customHeaders: ["X-Custom-Header": "Value"])
        // Option 3: Reject the call
        // call.hangup()
    }
}
Properties 
onCallQualityChange 
public var onCallQualityChange: ((CallQualityMetrics) -> Void)?
Callback for real-time call quality metrics This is triggered whenever new WebRTC statistics are available
inviteCustomHeaders 
public internal(set) var inviteCustomHeaders: [String:String]?
Custom headers received from the WebRTC INVITE message. These headers are passed during call initiation and can contain application-specific information. Format should be ["X-Header-Name": "Value"] where header names must start with "X-".
answerCustomHeaders 
public internal(set) var answerCustomHeaders: [String:String]?
Custom headers received from the WebRTC ANSWER message. These headers are passed during call acceptance and can contain application-specific information. Format should be ["X-Header-Name": "Value"] where header names must start with "X-".
sessionId 
public internal(set) var sessionId: String?
The unique session identifier for the current WebRTC connection. This ID is established during client connection and remains constant for the session duration.
telnyxSessionId 
public internal(set) var telnyxSessionId: UUID?
The unique Telnyx session identifier for this call. This ID can be used to track the call in Telnyx's systems and logs.
telnyxLegId 
public internal(set) var telnyxLegId: UUID?
The unique Telnyx leg identifier for this call. A call can have multiple legs (e.g., in call transfers). This ID identifies this specific leg.
debug 
public internal(set) var debug: Bool = false
Enables WebRTC statistics reporting for debugging purposes. When true, the SDK will collect and send WebRTC statistics to Telnyx servers. This is useful for troubleshooting call quality issues.
enableQualityMetrics 
public internal(set) var enableQualityMetrics: Bool = false
Enables CallQuality Metrics for Call
sendWebRTCStatsViaSocket 
public internal(set) var sendWebRTCStatsViaSocket: Bool = false
Controls whether the SDK should send WebRTC statistics via socket to Telnyx servers. When enabled, collected WebRTC stats will be sent to Telnyx servers for monitoring and debugging. This is independent of stats collection - stats can be collected without being sent via socket.
forceRelayCandidate 
public internal(set) var forceRelayCandidate: Bool = false
Controls whether the SDK should force TURN relay for peer connections. When enabled, the SDK will only use TURN relay candidates for ICE gathering, which prevents the "local network access" permission popup from appearing.
callInfo 
public var callInfo: TxCallInfo?
Contains essential information about the current call including:
- callId: Unique identifier for this call
 - callerName: Display name of the caller
 - callerNumber: Phone number or SIP URI of the caller
See 
TxCallInfofor complete details. 
callState 
public var callState: CallState = .NEW
The current state of the call. Possible values:
- NEW: Call object created but not yet initiated
 - CONNECTING: Outbound call is being established
 - RINGING: Incoming call waiting to be answered
 - ACTIVE: Call is connected and media is flowing
 - HELD: Call is temporarily suspended
 - DONE: Call has ended
 
The state changes are notified through the CallProtocol delegate.
isMuted 
public var isMuted: Bool
Indicates whether the local audio is currently muted.
- Returns: 
trueif the call is muted (audio track disabled) - Returns: 
falseif the call is not muted (audio track enabled) 
Use muteAudio() and unmuteAudio() to change the mute state.
localStream 
public var localStream: RTCMediaStream?
The local media stream containing audio and/or video tracks being sent to the remote party. This stream represents the media captured from the local device (microphone, camera). Can be used for audio visualization, local video preview, or other media processing.
Examples 
// Access local audio tracks for visualization
if let localStream = call.localStream {
    let audioTracks = localStream.audioTracks
    // Use audio tracks for waveform visualization
}
remoteStream 
public var remoteStream: RTCMediaStream?
The remote media stream containing audio and/or video tracks received from the remote party. This stream represents the media being received from the other participant in the call. Can be used for audio visualization, remote video display, or other media processing.
Examples 
// Access remote audio tracks for visualization
if let remoteStream = call.remoteStream {
    let audioTracks = remoteStream.audioTracks
    // Use audio tracks for waveform visualization
}