2023-12-01 17:32:19 +00:00
|
|
|
// Copyright 2014 Google LLC. All rights reserved.
|
2014-04-15 23:51:32 +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
|
|
|
|
|
2017-12-20 00:56:36 +00:00
|
|
|
#ifndef PACKAGER_MEDIA_FORMATS_MP2T_ADTS_HEADER_H_
|
|
|
|
#define PACKAGER_MEDIA_FORMATS_MP2T_ADTS_HEADER_H_
|
2014-04-15 23:51:32 +00:00
|
|
|
|
2023-12-01 17:32:19 +00:00
|
|
|
#include <cstdint>
|
2014-04-15 23:51:32 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2023-12-01 17:32:19 +00:00
|
|
|
#include <packager/media/formats/mp2t/audio_header.h>
|
2014-09-30 23:52:58 +00:00
|
|
|
|
2016-05-20 21:19:33 +00:00
|
|
|
namespace shaka {
|
2014-04-15 23:51:32 +00:00
|
|
|
namespace media {
|
|
|
|
namespace mp2t {
|
|
|
|
|
2017-10-23 05:27:27 +00:00
|
|
|
/// Class which parses ADTS frame (header / metadata) and synthesizes
|
|
|
|
/// AudioSpecificConfig from audio frame content.
|
|
|
|
class AdtsHeader : public AudioHeader {
|
2014-04-15 23:51:32 +00:00
|
|
|
public:
|
2017-10-23 05:27:27 +00:00
|
|
|
AdtsHeader() = default;
|
|
|
|
~AdtsHeader() override = default;
|
|
|
|
|
|
|
|
/// @name AudioHeader implementation overrides.
|
|
|
|
/// @{
|
|
|
|
bool IsSyncWord(const uint8_t* buf) const override;
|
|
|
|
size_t GetMinFrameSize() const override;
|
2017-11-06 23:45:44 +00:00
|
|
|
size_t GetSamplesPerFrame() const override;
|
2017-10-23 05:27:27 +00:00
|
|
|
bool Parse(const uint8_t* adts_frame, size_t adts_frame_size) override;
|
|
|
|
size_t GetHeaderSize() const override;
|
|
|
|
size_t GetFrameSize() const override;
|
2019-10-01 17:15:58 +00:00
|
|
|
size_t GetFrameSizeWithoutParsing(const uint8_t* data,
|
|
|
|
size_t num_bytes) const override;
|
2017-10-23 05:27:27 +00:00
|
|
|
void GetAudioSpecificConfig(std::vector<uint8_t>* buffer) const override;
|
|
|
|
uint8_t GetObjectType() const override;
|
|
|
|
uint32_t GetSamplingFrequency() const override;
|
|
|
|
uint8_t GetNumChannels() const override;
|
|
|
|
/// @}
|
2014-04-15 23:51:32 +00:00
|
|
|
|
|
|
|
private:
|
2017-10-23 05:27:27 +00:00
|
|
|
AdtsHeader(const AdtsHeader&) = delete;
|
|
|
|
AdtsHeader& operator=(const AdtsHeader&) = delete;
|
|
|
|
|
|
|
|
uint8_t protection_absent_ = 0;
|
|
|
|
uint16_t frame_size_ = 0;
|
|
|
|
uint8_t profile_ = 0;
|
|
|
|
uint8_t sampling_frequency_index_ = 0;
|
|
|
|
uint8_t channel_configuration_ = 0;
|
2014-04-15 23:51:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mp2t
|
|
|
|
} // namespace media
|
2016-05-20 21:19:33 +00:00
|
|
|
} // namespace shaka
|
2014-04-15 23:51:32 +00:00
|
|
|
|
2017-12-20 00:56:36 +00:00
|
|
|
#endif // PACKAGER_MEDIA_FORMATS_MP2T_ADTS_HEADER_H_
|