Shaka Packager SDK
Loading...
Searching...
No Matches
decoder_configuration_record.h
1// Copyright 2016 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_CODECS_DECODER_CONFIGURATION_RECORD_H_
8#define PACKAGER_MEDIA_CODECS_DECODER_CONFIGURATION_RECORD_H_
9
10#include <cstdint>
11#include <vector>
12
13#include <absl/log/check.h>
14#include <absl/log/log.h>
15
16#include <packager/macros/classes.h>
17#include <packager/media/codecs/nalu_reader.h>
18
19namespace shaka {
20namespace media {
21
22// Defines a base class for decoder configuration record.
24 public:
26
30 bool Parse(const std::vector<uint8_t>& data) {
31 return Parse(data.data(), data.size());
32 }
33
37 bool Parse(const uint8_t* data, size_t data_size);
38
40 uint8_t nalu_length_size() const { return nalu_length_size_; }
41
43 size_t nalu_count() const { return nalu_.size(); }
44
47 const Nalu& nalu(size_t i) const { return nalu_[i]; }
48
50 uint8_t transfer_characteristics() const { return transfer_characteristics_; }
51
53 uint8_t color_primaries() const { return color_primaries_; }
54
56 uint8_t matrix_coefficients() const { return matrix_coefficients_; }
57
58 protected:
60
62 void AddNalu(const Nalu& nalu);
63
65 const uint8_t* data() const { return data_.data(); }
66
68 size_t data_size() const { return data_.size(); }
69
72 DCHECK(nalu_length_size <= 2 || nalu_length_size == 4);
73 nalu_length_size_ = nalu_length_size;
74 }
75
78 transfer_characteristics_ = transfer_characteristics;
79 }
80
83 color_primaries_ = color_primaries;
84 }
87 matrix_coefficients_ = matrix_coefficients;
88 }
89
90 private:
91 // Performs the actual parsing of the data.
92 virtual bool ParseInternal() = 0;
93
94 // Contains a copy of the data. This manages the pointer lifetime so the
95 // extracted Nalu can accessed.
96 std::vector<uint8_t> data_;
97 std::vector<Nalu> nalu_;
98 uint8_t nalu_length_size_ = 0;
99
100 // Indicates the opto-electronic transfer characteristics of the source
101 // picture, which can be used to determine whether the video is HDR or SDR.
102 // The parameter is extracted from SPS.
103 uint8_t transfer_characteristics_ = 0;
104
105 uint8_t color_primaries_ = 0;
106 uint8_t matrix_coefficients_ = 0;
107
108 DISALLOW_COPY_AND_ASSIGN(DecoderConfigurationRecord);
109};
110
111} // namespace media
112} // namespace shaka
113
114#endif // PACKAGER_MEDIA_CODECS_DECODER_CONFIGURATION_RECORD_H_
void set_matrix_coefficients(uint8_t matrix_coefficients)
Sets the matrix coeffs.
void AddNalu(const Nalu &nalu)
Adds the given Nalu to the configuration.
void set_color_primaries(uint8_t color_primaries)
Sets the colour primaries.
void set_transfer_characteristics(uint8_t transfer_characteristics)
Sets the transfer characteristics.
bool Parse(const std::vector< uint8_t > &data)
void set_nalu_length_size(uint8_t nalu_length_size)
Sets the size of the NAL unit length field.
All the methods that are virtual are virtual for mocking.