diff --git a/index.bs b/index.bs index fb9834a..118cb0a 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,125 @@ 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 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: +

    +
  1. + Let document be [=this=]'s [=relevant global object=]'s + [=associated Document=]. +
  2. +
  3. + Let captureKind be "microphone". +
  4. +
  5. + Return the result of running the [=update capture state algorithm=] with + document, active and captureKind. +
  6. +
+

+

+ Similarly, the setCameraActive(active) + method indicates to the user agent the camera capture state desired by the page. + When invoked, it MUST perform the following steps: +

    +
  1. + Let document be [=this=]'s [=relevant global object=]'s + [=associated Document=]. +
  2. +
  3. + Let captureKind be "camera". +
  4. +
  5. + Return the result of running the [=update capture state algorithm=] with + document, active and captureKind. +
  6. +
+

+

+ The update capture state algorithm, when invoked with + document, active and captureKind, + MUST perform the following steps: +

    +
  1. + If document is not [=fully active=], return [=a promise + rejected with=] InvalidStateError. +
  2. +
  3. + If active is true and document's + [=Document/visibility state=] is not "visible", the user agent MAY return + [=a promise rejected with=] InvalidStateError. +
  4. +
  5. + Let p be a new promise. +
  6. +
  7. + In parallel, run the following steps: +
      +
    1. + 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. +
    2. +
    3. + If applyPausePolicy is true, run the following substeps: +
        +
      1. + Let currentlyActive be false if the user + agent is currently [=pausing all input sources=] of type captureKind + and true otherwise. +
      2. +
      3. + If active is currentlyActive, resolve + p with undefined and abort these steps. +
      4. +
      5. + If active is true, the user agent MAY wait to + proceed, for instance to prompt the user. +
      6. +
      7. + If the user agent denies the request to update the capture state, + reject p with a NotAllowedError and + abort these steps. +
      8. +
      +
    4. +
    5. + Update the user agent capture state UI according to captureKind + and active. +
    6. +
    7. Resolve p with undefined.
    8. +
    9. + If applyPausePolicy is true, run the following substeps: +
        +
      1. + Let newMutedState be true if active is + false and false otherwise.
      2. +
      3. + For each [=MediaStreamTrack=] whose source is of type captureKind, + queue a task to [=set MediaStreamTrack muted state=] to + newMutedState. +
      4. +
      +
    10. +
    +
  8. +
  9. + Return p. +
  10. +
+

+

+ 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.