| 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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 | 192 |
| 193 // Success! | 193 // Success! |
| 194 const AudioDecoderConfig& config = demuxer_stream_->audio_decoder_config(); | 194 const AudioDecoderConfig& config = demuxer_stream_->audio_decoder_config(); |
| 195 bits_per_channel_ = config.bits_per_channel(); | 195 bits_per_channel_ = config.bits_per_channel(); |
| 196 channel_layout_ = config.channel_layout(); | 196 channel_layout_ = config.channel_layout(); |
| 197 samples_per_second_ = config.samples_per_second(); | 197 samples_per_second_ = config.samples_per_second(); |
| 198 const int kBitsPerByte = 8; | 198 const int kBitsPerByte = 8; |
| 199 bytes_per_sample_ = ChannelLayoutToChannelCount(channel_layout_) * | 199 bytes_per_sample_ = ChannelLayoutToChannelCount(channel_layout_) * |
| 200 bits_per_channel_ / kBitsPerByte; | 200 bits_per_channel_ / kBitsPerByte; |
| 201 | 201 |
| 202 decryptor_->RegisterKeyAddedCB( | 202 decryptor_->RegisterNewKeyCB( |
| 203 Decryptor::kAudio, BIND_TO_LOOP(&DecryptingAudioDecoder::OnKeyAdded)); | 203 Decryptor::kAudio, BIND_TO_LOOP(&DecryptingAudioDecoder::OnKeyAdded)); |
| 204 | 204 |
| 205 state_ = kIdle; | 205 state_ = kIdle; |
| 206 base::ResetAndReturn(&init_cb_).Run(PIPELINE_OK); | 206 base::ResetAndReturn(&init_cb_).Run(PIPELINE_OK); |
| 207 } | 207 } |
| 208 | 208 |
| 209 void DecryptingAudioDecoder::DoRead(const ReadCB& read_cb) { | 209 void DecryptingAudioDecoder::DoRead(const ReadCB& read_cb) { |
| 210 DVLOG(3) << "DoRead()"; | 210 DVLOG(3) << "DoRead()"; |
| 211 DCHECK(message_loop_->BelongsToCurrentThread()); | 211 DCHECK(message_loop_->BelongsToCurrentThread()); |
| 212 DCHECK(state_ == kIdle || state_ == kDecodeFinished) << state_; | 212 DCHECK(state_ == kIdle || state_ == kDecodeFinished) << state_; |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 | 452 |
| 453 base::TimeDelta DecryptingAudioDecoder::NumberOfSamplesToDuration( | 453 base::TimeDelta DecryptingAudioDecoder::NumberOfSamplesToDuration( |
| 454 int number_of_samples) const { | 454 int number_of_samples) const { |
| 455 DCHECK(samples_per_second_); | 455 DCHECK(samples_per_second_); |
| 456 return base::TimeDelta::FromMicroseconds(base::Time::kMicrosecondsPerSecond * | 456 return base::TimeDelta::FromMicroseconds(base::Time::kMicrosecondsPerSecond * |
| 457 number_of_samples / | 457 number_of_samples / |
| 458 samples_per_second_); | 458 samples_per_second_); |
| 459 } | 459 } |
| 460 | 460 |
| 461 } // namespace media | 461 } // namespace media |
| OLD | NEW |