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