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 21 matching lines...) Expand all Loading... |
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 : task_runner_(task_runner), | 34 : task_runner_(task_runner), |
35 state_(kUninitialized), | 35 state_(kUninitialized), |
36 demuxer_stream_(NULL), | 36 demuxer_stream_(NULL), |
37 set_decryptor_ready_cb_(set_decryptor_ready_cb), | 37 set_decryptor_ready_cb_(set_decryptor_ready_cb), |
38 decryptor_(NULL), | 38 decryptor_(NULL), |
39 key_added_while_decrypt_pending_(false), | 39 key_added_while_decrypt_pending_(false), |
40 weak_factory_(this) {} | 40 weak_factory_(this) {} |
41 | 41 |
42 void DecryptingDemuxerStream::Initialize(DemuxerStream* stream, | 42 void DecryptingDemuxerStream::Initialize( |
43 const PipelineStatusCB& status_cb) { | 43 DemuxerStream* stream, |
| 44 const PipelineStatusCB& status_cb, |
| 45 const base::Closure& waiting_for_encryption_key_cb) { |
44 DVLOG(2) << __FUNCTION__; | 46 DVLOG(2) << __FUNCTION__; |
45 DCHECK(task_runner_->BelongsToCurrentThread()); | 47 DCHECK(task_runner_->BelongsToCurrentThread()); |
46 DCHECK_EQ(state_, kUninitialized) << state_; | 48 DCHECK_EQ(state_, kUninitialized) << state_; |
47 | 49 |
48 DCHECK(!demuxer_stream_); | 50 DCHECK(!demuxer_stream_); |
49 weak_this_ = weak_factory_.GetWeakPtr(); | 51 weak_this_ = weak_factory_.GetWeakPtr(); |
50 demuxer_stream_ = stream; | 52 demuxer_stream_ = stream; |
51 init_cb_ = BindToCurrentLoop(status_cb); | 53 init_cb_ = BindToCurrentLoop(status_cb); |
| 54 waiting_for_encryption_key_cb_ = waiting_for_encryption_key_cb; |
52 | 55 |
53 InitializeDecoderConfig(); | 56 InitializeDecoderConfig(); |
54 | 57 |
55 state_ = kDecryptorRequested; | 58 state_ = kDecryptorRequested; |
56 set_decryptor_ready_cb_.Run(BindToCurrentLoop( | 59 set_decryptor_ready_cb_.Run(BindToCurrentLoop( |
57 base::Bind(&DecryptingDemuxerStream::SetDecryptor, weak_this_))); | 60 base::Bind(&DecryptingDemuxerStream::SetDecryptor, weak_this_))); |
58 } | 61 } |
59 | 62 |
60 void DecryptingDemuxerStream::Read(const ReadCB& read_cb) { | 63 void DecryptingDemuxerStream::Read(const ReadCB& read_cb) { |
61 DVLOG(3) << __FUNCTION__; | 64 DVLOG(3) << __FUNCTION__; |
(...skipping 242 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_encryption_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 |