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_audio_decoder.h" | 5 #include "media/filters/decrypting_audio_decoder.h" |
6 | 6 |
7 #include <cstdlib> | 7 #include <cstdlib> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
11 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "base/logging.h" |
12 #include "base/message_loop_proxy.h" | 13 #include "base/message_loop_proxy.h" |
13 #include "base/logging.h" | |
14 #include "media/base/audio_decoder_config.h" | 14 #include "media/base/audio_decoder_config.h" |
15 #include "media/base/bind_to_loop.h" | 15 #include "media/base/bind_to_loop.h" |
16 #include "media/base/buffers.h" | 16 #include "media/base/buffers.h" |
17 #include "media/base/data_buffer.h" | 17 #include "media/base/data_buffer.h" |
18 #include "media/base/decoder_buffer.h" | 18 #include "media/base/decoder_buffer.h" |
19 #include "media/base/decryptor.h" | 19 #include "media/base/decryptor.h" |
20 #include "media/base/demuxer_stream.h" | 20 #include "media/base/demuxer_stream.h" |
21 #include "media/base/pipeline.h" | 21 #include "media/base/pipeline.h" |
22 | 22 |
23 namespace media { | 23 namespace media { |
(...skipping 10 matching lines...) Expand all Loading... |
34 kOutOfSyncThresholdInMicroseconds; | 34 kOutOfSyncThresholdInMicroseconds; |
35 } | 35 } |
36 | 36 |
37 DecryptingAudioDecoder::DecryptingAudioDecoder( | 37 DecryptingAudioDecoder::DecryptingAudioDecoder( |
38 const MessageLoopFactoryCB& message_loop_factory_cb, | 38 const MessageLoopFactoryCB& message_loop_factory_cb, |
39 const RequestDecryptorNotificationCB& request_decryptor_notification_cb) | 39 const RequestDecryptorNotificationCB& request_decryptor_notification_cb) |
40 : message_loop_factory_cb_(message_loop_factory_cb), | 40 : message_loop_factory_cb_(message_loop_factory_cb), |
41 state_(kUninitialized), | 41 state_(kUninitialized), |
42 request_decryptor_notification_cb_(request_decryptor_notification_cb), | 42 request_decryptor_notification_cb_(request_decryptor_notification_cb), |
43 decryptor_(NULL), | 43 decryptor_(NULL), |
44 key_added_while_pending_decode_(false), | 44 key_added_while_decode_pending_(false), |
45 bits_per_channel_(0), | 45 bits_per_channel_(0), |
46 channel_layout_(CHANNEL_LAYOUT_NONE), | 46 channel_layout_(CHANNEL_LAYOUT_NONE), |
47 samples_per_second_(0), | 47 samples_per_second_(0), |
48 bytes_per_sample_(0), | 48 bytes_per_sample_(0), |
49 output_timestamp_base_(kNoTimestamp()), | 49 output_timestamp_base_(kNoTimestamp()), |
50 total_samples_decoded_(0) { | 50 total_samples_decoded_(0) { |
51 } | 51 } |
52 | 52 |
53 void DecryptingAudioDecoder::Initialize( | 53 void DecryptingAudioDecoder::Initialize( |
54 const scoped_refptr<DemuxerStream>& stream, | 54 const scoped_refptr<DemuxerStream>& stream, |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 int buffer_size, | 321 int buffer_size, |
322 Decryptor::Status status, | 322 Decryptor::Status status, |
323 const Decryptor::AudioBuffers& frames) { | 323 const Decryptor::AudioBuffers& frames) { |
324 DVLOG(3) << "DoDeliverFrame() - status: " << status; | 324 DVLOG(3) << "DoDeliverFrame() - status: " << status; |
325 DCHECK(message_loop_->BelongsToCurrentThread()); | 325 DCHECK(message_loop_->BelongsToCurrentThread()); |
326 DCHECK_EQ(state_, kPendingDecode) << state_; | 326 DCHECK_EQ(state_, kPendingDecode) << state_; |
327 DCHECK(!read_cb_.is_null()); | 327 DCHECK(!read_cb_.is_null()); |
328 DCHECK(pending_buffer_to_decode_); | 328 DCHECK(pending_buffer_to_decode_); |
329 DCHECK(queued_audio_frames_.empty()); | 329 DCHECK(queued_audio_frames_.empty()); |
330 | 330 |
331 bool need_to_try_again_if_nokey_is_returned = key_added_while_pending_decode_; | 331 bool need_to_try_again_if_nokey_is_returned = key_added_while_decode_pending_; |
332 key_added_while_pending_decode_ = false; | 332 key_added_while_decode_pending_ = false; |
333 | 333 |
334 scoped_refptr<DecoderBuffer> scoped_pending_buffer_to_decode = | 334 scoped_refptr<DecoderBuffer> scoped_pending_buffer_to_decode = |
335 pending_buffer_to_decode_; | 335 pending_buffer_to_decode_; |
336 pending_buffer_to_decode_ = NULL; | 336 pending_buffer_to_decode_ = NULL; |
337 | 337 |
338 if (!reset_cb_.is_null()) { | 338 if (!reset_cb_.is_null()) { |
339 base::ResetAndReturn(&read_cb_).Run(kAborted, NULL); | 339 base::ResetAndReturn(&read_cb_).Run(kAborted, NULL); |
340 DoReset(); | 340 DoReset(); |
341 return; | 341 return; |
342 } | 342 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 | 393 |
394 state_ = kIdle; | 394 state_ = kIdle; |
395 base::ResetAndReturn(&read_cb_).Run(kOk, queued_audio_frames_.front()); | 395 base::ResetAndReturn(&read_cb_).Run(kOk, queued_audio_frames_.front()); |
396 queued_audio_frames_.pop_front(); | 396 queued_audio_frames_.pop_front(); |
397 } | 397 } |
398 | 398 |
399 void DecryptingAudioDecoder::OnKeyAdded() { | 399 void DecryptingAudioDecoder::OnKeyAdded() { |
400 DCHECK(message_loop_->BelongsToCurrentThread()); | 400 DCHECK(message_loop_->BelongsToCurrentThread()); |
401 | 401 |
402 if (state_ == kPendingDecode) { | 402 if (state_ == kPendingDecode) { |
403 key_added_while_pending_decode_ = true; | 403 key_added_while_decode_pending_ = true; |
404 return; | 404 return; |
405 } | 405 } |
406 | 406 |
407 if (state_ == kWaitingForKey) { | 407 if (state_ == kWaitingForKey) { |
408 state_ = kPendingDecode; | 408 state_ = kPendingDecode; |
409 DecodePendingBuffer(); | 409 DecodePendingBuffer(); |
410 } | 410 } |
411 } | 411 } |
412 | 412 |
413 void DecryptingAudioDecoder::DoReset() { | 413 void DecryptingAudioDecoder::DoReset() { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 | 456 |
457 base::TimeDelta DecryptingAudioDecoder::NumberOfSamplesToDuration( | 457 base::TimeDelta DecryptingAudioDecoder::NumberOfSamplesToDuration( |
458 int number_of_samples) const { | 458 int number_of_samples) const { |
459 DCHECK(samples_per_second_); | 459 DCHECK(samples_per_second_); |
460 return base::TimeDelta::FromMicroseconds(base::Time::kMicrosecondsPerSecond * | 460 return base::TimeDelta::FromMicroseconds(base::Time::kMicrosecondsPerSecond * |
461 number_of_samples / | 461 number_of_samples / |
462 samples_per_second_); | 462 samples_per_second_); |
463 } | 463 } |
464 | 464 |
465 } // namespace media | 465 } // namespace media |
OLD | NEW |