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

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

Issue 2425663003: media: Use native CDM enum types in media mojo interfaces (Closed)
Patch Set: comments addressed Created 4 years, 2 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
« no previous file with comments | « media/mojo/clients/mojo_cdm.cc ('k') | media/mojo/common/media_type_converters.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_decryptor.h" 5 #include "media/mojo/clients/mojo_decryptor.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <utility> 10 #include <utility>
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 } 169 }
170 170
171 void MojoDecryptor::OnBufferDecrypted(const DecryptCB& decrypt_cb, 171 void MojoDecryptor::OnBufferDecrypted(const DecryptCB& decrypt_cb,
172 Status status, 172 Status status,
173 mojom::DecoderBufferPtr buffer) { 173 mojom::DecoderBufferPtr buffer) {
174 DVLOG_IF(1, status != kSuccess) << __FUNCTION__ << "(" << status << ")"; 174 DVLOG_IF(1, status != kSuccess) << __FUNCTION__ << "(" << status << ")";
175 DVLOG_IF(3, status == kSuccess) << __FUNCTION__; 175 DVLOG_IF(3, status == kSuccess) << __FUNCTION__;
176 DCHECK(thread_checker_.CalledOnValidThread()); 176 DCHECK(thread_checker_.CalledOnValidThread());
177 177
178 if (buffer.is_null()) { 178 if (buffer.is_null()) {
179 decrypt_cb.Run(static_cast<Decryptor::Status>(status), nullptr); 179 decrypt_cb.Run(status, nullptr);
180 return; 180 return;
181 } 181 }
182 182
183 scoped_refptr<DecoderBuffer> media_buffer = 183 scoped_refptr<DecoderBuffer> media_buffer =
184 mojo_decoder_buffer_reader_->ReadDecoderBuffer(buffer); 184 mojo_decoder_buffer_reader_->ReadDecoderBuffer(buffer);
185 if (!media_buffer) { 185 if (!media_buffer) {
186 decrypt_cb.Run(kError, nullptr); 186 decrypt_cb.Run(kError, nullptr);
187 return; 187 return;
188 } 188 }
189 189
190 decrypt_cb.Run(static_cast<Decryptor::Status>(status), media_buffer); 190 decrypt_cb.Run(status, media_buffer);
191 } 191 }
192 192
193 void MojoDecryptor::OnAudioDecoded( 193 void MojoDecryptor::OnAudioDecoded(
194 const AudioDecodeCB& audio_decode_cb, 194 const AudioDecodeCB& audio_decode_cb,
195 Status status, 195 Status status,
196 std::vector<mojom::AudioBufferPtr> audio_buffers) { 196 std::vector<mojom::AudioBufferPtr> audio_buffers) {
197 DVLOG_IF(1, status != kSuccess) << __FUNCTION__ << "(" << status << ")"; 197 DVLOG_IF(1, status != kSuccess) << __FUNCTION__ << "(" << status << ")";
198 DVLOG_IF(3, status == kSuccess) << __FUNCTION__; 198 DVLOG_IF(3, status == kSuccess) << __FUNCTION__;
199 DCHECK(thread_checker_.CalledOnValidThread()); 199 DCHECK(thread_checker_.CalledOnValidThread());
200 200
201 Decryptor::AudioFrames audio_frames; 201 Decryptor::AudioFrames audio_frames;
202 for (size_t i = 0; i < audio_buffers.size(); ++i) 202 for (size_t i = 0; i < audio_buffers.size(); ++i)
203 audio_frames.push_back(audio_buffers[i].To<scoped_refptr<AudioBuffer>>()); 203 audio_frames.push_back(audio_buffers[i].To<scoped_refptr<AudioBuffer>>());
204 204
205 audio_decode_cb.Run(static_cast<Decryptor::Status>(status), audio_frames); 205 audio_decode_cb.Run(status, audio_frames);
206 } 206 }
207 207
208 void MojoDecryptor::OnVideoDecoded(const VideoDecodeCB& video_decode_cb, 208 void MojoDecryptor::OnVideoDecoded(const VideoDecodeCB& video_decode_cb,
209 Status status, 209 Status status,
210 mojom::VideoFramePtr video_frame) { 210 mojom::VideoFramePtr video_frame) {
211 DVLOG_IF(1, status != kSuccess) << __FUNCTION__ << "(" << status << ")"; 211 DVLOG_IF(1, status != kSuccess) << __FUNCTION__ << "(" << status << ")";
212 DVLOG_IF(3, status == kSuccess) << __FUNCTION__; 212 DVLOG_IF(3, status == kSuccess) << __FUNCTION__;
213 DCHECK(thread_checker_.CalledOnValidThread()); 213 DCHECK(thread_checker_.CalledOnValidThread());
214 214
215 if (video_frame.is_null()) { 215 if (video_frame.is_null()) {
216 video_decode_cb.Run(static_cast<Decryptor::Status>(status), nullptr); 216 video_decode_cb.Run(status, nullptr);
217 return; 217 return;
218 } 218 }
219 219
220 scoped_refptr<VideoFrame> frame(video_frame.To<scoped_refptr<VideoFrame>>()); 220 scoped_refptr<VideoFrame> frame(video_frame.To<scoped_refptr<VideoFrame>>());
221 221
222 // If using shared memory, ensure that ReleaseSharedBuffer() is called when 222 // If using shared memory, ensure that ReleaseSharedBuffer() is called when
223 // |frame| is destroyed. 223 // |frame| is destroyed.
224 if (frame->storage_type() == VideoFrame::STORAGE_MOJO_SHARED_BUFFER) { 224 if (frame->storage_type() == VideoFrame::STORAGE_MOJO_SHARED_BUFFER) {
225 MojoSharedBufferVideoFrame* mojo_frame = 225 MojoSharedBufferVideoFrame* mojo_frame =
226 static_cast<MojoSharedBufferVideoFrame*>(frame.get()); 226 static_cast<MojoSharedBufferVideoFrame*>(frame.get());
227 mojo_frame->SetMojoSharedBufferDoneCB(base::Bind( 227 mojo_frame->SetMojoSharedBufferDoneCB(base::Bind(
228 &MojoDecryptor::ReleaseSharedBuffer, weak_factory_.GetWeakPtr())); 228 &MojoDecryptor::ReleaseSharedBuffer, weak_factory_.GetWeakPtr()));
229 } 229 }
230 230
231 video_decode_cb.Run(static_cast<Decryptor::Status>(status), frame); 231 video_decode_cb.Run(status, frame);
232 } 232 }
233 233
234 void MojoDecryptor::ReleaseSharedBuffer(mojo::ScopedSharedBufferHandle buffer, 234 void MojoDecryptor::ReleaseSharedBuffer(mojo::ScopedSharedBufferHandle buffer,
235 size_t buffer_size) { 235 size_t buffer_size) {
236 DVLOG(1) << __FUNCTION__; 236 DVLOG(1) << __FUNCTION__;
237 DCHECK(thread_checker_.CalledOnValidThread()); 237 DCHECK(thread_checker_.CalledOnValidThread());
238 238
239 remote_decryptor_->ReleaseSharedBuffer(std::move(buffer), buffer_size); 239 remote_decryptor_->ReleaseSharedBuffer(std::move(buffer), buffer_size);
240 } 240 }
241 241
242 } // namespace media 242 } // namespace media
OLDNEW
« no previous file with comments | « media/mojo/clients/mojo_cdm.cc ('k') | media/mojo/common/media_type_converters.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698