OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/filters/decrypting_video_decoder.h" | 5 #include "media/filters/decrypting_video_decoder.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/location.h" | 9 #include "base/location.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
12 #include "base/trace_event/trace_event.h" | 12 #include "base/trace_event/trace_event.h" |
13 #include "media/base/bind_to_current_loop.h" | 13 #include "media/base/bind_to_current_loop.h" |
14 #include "media/base/decoder_buffer.h" | 14 #include "media/base/decoder_buffer.h" |
15 #include "media/base/decryptor.h" | 15 #include "media/base/decryptor.h" |
16 #include "media/base/pipeline.h" | 16 #include "media/base/pipeline.h" |
17 #include "media/base/video_decoder_config.h" | 17 #include "media/base/video_decoder_config.h" |
18 #include "media/base/video_frame.h" | 18 #include "media/base/video_frame.h" |
19 | 19 |
20 namespace media { | 20 namespace media { |
21 | 21 |
22 const char DecryptingVideoDecoder::kDecoderName[] = "DecryptingVideoDecoder"; | 22 const char DecryptingVideoDecoder::kDecoderName[] = "DecryptingVideoDecoder"; |
23 | 23 |
24 DecryptingVideoDecoder::DecryptingVideoDecoder( | 24 DecryptingVideoDecoder::DecryptingVideoDecoder( |
25 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 25 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
26 const SetDecryptorReadyCB& set_decryptor_ready_cb) | 26 const SetDecryptorReadyCB& set_decryptor_ready_cb, |
| 27 const base::Closure& waiting_for_decryption_key_cb) |
27 : task_runner_(task_runner), | 28 : task_runner_(task_runner), |
28 state_(kUninitialized), | 29 state_(kUninitialized), |
| 30 waiting_for_decryption_key_cb_(waiting_for_decryption_key_cb), |
29 set_decryptor_ready_cb_(set_decryptor_ready_cb), | 31 set_decryptor_ready_cb_(set_decryptor_ready_cb), |
30 decryptor_(NULL), | 32 decryptor_(NULL), |
31 key_added_while_decode_pending_(false), | 33 key_added_while_decode_pending_(false), |
32 trace_id_(0), | 34 trace_id_(0), |
33 weak_factory_(this) {} | 35 weak_factory_(this) { |
| 36 } |
34 | 37 |
35 std::string DecryptingVideoDecoder::GetDisplayName() const { | 38 std::string DecryptingVideoDecoder::GetDisplayName() const { |
36 return kDecoderName; | 39 return kDecoderName; |
37 } | 40 } |
38 | 41 |
39 void DecryptingVideoDecoder::Initialize(const VideoDecoderConfig& config, | 42 void DecryptingVideoDecoder::Initialize(const VideoDecoderConfig& config, |
40 bool /* low_delay */, | 43 bool /* low_delay */, |
41 const PipelineStatusCB& status_cb, | 44 const PipelineStatusCB& status_cb, |
42 const OutputCB& output_cb) { | 45 const OutputCB& output_cb) { |
43 DVLOG(2) << "Initialize()"; | 46 DVLOG(2) << "Initialize()"; |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 // pending buffer again when new key is added to the decryptor. | 266 // pending buffer again when new key is added to the decryptor. |
264 pending_buffer_to_decode_ = scoped_pending_buffer_to_decode; | 267 pending_buffer_to_decode_ = scoped_pending_buffer_to_decode; |
265 | 268 |
266 if (need_to_try_again_if_nokey_is_returned) { | 269 if (need_to_try_again_if_nokey_is_returned) { |
267 // The |state_| is still kPendingDecode. | 270 // The |state_| is still kPendingDecode. |
268 DecodePendingBuffer(); | 271 DecodePendingBuffer(); |
269 return; | 272 return; |
270 } | 273 } |
271 | 274 |
272 state_ = kWaitingForKey; | 275 state_ = kWaitingForKey; |
| 276 waiting_for_decryption_key_cb_.Run(); |
273 return; | 277 return; |
274 } | 278 } |
275 | 279 |
276 if (status == Decryptor::kNeedMoreData) { | 280 if (status == Decryptor::kNeedMoreData) { |
277 DVLOG(2) << "DeliverFrame() - kNeedMoreData"; | 281 DVLOG(2) << "DeliverFrame() - kNeedMoreData"; |
278 state_ = scoped_pending_buffer_to_decode->end_of_stream() ? kDecodeFinished | 282 state_ = scoped_pending_buffer_to_decode->end_of_stream() ? kDecodeFinished |
279 : kIdle; | 283 : kIdle; |
280 base::ResetAndReturn(&decode_cb_).Run(kOk); | 284 base::ResetAndReturn(&decode_cb_).Run(kOk); |
281 return; | 285 return; |
282 } | 286 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 } | 318 } |
315 | 319 |
316 void DecryptingVideoDecoder::DoReset() { | 320 void DecryptingVideoDecoder::DoReset() { |
317 DCHECK(init_cb_.is_null()); | 321 DCHECK(init_cb_.is_null()); |
318 DCHECK(decode_cb_.is_null()); | 322 DCHECK(decode_cb_.is_null()); |
319 state_ = kIdle; | 323 state_ = kIdle; |
320 base::ResetAndReturn(&reset_cb_).Run(); | 324 base::ResetAndReturn(&reset_cb_).Run(); |
321 } | 325 } |
322 | 326 |
323 } // namespace media | 327 } // namespace media |
OLD | NEW |