Skip to content

Commit ab47c8a

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

File tree

1 file changed

+207
-17
lines changed

1 file changed

+207
-17
lines changed

index.html

Lines changed: 207 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,106 @@ <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-sessions=] 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>Queue tasks to stop all tracks connected to sources in the
721+
[=capture-source-set=] associated with the [=capture-session=].
722+
</p>
723+
</li>
724+
725+
726+
<li>
727+
<p>Let <var>newSources</var> be the set of sources selected by the
728+
user when the user chose a new [=display surface=].</p>
729+
730+
731+
<p>
732+
<var>newSources</var> MUST fulfill the same requirements as the
733+
[=capture-source-set=] formed when {{MediaDevices/getDisplayMedia}}
734+
is called.</p>
735+
</li>
736+
737+
738+
<li>
739+
<p>
740+
Let <var>newSources</var> replace the [=capture-source-set=]
741+
associated with the [=capture-session=].
742+
</p>
743+
</li>
744+
745+
746+
<li>
747+
<p>Let <var>stream</var> be a new {{MediaStream}} with a new
748+
{{MediaStreamTrack}} for each source in <var>newSources</var>.
749+
</li>
750+
751+
752+
<li>
753+
<p>Run the [=ApplyConstraints algorithm=] on all tracks in
754+
<var>stream</var> with the appropriate constraints. Should
755+
this fail, abort these steps.</p>
756+
</li>
757+
758+
759+
<li>
760+
<p>Set
761+
<var>controller</var>.{{CaptureController/[[Source]]}} to
762+
the <var>stream</var>'s video track's
763+
<a data-cite="GETUSERMEDIA#dfn-source-0">[[\Source]]</a>.</p>
764+
</li>
765+
766+
767+
<li>
768+
<p>Set
769+
<var>controller</var>.{{CaptureController/[[DisplaySurfaceType]]}}
770+
to the <var>stream</var>'s video track's
771+
{{DisplayCaptureSurfaceType}}.</p>
772+
</li>
773+
774+
775+
<li>
776+
<p>Invoke
777+
<var>controller</var>.{{CaptureController/[[DisplaySurfaceChangeCallback]]}}
778+
with <var>stream</var> as the argument.</p>
779+
</li>
780+
</ol>
781+
</section>
782+
783+
671784
<section>
672785
<h2 id="constrainable-properties">Constrainable Properties for Captured
673786
Display Surfaces</h2>
@@ -1099,6 +1212,30 @@ <h2><dfn>CaptureStartFocusBehavior</dfn>
10991212
</div>
11001213
</section>
11011214

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

11031240
<section>
11041241
<h2><dfn>CaptureController</dfn>
@@ -1124,6 +1261,7 @@ <h2><dfn>CaptureController</dfn>
11241261
interface CaptureController : EventTarget {
11251262
constructor();
11261263
undefined setFocusBehavior(CaptureStartFocusBehavior focusBehavior);
1264+
undefined setDisplaySurfaceChangeCallback(DisplaySurfaceChangeCallback callback);
11271265
};
11281266
</pre>
11291267

@@ -1226,6 +1364,19 @@ <h2><dfn>CaptureController</dfn>
12261364

12271365
<td>The focus behavior desired by the application.</td>
12281366
</tr>
1367+
1368+
1369+
<tr>
1370+
<td><dfn>[[\DisplaySurfaceChangeCallback]]</dfn>
1371+
</td>
1372+
1373+
<td><code>null</code>
1374+
</td>
1375+
1376+
<td>A callback called when the [=display surface=] of the
1377+
associated [=capture-session=] changes.</td>
1378+
</tr>
1379+
12291380
</tbody>
12301381
</table>
12311382

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

12991489

0 commit comments

Comments
 (0)