Cleanup RTCEncodedFrame clone() method in favour of structuredClone()

The spec discussion is coming towards just supporting structuredClone()
as the best way of achieving these goals. This is already shipped
in Chrome, so we can cleanup this experimental clone() method.

Bug: webrtc:14709
Change-Id: Ib1ac9dd4ed5b639acf10eead00fe98e14ffaf381
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4859934
Reviewed-by: Palak Agarwal <agpalak@chromium.org>
Reviewed-by: Harald Alvestrand <hta@chromium.org>
Auto-Submit: Tony Herre <toprice@chromium.org>
Reviewed-by: Yoav Weiss <yoavweiss@chromium.org>
Commit-Queue: Tony Herre <toprice@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1197746}
diff --git a/webrtc-encoded-transform/RTCEncodedAudioFrame-clone.https.html b/webrtc-encoded-transform/RTCEncodedAudioFrame-clone.https.html
index ec99338..715cd36 100644
--- a/webrtc-encoded-transform/RTCEncodedAudioFrame-clone.https.html
+++ b/webrtc-encoded-transform/RTCEncodedAudioFrame-clone.https.html
@@ -35,7 +35,7 @@
       const receiverReader = receiverStreams.readable.getReader();
       const result = await receiverReader.read();
       const original = result.value;
-      let clone = original.clone();
+      let clone = structuredClone(original);
       assert_equals(original.timestamp, clone.timestamp);
       assert_array_equals(Array.from(original.data), Array.from(clone.data));
       await writer2.write(clone);
diff --git a/webrtc-encoded-transform/RTCEncodedAudioFrame-receive-cloned.https.html b/webrtc-encoded-transform/RTCEncodedAudioFrame-receive-cloned.https.html
index 5a3bfea..66ce0bb 100644
--- a/webrtc-encoded-transform/RTCEncodedAudioFrame-receive-cloned.https.html
+++ b/webrtc-encoded-transform/RTCEncodedAudioFrame-receive-cloned.https.html
@@ -40,7 +40,7 @@
       assert_equals(originalAudioFrame.timestamp, clonedAudioFrame.timestamp);
       assert_array_equals(Array.from(originalAudioFrame.data), Array.from(clonedAudioFrame.data));
       await writer2.write(clonedAudioFrame);
-      await receiverWriter.write(originalAudioFrame.clone());
+      await receiverWriter.write(structuredClone(originalAudioFrame));
       resolve();
     }
   });
diff --git a/webrtc-encoded-transform/RTCEncodedVideoFrame-clone.https.html b/webrtc-encoded-transform/RTCEncodedVideoFrame-clone.https.html
index 2933072..0c51df2 100644
--- a/webrtc-encoded-transform/RTCEncodedVideoFrame-clone.https.html
+++ b/webrtc-encoded-transform/RTCEncodedVideoFrame-clone.https.html
@@ -54,7 +54,7 @@
 
   for (let i = 0; i < numFramesToSend; i++) {
     const result = await senderReader.read();
-    senderWriter.write(result.value.clone());
+    senderWriter.write(structuredClone(result.value));
   }
   return framesReceivedCorrectly;
 }, "Cloning before sending works");
diff --git a/webrtc-encoded-transform/set-metadata.https.html b/webrtc-encoded-transform/set-metadata.https.html
index 037fefc..c469959 100644
--- a/webrtc-encoded-transform/set-metadata.https.html
+++ b/webrtc-encoded-transform/set-metadata.https.html
@@ -16,13 +16,15 @@
   const metadata = result.value.getMetadata();
   // TODO(https://crbug.com/webrtc/14709): When RTCEncodedVideoFrame has a
   // constructor, create a new frame from scratch instead of cloning it to
-  // ensure that none of the metadata was carried over via clone(). This would
-  // allow us to be confident that setMetadata() is doing all the work.
+  // ensure that none of the metadata was carried over via structuredClone().
+  // This would allow us to be confident that setMetadata() is doing all the
+  // work.
   //
-  // At that point, we can refactor the clone() implementation to be the same as
-  // constructor() + set data + setMetadata() to ensure that clone() cannot do
-  // things that are not already exposed in JavaScript (no secret steps!).
-  const clone = result.value.clone();
+  // At that point, we can refactor the structuredClone() implementation to be
+  // the same as constructor() + set data + setMetadata() to ensure that
+  // structuredClone() cannot do things that are not already exposed in
+  // JavaScript (no secret steps!).
+  const clone = structuredClone(result.value);
   clone.setMetadata(metadata);
   const cloneMetadata = clone.getMetadata();
   // Encoding related metadata.
@@ -37,10 +39,10 @@
                 'temporalIndex');
   // RTP related metadata.
   // TODO(https://crbug.com/webrtc/14709): This information also needs to be
-  // settable but isn't - the assertions only pass because clone() copies them
-  // for us. It would be great if different layers didn't consider different
-  // subset of the struct as "the metadata". Can we consolidate into a single
-  // webrtc struct for all metadata?
+  // settable but isn't - the assertions only pass because structuredClone()
+  // copies them for us. It would be great if different layers didn't consider
+  // different subset of the struct as "the metadata". Can we consolidate into a
+  // single webrtc struct for all metadata?
   assert_equals(cloneMetadata.synchronizationSource,
                 metadata.synchronizationSource, 'synchronizationSource');
   assert_array_equals(cloneMetadata.contributingSources,