2022-08-26 15:44:59 +00:00
|
|
|
// Copyright 2014 Google LLC. All rights reserved.
|
2014-02-14 23:21:05 +00:00
|
|
|
//
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file or at
|
|
|
|
// https://developers.google.com/open-source/licenses/bsd
|
2013-09-24 04:17:12 +00:00
|
|
|
|
2017-12-20 00:56:36 +00:00
|
|
|
#ifndef PACKAGER_MEDIA_BASE_AUDIO_STREAM_INFO_H_
|
|
|
|
#define PACKAGER_MEDIA_BASE_AUDIO_STREAM_INFO_H_
|
2013-09-24 04:17:12 +00:00
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
2023-10-10 23:51:11 +00:00
|
|
|
#include <packager/media/base/stream_info.h>
|
2013-09-24 04:17:12 +00:00
|
|
|
|
2016-05-20 21:19:33 +00:00
|
|
|
namespace shaka {
|
2013-09-24 04:17:12 +00:00
|
|
|
namespace media {
|
|
|
|
|
2014-01-24 18:46:46 +00:00
|
|
|
/// Holds audio stream information.
|
2013-09-24 04:17:12 +00:00
|
|
|
class AudioStreamInfo : public StreamInfo {
|
|
|
|
public:
|
2014-01-24 18:46:46 +00:00
|
|
|
/// Construct an initialized audio stream info object.
|
2021-08-04 18:56:44 +00:00
|
|
|
AudioStreamInfo(int track_id,
|
|
|
|
int32_t time_scale,
|
|
|
|
int64_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,
|
2013-09-24 04:17:12 +00:00
|
|
|
bool is_encrypted);
|
|
|
|
|
2017-01-24 00:55:02 +00:00
|
|
|
~AudioStreamInfo() override;
|
|
|
|
|
2014-01-24 18:46:46 +00:00
|
|
|
/// @name StreamInfo implementation overrides.
|
|
|
|
/// @{
|
2015-07-22 23:40:45 +00:00
|
|
|
bool IsValidConfig() const override;
|
|
|
|
std::string ToString() const override;
|
2017-09-12 17:24:24 +00:00
|
|
|
std::unique_ptr<StreamInfo> Clone() const override;
|
2014-01-24 18:46:46 +00:00
|
|
|
/// @}
|
2013-09-24 04:17:12 +00:00
|
|
|
|
2014-09-30 21:52:21 +00:00
|
|
|
uint8_t sample_bits() const { return sample_bits_; }
|
|
|
|
uint8_t sample_bytes() const { return sample_bits_ / 8; }
|
|
|
|
uint8_t num_channels() const { return num_channels_; }
|
|
|
|
uint32_t sampling_frequency() const { return sampling_frequency_; }
|
|
|
|
uint32_t bytes_per_frame() const {
|
|
|
|
return static_cast<uint32_t>(num_channels_) * sample_bits_ / 8;
|
2013-10-14 20:55:48 +00:00
|
|
|
}
|
2016-05-05 22:26:48 +00:00
|
|
|
uint64_t seek_preroll_ns() const { return seek_preroll_ns_; }
|
|
|
|
uint64_t codec_delay_ns() const { return codec_delay_ns_; }
|
2016-01-04 18:57:05 +00:00
|
|
|
uint32_t max_bitrate() const { return max_bitrate_; }
|
|
|
|
uint32_t avg_bitrate() const { return avg_bitrate_; }
|
2013-10-14 20:55:48 +00:00
|
|
|
|
2014-09-30 21:52:21 +00:00
|
|
|
void set_sampling_frequency(const uint32_t sampling_frequency) {
|
2014-07-14 21:35:57 +00:00
|
|
|
sampling_frequency_ = sampling_frequency;
|
|
|
|
}
|
|
|
|
|
2014-01-24 18:46:46 +00:00
|
|
|
/// @param audio_object_type is only used by AAC Codec, ignored otherwise.
|
|
|
|
/// @return The codec string.
|
2016-07-27 00:51:08 +00:00
|
|
|
static std::string GetCodecString(Codec codec, uint8_t audio_object_type);
|
2013-09-24 04:17:12 +00:00
|
|
|
|
|
|
|
private:
|
2014-09-30 21:52:21 +00:00
|
|
|
uint8_t sample_bits_;
|
|
|
|
uint8_t num_channels_;
|
|
|
|
uint32_t sampling_frequency_;
|
2016-05-05 22:26:48 +00:00
|
|
|
uint64_t seek_preroll_ns_;
|
|
|
|
uint64_t codec_delay_ns_;
|
2016-01-04 18:57:05 +00:00
|
|
|
uint32_t max_bitrate_;
|
|
|
|
uint32_t avg_bitrate_;
|
2013-09-24 04:17:12 +00:00
|
|
|
|
|
|
|
// Not using DISALLOW_COPY_AND_ASSIGN here intentionally to allow the compiler
|
|
|
|
// generated copy constructor and assignment operator. Since the extra data is
|
|
|
|
// typically small, the performance impact is minimal.
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace media
|
2016-05-20 21:19:33 +00:00
|
|
|
} // namespace shaka
|
2013-09-24 04:17:12 +00:00
|
|
|
|
2017-12-20 00:56:36 +00:00
|
|
|
#endif // PACKAGER_MEDIA_BASE_AUDIO_STREAM_INFO_H_
|