2022-08-26 15:44:59 +00:00
|
|
|
// Copyright 2016 Google LLC. All rights reserved.
|
2016-02-03 22:13:57 +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_CODECS_VIDEO_SLICE_HEADER_PARSER_H_
|
|
|
|
#define PACKAGER_MEDIA_CODECS_VIDEO_SLICE_HEADER_PARSER_H_
|
2016-02-03 22:13:57 +00:00
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
2023-10-14 16:36:01 +00:00
|
|
|
#include <packager/macros/classes.h>
|
2023-10-10 23:51:11 +00:00
|
|
|
#include <packager/media/codecs/h264_parser.h>
|
|
|
|
#include <packager/media/codecs/h265_parser.h>
|
2016-02-03 22:13:57 +00:00
|
|
|
|
2016-05-20 21:19:33 +00:00
|
|
|
namespace shaka {
|
2016-02-03 22:13:57 +00:00
|
|
|
namespace media {
|
|
|
|
|
|
|
|
class VideoSliceHeaderParser {
|
|
|
|
public:
|
|
|
|
VideoSliceHeaderParser() {}
|
|
|
|
virtual ~VideoSliceHeaderParser() {}
|
|
|
|
|
|
|
|
/// Adds decoder configuration from the given data. This must be called
|
|
|
|
/// once before any calls to GetHeaderSize.
|
|
|
|
virtual bool Initialize(
|
|
|
|
const std::vector<uint8_t>& decoder_configuration) = 0;
|
|
|
|
|
2019-07-16 22:09:25 +00:00
|
|
|
/// Process NAL unit, in particular parameter set NAL units. Non parameter
|
|
|
|
/// set NAL unit is allowed but the function always returns true.
|
|
|
|
/// Returns false if there is any problem processing the parameter set NAL
|
|
|
|
/// unit.
|
|
|
|
/// This function is needed to handle parameter set NAL units not in decoder
|
|
|
|
/// configuration record, i.e. in the samples.
|
|
|
|
virtual bool ProcessNalu(const Nalu& nalu) = 0;
|
|
|
|
|
2016-02-03 22:13:57 +00:00
|
|
|
/// Gets the header size of the given NALU. Returns < 0 on error.
|
|
|
|
virtual int64_t GetHeaderSize(const Nalu& nalu) = 0;
|
|
|
|
|
|
|
|
private:
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(VideoSliceHeaderParser);
|
|
|
|
};
|
|
|
|
|
|
|
|
class H264VideoSliceHeaderParser : public VideoSliceHeaderParser {
|
|
|
|
public:
|
|
|
|
H264VideoSliceHeaderParser();
|
|
|
|
~H264VideoSliceHeaderParser() override;
|
|
|
|
|
|
|
|
/// @name VideoSliceHeaderParser implementation overrides.
|
|
|
|
/// @{
|
|
|
|
bool Initialize(const std::vector<uint8_t>& decoder_configuration) override;
|
2019-07-16 22:09:25 +00:00
|
|
|
bool ProcessNalu(const Nalu& nalu) override;
|
2016-02-03 22:13:57 +00:00
|
|
|
int64_t GetHeaderSize(const Nalu& nalu) override;
|
|
|
|
/// @}
|
|
|
|
|
|
|
|
private:
|
|
|
|
H264Parser parser_;
|
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(H264VideoSliceHeaderParser);
|
|
|
|
};
|
|
|
|
|
2016-02-22 23:32:22 +00:00
|
|
|
class H265VideoSliceHeaderParser : public VideoSliceHeaderParser {
|
|
|
|
public:
|
|
|
|
H265VideoSliceHeaderParser();
|
|
|
|
~H265VideoSliceHeaderParser() override;
|
|
|
|
|
|
|
|
/// @name VideoSliceHeaderParser implementation overrides.
|
|
|
|
/// @{
|
|
|
|
bool Initialize(const std::vector<uint8_t>& decoder_configuration) override;
|
2019-07-16 22:09:25 +00:00
|
|
|
bool ProcessNalu(const Nalu& nalu) override;
|
2016-02-22 23:32:22 +00:00
|
|
|
int64_t GetHeaderSize(const Nalu& nalu) override;
|
|
|
|
/// @}
|
|
|
|
|
|
|
|
private:
|
|
|
|
H265Parser parser_;
|
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(H265VideoSliceHeaderParser);
|
|
|
|
};
|
2016-02-03 22:13:57 +00:00
|
|
|
|
|
|
|
} // namespace media
|
2016-05-20 21:19:33 +00:00
|
|
|
} // namespace shaka
|
2016-02-03 22:13:57 +00:00
|
|
|
|
2017-12-20 00:56:36 +00:00
|
|
|
#endif // PACKAGER_MEDIA_CODECS_VIDEO_SLICE_HEADER_PARSER_H_
|