DASH Media Packaging SDK
 All Classes Namespaces Functions Variables Typedefs Enumerator
audio_stream_info.h
1 // Copyright 2014 Google Inc. All rights reserved.
2 //
3 // Use of this source code is governed by a BSD-style
4 // license that can be found in the LICENSE file or at
5 // https://developers.google.com/open-source/licenses/bsd
6 
7 #ifndef MEDIA_BASE_AUDIO_STREAM_INFO_H_
8 #define MEDIA_BASE_AUDIO_STREAM_INFO_H_
9 
10 #include <vector>
11 
12 #include "packager/media/base/stream_info.h"
13 
14 namespace edash_packager {
15 namespace media {
16 
17 enum AudioCodec {
18  kUnknownAudioCodec = 0,
19  kCodecAAC,
20  kCodecAC3,
21  kCodecDTSC,
22  kCodecDTSE,
23  kCodecDTSH,
24  kCodecDTSL,
25  kCodecDTSM,
26  kCodecDTSP,
27  kCodecOpus,
28  kCodecVorbis,
29 
30  kNumAudioCodec
31 };
32 
34 class AudioStreamInfo : public StreamInfo {
35  public:
37  AudioStreamInfo(int track_id,
38  uint32_t time_scale,
39  uint64_t duration,
40  AudioCodec codec,
41  const std::string& codec_string,
42  const std::string& language,
43  uint8_t sample_bits,
44  uint8_t num_channels,
45  uint32_t sampling_frequency,
46  uint32_t max_bitrate,
47  uint32_t avg_bitrate,
48  const uint8_t* extra_data,
49  size_t extra_data_size,
50  bool is_encrypted);
51 
54  bool IsValidConfig() const override;
55  std::string ToString() const override;
57 
58  AudioCodec codec() const { return codec_; }
59  uint8_t sample_bits() const { return sample_bits_; }
60  uint8_t sample_bytes() const { return sample_bits_ / 8; }
61  uint8_t num_channels() const { return num_channels_; }
62  uint32_t sampling_frequency() const { return sampling_frequency_; }
63  uint32_t bytes_per_frame() const {
64  return static_cast<uint32_t>(num_channels_) * sample_bits_ / 8;
65  }
66  uint32_t max_bitrate() const { return max_bitrate_; }
67  uint32_t avg_bitrate() const { return avg_bitrate_; }
68 
69  void set_codec(AudioCodec codec) { codec_ = codec; }
70  void set_sampling_frequency(const uint32_t sampling_frequency) {
71  sampling_frequency_ = sampling_frequency;
72  }
73 
76  static std::string GetCodecString(AudioCodec codec,
77  uint8_t audio_object_type);
78 
79  private:
80  ~AudioStreamInfo() override;
81 
82  AudioCodec codec_;
83  uint8_t sample_bits_;
84  uint8_t num_channels_;
85  uint32_t sampling_frequency_;
86  uint32_t max_bitrate_;
87  uint32_t avg_bitrate_;
88 
89  // Not using DISALLOW_COPY_AND_ASSIGN here intentionally to allow the compiler
90  // generated copy constructor and assignment operator. Since the extra data is
91  // typically small, the performance impact is minimal.
92 };
93 
94 } // namespace media
95 } // namespace edash_packager
96 
97 #endif // MEDIA_BASE_AUDIO_STREAM_INFO_H_
Holds audio stream information.
std::string ToString() const override
Abstract class holds stream information.
Definition: stream_info.h:26
AudioStreamInfo(int track_id, uint32_t time_scale, uint64_t duration, AudioCodec codec, const std::string &codec_string, const std::string &language, uint8_t sample_bits, uint8_t num_channels, uint32_t sampling_frequency, uint32_t max_bitrate, uint32_t avg_bitrate, const uint8_t *extra_data, size_t extra_data_size, bool is_encrypted)
Construct an initialized audio stream info object.
static std::string GetCodecString(AudioCodec codec, uint8_t audio_object_type)