summarylogtreecommitdiffstats
path: root/0002-Revert-RTCInsertableStreams-Make-RTCEncodedVideoFram.patch
blob: 18bff6ecd5f82449b53e934b7b3e4b8c69cb5bc9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
From 23bf04c1127da00d17bfa72794602e59b484ae76 Mon Sep 17 00:00:00 2001
From: Daniel Playfair Cal <daniel.playfair.cal@gmail.com>
Date: Fri, 17 Apr 2020 00:41:46 +1000
Subject: [PATCH 2/8] Revert "[RTCInsertableStreams] Make RTCEncodedVideoFrame
 serializable"

This reverts commit 283079bc066cc19c0d0d186500697ca95ca03c3f.
---
 .../core/v8/serialization/serialization_tag.h |  1 -
 .../serialization/serialized_script_value.h   | 31 +------
 ...8_script_value_deserializer_for_modules.cc | 28 ------
 ...v8_script_value_deserializer_for_modules.h |  2 -
 .../v8_script_value_serializer_for_modules.cc | 28 ------
 .../v8_script_value_serializer_for_modules.h  |  2 -
 .../renderer/modules/peerconnection/BUILD.gn  |  2 -
 .../peerconnection/rtc_encoded_video_frame.cc | 54 +++++------
 .../peerconnection/rtc_encoded_video_frame.h  | 19 ++--
 .../rtc_encoded_video_frame_delegate.cc       | 89 -------------------
 .../rtc_encoded_video_frame_delegate.h        | 72 ---------------
 .../rtc_encoded_video_underlying_sink.cc      |  3 +-
 .../rtc_encoded_video_underlying_sink_test.cc |  2 +-
 13 files changed, 34 insertions(+), 299 deletions(-)
 delete mode 100644 third_party/blink/renderer/modules/peerconnection/rtc_encoded_video_frame_delegate.cc
 delete mode 100644 third_party/blink/renderer/modules/peerconnection/rtc_encoded_video_frame_delegate.h

