Skip to content

Commit 7c6434f

Browse files
committed
Added DisplaySurfaceChangeCallback (fix #255)
1 parent d864164 commit 7c6434f

File tree

1 file changed

+211
-17
lines changed

1 file changed

+211
-17
lines changed

index.html

Lines changed: 211 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -409,25 +409,37 @@ <h2><dfn>MediaDevices</dfn> Additions</h2>
409409

410410
<li>
411411
<p>[=Prompt the user to choose=] a display device, for a
412-
{{PermissionDescriptor}} with its
413-
{{PermissionDescriptor/name}} set to "display-capture",
414-
resulting in a set of provided media.</p>
412+
{{PermissionDescriptor}} with its
413+
{{PermissionDescriptor/name}} set to "display-capture",
414+
resulting in a <dfn>capture-source-set</dfn>,
415+
<var>sources</var>, that meets the following
416+
requirements:</p>
415417

416418

417-
<p>The provided media MUST include precisely one video
418-
track.</p>
419+
<ol>
420+
<li>
421+
<p>The [=capture-source-set=] MUST include precisely one
422+
video track.</p>
423+
</li>
419424

420425

421-
<p>The provided media MUST include at most one audio track.
422-
This audio track MUST NOT be included if audio was not
423-
specified in <var>requestedMediaTypes</var>, or if it was
424-
specified as <code>false</code>.</p>
426+
<li>
427+
<p>The [=capture-source-set=] MUST include at most one
428+
audio track. This audio track MUST NOT be included if
429+
audio was not specified in
430+
<var>requestedMediaTypes</var>, or if it was specified
431+
as <code>false</code>.</p>
432+
</li>
425433

426434

427-
<p>The devices chosen MUST be the ones determined by the
428-
user. Once selected, the source of a {{MediaStreamTrack}}
429-
MUST NOT change, unless the user permits it through their
430-
interaction with the user agent.</p>
435+
<li>
436+
<p>The sources in the [=capture-source-set=] MUST
437+
represent the devices determined by the user. Once
438+
selected, the source of a {{MediaStreamTrack}} MUST NOT
439+
change, unless the user permits it through their
440+
interaction with the user agent.</p>
441+
</li>
442+
</ol>
431443

432444

433445
<p>User agents are encouraged to warn users against sharing
@@ -439,9 +451,9 @@ <h2><dfn>MediaDevices</dfn> Additions</h2>
439451

440452

441453
<p>If the result of the request is
442-
{{PermissionState/"granted"}}, then for each device that is
443-
sourcing the provided media, using a stable and private id
444-
for the device, <var>deviceId</var>, set
454+
{{PermissionState/"granted"}}, then for each device with a
455+
source in [=capture-source-set=], using a stable and private
456+
id for the device, <var>deviceId</var>, set
445457
[[\devicesLiveMap]]<var>[deviceId]</var> to
446458
<code>true</code>, if it isn’t already <code>true</code>, and
447459
set the [[\devicesAccessibleMap]]<var>[deviceId]</var> to
@@ -512,7 +524,8 @@ <h2><dfn>MediaDevices</dfn> Additions</h2>
512524
<li>
513525
<p>This invocation of {{MediaDevices/getDisplayMedia()}} is
514526
now considered to have produced a new
515-
<dfn>capture-session</dfn>.</p>
527+
<dfn>capture-session</dfn>, with the associated
528+
[=capture-source-set=], <var>sources</var>.</p>
516529
</li>
517530

518531

@@ -668,6 +681,110 @@ <h2 id="constraints">Unconstrained Display Surface Selection</h2>
668681
</section>
669682

670683

684+
<section>
685+
<h2 id="changing-display-surfaces">Changing Display Surfaces</h2>
686+
687+
688+
<p>
689+
The user agent MUST NOT change the [=display surface=]
690+
associated with a [=capture-session=] unless the user has
691+
explicitly indicated that they want this change to be
692+
performed by interacting with user agent or operating system.
693+
694+
If the user indicates a change of [=display surface=], the
695+
user agent MUST run the following steps:
696+
</p>
697+
698+
699+
<ol>
700+
<li>
701+
<p>If the [=capture-session=] does not have an associated
702+
{{CaptureController}}, <var>controller</var>, abort these steps.</p>
703+
</li>
704+
705+
706+
<li>
707+
<p>If <var>controller.{{CaptureController/[[DisplaySurfaceChangeCallback]]}}</var>
708+
is null, abort these steps.</p>
709+
</li>
710+
711+
712+
<li>
713+
<p>Stop delivering frames from all sources in the
714+
[=capture-source-set=] associated with the [=capture-session=].
715+
</p>
716+
</li>
717+
718+
719+
<li>
720+
<p>Let <var>newSources</var> be the set of sources selected by the
721+
user when the user chose a new [=display surface=].</p>
722+
723+
724+
<p>
725+
<var>newSources</var> MUST fulfill the same requirements as the
726+
[=capture-source-set=] formed when {{MediaDevices/getDisplayMedia}}
727+
is called.</p>
728+
</li>
729+
730+
731+
<li>
732+
<p>Queue a task to:</p>
733+
<ol>
734+
<li>
735+
<p>
736+
Set the [=capture-source-set=]
737+
associated with the [=capture-session=] to <var>newSources</var>.
738+
</p>
739+
</li>
740+
741+
742+
<li>
743+
<p>Let <var>stream</var> be a new {{MediaStream}} with a new
744+
{{MediaStreamTrack}} for each source in <var>newSources</var>.
745+
</li>
746+
747+
748+
<li>
749+
<p>Run the [=ApplyConstraints algorithm=] on all tracks in
750+
<var>stream</var> with the appropriate constraints. Should
751+
this fail, abort these steps.</p>
752+
</li>
753+
754+
755+
<li>
756+
<p>Set
757+
<var>controller</var>.{{CaptureController/[[Source]]}} to
758+
the <var>stream</var>'s video track's
759+
<a data-cite="GETUSERMEDIA#dfn-source-0">[[\Source]]</a>.</p>
760+
</li>
761+
762+
763+
<li>
764+
<p>Set
765+
<var>controller</var>.{{CaptureController/[[DisplaySurfaceType]]}}
766+
to the <var>stream</var>'s video track's
767+
{{DisplayCaptureSurfaceType}}.</p>
768+
</li>
769+
770+
771+
<li>
772+
<p>Invoke
773+
<var>controller</var>.{{CaptureController/[[DisplaySurfaceChangeCallback]]}}
774+
with <var>stream</var> as the argument.</p>
775+
</li>
776+
</ol>
777+
</li>
778+
779+
<li>
780+
<p>Queue tasks to end all tracks connected to sources in the
781+
[=capture-source-set=] associated with the [=capture-session=].
782+
</p>
783+
</li>
784+
</ol>
785+
</section>
786+
787+
671788
<section>
672789
<h2 id="constrainable-properties">Constrainable Properties for Captured
673790
Display Surfaces</h2>
@@ -1099,6 +1216,30 @@ <h2><dfn>CaptureStartFocusBehavior</dfn>
10991216
</div>
11001217
</section>
11011218

1219+
<section>
1220+
<h2><dfn>DisplaySurfaceChangeCallback</dfn></h2>
1221+
<p>
1222+
Used to receive a new {{MediaStream}} if the [=display surface=]
1223+
associated with a [=capture-session=] changes.
1224+
</p>
1225+
<div>
1226+
<pre class="idl" >callback DisplaySurfaceChangeCallback = undefined
1227+
(MediaStream stream);</pre>
1228+
<section>
1229+
<h2>Callback <a class="idlType">DisplaySurfaceChangeCallback</a>
1230+
Parameters</h2>
1231+
<dl data-link-for="NavigatorUserMediaSuccessCallback" data-dfn-for=
1232+
"NavigatorUserMediaSuccessCallback" class="callback-members">
1233+
<dt>stream of type {{MediaStream}}</dt>
1234+
<dd>
1235+
A new {{MediaStream}} with a new {{MediaStreamTrack}} for each
1236+
source in the [=capture-source-set=] associated with the
1237+
[=display surface=] that the user has selected.
1238+
</dd>
1239+
</dl>
1240+
</section>
1241+
</div>
1242+
</section>
11021243

11031244
<section>
11041245
<h2><dfn>CaptureController</dfn>
@@ -1124,6 +1265,7 @@ <h2><dfn>CaptureController</dfn>
11241265
interface CaptureController : EventTarget {
11251266
constructor();
11261267
undefined setFocusBehavior(CaptureStartFocusBehavior focusBehavior);
1268+
undefined setDisplaySurfaceChangeCallback(DisplaySurfaceChangeCallback callback);
11271269
};
11281270
</pre>
11291271

@@ -1226,6 +1368,19 @@ <h2><dfn>CaptureController</dfn>
12261368

12271369
<td>The focus behavior desired by the application.</td>
12281370
</tr>
1371+
1372+
1373+
<tr>
1374+
<td><dfn>[[\DisplaySurfaceChangeCallback]]</dfn>
1375+
</td>
1376+
1377+
<td><code>null</code>
1378+
</td>
1379+
1380+
<td>A callback called when the [=display surface=] of the
1381+
associated [=capture-session=] changes.</td>
1382+
</tr>
1383+
12291384
</tbody>
12301385
</table>
12311386

@@ -1294,6 +1449,45 @@ <h2><dfn>CaptureController</dfn>
12941449
</li>
12951450
</ol>
12961451
</dd>
1452+
1453+
1454+
<dt><dfn>setDisplaySurfaceChangeCallback</dfn>
1455+
</dt>
1456+
1457+
1458+
<dd>
1459+
<p>Run the following steps:</p>
1460+
1461+
1462+
<ol>
1463+
<li>
1464+
<p>Let <var>callback</var> be the method's first argument.</p>
1465+
</li>
1466+
1467+
1468+
<li>
1469+
<p>If [=this=].{{CaptureController/[[IsBound]]}} is
1470+
<code>true</code>,
1471+
[=exception/throw=] an "{{InvalidStateError}}"
1472+
{{DOMException}}.</p>
1473+
</li>
1474+
1475+
1476+
<li>
1477+
<p>If
1478+
[=this=].{{CaptureController/[[DisplaySurfaceChangeCallback]]}}
1479+
is not <code>null</code>, [=exception/throw=] an
1480+
"{{InvalidStateError}}" {{DOMException}}.</p>
1481+
</li>
1482+
1483+
1484+
<li>
1485+
<p>Set
1486+
[=this=].{{CaptureController/[[DisplaySurfaceChangeCallback]]}}
1487+
to <var>callback</var>.</p>
1488+
</li>
1489+
</ol>
1490+
</dd>
12971491
</dl>
12981492

12991493

0 commit comments

Comments
 (0)