Bug 1975032 Comment 10 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

PS. I also have a query about what kind of modification you can do when cloning.
To test this I modified https://jsfiddle.net/jib1/5t1mehn4/ to change the 

I modified the example to construct one of these things.

```
["video"].forEach(kind => promise_test(async t => {
  const frame = await getRTCEncodedFrame(kind);
  const newFrame = new RTCEncodedVideoFrame(frame, {metadata: { height: "260" }} )
  console.log(`main ${JSON.stringify(frame.getMetadata(), null, 2)}`);
  console.log(`main2 ${JSON.stringify(newFrame.getMetadata(), null, 2)}`);
}, `${kind} test`));
```
This gave me error

> FAIL video test: InvalidModificationError: Failed to construct 'RTCEncodedVideoFrame': Cannot create a new VideoFrame: new metadata has member(s) missing. failed

Looking at the spec https://w3c.github.io/webrtc-encoded-transform/#dom-rtcencodedaudioframe-constructor it doesn't sound like it requires you to specify all members - it reads like they get cloned from the original doc and then any options that are specified overwrite those values. What am I missing?

Then I tried copying all the values and just modifying them.

```
["video"].forEach(kind => promise_test(async t => {
  const frame = await getRTCEncodedFrame(kind);
  let frameMeta = frame.getMetadata()
  frameMeta.width = 260;
  const newFrame = new RTCEncodedVideoFrame(frame, {metadata: frameMeta } )
  console.log(`main ${JSON.stringify(frameMeta, null, 2)}`);
  console.log(`main2 ${JSON.stringify(newFrame.getMetadata(), null, 2)}`);
}, `${kind} test`));
```
This gave me error:

> FAIL video test: InvalidModificationError: Failed to construct 'RTCEncodedVideoFrame': Cannot create a new VideoFrame: invalid modification of RTCEncodedVideoFrameMetadata. faile

Again, spec doesn't indicate any constraints. 

So the question is, what am I allowed to do?
EDITED FYI  PS. I also have a query about what kind of modification you can do when cloning. Looking at the spec https://w3c.github.io/webrtc-encoded-transform/#dom-rtcencodedaudioframe-constructor it doesn't sound like it requires you to specify all members - it reads like they get cloned from the original doc and then any options that are specified overwrite those values. 

Just letting you know that this theory works on Firefox but gave me errors on Chrome.

To test this I modified https://jsfiddle.net/jib1/5t1mehn4/ to create a new frame:

```
  const newFrame = new RTCEncodedVideoFrame(frame, {metadata: { height: "260" }} )
```

> FAIL video test: InvalidModificationError: Failed to construct 'RTCEncodedVideoFrame': Cannot create a new VideoFrame: new metadata has member(s) missing. failed

Similarly, if I got metadata (so a full object) and modified the width then created a frame with that. Chrome gave me this value.

> FAIL video test: InvalidModificationError: Failed to construct 'RTCEncodedVideoFrame': Cannot create a new VideoFrame: invalid modification of RTCEncodedVideoFrameMetadata.
EDITED FYI  PS.  Looking at the spec https://w3c.github.io/webrtc-encoded-transform/#dom-rtcencodedaudioframe-constructor it doesn't sound like it requires you to specify all members - it reads like they get cloned from the original doc and then any options that are specified overwrite those values. 

Just letting you know that this theory works on Firefox but gave me errors on Chrome.

To test this I modified https://jsfiddle.net/jib1/5t1mehn4/ to create a new frame:

```
  const newFrame = new RTCEncodedVideoFrame(frame, {metadata: { height: "260" }} )
```

> FAIL video test: InvalidModificationError: Failed to construct 'RTCEncodedVideoFrame': Cannot create a new VideoFrame: new metadata has member(s) missing. failed

Similarly, if I got metadata (so a full object) and modified the `width` metadata then created a frame with that. Chrome gave me this value.

> FAIL video test: InvalidModificationError: Failed to construct 'RTCEncodedVideoFrame': Cannot create a new VideoFrame: invalid modification of RTCEncodedVideoFrameMetadata.

Back to Bug 1975032 Comment 10