Track constraints
Settings, capabilities and constraints of tracks.
See MDN: 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.
- class webrtc.models.media_track_constraints.DoubleRange(min=None, max=None)
A range of numbers a source supports, in
MediaTrackCapabilities.
- 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, optional) β The lowest value allowed, as a requirement.max (
int, optional) β The highest value allowed, as a requirement.exact (
int, optional) β The only value allowed, as a requirement.ideal (
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, optional) β The lowest value allowed, as a requirement.max (
float, optional) β The highest value allowed, as a requirement.exact (
float, optional) β The only value allowed, as a requirement.ideal (
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.
- class webrtc.models.media_track_constraints.ConstrainDOMStringParameters(exact=None, ideal=None)
A constraint on a string, with required values or preferred ones.
- 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.
- webrtc.models.media_track_constraints.ConstrainULong
A constraint on an integer, where a bare value is an ideal one
alias of
int|ConstrainULongRange
- webrtc.models.media_track_constraints.ConstrainDouble
A constraint on a number, where a bare value is an ideal one
alias of
float|ConstrainDoubleRange
- webrtc.models.media_track_constraints.ConstrainBoolean
A constraint on a boolean, where a bare value is an ideal one
alias of
bool|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|list[str] |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|str|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()returns.Every member is
True. A recognized constraint that the source has no capability or setting for (likefacing_modeon the synthetic camera) is ignored when ideal and fails when required.See MDN: MediaDevices/getSupportedConstraints.
- Parameters:
width (
bool, optional) β Whetherwidthis recognized.height (
bool, optional) β Whetherheightis recognized.aspect_ratio (
bool, optional) β Whetheraspect_ratiois recognized.frame_rate (
bool, optional) β Whetherframe_rateis recognized.facing_mode (
bool, optional) β Whetherfacing_modeis recognized.resize_mode (
bool, optional) β Whetherresize_modeis recognized.sample_rate (
bool, optional) β Whethersample_rateis recognized.sample_size (
bool, optional) β Whethersample_sizeis recognized.echo_cancellation (
bool, optional) β Whetherecho_cancellationis recognized.auto_gain_control (
bool, optional) β Whetherauto_gain_controlis recognized.noise_suppression (
bool, optional) β Whethernoise_suppressionis recognized.latency (
bool, optional) β Whetherlatencyis recognized.channel_count (
bool, optional) β Whetherchannel_countis recognized.device_id (
bool, optional) β Whetherdevice_idis recognized.group_id (
bool, optional) β Whethergroup_idis recognized.background_blur (
bool, optional) β Whetherbackground_bluris recognized.voice_isolation (
bool, optional) β Whethervoice_isolationis 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()returns.Members are
Nonewhen they donβt apply to the track or arenβt known yet. The library never fillsfacing_modeorbackground_blur.- Parameters:
width (
int, optional) β The width of the video.height (
int, optional) β The height of the video.aspect_ratio (
float, optional) β The width divided by the height.frame_rate (
float, optional) β The frames per second: a cameraβs selected one, otherwise measured over the last frames.resize_mode (
str, optional) β How the source is resized. Itβs'none'for the synthetic camera.device_id (
str, optional) β The device of a track ofwebrtc.MediaDevices.get_user_media().group_id (
str, optional) β The group ID of the device.sample_rate (
int, optional) β The samples per second of the audio.sample_size (
int, optional) β The bits per sample of the audio.channel_count (
int, optional) β The channels of the audio.echo_cancellation (
boolorstr, optional) β Whether echo is cancelled. ItβsFalsefor the synthetic microphone.auto_gain_control (
bool, optional) β Whether the gain is controlled automatically.noise_suppression (
bool, optional) β Whether noise is suppressed.facing_mode (
str, optional) β Where the camera faces, like'user'.latency (
float, optional) β The latency of the audio in seconds.background_blur (
bool, optional) β Whether the background is blurred.voice_isolation (
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()returns.Only the synthetic camera and microphone of
webrtc.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 isNone, because the library doesnβt control their source.See MDN: MediaStreamTrack/getCapabilities.
- Parameters:
width (
ULongRange, optional) β The widths of the video.height (
ULongRange, optional) β The heights of the video.aspect_ratio (
DoubleRange, optional) β The aspect ratios of the video.frame_rate (
DoubleRange, optional) β The frame rates of the video.resize_mode (
listofstr, optional) β The ways the source can be resized.device_id (
str, optional) β The device of the track.group_id (
str, optional) β The group ID of the device.sample_rate (
ULongRange, optional) β The sample rates of the audio.sample_size (
ULongRange, optional) β The bits per sample of the audio.channel_count (
ULongRange, optional) β The channels of the audio.echo_cancellation (
listofboolorstr, optional) β Whether echo can be cancelled.auto_gain_control (
listofbool, optional) β Whether the gain can be controlled.noise_suppression (
listofbool, optional) β Whether noise can be suppressed.facing_mode (
listofstr, optional) β Where the camera can face.latency (
DoubleRange, optional) β The latencies of the audio in seconds.background_blur (
listofbool, optional) β Whether the background can be blurred.voice_isolation (
listofbool, 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
MediaTrackConstraintsand of its advanced sets.Each member is either a bare value, which is ideal, or a constraint object with
exact,ideal,minandmax. The required parts fail the constraints if the source canβt satisfy them, but the ideal ones never do.- Parameters:
width (
intorConstrainULongRange, optional) β The width of the video.height (
intorConstrainULongRange, optional) β The height of the video.aspect_ratio (
floatorConstrainDoubleRange, optional) β The aspect ratio of the video.frame_rate (
floatorConstrainDoubleRange, optional) β The frame rate of the video.resize_mode (
strorConstrainDOMStringParameters, optional) β How the source is resized.device_id (
strorConstrainDOMStringParameters, optional) β The device.group_id (
strorConstrainDOMStringParameters, optional) β The group ID of the device.sample_rate (
intorConstrainULongRange, optional) β The sample rate of the audio.sample_size (
intorConstrainULongRange, optional) β The bits per sample of the audio.channel_count (
intorConstrainULongRange, optional) β The channels of the audio.echo_cancellation (
boolorConstrainBooleanOrDOMStringParameters, optional) β Whether echo is cancelled.auto_gain_control (
boolorConstrainBooleanParameters, optional) β Whether the gain is controlled automatically.noise_suppression (
boolorConstrainBooleanParameters, optional) β Whether noise is suppressed.facing_mode (
strorConstrainDOMStringParameters, optional) β Where the camera faces.latency (
floatorConstrainDoubleRange, optional) β The latency of the audio in seconds.background_blur (
boolorConstrainBooleanParameters, optional) β Whether the background is blurred.voice_isolation (
boolorConstrainBooleanParameters, 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().Theyβre also given per track to
webrtc.MediaDevices.get_user_media(). The members are the ones ofMediaTrackConstraintSet, plusadvanced.See MDN: MediaTrackConstraints.
- Parameters:
advanced (
listofMediaTrackConstraintSet, 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()returns, and their constraints.At least one of the two must be requested. See MDN: MediaDevices/getUserMedia.
- Parameters:
video (
boolorMediaTrackConstraints, optional) β Whether to get a video track, and its constraints.audio (
boolorMediaTrackConstraints, optional) β Whether to get an audio track, and its constraints.