From 772f0ec45ef0207055ac9cbf9a1a464dde3eaab4 Mon Sep 17 00:00:00 2001
From: Youenn Fablet
Date: Wed, 10 Jan 2024 17:00:37 +0100
Subject: [PATCH] Make setMicrophoneActive and setCameraActive return promises
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.
---
index.bs | 105 +++++++++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 95 insertions(+), 10 deletions(-)
diff --git a/index.bs b/index.bs
index fb9834a..df20787 100644
--- a/index.bs
+++ b/index.bs
@@ -85,6 +85,7 @@ urlPrefix: https://html.spec.whatwg.org/multipage/dom.html; spec: dom
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
@@ -786,9 +787,9 @@ interface MediaSession {
undefined setPositionState(optional MediaPositionState state = {});
- undefined setMicrophoneActive(boolean active);
+ Promise<undefined> setMicrophoneActive(boolean active);
- undefined setCameraActive(boolean active);
+ Promise<undefined> setCameraActive(boolean active);
};
@@ -922,14 +923,98 @@ interface MediaSession {
- The setMicrophoneActive(active) and
- setCameraActive(active) 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 setMicrophoneActive(false)
).
- It is RECOMMENDED that the user agent respect the microphone and camera
- states indicated by the page in this UI.
+ The setMicrophoneActive(active) method
+ indicates to the user agent the microphone state desired by the page (e.g. if
+ the microphone is considered "muted" by the page since it is no longer sending
+ audio through a call, the page can invoke
+ setMicrophoneActive(false)
). When invoked, it MUST perform the
+ following steps:
+
+ -
+ Let document be [=this=]'s [=relevant global object=]'s
+ [=associated Document=].
+
+ -
+ Let captureKind be "microphone".
+
+ -
+ Return the result of running the [=update capture state algorithm=] with
+ document, active and captureKind.
+
+
+
+
+ Similarly, the setCameraActive(active)
+ method indicates to the user agent the camera state desired by the page. When
+ invoked, it MUST perform the following steps:
+
+ -
+ Let document be [=this=]'s [=relevant global object=]'s
+ [=associated Document=].
+
+ -
+ Let captureKind be "camera".
+
+ -
+ Return the result of running the [=update capture state algorithm=] with
+ document, active and captureKind.
+
+
+
+
+ When the update capture state algorithm is invoked with
+ document, active and captureKind, the user
+ agent MUST perform the following steps:
+
+ -
+ If document is not [=fully active=], return [=a promise
+ rejected with=] InvalidStateError.
+
+ -
+ If active is
true
and document's
+ [=Document/visibility state=] is not "visible", the user agent MAY return
+ [=a promise rejected with=] InvalidStateError.
+
+ -
+ Let p be a new promise.
+
+ -
+ In parallel, run the following substeps::
+
+ - The user agent MAY wait to proceed, for instance if
+ active is
true
and document's
+ [=Document/visibility state=] is not "visible".
+ - If active corresponds to captureKind's state,
+ resolve p with
undefined
and abort these
+ steps.
+ - If the user agent denies the request to change
+ captureKind's state to active, reject p
+ with a NotAllowedError and abort these steps.
+ - Let newMutedState be
true
if
+ active is false
and false
+ otherwise.
+ - It is recommended that the user agent initiates a change to
+ captureKind's [=MediaStreamTrack muted state|muted state=]
+ according active. When doing so, the user agent MUST queue
+ a task for any affected [=MediaStreamTrack=] to [=set
+ MediaStreamTrack muted state=] to newMutedState.
+ - Update the user agent captureKind's state UI according
+ active.
+ - Resolve p with
undefined
.
+
+
+ -
+ Return p.
+
+
+
+
+ Both the setMicrophoneActive(active) and setCameraActive(active)
+ methods can 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 could decide to require [=transient activation=] in
+ that case. It might also require user input through a prompt to make the
+ actual decision.