Shaka Packager SDK
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 PACKAGER_MEDIA_BASE_AUDIO_STREAM_INFO_H_
8 #define PACKAGER_MEDIA_BASE_AUDIO_STREAM_INFO_H_
9 
10 #include <vector>
11 
12 #include "packager/media/base/stream_info.h"
13 
14 namespace shaka {
15 namespace media {
16 
18 class AudioStreamInfo : public StreamInfo {
19  public:
21  AudioStreamInfo(int track_id, uint32_t time_scale, uint64_t duration,
22  Codec codec, const std::string& codec_string,
23  const uint8_t* codec_config, size_t codec_config_size,
24  uint8_t sample_bits, uint8_t num_channels,
25  uint32_t sampling_frequency, uint64_t seek_preroll_ns,
26  uint64_t codec_delay_ns, uint32_t max_bitrate,
27  uint32_t avg_bitrate, const std::string& language,
28  bool is_encrypted);
29 
30  ~AudioStreamInfo() override;
31 
34  bool IsValidConfig() const override;
35  std::string ToString() const override;
36  std::unique_ptr<StreamInfo> Clone() const override;
38 
39  uint8_t sample_bits() const { return sample_bits_; }
40  uint8_t sample_bytes() const { return sample_bits_ / 8; }
41  uint8_t num_channels() const { return num_channels_; }
42  uint32_t sampling_frequency() const { return sampling_frequency_; }
43  uint32_t bytes_per_frame() const {
44  return static_cast<uint32_t>(num_channels_) * sample_bits_ / 8;
45  }
46  uint64_t seek_preroll_ns() const { return seek_preroll_ns_; }
47  uint64_t codec_delay_ns() const { return codec_delay_ns_; }
48  uint32_t max_bitrate() const { return max_bitrate_; }
49  uint32_t avg_bitrate() const { return avg_bitrate_; }
50 
51  void set_sampling_frequency(const uint32_t sampling_frequency) {
52  sampling_frequency_ = sampling_frequency;
53  }
54 
57  static std::string GetCodecString(Codec codec, uint8_t audio_object_type);
58 
59  private:
60  uint8_t sample_bits_;
61  uint8_t num_channels_;
62  uint32_t sampling_frequency_;
63  uint64_t seek_preroll_ns_;
64  uint64_t codec_delay_ns_;
65  uint32_t max_bitrate_;
66  uint32_t avg_bitrate_;
67 
68  // Not using DISALLOW_COPY_AND_ASSIGN here intentionally to allow the compiler
69  // generated copy constructor and assignment operator. Since the extra data is
70  // typically small, the performance impact is minimal.
71 };
72 
73 } // namespace media
74 } // namespace shaka
75 
76 #endif // PACKAGER_MEDIA_BASE_AUDIO_STREAM_INFO_H_
Abstract class holds stream information.
Definition: stream_info.h:58
std::string ToString() const override
All the methods that are virtual are virtual for mocking.
bool IsValidConfig() const override
static std::string GetCodecString(Codec codec, uint8_t audio_object_type)
std::unique_ptr< StreamInfo > Clone() const override
AudioStreamInfo(int track_id, uint32_t time_scale, uint64_t duration, Codec codec, const std::string &codec_string, const uint8_t *codec_config, size_t codec_config_size, uint8_t sample_bits, uint8_t num_channels, uint32_t sampling_frequency, uint64_t seek_preroll_ns, uint64_t codec_delay_ns, uint32_t max_bitrate, uint32_t avg_bitrate, const std::string &language, bool is_encrypted)
Construct an initialized audio stream info object.
Holds audio stream information.