RTCIceCandidate

ICE candidates and parameters.

class webrtc.models.rtc_ice_candidate.RTCIceParameters(username_fragment=None, password=None, ice_lite=None)

The ICE username fragment and password of one end of an webrtc.RTCIceTransport.

See MDN: RTCIceParameters.

Parameters:
  • username_fragment (str, optional) – The username fragment, as in a=ice-ufrag of SDP.

  • password (str, optional) – The password, as in a=ice-pwd of SDP.

  • ice_lite (bool, optional) – Whether the agent implements ICE lite. It’s None for a remote agent, since that isn’t known.

class webrtc.models.rtc_ice_candidate.RTCIceCandidateInit(candidate='', sdp_mid=None, sdp_m_line_index=None, username_fragment=None)

A candidate as it’s signaled, for webrtc.RTCPeerConnection.add_ice_candidate().

It’s the JSON form that webrtc.RTCIceCandidate.to_json() returns and from_json() reads.

See MDN: RTCIceCandidate/RTCIceCandidate.

Parameters:
  • candidate (str, optional) – The candidate-attribute from SDP. An empty string marks the end of candidates.

  • sdp_mid (str, optional) – The mid of the media section the candidate belongs to.

  • sdp_m_line_index (int, optional) – The index of the media section of the candidate.

  • username_fragment (str, optional) – The ICE username fragment the candidate belongs to.

class webrtc.models.rtc_ice_candidate.RTCLocalIceCandidateInit(candidate='', sdp_mid=None, sdp_m_line_index=None, username_fragment=None, relay_protocol=None, url=None)

A candidate with the members that are only known locally.

It takes every argument of webrtc.RTCIceCandidate.

Parameters:
  • candidate (str, optional) – The candidate-attribute from SDP.

  • sdp_mid (str, optional) – The mid of the media section the candidate belongs to.

  • sdp_m_line_index (int, optional) – The index of the media section of the candidate.

  • username_fragment (str, optional) – The ICE username fragment the candidate belongs to.

  • relay_protocol (webrtc.RTCIceServerTransportProtocol, optional) – For a local relay candidate, the protocol used to reach the TURN server.

  • url (str, optional) – For a local server-reflexive or relay candidate, the address of the STUN or TURN server it came from.

class webrtc.models.rtc_ice_candidate.RTCIceCandidatePair(local, remote)

The local and the remote candidate an webrtc.RTCIceTransport sends and receives with.

See MDN: RTCIceCandidatePair.

Parameters:
class webrtc.models.rtc_ice_candidate.RTCIceCandidate(candidate='', sdp_mid=None, sdp_m_line_index=None, username_fragment=None, relay_protocol=None, url=None)

An ICE candidate, which is an address and port where a peer may be reached.

A webrtc.RTCPeerConnection gathers them (see its icecandidate event). Each one is sent to the remote peer and added there with webrtc.RTCPeerConnection.add_ice_candidate(). The constructor doesn’t reject an unparsable candidate, and the properties parsed from it are None then. Instances are immutable.

See MDN: RTCIceCandidate.

Parameters:
  • candidate (str, optional) – The candidate-attribute from SDP, like 'candidate:1 1 udp ...', optionally prefixed with a=. An empty string marks the end of candidates.

  • sdp_mid (str, optional) – The mid of the media section the candidate belongs to.

  • sdp_m_line_index (int, optional) – The index of the media section of the candidate.

  • username_fragment (str, optional) – The ICE username fragment the candidate belongs to.

  • relay_protocol (webrtc.RTCIceServerTransportProtocol, optional) – For a local relay candidate, the protocol used to reach the TURN server. It isn’t signaled, so it’s None for remote candidates.

  • url (str, optional) – For a local server-reflexive or relay candidate, the address of the STUN or TURN server it came from. It isn’t signaled either.

Raises:

TypeError – If both sdp_mid and sdp_m_line_index are None.

property foundation: str | None

An id shared by candidates of the same type, base address and server.

See MDN: RTCIceCandidate/foundation.

Type:

str, optional

property component: RTCIceComponent | None

Whether the candidate is for RTP or RTCP.

See MDN: RTCIceCandidate/component.

Type:

webrtc.RTCIceComponent, optional

property priority: int | None

The priority of the candidate. Higher ones are tried first.

See MDN: RTCIceCandidate/priority.

Type:

int, optional

property address: str | None

The IP address or host name (like an mDNS .local one) of the candidate.

It’s None for a remote peer-reflexive candidate.

See MDN: RTCIceCandidate/address.

Type:

str, optional

property protocol: RTCIceProtocol | None

The transport protocol of the candidate, UDP or TCP.

See MDN: RTCIceCandidate/protocol.

Type:

webrtc.RTCIceProtocol, optional

property port: int | None

The port of the candidate.

See MDN: RTCIceCandidate/port.

Type:

int, optional

property type: RTCIceCandidateType | None

host, reflexive or relay.

See MDN: RTCIceCandidate/type.

Type:

webrtc.RTCIceCandidateType, optional

Type:

How the candidate was found

property tcp_type: RTCIceTcpCandidateType | None

For a TCP candidate, how it opens connections.

See MDN: RTCIceCandidate/tcpType.

Type:

webrtc.RTCIceTcpCandidateType, optional

property related_address: str | None

For a candidate other than a host one, the address it was derived from.

See MDN: RTCIceCandidate/relatedAddress.

Type:

str, optional

property related_port: int | None

For a candidate other than a host one, the port it was derived from.

See MDN: RTCIceCandidate/relatedPort.

Type:

int, optional

to_json()

Returns the candidate as a JSON-serializable dictionary, to signal it to the remote peer.

See MDN: RTCIceCandidate/toJSON.

Returns:

dict – candidate, sdpMid, sdpMLineIndex and usernameFragment.

Return type:

dict[str, str | int | None]