| OLD | NEW |
| 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/services/mojo_decryptor_service.h" | 5 #include "media/mojo/services/mojo_decryptor_service.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/numerics/safe_conversions.h" | 10 #include "base/numerics/safe_conversions.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 } | 91 } |
| 92 | 92 |
| 93 void MojoDecryptorService::DecryptAndDecodeAudio( | 93 void MojoDecryptorService::DecryptAndDecodeAudio( |
| 94 mojom::DecoderBufferPtr encrypted, | 94 mojom::DecoderBufferPtr encrypted, |
| 95 const DecryptAndDecodeAudioCallback& callback) { | 95 const DecryptAndDecodeAudioCallback& callback) { |
| 96 DVLOG(3) << __FUNCTION__; | 96 DVLOG(3) << __FUNCTION__; |
| 97 | 97 |
| 98 scoped_refptr<DecoderBuffer> media_buffer = | 98 scoped_refptr<DecoderBuffer> media_buffer = |
| 99 mojo_decoder_buffer_reader_->ReadDecoderBuffer(encrypted); | 99 mojo_decoder_buffer_reader_->ReadDecoderBuffer(encrypted); |
| 100 if (!media_buffer) { | 100 if (!media_buffer) { |
| 101 callback.Run(Status::DECRYPTION_ERROR, nullptr); | 101 callback.Run(Status::DECRYPTION_ERROR, |
| 102 std::vector<mojom::AudioBufferPtr>()); |
| 102 return; | 103 return; |
| 103 } | 104 } |
| 104 | 105 |
| 105 decryptor_->DecryptAndDecodeAudio( | 106 decryptor_->DecryptAndDecodeAudio( |
| 106 std::move(media_buffer), | 107 std::move(media_buffer), |
| 107 base::Bind(&MojoDecryptorService::OnAudioDecoded, weak_this_, callback)); | 108 base::Bind(&MojoDecryptorService::OnAudioDecoded, weak_this_, callback)); |
| 108 } | 109 } |
| 109 | 110 |
| 110 void MojoDecryptorService::DecryptAndDecodeVideo( | 111 void MojoDecryptorService::DecryptAndDecodeVideo( |
| 111 mojom::DecoderBufferPtr encrypted, | 112 mojom::DecoderBufferPtr encrypted, |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 } | 184 } |
| 184 | 185 |
| 185 void MojoDecryptorService::OnAudioDecoded( | 186 void MojoDecryptorService::OnAudioDecoded( |
| 186 const DecryptAndDecodeAudioCallback& callback, | 187 const DecryptAndDecodeAudioCallback& callback, |
| 187 media::Decryptor::Status status, | 188 media::Decryptor::Status status, |
| 188 const media::Decryptor::AudioFrames& frames) { | 189 const media::Decryptor::AudioFrames& frames) { |
| 189 DVLOG_IF(1, status != media::Decryptor::kSuccess) << __FUNCTION__ << "(" | 190 DVLOG_IF(1, status != media::Decryptor::kSuccess) << __FUNCTION__ << "(" |
| 190 << status << ")"; | 191 << status << ")"; |
| 191 DVLOG_IF(3, status == media::Decryptor::kSuccess) << __FUNCTION__; | 192 DVLOG_IF(3, status == media::Decryptor::kSuccess) << __FUNCTION__; |
| 192 | 193 |
| 193 mojo::Array<mojom::AudioBufferPtr> audio_buffers; | 194 std::vector<mojom::AudioBufferPtr> audio_buffers; |
| 194 for (const auto& frame : frames) | 195 for (const auto& frame : frames) |
| 195 audio_buffers.push_back(mojom::AudioBuffer::From(frame)); | 196 audio_buffers.push_back(mojom::AudioBuffer::From(frame)); |
| 196 | 197 |
| 197 callback.Run(static_cast<Decryptor::Status>(status), | 198 callback.Run(static_cast<Decryptor::Status>(status), |
| 198 std::move(audio_buffers)); | 199 std::move(audio_buffers)); |
| 199 } | 200 } |
| 200 | 201 |
| 201 void MojoDecryptorService::OnVideoDecoded( | 202 void MojoDecryptorService::OnVideoDecoded( |
| 202 const DecryptAndDecodeVideoCallback& callback, | 203 const DecryptAndDecodeVideoCallback& callback, |
| 203 media::Decryptor::Status status, | 204 media::Decryptor::Status status, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 219 static_cast<MojoSharedBufferVideoFrame*>(frame.get()); | 220 static_cast<MojoSharedBufferVideoFrame*>(frame.get()); |
| 220 in_use_video_frames_.insert( | 221 in_use_video_frames_.insert( |
| 221 std::make_pair(mojo_frame->Handle().value(), frame)); | 222 std::make_pair(mojo_frame->Handle().value(), frame)); |
| 222 } | 223 } |
| 223 | 224 |
| 224 callback.Run(static_cast<Decryptor::Status>(status), | 225 callback.Run(static_cast<Decryptor::Status>(status), |
| 225 mojom::VideoFrame::From(frame)); | 226 mojom::VideoFrame::From(frame)); |
| 226 } | 227 } |
| 227 | 228 |
| 228 } // namespace media | 229 } // namespace media |
| OLD | NEW |