1 // Copyright (c) 2016 The WebM project authors. All Rights Reserved. 2 // 3 // Use of this source code is governed by a BSD-style license 4 // that can be found in the LICENSE file in the root of the source 5 // tree. An additional intellectual property rights grant can be found 6 // in the file PATENTS. All contributing project authors may 7 // be found in the AUTHORS file in the root of the source tree. 8 #ifndef INCLUDE_WEBM_DOM_TYPES_H_ 9 #define INCLUDE_WEBM_DOM_TYPES_H_ 10 11 #include <cstdint> 12 #include <string> 13 #include <vector> 14 15 #include "./element.h" 16 #include "./id.h" 17 18 /** 19 \file 20 Data structures representing parsed DOM objects. 21 22 For more information on each type and member, see the WebM specification for 23 the element that each type/member represents. 24 */ 25 26 namespace webm { 27 28 /** 29 \addtogroup PUBLIC_API 30 @{ 31 */ 32 33 /** 34 Metadata for a single frame. 35 */ 36 struct FrameMetadata { 37 /** 38 Metadata for the EBML element (\WebMID{Block} or \WebMID{SimpleBlock}) that 39 contains this frame. 40 */ 41 ElementMetadata parent_element; 42 43 /** 44 Absolute byte position (from the beginning of the byte stream/file) of the 45 frame start. 46 */ 47 std::uint64_t position; 48 49 /** 50 Size (in bytes) of the frame. 51 */ 52 std::uint64_t size; 53 54 /** 55 Returns true if every member within the two objects are equal. 56 */ 57 bool operator==(const FrameMetadata& other) const { 58 return parent_element == other.parent_element && 59 position == other.position && size == other.size; 60 } 61 }; 62 63 /** 64 A parsed \WebMID{BlockMore} element. 65 */ 66 struct BlockMore { 67 /** 68 A parsed \WebMID{BlockAddID} element. 69 */ 70 Element<std::uint64_t> id{1}; 71 72 /** 73 A parsed \WebMID{BlockAdditional} element. 74 */ 75 Element<std::vector<std::uint8_t>> data; 76 77 /** 78 Returns true if every member within the two objects are equal. 79 */ 80 bool operator==(const BlockMore& other) const { 81 return id == other.id && data == other.data; 82 } 83 }; 84 85 /** 86 A parsed \WebMID{BlockAdditions} element. 87 */ 88 struct BlockAdditions { 89 /** 90 Parsed \WebMID{BlockMore} elements. 91 */ 92 std::vector<Element<BlockMore>> block_mores; 93 94 /** 95 Returns true if every member within the two objects are equal. 96 */ 97 bool operator==(const BlockAdditions& other) const { 98 return block_mores == other.block_mores; 99 } 100 }; 101 102 /** 103 A parsed \WebMID{TimeSlice} element (deprecated). 104 */ 105 struct TimeSlice { 106 /** 107 A parsed \WebMID{LaceNumber} element (deprecated). 108 */ 109 Element<std::uint64_t> lace_number; 110 111 /** 112 Returns true if every member within the two objects are equal. 113 */ 114 bool operator==(const TimeSlice& other) const { 115 return lace_number == other.lace_number; 116 } 117 }; 118 119 /** 120 A parsed \WebMID{Slices} element (deprecated). 121 */ 122 struct Slices { 123 /** 124 Parsed \WebMID{TimeSlice} elements (deprecated). 125 */ 126 std::vector<Element<TimeSlice>> slices; 127 128 /** 129 Returns true if every member within the two objects are equal. 130 */ 131 bool operator==(const Slices& other) const { return slices == other.slices; } 132 }; 133 134 /** 135 A parsed \WebMID{BlockVirtual} element. 136 */ 137 struct VirtualBlock { 138 /** 139 The virtual block's track number. 140 */ 141 std::uint64_t track_number; 142 143 /** 144 The timecode of the virtual block. 145 */ 146 std::int16_t timecode; 147 148 /** 149 Returns true if every member within the two objects are equal. 150 */ 151 bool operator==(const VirtualBlock& other) const { 152 return track_number == other.track_number && timecode == other.timecode; 153 } 154 }; 155 156 /** 157 The frame lacing used in a block. 158 */ 159 enum class Lacing : std::uint8_t { 160 /** 161 No lacing is used. 162 */ 163 kNone = 0x00, 164 165 /** 166 Xiph-style lacing is used. 167 */ 168 kXiph = 0x02, 169 170 /** 171 Fixed-lacing is used, where each frame has the same, fixed size. 172 */ 173 kFixed = 0x04, 174 175 /** 176 EBML-style lacing is used. 177 */ 178 kEbml = 0x06, 179 }; 180 181 /** 182 A parsed \WebMID{Block} element. 183 */ 184 struct Block { 185 /** 186 The block's track number. 187 */ 188 std::uint64_t track_number; 189 190 /** 191 The number of frames in the block. 192 */ 193 int num_frames; 194 195 /** 196 The timecode of the block (relative to the containing \WebMID{Cluster}'s 197 timecode). 198 */ 199 std::int16_t timecode; 200 201 /** 202 The lacing used to store frames in the block. 203 */ 204 Lacing lacing; 205 206 /** 207 True if the frames are visible, false if they are invisible. 208 */ 209 bool is_visible; 210 211 /** 212 Returns true if every member within the two objects are equal. 213 */ 214 bool operator==(const Block& other) const { 215 return track_number == other.track_number && 216 num_frames == other.num_frames && timecode == other.timecode && 217 lacing == other.lacing && is_visible == other.is_visible; 218 } 219 }; 220 221 /** 222 A parsed \WebMID{SimpleBlock} element. 223 */ 224 struct SimpleBlock : public Block { 225 /** 226 True if the frames are all key frames. 227 */ 228 bool is_key_frame; 229 230 /** 231 True if frames can be discarded during playback if needed. 232 */ 233 bool is_discardable; 234 235 /** 236 Returns true if every member within the two objects are equal. 237 */ 238 bool operator==(const SimpleBlock& other) const { 239 return Block::operator==(other) && is_key_frame == other.is_key_frame && 240 is_discardable == other.is_discardable; 241 } 242 }; 243 244 /** 245 A parsed \WebMID{BlockGroup} element. 246 */ 247 struct BlockGroup { 248 /** 249 A parsed \WebMID{Block} element. 250 */ 251 Element<Block> block; 252 253 /** 254 A parsed \WebMID{BlockVirtual} element. 255 */ 256 Element<VirtualBlock> virtual_block; 257 258 /** 259 A parsed \WebMID{BlockAdditions} element. 260 */ 261 Element<BlockAdditions> additions; 262 263 /** 264 A parsed \WebMID{BlockDuration} element. 265 */ 266 Element<std::uint64_t> duration; 267 268 /** 269 Parsed \WebMID{ReferenceBlock} elements. 270 */ 271 std::vector<Element<std::int64_t>> references; 272 273 /** 274 A parsed \WebMID{DiscardPadding} element. 275 */ 276 Element<std::int64_t> discard_padding; 277 278 /** 279 A parsed \WebMID{Slices} element (deprecated). 280 */ 281 Element<Slices> slices; 282 283 /** 284 Returns true if every member within the two objects are equal. 285 */ 286 bool operator==(const BlockGroup& other) const { 287 return block == other.block && virtual_block == other.virtual_block && 288 additions == other.additions && duration == other.duration && 289 references == other.references && 290 discard_padding == other.discard_padding && slices == other.slices; 291 } 292 }; 293 294 /** 295 A parsed \WebMID{Cluster} element. 296 */ 297 struct Cluster { 298 /** 299 A parsed \WebMID{Timecode} element. 300 */ 301 Element<std::uint64_t> timecode; 302 303 /** 304 A parsed \WebMID{PrevSize} element. 305 */ 306 Element<std::uint64_t> previous_size; 307 308 /** 309 Parsed \WebMID{SimpleBlock} elements. 310 */ 311 std::vector<Element<SimpleBlock>> simple_blocks; 312 313 /** 314 Parsed \WebMID{BlockGroup} elements. 315 */ 316 std::vector<Element<BlockGroup>> block_groups; 317 318 /** 319 Returns true if every member within the two objects are equal. 320 */ 321 bool operator==(const Cluster& other) const { 322 return timecode == other.timecode && previous_size == other.previous_size && 323 simple_blocks == other.simple_blocks && 324 block_groups == other.block_groups; 325 } 326 }; 327 328 /** 329 A parsed \WebMID{EBML} element. 330 */ 331 struct Ebml { 332 /** 333 A parsed \WebMID{EBMLVersion} element. 334 */ 335 Element<std::uint64_t> ebml_version{1}; 336 337 /** 338 A parsed \WebMID{EBMLReadVersion} element. 339 */ 340 Element<std::uint64_t> ebml_read_version{1}; 341 342 /** 343 A parsed \WebMID{EBMLMaxIDLength} element. 344 */ 345 Element<std::uint64_t> ebml_max_id_length{4}; 346 347 /** 348 A parsed \WebMID{EBMLMaxSizeLength} element. 349 */ 350 Element<std::uint64_t> ebml_max_size_length{8}; 351 352 /** 353 A parsed \WebMID{DocType} element. 354 */ 355 Element<std::string> doc_type{"matroska"}; 356 357 /** 358 A parsed \WebMID{DocTypeVersion} element. 359 */ 360 Element<std::uint64_t> doc_type_version{1}; 361 362 /** 363 A parsed \WebMID{DocTypeReadVersion} element. 364 */ 365 Element<std::uint64_t> doc_type_read_version{1}; 366 367 /** 368 Returns true if every member within the two objects are equal. 369 */ 370 bool operator==(const Ebml& other) const { 371 return ebml_version == other.ebml_version && 372 ebml_read_version == other.ebml_read_version && 373 ebml_max_id_length == other.ebml_max_id_length && 374 ebml_max_size_length == other.ebml_max_size_length && 375 doc_type == other.doc_type && 376 doc_type_version == other.doc_type_version && 377 doc_type_read_version == other.doc_type_read_version; 378 } 379 }; 380 381 /** 382 A parsed \WebMID{Info} element. 383 */ 384 struct Info { 385 /** 386 A parsed \WebMID{TimecodeScale} element. 387 */ 388 Element<std::uint64_t> timecode_scale{1000000}; 389 390 /** 391 A parsed \WebMID{Duration} element. 392 */ 393 Element<double> duration; 394 395 /** 396 A parsed \WebMID{DateUTC} element. 397 */ 398 Element<std::int64_t> date_utc; 399 400 /** 401 A parsed \WebMID{Title} element. 402 */ 403 Element<std::string> title; 404 405 /** 406 A parsed \WebMID{MuxingApp} element. 407 */ 408 Element<std::string> muxing_app; 409 410 /** 411 A parsed \WebMID{WritingApp} element. 412 */ 413 Element<std::string> writing_app; 414 415 /** 416 Returns true if every member within the two objects are equal. 417 */ 418 bool operator==(const Info& other) const { 419 return timecode_scale == other.timecode_scale && 420 duration == other.duration && date_utc == other.date_utc && 421 title == other.title && muxing_app == other.muxing_app && 422 writing_app == other.writing_app; 423 } 424 }; 425 426 /** 427 A parsed \WebMID{Seek} element. 428 */ 429 struct Seek { 430 /** 431 A parsed \WebMID{SeekID} element. 432 */ 433 Element<Id> id; 434 435 /** 436 A parsed \WebMID{SeekPosition} element. 437 */ 438 Element<std::uint64_t> position; 439 440 /** 441 Returns true if every member within the two objects are equal. 442 */ 443 bool operator==(const Seek& other) const { 444 return id == other.id && position == other.position; 445 } 446 }; 447 448 /** 449 A parsed \WebMID{Audio} element. 450 */ 451 struct Audio { 452 /** 453 A parsed \WebMID{SamplingFrequency} element. 454 */ 455 Element<double> sampling_frequency{8000}; 456 457 /** 458 A parsed \WebMID{OutputSamplingFrequency} element. 459 */ 460 Element<double> output_frequency{8000}; 461 462 /** 463 A parsed \WebMID{Channels} element. 464 */ 465 Element<std::uint64_t> channels{1}; 466 467 /** 468 A parsed \WebMID{BitDepth} element. 469 */ 470 Element<std::uint64_t> bit_depth; 471 472 /** 473 Returns true if every member within the two objects are equal. 474 */ 475 bool operator==(const Audio& other) const { 476 return sampling_frequency == other.sampling_frequency && 477 output_frequency == other.output_frequency && 478 channels == other.channels && bit_depth == other.bit_depth; 479 } 480 }; 481 482 /** 483 A parsed \WebMID{MasteringMetadata} element. 484 */ 485 struct MasteringMetadata { 486 /** 487 A parsed \WebMID{PrimaryRChromaticityX} element. 488 */ 489 Element<double> primary_r_chromaticity_x; 490 491 /** 492 A parsed \WebMID{PrimaryRChromaticityY} element. 493 */ 494 Element<double> primary_r_chromaticity_y; 495 496 /** 497 A parsed \WebMID{PrimaryGChromaticityX} element. 498 */ 499 Element<double> primary_g_chromaticity_x; 500 501 /** 502 A parsed \WebMID{PrimaryGChromaticityY} element. 503 */ 504 Element<double> primary_g_chromaticity_y; 505 506 /** 507 A parsed \WebMID{PrimaryBChromaticityX} element. 508 */ 509 Element<double> primary_b_chromaticity_x; 510 511 /** 512 A parsed \WebMID{PrimaryBChromaticityY} element. 513 */ 514 Element<double> primary_b_chromaticity_y; 515 516 /** 517 A parsed \WebMID{WhitePointChromaticityX} element. 518 */ 519 Element<double> white_point_chromaticity_x; 520 521 /** 522 A parsed \WebMID{WhitePointChromaticityY} element. 523 */ 524 Element<double> white_point_chromaticity_y; 525 526 /** 527 A parsed \WebMID{LuminanceMax} element. 528 */ 529 Element<double> luminance_max; 530 531 /** 532 A parsed \WebMID{LuminanceMin} element. 533 */ 534 Element<double> luminance_min; 535 536 /** 537 Returns true if every member within the two objects are equal. 538 */ 539 bool operator==(const MasteringMetadata& other) const { 540 return primary_r_chromaticity_x == other.primary_r_chromaticity_x && 541 primary_r_chromaticity_y == other.primary_r_chromaticity_y && 542 primary_g_chromaticity_x == other.primary_g_chromaticity_x && 543 primary_g_chromaticity_y == other.primary_g_chromaticity_y && 544 primary_b_chromaticity_x == other.primary_b_chromaticity_x && 545 primary_b_chromaticity_y == other.primary_b_chromaticity_y && 546 white_point_chromaticity_x == other.white_point_chromaticity_x && 547 white_point_chromaticity_y == other.white_point_chromaticity_y && 548 luminance_max == other.luminance_max && 549 luminance_min == other.luminance_min; 550 } 551 }; 552 553 /** 554 A parsed \WebMID{MatrixCoefficients} element. 555 556 Matroska/WebM adopted these values from Table 4 of ISO/IEC 23001-8:2013/DCOR1. 557 See that document for further details. 558 */ 559 enum class MatrixCoefficients : std::uint64_t { 560 /** 561 The identity matrix. 562 563 Typically used for GBR (often referred to as RGB); however, may also be used 564 for YZX (often referred to as XYZ). 565 */ 566 kRgb = 0, 567 568 /** 569 Rec. ITU-R BT.709-5. 570 */ 571 kBt709 = 1, 572 573 /** 574 Image characteristics are unknown or are determined by the application. 575 */ 576 kUnspecified = 2, 577 578 /** 579 United States Federal Communications Commission Title 47 Code of Federal 580 Regulations (2003) 73.682 (a) (20). 581 */ 582 kFcc = 4, 583 584 /** 585 Rec. ITU-R BT.470‑6 System B, G (historical). 586 */ 587 kBt470Bg = 5, 588 589 /** 590 Society of Motion Picture and Television Engineers 170M (2004). 591 */ 592 kSmpte170M = 6, 593 594 /** 595 Society of Motion Picture and Television Engineers 240M (1999). 596 */ 597 kSmpte240M = 7, 598 599 /** 600 YCgCo. 601 */ 602 kYCgCo = 8, 603 604 /** 605 Rec. ITU-R BT.2020 (non-constant luminance). 606 */ 607 kBt2020NonconstantLuminance = 9, 608 609 /** 610 Rec. ITU-R BT.2020 (constant luminance). 611 */ 612 kBt2020ConstantLuminance = 10, 613 }; 614 615 /** 616 A parsed \WebMID{Range} element. 617 */ 618 enum class Range : std::uint64_t { 619 /** 620 Unspecified. 621 */ 622 kUnspecified = 0, 623 624 /** 625 Broadcast range. 626 */ 627 kBroadcast = 1, 628 629 /** 630 Full range (no clipping). 631 */ 632 kFull = 2, 633 634 /** 635 Defined by MatrixCoefficients/TransferCharacteristics. 636 */ 637 kDerived = 3, 638 }; 639 640 /** 641 A parsed \WebMID{TransferCharacteristics} element. 642 643 Matroska/WebM adopted these values from Table 3 of ISO/IEC 23001-8:2013/DCOR1. 644 See that document for further details. 645 */ 646 enum class TransferCharacteristics : std::uint64_t { 647 /** 648 Rec. ITU-R BT.709-6. 649 */ 650 kBt709 = 1, 651 652 /** 653 Image characteristics are unknown or are determined by the application. 654 */ 655 kUnspecified = 2, 656 657 /** 658 Rec. ITU‑R BT.470‑6 System M (historical) with assumed display gamma 2.2. 659 */ 660 kGamma22curve = 4, 661 662 /** 663 Rec. ITU‑R BT.470-6 System B, G (historical) with assumed display gamma 2.8. 664 */ 665 kGamma28curve = 5, 666 667 /** 668 Society of Motion Picture and Television Engineers 170M (2004). 669 */ 670 kSmpte170M = 6, 671 672 /** 673 Society of Motion Picture and Television Engineers 240M (1999). 674 */ 675 kSmpte240M = 7, 676 677 /** 678 Linear transfer characteristics. 679 */ 680 kLinear = 8, 681 682 /** 683 Logarithmic transfer characteristic (100:1 range). 684 */ 685 kLog = 9, 686 687 /** 688 Logarithmic transfer characteristic (100 * Sqrt(10) : 1 range). 689 */ 690 kLogSqrt = 10, 691 692 /** 693 IEC 61966-2-4. 694 */ 695 kIec6196624 = 11, 696 697 /** 698 Rec. ITU‑R BT.1361-0 extended colour gamut system (historical). 699 */ 700 kBt1361ExtendedColourGamut = 12, 701 702 /** 703 IEC 61966-2-1 sRGB or sYCC. 704 */ 705 kIec6196621 = 13, 706 707 /** 708 Rec. ITU-R BT.2020-2 (10-bit system). 709 */ 710 k10BitBt2020 = 14, 711 712 /** 713 Rec. ITU-R BT.2020-2 (12-bit system). 714 */ 715 k12BitBt2020 = 15, 716 717 /** 718 Society of Motion Picture and Television Engineers ST 2084. 719 */ 720 kSmpteSt2084 = 16, 721 722 /** 723 Society of Motion Picture and Television Engineers ST 428-1. 724 */ 725 kSmpteSt4281 = 17, 726 727 /** 728 Association of Radio Industries and Businesses (ARIB) STD-B67. 729 */ 730 kAribStdB67Hlg = 18, 731 }; 732 733 /** 734 A parsed \WebMID{Primaries} element. 735 736 Matroska/WebM adopted these values from Table 2 of ISO/IEC 23001-8:2013/DCOR1. 737 See that document for further details. 738 */ 739 enum class Primaries : std::uint64_t { 740 /** 741 Rec. ITU‑R BT.709-6. 742 */ 743 kBt709 = 1, 744 745 /** 746 Image characteristics are unknown or are determined by the application. 747 */ 748 kUnspecified = 2, 749 750 /** 751 Rec. ITU‑R BT.470‑6 System M (historical). 752 */ 753 kBt470M = 4, 754 755 /** 756 Rec. ITU‑R BT.470‑6 System B, G (historical). 757 */ 758 kBt470Bg = 5, 759 760 /** 761 Society of Motion Picture and Television Engineers 170M (2004). 762 */ 763 kSmpte170M = 6, 764 765 /** 766 Society of Motion Picture and Television Engineers 240M (1999). 767 */ 768 kSmpte240M = 7, 769 770 /** 771 Generic film. 772 */ 773 kFilm = 8, 774 775 /** 776 Rec. ITU-R BT.2020-2. 777 */ 778 kBt2020 = 9, 779 780 /** 781 Society of Motion Picture and Television Engineers ST 428-1. 782 */ 783 kSmpteSt4281 = 10, 784 785 /** 786 Society of Motion Picture and Television Engineers RP 431-2 (a.k.a. DCI-P3). 787 */ 788 kSmpteRp431 = 11, 789 790 /** 791 Society of Motion Picture and Television Engineers EG 432-1 792 (a.k.a. DCI-P3 D65). 793 */ 794 kSmpteEg432 = 12, 795 796 /** 797 JEDEC P22 phosphors/EBU Tech. 3213-E (1975). 798 */ 799 kJedecP22Phosphors = 22, 800 }; 801 802 /** 803 A parsed \WebMID{Colour} element. 804 */ 805 struct Colour { 806 /** 807 A parsed \WebMID{MatrixCoefficients} element. 808 */ 809 Element<MatrixCoefficients> matrix_coefficients{ 810 MatrixCoefficients::kUnspecified}; 811 812 /** 813 A parsed \WebMID{BitsPerChannel} element. 814 */ 815 Element<std::uint64_t> bits_per_channel{0}; 816 817 /** 818 A parsed \WebMID{ChromaSubsamplingHorz} element. 819 */ 820 Element<std::uint64_t> chroma_subsampling_x; 821 822 /** 823 A parsed \WebMID{ChromaSubsamplingVert} element. 824 */ 825 Element<std::uint64_t> chroma_subsampling_y; 826 827 /** 828 A parsed \WebMID{CbSubsamplingHorz} element. 829 */ 830 Element<std::uint64_t> cb_subsampling_x; 831 832 /** 833 A parsed \WebMID{CbSubsamplingVert} element. 834 */ 835 Element<std::uint64_t> cb_subsampling_y; 836 837 /** 838 A parsed \WebMID{ChromaSitingHorz} element. 839 */ 840 Element<std::uint64_t> chroma_siting_x{0}; 841 842 /** 843 A parsed \WebMID{ChromaSitingVert} element. 844 */ 845 Element<std::uint64_t> chroma_siting_y{0}; 846 847 /** 848 A parsed \WebMID{Range} element. 849 */ 850 Element<Range> range{Range::kUnspecified}; 851 852 /** 853 A parsed \WebMID{TransferCharacteristics} element. 854 */ 855 Element<TransferCharacteristics> transfer_characteristics{ 856 TransferCharacteristics::kUnspecified}; 857 858 /** 859 A parsed \WebMID{Primaries} element. 860 */ 861 Element<Primaries> primaries{Primaries::kUnspecified}; 862 863 /** 864 A parsed \WebMID{MaxCLL} element. 865 */ 866 Element<std::uint64_t> max_cll; 867 868 /** 869 A parsed \WebMID{MaxFALL} element. 870 */ 871 Element<std::uint64_t> max_fall; 872 873 /** 874 A parsed \WebMID{MasteringMetadata} element. 875 */ 876 Element<MasteringMetadata> mastering_metadata; 877 878 /** 879 Returns true if every member within the two objects are equal. 880 */ 881 bool operator==(const Colour& other) const { 882 return matrix_coefficients == other.matrix_coefficients && 883 bits_per_channel == other.bits_per_channel && 884 chroma_subsampling_x == other.chroma_subsampling_x && 885 chroma_subsampling_y == other.chroma_subsampling_y && 886 cb_subsampling_x == other.cb_subsampling_x && 887 cb_subsampling_y == other.cb_subsampling_y && 888 chroma_siting_x == other.chroma_siting_x && 889 chroma_siting_y == other.chroma_siting_y && range == other.range && 890 transfer_characteristics == other.transfer_characteristics && 891 primaries == other.primaries && max_cll == other.max_cll && 892 max_fall == other.max_fall && 893 mastering_metadata == other.mastering_metadata; 894 } 895 }; 896 897 /** 898 A parsed \WebMID{ProjectionType} element. 899 */ 900 enum class ProjectionType : std::uint64_t { 901 /** 902 Rectangular. 903 */ 904 kRectangular = 0, 905 906 /** 907 Equirectangular. 908 */ 909 kEquirectangular = 1, 910 911 /** 912 Cube map. 913 */ 914 kCubeMap = 2, 915 916 /** 917 Mesh. 918 */ 919 kMesh = 3, 920 }; 921 922 /** 923 A parsed \WebMID{Projection} element. 924 */ 925 struct Projection { 926 /** 927 A parsed \WebMID{ProjectionType} element. 928 */ 929 Element<ProjectionType> type; 930 931 /** 932 A parsed \WebMID{ProjectionPrivate} element. 933 */ 934 Element<std::vector<std::uint8_t>> projection_private; 935 936 /** 937 A parsed \WebMID{ProjectionPoseYaw} element. 938 */ 939 Element<double> pose_yaw; 940 941 /** 942 A parsed \WebMID{ProjectionPosePitch} element. 943 */ 944 Element<double> pose_pitch; 945 946 /** 947 A parsed \WebMID{ProjectionPoseRoll} element. 948 */ 949 Element<double> pose_roll; 950 951 /** 952 Returns true if every member within the two objects are equal. 953 */ 954 bool operator==(const Projection& other) const { 955 return type == other.type && 956 projection_private == other.projection_private && 957 pose_yaw == other.pose_yaw && pose_pitch == other.pose_pitch && 958 pose_roll == other.pose_roll; 959 } 960 }; 961 962 /** 963 A parsed \WebMID{FlagInterlaced} element. 964 */ 965 enum class FlagInterlaced : std::uint64_t { 966 /** 967 Unspecified. 968 */ 969 kUnspecified = 0, 970 971 /** 972 Interlaced. 973 */ 974 kInterlaced = 1, 975 976 /** 977 Progressive. 978 */ 979 kProgressive = 2, 980 }; 981 982 /** 983 A parsed \WebMID{StereoMode} element. 984 */ 985 enum class StereoMode : std::uint64_t { 986 /** 987 Mono. 988 */ 989 kMono = 0, 990 991 /** 992 Side-by-side, left eye is first. 993 */ 994 kSideBySideLeftFirst = 1, 995 996 /** 997 Top-bottom, right eye is first. 998 */ 999 kTopBottomRightFirst = 2, 1000 1001 /** 1002 Top-bottom, left eye is first. 1003 */ 1004 kTopBottomLeftFirst = 3, 1005 1006 /** 1007 Checkboard, right eye is first. 1008 */ 1009 kCheckboardRightFirst = 4, 1010 1011 /** 1012 Checkboard, left eye is first. 1013 */ 1014 kCheckboardLeftFirst = 5, 1015 1016 /** 1017 Row interleaved, right eye is first. 1018 */ 1019 kRowInterleavedRightFirst = 6, 1020 1021 /** 1022 Row interleaved, left eye is first. 1023 */ 1024 kRowInterleavedLeftFirst = 7, 1025 1026 /** 1027 Column interleaved, right eye is first. 1028 */ 1029 kColumnInterleavedRightFirst = 8, 1030 1031 /** 1032 Column interleaved, left eye is first. 1033 */ 1034 kColumnInterleavedLeftFirst = 9, 1035 1036 /** 1037 Anaglyph (cyan/read). 1038 */ 1039 kAnaglyphCyanRed = 10, 1040 1041 /** 1042 Side-by-side, right eye is first. 1043 */ 1044 kSideBySideRightFirst = 11, 1045 1046 /** 1047 Anaglyph (green/magenta). 1048 */ 1049 kAnaglyphGreenMagenta = 12, 1050 1051 /** 1052 Both eyes are laced in one block, left eye is first. 1053 */ 1054 kBlockLacedLeftFirst = 13, 1055 1056 /** 1057 Both eyes are laced in one block, right eye is first. 1058 */ 1059 kBlockLacedRightFirst = 14, 1060 1061 /** 1062 Stereo, but the layout for the left and right eyes is application dependent 1063 and must be determined from other data (like the ProjectionPrivate element). 1064 */ 1065 kStereoCustom = 15, 1066 }; 1067 1068 /** 1069 A parsed \WebMID{DisplayUnit} element. 1070 1071 Note that WebM only supports pixel display units. Centimeters, inches, and 1072 display aspect ratio aren't supported. 1073 */ 1074 enum class DisplayUnit : std::uint64_t { 1075 // The only value legal value in WebM is 0 (pixels). 1076 /** 1077 Pixels. 1078 1079 This is the only option supported by WebM. 1080 */ 1081 kPixels = 0, 1082 1083 /** 1084 Centimeters. 1085 */ 1086 kCentimeters = 1, 1087 1088 /** 1089 Inches. 1090 */ 1091 kInches = 2, 1092 1093 /** 1094 Display aspect ratio. 1095 */ 1096 kDisplayAspectRatio = 3, 1097 }; 1098 1099 /** 1100 A parsed \WebMID{AspectRatioType} element. 1101 */ 1102 enum class AspectRatioType : std::uint64_t { 1103 /** 1104 Free resizing. 1105 */ 1106 kFreeResizing = 0, 1107 1108 /** 1109 Keep aspect ratio. 1110 */ 1111 kKeep = 1, 1112 1113 /** 1114 Fixed aspect ratio. 1115 */ 1116 kFixed = 2, 1117 }; 1118 1119 /** 1120 A parsed \WebMID{Video} element. 1121 */ 1122 struct Video { 1123 /** 1124 A parsed \WebMID{FlagInterlaced} element. 1125 */ 1126 Element<FlagInterlaced> interlaced{FlagInterlaced::kUnspecified}; 1127 1128 /** 1129 A parsed \WebMID{StereoMode} element. 1130 */ 1131 Element<StereoMode> stereo_mode{StereoMode::kMono}; 1132 1133 /** 1134 A parsed \WebMID{AlphaMode} element. 1135 */ 1136 Element<std::uint64_t> alpha_mode{0}; 1137 1138 /** 1139 A parsed \WebMID{PixelWidth} element. 1140 */ 1141 Element<std::uint64_t> pixel_width; 1142 1143 /** 1144 A parsed \WebMID{PixelHeight} element. 1145 */ 1146 Element<std::uint64_t> pixel_height; 1147 1148 /** 1149 A parsed \WebMID{PixelCropBottom} element. 1150 */ 1151 Element<std::uint64_t> pixel_crop_bottom{0}; 1152 1153 /** 1154 A parsed \WebMID{PixelCropTop} element. 1155 */ 1156 Element<std::uint64_t> pixel_crop_top{0}; 1157 1158 /** 1159 A parsed \WebMID{PixelCropLeft} element. 1160 */ 1161 Element<std::uint64_t> pixel_crop_left{0}; 1162 1163 /** 1164 A parsed \WebMID{PixelCropRight} element. 1165 */ 1166 Element<std::uint64_t> pixel_crop_right{0}; 1167 1168 /** 1169 A parsed \WebMID{DisplayWidth} element. 1170 */ 1171 Element<std::uint64_t> display_width; 1172 1173 /** 1174 A parsed \WebMID{DisplayHeight} element. 1175 */ 1176 Element<std::uint64_t> display_height; 1177 1178 /** 1179 A parsed \WebMID{DisplayUnit} element. 1180 */ 1181 Element<DisplayUnit> display_unit{DisplayUnit::kPixels}; 1182 1183 /** 1184 A parsed \WebMID{AspectRatioType} element. 1185 */ 1186 Element<AspectRatioType> aspect_ratio_type{AspectRatioType::kFreeResizing}; 1187 1188 /** 1189 A parsed \WebMID{FrameRate} element (deprecated). 1190 */ 1191 Element<double> frame_rate; 1192 1193 /** 1194 A parsed \WebMID{Colour} element. 1195 */ 1196 Element<Colour> colour; 1197 1198 /** 1199 A parsed \WebMID{Projection} element. 1200 */ 1201 Element<Projection> projection; 1202 1203 /** 1204 Returns true if every member within the two objects are equal. 1205 */ 1206 bool operator==(const Video& other) const { 1207 return interlaced == other.interlaced && stereo_mode == other.stereo_mode && 1208 alpha_mode == other.alpha_mode && pixel_width == other.pixel_width && 1209 pixel_height == other.pixel_height && 1210 pixel_crop_bottom == other.pixel_crop_bottom && 1211 pixel_crop_top == other.pixel_crop_top && 1212 pixel_crop_left == other.pixel_crop_left && 1213 pixel_crop_right == other.pixel_crop_right && 1214 display_width == other.display_width && 1215 display_height == other.display_height && 1216 display_unit == other.display_unit && 1217 aspect_ratio_type == other.aspect_ratio_type && 1218 frame_rate == other.frame_rate && colour == other.colour && 1219 projection == other.projection; 1220 } 1221 }; 1222 1223 /** 1224 A parsed \WebMID{AESSettingsCipherMode} element. 1225 */ 1226 enum class AesSettingsCipherMode : std::uint64_t { 1227 /** 1228 Counter (CTR). 1229 */ 1230 kCtr = 1, 1231 }; 1232 1233 /** 1234 A parsed \WebMID{ContentEncAESSettings} element. 1235 */ 1236 struct ContentEncAesSettings { 1237 /** 1238 A parsed \WebMID{AESSettingsCipherMode} element. 1239 */ 1240 Element<AesSettingsCipherMode> aes_settings_cipher_mode{ 1241 AesSettingsCipherMode::kCtr}; 1242 1243 /** 1244 Returns true if every member within the two objects are equal. 1245 */ 1246 bool operator==(const ContentEncAesSettings& other) const { 1247 return aes_settings_cipher_mode == other.aes_settings_cipher_mode; 1248 } 1249 }; 1250 1251 /** 1252 A parsed \WebMID{ContentEncAlgo} element. 1253 */ 1254 enum class ContentEncAlgo : std::uint64_t { 1255 /** 1256 The contents have been signed but not encrypted. 1257 */ 1258 kOnlySigned = 0, 1259 1260 /** 1261 DES encryption. 1262 */ 1263 kDes = 1, 1264 1265 /** 1266 3DES encryption. 1267 */ 1268 k3Des = 2, 1269 1270 /** 1271 Twofish encryption. 1272 */ 1273 kTwofish = 3, 1274 1275 /** 1276 Blowfish encryption. 1277 */ 1278 kBlowfish = 4, 1279 1280 /** 1281 AES encryption. 1282 */ 1283 kAes = 5, 1284 }; 1285 1286 /** 1287 A parsed \WebMID{ContentEncryption} element. 1288 */ 1289 struct ContentEncryption { 1290 /** 1291 A parsed \WebMID{ContentEncAlgo} element. 1292 */ 1293 Element<ContentEncAlgo> algorithm{ContentEncAlgo::kOnlySigned}; 1294 1295 /** 1296 A parsed \WebMID{ContentEncKeyID} element. 1297 */ 1298 Element<std::vector<std::uint8_t>> key_id; 1299 1300 /** 1301 A parsed \WebMID{ContentEncAESSettings} element. 1302 */ 1303 Element<ContentEncAesSettings> aes_settings; 1304 1305 /** 1306 Returns true if every member within the two objects are equal. 1307 */ 1308 bool operator==(const ContentEncryption& other) const { 1309 return algorithm == other.algorithm && key_id == other.key_id && 1310 aes_settings == other.aes_settings; 1311 } 1312 }; 1313 1314 /** 1315 A parsed \WebMID{ContentEncodingType} element. 1316 */ 1317 enum class ContentEncodingType : std::uint64_t { 1318 /** 1319 Compression. 1320 */ 1321 kCompression = 0, 1322 1323 /** 1324 Encryption. 1325 */ 1326 kEncryption = 1, 1327 }; 1328 1329 /** 1330 A parsed \WebMID{ContentEncoding} element. 1331 */ 1332 struct ContentEncoding { 1333 /** 1334 A parsed \WebMID{ContentEncodingOrder} element. 1335 */ 1336 Element<std::uint64_t> order{0}; 1337 1338 /** 1339 A parsed \WebMID{ContentEncodingScope} element. 1340 */ 1341 Element<std::uint64_t> scope{1}; 1342 1343 /** 1344 A parsed \WebMID{ContentEncodingType} element. 1345 */ 1346 Element<ContentEncodingType> type{ContentEncodingType::kCompression}; 1347 1348 /** 1349 A parsed \WebMID{ContentEncryption} element. 1350 */ 1351 Element<ContentEncryption> encryption; 1352 1353 /** 1354 Returns true if every member within the two objects are equal. 1355 */ 1356 bool operator==(const ContentEncoding& other) const { 1357 return order == other.order && scope == other.scope && type == other.type && 1358 encryption == other.encryption; 1359 } 1360 }; 1361 1362 /** 1363 A parsed \WebMID{ContentEncodings} element. 1364 */ 1365 struct ContentEncodings { 1366 /** 1367 Parsed \WebMID{ContentEncoding} elements. 1368 */ 1369 std::vector<Element<ContentEncoding>> encodings; 1370 1371 /** 1372 Returns true if every member within the two objects are equal. 1373 */ 1374 bool operator==(const ContentEncodings& other) const { 1375 return encodings == other.encodings; 1376 } 1377 }; 1378 1379 /** 1380 A parsed \WebMID{TrackType} element. 1381 */ 1382 enum class TrackType : std::uint64_t { 1383 /** 1384 Video. 1385 */ 1386 kVideo = 0x01, 1387 1388 /** 1389 Audio. 1390 */ 1391 kAudio = 0x02, 1392 1393 /** 1394 Complex. 1395 */ 1396 kComplex = 0x03, 1397 1398 /** 1399 Logo. 1400 */ 1401 kLogo = 0x10, 1402 1403 /** 1404 Subtitle. 1405 */ 1406 kSubtitle = 0x11, 1407 1408 /** 1409 Buttons. 1410 */ 1411 kButtons = 0x12, 1412 1413 /** 1414 Control. 1415 */ 1416 kControl = 0x20, 1417 }; 1418 1419 /** 1420 A parsed \WebMID{TrackEntry} element. 1421 */ 1422 struct TrackEntry { 1423 /** 1424 A parsed \WebMID{TrackNumber} element. 1425 */ 1426 Element<std::uint64_t> track_number; 1427 1428 /** 1429 A parsed \WebMID{TrackUID} element. 1430 */ 1431 Element<std::uint64_t> track_uid; 1432 1433 /** 1434 A parsed \WebMID{TrackType} element. 1435 */ 1436 Element<TrackType> track_type; 1437 1438 /** 1439 A parsed \WebMID{FlagEnabled} element. 1440 */ 1441 Element<bool> is_enabled{true}; 1442 1443 /** 1444 A parsed \WebMID{FlagDefault} element. 1445 */ 1446 Element<bool> is_default{true}; 1447 1448 /** 1449 A parsed \WebMID{FlagForced} element. 1450 */ 1451 Element<bool> is_forced{false}; 1452 1453 /** 1454 A parsed \WebMID{FlagLacing} element. 1455 */ 1456 Element<bool> uses_lacing{true}; 1457 1458 /** 1459 A parsed \WebMID{DefaultDuration} element. 1460 */ 1461 Element<std::uint64_t> default_duration; 1462 1463 /** 1464 A parsed \WebMID{Name} element. 1465 */ 1466 Element<std::string> name; 1467 1468 /** 1469 A parsed \WebMID{Language} element. 1470 */ 1471 Element<std::string> language{"eng"}; 1472 1473 /** 1474 A parsed \WebMID{CodecID} element. 1475 */ 1476 Element<std::string> codec_id; 1477 1478 /** 1479 A parsed \WebMID{CodecPrivate} element. 1480 */ 1481 Element<std::vector<std::uint8_t>> codec_private; 1482 1483 /** 1484 A parsed \WebMID{CodecName} element. 1485 */ 1486 Element<std::string> codec_name; 1487 1488 /** 1489 A parsed \WebMID{CodecDelay} element. 1490 */ 1491 Element<std::uint64_t> codec_delay{0}; 1492 1493 /** 1494 A parsed \WebMID{SeekPreRoll} element. 1495 */ 1496 Element<std::uint64_t> seek_pre_roll{0}; 1497 1498 /** 1499 A parsed \WebMID{Video} element. 1500 */ 1501 Element<Video> video; 1502 1503 /** 1504 A parsed \WebMID{Audio} element. 1505 */ 1506 Element<Audio> audio; 1507 1508 /** 1509 A parsed \WebMID{ContentEncodings} element. 1510 */ 1511 Element<ContentEncodings> content_encodings; 1512 1513 /** 1514 Returns true if every member within the two objects are equal. 1515 */ 1516 bool operator==(const TrackEntry& other) const { 1517 return track_number == other.track_number && track_uid == other.track_uid && 1518 track_type == other.track_type && is_enabled == other.is_enabled && 1519 is_default == other.is_default && is_forced == other.is_forced && 1520 uses_lacing == other.uses_lacing && 1521 default_duration == other.default_duration && name == other.name && 1522 language == other.language && codec_id == other.codec_id && 1523 codec_private == other.codec_private && 1524 codec_name == other.codec_name && codec_delay == other.codec_delay && 1525 seek_pre_roll == other.seek_pre_roll && video == other.video && 1526 audio == other.audio && content_encodings == other.content_encodings; 1527 } 1528 }; 1529 1530 /** 1531 A parsed \WebMID{CueTrackPositions} element. 1532 */ 1533 struct CueTrackPositions { 1534 /** 1535 A parsed \WebMID{CueTrack} element. 1536 */ 1537 Element<std::uint64_t> track; 1538 1539 /** 1540 A parsed \WebMID{CueClusterPosition} element. 1541 */ 1542 Element<std::uint64_t> cluster_position; 1543 1544 /** 1545 A parsed \WebMID{CueRelativePosition} element. 1546 */ 1547 Element<std::uint64_t> relative_position; 1548 1549 /** 1550 A parsed \WebMID{CueDuration} element. 1551 */ 1552 Element<std::uint64_t> duration; 1553 1554 /** 1555 A parsed \WebMID{CueBlockNumber} element. 1556 */ 1557 Element<std::uint64_t> block_number{1}; 1558 1559 /** 1560 Returns true if every member within the two objects are equal. 1561 */ 1562 bool operator==(const CueTrackPositions& other) const { 1563 return track == other.track && cluster_position == other.cluster_position && 1564 relative_position == other.relative_position && 1565 duration == other.duration && block_number == other.block_number; 1566 } 1567 }; 1568 1569 /** 1570 A parsed \WebMID{CuePoint} element. 1571 */ 1572 struct CuePoint { 1573 /** 1574 A parsed \WebMID{CueTime} element. 1575 */ 1576 Element<std::uint64_t> time; 1577 1578 /** 1579 Parsed \WebMID{CueTrackPositions} elements. 1580 */ 1581 std::vector<Element<CueTrackPositions>> cue_track_positions; 1582 1583 /** 1584 Returns true if every member within the two objects are equal. 1585 */ 1586 bool operator==(const CuePoint& other) const { 1587 return time == other.time && 1588 cue_track_positions == other.cue_track_positions; 1589 } 1590 }; 1591 1592 /** 1593 A parsed \WebMID{ChapterDisplay} element. 1594 */ 1595 struct ChapterDisplay { 1596 /** 1597 A parsed \WebMID{ChapString} element. 1598 */ 1599 Element<std::string> string; 1600 1601 /** 1602 Parsed \WebMID{ChapLanguage} elements. 1603 */ 1604 std::vector<Element<std::string>> languages{Element<std::string>{"eng"}}; 1605 1606 /** 1607 Parsed \WebMID{ChapCountry} elements. 1608 */ 1609 std::vector<Element<std::string>> countries; 1610 1611 /** 1612 Returns true if every member within the two objects are equal. 1613 */ 1614 bool operator==(const ChapterDisplay& other) const { 1615 return string == other.string && languages == other.languages && 1616 countries == other.countries; 1617 } 1618 }; 1619 1620 /** 1621 A parsed \WebMID{ChapterAtom} element. 1622 */ 1623 struct ChapterAtom { 1624 /** 1625 A parsed \WebMID{ChapterUID} element. 1626 */ 1627 Element<std::uint64_t> uid; 1628 1629 /** 1630 A parsed \WebMID{ChapterStringUID} element. 1631 */ 1632 Element<std::string> string_uid; 1633 1634 /** 1635 A parsed \WebMID{ChapterTimeStart} element. 1636 */ 1637 Element<std::uint64_t> time_start; 1638 1639 /** 1640 A parsed \WebMID{ChapterTimeEnd} element. 1641 */ 1642 Element<std::uint64_t> time_end; 1643 1644 /** 1645 Parsed \WebMID{ChapterDisplay} elements. 1646 */ 1647 std::vector<Element<ChapterDisplay>> displays; 1648 1649 /** 1650 Parsed \WebMID{ChapterAtom} elements. 1651 */ 1652 std::vector<Element<ChapterAtom>> atoms; 1653 1654 /** 1655 Returns true if every member within the two objects are equal. 1656 */ 1657 bool operator==(const ChapterAtom& other) const { 1658 return uid == other.uid && string_uid == other.string_uid && 1659 time_start == other.time_start && time_end == other.time_end && 1660 displays == other.displays && atoms == other.atoms; 1661 } 1662 }; 1663 1664 /** 1665 A parsed \WebMID{EditionEntry} element. 1666 */ 1667 struct EditionEntry { 1668 /** 1669 Parsed \WebMID{ChapterAtom} elements. 1670 */ 1671 std::vector<Element<ChapterAtom>> atoms; 1672 1673 /** 1674 Returns true if every member within the two objects are equal. 1675 */ 1676 bool operator==(const EditionEntry& other) const { 1677 return atoms == other.atoms; 1678 } 1679 }; 1680 1681 /** 1682 A parsed \WebMID{SimpleTag} element. 1683 */ 1684 struct SimpleTag { 1685 /** 1686 A parsed \WebMID{TagName} element. 1687 */ 1688 Element<std::string> name; 1689 1690 /** 1691 A parsed \WebMID{TagLanguage} element. 1692 */ 1693 Element<std::string> language{"und"}; 1694 1695 /** 1696 A parsed \WebMID{TagDefault} element. 1697 */ 1698 Element<bool> is_default{true}; 1699 1700 /** 1701 A parsed \WebMID{TagString} element. 1702 */ 1703 Element<std::string> string; 1704 1705 /** 1706 A parsed \WebMID{TagBinary} element. 1707 */ 1708 Element<std::vector<std::uint8_t>> binary; 1709 1710 /** 1711 Parsed \WebMID{SimpleTag} elements. 1712 */ 1713 std::vector<Element<SimpleTag>> tags; 1714 1715 /** 1716 Returns true if every member within the two objects are equal. 1717 */ 1718 bool operator==(const SimpleTag& other) const { 1719 return name == other.name && language == other.language && 1720 is_default == other.is_default && string == other.string && 1721 binary == other.binary && tags == other.tags; 1722 } 1723 }; 1724 1725 /** 1726 A parsed \WebMID{Targets} element. 1727 */ 1728 struct Targets { 1729 /** 1730 A parsed \WebMID{TargetTypeValue} element. 1731 */ 1732 Element<std::uint64_t> type_value{50}; 1733 1734 /** 1735 A parsed \WebMID{TargetType} element. 1736 */ 1737 Element<std::string> type; 1738 1739 /** 1740 Parsed \WebMID{TagTrackUID} elements. 1741 */ 1742 std::vector<Element<std::uint64_t>> track_uids; 1743 1744 /** 1745 Returns true if every member within the two objects are equal. 1746 */ 1747 bool operator==(const Targets& other) const { 1748 return type_value == other.type_value && type == other.type && 1749 track_uids == other.track_uids; 1750 } 1751 }; 1752 1753 /** 1754 A parsed \WebMID{Tag} element. 1755 */ 1756 struct Tag { 1757 /** 1758 A parsed \WebMID{Targets} element. 1759 */ 1760 Element<Targets> targets; 1761 1762 /** 1763 Parsed \WebMID{SimpleTag} elements. 1764 */ 1765 std::vector<Element<SimpleTag>> tags; 1766 1767 /** 1768 Returns true if every member within the two objects are equal. 1769 */ 1770 bool operator==(const Tag& other) const { 1771 return targets == other.targets && tags == other.tags; 1772 } 1773 }; 1774 1775 /** 1776 @} 1777 */ 1778 1779 } // namespace webm 1780 1781 #endif // INCLUDE_WEBM_DOM_TYPES_H_ 1782