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

Side by Side Diff: media/mojo/clients/mojo_video_decoder.cc

Issue 2640153004: Add mailbox-based Mojo VideoFrame variant. (Closed)
Patch Set: 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/mojo/clients/mojo_video_decoder.h" 5 #include "media/mojo/clients/mojo_video_decoder.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/callback_helpers.h" 9 #include "base/callback_helpers.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 return; 97 return;
98 } 98 }
99 99
100 uint64_t decode_id = decode_counter_++; 100 uint64_t decode_id = decode_counter_++;
101 pending_decodes_[decode_id] = decode_cb; 101 pending_decodes_[decode_id] = decode_cb;
102 remote_decoder_->Decode(std::move(mojo_buffer), 102 remote_decoder_->Decode(std::move(mojo_buffer),
103 base::Bind(&MojoVideoDecoder::OnDecodeDone, 103 base::Bind(&MojoVideoDecoder::OnDecodeDone,
104 base::Unretained(this), decode_id)); 104 base::Unretained(this), decode_id));
105 } 105 }
106 106
107 void MojoVideoDecoder::OnVideoFrameDecoded(mojom::VideoFramePtr frame) { 107 void MojoVideoDecoder::OnVideoFrameDecoded(
108 mojom::VideoFramePtr frame,
109 const OnVideoFrameDecodedCallback& callback) {
108 DVLOG(2) << __func__; 110 DVLOG(2) << __func__;
109 DCHECK(task_runner_->BelongsToCurrentThread()); 111 DCHECK(task_runner_->BelongsToCurrentThread());
110 output_cb_.Run(frame.To<scoped_refptr<VideoFrame>>()); 112
113 scoped_refptr<VideoFrame> video_frame = frame.To<scoped_refptr<VideoFrame>>();
114 // TODO(sandersd): Fix threading and lifetime of |this|.
115 video_frame->SetReleaseMailboxCB(base::Bind(
116 &MojoVideoDecoder::OnReleaseMailbox, base::Unretained(this), callback));
sandersd (OOO until July 31) 2017/01/19 19:40:48 This isn't useful for non-mailbox VideoFrames, but
117 output_cb_.Run(std::move(video_frame));
118 }
119
120 void MojoVideoDecoder::OnReleaseMailbox(
121 const OnVideoFrameDecodedCallback& callback,
122 const gpu::SyncToken& release_sync_token) {
123 DCHECK(task_runner_->BelongsToCurrentThread());
124
125 base::Optional<gpu::SyncToken> token;
126 if (release_sync_token.HasData())
127 token = release_sync_token;
128 callback.Run(std::move(token));
111 } 129 }
112 130
113 void MojoVideoDecoder::OnDecodeDone(uint64_t decode_id, DecodeStatus status) { 131 void MojoVideoDecoder::OnDecodeDone(uint64_t decode_id, DecodeStatus status) {
114 DVLOG(2) << __func__; 132 DVLOG(2) << __func__;
115 DCHECK(task_runner_->BelongsToCurrentThread()); 133 DCHECK(task_runner_->BelongsToCurrentThread());
116 134
117 auto it = pending_decodes_.find(decode_id); 135 auto it = pending_decodes_.find(decode_id);
118 if (it == pending_decodes_.end()) { 136 if (it == pending_decodes_.end()) {
119 DLOG(ERROR) << "Decode request " << decode_id << " not found"; 137 DLOG(ERROR) << "Decode request " << decode_id << " not found";
120 Stop(); 138 Stop();
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 226
209 for (const auto& pending_decode : pending_decodes_) 227 for (const auto& pending_decode : pending_decodes_)
210 pending_decode.second.Run(DecodeStatus::DECODE_ERROR); 228 pending_decode.second.Run(DecodeStatus::DECODE_ERROR);
211 pending_decodes_.clear(); 229 pending_decodes_.clear();
212 230
213 if (!reset_cb_.is_null()) 231 if (!reset_cb_.is_null())
214 base::ResetAndReturn(&reset_cb_).Run(); 232 base::ResetAndReturn(&reset_cb_).Run();
215 } 233 }
216 234
217 } // namespace media 235 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698