RTCIceTransport
The ICE transport of a connection, which can also be used on its own.
- class webrtc.interfaces.rtc_ice_transport.RTCIceTransport
The ICE transport a
webrtc.RTCDtlsTransportof a connection runs over, or a standalone one.A standalone transport (
RTCIceTransport(), from WebRTC Extensions) is driven by hand. Callgather(),start()andadd_remote_candidate(), thenstop()when done. Those methods raise for a transport of a connection.See MDN: RTCIceTransport.
- Events:
statechange (
webrtc.Event) βstatechanged.gatheringstatechange (
webrtc.Event) βgathering_statechanged.selectedcandidatepairchange (
webrtc.Event) βget_selected_candidate_pair()changed.icecandidate (
webrtc.RTCPeerConnectionIceEvent) β A standalone transport gathered a candidate, orNoneonce it gathered them all.error (
webrtc.Event) β A standalone transport failed. It never fires, because the native ICE agent doesnβt report it.
Events
statechange:Eventgatheringstatechange:Eventselectedcandidatepairchange:Eventerror:Eventicecandidate:RTCPeerConnectionIceEvent
Handlers are registered with
on().- gather(options=None)
Starts gathering the local candidates of a standalone transport, each sent in an
icecandidateevent.- Parameters:
options (
webrtc.RTCIceGatherOptions, optional) β The policy and the ICE servers to gather with.- Raises:
webrtc.InvalidStateError β If itβs stopped, gathering already, or belongs to a connection.
webrtc.InvalidSyntaxError β If an ICE server URL is invalid.
webrtc.InvalidAccessError β If a TURN server has no credentials.
TypeError β If the policy isnβt a value of
webrtc.RTCIceTransportPolicy.
- start(remote_parameters=None, role='controlled')
Starts connectivity checks of a standalone transport with the remote agent.
Checks use the remote candidates added so far and any added later. Calling it again with other remote parameters (an ICE restart of the remote agent) drops the remote candidates added before.
- Parameters:
remote_parameters (
webrtc.RTCIceParameters, optional) β The username fragment and the password of the remote agent. Both are required, even though the argument has a default.role (
webrtc.RTCIceRole, optional) β Controlling or controlled (the default). If both agents pick the same role, the conflict is resolved and one of them switches.
- Raises:
webrtc.InvalidStateError β If itβs stopped, started with another role, or belongs to a connection.
webrtc.InvalidSyntaxError β If the username fragment or the password is invalid.
ValueError β If the role is neither controlling nor controlled.
- add_remote_candidate(remote_candidate=None)
Adds a candidate of the remote agent to a standalone transport.
The object passed is the one
get_remote_candidates()returns for it.- Parameters:
remote_candidate (
webrtc.RTCIceCandidateorwebrtc.RTCIceCandidateInit, optional) β The candidate, which needssdp_midorsdp_m_line_indexto be set.- Raises:
TypeError β If the candidate has neither
sdp_midnorsdp_m_line_index.webrtc.InvalidStateError β If itβs stopped, or belongs to a connection.
webrtc.OperationError β If the candidate canβt be parsed.
- stop()
Stops a standalone transport for good.
Its
statebecomesclosedwithout astatechangeevent.- Raises:
webrtc.InvalidStateError β If it belongs to a connection.
- get_selected_candidate_pair()
Returns the local and the remote candidate the transport sends and receives with.
A remote peer-reflexive candidate comes from connectivity checks. It has an empty
candidateand no address.See MDN: RTCIceTransport/getSelectedCandidatePair.
- Returns:
webrtc.RTCIceCandidatePair, optional β The pair, orNoneuntil one is selected.- Return type:
RTCIceCandidatePair | None
- get_local_candidates()
Returns the local candidates gathered for the transport so far.
Each call returns the same objects. For a standalone transport, theyβre the ones of its
icecandidateevents.See MDN: RTCIceTransport/getLocalCandidates.
- Returns:
listofwebrtc.RTCIceCandidateβ The candidates.- Return type:
- get_remote_candidates()
Returns the candidates the remote peer signaled for the transport, without peer-reflexive ones.
They come from its description,
webrtc.RTCPeerConnection.add_ice_candidate()oradd_remote_candidate().See MDN: RTCIceTransport/getRemoteCandidates.
- Returns:
listofwebrtc.RTCIceCandidateβ The candidates.- Return type:
- get_local_parameters()
Returns the local username fragment and password of the transport, with
ice_liteFalse.See MDN: RTCIceTransport/getLocalParameters.
- Returns:
webrtc.RTCIceParameters, optional β The parameters, orNonewithout a local description.- Return type:
RTCIceParameters | None
- get_remote_parameters()
Returns the remote username fragment and password of the transport, with
ice_liteunknown.See MDN: RTCIceTransport/getRemoteParameters.
- Returns:
webrtc.RTCIceParameters, optional β The parameters, orNonewithout a remote description.- Return type:
RTCIceParameters | None
- property component: RTCIceComponent
Whether the transport carries RTP or RTCP. Itβs
rtpwhen theyβre muxed.See MDN: RTCIceTransport/component.
- Type:
- property gathering_state: RTCIceGathererState
Whether local candidates are being gathered, or all were.
- property role: RTCIceRole | None
Whether this agent is the controlling one, which picks the pair.
Nonefor a standalone transport not started yet.See MDN: RTCIceTransport/role.
- Type:
webrtc.RTCIceRole, optional
- property state: RTCIceTransportState
Whether the transport is checking, connected, failed or closed.