| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "decoder_selector.h" | 5 #include "decoder_selector.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 InitializeDecryptingDecoder(); | 118 InitializeDecryptingDecoder(); |
| 119 #else | 119 #else |
| 120 InitializeDecryptingDemuxerStream(); | 120 InitializeDecryptingDemuxerStream(); |
| 121 #endif | 121 #endif |
| 122 } | 122 } |
| 123 | 123 |
| 124 #if !defined(OS_ANDROID) | 124 #if !defined(OS_ANDROID) |
| 125 template <DemuxerStream::Type StreamType> | 125 template <DemuxerStream::Type StreamType> |
| 126 void DecoderSelector<StreamType>::InitializeDecryptingDecoder() { | 126 void DecoderSelector<StreamType>::InitializeDecryptingDecoder() { |
| 127 decoder_.reset(new typename StreamTraits::DecryptingDecoderType( | 127 decoder_.reset(new typename StreamTraits::DecryptingDecoderType( |
| 128 task_runner_, media_log_, waiting_for_decryption_key_cb_)); | 128 task_runner_, media_log_, set_cdm_ready_cb_, |
| 129 waiting_for_decryption_key_cb_)); |
| 129 | 130 |
| 130 DecoderStreamTraits<StreamType>::InitializeDecoder( | 131 DecoderStreamTraits<StreamType>::InitializeDecoder( |
| 131 decoder_.get(), input_stream_, set_cdm_ready_cb_, | 132 decoder_.get(), input_stream_, |
| 132 base::Bind(&DecoderSelector<StreamType>::DecryptingDecoderInitDone, | 133 base::Bind(&DecoderSelector<StreamType>::DecryptingDecoderInitDone, |
| 133 weak_ptr_factory_.GetWeakPtr()), | 134 weak_ptr_factory_.GetWeakPtr()), |
| 134 output_cb_); | 135 output_cb_); |
| 135 } | 136 } |
| 136 | 137 |
| 137 template <DemuxerStream::Type StreamType> | 138 template <DemuxerStream::Type StreamType> |
| 138 void DecoderSelector<StreamType>::DecryptingDecoderInitDone(bool success) { | 139 void DecoderSelector<StreamType>::DecryptingDecoderInitDone(bool success) { |
| 139 DVLOG(2) << __FUNCTION__; | 140 DVLOG(2) << __FUNCTION__; |
| 140 DCHECK(task_runner_->BelongsToCurrentThread()); | 141 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 141 | 142 |
| 142 if (success) { | 143 if (success) { |
| 143 base::ResetAndReturn(&select_decoder_cb_) | 144 base::ResetAndReturn(&select_decoder_cb_) |
| 144 .Run(decoder_.Pass(), scoped_ptr<DecryptingDemuxerStream>()); | 145 .Run(decoder_.Pass(), scoped_ptr<DecryptingDemuxerStream>()); |
| 145 return; | 146 return; |
| 146 } | 147 } |
| 147 | 148 |
| 148 decoder_.reset(); | 149 decoder_.reset(); |
| 149 | 150 |
| 150 // When we get here decrypt-and-decode is not supported. Try to use | 151 // When we get here decrypt-and-decode is not supported. Try to use |
| 151 // DecryptingDemuxerStream to do decrypt-only. | 152 // DecryptingDemuxerStream to do decrypt-only. |
| 152 InitializeDecryptingDemuxerStream(); | 153 InitializeDecryptingDemuxerStream(); |
| 153 } | 154 } |
| 154 #endif // !defined(OS_ANDROID) | 155 #endif // !defined(OS_ANDROID) |
| 155 | 156 |
| 156 template <DemuxerStream::Type StreamType> | 157 template <DemuxerStream::Type StreamType> |
| 157 void DecoderSelector<StreamType>::InitializeDecryptingDemuxerStream() { | 158 void DecoderSelector<StreamType>::InitializeDecryptingDemuxerStream() { |
| 158 decrypted_stream_.reset(new DecryptingDemuxerStream( | 159 decrypted_stream_.reset( |
| 159 task_runner_, media_log_, waiting_for_decryption_key_cb_)); | 160 new DecryptingDemuxerStream(task_runner_, media_log_, set_cdm_ready_cb_, |
| 161 waiting_for_decryption_key_cb_)); |
| 160 | 162 |
| 161 decrypted_stream_->Initialize( | 163 decrypted_stream_->Initialize( |
| 162 input_stream_, set_cdm_ready_cb_, | 164 input_stream_, |
| 163 base::Bind(&DecoderSelector<StreamType>::DecryptingDemuxerStreamInitDone, | 165 base::Bind(&DecoderSelector<StreamType>::DecryptingDemuxerStreamInitDone, |
| 164 weak_ptr_factory_.GetWeakPtr())); | 166 weak_ptr_factory_.GetWeakPtr())); |
| 165 } | 167 } |
| 166 | 168 |
| 167 template <DemuxerStream::Type StreamType> | 169 template <DemuxerStream::Type StreamType> |
| 168 void DecoderSelector<StreamType>::DecryptingDemuxerStreamInitDone( | 170 void DecoderSelector<StreamType>::DecryptingDemuxerStreamInitDone( |
| 169 PipelineStatus status) { | 171 PipelineStatus status) { |
| 170 DVLOG(2) << __FUNCTION__; | 172 DVLOG(2) << __FUNCTION__; |
| 171 DCHECK(task_runner_->BelongsToCurrentThread()); | 173 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 172 | 174 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 194 | 196 |
| 195 if (decoders_.empty()) { | 197 if (decoders_.empty()) { |
| 196 ReturnNullDecoder(); | 198 ReturnNullDecoder(); |
| 197 return; | 199 return; |
| 198 } | 200 } |
| 199 | 201 |
| 200 decoder_.reset(decoders_.front()); | 202 decoder_.reset(decoders_.front()); |
| 201 decoders_.weak_erase(decoders_.begin()); | 203 decoders_.weak_erase(decoders_.begin()); |
| 202 | 204 |
| 203 DecoderStreamTraits<StreamType>::InitializeDecoder( | 205 DecoderStreamTraits<StreamType>::InitializeDecoder( |
| 204 decoder_.get(), input_stream_, set_cdm_ready_cb_, | 206 decoder_.get(), input_stream_, |
| 205 base::Bind(&DecoderSelector<StreamType>::DecoderInitDone, | 207 base::Bind(&DecoderSelector<StreamType>::DecoderInitDone, |
| 206 weak_ptr_factory_.GetWeakPtr()), | 208 weak_ptr_factory_.GetWeakPtr()), |
| 207 output_cb_); | 209 output_cb_); |
| 208 } | 210 } |
| 209 | 211 |
| 210 template <DemuxerStream::Type StreamType> | 212 template <DemuxerStream::Type StreamType> |
| 211 void DecoderSelector<StreamType>::DecoderInitDone(bool success) { | 213 void DecoderSelector<StreamType>::DecoderInitDone(bool success) { |
| 212 DVLOG(2) << __FUNCTION__; | 214 DVLOG(2) << __FUNCTION__; |
| 213 DCHECK(task_runner_->BelongsToCurrentThread()); | 215 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 214 | 216 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 233 | 235 |
| 234 // These forward declarations tell the compiler that we will use | 236 // These forward declarations tell the compiler that we will use |
| 235 // DecoderSelector with these arguments, allowing us to keep these definitions | 237 // DecoderSelector with these arguments, allowing us to keep these definitions |
| 236 // in our .cc without causing linker errors. This also means if anyone tries to | 238 // in our .cc without causing linker errors. This also means if anyone tries to |
| 237 // instantiate a DecoderSelector with anything but these two specializations | 239 // instantiate a DecoderSelector with anything but these two specializations |
| 238 // they'll most likely get linker errors. | 240 // they'll most likely get linker errors. |
| 239 template class DecoderSelector<DemuxerStream::AUDIO>; | 241 template class DecoderSelector<DemuxerStream::AUDIO>; |
| 240 template class DecoderSelector<DemuxerStream::VIDEO>; | 242 template class DecoderSelector<DemuxerStream::VIDEO>; |
| 241 | 243 |
| 242 } // namespace media | 244 } // namespace media |
| OLD | NEW |