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_demuxer_stream.h" | 5 #include "media/filters/decrypting_demuxer_stream.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" |
(...skipping 12 matching lines...) Expand all Loading... |
23 return ((stream->type() == DemuxerStream::AUDIO && | 23 return ((stream->type() == DemuxerStream::AUDIO && |
24 stream->audio_decoder_config().IsValidConfig() && | 24 stream->audio_decoder_config().IsValidConfig() && |
25 stream->audio_decoder_config().is_encrypted()) || | 25 stream->audio_decoder_config().is_encrypted()) || |
26 (stream->type() == DemuxerStream::VIDEO && | 26 (stream->type() == DemuxerStream::VIDEO && |
27 stream->video_decoder_config().IsValidConfig() && | 27 stream->video_decoder_config().IsValidConfig() && |
28 stream->video_decoder_config().is_encrypted())); | 28 stream->video_decoder_config().is_encrypted())); |
29 } | 29 } |
30 | 30 |
31 DecryptingDemuxerStream::DecryptingDemuxerStream( | 31 DecryptingDemuxerStream::DecryptingDemuxerStream( |
32 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 32 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
33 const SetDecryptorReadyCB& set_decryptor_ready_cb) | 33 const SetDecryptorReadyCB& set_decryptor_ready_cb, |
| 34 const base::Closure& waiting_for_decryption_key_cb) |
34 : task_runner_(task_runner), | 35 : task_runner_(task_runner), |
35 state_(kUninitialized), | 36 state_(kUninitialized), |
| 37 waiting_for_decryption_key_cb_(waiting_for_decryption_key_cb), |
36 demuxer_stream_(NULL), | 38 demuxer_stream_(NULL), |
37 set_decryptor_ready_cb_(set_decryptor_ready_cb), | 39 set_decryptor_ready_cb_(set_decryptor_ready_cb), |
38 decryptor_(NULL), | 40 decryptor_(NULL), |
39 key_added_while_decrypt_pending_(false), | 41 key_added_while_decrypt_pending_(false), |
40 weak_factory_(this) {} | 42 weak_factory_(this) { |
| 43 } |
41 | 44 |
42 void DecryptingDemuxerStream::Initialize(DemuxerStream* stream, | 45 void DecryptingDemuxerStream::Initialize(DemuxerStream* stream, |
43 const PipelineStatusCB& status_cb) { | 46 const PipelineStatusCB& status_cb) { |
44 DVLOG(2) << __FUNCTION__; | 47 DVLOG(2) << __FUNCTION__; |
45 DCHECK(task_runner_->BelongsToCurrentThread()); | 48 DCHECK(task_runner_->BelongsToCurrentThread()); |
46 DCHECK_EQ(state_, kUninitialized) << state_; | 49 DCHECK_EQ(state_, kUninitialized) << state_; |
47 | 50 |
48 DCHECK(!demuxer_stream_); | 51 DCHECK(!demuxer_stream_); |
49 weak_this_ = weak_factory_.GetWeakPtr(); | 52 weak_this_ = weak_factory_.GetWeakPtr(); |
50 demuxer_stream_ = stream; | 53 demuxer_stream_ = stream; |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 | 307 |
305 if (status == Decryptor::kNoKey) { | 308 if (status == Decryptor::kNoKey) { |
306 DVLOG(2) << "DoDeliverBuffer() - kNoKey"; | 309 DVLOG(2) << "DoDeliverBuffer() - kNoKey"; |
307 if (need_to_try_again_if_nokey) { | 310 if (need_to_try_again_if_nokey) { |
308 // The |state_| is still kPendingDecrypt. | 311 // The |state_| is still kPendingDecrypt. |
309 DecryptPendingBuffer(); | 312 DecryptPendingBuffer(); |
310 return; | 313 return; |
311 } | 314 } |
312 | 315 |
313 state_ = kWaitingForKey; | 316 state_ = kWaitingForKey; |
| 317 waiting_for_decryption_key_cb_.Run(); |
314 return; | 318 return; |
315 } | 319 } |
316 | 320 |
317 DCHECK_EQ(status, Decryptor::kSuccess); | 321 DCHECK_EQ(status, Decryptor::kSuccess); |
318 | 322 |
319 // Copy the key frame flag from the encrypted to decrypted buffer, assuming | 323 // Copy the key frame flag from the encrypted to decrypted buffer, assuming |
320 // that the decryptor initialized the flag to false. | 324 // that the decryptor initialized the flag to false. |
321 if (pending_buffer_to_decrypt_->is_key_frame()) | 325 if (pending_buffer_to_decrypt_->is_key_frame()) |
322 decrypted_buffer->set_is_key_frame(true); | 326 decrypted_buffer->set_is_key_frame(true); |
323 | 327 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 break; | 403 break; |
400 } | 404 } |
401 | 405 |
402 default: | 406 default: |
403 NOTREACHED(); | 407 NOTREACHED(); |
404 return; | 408 return; |
405 } | 409 } |
406 } | 410 } |
407 | 411 |
408 } // namespace media | 412 } // namespace media |
OLD | NEW |