RTCConfiguration

The configuration of a connection and the STUN and TURN servers it gathers candidates with.

class webrtc.models.rtc_configuration.RTCIceServer(urls, username=None, credential=None)

A STUN or TURN server to gather ICE candidates with.

It isn’t checked on creation, only when the configuration is applied. The URLs must be valid stun, stuns, turn or turns URLs (RFC 7064, RFC 7065), and a TURN server needs a username of at most 509 characters and a non-empty password. See MDN: RTCPeerConnection/RTCPeerConnection.

Parameters:
  • urls (str or list of str) – One URL or several, like 'stun:stun.example.org' or 'turn:turn.example.org:3478?transport=tcp'. At least one is required.

  • username (str, optional) – The username of a TURN server.

  • credential (str, optional) – The password of a TURN server.

class webrtc.models.rtc_configuration.RTCIceGatherOptions(gather_policy=RTCIceTransportPolicy.all, ice_servers=None)

How a standalone webrtc.RTCIceTransport gathers candidates, for webrtc.RTCIceTransport.gather().

Parameters:
class webrtc.models.rtc_configuration.RTCConfiguration(ice_servers=<factory>, ice_transport_policy=RTCIceTransportPolicy.all, bundle_policy=RTCBundlePolicy.balanced, rtcp_mux_policy=RTCRtcpMuxPolicy.require, ice_candidate_pool_size=0, port_range=None, certificates=None, always_negotiate_data_channels=False, rtp_header_encryption_policy=RTCRtpHeaderEncryptionPolicy.negotiate)

The configuration of a webrtc.RTCPeerConnection.

A connection takes it on creation and in webrtc.RTCPeerConnection.set_configuration(), and checks the members there. This class doesn’t check them. Enum members accept their values too. See MDN: RTCPeerConnection/RTCPeerConnection.

Parameters:
  • ice_servers (list of webrtc.RTCIceServer, optional) – The STUN and TURN servers to gather ICE candidates with. There are none by default.

  • ice_transport_policy (webrtc.RTCIceTransportPolicy, optional) – Whether every type of candidate may be used (all, the default) or only relay ones.

  • bundle_policy (webrtc.RTCBundlePolicy, optional) – How media is grouped into transports when the remote peer doesn’t support bundling. It’s balanced by default and can’t be changed.

  • rtcp_mux_policy (webrtc.RTCRtcpMuxPolicy, optional) – Whether RTCP multiplexing is required (the default). It can’t be changed.

  • ice_candidate_pool_size (int, optional) – How many candidates (0 to 255) to gather ahead of setting the local description. It’s 0 by default and can’t be changed once the local description is set.

  • port_range (tuple of two int, optional) – The lowest and the highest local UDP and TCP port to use, for firewalls that only allow a range. This option is specific to this library.

  • certificates (list of webrtc.RTCCertificate, optional) – The certificates to authenticate with. They’re generated if omitted. They can’t be changed, and leaving them out of webrtc.RTCPeerConnection.set_configuration() keeps the current ones.

  • always_negotiate_data_channels (bool, optional) – Whether every offer has a media section for data channels even before a channel is created. The section comes first among the new sections. It can’t be changed.

  • rtp_header_encryption_policy (webrtc.RTCRtpHeaderEncryptionPolicy, optional) – negotiate (the default) encrypts RTP header extensions with cryptex (RFC 9335) when the remote peer supports it, require fails a remote description without it, and disable never encrypts. It can’t be changed.