| 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" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 return std::abs(timestamp_1.InMicroseconds() - timestamp_2.InMicroseconds()) > | 32 return std::abs(timestamp_1.InMicroseconds() - timestamp_2.InMicroseconds()) > |
| 33 kOutOfSyncThresholdInMicroseconds; | 33 kOutOfSyncThresholdInMicroseconds; |
| 34 } | 34 } |
| 35 | 35 |
| 36 DecryptingAudioDecoder::DecryptingAudioDecoder( | 36 DecryptingAudioDecoder::DecryptingAudioDecoder( |
| 37 const scoped_refptr<base::MessageLoopProxy>& message_loop, | 37 const scoped_refptr<base::MessageLoopProxy>& message_loop, |
| 38 const SetDecryptorReadyCB& set_decryptor_ready_cb) | 38 const SetDecryptorReadyCB& set_decryptor_ready_cb) |
| 39 : message_loop_(message_loop), | 39 : message_loop_(message_loop), |
| 40 weak_factory_(this), | 40 weak_factory_(this), |
| 41 state_(kUninitialized), | 41 state_(kUninitialized), |
| 42 demuxer_stream_(NULL), |
| 42 set_decryptor_ready_cb_(set_decryptor_ready_cb), | 43 set_decryptor_ready_cb_(set_decryptor_ready_cb), |
| 43 decryptor_(NULL), | 44 decryptor_(NULL), |
| 44 key_added_while_decode_pending_(false), | 45 key_added_while_decode_pending_(false), |
| 45 bits_per_channel_(0), | 46 bits_per_channel_(0), |
| 46 channel_layout_(CHANNEL_LAYOUT_NONE), | 47 channel_layout_(CHANNEL_LAYOUT_NONE), |
| 47 samples_per_second_(0), | 48 samples_per_second_(0), |
| 48 bytes_per_sample_(0), | 49 bytes_per_sample_(0), |
| 49 output_timestamp_base_(kNoTimestamp()), | 50 output_timestamp_base_(kNoTimestamp()), |
| 50 total_samples_decoded_(0) { | 51 total_samples_decoded_(0) { |
| 51 } | 52 } |
| 52 | 53 |
| 53 void DecryptingAudioDecoder::Initialize( | 54 void DecryptingAudioDecoder::Initialize( |
| 54 const scoped_refptr<DemuxerStream>& stream, | 55 DemuxerStream* stream, |
| 55 const PipelineStatusCB& status_cb, | 56 const PipelineStatusCB& status_cb, |
| 56 const StatisticsCB& statistics_cb) { | 57 const StatisticsCB& statistics_cb) { |
| 57 DVLOG(2) << "Initialize()"; | 58 DVLOG(2) << "Initialize()"; |
| 58 DCHECK(message_loop_->BelongsToCurrentThread()); | 59 DCHECK(message_loop_->BelongsToCurrentThread()); |
| 59 DCHECK_EQ(state_, kUninitialized) << state_; | 60 DCHECK_EQ(state_, kUninitialized) << state_; |
| 60 DCHECK(stream); | 61 DCHECK(stream); |
| 61 | 62 |
| 62 weak_this_ = weak_factory_.GetWeakPtr(); | 63 weak_this_ = weak_factory_.GetWeakPtr(); |
| 63 init_cb_ = BindToCurrentLoop(status_cb); | 64 init_cb_ = BindToCurrentLoop(status_cb); |
| 64 | 65 |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 | 478 |
| 478 base::TimeDelta DecryptingAudioDecoder::NumberOfSamplesToDuration( | 479 base::TimeDelta DecryptingAudioDecoder::NumberOfSamplesToDuration( |
| 479 int number_of_samples) const { | 480 int number_of_samples) const { |
| 480 DCHECK(samples_per_second_); | 481 DCHECK(samples_per_second_); |
| 481 return base::TimeDelta::FromMicroseconds(base::Time::kMicrosecondsPerSecond * | 482 return base::TimeDelta::FromMicroseconds(base::Time::kMicrosecondsPerSecond * |
| 482 number_of_samples / | 483 number_of_samples / |
| 483 samples_per_second_); | 484 samples_per_second_); |
| 484 } | 485 } |
| 485 | 486 |
| 486 } // namespace media | 487 } // namespace media |
| OLD | NEW |