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

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

Issue 2640153004: Add mailbox-based Mojo VideoFrame variant. (Closed)
Patch Set: Switch to an interface method. Created 3 years, 11 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
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 c608bdcd2966e5e3529c689388f23e99f0f071bc..1d304880f1d053e4e2b49ef261551ff43650044b 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(
nasko 2017/02/16 21:37:29 Can this be called on multiple threads?
sandersd (OOO until July 31) 2017/02/25 01:19:38 No, it is a Mojo IPC callback and so should only b
+ 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) {

Powered by Google App Engine
This is Rietveld 408576698