summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/webrtc-encoded-transform/RTCPeerConnection-sender-worker-single-frame.js
blob: c943dafe5b154314132124e1d563df2a00b2aaf7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
onmessage = async (event) => {
  const readableStream = event.data.readableStream;
  const reader = readableStream.getReader();
  const result = await reader.read();

  // Post an object with individual fields so that the test side has
  // values to verify the serialization of the RTCEncodedVideoFrame.
  postMessage({
    type: result.value.type,
    timestamp: result.value.timestamp,
    data: result.value.data,
    metadata: result.value.getMetadata(),
  });

  // Send the frame twice to verify that the frame does not change after the
  // first serialization.
  postMessage(result.value);
  postMessage(result.value);
}