-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathindex.html
352 lines (351 loc) · 15.6 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
<!DOCTYPE html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<title>The Capture-Handle Actions Mechanism</title>
<script class="remove" src="capture-handle-actions.js" type="text/javascript"></script>
<script src="https://www.w3.org/Tools/respec/respec-w3c" class="remove"></script>
</head>
<body>
<section id="abstract">
<h2>Abstract</h2>
<p>
This document proposes a mechanism by which an application <var>APP</var> can opt-in to
exposing certain information with another application <var>CAPTR</var>, if
<var>CAPTR</var> is screen-capturing the tab in which <var>APP</var> is running.
It describes a mechanism for <a data-cite="SCREEN-CAPTURE#dfn-browser">tab capture</a> only.
</p>
</section>
<section id="sotd">
<p>
This document is not complete.
</p>
</section>
<section id="conformance"></section>
<section>
<h2>Problem Description</h2>
<section id="problem-desc">
<h3>Problem Description</h3>
<p>
Consider a web-application, running in one tab, which we’ll name "<var>main_app</var>."
Assume <var>main_app</var> calls
<a data-cite="SCREEN-CAPTURE#dom-mediadevices-getdisplaymedia">getDisplayMedia</a>
and the user chooses to share another tab, where an application is running which we’ll
call "<var>captured_app</var>."
</p>
<p>Note that:</p>
<ol>
<li><var>main_app</var> does not know what it is capturing.</li>
<li>
<var>captured_app</var> does not know that it is being captured; let alone by whom.
</li>
</ol>
<p>
Both of these traits are desirable in the general case, but there exists specific
use cases where the user of <var>main_app</var> would benefit if <var>main_app</var>
had available to it a limited set of standard instructions that <var>captured_app</var>
has opted into receiving.
</p>
<p>
We wish to enable the specific use cases while keeping the general case as it was
before.
</p>
</section>
<section id="use-case-1">
<h3>Use-case #1: Driving Presentations from Video Conferencing Apps</h3>
<p>
Consider a collaborating presentation software and video-conferencing software. Assume the
user is in a VC session. The user starts sharing a presentation. Both applications are
interested in letting the VC app discover that it is capturing a slides session,
so that the VC application will be able to expose
controls to the user for flipping through slides. When the user clicks those controls, the
VC app will be able to send messages to the presentation app, requesting that it do such
things as flip through slides, etc.
</p>
</section>
</section>
<section>
<h2>The Capture-Handle Actions Mechanism</h2>
<p>
The capture-handle actions mechanism consists of two parts - one on the captured side, one on
the capturing side.
</p>
<ul>
<li>
<a href="#captured-side-actions">Captured applications</a> opt-in by registering support for
standard actions they handle by calling {{MediaDevices/setSupportedCaptureActions}}.
</li>
<li>
<a href="#capturing-side-actions">Capturing applications</a> may trigger these actions using
{{MediaStreamTrack/sendCaptureAction}}.
</li>
</ul>
<div class="note">
There is disagreement on whether actions should be specified here or in a separate document.
</div>
<section id="captured-side-actions">
<h3>Captured Side for Actions</h3>
<p>
Applications in top-level documents can declare the [=capture actions=]
they support, if any. They would typically do so before even knowing if
they are being captured. The intended use is for an application to expect to receive
these actions from capturer applications wishing to control the progression of
the captured session, in response to interaction with the user.
Supported actions are declared by calling {{MediaDevices/setSupportedCaptureActions}}
with an array of the names of actions the application is prepared to respond to.
</p>
<section id="set-supported-capture-actions">
<h4>Registering and responding to capture actions</h4>
<p>
{{MediaDevices}} is extended with a method - {{MediaDevices/setSupportedCaptureActions}} -
which accepts an array of {{DOMString}}s. By calling this method, an application
registers with the user agent a set of zero or more [=capture actions=] it wishes to
respond to.
</p>
<p>
<dfn>Capture actions</dfn> are values defined in {{CaptureAction}}.
They are meant to be interpreted as instructions from the capturing application to
control the advancement of the presentation of the captured session, however the
captured application wishes to define this. The intent is to support capturer
applications implementing interactive controls for these actions, whose sending
requires [=transient activation=] and [=consume user activation=].
</p>
<pre class="idl">
partial interface MediaDevices {
undefined setSupportedCaptureActions(sequence<DOMString> actions);
attribute EventHandler oncaptureaction;
};
enum CaptureAction {
"next",
"previous",
"first",
"last"
};
</pre>
<dl data-link-for="MediaDevices" data-dfn-for="MediaDevices" class="methods">
<dt>
<dfn>setSupportedCaptureActions</dfn>
</dt>
<dd>
<p>When this method is invoked, the user agent MUST run the following steps:</p>
<ol>
<li>
If the [=relevant global object=]'s [=associated `Document`=] is
either not [=Document/fully active=] or its [=browsing context=] is not a
[=top-level browsing context=], then throw {{InvalidAccessError}}.
</li>
<li>
Let |actions| be the method's first argument.
</li>
<li>
If |actions| is non-empty, and this method was previously
called with a non-empty array on [=this=] {{MediaDevices}} object,
then throw {{InvalidStateError}}.
</p>
<li>
Remove from |actions| any value not found in {{CaptureAction}}.
</li>
<li>
Remove from |actions| any duplicates.
</li>
<li>
Set [=this=]'s {{MediaDevices/[[RegisteredCaptureActions]]}} to |actions|.
</li>
<li>
return `undefined` and run the remaining step [=in parallel=].
</li>
<li>
If this document is currently being captured as part of a
<a data-cite="SCREEN-CAPTURE#dfn-browser">browser</a>
<a data-cite="SCREEN-CAPTURE#dfn-display-surface">display surface</a>,
then for each capturer of that surface, queue a task on that capturer's
task-list to set all associated video {{MediaStreamTrack}}s'
{{MediaDevices/[[AvailableCaptureActions]]}} to |actions|.
</li>
</ul>
</dd>
</dl>
<dl data-link-for="MediaDevices" data-dfn-for="MediaDevices" class="attributes">
<dt><dfn>oncaptureaction</dfn> of type {{EventHandler}}</dt>
<dd>
<p>The event type of this event handler is `"captureaction"`.</p>
</dd>
</dl>
<p>
When {{MediaDevices}} is created, give it a
<dfn data-dfn-for="MediaDevices">[[\RegisteredCaptureActions]]</dfn> internal slot,
initialized to an empty list.
</p>
</section>
<section id="action-event">
<h3>Capture Action Event</h3>
<section id="capture-handle-action-event">
<h4><dfn>CaptureActionEvent</dfn></h4>
<p>
This event is fired on the captured application's {{MediaDevices}}
object whenever an action it registered with
{{MediaDevices/setSupportedCaptureActions}} has been triggered. This
lets the application respond by executing its implementation of this
action.
</p>
<pre class="idl">
[Exposed=Window]
interface CaptureActionEvent : Event {
constructor(optional CaptureActionEventInit init = {});
readonly attribute CaptureAction action;
};
</pre>
<dl data-link-for="CaptureActionEvent" data-dfn-for="CaptureActionEvent">
<dt>
<dfn>action</dfn>
</dt>
<dd>
The {{CaptureAction}} that was triggered.
</dd>
</dl>
</section>
<section>
<h4><dfn>CaptureActionEventInit</dfn></h4>
<pre class="idl">
dictionary CaptureActionEventInit : EventInit {
DOMString action;
};
</pre>
<dl
data-link-for="CaptureActionEventInit"
data-dfn-for="CaptureActionEventInit"
>
<dt>
<dfn>action</dfn>
</dt>
<dd>
The {{CaptureAction}} to initialize the event with.
</dd>
</dl>
</section>
</section>
</section>
<section id="capturing-side-actions">
<h3>Capturing Side for Actions</h3>
<p>
Capturing applications can enumerate available [=capture actions=] that
are supported on the video track they have obtained, by using
{{MediaStreamTrack/getSupportedCaptureActions}}, and can trigger those
actions by using {{MediaStreamTrack/sendCaptureAction}}.
</p>
<section id="capture-handle-get-supported-actions">
<h4>Enumerating supported actions and triggering them</h4>
<p>
When a {{MediaStreamTrack}} is a video track derived from screen-capture
of a <a data-cite="SCREEN-CAPTURE#dfn-browser">browser</a>
<a data-cite="SCREEN-CAPTURE#dfn-display-surface">display surface</a>,
{{MediaStreamTrack/getSupportedCaptureActions}} returns the set of
available [=capture actions=], if any, supported by the captured
application associated with this video track.
</p>
<pre class="idl">
partial interface MediaStreamTrack {
sequence<DOMString> getSupportedCaptureActions();
Promise<undefined> sendCaptureAction(CaptureAction action);
};
</pre>
<dl data-link-for="MediaStreamTrack" data-dfn-for="MediaStreamTrack">
<dt>
<dfn>getSupportedCaptureActions</dfn>
</dt>
<dd>
<p>When this method is invoked, the user agent MUST return [=this=]'
{{MediaDevices/[[AvailableCaptureActions]]}} if defined, or `[]` if not defined.</p>
</dd>
<dt>
<dfn>sendCaptureAction</dfn>
</dt>
<dd>
<p>When this method is invoked, the user agent MUST run the following steps:</p>
<ol>
<li>
If the [=relevant global object=] of [=this=] does not have
[=transient activation=], return a promise [=rejected=] with
{{InvalidStateError}}.
</li>
<li>
[=Consume user activation=].
</li>
<li>
Let |action| be the method's first argument.
</li>
<li>
If |action| is not in [=this=]' {{MediaDevices/[[AvailableCaptureActions]]}},
return a promise [=rejected=] with {{NotFoundError}}.
</li>
<li>
Let |p| be a new promise.
</li>
<li>
Run the following steps [=in parallel=]:
<ol>
<li>
<p>
Queue a task on the task-list of the captured
<a data-cite="SCREEN-CAPTURE#dfn-browser">browser</a>
<a data-cite="SCREEN-CAPTURE#dfn-display-surface">display surface</a>'s
[=top-level browsing context=]'s [=active document=] to run the
following steps:
</p>
<ol>
<li>
Let |target| be the the [=relevant global object=]'s
[=associated `Document`=]'s
associated navigator's {{MediaDevices}} object.
<li>
If |action| is not in |target|'s
{{MediaDevices/[[RegisteredCaptureActions]]}}, abort these steps.
<li>
[=Fire an event=] named `"captureaction"`, using a
{{CaptureActionEvent}} with {{CaptureActionEventInit/action}}
set to |action|, at |target|.
</li>
</ol>
<li>
Wait for the event to have been fired.
</li>
<li>
Resolve |p|.
</li>
</li>
</ol>
</li>
<li>
Return |p|.
</li>
</ol>
</dd>
</dl>
<p>
When a video {{MediaStreamTrack}} is created as part of the
<a data-cite="SCREEN-CAPTURE#dom-mediadevices-getdisplaymedia">getDisplayMedia</a>
algorithm, whose source is a
<a data-cite="SCREEN-CAPTURE#dfn-browser">browser</a>
<a data-cite="SCREEN-CAPTURE#dfn-display-surface">display surface</a>,
give it an
<dfn data-dfn-for="MediaDevices">[[\AvailableCaptureActions]]</dfn> internal
slot, initialized to the captured
<a data-cite="SCREEN-CAPTURE#dfn-browser">browser</a>
<a data-cite="SCREEN-CAPTURE#dfn-display-surface">display surface</a>'s
[=top-level browsing context=]'s [=Browsing context/active window=]'s
associated navigator's {{MediaDevices}} object's
{{MediaDevices/[[RegisteredCaptureActions]]}}.
</p>
<p>
While capture of a
<a data-cite="SCREEN-CAPTURE#dfn-browser">browser</a>
<a data-cite="SCREEN-CAPTURE#dfn-display-surface">display surface</a>
is occurring, whenever that surface's
[=top-level browsing context=] is navigated, then for each capturer of
that surface, queue a task on that capturer's task-list to set all
associated video {{MediaStreamTrack}}s'
{{MediaDevices/[[AvailableCaptureActions]]}} to `[]`.
</p>
</section>
<body>
</html>