# 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](https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/RTCPeerConnection).

* **Parameters:**
  * **urls** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) or [`list`](https://docs.python.org/3/builtins/stdtypes.html#list) of [`str`](https://docs.python.org/3/builtins/stdtypes.html#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`](https://docs.python.org/3/builtins/stdtypes.html#str), optional) – The username of a TURN server.
  * **credential** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#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`](../interfaces/rtc_ice_transport.md#webrtc.interfaces.rtc_ice_transport.RTCIceTransport) gathers candidates, for [`webrtc.RTCIceTransport.gather()`](../interfaces/rtc_ice_transport.md#webrtc.interfaces.rtc_ice_transport.RTCIceTransport.gather).

* **Parameters:**
  * **gather_policy** ([`webrtc.RTCIceTransportPolicy`](../enums.md#webrtc.enums.RTCIceTransportPolicy), optional) – Whether to gather every type of candidate
    (`all`, the default) or only relay ones.
  * **ice_servers** ([`list`](https://docs.python.org/3/builtins/stdtypes.html#list) of [`webrtc.RTCIceServer`](#webrtc.models.rtc_configuration.RTCIceServer), optional) – The STUN and TURN servers to gather with.

### *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`](../interfaces/rtc_peer_connection.md#webrtc.interfaces.rtc_peer_connection.RTCPeerConnection).

A connection takes it on creation and in [`webrtc.RTCPeerConnection.set_configuration()`](../interfaces/rtc_peer_connection.md#webrtc.interfaces.rtc_peer_connection.RTCPeerConnection.set_configuration), and checks the
members there. This class doesn’t check them. Enum members accept their values too.
See [MDN: RTCPeerConnection/RTCPeerConnection](https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/RTCPeerConnection).

* **Parameters:**
  * **ice_servers** ([`list`](https://docs.python.org/3/builtins/stdtypes.html#list) of [`webrtc.RTCIceServer`](#webrtc.models.rtc_configuration.RTCIceServer), optional) – The STUN and TURN servers to gather
    ICE candidates with. There are none by default.
  * **ice_transport_policy** ([`webrtc.RTCIceTransportPolicy`](../enums.md#webrtc.enums.RTCIceTransportPolicy), optional) – Whether every type of candidate may
    be used (`all`, the default) or only relay ones.
  * **bundle_policy** ([`webrtc.RTCBundlePolicy`](../enums.md#webrtc.enums.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`](../enums.md#webrtc.enums.RTCRtcpMuxPolicy), optional) – Whether RTCP multiplexing is required (the
    default). It can’t be changed.
  * **ice_candidate_pool_size** ([`int`](https://docs.python.org/3/builtins/functions.html#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`](https://docs.python.org/3/builtins/stdtypes.html#tuple) of two [`int`](https://docs.python.org/3/builtins/functions.html#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`](https://docs.python.org/3/builtins/stdtypes.html#list) of [`webrtc.RTCCertificate`](rtc_certificate.md#webrtc.models.rtc_certificate.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()`](../interfaces/rtc_peer_connection.md#webrtc.interfaces.rtc_peer_connection.RTCPeerConnection.set_configuration) keeps the current ones.
  * **always_negotiate_data_channels** ([`bool`](https://docs.python.org/3/builtins/functions.html#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`](../enums.md#webrtc.enums.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.
