@@ -619,30 +619,41 @@ <h4>Processing considerations</h4>
619
619
</ section >
620
620
< section >
621
621
< h2 > Exposing change of MediaStreamTrack configuration</ h2 >
622
+ < p > The configuration (capabilities, constraints or settings) of a {{MediaStreamTrack}} may be changed dynamically
623
+ outside the control of web applications. One example is when a user decides to switch on background blur through
624
+ the operating system. Web applications might want to know that the configuration
625
+ of a particular {{MediaStreamTrack}} has changed. For that purpose, a new event is defined below.
626
+ </ p >
627
+ < h3 > MediaStreamTrack Interface Extensions</ h3 >
622
628
< div >
623
- < p > The configuration (capabilities, constraints or settings) of a {{MediaStreamTrack}} may be changed dynamically
624
- outside the control of web applications. One example is when a user decides to switch on background blur through
625
- the operating system. Web applications might want to know that the configuration
626
- of a particular {{MediaStreamTrack}} has changed. For that purpose, a new event is defined below.
627
- </ p >
628
- < pre class ="idl ">
629
+ < pre class ="idl ">
629
630
partial interface MediaStreamTrack {
630
631
attribute EventHandler onconfigurationchange;
631
632
};</ pre >
633
+ < p > The < dfn data-dfn-for ="MediaStreamTrack "> onconfigurationchange</ dfn > attribute
634
+ is an [=event handler IDL attribute=] for the `onconfigurationchange`
635
+ [=event handler=], whose [=event handler event type=] is
636
+ < dfn event for =MediaStreamTrack > configurationchange</ dfn > .
637
+ </ p >
632
638
< p >
633
639
< p > When the [=User Agent=] detects < dfn data-export id ="change-track-configuration "> a change of configuration</ dfn >
634
640
in a < var > track</ var > 's underlying source, the [=User Agent=] MUST run the following steps:</ p >
635
641
< ol >
636
642
< li > < p > If < var > track</ var > .{{MediaStreamTrack/muted}} is < code > true</ code > , wait for < var > track</ var > .{{MediaStreamTrack/muted}}
637
643
to become < code > false</ code > or < var > track</ var > .{{MediaStreamTrack/readyState}} to be "ended".</ p > </ li >
638
644
< li > < p > If < var > track</ var > .{{MediaStreamTrack/readyState}} is "ended", abort these steps.</ p > </ li >
639
- < li > < p > If < var > track</ var > 's capabilities, constraints and settings are matching < var > source</ var > configuration, abort these steps.
645
+ < li > < p > If < var > track</ var > 's capabilities, constraints and settings are matching < var > source</ var > configuration, abort these steps.</ li >
640
646
< li >
641
647
<!-- FIXME: Export capabilities, constraints and settings so that we can use them here. -->
642
648
< p > Update < var > track</ var > 's capabilities, constraints and settings according < var > track</ var > 's underlying source.</ p >
643
649
</ li >
644
- < li >
645
- < p > [=Fire an event=] named < var > configurationchange</ var > on < var > track</ var > .</ p >
650
+ < li > < p > Let < var > changes</ var > be an empty [=sequence=].</ p > </ li >
651
+ < li > < p > For each change in < var > track</ var > 's capabilities and settings, add its name to < var > changes</ var > .</ p > </ li >
652
+ < li >
653
+ < p > [=Fire an event=] named {{MediaStreamTrack/configurationchange}}
654
+ at < var > track</ var > using {{ConfigurationChangeEvent}}, with its
655
+ {{ConfigurationChangeEvent.changes}} attribute initialized to
656
+ < var > changes</ var > .</ p >
646
657
</ li >
647
658
</ ol >
648
659
</ p >
@@ -653,6 +664,35 @@ <h2>Exposing change of MediaStreamTrack configuration</h2>
653
664
</ div >
654
665
</ p >
655
666
</ div >
667
+ < h3 > ConfigurationChangeEvent Interface</ h3 >
668
+ < div >
669
+ < pre class ="idl ">
670
+ [Exposed=Window]
671
+ interface ConfigurationChangeEvent : Event {
672
+ constructor(DOMString type, ConfigurationChangeEventInit changeEventInitDict);
673
+ readonly attribute FrozenArray<DOMString> changes;
674
+ };
675
+
676
+ dictionary ConfigurationChangeEventInit : EventInit {
677
+ required sequence<DOMString> changes;
678
+ };</ pre >
679
+ < p > The < dfn data-dfn-for ="ConfigurationChangeEvent "> changes</ dfn > getter
680
+ steps are to return the value that the corresponding attribute was
681
+ initialized to.
682
+ </ p >
683
+ </ div >
684
+ < h3 > Example</ h3 >
685
+ < div >
686
+ < p > This example shows how to monitor external background blur changes.</ p >
687
+ < pre class ="example ">
688
+ const stream = await navigator.mediaDevices.getUserMedia({ video: true });
689
+ const [track] = stream.getVideoTracks();
690
+ track.addEventListener("configurationchange", (event) => {
691
+ if (event.changes.includes("backgroundBlur")) {
692
+ // Background blur configuration has changed.
693
+ }
694
+ });</ pre >
695
+ </ div >
656
696
</ section >
657
697
</ body >
658
698
</ html >
0 commit comments