Commit 12fbc5fe authored by Sergey Ulanov's avatar Sergey Ulanov Committed by Commit Bot

Use VideoFrame::unique_id() to detect when frame is copied

Previously WebMediaPlayerMS::FrameDeliverer was keeping pointers to the
original frames passed to GpuMemoryBufferVideoFramePool in order to detect
when the original frame is returned back. This change updates it to use
VideoFrame::unique_id(), which allows to avoid adding ref count for the
frame.

Change-Id: I5186d9709debecaccc768f485de3233dde906b18
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2333568
Auto-Submit: Sergey Ulanov <sergeyu@chromium.org>
Reviewed-by: default avatarDale Curtis <dalecurtis@chromium.org>
Reviewed-by: default avatarGuido Urdaneta <guidou@chromium.org>
Commit-Queue: Guido Urdaneta <guidou@chromium.org>
Cr-Commit-Position: refs/heads/master@{#794206}
parent 552fff33
......@@ -182,7 +182,8 @@ class WebMediaPlayerMS::FrameDeliverer {
#endif // defined(OS_ANDROID)
if (!gpu_memory_buffer_pool_) {
EnqueueFrame(frame, frame);
int original_frame_id = frame->unique_id();
EnqueueFrame(original_frame_id, std::move(frame));
return;
}
......@@ -201,7 +202,8 @@ class WebMediaPlayerMS::FrameDeliverer {
// frames is unnecessary, because the frames are not going to be shown for
// the time period.
if (render_frame_suspended_ || skip_creating_gpu_memory_buffer) {
EnqueueFrame(frame, frame);
int original_frame_id = frame->unique_id();
EnqueueFrame(original_frame_id, std::move(frame));
// If there are any existing MaybeCreateHardwareFrame() calls, we do not
// want those frames to be placed after the current one, so just drop
// them.
......@@ -209,6 +211,8 @@ class WebMediaPlayerMS::FrameDeliverer {
return;
}
int original_frame_id = frame->unique_id();
// |gpu_memory_buffer_pool_| deletion is going to be posted to
// |media_task_runner_|. base::Unretained() usage is fine since
// |gpu_memory_buffer_pool_| outlives the task.
......@@ -219,10 +223,10 @@ class WebMediaPlayerMS::FrameDeliverer {
FROM_HERE,
base::BindOnce(
&media::GpuMemoryBufferVideoFramePool::MaybeCreateHardwareFrame,
base::Unretained(gpu_memory_buffer_pool_.get()), frame,
media::BindToCurrentLoop(
base::BindOnce(&FrameDeliverer::EnqueueFrame,
weak_factory_for_pool_.GetWeakPtr(), frame))));
base::Unretained(gpu_memory_buffer_pool_.get()), std::move(frame),
media::BindToCurrentLoop(base::BindOnce(
&FrameDeliverer::EnqueueFrame,
weak_factory_for_pool_.GetWeakPtr(), original_frame_id))));
}
void SetRenderFrameSuspended(bool render_frame_suspended) {
......@@ -240,7 +244,7 @@ class WebMediaPlayerMS::FrameDeliverer {
private:
friend class WebMediaPlayerMS;
void EnqueueFrame(scoped_refptr<media::VideoFrame> original_frame,
void EnqueueFrame(int original_frame_id,
scoped_refptr<media::VideoFrame> frame) {
DCHECK_CALLED_ON_VALID_THREAD(io_thread_checker_);
......@@ -257,7 +261,7 @@ class WebMediaPlayerMS::FrameDeliverer {
}
}
bool is_copy = original_frame != frame;
bool is_copy = original_frame_id != frame->unique_id();
enqueue_frame_cb_.Run(std::move(frame), is_copy);
}
......
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