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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 task_runner_, set_decryptor_ready_cb_, waiting_for_decryption_key_cb_)); | 112 task_runner_, set_decryptor_ready_cb_, waiting_for_decryption_key_cb_)); |
113 | 113 |
114 DecoderStreamTraits<StreamType>::InitializeDecoder( | 114 DecoderStreamTraits<StreamType>::InitializeDecoder( |
115 decoder_.get(), input_stream_, | 115 decoder_.get(), input_stream_, |
116 base::Bind(&DecoderSelector<StreamType>::DecryptingDecoderInitDone, | 116 base::Bind(&DecoderSelector<StreamType>::DecryptingDecoderInitDone, |
117 weak_ptr_factory_.GetWeakPtr()), | 117 weak_ptr_factory_.GetWeakPtr()), |
118 output_cb_); | 118 output_cb_); |
119 } | 119 } |
120 | 120 |
121 template <DemuxerStream::Type StreamType> | 121 template <DemuxerStream::Type StreamType> |
122 void DecoderSelector<StreamType>::DecryptingDecoderInitDone(bool success) { | 122 void DecoderSelector<StreamType>::DecryptingDecoderInitDone( |
| 123 PipelineStatus status) { |
123 DVLOG(2) << __FUNCTION__; | 124 DVLOG(2) << __FUNCTION__; |
124 DCHECK(task_runner_->BelongsToCurrentThread()); | 125 DCHECK(task_runner_->BelongsToCurrentThread()); |
125 | 126 |
126 if (success) { | 127 if (status == PIPELINE_OK) { |
127 base::ResetAndReturn(&select_decoder_cb_) | 128 base::ResetAndReturn(&select_decoder_cb_) |
128 .Run(decoder_.Pass(), scoped_ptr<DecryptingDemuxerStream>()); | 129 .Run(decoder_.Pass(), scoped_ptr<DecryptingDemuxerStream>()); |
129 return; | 130 return; |
130 } | 131 } |
131 | 132 |
132 decoder_.reset(); | 133 decoder_.reset(); |
133 | 134 |
134 decrypted_stream_.reset(new DecryptingDemuxerStream( | 135 decrypted_stream_.reset(new DecryptingDemuxerStream( |
135 task_runner_, set_decryptor_ready_cb_, waiting_for_decryption_key_cb_)); | 136 task_runner_, set_decryptor_ready_cb_, waiting_for_decryption_key_cb_)); |
136 | 137 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 decoders_.weak_erase(decoders_.begin()); | 172 decoders_.weak_erase(decoders_.begin()); |
172 | 173 |
173 DecoderStreamTraits<StreamType>::InitializeDecoder( | 174 DecoderStreamTraits<StreamType>::InitializeDecoder( |
174 decoder_.get(), input_stream_, | 175 decoder_.get(), input_stream_, |
175 base::Bind(&DecoderSelector<StreamType>::DecoderInitDone, | 176 base::Bind(&DecoderSelector<StreamType>::DecoderInitDone, |
176 weak_ptr_factory_.GetWeakPtr()), | 177 weak_ptr_factory_.GetWeakPtr()), |
177 output_cb_); | 178 output_cb_); |
178 } | 179 } |
179 | 180 |
180 template <DemuxerStream::Type StreamType> | 181 template <DemuxerStream::Type StreamType> |
181 void DecoderSelector<StreamType>::DecoderInitDone(bool success) { | 182 void DecoderSelector<StreamType>::DecoderInitDone(PipelineStatus status) { |
182 DVLOG(2) << __FUNCTION__; | 183 DVLOG(2) << __FUNCTION__; |
183 DCHECK(task_runner_->BelongsToCurrentThread()); | 184 DCHECK(task_runner_->BelongsToCurrentThread()); |
184 | 185 |
185 if (!success) { | 186 if (status != PIPELINE_OK) { |
186 decoder_.reset(); | 187 decoder_.reset(); |
187 InitializeDecoder(); | 188 InitializeDecoder(); |
188 return; | 189 return; |
189 } | 190 } |
190 | 191 |
191 base::ResetAndReturn(&select_decoder_cb_) | 192 base::ResetAndReturn(&select_decoder_cb_) |
192 .Run(decoder_.Pass(), decrypted_stream_.Pass()); | 193 .Run(decoder_.Pass(), decrypted_stream_.Pass()); |
193 } | 194 } |
194 | 195 |
195 template <DemuxerStream::Type StreamType> | 196 template <DemuxerStream::Type StreamType> |
196 void DecoderSelector<StreamType>::ReturnNullDecoder() { | 197 void DecoderSelector<StreamType>::ReturnNullDecoder() { |
197 DVLOG(2) << __FUNCTION__; | 198 DVLOG(2) << __FUNCTION__; |
198 DCHECK(task_runner_->BelongsToCurrentThread()); | 199 DCHECK(task_runner_->BelongsToCurrentThread()); |
199 base::ResetAndReturn(&select_decoder_cb_) | 200 base::ResetAndReturn(&select_decoder_cb_) |
200 .Run(scoped_ptr<Decoder>(), | 201 .Run(scoped_ptr<Decoder>(), |
201 scoped_ptr<DecryptingDemuxerStream>()); | 202 scoped_ptr<DecryptingDemuxerStream>()); |
202 } | 203 } |
203 | 204 |
204 // These forward declarations tell the compiler that we will use | 205 // These forward declarations tell the compiler that we will use |
205 // DecoderSelector with these arguments, allowing us to keep these definitions | 206 // DecoderSelector with these arguments, allowing us to keep these definitions |
206 // in our .cc without causing linker errors. This also means if anyone tries to | 207 // in our .cc without causing linker errors. This also means if anyone tries to |
207 // instantiate a DecoderSelector with anything but these two specializations | 208 // instantiate a DecoderSelector with anything but these two specializations |
208 // they'll most likely get linker errors. | 209 // they'll most likely get linker errors. |
209 template class DecoderSelector<DemuxerStream::AUDIO>; | 210 template class DecoderSelector<DemuxerStream::AUDIO>; |
210 template class DecoderSelector<DemuxerStream::VIDEO>; | 211 template class DecoderSelector<DemuxerStream::VIDEO>; |
211 | 212 |
212 } // namespace media | 213 } // namespace media |
OLD | NEW |