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