From 772f0ec45ef0207055ac9cbf9a1a464dde3eaab4 Mon Sep 17 00:00:00 2001
From: Youenn Fablet
Date: Wed, 10 Jan 2024 17:00:37 +0100
Subject: [PATCH 1/7] 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.
From 7ffba8d0a6ebe57fb13390d44b22589223d327ef Mon Sep 17 00:00:00 2001
From: youennf
Date: Fri, 2 Feb 2024 17:58:24 +0100
Subject: [PATCH 2/7] Update index.bs
Co-authored-by: Jan-Ivar Bruaroey
---
index.bs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/index.bs b/index.bs
index df20787..dc124e1 100644
--- a/index.bs
+++ b/index.bs
@@ -979,7 +979,7 @@ interface MediaSession {
Let p be a new promise.
- In parallel, run the following substeps::
+ In parallel, run the following substeps:
- The user agent MAY wait to proceed, for instance if
active is
true
and document's
From 9d0f90d45559d783ee109c6518e3b3df65ed34c6 Mon Sep 17 00:00:00 2001
From: youennf
Date: Fri, 2 Feb 2024 17:58:41 +0100
Subject: [PATCH 3/7] Update index.bs
Co-authored-by: Jan-Ivar Bruaroey
---
index.bs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/index.bs b/index.bs
index dc124e1..75324bc 100644
--- a/index.bs
+++ b/index.bs
@@ -927,7 +927,7 @@ interface MediaSession {
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
+ setMicrophoneActive(false)
). When invoked, the method MUST perform the
following steps:
-
From 6decc0671baf6147d30adc434ab9caa4afaa4470 Mon Sep 17 00:00:00 2001
From: youennf
Date: Fri, 2 Feb 2024 18:02:57 +0100
Subject: [PATCH 4/7] Update index.bs
Co-authored-by: Jan-Ivar Bruaroey
---
index.bs | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/index.bs b/index.bs
index 75324bc..6887bc8 100644
--- a/index.bs
+++ b/index.bs
@@ -981,9 +981,9 @@ interface MediaSession {
-
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 is
true
, the
+ user agent MAY wait to proceed, for instance to
+ prompt the user.
- If active corresponds to captureKind's state,
resolve p with
undefined
and abort these
steps.
From aa6607f54f0b71496e7c614f9e49ed98cc26f723 Mon Sep 17 00:00:00 2001
From: Youenn Fablet
Date: Fri, 2 Feb 2024 18:11:36 +0100
Subject: [PATCH 5/7] Switch to capture state
---
index.bs | 43 +++++++++++++++++++++----------------------
1 file changed, 21 insertions(+), 22 deletions(-)
diff --git a/index.bs b/index.bs
index 6887bc8..ba351ea 100644
--- a/index.bs
+++ b/index.bs
@@ -925,21 +925,21 @@ interface MediaSession {
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, the method MUST perform the
- following steps:
+ the microphone is considered "inactive" by the page since it is no longer
+ sending audio through a call, the page can invoke
+ setMicrophoneActive(false)
). When invoked, the method MUST
+ perform the following steps:
-
Let document be [=this=]'s [=relevant global object=]'s
[=associated Document=].
-
- Let captureKind be "microphone".
+ Let captureState be user agent microphone capture state.
-
Return the result of running the [=update capture state algorithm=] with
- document, active and captureKind.
+ document, active and captureState.
@@ -953,17 +953,17 @@ interface MediaSession {
[=associated Document=].
- Let captureKind be "camera".
+ Let captureState be user agent camera capture state.
Return the result of running the [=update capture state algorithm=] with
- document, active and captureKind.
+ document, active and captureState.
When the update capture state algorithm is invoked with
- document, active and captureKind, the user
+ document, active and captureState, the user
agent MUST perform the following steps:
-
@@ -981,24 +981,23 @@ interface MediaSession {
-
In parallel, run the following substeps:
- - If active is
true
, the
- user agent MAY wait to proceed, for instance to
- prompt the user.
- - If active corresponds to captureKind's state,
- resolve p with
undefined
and abort these
- steps.
+ - If active is
true
, the user agent MAY wait
+ to proceed, for instance to prompt the user.
+ - If active corresponds to captureState, 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.
+ captureState 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
+ [=MediaStreamTrack muted state|muted state=] for all tracks related to
+ captureState 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 captureState and UI according
active.
- Resolve p with
undefined
.
From 2fb5a042207512bf744b26c309bd7e2337f4c228 Mon Sep 17 00:00:00 2001
From: Youenn Fablet
Date: Tue, 13 Feb 2024 22:45:21 +0100
Subject: [PATCH 6/7] Switch back to captureKind
---
index.bs | 101 +++++++++++++++++++++++++++++++++----------------------
1 file changed, 60 insertions(+), 41 deletions(-)
diff --git a/index.bs b/index.bs
index ba351ea..bcd5d6b 100644
--- a/index.bs
+++ b/index.bs
@@ -924,48 +924,48 @@ interface MediaSession {
The setMicrophoneActive(active) method
- indicates to the user agent the microphone state desired by the page (e.g. if
- the microphone is considered "inactive" by the page since it is no longer
- sending audio through a call, the page can invoke
- setMicrophoneActive(false)
). When invoked, the method MUST
- perform the following steps:
-
+ indicates to the user agent the microphone capture state desired by the page
+ (e.g. if the microphone is considered "inactive" 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 captureState be user agent microphone capture state.
+ Let captureKind be "microphone".
-
Return the result of running the [=update capture state algorithm=] with
- document, active and captureState.
+ 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:
-
+ method indicates to the user agent the camera capture 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 captureState be user agent camera capture state.
+ Let captureKind be "camera".
-
Return the result of running the [=update capture state algorithm=] with
- document, active and captureState.
+ document, active and captureKind.
-
+
- When the update capture state algorithm is invoked with
- document, active and captureState, the user
- agent MUST perform the following steps:
-
+ The update capture state algorithm, when invoked with
+ document, active and captureKind,
+ MUST perform the following steps:
+
-
If document is not [=fully active=], return [=a promise
rejected with=] InvalidStateError.
@@ -979,33 +979,52 @@ interface MediaSession {
Let p be a new promise.
-
- In parallel, run the following substeps:
-
- - If active is
true
, the user agent MAY wait
- to proceed, for instance to prompt the user.
- - If active corresponds to captureState, resolve
- p with
undefined
and abort these steps.
- - If the user agent denies the request to change
- captureState 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
- [=MediaStreamTrack muted state|muted state=] for all tracks related to
- captureState 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 captureState and UI according
- active.
+ In parallel, run the following steps:
+
+ -
+ If the user agent implements a policy of pausing all
+ input sources of type captureKind in response to
+ UI, the user agent SHOULD run the following substeps:
+
+ -
+ Let currentlyActive be
false
if the user
+ agent is currently [=pausing all input sources=] of type captureKind
+ and true
otherwise.
+
+ -
+ If active is currentlyActive, resolve
+ p with
undefined
and abort these steps.
+
+ -
+ If active is
true
, the user agent MAY wait to
+ proceed, for instance to prompt the user.
+
+ -
+ If the user agent denies the request to update the capture state,
+ reject p with a NotAllowedError and
+ abort these steps.
+
+ -
+ Let newMutedState be
true
if active is
+ false
and false
otherwise.
+ -
+ For each [=MediaStreamTrack=] whose source is of type captureKind,
+ queue a task to [=set MediaStreamTrack muted state=] to
+ newMutedState.
+
+
+
+ -
+ Update the user agent capture state UI according to captureKind
+ and active.
+
- Resolve p with
undefined
.
-
+
-
Return p.
-
+
Both the setMicrophoneActive(active) and setCameraActive(active)
From 3cf4e757ea3d88c31cca0be93fff55ae9e7f5a5a Mon Sep 17 00:00:00 2001
From: Youenn Fablet
Date: Wed, 14 Feb 2024 09:22:34 +0100
Subject: [PATCH 7/7] Ensure promise is resolved before enqueuing tasks to
mute/unmute tracks
---
index.bs | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/index.bs b/index.bs
index bcd5d6b..118cb0a 100644
--- a/index.bs
+++ b/index.bs
@@ -982,9 +982,13 @@ interface MediaSession {
In parallel, run the following steps:
-
- If the user agent implements a policy of pausing all
- input sources of type captureKind in response to
- UI, the user agent SHOULD run the following substeps:
+ Let applyPausePolicy be
true
if the user agent
+ implements a policy of pausing all input sources of type
+ captureKind in response to UI and false
+ otherwise.
+
+ -
+ If applyPausePolicy is
true
, run the following substeps:
-
Let currentlyActive be
false
if the user
@@ -1004,6 +1008,16 @@ interface MediaSession {
reject p with a NotAllowedError and
abort these steps.
+
+
+ -
+ Update the user agent capture state UI according to captureKind
+ and active.
+
+ - Resolve p with
undefined
.
+ -
+ If applyPausePolicy is
true
, run the following substeps:
+
-
Let newMutedState be
true
if active is
false
and false
otherwise.
@@ -1014,11 +1028,6 @@ interface MediaSession {
-
- Update the user agent capture state UI according to captureKind
- and active.
-
- Resolve p with undefined
.