# Track constraints

Settings, capabilities and constraints of tracks.

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

### *class* webrtc.models.media_track_constraints.ULongRange(min=None, max=None)

A range of integers a source supports, in [`MediaTrackCapabilities`](#webrtc.models.media_track_constraints.MediaTrackCapabilities).

* **Parameters:**
  * **min** ([`int`](https://docs.python.org/3/builtins/functions.html#int), optional) – The lowest value, inclusive.
  * **max** ([`int`](https://docs.python.org/3/builtins/functions.html#int), optional) – The highest value, inclusive.

### *class* webrtc.models.media_track_constraints.DoubleRange(min=None, max=None)

A range of numbers a source supports, in [`MediaTrackCapabilities`](#webrtc.models.media_track_constraints.MediaTrackCapabilities).

* **Parameters:**
  * **min** ([`float`](https://docs.python.org/3/builtins/functions.html#float), optional) – The lowest value, inclusive.
  * **max** ([`float`](https://docs.python.org/3/builtins/functions.html#float), optional) – The highest value, inclusive.

### *class* webrtc.models.media_track_constraints.ConstrainULongRange(min=None, max=None, exact=None, ideal=None)

A constraint on an integer, with required bounds or a required value, and a preferred value.

The required members fail the constraints when the source’s range doesn’t allow them.

* **Parameters:**
  * **min** ([`int`](https://docs.python.org/3/builtins/functions.html#int), optional) – The lowest value allowed, as a requirement.
  * **max** ([`int`](https://docs.python.org/3/builtins/functions.html#int), optional) – The highest value allowed, as a requirement.
  * **exact** ([`int`](https://docs.python.org/3/builtins/functions.html#int), optional) – The only value allowed, as a requirement.
  * **ideal** ([`int`](https://docs.python.org/3/builtins/functions.html#int), optional) – The value to get as near as possible to. It never fails the constraints.

### *class* webrtc.models.media_track_constraints.ConstrainDoubleRange(min=None, max=None, exact=None, ideal=None)

A constraint on a number, with required bounds or a required value, and a preferred value.

The required members fail the constraints when the source’s range doesn’t allow them.

* **Parameters:**
  * **min** ([`float`](https://docs.python.org/3/builtins/functions.html#float), optional) – The lowest value allowed, as a requirement.
  * **max** ([`float`](https://docs.python.org/3/builtins/functions.html#float), optional) – The highest value allowed, as a requirement.
  * **exact** ([`float`](https://docs.python.org/3/builtins/functions.html#float), optional) – The only value allowed, as a requirement.
  * **ideal** ([`float`](https://docs.python.org/3/builtins/functions.html#float), optional) – The value to get as near as possible to. It never fails the constraints.

### *class* webrtc.models.media_track_constraints.ConstrainBooleanParameters(exact=None, ideal=None)

A constraint on a boolean, with a required value or a preferred one.

* **Parameters:**
  * **exact** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool), optional) – The only value allowed, as a requirement.
  * **ideal** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool), optional) – The value to get if possible. It never fails the constraints.

### *class* webrtc.models.media_track_constraints.ConstrainDOMStringParameters(exact=None, ideal=None)

A constraint on a string, with required values or preferred ones.

* **Parameters:**
  * **exact** ([`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), optional) – The value or values allowed, as a requirement.
  * **ideal** ([`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), optional) – The value or values to get if possible. They
    never fail the constraints.

### *class* webrtc.models.media_track_constraints.ConstrainBooleanOrDOMStringParameters(exact=None, ideal=None)

A constraint on a boolean or a string, with a required value or a preferred one.

* **Parameters:**
  * **exact** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool) or [`str`](https://docs.python.org/3/builtins/stdtypes.html#str), optional) – The only value allowed, as a requirement.
  * **ideal** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool) or [`str`](https://docs.python.org/3/builtins/stdtypes.html#str), optional) – The value to get if possible. It never fails the constraints.

### webrtc.models.media_track_constraints.ConstrainULong

A constraint on an integer, where a bare value is an ideal one

alias of [`int`](https://docs.python.org/3/builtins/functions.html#int) | [`ConstrainULongRange`](#webrtc.models.media_track_constraints.ConstrainULongRange)

### webrtc.models.media_track_constraints.ConstrainDouble

A constraint on a number, where a bare value is an ideal one

alias of [`float`](https://docs.python.org/3/builtins/functions.html#float) | [`ConstrainDoubleRange`](#webrtc.models.media_track_constraints.ConstrainDoubleRange)

### webrtc.models.media_track_constraints.ConstrainBoolean

A constraint on a boolean, where a bare value is an ideal one

alias of [`bool`](https://docs.python.org/3/builtins/functions.html#bool) | [`ConstrainBooleanParameters`](#webrtc.models.media_track_constraints.ConstrainBooleanParameters)

### webrtc.models.media_track_constraints.ConstrainDOMString

A constraint on a string, where a bare string or a list of them is ideal

alias of [`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)] | [`ConstrainDOMStringParameters`](#webrtc.models.media_track_constraints.ConstrainDOMStringParameters)

### webrtc.models.media_track_constraints.ConstrainBooleanOrDOMString

A constraint on a boolean or a string, where a bare value is an ideal one

alias of [`bool`](https://docs.python.org/3/builtins/functions.html#bool) | [`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`ConstrainBooleanOrDOMStringParameters`](#webrtc.models.media_track_constraints.ConstrainBooleanOrDOMStringParameters)

### *class* webrtc.models.media_track_constraints.MediaTrackSupportedConstraints(width=True, height=True, aspect_ratio=True, frame_rate=True, facing_mode=True, resize_mode=True, sample_rate=True, sample_size=True, echo_cancellation=True, auto_gain_control=True, noise_suppression=True, latency=True, channel_count=True, device_id=True, group_id=True, background_blur=True, voice_isolation=True)

The constraints the library recognizes, as [`webrtc.MediaDevices.get_supported_constraints()`](../interfaces/media_devices.md#webrtc.interfaces.media_devices.MediaDevices.get_supported_constraints) returns.

Every member is [`True`](https://docs.python.org/3/builtins/constants.html#True). A recognized constraint that the source has no capability or setting for (like
`facing_mode` on the synthetic camera) is ignored when ideal and fails when required.

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

* **Parameters:**
  * **width** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool), optional) – Whether `width` is recognized.
  * **height** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool), optional) – Whether `height` is recognized.
  * **aspect_ratio** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool), optional) – Whether `aspect_ratio` is recognized.
  * **frame_rate** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool), optional) – Whether `frame_rate` is recognized.
  * **facing_mode** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool), optional) – Whether `facing_mode` is recognized.
  * **resize_mode** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool), optional) – Whether `resize_mode` is recognized.
  * **sample_rate** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool), optional) – Whether `sample_rate` is recognized.
  * **sample_size** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool), optional) – Whether `sample_size` is recognized.
  * **echo_cancellation** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool), optional) – Whether `echo_cancellation` is recognized.
  * **auto_gain_control** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool), optional) – Whether `auto_gain_control` is recognized.
  * **noise_suppression** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool), optional) – Whether `noise_suppression` is recognized.
  * **latency** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool), optional) – Whether `latency` is recognized.
  * **channel_count** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool), optional) – Whether `channel_count` is recognized.
  * **device_id** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool), optional) – Whether `device_id` is recognized.
  * **group_id** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool), optional) – Whether `group_id` is recognized.
  * **background_blur** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool), optional) – Whether `background_blur` is recognized.
  * **voice_isolation** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool), optional) – Whether `voice_isolation` is recognized.

