2014-02-14 23:21:05 +00:00
|
|
|
// Copyright 2014 Google Inc. All rights reserved.
|
|
|
|
//
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file or at
|
|
|
|
// https://developers.google.com/open-source/licenses/bsd
|
2013-09-24 04:17:12 +00:00
|
|
|
|
|
|
|
#ifndef MEDIA_BASE_AUDIO_STREAM_INFO_H_
|
|
|
|
#define MEDIA_BASE_AUDIO_STREAM_INFO_H_
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "media/base/stream_info.h"
|
|
|
|
|
|
|
|
namespace media {
|
|
|
|
|
|
|
|
enum AudioCodec {
|
|
|
|
kUnknownAudioCodec = 0,
|
|
|
|
kCodecAAC,
|
|
|
|
kCodecMP3,
|
|
|
|
kCodecPCM,
|
|
|
|
kCodecVorbis,
|
|
|
|
kCodecFLAC,
|
|
|
|
kCodecAMR_NB,
|
|
|
|
kCodecAMR_WB,
|
|
|
|
kCodecPCM_MULAW,
|
|
|
|
kCodecGSM_MS,
|
|
|
|
kCodecPCM_S16BE,
|
|
|
|
kCodecPCM_S24BE,
|
|
|
|
kCodecOpus,
|
|
|
|
kCodecEAC3,
|
|
|
|
|
|
|
|
kNumAudioCodec
|
|
|
|
};
|
|
|
|
|
2014-01-24 18:46:46 +00:00
|
|
|
/// Holds audio stream information.
|
2013-09-24 04:17:12 +00:00
|
|
|
class AudioStreamInfo : public StreamInfo {
|
|
|
|
public:
|
2014-01-24 18:46:46 +00:00
|
|
|
/// Construct an initialized audio stream info object.
|
2013-09-24 04:17:12 +00:00
|
|
|
AudioStreamInfo(int track_id,
|
2013-10-14 20:55:48 +00:00
|
|
|
uint32 time_scale,
|
|
|
|
uint64 duration,
|
2013-09-24 04:17:12 +00:00
|
|
|
AudioCodec codec,
|
2013-10-14 20:55:48 +00:00
|
|
|
const std::string& codec_string,
|
|
|
|
const std::string& language,
|
|
|
|
uint8 sample_bits,
|
|
|
|
uint8 num_channels,
|
|
|
|
uint32 sampling_frequency,
|
2013-09-24 04:17:12 +00:00
|
|
|
const uint8* extra_data,
|
|
|
|
size_t extra_data_size,
|
|
|
|
bool is_encrypted);
|
|
|
|
|
2014-01-24 18:46:46 +00:00
|
|
|
/// @name StreamInfo implementation overrides.
|
|
|
|
/// @{
|
2013-10-14 20:55:48 +00:00
|
|
|
virtual bool IsValidConfig() const OVERRIDE;
|
|
|
|
virtual std::string ToString() const OVERRIDE;
|
2014-01-24 18:46:46 +00:00
|
|
|
/// @}
|
2013-09-24 04:17:12 +00:00
|
|
|
|
|
|
|
AudioCodec codec() const { return codec_; }
|
2013-10-14 20:55:48 +00:00
|
|
|
uint8 sample_bits() const { return sample_bits_; }
|
|
|
|
uint8 sample_bytes() const { return sample_bits_ / 8; }
|
|
|
|
uint8 num_channels() const { return num_channels_; }
|
|
|
|
uint32 sampling_frequency() const { return sampling_frequency_; }
|
|
|
|
uint32 bytes_per_frame() const {
|
|
|
|
return static_cast<uint32>(num_channels_) * sample_bits_ / 8;
|
|
|
|
}
|
|
|
|
|
2014-07-14 21:35:57 +00:00
|
|
|
void set_sampling_frequency(const uint32 sampling_frequency) {
|
|
|
|
sampling_frequency_ = sampling_frequency;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-24 18:46:46 +00:00
|
|
|
/// @param audio_object_type is only used by AAC Codec, ignored otherwise.
|
|
|
|
/// @return The codec string.
|
2013-10-14 20:55:48 +00:00
|
|
|
static std::string GetCodecString(AudioCodec codec, uint8 audio_object_type);
|
2013-09-24 04:17:12 +00:00
|
|
|
|
|
|
|
private:
|
2014-01-16 00:52:07 +00:00
|
|
|
virtual ~AudioStreamInfo();
|
|
|
|
|
2013-09-24 04:17:12 +00:00
|
|
|
AudioCodec codec_;
|
2013-10-14 20:55:48 +00:00
|
|
|
uint8 sample_bits_;
|
|
|
|
uint8 num_channels_;
|
|
|
|
uint32 sampling_frequency_;
|
2013-09-24 04:17:12 +00:00
|
|
|
|
|
|
|
// Not using DISALLOW_COPY_AND_ASSIGN here intentionally to allow the compiler
|
|
|
|
// generated copy constructor and assignment operator. Since the extra data is
|
|
|
|
// typically small, the performance impact is minimal.
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace media
|
|
|
|
|
|
|
|
#endif // MEDIA_BASE_AUDIO_STREAM_INFO_H_
|