Commit 536a6d39 authored by Guido Urdaneta's avatar Guido Urdaneta Committed by Commit Bot

[RTCInsertableStreams] Use WTF::Vector instead of std::vector in RTCEncodedVideoFrame

Switch the additional_data_vector_ field to WTF::Vector for better
compliance with Blink practices.
While this implies a copy of the data, this vector is normally small
and we plan to change it to a structured format in the near future.

Bug: 1059912
Change-Id: I0fdeb5fefd4aac9c85712bf246866e5826b5f2c0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2094311
Commit-Queue: Guido Urdaneta <guidou@chromium.org>
Reviewed-by: default avatarMarina Ciocea <marinaciocea@chromium.org>
Cr-Commit-Position: refs/heads/master@{#749254}
parent fbad3a79
......@@ -13,7 +13,7 @@ namespace blink {
RTCEncodedVideoFrame::RTCEncodedVideoFrame(
std::unique_ptr<webrtc::video_coding::EncodedFrame> delegate,
std::vector<uint8_t> additional_data)
Vector<uint8_t> additional_data)
: delegate_(std::move(delegate)),
additional_data_vector_(std::move(additional_data)) {}
......
......@@ -8,11 +8,11 @@
#include <stdint.h>
#include <memory>
#include <vector>
#include "third_party/blink/renderer/modules/modules_export.h"
#include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"
namespace webrtc {
namespace video_coding {
......@@ -30,7 +30,7 @@ class MODULES_EXPORT RTCEncodedVideoFrame final : public ScriptWrappable {
public:
explicit RTCEncodedVideoFrame(
std::unique_ptr<webrtc::video_coding::EncodedFrame> delegate,
std::vector<uint8_t> generic_descriptor);
Vector<uint8_t> generic_descriptor);
// rtc_encoded_video_frame.idl implementation.
String type() const;
......@@ -51,7 +51,7 @@ class MODULES_EXPORT RTCEncodedVideoFrame final : public ScriptWrappable {
private:
std::unique_ptr<webrtc::video_coding::EncodedFrame> delegate_;
std::vector<uint8_t> additional_data_vector_;
Vector<uint8_t> additional_data_vector_;
// Exposes encoded frame data from |delegate_|.
mutable Member<DOMArrayBuffer> frame_data_;
// Exposes data from |additional_data_vector_|.
......
......@@ -17,6 +17,7 @@
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/peerconnection/rtc_encoded_video_stream_transformer.h"
#include "third_party/blink/renderer/platform/testing/testing_platform_support.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"
#include "third_party/webrtc/api/frame_transformer_interface.h"
#include "third_party/webrtc/api/scoped_refptr.h"
#include "third_party/webrtc/rtc_base/ref_counted_object.h"
......@@ -68,7 +69,7 @@ class RTCEncodedVideoUnderlyingSinkTest : public testing::Test {
ScriptValue CreateEncodedVideoFrameChunk(ScriptState* script_state) {
RTCEncodedVideoFrame* frame = MakeGarbageCollected<RTCEncodedVideoFrame>(
/*frame_delegate=*/nullptr, std::vector<uint8_t>());
/*frame_delegate=*/nullptr, Vector<uint8_t>());
return ScriptValue(script_state->GetIsolate(),
ToV8(frame, script_state->GetContext()->Global(),
script_state->GetIsolate()));
......
......@@ -4,13 +4,14 @@
#include "third_party/blink/renderer/modules/peerconnection/rtc_encoded_video_underlying_source.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_throw_dom_exception.h"
#include "third_party/blink/renderer/core/streams/readable_stream_default_controller_with_script_scope.h"
#include "third_party/blink/renderer/modules/peerconnection/rtc_encoded_video_frame.h"
#include "third_party/webrtc/api/video/encoded_frame.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_throw_dom_exception.h"
#include "third_party/blink/renderer/platform/bindings/exception_code.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"
#include "third_party/webrtc/api/video/encoded_frame.h"
namespace blink {
// Frames should not be queued at all. We allow queuing a few frames to deal
......@@ -58,9 +59,15 @@ void RTCEncodedVideoUnderlyingSource::OnFrameFromSource(
return;
}
Vector<uint8_t> wtf_additional_data;
wtf_additional_data.ReserveInitialCapacity(
static_cast<wtf_size_t>(additional_data.size()));
wtf_additional_data.AppendRange(additional_data.begin(),
additional_data.end());
RTCEncodedVideoFrame* encoded_frame =
MakeGarbageCollected<RTCEncodedVideoFrame>(std::move(webrtc_frame),
std::move(additional_data));
MakeGarbageCollected<RTCEncodedVideoFrame>(
std::move(webrtc_frame), std::move(wtf_additional_data));
Controller()->Enqueue(encoded_frame);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment