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  kCodecMP3,
21  kCodecPCM,
22  kCodecVorbis,
23  kCodecFLAC,
24  kCodecAMR_NB,
25  kCodecAMR_WB,
26  kCodecPCM_MULAW,
27  kCodecGSM_MS,
28  kCodecPCM_S16BE,
29  kCodecPCM_S24BE,
30  kCodecOpus,
31  kCodecEAC3,
32  kCodecDTSC,
33  kCodecDTSH,
34  kCodecDTSL,
35  kCodecDTSE,
36  kCodecDTSP,
37  kCodecDTSM,
38 
39  kNumAudioCodec
40 };
41 
43 class AudioStreamInfo : public StreamInfo {
44  public:
46  AudioStreamInfo(int track_id,
47  uint32_t time_scale,
48  uint64_t duration,
49  AudioCodec codec,
50  const std::string& codec_string,
51  const std::string& language,
52  uint8_t sample_bits,
53  uint8_t num_channels,
54  uint32_t sampling_frequency,
55  const uint8_t* extra_data,
56  size_t extra_data_size,
57  bool is_encrypted);
58 
61  bool IsValidConfig() const override;
62  std::string ToString() const override;
64 
65  AudioCodec codec() const { return codec_; }
66  uint8_t sample_bits() const { return sample_bits_; }
67  uint8_t sample_bytes() const { return sample_bits_ / 8; }
68  uint8_t num_channels() const { return num_channels_; }
69  uint32_t sampling_frequency() const { return sampling_frequency_; }
70  uint32_t bytes_per_frame() const {
71  return static_cast<uint32_t>(num_channels_) * sample_bits_ / 8;
72  }
73 
74  void set_sampling_frequency(const uint32_t sampling_frequency) {
75  sampling_frequency_ = sampling_frequency;
76  }
77 
78 
81  static std::string GetCodecString(AudioCodec codec,
82  uint8_t audio_object_type);
83 
84  private:
85  ~AudioStreamInfo() override;
86 
87  AudioCodec codec_;
88  uint8_t sample_bits_;
89  uint8_t num_channels_;
90  uint32_t sampling_frequency_;
91 
92  // Not using DISALLOW_COPY_AND_ASSIGN here intentionally to allow the compiler
93  // generated copy constructor and assignment operator. Since the extra data is
94  // typically small, the performance impact is minimal.
95 };
96 
97 } // namespace media
98 } // namespace edash_packager
99 
100 #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, 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)