### *class* webrtc.models.media_track_constraints.MediaTrackSettings(width=None, height=None, aspect_ratio=None, frame_rate=None, resize_mode=None, device_id=None, group_id=None, sample_rate=None, sample_size=None, channel_count=None, echo_cancellation=None, auto_gain_control=None, noise_suppression=None, facing_mode=None, latency=None, background_blur=None, voice_isolation=None)

What a track carries now, as [`webrtc.MediaStreamTrack.get_settings()`](../interfaces/media_stream_track.md#webrtc.interfaces.media_stream_track.MediaStreamTrack.get_settings) returns.

Members are [`None`](https://docs.python.org/3/builtins/constants.html#None) when they don’t apply to the track or aren’t known yet. The library never fills
`facing_mode` or `background_blur`.

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

* **Parameters:**
  * **width** ([`int`](https://docs.python.org/3/builtins/functions.html#int), optional) – The width of the video.
  * **height** ([`int`](https://docs.python.org/3/builtins/functions.html#int), optional) – The height of the video.
  * **aspect_ratio** ([`float`](https://docs.python.org/3/builtins/functions.html#float), optional) – The width divided by the height.
  * **frame_rate** ([`float`](https://docs.python.org/3/builtins/functions.html#float), optional) – The frames per second: a camera’s selected one, otherwise measured over
    the last frames.
  * **resize_mode** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str), optional) – How the source is resized. It’s `'none'` for the synthetic camera.
  * **device_id** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str), optional) – The device of a track of [`webrtc.MediaDevices.get_user_media()`](../interfaces/media_devices.md#webrtc.interfaces.media_devices.MediaDevices.get_user_media).
  * **group_id** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str), optional) – The group ID of the device.
  * **sample_rate** ([`int`](https://docs.python.org/3/builtins/functions.html#int), optional) – The samples per second of the audio.
  * **sample_size** ([`int`](https://docs.python.org/3/builtins/functions.html#int), optional) – The bits per sample of the audio.
  * **channel_count** ([`int`](https://docs.python.org/3/builtins/functions.html#int), optional) – The channels of the audio.
  * **echo_cancellation** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool) or [`str`](https://docs.python.org/3/builtins/stdtypes.html#str), optional) – Whether echo is cancelled. It’s [`False`](https://docs.python.org/3/builtins/constants.html#False) for the
    synthetic microphone.
  * **auto_gain_control** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool), optional) – Whether the gain is controlled automatically.
  * **noise_suppression** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool), optional) – Whether noise is suppressed.
  * **facing_mode** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str), optional) – Where the camera faces, like `'user'`.
  * **latency** ([`float`](https://docs.python.org/3/builtins/functions.html#float), optional) – The latency of the audio in seconds.
  * **background_blur** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool), optional) – Whether the background is blurred.
  * **voice_isolation** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool), optional) – Whether voices are isolated from other sounds.

### *class* webrtc.models.media_track_constraints.MediaTrackCapabilities(width=None, height=None, aspect_ratio=None, frame_rate=None, resize_mode=None, device_id=None, group_id=None, sample_rate=None, sample_size=None, channel_count=None, echo_cancellation=None, auto_gain_control=None, noise_suppression=None, facing_mode=None, latency=None, background_blur=None, voice_isolation=None)

What the source of a track can do, as [`webrtc.MediaStreamTrack.get_capabilities()`](../interfaces/media_stream_track.md#webrtc.interfaces.media_stream_track.MediaStreamTrack.get_capabilities) returns.

Only the synthetic camera and microphone of [`webrtc.MediaDevices.get_user_media()`](../interfaces/media_devices.md#webrtc.interfaces.media_devices.MediaDevices.get_user_media) have capabilities. The
camera supports 1 to 4096 pixels each way at 1 to 120 frames per second, and faces no known way. The microphone
is 48 kHz 16-bit mono in 10 ms frames, with no processing. For other tracks every member is [`None`](https://docs.python.org/3/builtins/constants.html#None), because
the library doesn’t control their source.

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

* **Parameters:**
  * **width** ([`ULongRange`](#webrtc.models.media_track_constraints.ULongRange), optional) – The widths of the video.
  * **height** ([`ULongRange`](#webrtc.models.media_track_constraints.ULongRange), optional) – The heights of the video.
  * **aspect_ratio** ([`DoubleRange`](#webrtc.models.media_track_constraints.DoubleRange), optional) – The aspect ratios of the video.
  * **frame_rate** ([`DoubleRange`](#webrtc.models.media_track_constraints.DoubleRange), optional) – The frame rates of the video.
  * **resize_mode** ([`list`](https://docs.python.org/3/builtins/stdtypes.html#list) of [`str`](https://docs.python.org/3/builtins/stdtypes.html#str), optional) – The ways the source can be resized.
  * **device_id** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str), optional) – The device of the track.
  * **group_id** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str), optional) – The group ID of the device.
  * **sample_rate** ([`ULongRange`](#webrtc.models.media_track_constraints.ULongRange), optional) – The sample rates of the audio.
  * **sample_size** ([`ULongRange`](#webrtc.models.media_track_constraints.ULongRange), optional) – The bits per sample of the audio.
  * **channel_count** ([`ULongRange`](#webrtc.models.media_track_constraints.ULongRange), optional) – The channels of the audio.
  * **echo_cancellation** ([`list`](https://docs.python.org/3/builtins/stdtypes.html#list) of [`bool`](https://docs.python.org/3/builtins/functions.html#bool) or [`str`](https://docs.python.org/3/builtins/stdtypes.html#str), optional) – Whether echo can be cancelled.
  * **auto_gain_control** ([`list`](https://docs.python.org/3/builtins/stdtypes.html#list) of [`bool`](https://docs.python.org/3/builtins/functions.html#bool), optional) – Whether the gain can be controlled.
  * **noise_suppression** ([`list`](https://docs.python.org/3/builtins/stdtypes.html#list) of [`bool`](https://docs.python.org/3/builtins/functions.html#bool), optional) – Whether noise can be suppressed.
  * **facing_mode** ([`list`](https://docs.python.org/3/builtins/stdtypes.html#list) of [`str`](https://docs.python.org/3/builtins/stdtypes.html#str), optional) – Where the camera can face.
  * **latency** ([`DoubleRange`](#webrtc.models.media_track_constraints.DoubleRange), optional) – The latencies of the audio in seconds.
  * **background_blur** ([`list`](https://docs.python.org/3/builtins/stdtypes.html#list) of [`bool`](https://docs.python.org/3/builtins/functions.html#bool), optional) – Whether the background can be blurred.
  * **voice_isolation** ([`list`](https://docs.python.org/3/builtins/stdtypes.html#list) of [`bool`](https://docs.python.org/3/builtins/functions.html#bool), optional) – Whether voices can be isolated.

### *class* webrtc.models.media_track_constraints.MediaTrackConstraintSet(width=None, height=None, aspect_ratio=None, frame_rate=None, resize_mode=None, device_id=None, group_id=None, sample_rate=None, sample_size=None, channel_count=None, echo_cancellation=None, auto_gain_control=None, noise_suppression=None, facing_mode=None, latency=None, background_blur=None, voice_isolation=None)

A set of constraints on a track. It’s the base of [`MediaTrackConstraints`](#webrtc.models.media_track_constraints.MediaTrackConstraints) and of its advanced sets.

Each member is either a bare value, which is ideal, or a constraint object with `exact`, `ideal`, `min`
and `max`. The required parts fail the constraints if the source can’t satisfy them, but the ideal ones never
do.

* **Parameters:**
  * **width** ([`int`](https://docs.python.org/3/builtins/functions.html#int) or [`ConstrainULongRange`](#webrtc.models.media_track_constraints.ConstrainULongRange), optional) – The width of the video.
  * **height** ([`int`](https://docs.python.org/3/builtins/functions.html#int) or [`ConstrainULongRange`](#webrtc.models.media_track_constraints.ConstrainULongRange), optional) – The height of the video.
  * **aspect_ratio** ([`float`](https://docs.python.org/3/builtins/functions.html#float) or [`ConstrainDoubleRange`](#webrtc.models.media_track_constraints.ConstrainDoubleRange), optional) – The aspect ratio of the video.
  * **frame_rate** ([`float`](https://docs.python.org/3/builtins/functions.html#float) or [`ConstrainDoubleRange`](#webrtc.models.media_track_constraints.ConstrainDoubleRange), optional) – The frame rate of the video.
  * **resize_mode** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) or [`ConstrainDOMStringParameters`](#webrtc.models.media_track_constraints.ConstrainDOMStringParameters), optional) – How the source is resized.
  * **device_id** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) or [`ConstrainDOMStringParameters`](#webrtc.models.media_track_constraints.ConstrainDOMStringParameters), optional) – The device.
  * **group_id** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) or [`ConstrainDOMStringParameters`](#webrtc.models.media_track_constraints.ConstrainDOMStringParameters), optional) – The group ID of the device.
  * **sample_rate** ([`int`](https://docs.python.org/3/builtins/functions.html#int) or [`ConstrainULongRange`](#webrtc.models.media_track_constraints.ConstrainULongRange), optional) – The sample rate of the audio.
  * **sample_size** ([`int`](https://docs.python.org/3/builtins/functions.html#int) or [`ConstrainULongRange`](#webrtc.models.media_track_constraints.ConstrainULongRange), optional) – The bits per sample of the audio.
  * **channel_count** ([`int`](https://docs.python.org/3/builtins/functions.html#int) or [`ConstrainULongRange`](#webrtc.models.media_track_constraints.ConstrainULongRange), optional) – The channels of the audio.
  * **echo_cancellation** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool) or [`ConstrainBooleanOrDOMStringParameters`](#webrtc.models.media_track_constraints.ConstrainBooleanOrDOMStringParameters), optional) – Whether echo is
    cancelled.
  * **auto_gain_control** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool) or [`ConstrainBooleanParameters`](#webrtc.models.media_track_constraints.ConstrainBooleanParameters), optional) – Whether the gain is
    controlled automatically.
  * **noise_suppression** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool) or [`ConstrainBooleanParameters`](#webrtc.models.media_track_constraints.ConstrainBooleanParameters), optional) – Whether noise is suppressed.
  * **facing_mode** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) or [`ConstrainDOMStringParameters`](#webrtc.models.media_track_constraints.ConstrainDOMStringParameters), optional) – Where the camera faces.
  * **latency** ([`float`](https://docs.python.org/3/builtins/functions.html#float) or [`ConstrainDoubleRange`](#webrtc.models.media_track_constraints.ConstrainDoubleRange), optional) – The latency of the audio in seconds.
  * **background_blur** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool) or [`ConstrainBooleanParameters`](#webrtc.models.media_track_constraints.ConstrainBooleanParameters), optional) – Whether the background is
    blurred.
  * **voice_isolation** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool) or [`ConstrainBooleanParameters`](#webrtc.models.media_track_constraints.ConstrainBooleanParameters), optional) – Whether voices are isolated
    from other sounds.

### *class* webrtc.models.media_track_constraints.MediaTrackConstraints(width=None, height=None, aspect_ratio=None, frame_rate=None, resize_mode=None, device_id=None, group_id=None, sample_rate=None, sample_size=None, channel_count=None, echo_cancellation=None, auto_gain_control=None, noise_suppression=None, facing_mode=None, latency=None, background_blur=None, voice_isolation=None, advanced=None)

The constraints of a track, as given to [`webrtc.MediaStreamTrack.apply_constraints()`](../interfaces/media_stream_track.md#webrtc.interfaces.media_stream_track.MediaStreamTrack.apply_constraints).

They’re also given per track to [`webrtc.MediaDevices.get_user_media()`](../interfaces/media_devices.md#webrtc.interfaces.media_devices.MediaDevices.get_user_media). The members are the ones of
[`MediaTrackConstraintSet`](#webrtc.models.media_track_constraints.MediaTrackConstraintSet), plus `advanced`.

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

* **Parameters:**
  **advanced** ([`list`](https://docs.python.org/3/builtins/stdtypes.html#list) of [`MediaTrackConstraintSet`](#webrtc.models.media_track_constraints.MediaTrackConstraintSet), optional) – More sets to try in order after the basic
  one. A set is applied only if all of it can be satisfied. A set that can’t be satisfied is skipped and
  doesn’t fail the constraints.

### *class* webrtc.models.media_track_constraints.MediaStreamConstraints(video=False, audio=False)

Which tracks [`webrtc.MediaDevices.get_user_media()`](../interfaces/media_devices.md#webrtc.interfaces.media_devices.MediaDevices.get_user_media) returns, and their constraints.

At least one of the two must be requested. See [MDN: MediaDevices/getUserMedia](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia).

* **Parameters:**
  * **video** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool) or [`MediaTrackConstraints`](#webrtc.models.media_track_constraints.MediaTrackConstraints), optional) – Whether to get a video track, and its
    constraints.
  * **audio** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool) or [`MediaTrackConstraints`](#webrtc.models.media_track_constraints.MediaTrackConstraints), optional) – Whether to get an audio track, and its
    constraints.
