| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this |
| 2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
| 3 // LICENSE file. | 3 // LICENSE file. |
| 4 | 4 |
| 5 #include "media/base/data_buffer.h" | 5 #include "media/base/data_buffer.h" |
| 6 #include "media/filters/ffmpeg_audio_decoder.h" | 6 #include "media/filters/ffmpeg_audio_decoder.h" |
| 7 #include "media/filters/ffmpeg_common.h" | 7 #include "media/filters/ffmpeg_common.h" |
| 8 #include "media/filters/ffmpeg_demuxer.h" | 8 #include "media/filters/ffmpeg_demuxer.h" |
| 9 | 9 |
| 10 namespace media { | 10 namespace media { |
| 11 | 11 |
| 12 // Size of the decoded audio buffer. | 12 // Size of the decoded audio buffer. |
| 13 const size_t FFmpegAudioDecoder::kOutputBufferSize = | 13 const size_t FFmpegAudioDecoder::kOutputBufferSize = |
| 14 AVCODEC_MAX_AUDIO_FRAME_SIZE; | 14 AVCODEC_MAX_AUDIO_FRAME_SIZE; |
| 15 | 15 |
| 16 FFmpegAudioDecoder::FFmpegAudioDecoder() | 16 FFmpegAudioDecoder::FFmpegAudioDecoder() |
| 17 : DecoderBase<AudioDecoder, Buffer>("AudioDecoderThread"), | 17 : codec_context_(NULL) { |
| 18 codec_context_(NULL) { | |
| 19 } | 18 } |
| 20 | 19 |
| 21 FFmpegAudioDecoder::~FFmpegAudioDecoder() { | 20 FFmpegAudioDecoder::~FFmpegAudioDecoder() { |
| 22 } | 21 } |
| 23 | 22 |
| 24 // static | 23 // static |
| 25 bool FFmpegAudioDecoder::IsMediaFormatSupported(const MediaFormat& format) { | 24 bool FFmpegAudioDecoder::IsMediaFormatSupported(const MediaFormat& format) { |
| 26 std::string mime_type; | 25 std::string mime_type; |
| 27 return format.GetAsString(MediaFormat::kMimeType, &mime_type) && | 26 return format.GetAsString(MediaFormat::kMimeType, &mime_type) && |
| 28 mime_type::kFFmpegAudio == mime_type; | 27 mime_type::kFFmpegAudio == mime_type; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 base::TimeDelta FFmpegAudioDecoder::CalculateDuration(size_t size) { | 141 base::TimeDelta FFmpegAudioDecoder::CalculateDuration(size_t size) { |
| 143 int64 denominator = codec_context_->channels * | 142 int64 denominator = codec_context_->channels * |
| 144 av_get_bits_per_sample_format(codec_context_->sample_fmt) / 8 * | 143 av_get_bits_per_sample_format(codec_context_->sample_fmt) / 8 * |
| 145 codec_context_->sample_rate; | 144 codec_context_->sample_rate; |
| 146 double microseconds = size / | 145 double microseconds = size / |
| 147 (denominator / static_cast<double>(base::Time::kMicrosecondsPerSecond)); | 146 (denominator / static_cast<double>(base::Time::kMicrosecondsPerSecond)); |
| 148 return base::TimeDelta::FromMicroseconds(static_cast<int64>(microseconds)); | 147 return base::TimeDelta::FromMicroseconds(static_cast<int64>(microseconds)); |
| 149 } | 148 } |
| 150 | 149 |
| 151 } // namespace | 150 } // namespace |
| OLD | NEW |