Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(552)

Unified Diff: media/mojo/clients/mojo_video_decoder.cc

Issue 2640153004: Add mailbox-based Mojo VideoFrame variant. (Closed)
Patch Set: Rebase. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/mojo/clients/mojo_video_decoder.h ('k') | media/mojo/common/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/mojo/clients/mojo_video_decoder.cc
diff --git a/media/mojo/clients/mojo_video_decoder.cc b/media/mojo/clients/mojo_video_decoder.cc
index 04e8439ac84dfe1a9158de0e835171bdee057aaa..89607a6a07d45b4eb60d0ae0daa6887e3b6c84a6 100644
--- a/media/mojo/clients/mojo_video_decoder.cc
+++ b/media/mojo/clients/mojo_video_decoder.cc
@@ -11,6 +11,7 @@
#include "base/logging.h"
#include "base/single_thread_task_runner.h"
#include "base/unguessable_token.h"
+#include "media/base/bind_to_current_loop.h"
#include "media/base/decoder_buffer.h"
#include "media/base/demuxer_stream.h"
#include "media/base/video_frame.h"
@@ -28,7 +29,8 @@ MojoVideoDecoder::MojoVideoDecoder(
: task_runner_(task_runner),
remote_decoder_info_(remote_decoder.PassInterface()),
gpu_factories_(gpu_factories),
- client_binding_(this) {
+ client_binding_(this),
+ weak_factory_(this) {
DVLOG(1) << __func__;
}
@@ -51,6 +53,9 @@ void MojoVideoDecoder::Initialize(const VideoDecoderConfig& config,
DCHECK(task_runner_->BelongsToCurrentThread());
DCHECK(!cdm_context);
+ if (!weak_this_)
+ weak_this_ = weak_factory_.GetWeakPtr();
+
if (!remote_decoder_bound_)
BindRemoteDecoder();
@@ -104,10 +109,26 @@ void MojoVideoDecoder::Decode(const scoped_refptr<DecoderBuffer>& buffer,
base::Unretained(this), decode_id));
}
-void MojoVideoDecoder::OnVideoFrameDecoded(mojom::VideoFramePtr frame) {
+void MojoVideoDecoder::OnVideoFrameDecoded(
+ mojom::VideoFramePtr frame,
+ const base::Optional<base::UnguessableToken>& release_token) {
DVLOG(2) << __func__;
DCHECK(task_runner_->BelongsToCurrentThread());
- output_cb_.Run(frame.To<scoped_refptr<VideoFrame>>());
+
+ scoped_refptr<VideoFrame> video_frame = frame.To<scoped_refptr<VideoFrame>>();
+ if (release_token) {
+ video_frame->SetReleaseMailboxCB(
+ BindToCurrentLoop(base::Bind(&MojoVideoDecoder::OnReleaseMailbox,
+ weak_this_, release_token.value())));
+ }
+ output_cb_.Run(std::move(video_frame));
+}
+
+void MojoVideoDecoder::OnReleaseMailbox(
+ const base::UnguessableToken& release_token,
+ const gpu::SyncToken& release_sync_token) {
+ DCHECK(task_runner_->BelongsToCurrentThread());
+ remote_decoder_->OnReleaseMailbox(release_token, release_sync_token);
}
void MojoVideoDecoder::OnDecodeDone(uint64_t decode_id, DecodeStatus status) {
« no previous file with comments | « media/mojo/clients/mojo_video_decoder.h ('k') | media/mojo/common/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698