Skip to content

Commit

Permalink
Merge pull request #109 from youennf/audiooutputdevice-exposure
Browse files Browse the repository at this point in the history
Add an algorithm to expose audio output devices through enumerateDevices
  • Loading branch information
jan-ivar committed Oct 8, 2020
2 parents 250a9ea + 36a22d8 commit b1640c1
Showing 1 changed file with 44 additions and 4 deletions.
48 changes: 44 additions & 4 deletions index.html
Expand Up @@ -302,13 +302,13 @@ <h2>Methods</h2>
<var>p</var> with a new {{DOMException}} whose {{DOMException/name}} attribute
has the value {{NotAllowedError}} and abort these steps.</p></li>
<li><p>Let <var>deviceInfo</var> be a new {{MediaDeviceInfo}} object to represent the selected audio output device.</p></li>
<li><p>Add <var>deviceInfo</var>.<a data-cite="!GETUSERMEDIA#def-mediadeviceinfo-deviceId">deviceId</a>
to <a>[[\explicitelyGrantedAudioOutputDevices]]</a>.</p></li>
<li><p>Resolve <var>p</var> with <var>deviceInfo</var>.</p></li>
</ol>
</li>
<li><p>Return <var>p</var>.</p></li>
</ol>
<!-- FIXME: Introduce necessary hooks to expose a device in mediacapture main spec
and use it as a specific step in above algorithm. -->
<p>Once a device is exposed after a call to {{MediaDevices/selectAudioOutput}}, it MUST be listed by
<code>enumerateDevices</code> for the current browsing context.</p>
<p>If the promise returned by {{MediaDevices/selectAudioOutput}} is resolved,
Expand Down Expand Up @@ -380,8 +380,6 @@ <h3>Consent</h3>
<h3>Obtaining Consent</h3>
<p>The user agent may explicitly obtain user consent to play audio out of
non-default output devices using {{MediaDevices/selectAudioOutput}}.</p>
<!-- FIXME: Introduce necessary hooks in mediacapture-main spec to expose
audio output devices attached to the same device as microphone being used to capture. -->
<p>Implementations MUST also support implicit consent via the
<dfn data-cite="!GETUSERMEDIA#dom-mediadevices-getusermedia">
<code>getUserMedia()</code></dfn> permission prompt; when an audio input
Expand All @@ -392,6 +390,48 @@ <h3>Obtaining Consent</h3>
groupId</code></dfn>). This conveniently handles the common case of wanting
to route both input and output audio through a headset or speakerphone
device.</p>
<p>On page load, run the following step:</p>
<ol>
<li>
<p>On the <a data-cite="!HTML/#concept-relevant-global">relevant global object</a>,
create an internal slot: <dfn>[[\explicitelyGrantedAudioOutputDevices]]</dfn>,
used to store devices that the user grants explicitely through {{MediaDevices/selectAudioOutput}},
initialized to an empty set.</p>
</li>
</ol>
<p>This specification specifies the <dfn data-cite="!GETUSERMEDIA#device-exposure-decision-non-camera-microphone">
exposure decision algorithm for devices other than camera and microphone</dfn>.
The algorithm runs as follows, with <var>device</var>, <var>microphoneList</var> and <var>cameraList</var> as input:
</p>
<ol>
<li>
<p>Let <var>document</var> be the
<a data-cite="!HTML/webappapis.html#current-settings-object">
current settings object</a>'s
<a data-cite="!HTML/webappapis.html#responsible-document">
responsible document</a>.</p>
</li>
<li><p>Let <var>deviceInfo</var> be a new {{MediaDeviceInfo}} object to represent the device.</p></li>
<li>
<p>If <var>document</var> is not <a data-cite="!HTML/iframe-embed-object.html#allowed-to-use">
allowed to use</a> the feature identified by <a data-dfn-link-for="">"speaker-selection"</a>,
or <var>deviceInfo</var>.<a data-cite="!GETUSERMEDIA#def-mediadeviceinfo-kind">kind</a> is not "audiooutput",
return <code>false</code>.</p>
</li>
<li>
<p>If <var>deviceInfo</var>.<a data-cite="!GETUSERMEDIA#def-mediadeviceinfo-deviceId">deviceId</a>
is in <a>[[\explicitelyGrantedAudioOutputDevices]]</a>, return <code>true</code>.</p>
</li>
<li>
<p>If <var>deviceInfo</var>.<a data-cite="!GETUSERMEDIA#def-mediadeviceinfo-groupId">groupId</a>
is the same as the <a data-cite="!GETUSERMEDIA#def-mediadeviceinfo-groupId">groupId</a>
of any microphone in <var>microphoneList</var>,
return <code>true</code>.</p>
</li>
<li>
<p>return <code>false</code>.</p>
</li>
</ol>
</section>
<section>
<h3 id=permissions-policy-integration>Permissions Policy Integration</h3>
Expand Down

0 comments on commit b1640c1

Please sign in to comment.