Commit be8f1163 authored by Miyoung Shin's avatar Miyoung Shin Committed by Commit Bot

Replace base::queue with WTF::Deque in mediarecorder

This is a part of moving media recorder implementation to blink.
This CL replaces base::queue with WTF::Deque in mediarecorder.

Bug: 960665
Change-Id: If3b1a795b5e21cfd54b83c46481bf6591efaa74a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1669255Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarGuido Urdaneta <guidou@chromium.org>
Commit-Queue: Miyoung Shin <myid.shin@igalia.com>
Cr-Commit-Position: refs/heads/master@{#671211}
parent d135c39d
include_rules = [
"+base/containers/queue.h",
"+base/strings/string_piece.h",
"+base/task_runner_util.h",
"+base/threading/thread_task_runner_handle.h",
......
......@@ -107,7 +107,7 @@ void VEAEncoder::RequireBitstreamBuffers(unsigned int /*input_count*/,
vea_requested_input_coded_size_ = input_coded_size;
output_buffers_.clear();
base::queue<std::unique_ptr<base::SharedMemory>>().swap(input_buffers_);
Deque<std::unique_ptr<base::SharedMemory>>().Swap(input_buffers_);
for (int i = 0; i < kVEAEncoderOutputBufferCount; ++i) {
std::unique_ptr<base::SharedMemory> shm =
......@@ -139,9 +139,7 @@ void VEAEncoder::BitstreamBufferReady(
data->append(static_cast<char*>(output_buffer->memory()),
metadata.payload_size_bytes);
const auto front_frame = frames_in_encode_.front();
frames_in_encode_.pop();
const auto front_frame = frames_in_encode_.TakeFirst();
PostCrossThreadTask(
*origin_task_runner_.get(), FROM_HERE,
CrossThreadBindOnce(
......@@ -175,7 +173,7 @@ void VEAEncoder::UseOutputBitstreamBufferId(int32_t bitstream_buffer_id) {
void VEAEncoder::FrameFinished(std::unique_ptr<base::SharedMemory> shm) {
DVLOG(3) << __func__;
DCHECK(encoding_task_runner_->BelongsToCurrentThread());
input_buffers_.push(std::move(shm));
input_buffers_.push_back(std::move(shm));
}
void VEAEncoder::EncodeOnEncodingTaskRunner(scoped_refptr<VideoFrame> frame,
......@@ -228,8 +226,7 @@ void VEAEncoder::EncodeOnEncodingTaskRunner(scoped_refptr<VideoFrame> frame,
input_buffer = gpu_factories_->CreateSharedMemory(desired_mapped_size);
} else {
do {
input_buffer = std::move(input_buffers_.front());
input_buffers_.pop();
input_buffer = input_buffers_.TakeFirst();
} while (!input_buffers_.empty() &&
input_buffer->mapped_size() < desired_mapped_size);
if (!input_buffer || input_buffer->mapped_size() < desired_mapped_size)
......@@ -263,7 +260,7 @@ void VEAEncoder::EncodeOnEncodingTaskRunner(scoped_refptr<VideoFrame> frame,
video_frame->stride(media::VideoFrame::kVPlane),
input_visible_size_.width(), input_visible_size_.height());
}
frames_in_encode_.push(std::make_pair(
frames_in_encode_.push_back(std::make_pair(
media::WebmMuxer::VideoParameters(frame), capture_timestamp));
video_encoder_->Encode(video_frame, force_next_frame_to_be_keyframe_);
......
......@@ -5,10 +5,10 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_MEDIARECORDER_VEA_ENCODER_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_MEDIARECORDER_VEA_ENCODER_H_
#include "base/containers/queue.h"
#include "base/single_thread_task_runner.h"
#include "media/video/video_encode_accelerator.h"
#include "third_party/blink/renderer/modules/mediarecorder/video_track_recorder.h"
#include "third_party/blink/renderer/platform/wtf/deque.h"
#include "third_party/blink/renderer/platform/wtf/time.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"
#include "ui/gfx/geometry/size.h"
......@@ -83,8 +83,7 @@ class VEAEncoder final : public VideoTrackRecorder::Encoder,
Vector<std::unique_ptr<base::SharedMemory>> output_buffers_;
// Shared memory buffers for output with the VEA as FIFO.
// TODO(crbug.com/960665): Replace with a WTF equivalent.
base::queue<std::unique_ptr<base::SharedMemory>> input_buffers_;
Deque<std::unique_ptr<base::SharedMemory>> input_buffers_;
// Tracks error status.
bool error_notified_;
......@@ -99,8 +98,7 @@ class VEAEncoder final : public VideoTrackRecorder::Encoder,
gfx::Size vea_requested_input_coded_size_;
// Frames and corresponding timestamps in encode as FIFO.
// TODO(crbug.com/960665): Replace with a WTF equivalent.
base::queue<VideoParamsAndTimestamp> frames_in_encode_;
Deque<VideoParamsAndTimestamp> frames_in_encode_;
// Number of encoded frames produced consecutively without a keyframe.
uint32_t num_frames_after_keyframe_;
......
......@@ -604,9 +604,6 @@ _CONFIG = [
],
'allowed': [
'base::data',
# TODO(crbug.com/960665): Remove it once it is replaced with a WTF equivalent.
'base::queue',
'base::SharedMemory',
'base::StringPiece',
'base::ThreadTaskRunnerHandle',
......
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