A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.cdn.mozilla.net/en-US/docs/Web/API/RTCEncodedVideoFrame/data below:

RTCEncodedVideoFrame: data property - Web APIs

RTCEncodedVideoFrame: data property

Baseline 2023

Newly available

Note: This feature is available in Dedicated Web Workers.

The data property of the RTCEncodedVideoFrame interface returns a buffer containing the frame data.

Value

An ArrayBuffer.

Examples

This example WebRTC encoded transform shows how you might get the frame data in a TransformStream transform() function and negate all the bits.

The transform() function constructs a DataView on the buffer in the frame data property, and also creates a view on a new ArrayBuffer. It then writes the inverted bytes in the original data to the new buffer, assigns the buffer to the encoded frame data property, and enqueues the modified frame on the stream.

addEventListener("rtctransform", (event) => {
  const transform = new TransformStream({
    async transform(encodedFrame, controller) {
      // Reconstruct the original frame.
      const view = new DataView(encodedFrame.data);

      // Construct a new buffer
      const newData = new ArrayBuffer(encodedFrame.data.byteLength);
      const newView = new DataView(newData);

      // Negate all bits in the incoming frame
      for (let i = 0; i < encodedFrame.data.byteLength; ++i) {
        newView.setInt8(i, ~view.getInt8(i));
      }

      encodedFrame.data = newData;
      controller.enqueue(encodedFrame);
    },
  });
  event.transformer.readable
    .pipeThrough(transform)
    .pipeTo(event.transformer.writable);
});

Note that the surrounding code shown here is described in Using WebRTC Encoded Transforms.

Specifications Browser compatibility See also

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4