# 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`](../interfaces/rtc_ice_transport.md#webrtc.interfaces.rtc_ice_transport.RTCIceTransport).

See [MDN: RTCIceParameters](https://developer.mozilla.org/en-US/docs/Web/API/RTCIceParameters).

* **Parameters:**
  * **username_fragment** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str), optional) – The username fragment, as in `a=ice-ufrag` of SDP.
  * **password** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str), optional) – The password, as in `a=ice-pwd` of SDP.
  * **ice_lite** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool), optional) – Whether the agent implements ICE lite. It’s [`None`](https://docs.python.org/3/builtins/constants.html#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()`](../interfaces/rtc_peer_connection.md#webrtc.interfaces.rtc_peer_connection.RTCPeerConnection.add_ice_candidate).

It’s the JSON form that [`webrtc.RTCIceCandidate.to_json()`](#webrtc.models.rtc_ice_candidate.RTCIceCandidate.to_json) returns and `from_json()` reads.

See [MDN: RTCIceCandidate/RTCIceCandidate](https://developer.mozilla.org/en-US/docs/Web/API/RTCIceCandidate/RTCIceCandidate).

* **Parameters:**
  * **candidate** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str), optional) – The candidate-attribute from SDP. An empty string marks the end of
    candidates.
  * **sdp_mid** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str), optional) – The `mid` of the media section the candidate belongs to.
  * **sdp_m_line_index** ([`int`](https://docs.python.org/3/builtins/functions.html#int), optional) – The index of the media section of the candidate.
  * **username_fragment** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#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`](#webrtc.models.rtc_ice_candidate.RTCIceCandidate).

* **Parameters:**
  * **candidate** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str), optional) – The candidate-attribute from SDP.
  * **sdp_mid** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str), optional) – The `mid` of the media section the candidate belongs to.
  * **sdp_m_line_index** ([`int`](https://docs.python.org/3/builtins/functions.html#int), optional) – The index of the media section of the candidate.
  * **username_fragment** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str), optional) – The ICE username fragment the candidate belongs to.
  * **relay_protocol** ([`webrtc.RTCIceServerTransportProtocol`](../enums.md#webrtc.enums.RTCIceServerTransportProtocol), optional) – For a local relay candidate,
    the protocol used to reach the TURN server.
  * **url** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#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`](../interfaces/rtc_ice_transport.md#webrtc.interfaces.rtc_ice_transport.RTCIceTransport) sends and receives with.

See [MDN: RTCIceCandidatePair](https://developer.mozilla.org/en-US/docs/Web/API/RTCIceCandidatePair).

* **Parameters:**
  * **local** ([`webrtc.RTCIceCandidate`](#webrtc.models.rtc_ice_candidate.RTCIceCandidate)) – The local candidate.
  * **remote** ([`webrtc.RTCIceCandidate`](#webrtc.models.rtc_ice_candidate.RTCIceCandidate)) – The remote candidate.

### *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`](../interfaces/rtc_peer_connection.md#webrtc.interfaces.rtc_peer_connection.RTCPeerConnection) gathers them (see its `icecandidate` event). Each one is sent to the remote
peer and added there with [`webrtc.RTCPeerConnection.add_ice_candidate()`](../interfaces/rtc_peer_connection.md#webrtc.interfaces.rtc_peer_connection.RTCPeerConnection.add_ice_candidate). The constructor doesn’t reject an
unparsable `candidate`, and the properties parsed from it are [`None`](https://docs.python.org/3/builtins/constants.html#None) then. Instances are immutable.

See [MDN: RTCIceCandidate](https://developer.mozilla.org/en-US/docs/Web/API/RTCIceCandidate).

* **Parameters:**
  * **candidate** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#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`](https://docs.python.org/3/builtins/stdtypes.html#str), optional) – The `mid` of the media section the candidate belongs to.
  * **sdp_m_line_index** ([`int`](https://docs.python.org/3/builtins/functions.html#int), optional) – The index of the media section of the candidate.
  * **username_fragment** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str), optional) – The ICE username fragment the candidate belongs to.
  * **relay_protocol** ([`webrtc.RTCIceServerTransportProtocol`](../enums.md#webrtc.enums.RTCIceServerTransportProtocol), optional) – For a local relay candidate,
    the protocol used to reach the TURN server. It isn’t signaled, so it’s [`None`](https://docs.python.org/3/builtins/constants.html#None) for remote
    candidates.
  * **url** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#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**](https://docs.python.org/3/builtins/exceptions.html#TypeError) – If both `sdp_mid` and `sdp_m_line_index` are [`None`](https://docs.python.org/3/builtins/constants.html#None).

#### *property* foundation *: [str](https://docs.python.org/3/builtins/stdtypes.html#str) | [None](https://docs.python.org/3/builtins/constants.html#None)*

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

See [MDN: RTCIceCandidate/foundation](https://developer.mozilla.org/en-US/docs/Web/API/RTCIceCandidate/foundation).

* **Type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str), optional

#### *property* component *: [RTCIceComponent](../enums.md#webrtc.enums.RTCIceComponent) | [None](https://docs.python.org/3/builtins/constants.html#None)*

Whether the candidate is for RTP or RTCP.

See [MDN: RTCIceCandidate/component](https://developer.mozilla.org/en-US/docs/Web/API/RTCIceCandidate/component).

* **Type:**
  [`webrtc.RTCIceComponent`](../enums.md#webrtc.enums.RTCIceComponent), optional

#### *property* priority *: [int](https://docs.python.org/3/builtins/functions.html#int) | [None](https://docs.python.org/3/builtins/constants.html#None)*

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

See [MDN: RTCIceCandidate/priority](https://developer.mozilla.org/en-US/docs/Web/API/RTCIceCandidate/priority).

* **Type:**
  [`int`](https://docs.python.org/3/builtins/functions.html#int), optional

#### *property* address *: [str](https://docs.python.org/3/builtins/stdtypes.html#str) | [None](https://docs.python.org/3/builtins/constants.html#None)*

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

It’s [`None`](https://docs.python.org/3/builtins/constants.html#None) for a remote peer-reflexive candidate.

See [MDN: RTCIceCandidate/address](https://developer.mozilla.org/en-US/docs/Web/API/RTCIceCandidate/address).

* **Type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str), optional

#### *property* protocol *: [RTCIceProtocol](../enums.md#webrtc.enums.RTCIceProtocol) | [None](https://docs.python.org/3/builtins/constants.html#None)*

The transport protocol of the candidate, UDP or TCP.

See [MDN: RTCIceCandidate/protocol](https://developer.mozilla.org/en-US/docs/Web/API/RTCIceCandidate/protocol).

* **Type:**
  [`webrtc.RTCIceProtocol`](../enums.md#webrtc.enums.RTCIceProtocol), optional

#### *property* port *: [int](https://docs.python.org/3/builtins/functions.html#int) | [None](https://docs.python.org/3/builtins/constants.html#None)*

The port of the candidate.

See [MDN: RTCIceCandidate/port](https://developer.mozilla.org/en-US/docs/Web/API/RTCIceCandidate/port).

* **Type:**
  [`int`](https://docs.python.org/3/builtins/functions.html#int), optional

#### *property* type *: [RTCIceCandidateType](../enums.md#webrtc.enums.RTCIceCandidateType) | [None](https://docs.python.org/3/builtins/constants.html#None)*

host, reflexive or relay.

See [MDN: RTCIceCandidate/type](https://developer.mozilla.org/en-US/docs/Web/API/RTCIceCandidate/type).

* **Type:**
  [`webrtc.RTCIceCandidateType`](../enums.md#webrtc.enums.RTCIceCandidateType), optional
* **Type:**
  How the candidate was found

#### *property* tcp_type *: [RTCIceTcpCandidateType](../enums.md#webrtc.enums.RTCIceTcpCandidateType) | [None](https://docs.python.org/3/builtins/constants.html#None)*

For a TCP candidate, how it opens connections.

See [MDN: RTCIceCandidate/tcpType](https://developer.mozilla.org/en-US/docs/Web/API/RTCIceCandidate/tcpType).

* **Type:**
  [`webrtc.RTCIceTcpCandidateType`](../enums.md#webrtc.enums.RTCIceTcpCandidateType), optional

#### *property* related_address *: [str](https://docs.python.org/3/builtins/stdtypes.html#str) | [None](https://docs.python.org/3/builtins/constants.html#None)*

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

See [MDN: RTCIceCandidate/relatedAddress](https://developer.mozilla.org/en-US/docs/Web/API/RTCIceCandidate/relatedAddress).

* **Type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str), optional

#### *property* related_port *: [int](https://docs.python.org/3/builtins/functions.html#int) | [None](https://docs.python.org/3/builtins/constants.html#None)*

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

See [MDN: RTCIceCandidate/relatedPort](https://developer.mozilla.org/en-US/docs/Web/API/RTCIceCandidate/relatedPort).

* **Type:**
  [`int`](https://docs.python.org/3/builtins/functions.html#int), optional

#### to_json()

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

See [MDN: RTCIceCandidate/toJSON](https://developer.mozilla.org/en-US/docs/Web/API/RTCIceCandidate/toJSON).

* **Returns:**
  [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict) – `candidate`, `sdpMid`, `sdpMLineIndex` and `usernameFragment`.
* **Return type:**
  [dict](https://docs.python.org/3/builtins/stdtypes.html#dict)[[str](https://docs.python.org/3/builtins/stdtypes.html#str), [str](https://docs.python.org/3/builtins/stdtypes.html#str) | [int](https://docs.python.org/3/builtins/functions.html#int) | None]