diff --git a/third_party/blink/renderer/bindings/core/v8/serialization/serialization_tag.h b/third_party/blink/renderer/bindings/core/v8/serialization/serialization_tag.h
index cce273938fc2..05e37ce90847 100644
--- a/third_party/blink/renderer/bindings/core/v8/serialization/serialization_tag.h
+++ b/third_party/blink/renderer/bindings/core/v8/serialization/serialization_tag.h
@@ -102,7 +102,6 @@ enum SerializationTag {
   //                     namedCurve:uint32_t
   kRTCCertificateTag = 'k',  // length:uint32_t, pemPrivateKey:WebCoreString,
                              // pemCertificate:WebCoreString
-  kRTCEncodedVideoFrameTag = 'V',  // uint32_t -> transferred video frame ID
 
   // The following tags were used by the Shape Detection API implementation
   // between M71 and M81. During these milestones, the API was always behind
diff --git a/third_party/blink/renderer/bindings/core/v8/serialization/serialized_script_value.h b/third_party/blink/renderer/bindings/core/v8/serialization/serialized_script_value.h
index bbf10ef3135b..1a80aa3b2356 100644
--- a/third_party/blink/renderer/bindings/core/v8/serialization/serialized_script_value.h
+++ b/third_party/blink/renderer/bindings/core/v8/serialization/serialized_script_value.h
@@ -269,41 +269,13 @@ class CORE_EXPORT SerializedScriptValue
 
   bool IsLockedToAgentCluster() const {
     return !wasm_modules_.IsEmpty() ||
-           !shared_array_buffers_contents_.IsEmpty() ||
-           std::any_of(attachments_.begin(), attachments_.end(),
-                       [](const auto& entry) {
-                         return entry.value->IsLockedToAgentCluster();
-                       });
+           !shared_array_buffers_contents_.IsEmpty();
   }
 
   // Returns true after serializing script values that remote origins cannot
   // access.
   bool IsOriginCheckRequired() const;
 
-  // Derive from Attachments to define collections of objects to serialize in
-  // modules. They can be registered using GetOrCreateAttachment().
-  class Attachment {
-   public:
-    virtual ~Attachment() = default;
-    virtual bool IsLockedToAgentCluster() const = 0;
-  };
-
-  template <typename T>
-  T* GetOrCreateAttachment() {
-    auto result = attachments_.insert(&T::kAttachmentKey, std::unique_ptr<T>());
-    if (!result.stored_value->value)
-      result.stored_value->value = std::make_unique<T>();
-    return static_cast<T*>(result.stored_value->value.get());
-  }
-
-  template <typename T>
-  const T* GetAttachmentIfExists() const {
-    auto it = attachments_.find(&T::kAttachmentKey);
-    if (it == attachments_.end())
-      return nullptr;
-    return static_cast<T*>(it->value.get());
-  }
-
  private:
   friend class ScriptValueSerializer;
   friend class V8ScriptValueSerializer;
@@ -372,7 +344,6 @@ class CORE_EXPORT SerializedScriptValue
   MojoScopedHandleArray mojo_handles_;
   SharedArrayBufferContentsArray shared_array_buffers_contents_;
   NativeFileSystemTokensArray native_file_system_tokens_;
-  HashMap<const void* const*, std::unique_ptr<Attachment>> attachments_;
 
   bool has_registered_external_allocation_;
 #if DCHECK_IS_ON()
diff --git a/third_party/blink/renderer/bindings/modules/v8/serialization/v8_script_value_deserializer_for_modules.cc b/third_party/blink/renderer/bindings/modules/v8/serialization/v8_script_value_deserializer_for_modules.cc
index 684d40f0cee8..b5f07e85b7b2 100644
--- a/third_party/blink/renderer/bindings/modules/v8/serialization/v8_script_value_deserializer_for_modules.cc
+++ b/third_party/blink/renderer/bindings/modules/v8/serialization/v8_script_value_deserializer_for_modules.cc
@@ -18,8 +18,6 @@
 #include "third_party/blink/renderer/modules/native_file_system/native_file_system_file_handle.h"
 #include "third_party/blink/renderer/modules/peerconnection/rtc_certificate.h"
 #include "third_party/blink/renderer/modules/peerconnection/rtc_certificate_generator.h"
-#include "third_party/blink/renderer/modules/peerconnection/rtc_encoded_video_frame.h"
-#include "third_party/blink/renderer/modules/peerconnection/rtc_encoded_video_frame_delegate.h"
 
 namespace blink {
 
@@ -67,8 +65,6 @@ ScriptWrappable* V8ScriptValueDeserializerForModules::ReadDOMObject(
         return nullptr;
       return MakeGarbageCollected<RTCCertificate>(std::move(certificate));
     }
-    case kRTCEncodedVideoFrameTag:
-      return ReadRTCEncodedVideoFrame();
     default:
       break;
   }
@@ -373,28 +369,4 @@ V8ScriptValueDeserializerForModules::ReadNativeFileSystemHandle(
   }
 }
 
-RTCEncodedVideoFrame*
-V8ScriptValueDeserializerForModules::ReadRTCEncodedVideoFrame() {
-  if (!RuntimeEnabledFeatures::RTCInsertableStreamsEnabled(
-          ExecutionContext::From(GetScriptState()))) {
-    return nullptr;
-  }
-
-  uint32_t index;
-  if (!ReadUint32(&index))
-    return nullptr;
-
-  const auto* attachment =
-      GetSerializedScriptValue()
-          ->GetAttachmentIfExists<RTCEncodedVideoFramesAttachment>();
-  if (!attachment)
-    return nullptr;
-
-  const auto& frames = attachment->EncodedVideoFrames();
-  if (index >= frames.size())
-    return nullptr;
-
-  return MakeGarbageCollected<RTCEncodedVideoFrame>(frames[index]);
-}
-
 }  // namespace blink
diff --git a/third_party/blink/renderer/bindings/modules/v8/serialization/v8_script_value_deserializer_for_modules.h b/third_party/blink/renderer/bindings/modules/v8/serialization/v8_script_value_deserializer_for_modules.h
index 410fe5098096..15e5d35547b6 100644
--- a/third_party/blink/renderer/bindings/modules/v8/serialization/v8_script_value_deserializer_for_modules.h
+++ b/third_party/blink/renderer/bindings/modules/v8/serialization/v8_script_value_deserializer_for_modules.h
@@ -12,7 +12,6 @@ namespace blink {
 
 class CryptoKey;
 class NativeFileSystemHandle;
-class RTCEncodedVideoFrame;
 
 // Extends V8ScriptValueSerializer with support for modules/ types.
 class MODULES_EXPORT V8ScriptValueDeserializerForModules final
@@ -45,7 +44,6 @@ class MODULES_EXPORT V8ScriptValueDeserializerForModules final
   }
   CryptoKey* ReadCryptoKey();
   NativeFileSystemHandle* ReadNativeFileSystemHandle(SerializationTag tag);
