Peer class
Represents a peer in the WebRTC communication.
Constructors
-
Peer(TxSocket _socket, bool _debug, TelnyxClient _txClient, bool _forceRelayCandidate, bool _useTrickleIce, [AudioConstraints? _audioConstraints, bool initialMuteState = false, List<
TxIceServer> iceServers = const []]) - The constructor for the Peer class.
Properties
- callReportLogCollector → CallReportLogCollector?
-
Get the log collector for external event logging
no setter
- currentSession ↔ Session?
-
Current active session
getter/setter pair
- getUserMediaOverride ↔ GetUserMediaFn?
-
Optional override for
getUserMedia, used to exercise the media-permission recovery flow (VSDK-417) deterministically in tests. When null the realnavigator.mediaDevices.getUserMediais used.getter/setter pair - hashCode → int
-
The hash code for this object.
no setterinherited
- onAddRemoteStream ↔ dynamic Function(Session session, MediaStream stream)?
-
Called when a remote media stream is added to a session.
getter/setter pair
- onCallQualityChange ↔ CallQualityCallback?
-
Callback for call quality metrics updates.
getter/setter pair
- onCallStateChange ↔ dynamic Function(Session session, CallState state)?
-
Called when the call state changes for a given session.
getter/setter pair
- onDataChannel ↔ dynamic Function(Session session, RTCDataChannel dc)?
-
Called when a data channel is opened for a session.
getter/setter pair
- onDataChannelMessage ↔ dynamic Function(Session session, RTCDataChannel dc, RTCDataChannelMessage data)?
-
Called when a data channel message is received for a session.
getter/setter pair
- onLocalStream ↔ dynamic Function(MediaStream stream)?
-
Called when the local media stream becomes available.
getter/setter pair
- onPeersUpdate ↔ dynamic Function(dynamic event)?
-
Called when the set of active peers is updated.
getter/setter pair
- onRemoveRemoteStream ↔ dynamic Function(Session session, MediaStream stream)?
-
Called when a remote media stream is removed from a session.
getter/setter pair
- onSignalingStateChange ↔ dynamic Function(SignalingState state)?
-
Called when the signaling state of the peer changes.
getter/setter pair
- peerConnection ↔ RTCPeerConnection?
-
The peer connection instance.
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- sdpSemantics → String
-
Gets the SDP semantics based on the platform.
Returns 'plan-b' for Windows and 'unified-plan' for other platforms.
no setter
- shouldForceRelayForRecovery → bool
-
Whether the latest call diagnostics justify relay-only recovery.
no setter
Methods
-
accept(
String callerName, String callerNumber, String destinationNumber, String clientState, String callId, IncomingInviteParams invite, Map< String, String> customHeaders, bool isAttach, {String? answeredDeviceToken}) → Future<void> - Accepts an incoming call.
-
applyAudioCodecPreferences(
RTCPeerConnection peerConnection, List< Map< ? preferredCodecs) → Future<String, dynamic> >void> - Applies audio codec preferences to the peer connection's audio transceiver. This method must be called before creating an offer or answer to ensure the preferred codecs are negotiated in the correct order.
-
close(
) → Future< void> - Closes all peer connections, local streams, and the socket connection.
-
closeSession(
) → void - Closes the current session (based on _selfId).
-
createStream(
String media, {bool isAnswer = false, String? callId}) → Future< MediaStream> - Creates a local media stream (audio only for web).
-
enableSpeakerPhone(
bool enable) → void -
Enables or disables the speakerphone.
enableTrue to enable speakerphone, false to disable. -
handleRemoteCandidate(
String callId, String candidateStr, String? sdpMid, int? sdpMLineIndex) → void - Handles remote ICE candidates received via WebSocket
-
handleUpdateMediaResponse(
UpdateMediaResponse response) → Future< void> - Handles the updateMedia response from the server
-
initRenderers(
) → Future< void> - Initializes the local and remote video renderers.
-
invite(
String callerName, String callerNumber, String destinationNumber, String clientState, String callId, String telnyxSessionId, Map< String, String> customHeaders, {List<Map< ? preferredCodecs}) → Future<String, dynamic> >void> - Initiates a new call.
-
muteUnmuteMic(
) → void - Mutes or unmutes the microphone.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
postCallReport(
{required String callId, required String direction, String? destinationNumber, String? callerNumber, String? state, String? telnyxSessionId, String? telnyxLegId}) → Future< void> - Posts the collected call report to voice-sdk-proxy. Should be called after stopStats() when the call ends.
-
remoteSessionReceived(
String sdp) → void -
Called if you receive an "answer" sdp from the server
(e.g., bridging a call scenario).
sdpThe SDP string of the remote description. -
setCallReportConfig(
{int callReportInterval = 5000, String callReportLogLevel = 'debug', int callReportMaxLogEntries = 1000}) → void - Set call report configuration from Config
-
setCallReportIdentifiers(
{String? sessionId, String? legId}) → void - Adds authoritative Telnyx identifiers received after call creation.
-
setClientSummary(
ClientSummary? summary) → void -
Cache a ClientSummary built from the active Config so it can be
included in the final call report payload. Should be called at call
start (e.g. from
invite()/answer()). This is deliberately a call-start snapshot; later recovery changes such as relay escalation do not rewrite the original client configuration. -
setMuteState(
bool muted) → void - Sets the microphone mute state to a specific value.
-
setResolvedCallReportConnection(
{String? region, String? dc}) → void - Adds authoritative connection metadata received after call creation.
-
startIceRenegotiation(
String callId, String sessionId) → Future< void> - Starts ICE renegotiation process when ICE connection fails
-
startStats(
String callId, String peerId, RTCPeerConnection pc, {CallQualityCallback? onCallQualityChange, String? direction, String? destinationNumber, String? callerNumber}) → Future< bool> -
Starts collecting WebRTC statistics for the given call and peer
connection, reporting call quality updates via
onCallQualityChange. -
stopStats(
String callId) → Future< void> -
Stops WebRTC statistics reporting for the given call ID.
Awaits final stats collection to ensure no data is lost.
callIdThe ID of the call for which to stop stats. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited