diff options
author | scherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-21 22:44:04 +0000 |
---|---|---|
committer | scherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-21 22:44:04 +0000 |
commit | 1ab1c24bda1b30b57e040b3b077a001d095fcab3 (patch) | |
tree | 59e01bd62cc44596a5d8df6c7e63e6414846b4a8 /media/base/audio_decoder_config.cc | |
parent | 735586ec444f701f94219fbb59ff01f11b064071 (diff) | |
download | chromium_src-1ab1c24bda1b30b57e040b3b077a001d095fcab3.zip chromium_src-1ab1c24bda1b30b57e040b3b077a001d095fcab3.tar.gz chromium_src-1ab1c24bda1b30b57e040b3b077a001d095fcab3.tar.bz2 |
Introduce AudioDecoderConfig to migrate away from GetAVStream().
Instead add DemuxerStream::audio_decoder_config() to break FFmpegAudioDecoder's dependency on the AVCodecContext object maintained by FFmpegDemuxer.
Review URL: http://codereview.chromium.org/7867051
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@102183 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/base/audio_decoder_config.cc')
-rw-r--r-- | media/base/audio_decoder_config.cc | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/media/base/audio_decoder_config.cc b/media/base/audio_decoder_config.cc new file mode 100644 index 0000000..80b23e2 --- /dev/null +++ b/media/base/audio_decoder_config.cc @@ -0,0 +1,87 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "media/base/audio_decoder_config.h" + +#include "base/logging.h" +#include "media/base/limits.h" + +namespace media { + +AudioDecoderConfig::AudioDecoderConfig() + : codec_(kUnknownAudioCodec), + bits_per_channel_(0), + channel_layout_(CHANNEL_LAYOUT_UNSUPPORTED), + samples_per_second_(0), + extra_data_size_(0) { +} + +AudioDecoderConfig::AudioDecoderConfig(AudioCodec codec, + int bits_per_channel, + ChannelLayout channel_layout, + int samples_per_second, + const uint8* extra_data, + size_t extra_data_size) { + Initialize(codec, bits_per_channel, channel_layout, samples_per_second, + extra_data, extra_data_size); +} + +void AudioDecoderConfig::Initialize(AudioCodec codec, + int bits_per_channel, + ChannelLayout channel_layout, + int samples_per_second, + const uint8* extra_data, + size_t extra_data_size) { + CHECK((extra_data_size != 0) == (extra_data != NULL)); + + codec_ = codec; + bits_per_channel_ = bits_per_channel; + channel_layout_ = channel_layout; + samples_per_second_ = samples_per_second; + extra_data_size_ = extra_data_size; + + if (extra_data_size_ > 0) { + extra_data_.reset(new uint8[extra_data_size_]); + memcpy(extra_data_.get(), extra_data, extra_data_size_); + } else { + extra_data_.reset(); + } +} + +AudioDecoderConfig::~AudioDecoderConfig() {} + +bool AudioDecoderConfig::IsValidConfig() const { + return codec_ != kUnknownAudioCodec && + channel_layout_ != CHANNEL_LAYOUT_UNSUPPORTED && + bits_per_channel_ > 0 && + bits_per_channel_ <= Limits::kMaxBitsPerSample && + samples_per_second_ > 0 && + samples_per_second_ <= Limits::kMaxSampleRate; +} + +AudioCodec AudioDecoderConfig::codec() const { + return codec_; +} + +int AudioDecoderConfig::bits_per_channel() const { + return bits_per_channel_; +} + +ChannelLayout AudioDecoderConfig::channel_layout() const { + return channel_layout_; +} + +int AudioDecoderConfig::samples_per_second() const { + return samples_per_second_; +} + +uint8* AudioDecoderConfig::extra_data() const { + return extra_data_.get(); +} + +size_t AudioDecoderConfig::extra_data_size() const { + return extra_data_size_; +} + +} // namespace media |