Shaka Packager SDK
Loading...
Searching...
No Matches
box_definitions_comparison.h
1// Copyright 2014 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// Overloads operator== for mp4 boxes, mainly used for testing.
8
9#ifndef PACKAGER_MEDIA_FORMATS_MP4_BOX_DEFINITIONS_COMPARISON_H_
10#define PACKAGER_MEDIA_FORMATS_MP4_BOX_DEFINITIONS_COMPARISON_H_
11
12#include <packager/media/base/decrypt_config.h>
13#include <packager/media/codecs/es_descriptor.h>
14#include <packager/media/formats/mp4/box_definitions.h>
15
16namespace shaka {
17namespace media {
18
19inline bool operator==(const SubsampleEntry& lhs, const SubsampleEntry& rhs) {
20 return lhs.clear_bytes == rhs.clear_bytes &&
21 lhs.cipher_bytes == rhs.cipher_bytes;
22}
23
24namespace mp4 {
25
26inline bool operator==(const FileType& lhs, const FileType& rhs) {
27 return lhs.major_brand == rhs.major_brand &&
28 lhs.minor_version == rhs.minor_version &&
29 lhs.compatible_brands == rhs.compatible_brands;
30}
31
32inline bool operator==(const ProtectionSystemSpecificHeader& lhs,
33 const ProtectionSystemSpecificHeader& rhs) {
34 return lhs.raw_box == rhs.raw_box;
35}
36
37inline bool operator==(const SampleAuxiliaryInformationOffset& lhs,
38 const SampleAuxiliaryInformationOffset& rhs) {
39 return lhs.offsets == rhs.offsets;
40}
41
42inline bool operator==(const SampleAuxiliaryInformationSize& lhs,
43 const SampleAuxiliaryInformationSize& rhs) {
44 return lhs.default_sample_info_size == rhs.default_sample_info_size &&
45 lhs.sample_count == rhs.sample_count &&
46 lhs.sample_info_sizes == rhs.sample_info_sizes;
47}
48
49inline bool operator==(const SampleEncryptionEntry& lhs,
50 const SampleEncryptionEntry& rhs) {
51 return lhs.initialization_vector == rhs.initialization_vector &&
52 lhs.subsamples == rhs.subsamples;
53}
54
55inline bool operator==(const SampleEncryption& lhs,
56 const SampleEncryption& rhs) {
57 return lhs.iv_size == rhs.iv_size &&
58 lhs.sample_encryption_entries == rhs.sample_encryption_entries;
59}
60
61inline bool operator==(const OriginalFormat& lhs, const OriginalFormat& rhs) {
62 return lhs.format == rhs.format;
63}
64
65inline bool operator==(const SchemeType& lhs, const SchemeType& rhs) {
66 return lhs.type == rhs.type && lhs.version == rhs.version;
67}
68
69inline bool operator==(const TrackEncryption& lhs, const TrackEncryption& rhs) {
70 return lhs.default_is_protected == rhs.default_is_protected &&
71 lhs.default_per_sample_iv_size == rhs.default_per_sample_iv_size &&
72 lhs.default_kid == rhs.default_kid &&
73 lhs.default_crypt_byte_block == rhs.default_crypt_byte_block &&
74 lhs.default_skip_byte_block == rhs.default_skip_byte_block &&
75 lhs.default_constant_iv == rhs.default_constant_iv;
76}
77
78inline bool operator==(const SchemeInfo& lhs, const SchemeInfo& rhs) {
79 return lhs.track_encryption == rhs.track_encryption;
80}
81
82inline bool operator==(const ProtectionSchemeInfo& lhs,
83 const ProtectionSchemeInfo& rhs) {
84 return lhs.format == rhs.format && lhs.type == rhs.type &&
85 lhs.info == rhs.info;
86}
87
88inline bool operator==(const MovieHeader& lhs, const MovieHeader& rhs) {
89 return lhs.creation_time == rhs.creation_time &&
90 lhs.modification_time == rhs.modification_time &&
91 lhs.timescale == rhs.timescale && lhs.duration == rhs.duration &&
92 lhs.rate == rhs.rate && lhs.volume == rhs.volume &&
93 lhs.next_track_id == rhs.next_track_id;
94}
95
96inline bool operator==(const TrackHeader& lhs, const TrackHeader& rhs) {
97 return lhs.creation_time == rhs.creation_time &&
98 lhs.modification_time == rhs.modification_time &&
99 lhs.track_id == rhs.track_id && lhs.duration == rhs.duration &&
100 lhs.layer == rhs.layer && lhs.alternate_group == rhs.alternate_group &&
101 lhs.volume == rhs.volume && lhs.width == rhs.width &&
102 lhs.height == rhs.height;
103}
104
105inline bool operator==(const SampleDescription& lhs,
106 const SampleDescription& rhs) {
107 return lhs.type == rhs.type && lhs.video_entries == rhs.video_entries &&
108 lhs.audio_entries == rhs.audio_entries;
109}
110
111inline bool operator==(const DecodingTime& lhs, const DecodingTime& rhs) {
112 return lhs.sample_count == rhs.sample_count &&
113 lhs.sample_delta == rhs.sample_delta;
114}
115
116inline bool operator==(const DecodingTimeToSample& lhs,
117 const DecodingTimeToSample& rhs) {
118 return lhs.decoding_time == rhs.decoding_time;
119}
120
121inline bool operator==(const CompositionOffset& lhs,
122 const CompositionOffset& rhs) {
123 return lhs.sample_count == rhs.sample_count &&
124 lhs.sample_offset == rhs.sample_offset;
125}
126
127inline bool operator==(const CompositionTimeToSample& lhs,
128 const CompositionTimeToSample& rhs) {
129 return lhs.composition_offset == rhs.composition_offset;
130}
131
132inline bool operator==(const ChunkInfo& lhs, const ChunkInfo& rhs) {
133 return lhs.first_chunk == rhs.first_chunk &&
134 lhs.samples_per_chunk == rhs.samples_per_chunk &&
135 lhs.sample_description_index == rhs.sample_description_index;
136}
137
138inline bool operator==(const SampleToChunk& lhs, const SampleToChunk& rhs) {
139 return lhs.chunk_info == rhs.chunk_info;
140}
141
142inline bool operator==(const SampleSize& lhs, const SampleSize& rhs) {
143 return lhs.sample_size == rhs.sample_size &&
144 lhs.sample_count == rhs.sample_count && lhs.sizes == rhs.sizes;
145}
146
147inline bool operator==(const CompactSampleSize& lhs,
148 const CompactSampleSize& rhs) {
149 return lhs.field_size == rhs.field_size && lhs.sizes == rhs.sizes;
150}
151
152inline bool operator==(const ChunkLargeOffset& lhs,
153 const ChunkLargeOffset& rhs) {
154 return lhs.offsets == rhs.offsets;
155}
156
157inline bool operator==(const SyncSample& lhs, const SyncSample& rhs) {
158 return lhs.sample_number == rhs.sample_number;
159}
160
161inline bool operator==(const CencSampleEncryptionInfoEntry& lhs,
162 const CencSampleEncryptionInfoEntry& rhs) {
163 return lhs.is_protected == rhs.is_protected &&
164 lhs.per_sample_iv_size == rhs.per_sample_iv_size &&
165 lhs.key_id == rhs.key_id &&
166 lhs.crypt_byte_block == rhs.crypt_byte_block &&
167 lhs.skip_byte_block == rhs.skip_byte_block &&
168 lhs.constant_iv == rhs.constant_iv;
169}
170
171inline bool operator==(const AudioRollRecoveryEntry& lhs,
172 const AudioRollRecoveryEntry& rhs) {
173 return lhs.roll_distance == rhs.roll_distance;
174}
175
176inline bool operator==(const SampleGroupDescription& lhs,
177 const SampleGroupDescription& rhs) {
178 return lhs.grouping_type == rhs.grouping_type &&
179 lhs.cenc_sample_encryption_info_entries ==
180 rhs.cenc_sample_encryption_info_entries &&
181 lhs.audio_roll_recovery_entries == rhs.audio_roll_recovery_entries;
182}
183
184inline bool operator==(const SampleToGroupEntry& lhs,
185 const SampleToGroupEntry& rhs) {
186 return lhs.sample_count == rhs.sample_count &&
187 lhs.group_description_index == rhs.group_description_index;
188}
189
190inline bool operator==(const SampleToGroup& lhs, const SampleToGroup& rhs) {
191 return lhs.grouping_type == rhs.grouping_type &&
192 lhs.grouping_type_parameter == rhs.grouping_type_parameter &&
193 lhs.entries == rhs.entries;
194}
195
196inline bool operator==(const SampleTable& lhs, const SampleTable& rhs) {
197 return lhs.description == rhs.description &&
198 lhs.decoding_time_to_sample == rhs.decoding_time_to_sample &&
199 lhs.composition_time_to_sample == rhs.composition_time_to_sample &&
200 lhs.sample_to_chunk == rhs.sample_to_chunk &&
201 lhs.sample_size == rhs.sample_size &&
202 lhs.chunk_large_offset == rhs.chunk_large_offset &&
203 lhs.sync_sample == rhs.sync_sample &&
204 lhs.sample_group_descriptions == rhs.sample_group_descriptions &&
205 lhs.sample_to_groups == rhs.sample_to_groups;
206}
207
208inline bool operator==(const EditListEntry& lhs, const EditListEntry& rhs) {
209 return lhs.segment_duration == rhs.segment_duration &&
210 lhs.media_time == rhs.media_time &&
211 lhs.media_rate_integer == rhs.media_rate_integer &&
212 lhs.media_rate_fraction == rhs.media_rate_fraction;
213}
214
215inline bool operator==(const EditList& lhs, const EditList& rhs) {
216 return lhs.edits == rhs.edits;
217}
218
219inline bool operator==(const Edit& lhs, const Edit& rhs) {
220 return lhs.list == rhs.list;
221}
222
223inline bool operator==(const HandlerReference& lhs,
224 const HandlerReference& rhs) {
225 return lhs.handler_type == rhs.handler_type;
226}
227
228inline bool operator==(const Language& lhs, const Language& rhs) {
229 return lhs.code == rhs.code;
230}
231
232inline bool operator==(const ID3v2& lhs, const ID3v2& rhs) {
233 return lhs.language == rhs.language && lhs.id3v2_data == rhs.id3v2_data;
234}
235
236inline bool operator==(const Metadata& lhs, const Metadata& rhs) {
237 return lhs.handler == rhs.handler && lhs.id3v2 == rhs.id3v2;
238}
239
240inline bool operator==(const CodecConfiguration& lhs,
241 const CodecConfiguration& rhs) {
242 return lhs.box_type == rhs.box_type && lhs.data == rhs.data;
243}
244
245inline bool operator==(const PixelAspectRatio& lhs,
246 const PixelAspectRatio& rhs) {
247 return lhs.h_spacing == rhs.h_spacing && lhs.v_spacing == rhs.v_spacing;
248}
249
250inline bool operator==(const VideoSampleEntry& lhs,
251 const VideoSampleEntry& rhs) {
252 return lhs.format == rhs.format &&
253 lhs.data_reference_index == rhs.data_reference_index &&
254 lhs.width == rhs.width && lhs.height == rhs.height &&
255 lhs.pixel_aspect == rhs.pixel_aspect && lhs.sinf == rhs.sinf &&
256 lhs.codec_configuration == rhs.codec_configuration;
257}
258
259inline bool operator==(const DecoderSpecificInfoDescriptor& lhs,
260 const DecoderSpecificInfoDescriptor& rhs) {
261 return lhs.data() == rhs.data();
262}
263
264inline bool operator==(const DecoderConfigDescriptor& lhs,
265 const DecoderConfigDescriptor& rhs) {
266 return lhs.buffer_size_db() == rhs.buffer_size_db() &&
267 lhs.max_bitrate() == rhs.max_bitrate() &&
268 lhs.avg_bitrate() == rhs.avg_bitrate() &&
269 lhs.object_type() == rhs.object_type() &&
270 lhs.decoder_specific_info_descriptor() ==
271 rhs.decoder_specific_info_descriptor();
272}
273
274inline bool operator==(const ESDescriptor& lhs, const ESDescriptor& rhs) {
275 return lhs.esid() == rhs.esid() &&
276 lhs.decoder_config_descriptor() == rhs.decoder_config_descriptor();
277}
278
279inline bool operator==(const ElementaryStreamDescriptor& lhs,
280 const ElementaryStreamDescriptor& rhs) {
281 return lhs.es_descriptor == rhs.es_descriptor;
282}
283
284inline bool operator==(const DTSSpecific& lhs, const DTSSpecific& rhs) {
285 return lhs.sampling_frequency == rhs.sampling_frequency &&
286 lhs.max_bitrate == rhs.max_bitrate &&
287 lhs.avg_bitrate == rhs.avg_bitrate &&
288 lhs.pcm_sample_depth == rhs.pcm_sample_depth &&
289 lhs.extra_data == rhs.extra_data;
290}
291
292inline bool operator==(const AC3Specific& lhs, const AC3Specific& rhs) {
293 return lhs.data == rhs.data;
294}
295
296inline bool operator==(const EC3Specific& lhs, const EC3Specific& rhs) {
297 return lhs.data == rhs.data;
298}
299
300inline bool operator==(const OpusSpecific& lhs, const OpusSpecific& rhs) {
301 return lhs.opus_identification_header == rhs.opus_identification_header &&
302 lhs.preskip == rhs.preskip;
303}
304
305inline bool operator==(const AudioSampleEntry& lhs,
306 const AudioSampleEntry& rhs) {
307 return lhs.format == rhs.format &&
308 lhs.data_reference_index == rhs.data_reference_index &&
309 lhs.channelcount == rhs.channelcount &&
310 lhs.samplesize == rhs.samplesize && lhs.samplerate == rhs.samplerate &&
311 lhs.sinf == rhs.sinf && lhs.esds == rhs.esds && lhs.ddts == rhs.ddts &&
312 lhs.dac3 == rhs.dac3 && lhs.dec3 == rhs.dec3 && lhs.dops == rhs.dops;
313}
314
315inline bool operator==(const WebVTTConfigurationBox& lhs,
316 const WebVTTConfigurationBox& rhs) {
317 return lhs.config == rhs.config;
318}
319
320inline bool operator==(const WebVTTSourceLabelBox& lhs,
321 const WebVTTSourceLabelBox& rhs) {
322 return lhs.source_label == rhs.source_label;
323}
324
325inline bool operator==(const TextSampleEntry& lhs, const TextSampleEntry& rhs) {
326 return lhs.config == rhs.config && lhs.label == rhs.label;
327}
328
329inline bool operator==(const MediaHeader& lhs, const MediaHeader& rhs) {
330 return lhs.creation_time == rhs.creation_time &&
331 lhs.modification_time == rhs.modification_time &&
332 lhs.timescale == rhs.timescale && lhs.duration == rhs.duration &&
333 lhs.language == rhs.language;
334}
335
336inline bool operator==(const VideoMediaHeader& lhs,
337 const VideoMediaHeader& rhs) {
338 return lhs.graphicsmode == rhs.graphicsmode &&
339 lhs.opcolor_red == rhs.opcolor_red &&
340 lhs.opcolor_green == rhs.opcolor_green &&
341 lhs.opcolor_blue == rhs.opcolor_blue;
342}
343
344inline bool operator==(const SoundMediaHeader& lhs,
345 const SoundMediaHeader& rhs) {
346 return lhs.balance == rhs.balance;
347}
348
349inline bool operator==(const SubtitleMediaHeader& /*lhs*/,
350 const SubtitleMediaHeader& /*rhs*/) {
351 return true;
352}
353
354inline bool operator==(const DataEntryUrl& lhs, const DataEntryUrl& rhs) {
355 return lhs.flags == rhs.flags && lhs.location == rhs.location;
356}
357
358inline bool operator==(const DataReference& lhs, const DataReference& rhs) {
359 return lhs.data_entry == rhs.data_entry;
360}
361
362inline bool operator==(const DataInformation& lhs, const DataInformation& rhs) {
363 return lhs.dref == rhs.dref;
364}
365
366inline bool operator==(const MediaInformation& lhs,
367 const MediaInformation& rhs) {
368 return lhs.dinf == rhs.dinf && lhs.sample_table == rhs.sample_table &&
369 lhs.vmhd == rhs.vmhd && lhs.smhd == rhs.smhd;
370}
371
372inline bool operator==(const Media& lhs, const Media& rhs) {
373 return lhs.header == rhs.header && lhs.handler == rhs.handler &&
374 lhs.information == rhs.information;
375}
376
377inline bool operator==(const Track& lhs, const Track& rhs) {
378 return lhs.header == rhs.header && lhs.media == rhs.media &&
379 lhs.edit == rhs.edit && lhs.sample_encryption == rhs.sample_encryption;
380}
381
382inline bool operator==(const MovieExtendsHeader& lhs,
383 const MovieExtendsHeader& rhs) {
384 return lhs.fragment_duration == rhs.fragment_duration;
385}
386
387inline bool operator==(const TrackExtends& lhs, const TrackExtends& rhs) {
388 return lhs.track_id == rhs.track_id &&
389 lhs.default_sample_description_index ==
390 rhs.default_sample_description_index &&
391 lhs.default_sample_duration == rhs.default_sample_duration &&
392 lhs.default_sample_size == rhs.default_sample_size &&
393 lhs.default_sample_flags == rhs.default_sample_flags;
394}
395
396inline bool operator==(const MovieExtends& lhs, const MovieExtends& rhs) {
397 return lhs.header == rhs.header && lhs.tracks == rhs.tracks;
398}
399
400inline bool operator==(const Movie& lhs, const Movie& rhs) {
401 return lhs.header == rhs.header && lhs.extends == rhs.extends &&
402 lhs.tracks == rhs.tracks && lhs.pssh == rhs.pssh;
403}
404
405inline bool operator==(const TrackFragmentDecodeTime& lhs,
406 const TrackFragmentDecodeTime& rhs) {
407 return lhs.decode_time == rhs.decode_time;
408}
409
410inline bool operator==(const MovieFragmentHeader& lhs,
411 const MovieFragmentHeader& rhs) {
412 return lhs.sequence_number == rhs.sequence_number;
413}
414
415inline bool operator==(const TrackFragmentHeader& lhs,
416 const TrackFragmentHeader& rhs) {
417 return lhs.flags == rhs.flags && lhs.track_id == rhs.track_id &&
418 lhs.sample_description_index == rhs.sample_description_index &&
419 lhs.default_sample_duration == rhs.default_sample_duration &&
420 lhs.default_sample_size == rhs.default_sample_size &&
421 lhs.default_sample_flags == rhs.default_sample_flags;
422}
423
424inline bool operator==(const TrackFragmentRun& lhs,
425 const TrackFragmentRun& rhs) {
426 return lhs.flags == rhs.flags && lhs.sample_count == rhs.sample_count &&
427 lhs.data_offset == rhs.data_offset &&
428 lhs.sample_flags == rhs.sample_flags &&
429 lhs.sample_sizes == rhs.sample_sizes &&
430 lhs.sample_durations == rhs.sample_durations &&
431 lhs.sample_composition_time_offsets ==
432 rhs.sample_composition_time_offsets;
433}
434
435inline bool operator==(const TrackFragment& lhs, const TrackFragment& rhs) {
436 return lhs.header == rhs.header && lhs.runs == rhs.runs &&
437 lhs.decode_time == rhs.decode_time &&
438 lhs.auxiliary_offset == rhs.auxiliary_offset &&
439 lhs.auxiliary_size == rhs.auxiliary_size &&
440 lhs.sample_encryption == rhs.sample_encryption;
441}
442
443inline bool operator==(const MovieFragment& lhs, const MovieFragment& rhs) {
444 return lhs.header == rhs.header && lhs.tracks == rhs.tracks &&
445 lhs.pssh == rhs.pssh;
446}
447
448inline bool operator==(const SegmentReference& lhs,
449 const SegmentReference& rhs) {
450 return lhs.reference_type == rhs.reference_type &&
451 lhs.referenced_size == rhs.referenced_size &&
452 lhs.subsegment_duration == rhs.subsegment_duration &&
453 lhs.starts_with_sap == rhs.starts_with_sap &&
454 lhs.sap_type == rhs.sap_type &&
455 lhs.sap_delta_time == rhs.sap_delta_time;
456}
457
458inline bool operator==(const SegmentIndex& lhs, const SegmentIndex& rhs) {
459 return lhs.reference_id == rhs.reference_id &&
460 lhs.timescale == rhs.timescale &&
461 lhs.earliest_presentation_time == rhs.earliest_presentation_time &&
462 lhs.first_offset == rhs.first_offset &&
463 lhs.references == rhs.references;
464}
465
466inline bool operator==(const CueSourceIDBox& lhs, const CueSourceIDBox& rhs) {
467 return lhs.source_id == rhs.source_id;
468}
469
470inline bool operator==(const CueTimeBox& lhs, const CueTimeBox& rhs) {
471 return lhs.cue_current_time == rhs.cue_current_time;
472}
473
474inline bool operator==(const CueIDBox& lhs, const CueIDBox& rhs) {
475 return lhs.cue_id == rhs.cue_id;
476}
477
478inline bool operator==(const CueSettingsBox& lhs, const CueSettingsBox& rhs) {
479 return lhs.settings == rhs.settings;
480}
481
482inline bool operator==(const CuePayloadBox& lhs, const CuePayloadBox& rhs) {
483 return lhs.cue_text == rhs.cue_text;
484}
485
486inline bool operator==(const VTTEmptyCueBox& /*lhs*/,
487 const VTTEmptyCueBox& /*rhs*/) {
488 return true;
489}
490
491inline bool operator==(const VTTAdditionalTextBox& lhs,
492 const VTTAdditionalTextBox& rhs) {
493 return lhs.cue_additional_text == rhs.cue_additional_text;
494}
495
496inline bool operator==(const VTTCueBox& lhs, const VTTCueBox& rhs) {
497 return lhs.cue_source_id == rhs.cue_source_id && lhs.cue_id == rhs.cue_id &&
498 lhs.cue_time == rhs.cue_time && lhs.cue_settings == rhs.cue_settings &&
499 lhs.cue_payload == rhs.cue_payload;
500}
501
502} // namespace mp4
503} // namespace media
504} // namespace shaka
505
506#endif // PACKAGER_MEDIA_FORMATS_MP4_BOX_DEFINITIONS_COMPARISON_H_
All the methods that are virtual are virtual for mocking.