Shaka Packager SDK
Loading...
Searching...
No Matches
audio_stream_info.h
1// Copyright 2014 Google LLC. 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
14namespace shaka {
15namespace media {
16
19 public:
21 AudioStreamInfo(int track_id,
22 int32_t time_scale,
23 int64_t duration,
24 Codec codec,
25 const std::string& codec_string,
26 const uint8_t* codec_config,
27 size_t codec_config_size,
28 uint8_t sample_bits,
29 uint8_t num_channels,
30 uint32_t sampling_frequency,
31 uint64_t seek_preroll_ns,
32 uint64_t codec_delay_ns,
33 uint32_t max_bitrate,
34 uint32_t avg_bitrate,
35 const std::string& language,
36 bool is_encrypted);
37
38 ~AudioStreamInfo() override;
39
42 bool IsValidConfig() const override;
43 std::string ToString() const override;
44 std::unique_ptr<StreamInfo> Clone() const override;
46
47 uint8_t sample_bits() const { return sample_bits_; }
48 uint8_t sample_bytes() const { return sample_bits_ / 8; }
49 uint8_t num_channels() const { return num_channels_; }
50 uint32_t sampling_frequency() const { return sampling_frequency_; }
51 uint32_t bytes_per_frame() const {
52 return static_cast<uint32_t>(num_channels_) * sample_bits_ / 8;
53 }
54 uint64_t seek_preroll_ns() const { return seek_preroll_ns_; }
55 uint64_t codec_delay_ns() const { return codec_delay_ns_; }
56 uint32_t max_bitrate() const { return max_bitrate_; }
57 uint32_t avg_bitrate() const { return avg_bitrate_; }
58
59 void set_sampling_frequency(const uint32_t sampling_frequency) {
60 sampling_frequency_ = sampling_frequency;
61 }
62
63 void set_max_bitrate(const uint32_t max_bitrate) {
64 max_bitrate_ = max_bitrate;
65 }
66
69 static std::string GetCodecString(Codec codec, uint8_t audio_object_type);
70
71 private:
72 uint8_t sample_bits_;
73 uint8_t num_channels_;
74 uint32_t sampling_frequency_;
75 uint64_t seek_preroll_ns_;
76 uint64_t codec_delay_ns_;
77 uint32_t max_bitrate_;
78 uint32_t avg_bitrate_;
79
80 // Not using DISALLOW_COPY_AND_ASSIGN here intentionally to allow the compiler
81 // generated copy constructor and assignment operator. Since the extra data is
82 // typically small, the performance impact is minimal.
83};
84
85} // namespace media
86} // namespace shaka
87
88#endif // PACKAGER_MEDIA_BASE_AUDIO_STREAM_INFO_H_
Holds audio stream information.
std::unique_ptr< StreamInfo > Clone() const override
bool IsValidConfig() const override
std::string ToString() const override
static std::string GetCodecString(Codec codec, uint8_t audio_object_type)
Abstract class holds stream information.
Definition stream_info.h:71
All the methods that are virtual are virtual for mocking.