Skip to content

Commit 234f052

Browse files
authored
Merge pull request #159 from brychanrobot/background_blur
Add a section for the background blur field in VideoFrameMetadata
2 parents a43b835 + f6f7b07 commit 234f052

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed

index.html

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1876,6 +1876,92 @@ <h3>Examples</h3>
18761876
</pre>
18771877
</section>
18781878
</section>
1879+
<section>
1880+
<h2>Background Blur Effect Status</h2>
1881+
<p>The {{VideoFrameMetadata}} interface exposes the blur state as a property,
1882+
which allows apps to know the state for every frame. This can be helpful for
1883+
scenarios where the app wishes to help protect user privacy by never sending an
1884+
un-blurred frame off of the user's system.</p>
1885+
<section>
1886+
<h3>{{VideoFrameMetadata}}</h3>
1887+
<pre class="idl">
1888+
partial dictionary VideoFrameMetadata {
1889+
BackgroundBlur backgroundBlur;
1890+
};</pre>
1891+
<section class="notoc">
1892+
<h4>Members</h4>
1893+
<dl class="dictionary-members" data-link-for="VideoFrameMetadata" data-dfn-for="VideoFrameMetadata">
1894+
<dt><dfn><code>backgroundBlur</code></dfn> of type <code>{{BackgroundBlur}}</code></dt>
1895+
<dd>
1896+
<p>The state of the background blur effect for the current frame, if
1897+
[=map/exist|present=]. Absence might indicate that the frame is not
1898+
from a camera, or the user agent might not support reporting blur state.
1899+
</p>
1900+
</dd>
1901+
</dl>
1902+
</section>
1903+
</section>
1904+
<section>
1905+
<h3>{{BackgroundBlur}}</h3>
1906+
<pre class="idl">
1907+
dictionary BackgroundBlur: MediaEffectInfo {};</pre>
1908+
<section class="notoc">
1909+
</section>
1910+
</section>
1911+
<section>
1912+
<h3>{{MediaEffectInfo}}</h3>
1913+
<pre class="idl">
1914+
dictionary MediaEffectInfo {
1915+
required boolean enabled;
1916+
};</pre>
1917+
<section class="notoc">
1918+
<h4>Dictionary {{MediaEffectInfo}} Members</h4>
1919+
<dl class="dictionary-members" data-dfn-for="MediaEffectInfo" data-link-for="MediaEffectInfo">
1920+
<dt><dfn><code>enabled</code></dfn> of type {{boolean}}</dt>
1921+
<dd>
1922+
<p>True if the effect is enabled, false otherwise. This isn't a strong guarantee, as user
1923+
agents likely can't detect all possible video manipulation software.
1924+
</p>
1925+
</dd>
1926+
</dl>
1927+
</section>
1928+
</section>
1929+
<section>
1930+
<h3>Example</h3>
1931+
<pre class="example">
1932+
const stream = await navigator.mediaDevices.getUserMedia({ video: true });
1933+
const track = stream.getVideoTracks()[0];
1934+
const worker = new Worker(`data:text/javascript,(${work.toString()})()`);
1935+
worker.postMessage({track}, [track]);
1936+
const {data} = await new Promise(r => worker.onmessage = r);
1937+
video.srcObject = new MediaStream([data.track]);
1938+
1939+
function work() {
1940+
onmessage = async ({data: {track}}) => {
1941+
const trackGenerator = new VideoTrackGenerator({ kind: "video" });
1942+
self.postMessage({track: trackGenerator.track}, [trackGenerator.track]);
1943+
const trackProcessor = new MediaStreamTrackProcessor({ track });
1944+
1945+
const transformer = new TransformStream({
1946+
async transform(videoFrame, controller) {
1947+
if ("backgroundBlur" in videoFrame.metadata()) {
1948+
console.log('backgroundBlur.enabled:', videoFrame.metadata().backgroundBlur.enabled);
1949+
} else {
1950+
console.log('backgroundBlur unsupported');
1951+
}
1952+
1953+
controller.enqueue(videoFrame);
1954+
},
1955+
});
1956+
1957+
trackProcessor.readable
1958+
.pipeThrough(transformer)
1959+
.pipeTo(trackGenerator.writable);
1960+
};
1961+
}
1962+
</pre>
1963+
</section>
1964+
</section>
18791965
<section>
18801966
<h2>MediaStream in workers</h2>
18811967
<div>

0 commit comments

Comments
 (0)