Skip to content

Commit

Permalink
Merge pull request #643 from jan-ivar/fixpermission
Browse files Browse the repository at this point in the history
Move request permission steps into the for-loop.
  • Loading branch information
henbos committed Nov 21, 2019
2 parents f492260 + df39aaa commit 9ba0dbc
Showing 1 changed file with 85 additions and 71 deletions.
156 changes: 85 additions & 71 deletions getusermedia.html
Expand Up @@ -3516,11 +3516,11 @@ <h2>Methods</h2>
set.</p>
</li>
<li>
<p>For each media type <var>T</var> in
<var>requestedMediaTypes</var>,</p>
<p>For each media type <var>kind</var> in
<var>requestedMediaTypes</var>, run the following steps:</p>
<ol>
<li>
<p>For each possible source for that media type,
<p>For each possible source for media of type <var>kind</var>,
construct an unconstrained MediaStreamTrack with that
source as its source.</p>
<p>Call this set of tracks the
Expand All @@ -3531,21 +3531,21 @@ <h2>Methods</h2>
<code>name</code> attribute has the value
<code>NotFoundError</code> and abort these steps.</p>
</li>
<li>If the value of the <var>T</var> entry of
<li>If the value of the <var>kind</var> entry of
<var>constraints</var> is "true", set <var>CS</var> to
the empty constraint set (no constraint). Otherwise,
continue with <var>CS</var> set to the value of the
<var>T</var> entry of <var>constraints</var>.</li>
<var>kind</var> entry of <var>constraints</var>.</li>
<li>Remove any constrainable property inside of
<var>CS</var> that are not defined for
<code><a>MediaStreamTrack</a></code> objects of type
<var>T</var>. This means that audio-only constraints
<var>kind</var>. This means that audio-only constraints
inside of "video" and video-only constraints inside of
"audio" are simply ignored rather than causing
<code>OverconstrainedError</code>.</li>
<li>
<p>Run the <a>SelectSettings</a> algorithm on each
track in <var>CandidateSet</var> with <var>CS</var>
track in <var>candidateSet</var> with <var>CS</var>
as the constraint set. If the algorithm returns
<code>undefined</code>, remove the track from
<var>candidateSet</var>. This eliminates devices
Expand Down Expand Up @@ -3577,79 +3577,93 @@ <h2>Methods</h2>
"denied", jump to the step labeled
<em>PermissionFailure</em> below.</p>
</li>
<li>
<p>Optionally, e.g., based on a previously-established
user preference, for security reasons, or due to platform
limitations, jump to the step labeled <em>Permission
Failure</em> below.</p>
</li>
<li>
<p>Add all tracks from <var>candidateSet</var> to
<var>finalSet</var>.</p>
</li>
</ol>
</li>
<li>
<p>Optionally, e.g., based on a previously-established
user preference, for security reasons, or due to platform
limitations, jump to the step labeled <em>Permission
Failure</em> below.</p>
</li>
<li>
<p><a>Request permission to
use</a> a PermissionDescriptor with its name member set
to the permission name associated with <var>kind</var>
(e.g. "camera", "microphone"), and, optionally, its
deviceId member set to the device's <var>deviceId</var>,
while considering all devices attached to a
<code>live</code> and <a>same-permission</a>
MediaStreamTrack in the current <a data-cite=
"!HTML/#browsing-context">browsing
context</a> to have permission status "granted",
resulting in a set of provided media.
<dfn>Same-permission</dfn> in this context means a
MediaStreamTrack that required the same level of
permission to obtain as what is being requested (e.g. not
isolated).</p>
<p>The provided media MUST include precisely one track of
each media type in requestedMediaTypes from the
<var>finalSet</var>. The decision of which devices to
choose from the <var>finalSet</var> is completely up to
the User Agent and may be determined by asking the user.
Once selected, the source of a
<code><a>MediaStreamTrack</a></code> MUST NOT change.</p>
<p>The User Agent MAY use the value of the computed
"fitness distance" from the <a>SelectSettings</a>
algorithm, or any other internally-available information
about the devices, as an input to the selection
algorithm.</p>
<p>User Agents are encouraged to default to using the
user's primary or system default camera and/or microphone
(when possible) to generate the media stream. User Agents
MAY allow users to use any media source, including
pre-recorded media files.</p>
<p>If the result of the request is "granted", then for
each device that is sourcing the provided media, using
the device's deviceId, <var>deviceId</var>, set
[[\devicesLiveMap]]<var>[deviceId]</var> to
<code>true</code>, if it isn’t already <code>true</code>,
and set the
[[\devicesAccessibleMap]]<var>[deviceId]</var> to
<code>true</code>, if it isn’t already
<code>true</code>.</p>
<p>If the result is "denied", jump to the step labeled
<em>Permission Failure</em> below. If the user never
responds, this algorithm stalls on this step.</p>
<p>If the user grants permission but a hardware error
such as an OS/program/webpage lock prevents access,
<a>reject</a> <var>p</var> with a new
<code><a>DOMException</a></code> object whose
<code>name</code> attribute has the value
<code>NotReadableError</code> and abort these steps.</p>
<p>If the result is "granted" but device access fails for
any reason other than those listed above, <a>reject</a>
<var>p</var> with a new <code><a>DOMException</a></code>
object whose <code>name</code> attribute has the
value <code>AbortError</code> and abort these steps.</p>
<p>Let <var>stream</var> be a new and empty
<code><a>MediaStream</a></code> object.</p>
</li>
<li>
<p>Let <var>stream</var> be the
<code><a>MediaStream</a></code> object for which the user
granted permission.</p>
<p>For each media type <var>kind</var> in
<var>requestedMediaTypes</var>, run the following steps,
preferably at the same time:</p>
<div class="note">
<p>User agents are encouraged to bundle concurrent
requests for different kinds of media into a single
user-facing permission prompt.</p>
</div>
<ol>
<li>
<p><a>Request permission to
use</a> a PermissionDescriptor with its name member set
to the permission name associated with <var>kind</var>
(e.g. "camera" for "video", "microphone" for "audio"),
and, optionally, consider its deviceId member set to
any appropriate device's <var>deviceId</var>,
while considering all devices attached to a
<code>live</code> and <a>same-permission</a>
MediaStreamTrack in the current <a data-cite=
"!HTML/#browsing-context">browsing
context</a> to have permission status "granted",
resulting in a set of provided media.
<dfn>Same-permission</dfn> in this context means a
MediaStreamTrack that required the same level of
permission to obtain as what is being requested (e.g. not
isolated).</p>
<p>Let <var>track</var> be the provided media, which
MUST be precisely one track of type <var>kind</var> from
<var>finalSet</var>. The decision of which track to
choose from the <var>finalSet</var> is completely up to
the User Agent and may be determined by asking the user.
Once selected, the source of the
<code><a>MediaStreamTrack</a></code> MUST NOT change.</p>
<p>The User Agent MAY use the value of the computed
"fitness distance" from the <a>SelectSettings</a>
algorithm, or any other internally-available information
about the devices, as an input to the selection
algorithm.</p>
<p>User Agents are encouraged to default to using the
user's primary or system default device for <var>kind</var>
(when possible). User Agents
MAY allow users to use any media source, including
pre-recorded media files.</p>
<p>If the result of the request is "granted", then using
the granted device's deviceId, <var>deviceId</var>, set
[[\devicesLiveMap]]<var>[deviceId]</var> to
<code>true</code>, if it isn’t already <code>true</code>,
and set the
[[\devicesAccessibleMap]]<var>[deviceId]</var> to
<code>true</code>, if it isn’t already
<code>true</code>.</p>
<p>If the result is "denied", jump to the step labeled
<em>Permission Failure</em> below. If the user never
responds, this algorithm stalls on this step.</p>
<p>If the user grants permission but a hardware error
such as an OS/program/webpage lock prevents access,
<a>reject</a> <var>p</var> with a new
<code><a>DOMException</a></code> object whose
<code>name</code> attribute has the value
<code>NotReadableError</code> and abort these steps.</p>
<p>If the result is "granted" but device access fails for
any reason other than those listed above, <a>reject</a>
<var>p</var> with a new <code><a>DOMException</a></code>
object whose <code>name</code> attribute has the
value <code>AbortError</code> and abort these steps.</p>
</li>
<li>
<p>Add <var>track</var> to <var>stream</var>'s track set.</p>
</li>
</ol>
</li>
<li>
<p>Run the <a>ApplyConstraints algorithm</a> on all
Expand Down

0 comments on commit 9ba0dbc

Please sign in to comment.