-  RTCEncodedVideoFrame* ReadRTCEncodedVideoFrame();
 };
 
 }  // namespace blink
diff --git a/third_party/blink/renderer/bindings/modules/v8/serialization/v8_script_value_serializer_for_modules.cc b/third_party/blink/renderer/bindings/modules/v8/serialization/v8_script_value_serializer_for_modules.cc
index 6811770537b9..6f017cdd3eca 100644
--- a/third_party/blink/renderer/bindings/modules/v8/serialization/v8_script_value_serializer_for_modules.cc
+++ b/third_party/blink/renderer/bindings/modules/v8/serialization/v8_script_value_serializer_for_modules.cc
@@ -18,9 +18,6 @@
 #include "third_party/blink/renderer/bindings/modules/v8/v8_landmark.h"
 #include "third_party/blink/renderer/bindings/modules/v8/v8_point_2d.h"
 #include "third_party/blink/renderer/bindings/modules/v8/v8_rtc_certificate.h"
-#include "third_party/blink/renderer/bindings/modules/v8/v8_rtc_encoded_video_frame.h"
-#include "third_party/blink/renderer/modules/peerconnection/rtc_encoded_video_frame.h"
-#include "third_party/blink/renderer/modules/peerconnection/rtc_encoded_video_frame_delegate.h"
 #include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
 
 namespace blink {
@@ -77,17 +74,6 @@ bool V8ScriptValueSerializerForModules::WriteDOMObject(
     WriteUTF8String(pem.certificate().c_str());
     return true;
   }
-  if (wrapper_type_info == V8RTCEncodedVideoFrame::GetWrapperTypeInfo() &&
-      RuntimeEnabledFeatures::RTCInsertableStreamsEnabled(
-          ExecutionContext::From(GetScriptState()))) {
-    if (IsForStorage()) {
-      exception_state.ThrowDOMException(DOMExceptionCode::kDataCloneError,
-                                        "An RTCEncodedVideoFrame cannot be "
-                                        "serialized for storage.");
-      return false;
-    }
-    return WriteRTCEncodedVideoFrame(wrappable->ToImpl<RTCEncodedVideoFrame>());
-  }
   return false;
 }
 
@@ -286,18 +272,4 @@ bool V8ScriptValueSerializerForModules::WriteNativeFileSystemHandle(
   return true;
 }
 
-bool V8ScriptValueSerializerForModules::WriteRTCEncodedVideoFrame(
-    RTCEncodedVideoFrame* video_frame) {
-  auto* attachment =
-      GetSerializedScriptValue()
-          ->GetOrCreateAttachment<RTCEncodedVideoFramesAttachment>();
-  auto& frames = attachment->EncodedVideoFrames();
-  frames.push_back(video_frame->Delegate());
-  const uint32_t index = static_cast<uint32_t>(frames.size() - 1);
-
-  WriteTag(kRTCEncodedVideoFrameTag);
-  WriteUint32(index);
-  return true;
-}
-
 }  // namespace blink
diff --git a/third_party/blink/renderer/bindings/modules/v8/serialization/v8_script_value_serializer_for_modules.h b/third_party/blink/renderer/bindings/modules/v8/serialization/v8_script_value_serializer_for_modules.h
index 10ac32ca4f69..6405202e0cb0 100644
--- a/third_party/blink/renderer/bindings/modules/v8/serialization/v8_script_value_serializer_for_modules.h
+++ b/third_party/blink/renderer/bindings/modules/v8/serialization/v8_script_value_serializer_for_modules.h
@@ -12,7 +12,6 @@
 namespace blink {
 
 class NativeFileSystemHandle;
-class RTCEncodedVideoFrame;
 class WebCryptoKey;
 
 // Extends V8ScriptValueSerializer with support for modules/ types.
@@ -33,7 +32,6 @@ class MODULES_EXPORT V8ScriptValueSerializerForModules final
   bool WriteNativeFileSystemHandle(
       SerializationTag tag,
       NativeFileSystemHandle* native_file_system_handle);
-  bool WriteRTCEncodedVideoFrame(RTCEncodedVideoFrame*);
 };
 
 }  // namespace blink
