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 <vector>
11
12#include <absl/log/check.h>
13#include <absl/log/log.h>
14
15#include <packager/macros/classes.h>
16#include <packager/media/codecs/nalu_reader.h>
17
18namespace shaka {
19namespace media {
20
21// Defines a base class for decoder configuration record.
23 public:
25
29 bool Parse(const std::vector<uint8_t>& data) {
30 return Parse(data.data(), data.size());
31 }
32
36 bool Parse(const uint8_t* data, size_t data_size);
37
39 uint8_t nalu_length_size() const { return nalu_length_size_; }
40
42 size_t nalu_count() const { return nalu_.size(); }
43
46 const Nalu& nalu(size_t i) const { return nalu_[i]; }
47
49 uint8_t transfer_characteristics() const { return transfer_characteristics_; }
50
52 uint8_t color_primaries() const { return color_primaries_; }
53
55 uint8_t matrix_coefficients() const { return matrix_coefficients_; }
56
57 protected:
59
61 void AddNalu(const Nalu& nalu);
62
64 const uint8_t* data() const { return data_.data(); }
65
67 size_t data_size() const { return data_.size(); }
68
71 DCHECK(nalu_length_size <= 2 || nalu_length_size == 4);
72 nalu_length_size_ = nalu_length_size;
73 }
74
77 transfer_characteristics_ = transfer_characteristics;
78 }
79
82 color_primaries_ = color_primaries;
83 }
86 matrix_coefficients_ = matrix_coefficients;
87 }
88
89 private:
90 // Performs the actual parsing of the data.
91 virtual bool ParseInternal() = 0;
92
93 // Contains a copy of the data. This manages the pointer lifetime so the
94 // extracted Nalu can accessed.
95 std::vector<uint8_t> data_;
96 std::vector<Nalu> nalu_;
97 uint8_t nalu_length_size_ = 0;
98
99 // Indicates the opto-electronic transfer characteristics of the source
100 // picture, which can be used to determine whether the video is HDR or SDR.
101 // The parameter is extracted from SPS.
102 uint8_t transfer_characteristics_ = 0;
103
104 uint8_t color_primaries_ = 0;
105 uint8_t matrix_coefficients_ = 0;
106
107 DISALLOW_COPY_AND_ASSIGN(DecoderConfigurationRecord);
108};
109
110} // namespace media
111} // namespace shaka
112
113#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.