Commit 7eb8a075 authored by Hirokazu Honda's avatar Hirokazu Honda Committed by Commit Bot

GpuArcVideoEncodeAccelerator: Remove VideoFrameDoneNotifier

VideoFrameDoneNotifier is unnecessary. It is the helper class to execute a given
callback in the destructor. That totally can be done with
VideoFrame::AddDestructionObserver. This just removes VideoFrameDoneNotifier.

BUG=None
TEST=CtsMediaTestCases

Change-Id: I30222876159565f2b639d92650d4ab3fa6de385b
Reviewed-on: https://chromium-review.googlesource.com/c/1331103
Commit-Queue: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: default avatarPawel Osciak <posciak@chromium.org>
Cr-Commit-Position: refs/heads/master@{#607182}
parent e3ab8c9e
...@@ -21,16 +21,9 @@ namespace arc { ...@@ -21,16 +21,9 @@ namespace arc {
namespace { namespace {
// Helper class to notify client about the end of processing a video frame. void DropSharedMemory(std::unique_ptr<base::SharedMemory> shm) {
class VideoFrameDoneNotifier { // Just let |shm| fall out of scope.
public: }
explicit VideoFrameDoneNotifier(base::OnceClosure notify_closure)
: notify_closure_(std::move(notify_closure)) {}
~VideoFrameDoneNotifier() { std::move(notify_closure_).Run(); }
private:
base::OnceClosure notify_closure_;
};
} // namespace } // namespace
...@@ -99,12 +92,6 @@ void GpuArcVideoEncodeAccelerator::Initialize( ...@@ -99,12 +92,6 @@ void GpuArcVideoEncodeAccelerator::Initialize(
std::move(callback).Run(true); std::move(callback).Run(true);
} }
static void DropShareMemoryAndVideoFrameDoneNotifier(
std::unique_ptr<base::SharedMemory> shm,
std::unique_ptr<VideoFrameDoneNotifier> notifier) {
// Just let |shm| and |notifier| fall out of scope.
}
void GpuArcVideoEncodeAccelerator::Encode( void GpuArcVideoEncodeAccelerator::Encode(
mojo::ScopedHandle handle, mojo::ScopedHandle handle,
std::vector<::arc::VideoFramePlane> planes, std::vector<::arc::VideoFramePlane> planes,
...@@ -117,8 +104,6 @@ void GpuArcVideoEncodeAccelerator::Encode( ...@@ -117,8 +104,6 @@ void GpuArcVideoEncodeAccelerator::Encode(
return; return;
} }
auto notifier = std::make_unique<VideoFrameDoneNotifier>(std::move(callback));
if (planes.empty()) { // EOS if (planes.empty()) { // EOS
accelerator_->Encode(media::VideoFrame::CreateEOSFrame(), force_keyframe); accelerator_->Encode(media::VideoFrame::CreateEOSFrame(), force_keyframe);
return; return;
...@@ -167,14 +152,12 @@ void GpuArcVideoEncodeAccelerator::Encode( ...@@ -167,14 +152,12 @@ void GpuArcVideoEncodeAccelerator::Encode(
shm_memory + aligned_offset, allocation_size, shm_handle, shm_memory + aligned_offset, allocation_size, shm_handle,
planes[0].offset, base::TimeDelta::FromMicroseconds(timestamp)); planes[0].offset, base::TimeDelta::FromMicroseconds(timestamp));
// Wrap |shm| and |notifier| in a callback and add it as a destruction // Add the function to relase |shm| and |callback| to |frame|'s destruction
// observer. When the |frame| goes out of scope, it unmaps and releases // observer. When the |frame| goes out of scope, it unmaps and releases the
// the shared memory as well as notifies |client_| about the end of processing // shared memory as well as executes |callback|.
// the |frame|.
frame->AddDestructionObserver( frame->AddDestructionObserver(
base::BindOnce(&DropShareMemoryAndVideoFrameDoneNotifier, std::move(shm), base::BindOnce(&DropSharedMemory, std::move(shm)));
std::move(notifier))); frame->AddDestructionObserver(std::move(callback));
accelerator_->Encode(frame, force_keyframe); accelerator_->Encode(frame, force_keyframe);
} }
......
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