| 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 "media/filters/decoder_selector.h" |
| 6 |
| 7 #include <utility> |
| 6 | 8 |
| 7 #include "base/bind.h" | 9 #include "base/bind.h" |
| 8 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| 9 #include "base/logging.h" | 11 #include "base/logging.h" |
| 10 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
| 11 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 12 #include "media/base/audio_decoder.h" | 14 #include "media/base/audio_decoder.h" |
| 13 #include "media/base/bind_to_current_loop.h" | 15 #include "media/base/bind_to_current_loop.h" |
| 14 #include "media/base/demuxer_stream.h" | 16 #include "media/base/demuxer_stream.h" |
| 15 #include "media/base/media_log.h" | 17 #include "media/base/media_log.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 } | 54 } |
| 53 return false; | 55 return false; |
| 54 } | 56 } |
| 55 | 57 |
| 56 template <DemuxerStream::Type StreamType> | 58 template <DemuxerStream::Type StreamType> |
| 57 DecoderSelector<StreamType>::DecoderSelector( | 59 DecoderSelector<StreamType>::DecoderSelector( |
| 58 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 60 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
| 59 ScopedVector<Decoder> decoders, | 61 ScopedVector<Decoder> decoders, |
| 60 const scoped_refptr<MediaLog>& media_log) | 62 const scoped_refptr<MediaLog>& media_log) |
| 61 : task_runner_(task_runner), | 63 : task_runner_(task_runner), |
| 62 decoders_(decoders.Pass()), | 64 decoders_(std::move(decoders)), |
| 63 media_log_(media_log), | 65 media_log_(media_log), |
| 64 input_stream_(nullptr), | 66 input_stream_(nullptr), |
| 65 weak_ptr_factory_(this) {} | 67 weak_ptr_factory_(this) {} |
| 66 | 68 |
| 67 template <DemuxerStream::Type StreamType> | 69 template <DemuxerStream::Type StreamType> |
| 68 DecoderSelector<StreamType>::~DecoderSelector() { | 70 DecoderSelector<StreamType>::~DecoderSelector() { |
| 69 DVLOG(2) << __FUNCTION__; | 71 DVLOG(2) << __FUNCTION__; |
| 70 DCHECK(task_runner_->BelongsToCurrentThread()); | 72 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 71 | 73 |
| 72 if (!select_decoder_cb_.is_null()) | 74 if (!select_decoder_cb_.is_null()) |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 output_cb_); | 137 output_cb_); |
| 136 } | 138 } |
| 137 | 139 |
| 138 template <DemuxerStream::Type StreamType> | 140 template <DemuxerStream::Type StreamType> |
| 139 void DecoderSelector<StreamType>::DecryptingDecoderInitDone(bool success) { | 141 void DecoderSelector<StreamType>::DecryptingDecoderInitDone(bool success) { |
| 140 DVLOG(2) << __FUNCTION__; | 142 DVLOG(2) << __FUNCTION__; |
| 141 DCHECK(task_runner_->BelongsToCurrentThread()); | 143 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 142 | 144 |
| 143 if (success) { | 145 if (success) { |
| 144 base::ResetAndReturn(&select_decoder_cb_) | 146 base::ResetAndReturn(&select_decoder_cb_) |
| 145 .Run(decoder_.Pass(), scoped_ptr<DecryptingDemuxerStream>()); | 147 .Run(std::move(decoder_), scoped_ptr<DecryptingDemuxerStream>()); |
| 146 return; | 148 return; |
| 147 } | 149 } |
| 148 | 150 |
| 149 decoder_.reset(); | 151 decoder_.reset(); |
| 150 | 152 |
| 151 // When we get here decrypt-and-decode is not supported. Try to use | 153 // When we get here decrypt-and-decode is not supported. Try to use |
| 152 // DecryptingDemuxerStream to do decrypt-only. | 154 // DecryptingDemuxerStream to do decrypt-only. |
| 153 InitializeDecryptingDemuxerStream(); | 155 InitializeDecryptingDemuxerStream(); |
| 154 } | 156 } |
| 155 #endif // !defined(OS_ANDROID) | 157 #endif // !defined(OS_ANDROID) |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 DVLOG(2) << __FUNCTION__; | 215 DVLOG(2) << __FUNCTION__; |
| 214 DCHECK(task_runner_->BelongsToCurrentThread()); | 216 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 215 | 217 |
| 216 if (!success) { | 218 if (!success) { |
| 217 decoder_.reset(); | 219 decoder_.reset(); |
| 218 InitializeDecoder(); | 220 InitializeDecoder(); |
| 219 return; | 221 return; |
| 220 } | 222 } |
| 221 | 223 |
| 222 base::ResetAndReturn(&select_decoder_cb_) | 224 base::ResetAndReturn(&select_decoder_cb_) |
| 223 .Run(decoder_.Pass(), decrypted_stream_.Pass()); | 225 .Run(std::move(decoder_), std::move(decrypted_stream_)); |
| 224 } | 226 } |
| 225 | 227 |
| 226 template <DemuxerStream::Type StreamType> | 228 template <DemuxerStream::Type StreamType> |
| 227 void DecoderSelector<StreamType>::ReturnNullDecoder() { | 229 void DecoderSelector<StreamType>::ReturnNullDecoder() { |
| 228 DVLOG(2) << __FUNCTION__; | 230 DVLOG(2) << __FUNCTION__; |
| 229 DCHECK(task_runner_->BelongsToCurrentThread()); | 231 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 230 base::ResetAndReturn(&select_decoder_cb_) | 232 base::ResetAndReturn(&select_decoder_cb_) |
| 231 .Run(scoped_ptr<Decoder>(), | 233 .Run(scoped_ptr<Decoder>(), |
| 232 scoped_ptr<DecryptingDemuxerStream>()); | 234 scoped_ptr<DecryptingDemuxerStream>()); |
| 233 } | 235 } |
| 234 | 236 |
| 235 // These forward declarations tell the compiler that we will use | 237 // These forward declarations tell the compiler that we will use |
| 236 // DecoderSelector with these arguments, allowing us to keep these definitions | 238 // DecoderSelector with these arguments, allowing us to keep these definitions |
| 237 // in our .cc without causing linker errors. This also means if anyone tries to | 239 // in our .cc without causing linker errors. This also means if anyone tries to |
| 238 // instantiate a DecoderSelector with anything but these two specializations | 240 // instantiate a DecoderSelector with anything but these two specializations |
| 239 // they'll most likely get linker errors. | 241 // they'll most likely get linker errors. |
| 240 template class DecoderSelector<DemuxerStream::AUDIO>; | 242 template class DecoderSelector<DemuxerStream::AUDIO>; |
| 241 template class DecoderSelector<DemuxerStream::VIDEO>; | 243 template class DecoderSelector<DemuxerStream::VIDEO>; |
| 242 | 244 |
| 243 } // namespace media | 245 } // namespace media |
| OLD | NEW |