7 #ifndef PACKAGER_MEDIA_CODECS_VP_CODEC_CONFIGURATION_RECORD_H_
8 #define PACKAGER_MEDIA_CODECS_VP_CODEC_CONFIGURATION_RECORD_H_
15 #include <packager/macros/classes.h>
16 #include <packager/media/base/video_stream_info.h>
23 enum AVColorPrimaries {
24 AVCOL_PRI_RESERVED0 = 0,
27 AVCOL_PRI_UNSPECIFIED = 2,
28 AVCOL_PRI_RESERVED = 3,
32 AVCOL_PRI_BT470BG = 5,
34 AVCOL_PRI_SMPTE170M = 6,
36 AVCOL_PRI_SMPTE240M = 7,
42 AVCOL_PRI_SMPTE428 = 10,
43 AVCOL_PRI_SMPTEST428_1 = AVCOL_PRI_SMPTE428,
45 AVCOL_PRI_SMPTE431 = 11,
47 AVCOL_PRI_SMPTE432 = 12,
53 enum AVColorTransferCharacteristic {
54 AVCOL_TRC_RESERVED0 = 0,
57 AVCOL_TRC_UNSPECIFIED = 2,
58 AVCOL_TRC_RESERVED = 3,
60 AVCOL_TRC_GAMMA22 = 4,
62 AVCOL_TRC_GAMMA28 = 5,
65 AVCOL_TRC_SMPTE170M = 6,
66 AVCOL_TRC_SMPTE240M = 7,
72 AVCOL_TRC_LOG_SQRT = 10,
74 AVCOL_TRC_IEC61966_2_4 = 11,
76 AVCOL_TRC_BT1361_ECG = 12,
78 AVCOL_TRC_IEC61966_2_1 = 13,
80 AVCOL_TRC_BT2020_10 = 14,
82 AVCOL_TRC_BT2020_12 = 15,
84 AVCOL_TRC_SMPTE2084 = 16,
85 AVCOL_TRC_SMPTEST2084 = AVCOL_TRC_SMPTE2084,
87 AVCOL_TRC_SMPTE428 = 17,
88 AVCOL_TRC_SMPTEST428_1 = AVCOL_TRC_SMPTE428,
90 AVCOL_TRC_ARIB_STD_B67 = 18,
101 AVCOL_SPC_UNSPECIFIED = 2,
102 AVCOL_SPC_RESERVED = 3,
107 AVCOL_SPC_BT470BG = 5,
109 AVCOL_SPC_SMPTE170M = 6,
111 AVCOL_SPC_SMPTE240M = 7,
115 AVCOL_SPC_BT2020_NCL = 9,
117 AVCOL_SPC_BT2020_CL = 10,
119 AVCOL_SPC_SMPTE2085 = 11,
137 enum AVChromaLocation {
138 AVCHROMA_LOC_UNSPECIFIED = 0,
140 AVCHROMA_LOC_LEFT = 1,
142 AVCHROMA_LOC_CENTER = 2,
144 AVCHROMA_LOC_TOPLEFT = 3,
145 AVCHROMA_LOC_TOP = 4,
146 AVCHROMA_LOC_BOTTOMLEFT = 5,
147 AVCHROMA_LOC_BOTTOM = 6,
155 enum ChromaSubsampling {
156 CHROMA_420_VERTICAL = 0,
157 CHROMA_420_COLLOCATED_WITH_LUMA = 1,
162 enum ChromaSitingValues {
165 kTopCollocated = kLeftCollocated,
174 uint8_t chroma_subsampling,
175 bool video_full_range_flag,
176 uint8_t color_primaries,
177 uint8_t transfer_characteristics,
178 uint8_t matrix_coefficients,
179 const std::vector<uint8_t>& codec_initialization_data);
184 bool ParseMP4(
const std::vector<uint8_t>& data);
188 bool ParseWebM(
const std::vector<uint8_t>& data);
193 double sample_duration_seconds);
197 void WriteMP4(std::vector<uint8_t>* data)
const;
201 void WriteWebM(std::vector<uint8_t>* data)
const;
210 void SetChromaSubsampling(uint8_t subsampling_x, uint8_t subsampling_y);
211 void SetChromaSubsampling(ChromaSubsampling chroma_subsampling);
212 void SetChromaLocation(uint8_t chroma_siting_x, uint8_t chroma_siting_y);
214 void set_profile(uint8_t profile) { profile_ = profile; }
215 void set_level(uint8_t level) { level_ = level; }
216 void set_bit_depth(uint8_t bit_depth) { bit_depth_ = bit_depth; }
217 void set_video_full_range_flag(
bool video_full_range_flag) {
218 video_full_range_flag_ = video_full_range_flag;
220 void set_color_primaries(uint8_t color_primaries) {
221 color_primaries_ = color_primaries;
223 void set_transfer_characteristics(uint8_t transfer_characteristics) {
224 transfer_characteristics_ = transfer_characteristics;
226 void set_matrix_coefficients(uint8_t matrix_coefficients) {
227 matrix_coefficients_ = matrix_coefficients;
230 bool is_profile_set()
const {
return static_cast<bool>(profile_); }
231 bool is_level_set()
const {
return static_cast<bool>(level_); }
232 bool is_bit_depth_set()
const {
return static_cast<bool>(bit_depth_); }
233 bool is_chroma_subsampling_set()
const {
234 return static_cast<bool>(chroma_subsampling_);
236 bool is_video_full_range_flag_set()
const {
237 return static_cast<bool>(video_full_range_flag_);
239 bool is_color_primaries_set()
const {
240 return static_cast<bool>(color_primaries_);
242 bool is_transfer_characteristics_set()
const {
243 return static_cast<bool>(transfer_characteristics_);
245 bool is_matrix_coefficients_set()
const {
246 return static_cast<bool>(matrix_coefficients_);
248 bool is_chroma_location_set()
const {
249 return static_cast<bool>(chroma_location_);
252 uint8_t profile()
const {
return profile_.value_or(0); }
253 uint8_t level()
const {
return level_.value_or(10); }
254 uint8_t bit_depth()
const {
return bit_depth_.value_or(8); }
255 uint8_t chroma_subsampling()
const {
256 return chroma_subsampling_.value_or(CHROMA_420_COLLOCATED_WITH_LUMA);
258 bool video_full_range_flag()
const {
259 return video_full_range_flag_.value_or(
false);
261 uint8_t color_primaries()
const {
262 return color_primaries_.value_or(AVCOL_PRI_UNSPECIFIED);
264 uint8_t transfer_characteristics()
const {
265 return transfer_characteristics_.value_or(AVCOL_TRC_UNSPECIFIED);
267 uint8_t matrix_coefficients()
const {
268 return matrix_coefficients_.value_or(AVCOL_SPC_UNSPECIFIED);
270 uint8_t chroma_location()
const {
271 return chroma_location_.value_or(AVCHROMA_LOC_UNSPECIFIED);
275 void UpdateChromaSubsamplingIfNeeded();
277 std::optional<uint8_t> profile_;
278 std::optional<uint8_t> level_;
279 std::optional<uint8_t> bit_depth_;
280 std::optional<uint8_t> chroma_subsampling_;
281 std::optional<bool> video_full_range_flag_;
282 std::optional<uint8_t> color_primaries_;
283 std::optional<uint8_t> transfer_characteristics_;
284 std::optional<uint8_t> matrix_coefficients_;
285 std::vector<uint8_t> codec_initialization_data_;
289 std::optional<uint8_t> chroma_location_;
All the methods that are virtual are virtual for mocking.