Abstract
This document defines how a user's display, or parts thereof, can be
used as the source of a media stream using
getDisplayMedia, an extension to the Media Capture API
[GETUSERMEDIA].
Status of This Document
This section describes the status of this document at the time of its publication. A list of current W3C publications and the latest revision of this technical report can be found in the W3C standards and drafts index.
This document is not complete. It is subject to major changes and, while early experimentations are encouraged, it is therefore not intended for implementation.
This document was published by the Web Real-Time Communications Working Group as a Working Draft using the Recommendation track.
Publication as a Working Draft does not imply endorsement by W3C and its Members.
This is a draft document and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to cite this document as other than a work in progress.
This document was produced by a group operating under the W3C Patent Policy. W3C maintains a public list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent that the individual believes contains Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy.
This document is governed by the 18 August 2025 W3C Process Document.
Table of Contents
- Abstract
- Status of This Document
- 1. Introduction
- 2. Conformance
- 3. Example
- 4. Terminology
- 5. Capturing Displayed Media
- 5.1
MediaDevicesAdditions - 5.2 Closed and Minimized Display Surfaces
- 5.3 Unconstrained Display Surface Selection
- 5.4 Constrainable Properties for Captured
Display Surfaces
- 5.4.1 Downscaling and Frame Decimation
- 5.4.2
CaptureStartFocusBehavior - 5.4.3
CaptureController - 5.4.4
SelfCapturePreferenceEnum - 5.4.5
SystemAudioPreferenceEnum - 5.4.6
WindowAudioPreferenceEnum - 5.4.7
SurfaceSwitchingPreferenceEnum - 5.4.8
MonitorTypeSurfacesEnum - 5.4.9
AudioSelectionPreferenceEnum - 5.4.10 DisplayMediaStreamOptions
- 5.4.11 Extensions to
MediaTrackSupportedConstraints - 5.4.12 Extensions to
MediaTrackConstraintSet - 5.4.13 Extensions to
MediaTrackSettings - 5.4.14 Extensions to
MediaTrackCapabilities - 5.4.15
DisplayCaptureSurfaceType - 5.4.16
CursorCaptureConstraint
- 5.5 Device Identifiers
- 5.1
- 6. Permissions Integration
- 7. Permissions Policy Integration
- 8. Privacy Indicator Requirements
- 9. Security and Permissions
- A. References
This section is non-normative.
This document describes an extension to the Media Capture API [GETUSERMEDIA] that enables the acquisition of a user's display, or part thereof, in the form of a video track. In some cases system, application or window audio is also captured which is presented in the form of an audio track. This enables a number of applications, including screen sharing using WebRTC [WEBRTC].
This feature has signficant security implications. Applications that use this API to access information that is displayed to users could access confidential information from other origins if that information is under the control of the application. This includes content that would otherwise be inaccessible due to the protections offered by the user agent sandbox.
This document concerns itself primarily with the capture of video and audio [GETUSERMEDIA], but the general mechanisms defined here could be extended to other types of media, of which depth [MEDIACAPTURE-DEPTH] is currently defined.
As well as sections marked as non-normative, all authoring guidelines, diagrams, examples, and notes in this specification are non-normative. Everything else in this specification is normative.
The key words MAY, MUST, MUST NOT, and SHOULD in this document are to be interpreted as described in BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all capitals, as shown here.
This specification defines conformance criteria that apply to a single product: the user agent that implements the interfaces that it contains.
Implementations that use ECMAScript [ECMA-262] to implement the APIs defined in this specification must implement them in a manner consistent with the ECMAScript Bindings defined in the Web IDL specification [WEBIDL], as this specification uses that specification and terminology.
The following example demonstrates a request for display capture using
the navigator.mediaDevices.getDisplayMedia method defined in
this document.
try {
let mediaStream = await navigator.mediaDevices.getDisplayMedia({video:true});
videoElement.srcObject = mediaStream;
} catch (e) {
console.log('Unable to acquire screen capture: ' + e);
}
This document uses the definition of MediaStream,
MediaStreamTrack and ConstrainablePattern from
[GETUSERMEDIA].
Screen capture encompasses the capture of several different types of screen-based surfaces. Collectively, these are referred to as display surfaces , of which this document defines the following types:
- A monitor
display surface represents a physical display. Some systems have
multiple monitors, which can be identified
separately. Multiple monitors might also be
aggregated into a single logical monitor. An
aggregated display surface is captured as a single
MediaStreamTrack. - A window display surface is a single contiguous surface that is used by a single application.
- A browser display surface is the rendered form of a browsing context. This is not strictly limited to HTML [HTML] documents, though the discussion in this document will address some specific concerns with the capture of HTML.
This document draws a distinction between two variants of each type of display surface:
- A logical display surface is the surface that an operating system makes available to an application for the purposes of rendering.
- a visible display surface is the portion of a logical display surface that is rendered to a monitor.
Some operating systems permit windows from different applications to occlude other windows, in whole or part, so the visible display surface is a strict subset of the logical display surface.
The source pixel ratio of a display surface is 1/96th of 1 inch divided by its vertical pixel size.
The devicechange event is defined in [GETUSERMEDIA].
Capture of displayed media is enabled through the addition of a new
getDisplayMedia method on the MediaDevices interface,
that is similar to getUserMedia() , except that it
acquires media from one display device chosen by the end-user each
time.
partial interface MediaDevices {
Promise<MediaStream> getDisplayMedia(optional DisplayMediaStreamOptions options = {});
};
-
getDisplayMedia -
Prompts the user for permission to live-capture their display.
The user agent MUST let the end-user choose which display surface to share out of all available choices every time, and MUST NOT use any
MediaTrackConstraintsin options.videoor options.audioto limit that choice.The user agent MAY use the presence of the
displaySurfaceconstraint and its value to influence the presentation to the user of the sources to pick from. The user agent MUST still offer the user unlimited choice of any display surface. The user agent is strongly recommended to steer users away from sharing a monitor, as this poses risks to user privacy.Any
MediaTrackConstraintsin options.videoor options.audioMUST be applied to the media chosen by the user only after the user has made their selection.In the case of audio, the user agent MAY present the end-user with audio sources to share. Which choices are available to choose from is up to the user agent, and the audio source(s) are not necessarily the same as the video source(s). An audio source may be a particular window, browser, the entire system audio or any combination thereof. Unlike
getUserMedia()with regards to audio+video, the user agent is allowed not to return audio even if the audio constraint is present. If the user agent knows no audio will be shared for the lifetime of the stream it MUST NOT include an audio track in the resulting stream. The user agent MAY accept a request for audio and video by only returning a video track in the resulting stream, or it MAY accept the request by returning both an audio track and a video track in the resulting stream. The user agent MUST reject audio-only requests.In addition to drawing from a different set of sources and requiring user selection,
getDisplayMediaalso differs fromgetUserMedia()in that "granted" permissions cannot be persisted.When the
getDisplayMedia()method is called, the user agent MUST run the following steps:-
Let mediaDevices be this.
-
Let controller be options.
controllerif present, ornullotherwise. -
If controller is not
null, run the following steps:-
If controller.
[[IsBound]]istrue, return a promise rejected with aDOMExceptionobject whosenameattribute has the valueInvalidStateError. -
Set controller.
[[IsBound]]totrue.
-
-
If the relevant global object of this does not have transient activation, return a promise rejected with a
DOMExceptionobject whosenameattribute has the valueInvalidStateError. -
Let options be the method's first argument.
-
Let constraints be
[options.audio, options.video]. -
If
constraints.videoisfalse, return a promise rejected with a newly createdTypeError. -
For each existing member in constraints whose value, CS, is a dictionary, run the following steps:
-
If CS contains a member named
advanced, return a promise rejected with a newly createdTypeError. -
If CS contains a member whose name specifies a constrainable property applicable to display surfaces, and whose value in turn is a dictionary containing a member named either
minorexact, return a promise rejected with a newly createdTypeError. -
If CS contains a member whose name specifies a constrainable property applicable to display surfaces, and whose value in turn is a dictionary containing a member named
max, and that member's value in turn is less than the constrainable property's floor value, then let failedConstraint be the name of the member, let message be eitherundefinedor an informative human-readable message, and return a promise rejected with a newOverconstrainedErrorcreated by callingOverconstrainedError(failedConstraint, message).
-
-
Let requestedMediaTypes be the set of media types in constraints with either a dictionary value or a value of
true. -
If the current settings object's relevant global object's associated
Documentis NOT fully active or does NOT have focus, return a promise rejected with aDOMExceptionobject whosenameattribute has the valueInvalidStateError. -
Let p be a new promise.
-
Run the following steps in parallel:
-
For each media type T in requestedMediaTypes,
-
If no sources of type T are available, queue a task on the user interaction task source to reject p with a new
DOMExceptionobject whosenameattribute has the valueNotFoundError, and abort these steps. -
Read the current permission state for obtaining sources of type T in the current browsing context. If the permission state is "
denied", jump to the step labeled PermissionFailure below.
-
-
Optionally, e.g., based on a previously-established user preference, for security reasons, or due to platform limitations, jump to the step labeled Permission Failure below.
-
Prompt the user to choose a display device, for a
PermissionDescriptorwith itsnameset to "display-capture", resulting in a set of provided media.The provided media MUST include precisely one video track.
The provided media MUST include at most one audio track. This audio track MUST NOT be included if audio was not specified in requestedMediaTypes, or if it was specified as
false.The devices chosen MUST be the ones determined by the user. Once selected, the source of a
MediaStreamTrackMUST NOT change, unless the user permits it through their interaction with the user agent.User agents are encouraged to warn users against sharing browser display devices as well as monitor display devices where browser windows are visible, or otherwise try to discourage their selection on the basis that these represent a significantly higher risk when shared.
If the result of the request is "
granted", then for each device that is sourcing the provided media, using a stable and private id for the device, deviceId, set [[devicesLiveMap]][deviceId] totrue, if it isn’t alreadytrue, and set the [[devicesAccessibleMap]][deviceId] totrue, if it isn’t alreadytrue.The user agent MUST NOT store a "
granted" permission entry.If the result is "
denied", jump to the step labeled Permission Failure below. If the user never responds, this algorithm stalls on this step.If the user grants permission but a hardware error such as an OS/program/webpage lock prevents access, queue a task on the user interaction task source to reject p with a new
DOMExceptionobject whosenameattribute has the valueNotReadableError, and abort these steps.If the result is "
granted" but device access fails for any reason other than those listed above, queue a task on the user interaction task source to reject p with a newDOMExceptionobject whosenameattribute has the valueAbortError, and abort these steps. -
Let stream be a
MediaStreamobject. -
For each source that the user granted permission to, run the following steps:
-
Let track be the result of creating a MediaStreamTrack with source and mediaDevices.
-
Add track to stream's track set.
-
Tie track source to MediaDevices with source and mediaDevices.
-
-
Run the ApplyConstraints algorithm on all tracks in stream with the appropriate constraints. Should this fail, let failedConstraint be the result of the algorithm that failed, and let message be either
undefinedor an informative human-readable message, and then queue a task on the user interaction task source to reject p with a newOverconstrainedErrorcreated by callingOverconstrainedError(failedConstraint, message), and abort these steps. -
This invocation of
getDisplayMedia()is now considered to have produced a new capture-session . -
Queue a task on the user interaction task source to run the following steps:
-
If controller is not
null, run the following steps:-
Set controller.
[[Source]]to stream's video track's [[Source]]. -
Set controller.
[[DisplaySurfaceType]]to the to stream's video track'sDisplayCaptureSurfaceType.
-
- Set the last activation timestamp to the current high resolution time.
-
Resolve p with stream.
-
-
If controller is not
null, queue a task on the user interaction task source to run the finalize focus decision algorithm on controller. -
Abort these steps.
-
Permission Failure: Queue a task on the user interaction task source to reject p with a new
DOMExceptionobject whosenameattribute has the valueNotAllowedError.
-
-
Return p.
When the top-level document loses focus, run the following steps on all
CaptureControllerobjects in that document and in documents of its nested browsing contexts:-
If
[[Source]]isundefined, abort these steps. -
Set
[[FocusChangeDisabled]]totrue.
The user agent MUST NOT capture content that's behind a partially transparent captured display surface.
For the newly created
MediaStreamTrack, the user agent MUST NOT capture the prompt that was shown to the user.Information that is not currently rendered to the screen SHOULD be obscured in captures unless the application has been specifically authorized to access that content (e.g. through means such as elevated permissions).
The user agent MUST NOT share audio without active user consent, for example if the capture of the video of a window is accompanied by capture of the audio of the entire system, including applications unrelated to that window.
-
A display surface that is being shared may temporarily or permanently become inaccessible to the application because of actions taken by the operating system or user agent. What makes a display surface considered inaccesible is outside the scope of this specification, but examples MAY include a monitor disconnecting, window or browser closing or becoming minimized, or due to an incoming call on a phone.
Note
User agents ultimately control what inaccesible means in this context, but are encouraged to only fire mute and unmute events for interruptions that have external reasons.
When display surface enters an inaccessible state that is not
necessarily permanent, the user agent MUST queue a task on the
user interaction task source that sets the muted state of the corresponding media
track to true.
When display surface exits an inaccessible state and becomes
accessible, the user agent MUST queue a task on the
user interaction task source that sets the muted state of the corresponding media track to
false.
When a display surface enters an inaccessible state that is permanent (such as the source window closing), the user agent MUST queue a task on the user interaction task source that ends the corresponding media track.
A stream that was just returned by getDisplayMedia
MAY contain tracks that are muted by default. Audio and video tracks
belonging to the same stream MAY be muted/unmuted independently of one
another.
Not accepting constraints for source selection
means that getDisplayMedia only provides fingerprinting
surface that exposes whether audio, video or audio and video display
sources are present. ![]()
Note that accepting the displaySurface constraint does not limit
user selection.
Constraints serve a different purpose in
getDisplayMedia than they do in
getUserMedia(). They do not aid discovery, instead they
are applied only after user-selection.
This section define which constraints apply to
getDisplayMedia tracks; constraints defined for
getUserMedia() do not apply unless listed here.
Some of these constraints enable user agent processing like downscaling and frame decimation, as well as display-specific features. Others enable observation of inherent properties of a user-selected display surface, as capabilities and settings.
The following new and existing MediaStreamTrack Constrainable Properties are
defined to apply to the user-selected video display surface, with
the following behavior:
| Property Name | Type | Behavior |
|---|---|---|
| width | unsigned long |
The width, in pixels. As a capability, max MUST reflect the display surface's width, and min MUST reflect the width of the smallest aspect-preserving representation available through downscaling by the user agent. |
| height | unsigned long |
The height, in pixels. As a capability, max MUST reflect the display surface's height, and min MUST reflect the height of the smallest aspect-preserving representation available through downscaling by the user agent. |
| frameRate | double |
The frame rate (frames per second). As a capability, max MUST reflect the display surface's frame rate, and min MUST reflect the lowest frame rate available through frame decimation by the user agent. |
| aspectRatio | double |
The exact aspect ratio (width in pixels divided by height in
pixels, represented as a double rounded to the tenth decimal place)
or aspect ratio range. As a setting, represents width /
height. As a capability, min and max both MUST be the
current setting value, rendering this property immutable from the
application viewpoint. |
| resizeMode | DOMString |
This string is one of the members of VideoResizeModeEnum. As
a setting, "none" means the
MediaStreamTrack contains all bits needed to render the
display in full detail, which if the source pixel
ratio > 1, means width and
height will be larger than the display's appearance
from an end-user viewpoint would suggest, whereas
"crop-and-scale" means the
MediaStreamTrack contains an aspect-preserved representation
of the display surface that has been downscaled by the
user agent, but not cropped. As a capability, the values
"none" and
"crop-and-scale" both MUST be present.
|
| deviceId | DOMString |
The identifier of the surface being captured.
As a setting, identifies the display surface that is being captured. The identifier MUST be uniquely generated for each document. As a capability, the setting value MUST be the lone value present, rendering this property immutable from the application viewpoint. |
| displaySurface | DOMString |
This string is one of the members of
As a setting, indicates the type of display surface that is being captured. As a capability, the setting value MUST be the lone value present, rendering this property immutable from the application viewpoint. As a constraint, the value signals the application's
preference of a particular display surface type to the user
agent; the user agent MAY reorder the options offered to the user
according to that preference. This constraint is ignored for all
other purposes, and can therefore not cause any side effects
(such as being the cause of
|
| logicalSurface | boolean |
As a setting, a value of true indicates capture of
a logical display surface, whereas a value of
false indicates a capture of a visible display surface. As a capability, this same value MUST be the lone value
present, rendering this property immutable from the application
viewpoint. |
| cursor | DOMString |
This string is one of the members of
CursorCaptureConstraint. As a setting, indicates if and when
the cursor is included in the captured display surface. As a
capability, the user agent MUST include only the set of values from
CursorCaptureConstraint it is capable of supporting for this
display surface. |
| screenPixelRatio | double |
As a setting, it is the result of dividing the size of a CSS pixel at a page zoom of 1.0 and using a scale factor of 1.0 by the vertical size of a pixel from the display surface. It cannot be used as a constraint or capability. |
The following new and existing MediaStreamTrack Constrainable Properties are
defined to apply to the user-selected audio sources, with the following
behavior:
| Property Name | Type | Behavior |
|---|---|---|
| restrictOwnAudio | boolean |
As a setting, this value indicates whether or not the user agent is applying own audio restriction to the source. As a constraint, this property can be constrained resulting in a source with own audio restriction enabled or disabled. When own audio restriction is applied, the user
agent MUST attempt to remove any audio from the audio being
captured that was produced by the document that performed
|
| suppressLocalAudioPlayback | boolean |
As a setting, this value indicates whether or not the application instructed the user agent to apply local audio playback suppression to the source. As a constraint, this value is only meaningful if the user
selects capturing a browser display surface. In that case, a value of When local audio playback suppression is applied, the user agent SHOULD stop relaying audio to the local speakers, but that audio MUST still be captured by any ongoing audio-capturing capture-sessions. This suppression MUST NOT be observable to the captured document. Furthermore, the capturing document may only observe whether it is applying suppressLocalAudioPlayback; not whether that suppression is having an effect (i.e. can't observe if the user is overriding this in the user agent). When a browser display surface is
subject to multiple concurrent captures, local audio playback
suppression SHOULD be applied as long as at least one active
audio-capturing capture-session is constraining
suppressLocalAudioPlayback to |
When inherent properties of the underlying source of a user-selected display surface change, for example in response to the end-user resizing a captured window, and these changes render the capabilities and/or settings of one or more constrainable properties outdated, the user agent MUST queue a task on the user interaction task source to run the following step:
-
Update all affected constrainable properties at the same time.
If this causes an "overconstrained" situation, then the user agent MUST ignore the culprit constraints for as long as they overconstrain. The user agent MUST NOT mute the track.
Note
While min and exact constraints produce TypeError on getDisplayMedia(), this specification does not alter the track.applyConstraints() method. Therefore, they may instead produce OverconstrainedError or succeed depending on values, and therefore potentially be present to cause this "overconstrained" situation. The max constraint may also cause this, e.g. with aspectRatio. This spec considers these to be edge cases that aren't useful.
For the purposes of the SelectSettings algorithm, the user agent SHOULD consider all possible combinations of downscaled dimensions that preserve the aspect ratio of the original display surface (to the nearest pixel), and frame rates available through frame decimation, as available settings dictionaries.
The downscaling and decimation effects of constraints is then effectively governed by the fitness distance algorithm.
The intent is for the user agent to produce output that is close to
the ideal width, ideal height, and/or ideal
frameRate when these are specified, while at all times
preserving the aspect ratio of the original display surface.
The user agent SHOULD downscale by the source pixel ratio by default, unless otherwise directed by applied constraints.
The user agent MUST NOT crop the captured output.
The user agent MUST NOT upscale the captured output, or create additional frames, except as needed to preserve high resolutions and frame rates in an aggregated display surface.
Note
The max constraint type lets a web application provide a maximum envelope for constrainable properties like width and height. This is helpful to limit extreme aspect ratios, should the end-user resize a window or browser surface to such an extreme while it is being captured.
For each constrainable property of positive numeric type in this
specification, the user agent MUST establish a floor value ,
representing the smallest allowable value supported by the user agent
regardless of source. This value MUST be constant and MUST be greater
than 0. The user agent is encouraged to support all values
above the floor value regardless of source.
Note
The purpose of the floor value is to help user agents avoid
failing getDisplayMedia() with
OverconstrainedError after the user has already been
prompted, and avoid leaking information about the user's system.
Describes whether an application invoking
setFocusBehavior() would like the user agent to
focus the display surface associated with that
CaptureController's capture-session.
enum CaptureStartFocusBehavior {
"focus-capturing-application",
"focus-captured-surface",
"no-focus-change"
};
| Enumeration description | |
|---|---|
focus-capturing-application
|
The application prefers to be focused. |
focus-captured-surface
|
The application prefers that the display surface
associated with this CaptureController's capture-session
be focused. |
no-focus-change
|
The application prefers that the user agent not change focus, leaving focus with whichever surface last had focus following the user's interaction with the user agent and/or operating system. |
Note
The Working Group is investigating the possibility of deprecating
"no-focus-change".
A CaptureController object may be associated with a
capture-session. It would be used to expose functionality that's
associated with the capture-session itself, rather than with the
call to getDisplayMedia() or its resulting stream or
tracks.
Any given capture-session is associated with at most one
CaptureController.
At most one CaptureController is associated with any given
capture-session.
[Exposed=Window, SecureContext]
interface CaptureController : EventTarget {
constructor();
undefined setFocusBehavior(CaptureStartFocusBehavior focusBehavior);
};
(Feature at Risk) Issue 1
CaptureController does not yet define event handlers, so it is
not required to inherit from EventTarget. This is for the benefit
of future specifications that extend CaptureController with event
handler attributes; if inheritance is not used, it can be
removed.
-
constructor -
Create a new
CaptureControllerobject with the following internal slots:Internal Slot Initial value Description (non-normative) [[IsBound]] falseWhether an application has attempted to associate this with a capture-session. [[Source]] nullThe source of the associated capture-session. [[DisplaySurfaceType]] nullOnce capture starts, this will be set to the type of the captured display surface. [[FocusChangeDisabled]] falseWhether focus-change has been disabled by an external event or a user agent consideration. [[FocusDecisionFinalized]] falseSet to true when the focus decision is finalized. [[FocusBehavior]] nullThe focus behavior desired by the application. The user agent MAY set
[[FocusChangeDisabled]]totrueat any moment based on its own logic. -
setFocusBehavior -
Run the following steps:
-
Let focusBehavior be the method's first argument.
-
If this.
[[Source]]isnull, set this.[[FocusBehavior]]to focusBehavior and abort these steps. -
If this.
[[Source]]has been stopped, throw an "InvalidStateError"DOMException. -
If this.
[[DisplaySurfaceType]]is neither "browser" nor "window", throw an "InvalidStateError"DOMException. -
If this.
[[FocusDecisionFinalized]]istrue, throw an "InvalidStateError"DOMException. -
Set this.
[[FocusBehavior]]to focusBehavior. -
Run the finalize focus decision algorithm on this.
-
The finalize focus decision algorithm , given a controller, consists of running the following steps:
-
If too much time has elapsed since the capture-session started, the user agent SHOULD set
[[FocusDecisionFinalized]]totrue. The timespan is left up to the user agent, but it is recommended that a value of one second be used. -
If controller.
[[FocusDecisionFinalized]]istrue, abort these steps. -
Set controller.
[[FocusDecisionFinalized]]totrue. -
If controller.
[[FocusChangeDisabled]]istrue, abort these steps. -
If controller.
[[DisplaySurfaceType]]is neither "browser" nor "window", abort these steps. -
Let focusBehavior be controller.
[[FocusBehavior]]. -
Run the following steps in parallel:
-
If focusBehavior is "
focus-capturing-application", focus the display surface representing the capturing document. -
If focusBehavior is "
focus-captured-surface", focus the display surface referred to by controller.[[Source]].
-
Describes the different hints an application can provide about whether the display surface the application is in, should be among the choices offered to the user.
enum SelfCapturePreferenceEnum {
"include",
"exclude"
};
| Enum value | Description |
|---|---|
include
|
The application prefers the surface be included among the choices offered. |
exclude
|
The application prefers the surface be excluded from the choices offered. |
Describes whether an application invoking
getDisplayMedia() would like the user agent to include
system audio among the audio sources offered to the user for
monitor display surfaces. Does not apply to any
other type of display surface.
enum SystemAudioPreferenceEnum {
"include",
"exclude"
};
| Enumeration description | |
|---|---|
include
|
The application prefers that options to share system audio be offered to the user for monitor display surfaces. |
exclude
|
The application prefers that options to share system audio not be offered to the user for monitor display surfaces. |
Describes whether an application invoking
getDisplayMedia() would like the user agent to include
window or system audio among the audio sources offered to the user for
window display surfaces.
enum WindowAudioPreferenceEnum {
"system",
"window",
"exclude"
};
| Enumeration description | |
|---|---|
system
|
The application prefers that options to share system audio be offered to the user for window display surfaces. |
window
|
The application prefers that options to share window audio be offered to the user for window display surfaces. |
exclude
|
The application prefers that options to share audio not be offered to the user for window display surfaces. |
Describes whether an application invoking
getDisplayMedia() would like the user agent to offer
the user an option to dynamically switch the source display surface
during the capture.
enum SurfaceSwitchingPreferenceEnum {
"include",
"exclude"
};
| Enumeration description | |
|---|---|
include
|
The application prefers that an option to dynamically switch the source display surface during the capture be offered to the user. |
exclude
|
The application prefers that an option to dynamically switch the source display surface during the capture NOT be offered to the user. |
Describes whether the application would like the user agent to offer the user the option to choose display surfaces whose type is monitor.
enum MonitorTypeSurfacesEnum {
"include",
"exclude"
};
| Enumeration description | |
|---|---|
include
|
The application prefers that the display surfaces presented to the user include those of type monitor. |
exclude
|
The application prefers that the display surfaces presented to the user exclude those of type monitor. |
Describes whether an application invoking
getDisplayMedia() would like the user agent to prefer
capturing audio along with the video.
enum AudioSelectionPreferenceEnum {
"preferred"
};
| Enumeration description | |
|---|---|
preferred
|
The application prefers that the user agent prioritize capturing audio along with the video. |
The DisplayMediaStreamOptions dictionary is used to
instruct the user agent what sort of MediaStreamTracks may be
included in the MediaStream returned by
getDisplayMedia.
dictionary DisplayMediaStreamOptions {
(boolean or MediaTrackConstraints) video = true;
(boolean or MediaTrackConstraints) audio = false;
CaptureController controller;
SelfCapturePreferenceEnum selfBrowserSurface;
SystemAudioPreferenceEnum systemAudio;
WindowAudioPreferenceEnum windowAudio;
SurfaceSwitchingPreferenceEnum surfaceSwitching;
MonitorTypeSurfacesEnum monitorTypeSurfaces;
AudioSelectionPreferenceEnum audioSelection;
};
-
videoof type(boolean or, defaulting toMediaTrackConstraints)true -
If
true, it requests that the returnedMediaStreamcontain a video track. If aConstraintsstructure is provided, it further specifies desired processing options to be applied to the video track rendition of the display surface chosen by the user. Iffalse, the request will be rejected with aTypeError, as per the getDisplayMedia algorithm. -
audioof type(boolean or, defaulting toMediaTrackConstraints)false -
If
true, it signals an interest that the returnedMediaStreamcontain an audio track, if supported and audio is available for display surface chosen by the user. If aConstraintsstructure is provided, it further specifies desired processing options to be applied to the audio track. Iffalse, theMediaStreamwill not contain an audio track. -
controllerof typeCaptureController -
If present, this
CaptureControllerobject will be associated with the capture-session. Through the methods exposed on this object, the capture-session can be manipulated. -
selfBrowserSurfaceof typeSelfCapturePreferenceEnum - If present, signals application preference for whether the browser display surface which is associated with this's relevant global object's associated Document's top-level browsing context, should be among the choices offered to the user. The user agent MAY ignore this hint.
-
systemAudioof typeSystemAudioPreferenceEnum - If present, signals whether the application would like system audio to be included among the possible audio sources offered to the user for monitor display surfaces. The user agent MAY ignore this hint.
-
windowAudioof typeWindowAudioPreferenceEnum - If present, signals whether the application would like window or system audio among the possible audio sources offered to the user for window display surfaces. The user agent MAY ignore this hint.
-
surfaceSwitchingof typeSurfaceSwitchingPreferenceEnum - If present, signals whether the application would like the user agent to offer the user an option to dynamically switch the captured display surface. The user agent MAY ignore this hint.
-
monitorTypeSurfacesof typeMonitorTypeSurfacesEnum -
If present, signals whether the application would like the user agent to include display surfaces whose type is monitor among the choices offered to the user. The user agent MAY ignore this hint.
Note
The user agent may still offer to the user the option to capture display surfaces of type monitor. Applications are therefore encouraged to still check the
displaySurfacesetting of the tracks they receive. -
audioSelectionof typeAudioSelectionPreferenceEnum -
If present, signals whether the application would like the user agent to steer the user towards sharing audio along with the video. The user agent MAY ignore this hint.
MediaTrackSupportedConstraints is extended here with the list of
constraints that a user agent recognizes.
partial dictionary MediaTrackSupportedConstraints {
boolean displaySurface = true;
boolean logicalSurface = true;
boolean cursor = true;
boolean restrictOwnAudio = true;
boolean suppressLocalAudioPlayback = true;
};
-
displaySurfaceof typeboolean, defaulting totrue -
Whether
displaySurfaceconstraint is recognized. -
logicalSurfaceof typeboolean, defaulting totrue -
Whether
logicalSurfaceconstraint is recognized. -
cursorof typeboolean, defaulting totrue -
Whether
cursorconstraint is recognized. -
restrictOwnAudioof typeboolean, defaulting totrue -
Whether
restrictOwnAudioconstraint is recognized. -
suppressLocalAudioPlaybackof typeboolean, defaulting totrue -
Whether
suppressLocalAudioPlaybackconstraint is recognized.
MediaTrackConstraintSet is used for reading the current status
of constraints.
partial dictionary MediaTrackConstraintSet {
ConstrainDOMString displaySurface;
ConstrainBoolean logicalSurface;
ConstrainDOMString cursor;
ConstrainBoolean restrictOwnAudio;
ConstrainBoolean suppressLocalAudioPlayback;
};
-
displaySurfaceof typeConstrainDOMString -
The type of display surface that is being captured. This assumes values from the
DisplayCaptureSurfaceTypeenumeration. -
logicalSurfaceof typeConstrainBoolean -
A value of
trueindicates capture of a logical display surface; a value offalseindicates a capture of a visible display surface. -
cursorof typeConstrainDOMString -
Assumes values from the
CursorCaptureConstraintenumeration that determines if and when the cursor is included in the captured display surface. -
restrictOwnAudioof typeConstrainBoolean -
This constraint is only applicable to audio tracks. See
restrictOwnAudio. -
suppressLocalAudioPlaybackof typeConstrainBoolean -
This constraint is only applicable to audio tracks. See
suppressLocalAudioPlayback.
When the getSettings() method is invoked on a
video stream track, the user agent must return the extended
MediaTrackSettings dictionary, representing the current status of
the underlying user agent.
partial dictionary MediaTrackSettings {
DOMString displaySurface;
boolean logicalSurface;
DOMString cursor;
boolean restrictOwnAudio;
boolean suppressLocalAudioPlayback;
double screenPixelRatio;
};
-
displaySurfaceof typeDOMString -
The type of display surface that is being captured. This assumes values from the
DisplayCaptureSurfaceTypeenumeration. -
logicalSurfaceof typeboolean -
A value of
trueindicates capture of a logical display surface; a value offalseindicates a capture capture of a visible display surface. -
cursorof typeDOMString -
Assumes values from the
CursorCaptureConstraintenumeration that determines if and when the cursor is included in the captured display surface. -
restrictOwnAudioof typeboolean -
Indicates whether the restrictOwnAudio constraint is applied (
true) or not (false). -
suppressLocalAudioPlaybackof typeboolean -
Indicates whether or not the application instructed the user agent to apply local audio playback suppression to the source.
-
screenPixelRatioof typedouble -
The screen pixel ratio of of the display surface being captured.
When the getCapabilities() method is invoked on
a video stream track, the user agent must return the extended
MediaTrackCapabilities dictionary, representing the capabilities of
the underlying user agent.
partial dictionary MediaTrackCapabilities {
DOMString displaySurface;
boolean logicalSurface;
sequence<DOMString> cursor;
};
-
displaySurfaceof typeDOMString -
MUST be the same value as is returned by
getSettings(), rendering this property immutable from the application's viewpoint. -
logicalSurfaceof typeboolean -
MUST be the same value as is returned by
getSettings(), rendering this property immutable from the application's viewpoint. -
cursorof type sequence<DOMString> -
MUST consist of exactly the set of values from
CursorCaptureConstraintthat the user agent is capable of supporting for this track.
The DisplayCaptureSurfaceType enumeration describes the
different types of display surface.
enum DisplayCaptureSurfaceType {
"monitor",
"window",
"browser"
};
| Enum value | Description |
|---|---|
monitor
|
a monitor display surface, physical display, or collection of physical displays |
window
|
a window display surface, or single application window |
browser
|
a browser display surface, or single browser window |
The CursorCaptureConstraint enumerates the conditions under
which the cursor is captured.
enum CursorCaptureConstraint {
"never",
"always",
"motion"
};
| Enum value | Description |
|---|---|
never
|
a "never" cursor capture
constraint omits the cursor from the captured display
surface. |
always
|
a "always" cursor capture
constraint includes the cursor in the captured display
surface. |
motion
|
a "motion" cursor capture
constraint includes the cursor in the captured display surface
when the cursor/pointer is moved. The captured cursor is
removed when there is no further movement of the pointer/cursor
for certain period of time, as determined by the user
agent.
|
Each potential source of capture is treated by this API as a discrete
media source. However, display capture sources MUST NOT be enumerated by
enumerateDevices(), since this would reveal too much
information about the host system.
Display capture sources therefore cannot be selected with the
deviceId constraint, since their
deviceIds are not exposed.
Note
This is not to be confused with the stable and private id of the same name used in algorithms to implement privacy indicators.
Screen Capture is a powerful feature which is identified by the name "display-capture", requiring express permission to be used.
As required for integration with the Permissions specification, this specification defines the following:
- permission state constraints
-
Valid values for this descriptor's permission state are
"
prompt" and "denied". The user agent MUST NOT ever set this descriptor's permission state to "granted".
This specification defines a policy-controlled feature identified by
the string "display-capture" . Its
default allowlist is "self".
Note
This specification extends the Privacy Indicator
Requirements of getUserMedia() to include
getDisplayMedia.
References in this specification to [[devicesLiveMap]],
[[devicesAccessibleMap]], and [[kindsAccessibleMap]] refer to the
definitions already created to support Privacy Indicator Requirements for
getUserMedia().
For each kind of device that getDisplayMedia
exposes, using a stable and private id for the device, deviceId,
set kind to "Display" + kind, and do the
following:
- Define any<kind>Accessible (e.g.
anyDisplayVideoAccessible) as the logical OR of the
[[kindsAccessibleMap]][kind] value and all the
[[devicesAccessibleMap]][deviceId] values for devices of that
kind, and initialize all values to
false. - Define any<kind>Accessible (e.g.
anyDisplayVideoAccessible) as the logical OR of the
[[kindsAccessibleMap]][kind] value and all the
[[devicesAccessibleMap]][deviceId] values for devices of that
kind, and initialize all values to
false. - Define any<kind>Live (e.g. anyDisplayVideoLive) to be the logical OR of all the [[devicesLiveMap]][deviceId] values for devices of that kind.
Then, given the new definitions above, the requirements on the user
agent are those specified in Privacy Indicator
Requirements of getUserMedia().
Note
Even though there's a single permission descriptor for
getDisplayMedia, the above definitions distinguish by
kind to enable user agents to implement privacy indicators that show the
end-user the specific kinds of display sources that are being shared at
any point.
Note
Since this specification forbids user agents from persisting
"granted" permissions, only the "Live" indicators are
significant.
The user agent MUST NOT fire the devicechange event
based on changes in the set of available sources from
getDisplayMedia.
This section is informative; however, it notes some serious risks to platform security if the advice it contains are not adhered to.
The risks to user privacy and security posed by capture of displayed content are twofold. The immediate and obvious risk is that users inadvertently share content that they did not wish to share, or might not have realized would be shared.
Display capture presents a less obvious risk to the cross site request forgery protections offered by the browser sandbox. Display and capture of information that is also under the control of an application, even indirectly, can allow that application to access information that would otherwise be inaccessible to it directly. For example, the canvas API does not permit sampling of a canvas, or conversion to an accessible form if it is not origin-clean [2DCONTEXT].
This issue is discussed in further detail in [RTCWEB-SECURITY-ARCH] and [RTCWEB-SECURITY].
Display capture that includes browser windows, particularly those that are under any form of control by the application, risks violation of these basic security protections. This risk is not entirely contained to browser windows, since control channels between browser applications and other applications, depending on the operating system. The key consideration is whether the captured display surface could be somehow induced to present information that would otherwise be secret from the application that is receiving the resulting media.
Capture of logical display surfaces causes there to be a potential for content to be shared that a user is not made aware of. A logical display surface might render information that a user did not intend to expose. This can be more easily recognized if this information is visible. Such means are likely ineffectual against a machine, but a human recipient is less able to process content that appears only briefly.
It is encouraged that information that is not currently rendered to the screen be obscured in captures unless the application has been specifically authorized to access that content through elevated permissions.
How obscured areas of the logical display surface are captured to produce a visible display surface capture MAY vary. Some applications, like presentation software, benefit from having obscured portions of the screen render the image that appeared prior to being obscured. Freezing images can cause visual artifacts for changing content, or hide the fact that content is being obscured. Note that frozen portions of a capture can be incorrectly perceived as a bug. Alternatively, obscured areas might be replaced with content that marks them as being obscured, such as a grey color or hatching.
Some systems may only capture the logical display surface. Devices with small screens, for instance, do not typically have the concept of a window, and render applications in full screen modes only. These systems might provide a capture of an application that is not currently visible, which could be unusable without capturing the logical display surface.
When capturing a window or other display surface that is partially transparent, any content behind it will not be captured.
There is a risk that the user prompt be exposed to the web page for a
short amount of time by the newly created MediaStreamTrack, for
instance if the user selects the screen on which the user prompt is
displayed. In the case of the user prompt displaying previews of the
various surfaces available for selection, those previews will not be
captured by the newly created MediaStreamTrack.
getDisplayMedia allows capturing audio alongside
video, this poses privacy and security concern as this may expose
additional information about system applications, and the set of shared
audio sources are not necessarily the same as the set of shared video
sources. For example, the capture of the video of a window that is accompanied by the audio of the entire system,
including applications unrelated to that window, will not be shared
without active user consent. It is important that the user is
aware of what content will be shared, including any possible audio. It is
strongly encouraged that the user is allowed to give consent to video but
not audio, resulting in a video-only stream. This ensures that the
request for audio is always optional and does not restrict the user's
choices compared to a video-only request.
This document encourages implementations to provide additional limitations on the mechanisms used to affirm user consent. These limitations are designed to mitigate the security and privacy risks that the API poses.
Two forms of consent interaction are described: active user consent and a range of elevated permissions. These are non-normative recommandations only.
Active user consent is sufficient where there is little or no risk of an application gaining information that the user did not intend to share. These cases can be identified by those where the application that requests capture has no control over what is rendered to the captured display surface.
To prevent applications from limiting the available choices
presented to a user with the goal of promoting a particular choice, the
getDisplayMedia API does not permit the use of
constraints to narrow the set of options presented.
It is strongly advised that elevated permissions be required to access any display surface that might be used to circumvent cross-origin protections for content. The key goal of this consent process is not just to demonstrate that a user intends to share content, but to also to determine that the user exhibits an elevated level of trust in the application that is being granted access.
Several different controls might be provided to grant elevated permissions. This section describes several different capabilities that could be independently granted. A user agent might opt to prohibit access to any capability that requires elevated permissions.
If access to these surfaces is supported, it is strongly advised that any mechanism to acquire elevated permissions not rely solely on simple prompts for user consent. Any action needs to ensure that a decision to authorize an application with elevated privileges is deliberate. For instance, a user agent might require a process equivalent to software installation to signify that user consent for elevated permissions is granted.
An elevated permissions experience could allow the user agent to communicate the risks associated with enabling this feature, or at least to convey the need for augmented trust in the application.
Note that elevated permissions are not a substitute for active user consent. It is advised that user agents still present users with the ability to select what is shared, even for applications that have elevated permissions.
Elevated permissions are encouraged as a prerequisite for access to capture of monitor or browser display surfaces. Note that capture of a complete monitor is included because this could include a window from the user agent.
Similarly, elevated permissions are an encouraged prerequisite for access to logical display surfaces, where that would not ordinarily be provided.
It is encouraged that elevated permissions that are granted to an origin be persisted. An elevated permissions process in part relies on its novelty to ensure that it correctly captures user intent.
Implementations are advised to provide user feedback and control mechanisms similar to those offered users when sharing a camera or microphone, as encouraged in [GETUSERMEDIA].
It is important that a user be aware that content is being shared when content is actively being captured. User agents are advised to display a prominent indicator while content is being captured. In addition to an indicator, a user agent is advised to provide a means to learn precisely what is being shared; while this capability is trivially provided by an application by rendering the captured content, this information allows a user to accurately assess what is being shared.
In addition to feedback mechanisms, a means to for the user to stop any active capture is advisable.
- [2DCONTEXT]
- HTML Canvas 2D Context. Rik Cabanier; Jatinder Mann; Jay Munro; Tom Wiltzius; Ian Hickson. W3C. 28 January 2021. W3C Recommendation. URL: https://www.w3.org/TR/2dcontext/
- [css-values]
- CSS Values and Units Module Level 4. Tab Atkins Jr.; Elika Etemad. W3C. 12 March 2024. W3C Working Draft. URL: https://www.w3.org/TR/css-values-4/
- [dom]
- DOM Standard. Anne van Kesteren. WHATWG. Living Standard. URL: https://dom.spec.whatwg.org/
- [ECMA-262]
- ECMAScript Language Specification. Ecma International. URL: https://tc39.es/ecma262/multipage/
- [GETUSERMEDIA]
- Media Capture and Streams. Cullen Jennings; Jan-Ivar Bruaroey; Henrik Boström; youenn fablet. W3C. 9 October 2025. CRD. URL: https://www.w3.org/TR/mediacapture-streams/
- [hr-time]
- High Resolution Time. Yoav Weiss. W3C. 24 March 2026. W3C Working Draft. URL: https://www.w3.org/TR/hr-time-3/
- [HTML]
- HTML Standard. Anne van Kesteren; Domenic Denicola; Dominic Farolino; Ian Hickson; Philip Jägenstedt; Simon Pieters. WHATWG. Living Standard. URL: https://html.spec.whatwg.org/multipage/
- [infra]
- Infra Standard. Anne van Kesteren; Domenic Denicola. WHATWG. Living Standard. URL: https://infra.spec.whatwg.org/
- [Permissions]
- Permissions. Marcos Caceres; Mike Taylor. W3C. 6 October 2025. W3C Working Draft. URL: https://www.w3.org/TR/permissions/
- [permissions-policy]
- Permissions Policy. Ian Clelland. W3C. 18 June 2026. W3C Working Draft. URL: https://www.w3.org/TR/permissions-policy-1/
- [RFC2119]
- Key words for use in RFCs to Indicate Requirement Levels. S. Bradner. IETF. March 1997. Best Current Practice. URL: https://www.rfc-editor.org/info/rfc2119/
- [RFC8174]
- Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words. B. Leiba. IETF. May 2017. Best Current Practice. URL: https://www.rfc-editor.org/info/rfc8174/
- [RTCWEB-SECURITY]
- Security Considerations for WebRTC. E. Rescorla. IETF. January 2021. Proposed Standard. URL: https://www.rfc-editor.org/info/rfc8826/
- [RTCWEB-SECURITY-ARCH]
- WebRTC Security Architecture. E. Rescorla. IETF. January 2021. Proposed Standard. URL: https://www.rfc-editor.org/info/rfc8827/
- [WEBIDL]
- Web IDL Standard. Edgar Chen; Timothy Gu. WHATWG. Living Standard. URL: https://webidl.spec.whatwg.org/
- [MEDIACAPTURE-DEPTH]
- Media Capture Depth Stream Extensions. Anssi Kostiainen; Ningxin Hu; Rijubrata Bhaumik; Rob Manson. W3C. 1 February 2022. W3C Working Draft. URL: https://www.w3.org/TR/mediacapture-depth/
- [WEBRTC]
- WebRTC: Real-Time Communication in Browsers. Cullen Jennings; Jan-Ivar Bruaroey; Henrik Boström; Florent Castelli. W3C. 13 March 2025. W3C Recommendation. URL: https://www.w3.org/TR/webrtc/