7 #include "packager/media/base/audio_stream_info.h"
11 #include "packager/base/logging.h"
12 #include "packager/base/strings/string_number_conversions.h"
13 #include "packager/base/strings/stringprintf.h"
14 #include "packager/media/base/limits.h"
20 std::string AudioCodecToString(Codec codec) {
51 NOTIMPLEMENTED() <<
"Unknown Audio Codec: " << codec;
52 return "UnknownCodec";
58 int track_id, uint32_t time_scale, uint64_t duration, Codec codec,
59 const std::string& codec_string,
const uint8_t* codec_config,
60 size_t codec_config_size, uint8_t sample_bits, uint8_t num_channels,
61 uint32_t sampling_frequency, uint64_t seek_preroll_ns,
62 uint64_t codec_delay_ns, uint32_t max_bitrate, uint32_t avg_bitrate,
63 const std::string& language,
bool is_encrypted)
64 :
StreamInfo(kStreamAudio, track_id, time_scale, duration, codec,
65 codec_string, codec_config, codec_config_size, language,
67 sample_bits_(sample_bits),
68 num_channels_(num_channels),
69 sampling_frequency_(sampling_frequency),
70 seek_preroll_ns_(seek_preroll_ns),
71 codec_delay_ns_(codec_delay_ns),
72 max_bitrate_(max_bitrate),
73 avg_bitrate_(avg_bitrate) {}
75 AudioStreamInfo::~AudioStreamInfo() {}
78 return codec() != kUnknownCodec && num_channels_ != 0 &&
79 num_channels_ <= limits::kMaxChannels && sample_bits_ > 0 &&
80 sample_bits_ <= limits::kMaxBitsPerSample && sampling_frequency_ > 0 &&
81 sampling_frequency_ <= limits::kMaxSampleRate;
85 std::string str = base::StringPrintf(
86 "%s codec: %s\n sample_bits: %d\n num_channels: %d\n "
87 "sampling_frequency: %d\n language: %s\n",
89 sample_bits_, num_channels_, sampling_frequency_, language().c_str());
90 if (seek_preroll_ns_ != 0) {
91 base::StringAppendF(&str,
" seek_preroll_ns: %" PRIu64
"\n",
94 if (codec_delay_ns_ != 0) {
95 base::StringAppendF(&str,
" codec_delay_ns: %" PRIu64
"\n",
106 uint8_t audio_object_type) {
109 return "mp4a.40." + base::UintToString(audio_object_type);
131 return base::StringPrintf(
132 "ac-4.%02d.%02d.%02d", (audio_object_type & 0xE0) >> 5,
133 (audio_object_type & 0x18) >> 3, audio_object_type & 0x7);
143 NOTIMPLEMENTED() <<
"Codec: " << codec;
All the methods that are virtual are virtual for mocking.