diff options
Diffstat (limited to 'files/ru/web/api/mediatrackconstraints/index.html')
-rw-r--r-- | files/ru/web/api/mediatrackconstraints/index.html | 195 |
1 files changed, 195 insertions, 0 deletions
diff --git a/files/ru/web/api/mediatrackconstraints/index.html b/files/ru/web/api/mediatrackconstraints/index.html new file mode 100644 index 0000000000..1265eca23f --- /dev/null +++ b/files/ru/web/api/mediatrackconstraints/index.html @@ -0,0 +1,195 @@ +--- +title: MediaTrackConstraints +slug: Web/API/MediaTrackConstraints +tags: + - API + - Constraints + - Dictionary + - Interface + - Media + - Media Capture and Streams API + - Media Streams API + - MediaTrackConstraints + - NeedsTranslation + - Reference + - Screen Sharing + - Screen Sharing API + - Sharing + - TopicStub + - WebRTC + - screen +translation_of: Web/API/MediaTrackConstraints +--- +<div>{{APIRef("Media Capture and Streams")}}</div> + +<p>The <strong><code>MediaTrackConstraints</code></strong> dictionary is used to describe a set of capabilities and the value or values each can take on. A constraints dictionary is passed into {{domxref("MediaStreamTrack.applyConstraints", "applyConstraints()")}} to allow a script to establish a set of exact (required) values or ranges and/or preferred values or ranges of values for the track, and the most recently-requested set of custom constraints can be retrieved by calling {{domxref("MediaStreamTrack.getConstraints", "getConstraints()")}}.</p> + +<p>For each constraint, you can typically specify an exact value you need, an ideal value you want, a range of acceptable values, and/or a value which you'd like to be as close to as possible. The specifics vary somewhat depending on the type of the constrainable property.</p> + +<p>To learn more about how constraints work, see <a href="/en-US/docs/Web/API/Media_Streams_API/Constraints">Capabilities, constraints, and settings</a>.</p> + +<h2 id="Properties">Properties</h2> + +<p>Some combination—but not necessarily all—of the following properties will exist on the object. This may be because a given browser doesn't support the property, or because it doesn't apply. For example, because {{Glossary("RTP")}} doesn't provide some of these values during negotiation of a WebRTC connection, a track associated with a {{domxref("RTCPeerConnection")}} will not include certain values, such as {{domxref("MediaTrackConstraints.facingMode", "facingMode")}} or {{domxref("MediaTrackConstraints.groupId", "groupId")}}.</p> + +<h3 id="Properties_of_all_media_tracks">Properties of all media tracks</h3> + +<dl> + <dt>{{domxref("MediaTrackConstraints.deviceId", "deviceId")}}</dt> + <dd>A {{domxref("ConstrainDOMString")}} object specifying a device ID or an array of device IDs which are acceptable and/or required.</dd> + <dt>{{domxref("MediaTrackConstraints.groupId", "groupId")}}</dt> + <dd>A {{domxref("ConstrainDOMString")}} object specifying a group ID or an array of group IDs which are acceptable and/or required.</dd> +</dl> + +<h3 id="Properties_of_audio_tracks">Properties of audio tracks</h3> + +<dl> + <dt>{{domxref("MediaTrackConstraints.autoGainControl", "autoGainControl")}}</dt> + <dd>A {{domxref("ConstrainBoolean")}} object which specifies whether automatic gain control is preferred and/or required.</dd> + <dt>{{domxref("MediaTrackConstraints.channelCount", "channelCount")}}</dt> + <dd>A {{domxref("ConstrainLong")}} specifying the channel count or range of channel counts which are acceptable and/or required.</dd> + <dt>{{domxref("MediaTrackConstraints.echoCancellation", "echoCancellation")}}</dt> + <dd>A {{domxref("ConstrainBoolean")}} object specifying whether or not echo cancellation is preferred and/or required.</dd> + <dt>{{domxref("MediaTrackConstraints.latency", "latency")}}</dt> + <dd>A {{domxref("ConstrainDouble")}} specifying the latency or range of latencies which are acceptable and/or required.</dd> + <dt>{{domxref("MediaTrackConstraints.noiseSuppression", "noiseSuppression")}}</dt> + <dd>A {{domxref("ConstrainBoolean")}} which specifies whether noise suppression is preferred and/or required.</dd> + <dt>{{domxref("MediaTrackConstraints.sampleRate", "sampleRate")}}</dt> + <dd>A {{domxref("ConstrainLong")}} specifying the sample rate or range of sample rates which are acceptable and/or required.</dd> + <dt>{{domxref("MediaTrackConstraints.sampleSize", "sampleSize")}}</dt> + <dd>A {{domxref("ConstrainLong")}} specifying the sample size or range of sample sizes which are acceptable and/or required.</dd> + <dt>{{domxref("MediaTrackConstraints.volume", "volume")}}</dt> + <dd>A {{domxref("ConstrainDouble")}} specifying the volume or range of volumes which are acceptable and/or required.</dd> +</dl> + +<h3 id="Properties_of_image_tracks">Properties of image tracks</h3> + +<dl> + <dt>{{domxref("MediaTrackConstraints.whiteBalanceMode","whiteBalanceMode")}}</dt> + <dd>A {{jsxref("String")}} specifying one of <code>"none"</code>, <code>"manual"</code>, <code>"single-shot"</code>, or <code>"continuous"</code>.</dd> + <dt>{{domxref("MediaTrackConstraints.exposureMode","exposureMode")}}</dt> + <dd>A {{jsxref("String")}} specifying one of <code>"none"</code>, <code>"manual"</code>, <code>"single-shot"</code>, or <code>"continuous"</code>.</dd> + <dt>{{domxref("MediaTrackConstraints.focusMode","focusMode")}}</dt> + <dd>A {{jsxref("String")}} specifying one of <code>"none"</code>, <code>"manual"</code>, <code>"single-shot"</code>, or <code>"continuous"</code>.</dd> + <dt>{{domxref("MediaTrackConstraints.pointsOfInterest","pointsOfInterest")}}</dt> + <dd>The pixel coordinates on the sensor of one or more points of interest. This is either an object in the form { x:<em>value</em>, y:<em>value</em> } or an array of such objects, where <em>value </em> is a double-precision integer.</dd> + <dt>{{domxref("MediaTrackConstraints.expsureCompensation","exposureCompensation")}}</dt> + <dd>A {{domxref("ConstrainDouble")}} (a double-precision integer) specifying f-stop adjustment by up to ±3. </dd> + <dt>{{domxref("MediaTrackConstraints.colorTemperature","colorTemperature")}}</dt> + <dd>A {{domxref("ConstrainDouble")}} (a double-precision integer) specifying a desired color temperature in degrees kelvin.</dd> + <dt>{{domxref("MediaTrackConstraints.iso","iso")}}</dt> + <dd>A {{domxref("ConstrainDouble")}} (a double-precision integer) specifying a desired iso setting.</dd> + <dt>{{domxref("MediaTrackConstraints.brightness","brightness")}}</dt> + <dd>A {{domxref("ConstrainDouble")}} (a double-precision integer) specifying a desired brightness setting.</dd> + <dt>{{domxref("MediaTrackConstraints.contrast","contrast")}}</dt> + <dd>A {{domxref("ConstrainDouble")}} (a double-precision integer) specifying the degree of difference between light and dark.</dd> + <dt>{{domxref("MediaTrackConstraints.saturation","saturation")}}</dt> + <dd>A {{domxref("ConstrainDouble")}} (a double-precision integer) specifying the degree of color intensity.</dd> + <dt>{{domxref("MediaTrackConstraints.sharpness","sharpness")}}</dt> + <dd>A {{domxref("ConstrainDouble")}} (a double-precision integer) specifying the intensity of edges.</dd> + <dt>{{domxref("MediaTrackConstraints.focusDistance","focusDistance")}}</dt> + <dd>A {{domxref("ConstrainDouble")}} (a double-precision integer) specifying distance to a focused object.</dd> + <dt>{{domxref("MediaTrackConstraints.zoom","zoom")}}</dt> + <dd>A {{domxref("ConstrainDouble")}} (a double-precision integer) specifying the desired focal length.</dd> + <dt>{{domxref("MediaTrackConstraints.torch","torch")}}</dt> + <dd>A {{jsxref("Boolean")}} defining whether the fill light is continuously connected, meaning it stays on as long as the track is active.</dd> +</dl> + +<h3 id="Properties_of_video_tracks">Properties of video tracks</h3> + +<dl> + <dt>{{domxref("MediaTrackConstraints.aspectRatio", "aspectRatio")}}</dt> + <dd>A {{domxref("ConstrainDouble")}} specifying the video aspect ratio or range of aspect ratios which are acceptable and/or required.</dd> + <dt>{{domxref("MediaTrackConstraints.facingMode", "facingMode")}}</dt> + <dd>A {{domxref("ConstrainDOMString")}} object specifying a facing or an array of facings which are acceptable and/or required.</dd> + <dt>{{domxref("MediaTrackConstraints.frameRate", "frameRate")}}</dt> + <dd>A {{domxref("ConstrainDouble")}} specifying the frame rate or range of frame rates which are acceptable and/or required.</dd> + <dt>{{domxref("MediaTrackConstraints.height", "height")}}</dt> + <dd>A {{domxref("ConstrainLong")}} specifying the video height or range of heights which are acceptable and/or required.</dd> + <dt>{{domxref("MediaTrackConstraints.width", "width")}}</dt> + <dd>A {{domxref("ConstrainLong")}} specifying the video width or range of widths which are acceptable and/or required.</dd> + <dt>{{domxref("MediaTrackConstraints.resizeMode", "resizeMode")}}</dt> + <dd>A {{domxref("ConstrainDOMString")}} object specifying a mode or an array of modes the UA can use to derive the resolution of a video track. Allowed values are <code>none</code> and <code>crop-and-scale</code>. <code>none</code> means that the user agent uses the resolution provided by the camera, its driver or the OS. <code>crop-and-scale</code> means that the user agent can use cropping and downscaling on the camera output in order to satisfy other constraints that affect the resolution.</dd> +</dl> + +<h3 id="Properties_of_shared_screen_tracks">Properties of shared screen tracks</h3> + +<p>These constraints apply to <code>MediaTrackConstraints</code> objects specified as part of the {{domxref("DisplayMediaStreamConstraints")}} object's {{domxref("DisplayMediaStreamConstraints.video", "video")}} property when using {{domxref("MediaDevices.getDisplayMedia", "getDisplayMedia()")}} to obtain a stream for screen sharing.</p> + +<dl> + <dt>{{domxref("MediaTrackConstraints.cursor", "cursor")}}</dt> + <dd> + <p>A {{domxref("ConstrainDOMString")}} which specifies whether or not to include the mouse cursor in the generated track, and if so, whether or not to hide it while not moving. The value may be a single one of the following strings, or an array of them to allow the browser flexibility in deciding what to do about the cursor.</p> + + <dl> + <dt><code>always</code></dt> + <dd>The mouse is always visible in the video content of the {domxref("MediaStream"), unless the mouse has moved outside the area of the content.</dd> + <dt><code>motion</code></dt> + <dd>The mouse cursor is always included in the video if it's moving, and for a short time after it stops moving.</dd> + <dt><code>never</code></dt> + <dd>The mouse cursor is never included in the shared video.</dd> + </dl> + </dd> + <dt>{{domxref("MediaTrackConstraints.displaySurface", "displaySurface")}}</dt> + <dd> + <p>A {{domxref("ConstrainDOMString")}} which specifies the types of display surface that may be selected by the user. This may be a single one of the following strings, or a list of them to allow multiple source surfaces:</p> + + <dl> + <dt><code>application</code></dt> + <dd>The stream contains all of the windows of the application chosen by the user rendered into the one video track.</dd> + <dt><code>browser</code></dt> + <dd>The stream contains the contents of a single browser tab selected by the user.</dd> + <dt><code>monitor</code></dt> + <dd>The stream's video track contains the entire contents of one or more of the user's screens.</dd> + <dt><code>window</code></dt> + <dd>The stream contains a single window selected by the user for sharing.</dd> + </dl> + </dd> + <dt>{{domxref("MediaTrackConstraints.logicalSurface", "logicalSurface")}}</dt> + <dd>A {{domxref("ConstrainBoolean")}} value which may contain a single Boolean value or a set of them, indicating whether or not to allow the user to choose source surfaces which do not directly correspond to display areas. These may include backing buffers for windows to allow capture of window contents that are hidden by other windows in front of them, or buffers containing larger documents that need to be scrolled through to see the entire contents in their windows.</dd> +</dl> + +<h2 id="Specifications">Specifications</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">Specification</th> + <th scope="col">Status</th> + <th scope="col">Comment</th> + </tr> + <tr> + <td>{{SpecName('Media Capture', '#dom-mediatrackconstraints')}}</td> + <td>{{Spec2('Media Capture')}}</td> + <td>Initial definition.</td> + </tr> + <tr> + <td>{{SpecName('MediaStream Image', '#mediatrackconstraintset-section')}}</td> + <td>{{Spec2('MediaStream Image')}}</td> + <td>Adds image constraints.</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility">Browser compatibility</h2> + +<div> + + +<p>{{Compat("api.MediaTrackConstraints")}}</p> +</div> + +<h2 id="See_also">See also</h2> + +<ul> + <li><a href="/en-US/docs/Web/API/Media_Streams_API">Media Capture and Streams API</a></li> + <li><a href="/en-US/docs/Web/API/Media_Streams_API/Constraints">Capabilities, constraints, and settings</a></li> + <li><a href="/en-US/docs/Web/API/Screen_Capture_API">Screen Capture API</a></li> + <li><a href="/en-US/docs/Web/API/Screen_Capture_API/Using_Screen_Capture">Using the Screen Capture API</a></li> + <li>{{domxref("MediaDevices.getUserMedia()")}}</li> + <li>{{domxref("MediaStreamTrack.getConstraints()")}}</li> + <li>{{domxref("MediaStreamTrack.applyConstraints()")}}</li> + <li>{{domxref("MediaDevices.getSupportedConstraints()")}}</li> + <li>{{domxref("MediaTrackSupportedConstraints")}}</li> + <li>{{domxref("MediaStreamTrack.getSettings()")}}</li> +</ul> |