DASH Media Packaging SDK
 All Classes Namespaces Functions Variables Typedefs
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 
33  kNumAudioCodec
34 };
35 
37 class AudioStreamInfo : public StreamInfo {
38  public:
40  AudioStreamInfo(int track_id,
41  uint32_t time_scale,
42  uint64_t duration,
43  AudioCodec codec,
44  const std::string& codec_string,
45  const std::string& language,
46  uint8_t sample_bits,
47  uint8_t num_channels,
48  uint32_t sampling_frequency,
49  const uint8_t* extra_data,
50  size_t extra_data_size,
51  bool is_encrypted);
52 
55  bool IsValidConfig() const override;
56  std::string ToString() const override;
58 
59  AudioCodec codec() const { return codec_; }
60  uint8_t sample_bits() const { return sample_bits_; }
61  uint8_t sample_bytes() const { return sample_bits_ / 8; }
62  uint8_t num_channels() const { return num_channels_; }
63  uint32_t sampling_frequency() const { return sampling_frequency_; }
64  uint32_t bytes_per_frame() const {
65  return static_cast<uint32_t>(num_channels_) * sample_bits_ / 8;
66  }
67 
68  void set_sampling_frequency(const uint32_t sampling_frequency) {
69  sampling_frequency_ = sampling_frequency;
70  }
71 
72 
75  static std::string GetCodecString(AudioCodec codec,
76  uint8_t audio_object_type);
77 
78  private:
79  ~AudioStreamInfo() override;
80 
81  AudioCodec codec_;
82  uint8_t sample_bits_;
83  uint8_t num_channels_;
84  uint32_t sampling_frequency_;
85 
86  // Not using DISALLOW_COPY_AND_ASSIGN here intentionally to allow the compiler
87  // generated copy constructor and assignment operator. Since the extra data is
88  // typically small, the performance impact is minimal.
89 };
90 
91 } // namespace media
92 } // namespace edash_packager
93 
94 #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)