Commit a20ddd18 authored by Antonio Gomes's avatar Antonio Gomes Committed by Commit Bot

Switch away from std::vector in rtc_video_encoder.cc

... where ever possible.

Note that some instances of std::vector still remain, because
they are from method signatures' that override //third_party/webrtc
APIs, or call out to //media APIs.

BUG=787254
R=guidou@chromium.org

Change-Id: I358bf8b23109612e3e3f604029c4ad83b06c0297
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1775873Reviewed-by: default avatarGuido Urdaneta <guidou@chromium.org>
Commit-Queue: Antonio Gomes <tonikitoo@igalia.com>
Cr-Commit-Position: refs/heads/master@{#691750}
parent 207efe48
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include "base/synchronization/waitable_event.h" #include "base/synchronization/waitable_event.h"
#include "base/threading/thread_checker.h" #include "base/threading/thread_checker.h"
#include "base/threading/thread_restrictions.h" #include "base/threading/thread_restrictions.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "media/base/bind_to_current_loop.h" #include "media/base/bind_to_current_loop.h"
#include "media/base/bitstream_buffer.h" #include "media/base/bitstream_buffer.h"
...@@ -36,6 +35,7 @@ ...@@ -36,6 +35,7 @@
#include "third_party/blink/renderer/platform/wtf/cross_thread_functional.h" #include "third_party/blink/renderer/platform/wtf/cross_thread_functional.h"
#include "third_party/blink/renderer/platform/wtf/deque.h" #include "third_party/blink/renderer/platform/wtf/deque.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"
#include "third_party/libyuv/include/libyuv.h" #include "third_party/libyuv/include/libyuv.h"
#include "third_party/webrtc/modules/video_coding/codecs/h264/include/h264.h" #include "third_party/webrtc/modules/video_coding/codecs/h264/include/h264.h"
#include "third_party/webrtc/modules/video_coding/include/video_error_codes.h" #include "third_party/webrtc/modules/video_coding/include/video_error_codes.h"
...@@ -275,19 +275,16 @@ class RTCVideoEncoder::Impl ...@@ -275,19 +275,16 @@ class RTCVideoEncoder::Impl
// Shared memory buffers for input/output with the VEA. The input buffers may // Shared memory buffers for input/output with the VEA. The input buffers may
// be referred to by a VideoFrame, so they are wrapped in a unique_ptr to have // be referred to by a VideoFrame, so they are wrapped in a unique_ptr to have
// a stable memory location. That is not necessary for the output buffers. // a stable memory location. That is not necessary for the output buffers.
// Vector<std::unique_ptr<std::pair<base::UnsafeSharedMemoryRegion,
// TODO(crbug.com/787254): Replace the use of std::vector by WTF::Vector here base::WritableSharedMemoryMapping>>>
// and where else possible in this file.
std::vector<std::unique_ptr<std::pair<base::UnsafeSharedMemoryRegion,
base::WritableSharedMemoryMapping>>>
input_buffers_; input_buffers_;
std::vector<std::pair<base::UnsafeSharedMemoryRegion, Vector<std::pair<base::UnsafeSharedMemoryRegion,
base::WritableSharedMemoryMapping>> base::WritableSharedMemoryMapping>>
output_buffers_; output_buffers_;
// Input buffers ready to be filled with input from Encode(). As a LIFO since // Input buffers ready to be filled with input from Encode(). As a LIFO since
// we don't care about ordering. // we don't care about ordering.
std::vector<int> input_buffers_free_; Vector<int> input_buffers_free_;
// The number of output buffers ready to be filled with output from the // The number of output buffers ready to be filled with output from the
// encoder. // encoder.
...@@ -403,7 +400,7 @@ void RTCVideoEncoder::Impl::Enqueue(const webrtc::VideoFrame* input_frame, ...@@ -403,7 +400,7 @@ void RTCVideoEncoder::Impl::Enqueue(const webrtc::VideoFrame* input_frame,
// buffers. Returning an error in Encode() is not fatal and WebRTC will just // buffers. Returning an error in Encode() is not fatal and WebRTC will just
// continue. If this is a key frame, WebRTC will request a key frame again. // continue. If this is a key frame, WebRTC will request a key frame again.
// Besides, webrtc will drop a frame if Encode() blocks too long. // Besides, webrtc will drop a frame if Encode() blocks too long.
if (input_buffers_free_.empty() && output_buffers_free_count_ == 0) { if (input_buffers_free_.IsEmpty() && output_buffers_free_count_ == 0) {
DVLOG(2) << "Run out of input and output buffers. Drop the frame."; DVLOG(2) << "Run out of input and output buffers. Drop the frame.";
SignalAsyncWaiter(WEBRTC_VIDEO_CODEC_ERROR); SignalAsyncWaiter(WEBRTC_VIDEO_CODEC_ERROR);
return; return;
...@@ -411,7 +408,7 @@ void RTCVideoEncoder::Impl::Enqueue(const webrtc::VideoFrame* input_frame, ...@@ -411,7 +408,7 @@ void RTCVideoEncoder::Impl::Enqueue(const webrtc::VideoFrame* input_frame,
input_next_frame_ = input_frame; input_next_frame_ = input_frame;
input_next_frame_keyframe_ = force_keyframe; input_next_frame_keyframe_ = force_keyframe;
if (!input_buffers_free_.empty()) if (!input_buffers_free_.IsEmpty())
EncodeOneFrame(); EncodeOneFrame();
} }
...@@ -586,7 +583,7 @@ void RTCVideoEncoder::Impl::BitstreamBufferReady( ...@@ -586,7 +583,7 @@ void RTCVideoEncoder::Impl::BitstreamBufferReady(
base::Optional<int64_t> capture_timestamp_ms; base::Optional<int64_t> capture_timestamp_ms;
if (!failed_timestamp_match_) { if (!failed_timestamp_match_) {
// Pop timestamps until we have a match. // Pop timestamps until we have a match.
while (!pending_timestamps_.empty()) { while (!pending_timestamps_.IsEmpty()) {
const auto& front_timestamps = pending_timestamps_.front(); const auto& front_timestamps = pending_timestamps_.front();
if (front_timestamps.media_timestamp_ == metadata.timestamp) { if (front_timestamps.media_timestamp_ == metadata.timestamp) {
rtp_timestamp = front_timestamps.rtp_timestamp; rtp_timestamp = front_timestamps.rtp_timestamp;
...@@ -672,7 +669,7 @@ void RTCVideoEncoder::Impl::EncodeOneFrame() { ...@@ -672,7 +669,7 @@ void RTCVideoEncoder::Impl::EncodeOneFrame() {
DVLOG(3) << "Impl::EncodeOneFrame()"; DVLOG(3) << "Impl::EncodeOneFrame()";
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DCHECK(input_next_frame_); DCHECK(input_next_frame_);
DCHECK(!input_buffers_free_.empty()); DCHECK(!input_buffers_free_.IsEmpty());
// EncodeOneFrame() may re-enter EncodeFrameFinished() if VEA::Encode() fails, // EncodeOneFrame() may re-enter EncodeFrameFinished() if VEA::Encode() fails,
// we receive a VEA::NotifyError(), and the media::VideoFrame we pass to // we receive a VEA::NotifyError(), and the media::VideoFrame we pass to
......
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