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