Skip to content

Commit

Permalink
Make setMicrophoneActive and setCameraActive return promises.
Browse files Browse the repository at this point in the history
Define steps for each of these methods.
Mention the possibility to mute/unmute tracks based on setMicrophoneActive/setCameraActive calls.
Mention the possibility for the user agent to deny the mutation of capture states via setMicrophoneActive/setCameraActive calls.
  • Loading branch information
youennf committed Jan 10, 2024
1 parent 5d4054a commit 4af6e95
Showing 1 changed file with 78 additions and 11 deletions.
89 changes: 78 additions & 11 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ urlPrefix: https://www.w3.org/TR/permissions-policy-1/; spec: PermissionsPolicy
urlPrefix: https://html.spec.whatwg.org/multipage/dom.html; spec: dom
type: dfn
text: permissions policy; url:#concept-document-permissions-policy
urlPrefix: https://www.w3.org/TR/mediacapture-streams/; spec: mediacapture-main
type: dfn
text: MediaStreamTrack; url:#mediastreamtrack
text: MediaStreamTrack muted state; url:#track-muted
text: set MediaStreamTrack muted state; url:#set-track-muted
</pre>

<h2 id="introduction">Introduction</h2>
Expand Down Expand Up @@ -776,9 +781,9 @@ interface MediaSession {

undefined setPositionState(optional MediaPositionState state = {});

undefined setMicrophoneActive(boolean active);
Promise&lt;undefined&gt; setMicrophoneActive(boolean active);

undefined setCameraActive(boolean active);
Promise&lt;undefined&gt; setCameraActive(boolean active);
};
</pre>

Expand Down Expand Up @@ -912,16 +917,78 @@ interface MediaSession {
</li>
</ul>
</p>

<p>
The <dfn method for=MediaSession>setMicrophoneActive(active)</dfn> and
<dfn method for=MediaSession>setCameraActive(active)</dfn> methods indicate to
the user agent whether the microphone and camera are currently considered by
the page to be active (e.g. if the microphone is considered "muted" by the
page since it is no longer sending audio through to a call, then the page can
invoke <code>setMicrophoneActive(false)</code>).
It is RECOMMENDED that the user agent respect the microphone and camera
states indicated by the page in this UI.
The <dfn method for=MediaSession>setMicrophoneActive(active)</dfn> method
indicates to the user agent whether the microphone is considered by the page
to be active (e.g. if the microphone is considered "muted" by the page since
it is no longer sending audio through a call, then the page can invoke
<code>setMicrophoneActive(false)</code>). When invoked, it MUST perform the
following steps:
<ul>
<li>
Let <var>p</var> be a new promise.
</li>
<li>
<a>Queue a task</a> to run the following substeps:
<ul>
<li>The user agent MAY wait to proceed, for instance if
<var>active</var> is <code>true</code> and the relevant global object's
associated <code>Document</code> visiblity state is not "visible".</li>
<li>If the user agent denies permission to change the microphone state
to <var>active</var>, reject <var>p</var> with a <a
exception>NotAllowedError</a>.</li>
<li>If the user agent exposes the microphone state via
<a>MediaStreamTrack muted state</a>, the user agent MUST <a>queue a
task</a> to <a>set MediaStreamTrack muted state</a> on any affected
<a>MediaStreamTrack</a>.</li>
<li>Update the user agent microphone state UI according
<var>active</var>.</li>
<li>Resolve <var>p</var> with <code>undefined</code>.</li>
</ul>
</li>
<li>
Return <var>p</var> be a new promise.
</li>
</ul>
</p>
<p>
Similarly, the <dfn method for=MediaSession>setCameraActive(active)</dfn>
method indicates to the user agent whether the camera is considered by the
page to be active. When invoked, it MUST perform the following steps:
<ul>
<li>
Let <var>p</var> be a new promise.
</li>
<li>
<a>Queue a task</a> to run the following substeps:
<ul>
<li>The user agent MAY wait to proceed, for instance if
<var>active</var> is <code>true</code> and the relevant global object's
associated <code>Document</code> visiblity state is not "visible".</li>
<li>If the user agent denies permission to change the camera state to
<var>active</var>, reject <var>p</var> with a <a
exception>NotAllowedError</a>.</li>
<li>If the user agent exposes the camera state via <a>MediaStreamTrack
muted state</a>, the user agent MUST <a>queue a task</a> to <a>set
MediaStreamTrack muted state</a> on any affected
<a>MediaStreamTrack</a>.</li>
<li>Update the user agent camera state UI according
<var>active</var>.</li>
<li>Resolve <var>p</var> with <code>undefined</code>.</li>
</ul>
</li>
<li>
Return <var>p</var> be a new promise.
</li>
</ul>
</p>
<p class=note>
Both the <a>setMicrophoneActive(active)</a> and <a>setCameraActive(active)</a>
methods may reject based on user agent specific heuristics. This might in
particular happen when the web page asks to activate (aka unmute) microphone
or camera. The user agent may decide to require transient activation in that
case. It may also require user input through a prompt to make the actual
decision.
</p>

<p>
Expand Down

0 comments on commit 4af6e95

Please sign in to comment.