diff --git a/third_party/blink/renderer/modules/peerconnection/BUILD.gn b/third_party/blink/renderer/modules/peerconnection/BUILD.gn
index 4f9144ed30e0..5cf4876a3628 100644
--- a/third_party/blink/renderer/modules/peerconnection/BUILD.gn
+++ b/third_party/blink/renderer/modules/peerconnection/BUILD.gn
@@ -84,8 +84,6 @@ blink_modules_sources("peerconnection") {
     "rtc_encoded_audio_underlying_source.h",
     "rtc_encoded_video_frame.cc",
     "rtc_encoded_video_frame.h",
-    "rtc_encoded_video_frame_delegate.cc",
-    "rtc_encoded_video_frame_delegate.h",
     "rtc_encoded_video_underlying_sink.cc",
     "rtc_encoded_video_underlying_sink.h",
     "rtc_encoded_video_underlying_source.cc",
diff --git a/third_party/blink/renderer/modules/peerconnection/rtc_encoded_video_frame.cc b/third_party/blink/renderer/modules/peerconnection/rtc_encoded_video_frame.cc
index 65593da51242..3f8676ddb290 100644
--- a/third_party/blink/renderer/modules/peerconnection/rtc_encoded_video_frame.cc
+++ b/third_party/blink/renderer/modules/peerconnection/rtc_encoded_video_frame.cc
@@ -4,47 +4,46 @@
 
 #include "third_party/blink/renderer/modules/peerconnection/rtc_encoded_video_frame.h"
 
-#include <utility>
-
 #include "third_party/blink/renderer/core/typed_arrays/dom_array_buffer.h"
-#include "third_party/blink/renderer/modules/peerconnection/rtc_encoded_video_frame_delegate.h"
 #include "third_party/blink/renderer/platform/wtf/text/string_builder.h"
 #include "third_party/webrtc/api/frame_transformer_interface.h"
 
 namespace blink {
 
 RTCEncodedVideoFrame::RTCEncodedVideoFrame(
-    std::unique_ptr<webrtc::TransformableVideoFrameInterface> webrtc_frame)
-    : delegate_(base::MakeRefCounted<RTCEncodedVideoFrameDelegate>(
-          std::move(webrtc_frame))) {}
-
-RTCEncodedVideoFrame::RTCEncodedVideoFrame(
-    scoped_refptr<RTCEncodedVideoFrameDelegate> delegate)
+    std::unique_ptr<webrtc::TransformableVideoFrameInterface> delegate)
     : delegate_(std::move(delegate)) {}
 
 String RTCEncodedVideoFrame::type() const {
-  return delegate_->Type();
+  if (!delegate_)
+    return "empty";
+
+  return delegate_->IsKeyFrame() ? "key" : "delta";
 }
 
 uint64_t RTCEncodedVideoFrame::timestamp() const {
-  return delegate_->Timestamp();
+  return delegate_ ? delegate_->GetTimestamp() : 0;
 }
 
 DOMArrayBuffer* RTCEncodedVideoFrame::data() const {
-  if (!frame_data_)
-    frame_data_ = delegate_->CreateDataBuffer();
+  if (delegate_ && !frame_data_) {
+    frame_data_ = DOMArrayBuffer::Create(delegate_->GetData().data(),
+                                         delegate_->GetData().size());
+  }
   return frame_data_;
 }
 
 DOMArrayBuffer* RTCEncodedVideoFrame::additionalData() const {
-  if (!additional_data_)
-    additional_data_ = delegate_->CreateAdditionalDataBuffer();
-
+  if (delegate_ && !additional_data_) {
+    auto additional_data = delegate_->GetAdditionalData();
+    additional_data_ =
+        DOMArrayBuffer::Create(additional_data.data(), additional_data.size());
+  }
   return additional_data_;
 }
 
 uint32_t RTCEncodedVideoFrame::synchronizationSource() const {
-  return delegate_->Ssrc();
+  return delegate_ ? delegate_->GetSsrc() : 0;
 }
 
 void RTCEncodedVideoFrame::setData(DOMArrayBuffer* data) {
@@ -66,20 +65,15 @@ String RTCEncodedVideoFrame::toString() const {
   return sb.ToString();
 }
 
-void RTCEncodedVideoFrame::SyncDelegate() const {
-  delegate_->SetData(frame_data_);
-}
-
-scoped_refptr<RTCEncodedVideoFrameDelegate> RTCEncodedVideoFrame::Delegate()
-    const {
-  SyncDelegate();
-  return delegate_;
-}
-
 std::unique_ptr<webrtc::TransformableVideoFrameInterface>
-RTCEncodedVideoFrame::PassWebRtcFrame() {
-  SyncDelegate();
-  return delegate_->PassWebRtcFrame();
+RTCEncodedVideoFrame::PassDelegate() {
+  // Sync the delegate data with |frame_data_| if necessary.
+  if (delegate_ && frame_data_) {
+    delegate_->SetData(rtc::ArrayView<const uint8_t>(
+        static_cast<const uint8_t*>(frame_data_->Data()),
+        frame_data_->ByteLengthAsSizeT()));
+  }
+  return std::move(delegate_);
 }
 
 void RTCEncodedVideoFrame::Trace(Visitor* visitor) {
diff --git a/third_party/blink/renderer/modules/peerconnection/rtc_encoded_video_frame.h b/third_party/blink/renderer/modules/peerconnection/rtc_encoded_video_frame.h
index 5e13b07e9c14..67024c262e6e 100644
--- a/third_party/blink/renderer/modules/peerconnection/rtc_encoded_video_frame.h
+++ b/third_party/blink/renderer/modules/peerconnection/rtc_encoded_video_frame.h
@@ -20,16 +20,13 @@ class TransformableVideoFrameInterface;
 namespace blink {
 
 class DOMArrayBuffer;
-class RTCEncodedVideoFrameDelegate;
 
 class MODULES_EXPORT RTCEncodedVideoFrame final : public ScriptWrappable {
   DEFINE_WRAPPERTYPEINFO();
 
  public:
   explicit RTCEncodedVideoFrame(
-      std::unique_ptr<webrtc::TransformableVideoFrameInterface> webrtc_frame);
-  explicit RTCEncodedVideoFrame(
-      scoped_refptr<RTCEncodedVideoFrameDelegate> delegate);
+      std::unique_ptr<webrtc::TransformableVideoFrameInterface> delegate);
 
   // rtc_encoded_video_frame.idl implementation.
   String type() const;
@@ -41,19 +38,17 @@ class MODULES_EXPORT RTCEncodedVideoFrame final : public ScriptWrappable {
   uint32_t synchronizationSource() const;
   String toString() const;
 
-  scoped_refptr<RTCEncodedVideoFrameDelegate> Delegate() const;
-  void SyncDelegate() const;
-
+  // Internal API
+  bool HasDelegate() { return !!delegate_; }
   // Returns and transfers ownership of the internal WebRTC frame
-  // backing this RTCEncodedVideoFrame, neutering all RTCEncodedVideoFrames
-  // backed by that internal WebRTC frame.
-  std::unique_ptr<webrtc::TransformableVideoFrameInterface> PassWebRtcFrame();
+  // backing this RTCEncodedVideoFrame, leaving the RTCEncodedVideoFrame
+  // without a delegate WebRTC frame.
+  std::unique_ptr<webrtc::TransformableVideoFrameInterface> PassDelegate();
 
   void Trace(Visitor*) override;
 
  private:
-  const scoped_refptr<RTCEncodedVideoFrameDelegate> delegate_;
-
+  std::unique_ptr<webrtc::TransformableVideoFrameInterface> delegate_;
   // Exposes encoded frame data from |delegate_|.
   mutable Member<DOMArrayBuffer> frame_data_;
   // Exposes additional data from |delegate_|.
diff --git a/third_party/blink/renderer/modules/peerconnection/rtc_encoded_video_frame_delegate.cc b/third_party/blink/renderer/modules/peerconnection/rtc_encoded_video_frame_delegate.cc
deleted file mode 100644
index 6d2de5b2b773..000000000000
--- a/third_party/blink/renderer/modules/peerconnection/rtc_encoded_video_frame_delegate.cc
+++ /dev/null
@@ -1,89 +0,0 @@
-// Copyright 2020 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "third_party/blink/renderer/modules/peerconnection/rtc_encoded_video_frame_delegate.h"
-
-#include <utility>
-
-#include "third_party/blink/renderer/core/typed_arrays/dom_array_buffer.h"
-#include "third_party/webrtc/api/frame_transformer_interface.h"
-
-namespace blink {
-
-const void* const RTCEncodedVideoFramesAttachment::kAttachmentKey = nullptr;
-
-RTCEncodedVideoFrameDelegate::RTCEncodedVideoFrameDelegate(
-    std::unique_ptr<webrtc::TransformableVideoFrameInterface> webrtc_frame)
-    : webrtc_frame_(std::move(webrtc_frame)) {}
-
-String RTCEncodedVideoFrameDelegate::Type() const {
-  MutexLocker lock(mutex_);
-  if (!webrtc_frame_)
-    return "empty";
-
-  return webrtc_frame_->IsKeyFrame() ? "key" : "delta";
-}
-
-uint64_t RTCEncodedVideoFrameDelegate::Timestamp() const {
-  MutexLocker lock(mutex_);
-  return webrtc_frame_ ? webrtc_frame_->GetTimestamp() : 0;
-}
-
-DOMArrayBuffer* RTCEncodedVideoFrameDelegate::CreateDataBuffer() const {
-  ArrayBufferContents contents;
-  {
-    MutexLocker lock(mutex_);
-    if (!webrtc_frame_)
-      return nullptr;
-
-    auto data = webrtc_frame_->GetData();
-    contents =
-        ArrayBufferContents(data.size(), 1, ArrayBufferContents::kNotShared,
-                            ArrayBufferContents::kDontInitialize);
-    if (UNLIKELY(!contents.Data()))
-      OOM_CRASH(data.size());
-    memcpy(contents.Data(), data.data(), data.size());
-  }
-  return DOMArrayBuffer::Create(std::move(contents));
-}
-
-void RTCEncodedVideoFrameDelegate::SetData(const DOMArrayBuffer* data) {
-  MutexLocker lock(mutex_);
-  if (webrtc_frame_ && data) {
-    webrtc_frame_->SetData(rtc::ArrayView<const uint8_t>(
-        static_cast<const uint8_t*>(data->Data()), data->ByteLengthAsSizeT()));
-  }
-}
-
-DOMArrayBuffer* RTCEncodedVideoFrameDelegate::CreateAdditionalDataBuffer()
-    const {
-  ArrayBufferContents contents;
-  {
-    MutexLocker lock(mutex_);
-    if (!webrtc_frame_)
-      return nullptr;
-
-    auto additional_data = webrtc_frame_->GetAdditionalData();
-    contents = ArrayBufferContents(additional_data.size(), 1,
-                                   ArrayBufferContents::kNotShared,
-                                   ArrayBufferContents::kDontInitialize);
-    if (UNLIKELY(!contents.Data()))
-      OOM_CRASH(additional_data.size());
-    memcpy(contents.Data(), additional_data.data(), additional_data.size());
-  }
-  return DOMArrayBuffer::Create(std::move(contents));
-}
-
-uint32_t RTCEncodedVideoFrameDelegate::Ssrc() const {
-  MutexLocker lock(mutex_);
-  return webrtc_frame_ ? webrtc_frame_->GetSsrc() : 0;
-}
-
-std::unique_ptr<webrtc::TransformableVideoFrameInterface>
-RTCEncodedVideoFrameDelegate::PassWebRtcFrame() {
-  MutexLocker lock(mutex_);
-  return std::move(webrtc_frame_);
-}
-
-}  // namespace blink
diff --git a/third_party/blink/renderer/modules/peerconnection/rtc_encoded_video_frame_delegate.h b/third_party/blink/renderer/modules/peerconnection/rtc_encoded_video_frame_delegate.h
deleted file mode 100644
index 5bc300b6e82c..000000000000
--- a/third_party/blink/renderer/modules/peerconnection/rtc_encoded_video_frame_delegate.h
+++ /dev/null
@@ -1,72 +0,0 @@
-// Copyright 2020 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_PEERCONNECTION_RTC_ENCODED_VIDEO_FRAME_DELEGATE_H_
-#define THIRD_PARTY_BLINK_RENDERER_MODULES_PEERCONNECTION_RTC_ENCODED_VIDEO_FRAME_DELEGATE_H_
-
-#include <stdint.h>
-
-#include <memory>
-
-#include "third_party/blink/renderer/bindings/core/v8/serialization/serialized_script_value.h"
-#include "third_party/blink/renderer/modules/modules_export.h"
-#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
-#include "third_party/blink/renderer/platform/wtf/thread_safe_ref_counted.h"
-#include "third_party/blink/renderer/platform/wtf/threading_primitives.h"
-#include "third_party/webrtc/api/frame_transformer_interface.h"
-
-namespace blink {
-
-class DOMArrayBuffer;
-
-// This class wraps a WebRTC video frame and allows making shallow
-// copies. Its purpose is to support making RTCEncodedVideoFrames
-// serializable in the same process.
-class RTCEncodedVideoFrameDelegate
-    : public WTF::ThreadSafeRefCounted<RTCEncodedVideoFrameDelegate> {
- public:
-  explicit RTCEncodedVideoFrameDelegate(
-      std::unique_ptr<webrtc::TransformableVideoFrameInterface> webrtc_frame);
-
-  String Type() const;
-  uint64_t Timestamp() const;
-  DOMArrayBuffer* CreateDataBuffer() const;
-  void SetData(const DOMArrayBuffer* data);
-  DOMArrayBuffer* CreateAdditionalDataBuffer() const;
-  uint32_t Ssrc() const;
-  std::unique_ptr<webrtc::TransformableVideoFrameInterface> PassWebRtcFrame();
-
- private:
-  mutable Mutex mutex_;
-  std::unique_ptr<webrtc::TransformableVideoFrameInterface> webrtc_frame_
-      GUARDED_BY(mutex_);
-};
-
-class MODULES_EXPORT RTCEncodedVideoFramesAttachment
-    : public SerializedScriptValue::Attachment {
- public:
-  static const void* const kAttachmentKey;
-  RTCEncodedVideoFramesAttachment() = default;
-  ~RTCEncodedVideoFramesAttachment() override = default;
-
-  bool IsLockedToAgentCluster() const override {
-    return !encoded_video_frames_.IsEmpty();
-  }
-
-  Vector<scoped_refptr<RTCEncodedVideoFrameDelegate>>& EncodedVideoFrames() {
-    return encoded_video_frames_;
-  }
-
-  const Vector<scoped_refptr<RTCEncodedVideoFrameDelegate>>&
-  EncodedVideoFrames() const {
-    return encoded_video_frames_;
-  }
-
- private:
-  Vector<scoped_refptr<RTCEncodedVideoFrameDelegate>> encoded_video_frames_;
-};
-
-}  // namespace blink
-
-#endif  // THIRD_PARTY_BLINK_RENDERER_MODULES_PEERCONNECTION_RTC_ENCODED_VIDEO_FRAME_DELEGATE_H_
diff --git a/third_party/blink/renderer/modules/peerconnection/rtc_encoded_video_underlying_sink.cc b/third_party/blink/renderer/modules/peerconnection/rtc_encoded_video_underlying_sink.cc
index 4585483a1cb2..3762b10e6bc5 100644
--- a/third_party/blink/renderer/modules/peerconnection/rtc_encoded_video_underlying_sink.cc
+++ b/third_party/blink/renderer/modules/peerconnection/rtc_encoded_video_underlying_sink.cc
@@ -48,8 +48,7 @@ ScriptPromise RTCEncodedVideoUnderlyingSink::write(
     return ScriptPromise();
   }
 
-  transformer_callback_.Run()->SendFrameToSink(
-      encoded_frame->PassWebRtcFrame());
+  transformer_callback_.Run()->SendFrameToSink(encoded_frame->PassDelegate());
   return ScriptPromise::CastUndefined(script_state);
 }
 
diff --git a/third_party/blink/renderer/modules/peerconnection/rtc_encoded_video_underlying_sink_test.cc b/third_party/blink/renderer/modules/peerconnection/rtc_encoded_video_underlying_sink_test.cc
index ea8a67a9cc5f..3d0dfbdbbe3e 100644
--- a/third_party/blink/renderer/modules/peerconnection/rtc_encoded_video_underlying_sink_test.cc
+++ b/third_party/blink/renderer/modules/peerconnection/rtc_encoded_video_underlying_sink_test.cc
@@ -68,7 +68,7 @@ class RTCEncodedVideoUnderlyingSinkTest : public testing::Test {
 
   ScriptValue CreateEncodedVideoFrameChunk(ScriptState* script_state) {
     RTCEncodedVideoFrame* frame = MakeGarbageCollected<RTCEncodedVideoFrame>(
-        std::unique_ptr<webrtc::TransformableVideoFrameInterface>());
+        /*frame_delegate=*/nullptr);
     return ScriptValue(script_state->GetIsolate(),
                        ToV8(frame, script_state->GetContext()->Global(),
                             script_state->GetIsolate()));
-- 
2.26.1