├── .gitignore ├── .gitmodules ├── CMakeLists.txt ├── LICENSE.txt ├── README.md ├── TODO.txt ├── demo ├── dump.cc └── ftyp.cc ├── extern └── CMakeLists.txt ├── include └── mpeg-isobase │ ├── box.h │ ├── box │ ├── additional_metadata_container.h │ ├── audio_sample_entry.h │ ├── binary_xml.h │ ├── chunk_large_offset.h │ ├── chunk_offset.h │ ├── compact_sample_size.h │ ├── composition_offset.h │ ├── composition_to_decode.h │ ├── copyright.h │ ├── data_entry_url.h │ ├── data_entry_urn.h │ ├── data_information.h │ ├── data_reference.h │ ├── degradation_priority.h │ ├── edit_list.h │ ├── extended_language.h │ ├── fd_item_information.h │ ├── fd_session_group.h │ ├── fec_reservoir.h │ ├── file_partition.h │ ├── file_reservoir.h │ ├── file_type.h │ ├── full.h │ ├── group_id_to_name.h │ ├── handler.h │ ├── hint_media_header.h │ ├── hint_sample_entry.h │ ├── ipmpcontrol.h │ ├── ipmpinfo.h │ ├── item_data.h │ ├── item_info.h │ ├── item_info_entry.h │ ├── item_location.h │ ├── item_protection.h │ ├── item_reference.h │ ├── level_assignment.h │ ├── media_header.h │ ├── meta.h │ ├── metabox_relation.h │ ├── movie_extends_header.h │ ├── movie_fragment_header.h │ ├── movie_fragment_random_access_offset.h │ ├── movie_header.h │ ├── null_media_header.h │ ├── original_format.h │ ├── padding_bits.h │ ├── partition_entry.h │ ├── primary_item.h │ ├── producer_reference_time.h │ ├── progressive_download_info.h │ ├── protection_scheme_info.h │ ├── sample_auxiliary_information_sizes.h │ ├── sample_dependency_type.h │ ├── sample_description.h │ ├── sample_entry.h │ ├── sample_group_description.h │ ├── sample_scale.h │ ├── sample_size.h │ ├── sample_to_chunk.h │ ├── sample_to_group.h │ ├── scheme_information.h │ ├── scheme_type.h │ ├── segment_index.h │ ├── segment_type.h │ ├── shadow_sync_sample.h │ ├── sound_media_header.h │ ├── sub_track.h │ ├── sub_track_information.h │ ├── subsample_information.h │ ├── subsegment_index.h │ ├── subtitle_media_header.h │ ├── sync_sample.h │ ├── time_to_sample.h │ ├── track_extends.h │ ├── track_fragment_base_media_decode_time.h │ ├── track_fragment_header.h │ ├── track_fragment_random_access.h │ ├── track_header.h │ ├── track_reference.h │ ├── track_reference_type.h │ ├── track_run.h │ ├── track_selection.h │ ├── user_data.h │ ├── video_media_header.h │ ├── visual_sample_entry.h │ └── xml.h │ ├── box_desc.h │ ├── box_entries.h │ ├── box_map.h │ ├── boxes.h │ ├── composer.h │ └── parser.h ├── src ├── box.cc ├── box │ ├── additional_metadata_container.cc │ ├── audio_sample_entry.cc │ ├── binary_xml.cc │ ├── chunk_large_offset.cc │ ├── chunk_offset.cc │ ├── compact_sample_size.cc │ ├── composition_offset.cc │ ├── composition_to_decode.cc │ ├── copyright.cc │ ├── data_entry_url.cc │ ├── data_entry_urn.cc │ ├── data_information.cc │ ├── data_reference.cc │ ├── degradation_priority.cc │ ├── edit_list.cc │ ├── extended_language.cc │ ├── fd_item_information.cc │ ├── fd_session_group.cc │ ├── fec_reservoir.cc │ ├── file_partition.cc │ ├── file_reservoir.cc │ ├── file_type.cc │ ├── full.cc │ ├── group_id_to_name.cc │ ├── handler.cc │ ├── hint_media_header.cc │ ├── hint_sample_entry.cc │ ├── ipmpcontrol.cc │ ├── ipmpinfo.cc │ ├── item_data.cc │ ├── item_info.cc │ ├── item_info_entry.cc │ ├── item_location.cc │ ├── item_protection.cc │ ├── item_reference.cc │ ├── level_assignment.cc │ ├── media_header.cc │ ├── meta.cc │ ├── metabox_relation.cc │ ├── movie_extends_header.cc │ ├── movie_fragment_header.cc │ ├── movie_fragment_random_access_offset.cc │ ├── movie_header.cc │ ├── null_media_header.cc │ ├── original_format.cc │ ├── padding_bits.cc │ ├── partition_entry.cc │ ├── primary_item.cc │ ├── producer_reference_time.cc │ ├── progressive_download_info.cc │ ├── protection_scheme_info.cc │ ├── sample_auxiliary_information_sizes.cc │ ├── sample_dependency_type.cc │ ├── sample_description.cc │ ├── sample_entry.cc │ ├── sample_group_description.cc │ ├── sample_scale.cc │ ├── sample_size.cc │ ├── sample_to_chunk.cc │ ├── sample_to_group.cc │ ├── scheme_information.cc │ ├── scheme_type.cc │ ├── segment_index.cc │ ├── segment_type.cc │ ├── shadow_sync_sample.cc │ ├── sound_media_header.cc │ ├── sub_track.cc │ ├── sub_track_information.cc │ ├── subsample_information.cc │ ├── subsegment_index.cc │ ├── subtitle_media_header.cc │ ├── sync_sample.cc │ ├── time_to_sample.cc │ ├── track_extends.cc │ ├── track_fragment_base_media_decode_time.cc │ ├── track_fragment_header.cc │ ├── track_fragment_random_access.cc │ ├── track_header.cc │ ├── track_reference.cc │ ├── track_reference_type.cc │ ├── track_run.cc │ ├── track_selection.cc │ ├── user_data.cc │ ├── video_media_header.cc │ ├── visual_sample_entry.cc │ └── xml.cc ├── box_desc.cc ├── box_entries.cc ├── box_map.cc ├── boxes.cc └── parser.cc └── test ├── CMakeLists.txt ├── file_list_processing.h ├── test_box_map.cc ├── test_boxes.cc └── test_parser.cc /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "bitstream"] 2 | path = extern/bitstream 3 | url = git@github.com:DicomJ/bitstream.git 4 | branch = master 5 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.8) 2 | project(mpeg-isobase) 3 | include(GNUInstallDirs) 4 | 5 | add_definitions(-std=${CXX_STD} -Wno-multichar) 6 | file(GLOB sources src/*.cc src/box/*.cc) 7 | include_directories(PUBLIC include PRIVATE src) 8 | add_library(lib${PROJECT_NAME}_object OBJECT ${sources}) 9 | set_target_properties(lib${PROJECT_NAME}_object PROPERTIES POSITION_INDEPENDENT_CODE ON) 10 | 11 | add_library(lib${PROJECT_NAME}_shared SHARED $) 12 | add_library(lib${PROJECT_NAME}_static STATIC $) 13 | set_target_properties(lib${PROJECT_NAME}_shared lib${PROJECT_NAME}_static PROPERTIES OUTPUT_NAME ${PROJECT_NAME}) 14 | 15 | install(TARGETS lib${PROJECT_NAME}_shared lib${PROJECT_NAME}_static 16 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} 17 | ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) 18 | install(DIRECTORY include/${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) 19 | 20 | 21 | # Externs 22 | 23 | add_subdirectory(extern) 24 | 25 | ExternalProject_Get_Property(bitstream INSTALL_DIR) 26 | add_dependencies(lib${PROJECT_NAME}_object bitstream) 27 | include_directories(PUBLIC ${INSTALL_DIR}/${CMAKE_INSTALL_INCLUDEDIR}) 28 | target_link_libraries(lib${PROJECT_NAME}_shared ${INSTALL_DIR}/${CMAKE_INSTALL_LIBDIR}/libbitstream${CMAKE_SHARED_LIBRARY_SUFFIX}) 29 | 30 | install(DIRECTORY ${INSTALL_DIR}/${CMAKE_INSTALL_LIBDIR}/ # make sure trailing slash 31 | DESTINATION ${CMAKE_INSTALL_LIBDIR}) 32 | install(DIRECTORY ${INSTALL_DIR}/${CMAKE_INSTALL_INCLUDEDIR}/ # make sure trailing slash 33 | DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) 34 | 35 | # Tests 36 | 37 | if(CMAKE_BUILD_TYPE MATCHES Debug) 38 | enable_testing() 39 | add_subdirectory(test) 40 | endif() 41 | 42 | -------------------------------------------------------------------------------- /TODO.txt: -------------------------------------------------------------------------------- 1 | Items to be done: 2 | - make a check of max_depth for nexted boxes 3 | - ability to override box class within box map 4 | - ability to clone box map 5 | - handle text and sbtl handler_type\s 6 | -------------------------------------------------------------------------------- /demo/dump.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | int main(int argc, const char **argv) { 8 | for (int i = 1; i < argc; ++i) { 9 | try { 10 | bitstream::input::file::Stream stream(argv[i]); 11 | mpeg::isobase::Parser parser(stream, bitstream::output::print::to_stdout); 12 | parser.parse(); 13 | } catch (const std::exception &e) { 14 | std::cerr << e.what() << std::endl; 15 | } 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /demo/ftyp.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | 7 | int main(int argc, const char **argv) { 8 | for (int i = 1; i < argc; ++i) { 9 | try { 10 | struct: bitstream::Parser::Observer { 11 | virtual void event(const bitstream::Parser::Event::Header &event) { 12 | auto box = dynamic_cast(&event.header); 13 | if (box != nullptr) { 14 | assert(box->type() == 'ftyp'); 15 | std::cout << "Found 'ftyp' box of " << box->size() << " bytes size." << std::endl; 16 | } 17 | } 18 | } observer; 19 | bitstream::input::file::Stream stream(argv[i]); 20 | mpeg::isobase::Parser parser(stream, observer); 21 | parser.parse(); 22 | } catch (const std::exception &e) { 23 | std::cerr << e.what() << std::endl; 24 | } 25 | } 26 | } 27 | 28 | -------------------------------------------------------------------------------- /extern/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include(ExternalProject) 2 | 3 | Execute_Process(COMMAND git submodule update --init 4 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) 5 | 6 | ExternalProject_Add(bitstream 7 | SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/bitstream 8 | BINARY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/bitstream/build 9 | INSTALL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/bitstream/build/install 10 | CMAKE_ARGS -DCMAKE_INSTALL_PREFIX= -DCXX_STD=${CXX_STD} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} 11 | ) 12 | 13 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/additional_metadata_container.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_ADDITIONAL_METADATA_CONTAINER_BOX__ 2 | #define __MPEG_ISOBASE_ADDITIONAL_METADATA_CONTAINER_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct AdditionalMetadataContainerBox: Box { 14 | 15 | static constexpr Type container_type[] = {'moov', 'trak'}; 16 | static constexpr Type box_type = 'meco'; 17 | static constexpr const char *box_name = "AdditionalMetadataContainerBox"; 18 | 19 | AdditionalMetadataContainerBox(Composer &composer, bool largesize = false): Box(composer, box_type, largesize) {} 20 | AdditionalMetadataContainerBox(Parser &parser): Box(parser) {} 21 | }; 22 | 23 | 24 | }} // namespace mpeg::isobase 25 | 26 | #endif // __MPEG_ISOBASE_ADDITIONAL_METADATA_CONTAINER_BOX__ 27 | 28 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/audio_sample_entry.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_AUDIO_SAMPLE_ENTRY__ 2 | #define __MPEG_ISOBASE_AUDIO_SAMPLE_ENTRY__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct AudioSampleEntry: SampleEntry { 14 | 15 | static constexpr Type box_type = 'soun'; 16 | static constexpr const char *box_name = "AudioSampleEntry"; 17 | 18 | union { Footprint<2 * 32 + 4 * 16 + 32> header; 19 | UInt32< 0>::Static::Array<2> reserved; // = 0; 20 | UInt16< 64> channelcount; // = 2; 21 | UInt16< 80> samplesize; // = 16; 22 | UInt16< 96> pre_defined; // = 0; 23 | UInt16<112> reserved2; // = 0; 24 | UInt32<128> samplerate; // {timescale of media}<<16; 25 | }; 26 | 27 | template ::value> 28 | void AudioSampleEntry_(Composer &composer) { 29 | composer.get(header); 30 | const_field(reserved, {0, 0}); 31 | //const_fieldassert(channelcount, 2); 32 | const_field(samplesize, 16); 33 | const_field(pre_defined, 0); 34 | const_field(reserved2, 0); 35 | } 36 | 37 | AudioSampleEntry(Composer &composer, bool largesize = false): SampleEntry(composer, box_type, largesize) { 38 | AudioSampleEntry_(composer); 39 | } 40 | 41 | AudioSampleEntry(Parser &parser): SampleEntry(parser) { 42 | AudioSampleEntry_(parser); 43 | } 44 | 45 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 46 | 47 | }; 48 | 49 | 50 | }} // namespace mpeg::isobase 51 | 52 | #endif // __MPEG_ISOBASE_AUDIO_SAMPLE_ENTRY__ 53 | 54 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/binary_xml.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_BINARY_XML_BOX__ 2 | #define __MPEG_ISOBASE_BINARY_XML_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct BinaryXMLBox: FullBox { 14 | 15 | static constexpr Type container_type = 'meta'; 16 | static constexpr Type box_type = 'bxml'; 17 | static constexpr const char *box_name = "BinaryXMLBox"; 18 | 19 | UInt8<>::Array data; 20 | 21 | BinaryXMLBox(Composer &composer, const std::vector &data, Version version = 0, bool largesize = false): FullBox(composer, box_type, version, Flags(0), largesize) { 22 | composer.get(this->data, data); 23 | } 24 | 25 | BinaryXMLBox(Parser &parser): FullBox(parser, Flags(0)) { 26 | parser.get(*this, data); 27 | } 28 | 29 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 30 | 31 | }; 32 | 33 | 34 | }} // namespace mpeg::isobase 35 | 36 | #endif // __MPEG_ISOBASE_BINARY_XML_BOX__ 37 | 38 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/chunk_large_offset.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_CHUNK_LARGE_OFFSET_BOX__ 2 | #define __MPEG_ISOBASE_CHUNK_LARGE_OFFSET_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | namespace mpeg { 11 | namespace isobase { 12 | 13 | 14 | struct ChunkLargeOffsetBox: FullBox { 15 | 16 | static constexpr Type container_type = 'stbl'; 17 | static constexpr Type box_type = 'co64'; 18 | static constexpr const char *box_name = "ChunkLargeOffsetBox"; 19 | 20 | UInt32<0> entry_count; 21 | 22 | struct Entry; 23 | struct Parsed { 24 | using Entries = Box::Parsed::Entries; 25 | }; 26 | struct Composed { 27 | using Entries = Box::Composed::Entries; 28 | }; 29 | 30 | ChunkLargeOffsetBox(Composer &composer, uint32_t entry_count, Version version = 0, bool largesize = false): FullBox(composer, box_type, version, Flags(0), largesize) { 31 | composer.get(this->entry_count) = entry_count; 32 | } 33 | 34 | ChunkLargeOffsetBox(Parser &parser): FullBox(parser, Flags(0)) { 35 | parser.get(entry_count); 36 | //assert(entry_count > 0); 37 | } 38 | 39 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 40 | 41 | virtual void parse_payload(Remainder left_payload); 42 | }; 43 | 44 | 45 | struct ChunkLargeOffsetBox::Entry : Box::Entry { 46 | union { Footprint<64> header; 47 | UInt64<0> chunk_offset; 48 | }; 49 | 50 | Entry(const Entry &entry): header(entry.header), Box::Entry(entry) {} 51 | 52 | template 53 | Entry(const ChunkLargeOffsetBox &, Composer &composer) { 54 | composer.get(header); 55 | } 56 | 57 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 58 | 59 | }; 60 | 61 | 62 | }} // namespace mpeg::isobase 63 | 64 | #endif // __MPEG_ISOBASE_CHUNK_LARGE_OFFSET_BOX__ 65 | 66 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/chunk_offset.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_CHUNK_OFFSET_BOX__ 2 | #define __MPEG_ISOBASE_CHUNK_OFFSET_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | namespace mpeg { 11 | namespace isobase { 12 | 13 | 14 | struct ChunkOffsetBox: FullBox { 15 | 16 | static constexpr Type container_type = 'stbl'; 17 | static constexpr Type box_type = 'stco'; 18 | static constexpr const char *box_name = "ChunkOffsetBox"; 19 | 20 | UInt32<0> entry_count; 21 | 22 | struct Entry; 23 | struct Parsed { 24 | using Entries = Box::Parsed::Entries; 25 | }; 26 | struct Composed { 27 | using Entries = Box::Composed::Entries; 28 | }; 29 | 30 | ChunkOffsetBox(Composer &composer, uint32_t entry_count, Version version = 0, bool largesize = false): FullBox(composer, box_type, version, Flags(0), largesize) { 31 | composer.get(this->entry_count) = entry_count; 32 | } 33 | 34 | ChunkOffsetBox(Parser &parser): FullBox(parser, Flags(0)) { 35 | parser.get(entry_count); 36 | //assert(entry_count > 0); 37 | } 38 | 39 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 40 | 41 | virtual void parse_payload(Remainder left_payload); 42 | }; 43 | 44 | 45 | struct ChunkOffsetBox::Entry : Box::Entry { 46 | union { Footprint<32> header; 47 | UInt32<0> chunk_offset; 48 | }; 49 | 50 | Entry(const Entry &entry): header(entry.header), Box::Entry(entry) {} 51 | 52 | template 53 | Entry(const ChunkOffsetBox &, Composer &composer) { 54 | composer.get(header); 55 | } 56 | 57 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 58 | 59 | }; 60 | 61 | 62 | }} // namespace mpeg::isobase 63 | 64 | #endif // __MPEG_ISOBASE_CHUNK_OFFSET_BOX__ 65 | 66 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/composition_offset.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_COMPOSITION_OFFSET_BOX__ 2 | #define __MPEG_ISOBASE_COMPOSITION_OFFSET_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | 11 | namespace mpeg { 12 | namespace isobase { 13 | 14 | 15 | struct CompositionOffsetBox: FullBox { 16 | 17 | static constexpr Type container_type = 'stbl'; 18 | static constexpr Type box_type = 'ctts'; 19 | static constexpr const char *box_name = "CompositionOffsetBox"; 20 | 21 | UInt32<0> entry_count; 22 | 23 | template 24 | struct Entry; 25 | 26 | struct V0 { 27 | using Entry = CompositionOffsetBox::Entry<0>; 28 | struct Parsed { 29 | using Entries = Box::Parsed::Entries; 30 | }; 31 | struct Composed { 32 | using Entries = Box::Composed::Entries; 33 | }; 34 | }; 35 | 36 | struct V1 { 37 | using Entry = CompositionOffsetBox::Entry<1>; 38 | struct Parsed { 39 | using Entries = Box::Parsed::Entries; 40 | }; 41 | struct Composed { 42 | using Entries = Box::Composed::Entries; 43 | }; 44 | }; 45 | 46 | CompositionOffsetBox(Composer &composer, uint32_t entry_count, Version version = 0, bool largesize = false): FullBox(composer, box_type, version, Flags(0), largesize) { 47 | composer.get(this->entry_count) = entry_count; 48 | } 49 | 50 | CompositionOffsetBox(Parser &parser): FullBox(parser, Flags(0)) { 51 | parser.get(entry_count); 52 | //assert(entry_count > 0); 53 | } 54 | 55 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 56 | 57 | virtual void parse_payload(Remainder left_payload); 58 | }; 59 | 60 | template 61 | struct CompositionOffsetBox::Entry: Box::Entry { 62 | union { Footprint<2 * 32> header; 63 | UInt32< 0> sample_count; 64 | Field<32, 32, typename signedness::template FromBoolTo::type> sample_offset; 65 | }; 66 | 67 | Entry(const Entry &entry): header(entry.header), Box::Entry(entry) {} 68 | 69 | template 70 | Entry(const CompositionOffsetBox&, Composer &composer) { 71 | composer.get(header); 72 | } 73 | 74 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 75 | 76 | }; 77 | 78 | 79 | }} // namespace mpeg::isobase 80 | 81 | #endif // __MPEG_ISOBASE_COMPOSITION_OFFSET_BOX__ 82 | 83 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/copyright.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_COPYRIGHT_BOX__ 2 | #define __MPEG_ISOBASE_COPYRIGHT_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct CopyrightBox: FullBox { 14 | 15 | static constexpr Type container_type = 'stbl'; 16 | static constexpr Type box_type = 'cprt'; 17 | static constexpr const char *box_name = "CopyrightBox"; 18 | 19 | union { Footprint<1+ 5 * 3> header; 20 | UInt<1, 0> pad; // = 0; 21 | UInt<5, 1>::Static::Array<3> language; // ISO-639-2/T language code 22 | }; 23 | String notice; 24 | 25 | template ::value> 26 | void CopyrightBox_(Composer &composer) { 27 | composer.get(header); 28 | const_field(pad, 0); 29 | } 30 | 31 | CopyrightBox(Composer &composer, const std::string ¬ice, Version version = 0, bool largesize = false): FullBox(composer, box_type, version, Flags(0)) { 32 | CopyrightBox_(composer); 33 | composer.get(this->notice, notice); 34 | } 35 | 36 | CopyrightBox(Parser &parser): FullBox(parser, Flags(0)) { 37 | CopyrightBox_(parser); 38 | parser.get(*this, notice); 39 | } 40 | 41 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 42 | 43 | }; 44 | 45 | 46 | }} // namespace mpeg::isobase 47 | 48 | #endif // __MPEG_ISOBASE_COPYRIGHT_BOX__ 49 | 50 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/data_entry_url.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_DATA_ENTRY_URL_BOX__ 2 | #define __MPEG_ISOBASE_DATA_ENTRY_URL_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct DataEntryUrlBox: FullBox { 14 | 15 | static constexpr Type container_type = 'dref'; 16 | static constexpr Type box_type = 'url '; 17 | static constexpr const char *box_name = "DataEntryUrlBox"; 18 | 19 | static constexpr Flags SameFileFlag = 0x000001; 20 | 21 | String location; 22 | 23 | DataEntryUrlBox(Composer &composer, const std::string &location = std::string(), Version version = 0, Flags flags = 0, bool largesize = false): FullBox(composer, box_type, version, flags, largesize) { 24 | if (flags & SameFileFlag) { 25 | assert(location.empty()); 26 | } else { 27 | composer.get(this->location, location); 28 | } 29 | } 30 | 31 | DataEntryUrlBox(Parser &parser): FullBox(parser) { 32 | //if (!(flags & SameFileFlag)) { // TODO: make it properly work 33 | parser.get(*this, location); 34 | //} 35 | } 36 | 37 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 38 | 39 | }; 40 | 41 | 42 | }} // namespace mpeg::isobase 43 | 44 | #endif // __MPEG_ISOBASE_DATA_ENTRY_URL_BOX__ 45 | 46 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/data_entry_urn.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_DATA_ENTRY_URN_BOX__ 2 | #define __MPEG_ISOBASE_DATA_ENTRY_URN_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct DataEntryUrnBox: FullBox { 14 | 15 | static constexpr Type container_type = 'dref'; 16 | static constexpr Type box_type = 'urn '; 17 | static constexpr const char *box_name = "DataEntryUrnBox"; 18 | 19 | static constexpr Flags SameFileFlag = 0x000001; 20 | 21 | String name, location; 22 | 23 | DataEntryUrnBox(Composer &composer, 24 | const std::string &name = std::string(), const std::string &location = std::string(), 25 | Version version = 0, Flags flags = 0, bool largesize = false): FullBox(composer, box_type, version, flags, largesize) { 26 | 27 | if (flags & SameFileFlag) { 28 | assert(name.empty() && location.empty()); 29 | } else { 30 | composer.get(this->name, name, this->location, location); 31 | } 32 | } 33 | 34 | DataEntryUrnBox(Parser &parser): FullBox(parser) { 35 | //if (!(flags & SameFileFlag)) { // TODO: make it properly work 36 | parser.get(*this, name, location); 37 | //} 38 | } 39 | 40 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 41 | 42 | }; 43 | 44 | 45 | }} // namespace mpeg::isobase 46 | 47 | #endif // __MPEG_ISOBASE_DATA_ENTRY_URN_BOX__ 48 | 49 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/data_information.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_DATA_INFORMATION_BOX__ 2 | #define __MPEG_ISOBASE_DATA_INFORMATION_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct DataInformationBox: Box { 14 | 15 | static constexpr Type container_type[] = {'minf', 'meta'}; 16 | static constexpr Type box_type = 'dinf'; 17 | static constexpr const char *box_name = "DataInformationBox"; 18 | 19 | DataInformationBox(Composer &composer, bool largesize = false): Box(composer, largesize) {} 20 | DataInformationBox(Parser &parser): Box(parser) {} 21 | }; 22 | 23 | 24 | }} // namespace mpeg::isobase 25 | 26 | #endif // __MPEG_ISOBASE_DATA_INFORMATION_BOX__ 27 | 28 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/data_reference.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_DATA_REFERENCE_BOX__ 2 | #define __MPEG_ISOBASE_DATA_REFERENCE_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct DataReferenceBox: FullBox { 14 | 15 | static constexpr Type container_type[] = {'dinf', 'minf'}; 16 | static constexpr Type box_type = 'dref'; 17 | static constexpr const char *box_name = "DataReferenceBox"; 18 | 19 | UInt32<0> entry_count; 20 | 21 | DataReferenceBox(Composer &composer, uint32_t entry_count, Version version = 0, bool largesize = false): FullBox(composer, box_type, version, Flags(0), largesize) { 22 | composer.get(this->entry_count) = entry_count; 23 | } 24 | 25 | DataReferenceBox(Parser &parser): FullBox(parser, Flags(0)) { 26 | parser.get(entry_count); 27 | //assert(entry_count > 0); 28 | } 29 | 30 | //virtual void parse_payload(Box::Parser &parser, Remainder left) { 31 | // // by default payload is parsed as contained boxes 32 | // auto count = parse_subboxes(left); 33 | // if (!parser.ignore_wrong_data_reference_entry_count && count != entry_count) { 34 | // throw Parser::Exception(SStream() << "Wrong number of DataReferenceBox::entry_count(" << (uint32_t)entry_count << ") but got " << count); 35 | // } 36 | //} 37 | 38 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 39 | 40 | }; 41 | 42 | 43 | }} // namespace mpeg::isobase 44 | 45 | #endif // __MPEG_ISOBASE_DATA_REFERENCE_BOX__ 46 | 47 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/degradation_priority.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_DEGRADATION_PRIORITY_BOX__ 2 | #define __MPEG_ISOBASE_DEGRADATION_PRIORITY_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | namespace mpeg { 11 | namespace isobase { 12 | 13 | 14 | struct DegradationPriorityBox: FullBox { 15 | 16 | static constexpr Type container_type = 'stbl'; 17 | static constexpr Type box_type = 'stdp'; 18 | static constexpr const char *box_name = "DegradationPriorityBox"; 19 | 20 | uint32_t entry_count; 21 | 22 | struct Entry; 23 | struct Parsed { 24 | using Entries = Box::Parsed::Entries; 25 | }; 26 | struct Composed { 27 | using Entries = Box::Composed::Entries; 28 | }; 29 | 30 | DegradationPriorityBox(Composer &composer, uint32_t entry_count, Version version = 0, bool largesize = false): FullBox(composer, box_type, version, Flags(0), largesize), entry_count(entry_count) { 31 | } 32 | 33 | DegradationPriorityBox(Parser &parser): FullBox(parser, Flags(0)) { 34 | } 35 | 36 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 37 | 38 | virtual void parse_payload(Remainder left_payload); 39 | }; 40 | 41 | struct DegradationPriorityBox::Entry : Box::Entry { 42 | union { Footprint<16> header; 43 | UInt16<0> priority; 44 | }; 45 | 46 | Entry(const Entry &entry): header(entry.header), Box::Entry(entry) {} 47 | 48 | template 49 | Entry(const DegradationPriorityBox &, Composer &composer) { 50 | composer.get(header); 51 | } 52 | 53 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 54 | 55 | }; 56 | 57 | 58 | }} // namespace mpeg::isobase 59 | 60 | #endif // __MPEG_ISOBASE_DEGRADATION_PRIORITY_BOX__ 61 | 62 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/edit_list.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_EDIT_LIST_BOX__ 2 | #define __MPEG_ISOBASE_EDIT_LIST_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | namespace mpeg { 11 | namespace isobase { 12 | 13 | 14 | struct EditListBox: FullBox { 15 | 16 | static constexpr Type container_type = 'edts'; 17 | static constexpr Type box_type = 'elst'; 18 | static constexpr const char *box_name = "EditListBox"; 19 | 20 | UInt32<0> entry_count; 21 | 22 | template 23 | struct Entry; 24 | 25 | 26 | struct V0 { 27 | using Entry = EditListBox::Entry<0>; 28 | struct Parsed { 29 | using Entries = Box::Parsed::Entries; 30 | }; 31 | struct Composed { 32 | using Entries = Box::Composed::Entries; 33 | }; 34 | }; 35 | 36 | struct V1 { 37 | using Entry = EditListBox::Entry<1>; 38 | struct Parsed { 39 | using Entries = Box::Parsed::Entries; 40 | }; 41 | struct Composed { 42 | using Entries = Box::Composed::Entries; 43 | }; 44 | }; 45 | 46 | EditListBox(Composer &composer, uint32_t entry_count, Version version = 0, bool largesize = false): FullBox(composer, box_type, version, Flags(0), largesize) { 47 | composer.get(this->entry_count) = entry_count; 48 | } 49 | 50 | EditListBox(Parser &parser): FullBox(parser, Flags(0)) { 51 | parser.get(entry_count); 52 | //assert(entry_count > 0); 53 | } 54 | 55 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 56 | 57 | virtual void parse_payload(Remainder left_payload); 58 | }; 59 | 60 | template 61 | struct EditListBox::Entry : Box::Entry { 62 | union { Footprint<2*w+2*16> header; 63 | UInt segment_duration; 64 | UInt media_time; 65 | UInt16<2*w> media_rate_integer; 66 | UInt16<2*w+16> media_rate_fraction; 67 | UInt32<2*w> media_rate; // 16.16 fixed-point 68 | }; 69 | 70 | Entry(const Entry &entry): header(entry.header), Box::Entry(entry) {} 71 | 72 | template ::value> 73 | Entry(const EditListBox&, Composer &composer) { 74 | composer.get(header); 75 | const_field(media_rate_fraction, 0); 76 | } 77 | 78 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 79 | 80 | }; 81 | 82 | 83 | }} // namespace mpeg::isobase 84 | 85 | #endif // __MPEG_ISOBASE_EDIT_LIST_BOX__ 86 | 87 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/extended_language.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_EXTENDED_LANGUAGE_BOX__ 2 | #define __MPEG_ISOBASE_EXTENDED_LANGUAGE_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct ExtendedLanguageBox: FullBox { 14 | 15 | static constexpr Type container_type = 'mdia'; 16 | static constexpr Type box_type = 'elng'; 17 | static constexpr const char *box_name = "ExtendedLanguageBox"; 18 | 19 | String extended_language; 20 | 21 | ExtendedLanguageBox(Composer &composer, const std::string &extended_language, Version version = 0, Flags flags = 0, bool largesize = false): FullBox(composer, box_type, version, flags, largesize) { 22 | composer.get(this->extended_language, extended_language); 23 | } 24 | 25 | ExtendedLanguageBox(Parser &parser): FullBox(parser) { 26 | parser.get(*this, extended_language); 27 | } 28 | 29 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 30 | 31 | }; 32 | 33 | 34 | }} // namespace mpeg::isobase 35 | 36 | #endif // __MPEG_ISOBASE_EXTENDED_LANGUAGE_BOX__ 37 | 38 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/fd_item_information.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_FD_ITEM_INFORMATION_BOX__ 2 | #define __MPEG_ISOBASE_FD_ITEM_INFORMATION_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct FDItemInformationBox: FullBox { 14 | 15 | static constexpr Type container_type = 'meta'; 16 | static constexpr Type box_type = 'fiin'; 17 | static constexpr const char *box_name = "FDItemInformationBox"; 18 | 19 | UInt16<> entry_count; 20 | //PartitionEntry partition_entries[ entry_count ]; 21 | //FDSessionGroupBox session_info; //optional 22 | //GroupIdToNameBox group_id_to_name; //optional 23 | 24 | FDItemInformationBox(Composer &composer, uint32_t entry_count, Version version = 0, bool largesize = false): FullBox(composer, box_type, version, Flags(0), largesize) { 25 | composer.get(this->entry_count) = entry_count; 26 | } 27 | 28 | FDItemInformationBox(Parser &parser): FullBox(parser, Flags(0)) { 29 | parser.get(entry_count); 30 | //assert(entry_count > 0); 31 | } 32 | 33 | //virtual void parse_payload(Box::Parser &parser, Remainder left) { 34 | // // by default payload is parsed as contained boxes 35 | // auto count = parse_subboxes(left, {&PartitionEntry}); 36 | // if (!parser.ignore_wrong_fd_item_information_partition_entry_count && count != entry_count) { 37 | // throw Parser::Exception(SStream() << "Wrong number of FDItemInformationBox::entry_count(" << (uint32_t)entry_count << ") but got " << count); 38 | // } 39 | //} 40 | // 41 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 42 | 43 | }; 44 | 45 | 46 | }} // namespace mpeg::isobase 47 | 48 | #endif // __MPEG_ISOBASE_FD_ITEM_INFORMATION_BOX__ 49 | 50 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/fec_reservoir.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_FEC_RESERVOIR_BOX__ 2 | #define __MPEG_ISOBASE_FEC_RESERVOIR_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct FECReservoirBox: FileReservoirBox { 14 | 15 | static constexpr Type box_type = 'fecr'; 16 | static constexpr const char *box_name = "FECReservoirBox"; 17 | 18 | using FileReservoirBox::FileReservoirBox; 19 | }; 20 | 21 | 22 | }} // namespace mpeg::isobase 23 | 24 | #endif // __MPEG_ISOBASE_FEC_RESERVOIR_BOX__ 25 | 26 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/file_type.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_FILE_TYPE_BOX__ 2 | #define __MPEG_ISOBASE_FILE_TYPE_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct FileTypeBox: Box { 14 | 15 | static constexpr Type box_type = 'ftyp'; 16 | static constexpr const char *box_name = "FileTypeBox"; 17 | 18 | union { Footprint<64> header; 19 | UInt32< 0> major_brand; 20 | UInt32<32> minor_version; 21 | }; 22 | UInt32<>::Array compatible_brands; // to end of the box 23 | 24 | template 25 | FileTypeBox(Composer &composer, const CompatibleBrands &compatible_brands, bool largesize = false): Box(composer, box_type, largesize) { 26 | composer.get(header); 27 | composer.get(this->compatible_brands, compatible_brands); 28 | } 29 | 30 | FileTypeBox(Parser &parser) : Box(parser) { 31 | parser.get(header); 32 | parser.get(*this, compatible_brands); 33 | } 34 | 35 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 36 | 37 | }; 38 | 39 | 40 | }} // namespace mpeg::isobase 41 | 42 | #endif // __MPEG_ISOBASE_FILE_TYPE_BOX__ 43 | 44 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/full.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_FULL_BOX__ 2 | #define __MPEG_ISOBASE_FULL_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | struct FullBox: Box { 13 | 14 | union { Footprint<32> header; 15 | UInt8< 0> version; 16 | UInt<24, 8> flags; 17 | }; 18 | 19 | using Version = uint8_t; 20 | using Flags = uint32_t; 21 | 22 | template 23 | FullBox(Composer &composer, const Type &box_type, Version version, Flags flags, bool largesize = false): Box(composer, box_type, largesize) { 24 | composer.get(header); 25 | const_field(this->version, version); 26 | const_field(this->flags, flags); 27 | } 28 | 29 | inline FullBox(Parser &parser): Box(parser) { 30 | parser.get(header); 31 | } 32 | 33 | inline FullBox(Parser &parser, Version version, Flags flags): FullBox(parser) { 34 | const_field(this->version, version); 35 | const_field(this->flags, flags); 36 | } 37 | 38 | inline FullBox(Parser &parser, Version version): FullBox(parser) { 39 | const_field(this->version, version); 40 | } 41 | 42 | inline FullBox(Parser &parser, Flags flags): FullBox(parser) { 43 | const_field(this->flags, flags); 44 | } 45 | 46 | virtual void output_fields(bitstream::output::meta::field::Stream &stream_) const; 47 | }; 48 | 49 | 50 | }} // namespace mpeg::isobase 51 | 52 | #endif // __MPEG_ISOBASE_FULL_BOX__ 53 | 54 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/group_id_to_name.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_GROUP_ID_TO_NAME_BOX__ 2 | #define __MPEG_ISOBASE_GROUP_ID_TO_NAME_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | namespace mpeg { 11 | namespace isobase { 12 | 13 | 14 | struct GroupIdToNameBox: FullBox { 15 | 16 | static constexpr Type container_type = 'fiin'; 17 | static constexpr Type box_type = 'gitn'; 18 | static constexpr const char *box_name = "GroupIdToNameBox"; 19 | 20 | UInt16<0> entry_count; 21 | 22 | struct Entry; 23 | struct Parsed { 24 | using Entries = Box::Parsed::Entries; 25 | }; 26 | struct Composed { 27 | using Entries = Box::Composed::Entries; 28 | }; 29 | 30 | GroupIdToNameBox(Composer &composer, uint16_t entry_count, Version version = 0, bool largesize = false): FullBox(composer, box_type, version, Flags(0), largesize) { 31 | composer.get(this->entry_count) = entry_count; 32 | } 33 | 34 | GroupIdToNameBox(Parser &parser): FullBox(parser, Flags(0)) { 35 | parser.get(this->entry_count); 36 | //assert(entry_count > 0); 37 | } 38 | 39 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 40 | 41 | virtual void parse_payload(Remainder left_payload); 42 | }; 43 | 44 | struct GroupIdToNameBox::Entry : Box::Entry { 45 | UInt32< 0> group_ID; 46 | String group_name; 47 | 48 | Entry(const Entry &entry): Box::Entry(entry) {} 49 | 50 | template 51 | Entry(const GroupIdToNameBox &, Composer &composer) { 52 | composer.get(group_ID); 53 | composer.get(group_name); 54 | } 55 | 56 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 57 | }; 58 | 59 | 60 | }} // namespace mpeg::isobase 61 | 62 | #endif // __MPEG_ISOBASE_GROUP_ID_TO_NAME_BOX__ 63 | 64 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/handler.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_HANDLER_BOX__ 2 | #define __MPEG_ISOBASE_HANDLER_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct HandlerBox: FullBox { 14 | 15 | static constexpr Type container_type[] = {'mdia', 'meta'}; 16 | static constexpr Type box_type = 'hdlr'; 17 | static constexpr const char *box_name = "HandlerBox"; 18 | 19 | union { Footprint<1+ 5 * 3 + 16> header; 20 | UInt32< 0> pre_defined; // = 0; 21 | UInt32<32> handler_type; 22 | UInt32<64>::Static::Array<3> reserved; // = 0; 23 | }; 24 | String name; 25 | 26 | template ::value> 27 | void HandlerBox_(Composer &composer) { 28 | composer.get(header); 29 | const_field(pre_defined, 0); 30 | const_field(reserved, {0, 0, 0}); 31 | } 32 | 33 | HandlerBox(Composer &composer, const std::string &name, Version version = 0, bool largesize = false): FullBox(composer, box_type, version, Flags(0), largesize) { 34 | HandlerBox_(composer); 35 | composer.get(this->name, name); 36 | } 37 | 38 | HandlerBox(Parser &parser): FullBox(parser, Flags(0)) { 39 | HandlerBox_(parser); 40 | parser.get(*this, name); 41 | 42 | parser.handler_type = handler_type; // TODO: add code which resets this flag for each trak. OR remove this code at all 43 | } 44 | 45 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 46 | 47 | }; 48 | 49 | 50 | }} // namespace mpeg::isobase 51 | 52 | #endif // __MPEG_ISOBASE_HANDLER_BOX__ 53 | 54 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/hint_media_header.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_HINT_MEDIA_HEADER_BOX__ 2 | #define __MPEG_ISOBASE_HINT_MEDIA_HEADER_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct HintMediaHeaderBox: FullBox { 14 | 15 | static constexpr Type container_type = 'minf'; 16 | static constexpr Type box_type = 'hmhd'; 17 | static constexpr const char *box_name = "HintMediaHeaderBox"; 18 | 19 | union { Footprint<2 * 16 + 3 * 32> header; 20 | UInt16< 0> maxPDUsize; 21 | UInt16<16> avgPDUsize; 22 | UInt32<32> maxbitrate; 23 | UInt32<64> avgbitrate; 24 | UInt32<96> reserved; 25 | }; 26 | 27 | template ::value> 28 | void HintMediaHeaderBox_(Composer &composer) { 29 | composer.get(header); 30 | 31 | const_field(reserved, 0); 32 | } 33 | 34 | HintMediaHeaderBox(Composer &composer, Version version = 0, bool largesize = false): FullBox(composer, box_type, version, Flags(0), largesize) { 35 | HintMediaHeaderBox_(composer); 36 | } 37 | 38 | HintMediaHeaderBox(Parser &parser): FullBox(parser, Flags(0)) { 39 | HintMediaHeaderBox_(parser); 40 | } 41 | 42 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 43 | 44 | }; 45 | 46 | 47 | }} // namespace mpeg::isobase 48 | 49 | #endif // __MPEG_ISOBASE_HINT_MEDIA_HEADER_BOX__ 50 | 51 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/hint_sample_entry.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_HINT_SAMPLE_ENTRY__ 2 | #define __MPEG_ISOBASE_HINT_SAMPLE_ENTRY__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct HintSampleEntry: SampleEntry { 14 | 15 | static constexpr Type box_type = 'hint'; 16 | static constexpr const char *box_name = "HintSampleEntry"; 17 | 18 | UInt8<>::Array data; 19 | 20 | HintSampleEntry(Composer &composer, long data_size, bool largesize = false): SampleEntry(composer, box_type, largesize) { 21 | composer.get(data, data_size); 22 | } 23 | 24 | HintSampleEntry(Parser &parser): SampleEntry(parser) { 25 | parser.get(*this, data); 26 | } 27 | 28 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 29 | 30 | }; 31 | 32 | 33 | }} // namespace mpeg::isobase 34 | 35 | #endif // __MPEG_ISOBASE_HINT_SAMPLE_ENTRY__ 36 | 37 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/ipmpcontrol.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_IPMPCONTROL_BOX__ 2 | #define __MPEG_ISOBASE_IPMPCONTROL_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct IPMPControlBox: Box { 14 | 15 | static constexpr Type container_type[] = {'moov', 'meta'}; 16 | static constexpr Type box_type = 'ipmc'; 17 | static constexpr const char *box_name = "IPMPControlBox"; 18 | 19 | // TODO: Find definition 20 | IPMPControlBox(Parser &parser): Box(parser) { 21 | } 22 | }; 23 | 24 | 25 | }} // namespace mpeg::isobase 26 | 27 | #endif // __MPEG_ISOBASE_IPMPCONTROL_BOX__ 28 | 29 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/ipmpinfo.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_IPMPINFO_BOX__ 2 | #define __MPEG_ISOBASE_IPMPINFO_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct IPMPInfoBox: Box { 14 | 15 | static constexpr Type container_type = 'sinf'; 16 | static constexpr Type box_type = 'imif'; 17 | static constexpr const char *box_name = "IPMPInfoBox"; 18 | 19 | // TODO: Find definition 20 | IPMPInfoBox(Parser &parser): Box(parser) { 21 | } 22 | }; 23 | 24 | 25 | }} // namespace mpeg::isobase 26 | 27 | #endif // __MPEG_ISOBASE_IPMPINFO_BOX__ 28 | 29 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/item_data.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_ITEM_DATA_BOX__ 2 | #define __MPEG_ISOBASE_ITEM_DATA_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct ItemDataBox: Box { 14 | 15 | static constexpr Type container_type = 'meta'; 16 | static constexpr Type box_type = 'idat'; 17 | static constexpr const char *box_name = "ItemDataBox"; 18 | 19 | UInt8<>::Array data; 20 | 21 | ItemDataBox(Composer &composer, const std::vector &data, bool largesize = false): Box(composer, box_type, largesize) { 22 | composer.get(this->data, data); 23 | } 24 | 25 | ItemDataBox(Parser &parser): Box(parser) { 26 | parser.get(*this, data); 27 | } 28 | 29 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 30 | 31 | }; 32 | 33 | 34 | }} // namespace mpeg::isobase 35 | 36 | #endif // __MPEG_ISOBASE_ITEM_DATA_BOX__ 37 | 38 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/item_info.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_ITEM_INFO_BOX__ 2 | #define __MPEG_ISOBASE_ITEM_INFO_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct ItemInfoBox: FullBox { 14 | 15 | static constexpr Type container_type = 'meta'; 16 | static constexpr Type box_type = 'iinf'; 17 | static constexpr const char *box_name = "ItemInfoBox"; 18 | 19 | UInt16<> entry_count16; // version == 0 20 | UInt32<> entry_count32; // version != 0 21 | 22 | template ::value> 23 | void ItemInfoBox_(Composer &composer) { 24 | if (version == 0) { 25 | composer.get(entry_count16); 26 | } else { 27 | composer.get(entry_count32); 28 | } 29 | } 30 | 31 | ItemInfoBox(Composer &composer, Flags flags, Version version = 0, bool largesize = false): FullBox(composer, box_type, version, Flags(0), largesize) { 32 | ItemInfoBox_(composer); 33 | } 34 | 35 | ItemInfoBox(Parser &parser): FullBox(parser, Flags(0)) { 36 | ItemInfoBox_(parser); 37 | } 38 | 39 | // TODO: PROCESS PAYLOAD (check entry_count) 40 | 41 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 42 | 43 | }; 44 | 45 | 46 | }} // namespace mpeg::isobase 47 | 48 | #endif // __MPEG_ISOBASE_ITEM_INFO_BOX__ 49 | 50 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/item_info_entry.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_ITEM_INFO_ENTRY__ 2 | #define __MPEG_ISOBASE_ITEM_INFO_ENTRY__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct ItemInfoEntry: FullBox { 14 | 15 | static constexpr Type container_type = 'iinf'; 16 | static constexpr Type box_type = 'infe'; 17 | static constexpr const char *box_name = "ItemInfoEntry"; 18 | 19 | // TODO: not up to date structure of the box: these guys are quite crazy with such structures of the box 20 | union { Footprint<2 * 16> header; 21 | UInt16< 0> item_ID; 22 | UInt16<16> item_protection_index; 23 | }; 24 | String item_name; 25 | String content_type; 26 | String content_encoding; 27 | 28 | ItemInfoEntry(Composer &composer, 29 | const std::string &item_name, 30 | const std::string &content_type, 31 | const std::string &content_encoding, 32 | Version version, bool largesize = false): FullBox(composer, box_type, version, Flags(0), largesize) { 33 | composer.get(this->item_name, item_name, 34 | this->content_type, content_type, 35 | this->content_encoding, content_encoding); 36 | } 37 | 38 | ItemInfoEntry(Parser &parser): FullBox(parser) { 39 | parser.get(header); 40 | parser.get(*this, item_name, content_type, content_encoding); 41 | 42 | assert(flags == 0); 43 | } 44 | 45 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 46 | 47 | }; 48 | 49 | 50 | }} // namespace mpeg::isobase 51 | 52 | #endif // __MPEG_ISOBASE_ITEM_INFO_ENTRY__ 53 | 54 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/item_location.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_ITEM_LOCATION_BOX__ 2 | #define __MPEG_ISOBASE_ITEM_LOCATION_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct ItemLocationBox: FullBox { 14 | 15 | static constexpr Type container_type = 'meta'; 16 | static constexpr Type box_type = 'iloc'; 17 | static constexpr const char *box_name = "ItemLocationBox"; 18 | 19 | union { Footprint<4 *4 + 16> header; 20 | UInt<4, 0> offset_size; 21 | UInt<4, 4> length_size; 22 | UInt<4, 8> base_offset_size; 23 | UInt<4, 12> index_size; // ((version == 1) || (version == 2) 24 | UInt<4, 12> reserved; 25 | UInt16< 16> item_count; 26 | }; 27 | 28 | ItemLocationBox(Composer &composer, Flags flags, Version version = 0, bool largesize = false): FullBox(composer, box_type, version, Flags(0), largesize) { 29 | composer.get(header); 30 | } 31 | 32 | ItemLocationBox(Parser &parser): FullBox(parser, Flags(0)) { 33 | parser.get(header); 34 | } 35 | 36 | // TODO: PROCESS PAYLOAD 37 | 38 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 39 | 40 | }; 41 | 42 | 43 | }} // namespace mpeg::isobase 44 | 45 | #endif // __MPEG_ISOBASE_ITEM_LOCATION_BOX__ 46 | 47 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/item_protection.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_ITEM_PROTECTION_BOX__ 2 | #define __MPEG_ISOBASE_ITEM_PROTECTION_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct ItemProtectionBox: FullBox { 14 | 15 | static constexpr Type container_type = 'meta'; 16 | static constexpr Type box_type = 'ipro'; 17 | static constexpr const char *box_name = "ItemProtectionBox"; 18 | 19 | UInt16<> protection_count; 20 | 21 | ItemProtectionBox(Composer &composer, Flags flags, Version version = 0, bool largesize = false): FullBox(composer, box_type, version, Flags(0), largesize) { 22 | composer.get(protection_count); 23 | } 24 | 25 | ItemProtectionBox(Parser &parser): FullBox(parser, Flags(0)) { 26 | parser.get(protection_count); 27 | } 28 | 29 | // TODO: PROCESS PAYLOAD (check count) 30 | 31 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 32 | 33 | }; 34 | 35 | 36 | }} // namespace mpeg::isobase 37 | 38 | #endif // __MPEG_ISOBASE_ITEM_PROTECTION_BOX__ 39 | 40 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/item_reference.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_ITEM_REFERENCE_BOX__ 2 | #define __MPEG_ISOBASE_ITEM_REFERENCE_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct ItemReferenceBox: FullBox { 14 | 15 | static constexpr Type container_type = 'meta'; 16 | static constexpr Type box_type = 'iref'; 17 | static constexpr const char *box_name = "ItemReferenceBox"; 18 | 19 | ItemReferenceBox(Composer &composer, const std::string &xml, Version version = 0, bool largesize = false): FullBox(composer, box_type, version, Flags(0), largesize) { 20 | } 21 | 22 | ItemReferenceBox(Parser &parser): FullBox(parser, Flags(0)) { 23 | } 24 | 25 | // TODO: PROCESS PAYLOAD (Introduce SingleItemTypeReferenceBox(referenceType)) 26 | }; 27 | 28 | 29 | 30 | }} // namespace mpeg::isobase 31 | 32 | #endif // __MPEG_ISOBASE_ITEM_REFERENCE_BOX__ 33 | 34 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/level_assignment.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_LEVEL_ASSIGNMENT_BOX__ 2 | #define __MPEG_ISOBASE_LEVEL_ASSIGNMENT_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | namespace mpeg { 11 | namespace isobase { 12 | 13 | 14 | struct LevelAssignmentBox: FullBox { 15 | 16 | static constexpr Type container_type = 'mvex'; 17 | static constexpr Type box_type = 'leva'; 18 | static constexpr const char *box_name = "LevelAssignmentBox"; 19 | 20 | UInt8<> level_count; 21 | 22 | struct Entry; 23 | struct Parsed { 24 | using Entries = Box::Parsed::Entries; 25 | }; 26 | struct Composed { 27 | using Entries = Box::Composed::Entries; 28 | }; 29 | 30 | LevelAssignmentBox(Composer &composer, uint32_t level_count, bool largesize = false): FullBox(composer, box_type, Version(0), Flags(0), largesize) { 31 | composer.get(this->level_count) = level_count; 32 | } 33 | 34 | LevelAssignmentBox(Parser &parser): FullBox(parser, Version(0), Flags(0)) { 35 | parser.get(level_count); 36 | } 37 | 38 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 39 | 40 | virtual void parse_payload(Remainder left_payload); 41 | }; 42 | 43 | struct LevelAssignmentBox::Entry : Box::Entry { 44 | union { Footprint<32+1+7> header; 45 | UInt32<> track_id; 46 | UInt<1, 32> padding_flag; 47 | UInt<7, 33> assignment_type; 48 | }; 49 | 50 | union { Footprint<2*32> grouping_type_header; 51 | UInt32< 0> grouping_type; 52 | UInt32<32> grouping_type_parameter; 53 | }; 54 | 55 | UInt32<> sub_track_id; 56 | 57 | Entry(const Entry &entry): header(entry.header), Box::Entry(entry) {} 58 | 59 | template 60 | Entry(const LevelAssignmentBox &, Composer &composer) { 61 | composer.get(header); 62 | if (assignment_type == 0) { 63 | composer.get(grouping_type); 64 | } else if (assignment_type == 1) { 65 | composer.get(grouping_type_header); 66 | } else if (assignment_type == 2) { // no further syntax elements needed 67 | } else if (assignment_type == 3) { // no further syntax elements needed 68 | } else if (assignment_type == 4) { 69 | composer.get(sub_track_id); 70 | } 71 | // other assignment_type values are reserved 72 | } 73 | 74 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 75 | 76 | }; 77 | 78 | 79 | }} // namespace mpeg::isobase 80 | 81 | #endif // __MPEG_ISOBASE_LEVEL_ASSIGNMENT_BOX__ 82 | 83 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/meta.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_META_BOX__ 2 | #define __MPEG_ISOBASE_META_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct MetaBox: FullBox { 14 | 15 | static constexpr Type container_type[] = {0, 'moov', 'trak', 'meco', 'moof', 'traf'}; 16 | static constexpr Type box_type = 'meta'; 17 | static constexpr const char *box_name = "MetaBox"; 18 | 19 | //HandlerBox(handler_type) theHandler; 20 | //PrimaryItemBox primary_resource; // optional 21 | //DataInformationBox file_locations; // optional 22 | //ItemLocationBox item_locations; // optional 23 | //ItemProtectionBox protections; // optional 24 | //ItemInfoBox item_infos; // optional 25 | //IPMPControlBox IPMP_control; // optional 26 | //ItemReferenceBox item_refs; // optional 27 | //ItemDataBox item_data; // optional 28 | //Box other_boxes[]; 29 | 30 | MetaBox(Composer &composer, Version version = 0, bool largesize = false): FullBox(composer, box_type, version, Flags(0)) { 31 | } 32 | 33 | MetaBox(Parser &parser): FullBox(parser, Flags(0)) { 34 | } 35 | 36 | // TODO: PROCESS PAYLOAD 37 | 38 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 39 | 40 | }; 41 | 42 | 43 | }} // namespace mpeg::isobase 44 | 45 | #endif // __MPEG_ISOBASE_META_BOX__ 46 | 47 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/metabox_relation.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_METABOX_RELATION_BOX__ 2 | #define __MPEG_ISOBASE_METABOX_RELATION_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct MetaboxRelationBox: FullBox { 14 | 15 | static constexpr Type container_type = 'meco'; 16 | static constexpr Type box_type = 'mere'; 17 | static constexpr const char *box_name = "MetaboxRelationBox"; 18 | 19 | 20 | union { Footprint<2*32+8> header; 21 | UInt32< 0> first_metabox_handler_type; 22 | UInt32<32> second_metabox_handler_type; 23 | UInt8 <64> metabox_relation; 24 | }; 25 | 26 | MetaboxRelationBox(Composer &composer, Version version = 0, bool largesize = false): FullBox(composer, box_type, version, Flags(0), largesize) { 27 | composer.get(header); 28 | } 29 | 30 | MetaboxRelationBox(Parser &parser): FullBox(parser, Flags(0)) { 31 | parser.get(header); 32 | } 33 | 34 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 35 | 36 | }; 37 | 38 | 39 | }} // namespace mpeg::isobase 40 | 41 | #endif // __MPEG_ISOBASE_METABOX_RELATION_BOX__ 42 | 43 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/movie_extends_header.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_MOVIE_EXTENDS_HEADER_BOX__ 2 | #define __MPEG_ISOBASE_MOVIE_EXTENDS_HEADER_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct MovieExtendsHeaderBox: FullBox { 14 | 15 | static constexpr Type container_type = 'mvex'; 16 | static constexpr Type box_type = 'mehd'; 17 | static constexpr const char *box_name = "MovieExtendsHeaderBox"; 18 | 19 | UInt32<0> fragment_duration32; 20 | UInt64<0> fragment_duration64; 21 | 22 | uint64_t fragment_duration() const { return version == 1 ? uint64_t(fragment_duration64): uint64_t(fragment_duration32); } 23 | 24 | template ::value> 25 | void MovieExtendsHeaderBox_(Composer &composer) { 26 | 27 | if (version == 1) { 28 | composer.get(fragment_duration64); 29 | } else { // version==0 30 | composer.get(fragment_duration32); 31 | } 32 | 33 | const_field(flags, 0); 34 | } 35 | 36 | MovieExtendsHeaderBox(Composer &composer, Version version = 0, bool largesize = false): FullBox(composer, box_type, version, Flags(0)) { 37 | MovieExtendsHeaderBox_(composer); 38 | } 39 | 40 | MovieExtendsHeaderBox(Parser &parser): FullBox(parser, Flags(0)) { 41 | MovieExtendsHeaderBox_(parser); 42 | } 43 | 44 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 45 | 46 | }; 47 | 48 | 49 | }} // namespace mpeg::isobase 50 | 51 | #endif // __MPEG_ISOBASE_MOVIE_EXTENDS_HEADER_BOX__ 52 | 53 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/movie_fragment_header.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_MOVIE_FRAGMENT_HEADER_BOX__ 2 | #define __MPEG_ISOBASE_MOVIE_FRAGMENT_HEADER_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct MovieFragmentHeaderBox: FullBox { 14 | 15 | static constexpr Type container_type = 'moof'; 16 | static constexpr Type box_type = 'mfhd'; 17 | static constexpr const char *box_name = "MovieFragmentHeaderBox"; 18 | 19 | UInt32<> sequence_number; 20 | 21 | MovieFragmentHeaderBox(Composer &composer, bool largesize = false): FullBox(composer, box_type, Version(0), Flags(0), largesize) { 22 | composer.get(sequence_number); 23 | } 24 | 25 | MovieFragmentHeaderBox(Parser &parser): FullBox(parser, Version(0), Flags(0)) { 26 | parser.get(sequence_number); 27 | } 28 | 29 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 30 | 31 | }; 32 | 33 | 34 | }} // namespace mpeg::isobase 35 | 36 | #endif // __MPEG_ISOBASE_MOVIE_FRAGMENT_HEADER_BOX__ 37 | 38 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/movie_fragment_random_access_offset.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_MOVIE_FRAGMENT_RANDOM_ACCESS_OFFSET_BOX__ 2 | #define __MPEG_ISOBASE_MOVIE_FRAGMENT_RANDOM_ACCESS_OFFSET_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct MovieFragmentRandomAccessOffsetBox: FullBox { 14 | 15 | static constexpr Type container_type = 'edts'; 16 | static constexpr Type box_type = 'mfro'; 17 | static constexpr const char *box_name = "MovieFragmentRandomAccessOffsetBox"; 18 | 19 | UInt32<0> size; 20 | 21 | MovieFragmentRandomAccessOffsetBox(Composer &composer, Version version = 0, bool largesize = false): FullBox(composer, box_type, version, Flags(0)) { 22 | composer.get(size); 23 | } 24 | 25 | MovieFragmentRandomAccessOffsetBox(Parser &parser): FullBox(parser, Flags(0)) { 26 | parser.get(size); 27 | } 28 | 29 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 30 | 31 | }; 32 | 33 | 34 | }} // namespace mpeg::isobase 35 | 36 | #endif // __MPEG_ISOBASE_MOVIE_FRAGMENT_RANDOM_ACCESS_OFFSET_BOX__ 37 | 38 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/null_media_header.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_NULL_MEDIA_HEADER_BOX__ 2 | #define __MPEG_ISOBASE_NULL_MEDIA_HEADER_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct NullMediaHeaderBox: FullBox { 14 | 15 | static constexpr Type container_type = 'minf'; 16 | static constexpr Type box_type = 'nmhd'; 17 | static constexpr const char *box_name = "NullMediaHeaderBox"; 18 | 19 | NullMediaHeaderBox(Composer &composer, Version version = 0, Flags flags = 0, bool largesize = false): FullBox(composer, box_type, version, flags, largesize) {} 20 | NullMediaHeaderBox(Parser &parser): FullBox(parser) {} 21 | }; 22 | 23 | 24 | }} // namespace mpeg::isobase 25 | 26 | #endif // __MPEG_ISOBASE_NULL_MEDIA_HEADER_BOX__ 27 | 28 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/original_format.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_ORIGINAL_FORMAT_BOX__ 2 | #define __MPEG_ISOBASE_ORIGINAL_FORMAT_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct OriginalFormatBox: Box { 14 | 15 | static constexpr Type container_type = 'ipro'; 16 | static constexpr Type box_type = 'frma'; 17 | static constexpr const char *box_name = "OriginalFormatBox"; 18 | 19 | UInt32<> data_format; 20 | 21 | OriginalFormatBox(Composer &composer, uint32_t codingname): Box(composer, box_type) { 22 | composer.get(data_format); 23 | data_format = codingname; 24 | } 25 | 26 | OriginalFormatBox(Parser &parser): Box(parser) { 27 | parser.get(data_format); 28 | } 29 | 30 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 31 | 32 | }; 33 | 34 | 35 | }} // namespace mpeg::isobase 36 | 37 | #endif // __MPEG_ISOBASE_ORIGINAL_FORMAT_BOX__ 38 | 39 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/padding_bits.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_PADDING_BITS_BOX__ 2 | #define __MPEG_ISOBASE_PADDING_BITS_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | namespace mpeg { 11 | namespace isobase { 12 | 13 | 14 | struct PaddingBitsBox: FullBox { 15 | 16 | static constexpr Type container_type = 'stbl'; 17 | static constexpr Type box_type = 'padb'; 18 | static constexpr const char *box_name = "PaddingBitsBox"; 19 | 20 | UInt32<> sample_count; 21 | 22 | struct Entry; 23 | struct Parsed { 24 | using Entries = Box::Parsed::Entries; 25 | }; 26 | struct Composed { 27 | using Entries = Box::Composed::Entries; 28 | }; 29 | 30 | PaddingBitsBox(Composer &composer, uint32_t sample_count, Version version = 0, bool largesize = false): FullBox(composer, box_type, version, Flags(0), largesize) { 31 | composer.get(this->sample_count) = sample_count; 32 | } 33 | 34 | PaddingBitsBox(Parser &parser): FullBox(parser, Flags(0)) { 35 | parser.get(sample_count); 36 | } 37 | 38 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 39 | 40 | virtual void parse_payload(Remainder left_payload); 41 | }; 42 | 43 | struct PaddingBitsBox::Entry : Box::Entry { 44 | union { Footprint<1+3+1+3> header; 45 | UInt<1, 0> reserved1; 46 | UInt<3, 1> pad1; 47 | UInt<1, 4> reserved2; 48 | UInt<3, 5> pad2; 49 | }; 50 | 51 | Entry(const Entry &entry): header(entry.header), Box::Entry(entry) {} 52 | 53 | template ::value> 54 | Entry(const PaddingBitsBox &, Composer &composer) { 55 | composer.get(header); 56 | 57 | const_field(reserved1, 0); 58 | const_field(reserved2, 0); 59 | } 60 | 61 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 62 | 63 | }; 64 | 65 | 66 | }} // namespace mpeg::isobase 67 | 68 | #endif // __MPEG_ISOBASE_PADDING_BITS_BOX__ 69 | 70 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/partition_entry.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_PARTITION_ENTRY__ 2 | #define __MPEG_ISOBASE_PARTITION_ENTRY__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct PartitionEntry: Box { 14 | 15 | static constexpr Type container_type = 'fiin'; 16 | static constexpr Type box_type = 'paen'; 17 | static constexpr const char *box_name = "PartitionEntry"; 18 | 19 | //FilePartitionBox blocks_and_symbols; 20 | //FECReservoirBox FEC_symbol_locations; //optional 21 | //FileReservoirBox File_symbol_locations; //optional 22 | 23 | //TODO: PROCESS PAYLOAD (control children) 24 | 25 | using Box::Box; 26 | }; 27 | 28 | 29 | }} // namespace mpeg::isobase 30 | 31 | #endif // __MPEG_ISOBASE_PARTITION_ENTRY__ 32 | 33 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/primary_item.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_PRIMARY_ITEM_BOX__ 2 | #define __MPEG_ISOBASE_PRIMARY_ITEM_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct PrimaryItemBox: FullBox { 14 | 15 | static constexpr Type container_type = 'meta'; 16 | static constexpr Type box_type = 'pitm'; 17 | static constexpr const char *box_name = "PrimaryItemBox"; 18 | 19 | template 20 | struct Header { 21 | UInt item_ID; 22 | Header() {} 23 | 24 | template 25 | void Header_(Composer &composer) { 26 | composer.get(item_ID); 27 | } 28 | 29 | void output(bitstream::output::meta::field::Stream &stream_) const; 30 | }; 31 | Header<0> v0; 32 | Header<1> v1; 33 | 34 | uint64_t item_ID() const { return version == 0 ? uint64_t(v0.item_ID): uint64_t(v1.item_ID); } 35 | 36 | template ::value> 37 | void PrimaryItemBox_(Composer &composer) { 38 | if (version == 0) { 39 | v0.Header_(composer); 40 | } else { 41 | v1.Header_(composer); 42 | } 43 | } 44 | 45 | PrimaryItemBox(Composer &composer, Flags flags, Version version = 0, bool largesize = false): FullBox(composer, box_type, version, Flags(0), largesize) { 46 | PrimaryItemBox_(composer); 47 | } 48 | 49 | PrimaryItemBox(Parser &parser): FullBox(parser, Flags(0)) { 50 | PrimaryItemBox_(parser); 51 | } 52 | 53 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 54 | 55 | }; 56 | 57 | 58 | }} // namespace mpeg::isobase 59 | 60 | #endif // __MPEG_ISOBASE_PRIMARY_ITEM_BOX__ 61 | 62 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/producer_reference_time.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_PRODUCER_REFERENCE_TIME_BOX__ 2 | #define __MPEG_ISOBASE_PRODUCER_REFERENCE_TIME_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct ProducerReferenceTimeBox: FullBox { 14 | 15 | static constexpr Type box_type = 'prft'; 16 | static constexpr const char *box_name = "ProducerReferenceTimeBox"; 17 | 18 | union { Footprint<32+64> header; 19 | UInt32<> reference_track_ID; 20 | UInt16<16> ntp_timestamp; 21 | }; 22 | 23 | template 24 | struct MediaTime { 25 | UInt media_time; 26 | 27 | template 28 | void MediaTime_(Composer &composer) { 29 | composer.get(media_time); 30 | } 31 | 32 | void output(bitstream::output::meta::field::Stream &stream) const; 33 | }; 34 | MediaTime<0> v0; 35 | MediaTime<1> v1; 36 | 37 | uint64_t media_time() const { return version == 0 ? uint64_t(v0.media_time): uint64_t(v1.media_time); } 38 | 39 | ProducerReferenceTimeBox(Composer &composer, Version version, bool largesize = false): FullBox(composer, box_type, version, Flags(0), largesize) { 40 | composer.get(header); 41 | if (version == 0) { 42 | v0.MediaTime_(composer); 43 | } else { 44 | v1.MediaTime_(composer); 45 | } 46 | } 47 | 48 | ProducerReferenceTimeBox(Parser &parser): FullBox(parser, Flags(0)) { 49 | parser.get(header); 50 | } 51 | 52 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 53 | 54 | }; 55 | 56 | 57 | 58 | }} // namespace mpeg::isobase 59 | 60 | #endif // __MPEG_ISOBASE_PRODUCER_REFERENCE_TIME_BOX__ 61 | 62 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/progressive_download_info.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_PROGRESSIVE_DOWNLOAD_INFO_BOX__ 2 | #define __MPEG_ISOBASE_PROGRESSIVE_DOWNLOAD_INFO_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | namespace mpeg { 11 | namespace isobase { 12 | 13 | 14 | struct ProgressiveDownloadInfoBox: FullBox { 15 | 16 | static constexpr Type box_type = 'pdin'; 17 | static constexpr const char *box_name = "ProgressiveDownloadInfoBox"; 18 | 19 | struct Entry; 20 | struct Parsed { 21 | using Entries = Box::Parsed::Entries; 22 | }; 23 | struct Composed { 24 | using Entries = Box::Composed::Entries; 25 | }; 26 | 27 | inline uint32_t entries() const; 28 | 29 | ProgressiveDownloadInfoBox(Composer &composer, Version version = 0, bool largesize = false): FullBox(composer, box_type, version, Flags(0)) { 30 | } 31 | 32 | ProgressiveDownloadInfoBox(Parser &parser): FullBox(parser, Flags(0)) { 33 | assert(parser.box_payload_size(*this) % 8 == 0); 34 | } 35 | 36 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 37 | 38 | virtual void parse_payload(Remainder left_payload); 39 | }; 40 | 41 | 42 | struct ProgressiveDownloadInfoBox::Entry : Box::Entry { 43 | union { Footprint<2 * 32> header; 44 | UInt32< 0> rate; 45 | UInt32<32> initial_delay; 46 | }; 47 | 48 | Entry(const Entry &entry): header(entry.header), Box::Entry(entry) {} 49 | 50 | 51 | template 52 | Entry(const ProgressiveDownloadInfoBox &, Composer &composer) { 53 | composer.get(header); 54 | } 55 | 56 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 57 | 58 | }; 59 | 60 | inline uint32_t ProgressiveDownloadInfoBox::entries() const { 61 | return parser().box_payload_size(*this) / (decltype(Entry::header)::size / 8); // to the end of box 62 | } 63 | 64 | 65 | }} // namespace mpeg::isobase 66 | 67 | #endif // __MPEG_ISOBASE_PROGRESSIVE_DOWNLOAD_INFO_BOX__ 68 | 69 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/protection_scheme_info.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_PROTECTION_SCHEME_INFO_BOX__ 2 | #define __MPEG_ISOBASE_PROTECTION_SCHEME_INFO_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct ProtectionSchemeInfoBox: Box { 14 | 15 | static constexpr Type container_type = 'ipro'; 16 | static constexpr Type box_type = 'sinf'; 17 | static constexpr const char *box_name = "ProtectionSchemeInfoBox"; 18 | 19 | //OriginalFormatBox(fmt) original_format; 20 | //SchemeTypeBox scheme_type_box; // optional 21 | //SchemeInformationBox info; // optional 22 | 23 | ProtectionSchemeInfoBox(Composer &composer): Box(composer, box_type) {} 24 | ProtectionSchemeInfoBox(Parser &parser): Box(parser) {} 25 | 26 | // TODO: PROCESS PAYLOAD 27 | }; 28 | 29 | 30 | }} // namespace mpeg::isobase 31 | 32 | #endif // __MPEG_ISOBASE_PROTECTION_SCHEME_INFO_BOX__ 33 | 34 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/sample_auxiliary_information_sizes.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_SAMPLE_AUXILIARY_INFORMATION_SIZES_BOX__ 2 | #define __MPEG_ISOBASE_SAMPLE_AUXILIARY_INFORMATION_SIZES_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct SampleAuxiliaryInformationSizesBox: FullBox { 14 | 15 | static constexpr Type container_type[] = {'stbl', 'traf'}; 16 | static constexpr Type box_type = 'saiz'; 17 | static constexpr const char *box_name = "SampleAuxiliaryInformationSizesBox"; 18 | 19 | union { Footprint<2 * 32> aux_header; 20 | UInt32< 0> aux_info_type; 21 | UInt32<32> aux_info_type_parameter; 22 | }; 23 | 24 | union { Footprint<8 + 32> header; 25 | UInt8 < 0> default_sample_info_size; 26 | UInt32<32> sample_count; 27 | }; 28 | UInt8<>::Array sample_info_size; 29 | 30 | 31 | template 32 | void SampleAuxiliaryInformationSizesBox_(Composer &composer) { 33 | if (flags & 1) { 34 | composer.get(aux_header); 35 | } 36 | composer.get(header); 37 | } 38 | 39 | template ::Array::Vector> 40 | SampleAuxiliaryInformationSizesBox(Composer &composer, const SampleInfoSize sample_info_size = SampleInfoSize(), Flags flags = 0, bool largesize = false): FullBox(composer, box_type, Version(0), flags, largesize) { 41 | SampleAuxiliaryInformationSizesBox_(composer); 42 | if (sample_info_size.size() != 0) { 43 | default_sample_info_size = 0; 44 | composer.get(this->sample_info_size, sample_info_size); 45 | } 46 | } 47 | 48 | SampleAuxiliaryInformationSizesBox(Parser &parser): FullBox(parser, Version(0)) { 49 | SampleAuxiliaryInformationSizesBox_(parser); 50 | if (default_sample_info_size == 0) { 51 | parser.get(*this, sample_info_size); 52 | //assert(parser.box_payload_size(*this) == sample_count); 53 | } 54 | } 55 | 56 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 57 | 58 | }; 59 | 60 | 61 | }} // namespace mpeg::isobase 62 | 63 | #endif // __MPEG_ISOBASE_SAMPLE_AUXILIARY_INFORMATION_SIZES_BOX__ 64 | 65 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/sample_dependency_type.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_SAMPLE_DEPENDENCY_TYPE_BOX__ 2 | #define __MPEG_ISOBASE_SAMPLE_DEPENDENCY_TYPE_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | namespace mpeg { 11 | namespace isobase { 12 | 13 | 14 | struct SampleDependencyTypeBox: FullBox { 15 | 16 | static constexpr Type container_type[] = {'stbl', 'traf'}; 17 | static constexpr Type box_type = 'sdtp'; 18 | static constexpr const char *box_name = "SampleDependencyTypeBox"; 19 | 20 | struct Entry; 21 | struct Parsed { 22 | using Entries = Box::Parsed::Entries; 23 | }; 24 | struct Composed { 25 | using Entries = Box::Composed::Entries; 26 | }; 27 | 28 | //sample_count is taken from the sample_count in the Sample Size Box ('stsz') or Compact Sample Size Box (‘stz2’). 29 | inline uint32_t entries() const; 30 | 31 | SampleDependencyTypeBox(Composer &composer, Version version = 0, bool largesize = false): FullBox(composer, box_type, version, Flags(0)) { 32 | } 33 | 34 | SampleDependencyTypeBox(Parser &parser): FullBox(parser, Flags(0)) { 35 | } 36 | 37 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 38 | 39 | virtual void parse_payload(Remainder left_payload); 40 | }; 41 | 42 | 43 | struct SampleDependencyTypeBox::Entry : Box::Entry { 44 | union { Footprint<8> header; 45 | UInt<2, 0> is_leading; 46 | UInt<2, 2> sample_depends_on; 47 | UInt<2, 4> sample_is_depended_on; 48 | UInt<2, 6> sample_has_redundancy; 49 | UInt8<> entire_mask; 50 | }; 51 | 52 | Entry(const Entry &entry): header(entry.header), Box::Entry(entry) {} 53 | 54 | template 55 | Entry(const SampleDependencyTypeBox &, Composer &composer) { 56 | composer.get(header); 57 | } 58 | 59 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 60 | 61 | }; 62 | 63 | inline uint32_t SampleDependencyTypeBox::entries() const { 64 | return parser().box_payload_size(*this) / (decltype(Entry::header)::size / 8); // to the end of box 65 | } 66 | 67 | 68 | }} // namespace mpeg::isobase 69 | 70 | #endif // __MPEG_ISOBASE_SAMPLE_DEPENDENCY_TYPE_BOX__ 71 | 72 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/sample_description.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_SAMPLE_DESCRIPTION_BOX__ 2 | #define __MPEG_ISOBASE_SAMPLE_DESCRIPTION_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct SampleDescriptionBox: FullBox { 14 | 15 | static constexpr Type container_type = 'stbl'; 16 | static constexpr Type box_type = 'stsd'; 17 | static constexpr const char *box_name = "SampleDescriptionBox"; 18 | 19 | UInt32<0> entry_count; 20 | 21 | SampleDescriptionBox(Composer &composer, uint32_t entry_count, Version version = 0, bool largesize = false): FullBox(composer, box_type, version, Flags(0), largesize) { 22 | composer.get(this->entry_count) = entry_count; 23 | } 24 | 25 | SampleDescriptionBox(Parser &parser): FullBox(parser, Flags(0)) { 26 | parser.get(entry_count); 27 | assert(entry_count > 0); 28 | } 29 | 30 | virtual void parse_payload(Remainder left); 31 | virtual void output_fields(bitstream::output::meta::field::Stream &stream_) const; 32 | }; 33 | 34 | 35 | }} // namespace mpeg::isobase 36 | 37 | #endif // __MPEG_ISOBASE_SAMPLE_DESCRIPTION_BOX__ 38 | 39 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/sample_entry.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_SAMPLE_ENTRY__ 2 | #define __MPEG_ISOBASE_SAMPLE_ENTRY__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct SampleEntry: Box { 14 | 15 | static constexpr Type container_type = 'stsd'; 16 | static constexpr const char *box_name = "SampleEntry"; 17 | 18 | union { Footprint<8 * 6 + 16> header; 19 | UInt8 < 0>::Static::Array<6> reserved; // = 0 20 | UInt16<48> data_reference_index; 21 | }; 22 | 23 | template ::value> 24 | void SampleEntry_(Composer &composer) { 25 | composer.get(header); 26 | const_field(reserved, {0, 0, 0, 0, 0, 0}); 27 | } 28 | 29 | inline SampleEntry(Composer &composer, uint32_t format, bool largesize = false): Box(composer, format, largesize) { 30 | SampleEntry_(composer); 31 | } 32 | 33 | inline SampleEntry(Parser &parser): Box(parser) { 34 | SampleEntry_(parser); 35 | } 36 | 37 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 38 | 39 | }; 40 | 41 | 42 | }} // namespace mpeg::isobase 43 | 44 | #endif // __MPEG_ISOBASE_SAMPLE_ENTRY__ 45 | 46 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/sample_group_description.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_SAMPLE_GROUP_DESCRIPTION_BOX__ 2 | #define __MPEG_ISOBASE_SAMPLE_GROUP_DESCRIPTION_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct SampleGroupDescriptionBox: FullBox { 14 | 15 | static constexpr Type container_type[] = {'stbl', 'traf'}; 16 | static constexpr Type box_type = 'sgpd'; 17 | static constexpr const char *box_name = "SampleGroupDescriptionBox"; 18 | 19 | UInt32<> grouping_type; 20 | UInt32<> default_length; // version==1 21 | UInt32<> default_sample_description_index; // version>=2 22 | UInt32<> entry_count; 23 | 24 | template ::value> 25 | void SampleGroupDescriptionBox_(Composer &composer) { 26 | composer.get(grouping_type); 27 | 28 | if (version == 1) { 29 | composer.get(default_length); 30 | } 31 | if (version >= 2) { 32 | composer.get(default_sample_description_index); 33 | } 34 | composer.get(entry_count); 35 | } 36 | 37 | SampleGroupDescriptionBox(Composer &composer, Flags flags, Version version = 0, bool largesize = false): FullBox(composer, box_type, version, Flags(0), largesize) { 38 | SampleGroupDescriptionBox_(composer); 39 | } 40 | 41 | SampleGroupDescriptionBox(Parser &parser): FullBox(parser, Flags(0)) { 42 | SampleGroupDescriptionBox_(parser); 43 | } 44 | 45 | // TODO: PROCESS PAYLOAD 46 | 47 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 48 | }; 49 | 50 | 51 | }} // namespace mpeg::isobase 52 | 53 | #endif // __MPEG_ISOBASE_SAMPLE_GROUP_DESCRIPTION_BOX__ 54 | 55 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/sample_scale.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_SAMPLE_SCALE_BOX__ 2 | #define __MPEG_ISOBASE_SAMPLE_SCALE_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct SampleScaleBox: FullBox { 14 | 15 | //static constexpr Type container_type = ''; 16 | static constexpr Type box_type = 'stsl'; 17 | static constexpr const char *box_name = "SampleScaleBox"; 18 | 19 | union { Footprint<32+ 26 + 3 * 2 + 32> header; 20 | UInt<7, 0> reserved; // = 0; 21 | UInt<1, 7> constraint_flag; 22 | UInt8< 8> scale_method; 23 | UInt16<16> display_center_x; 24 | UInt16<32> display_center_y; 25 | }; 26 | 27 | template ::value> 28 | void SampleScaleBox_(Composer &composer) { 29 | composer.get(header); 30 | const_field(reserved, 0); 31 | } 32 | 33 | SampleScaleBox(Composer &composer, Flags flags, Version version = 0, bool largesize = false): FullBox(composer, box_type, version, Flags(0), largesize) { 34 | SampleScaleBox_(composer); 35 | } 36 | 37 | SampleScaleBox(Parser &parser): FullBox(parser, Flags(0)) { 38 | SampleScaleBox_(parser); 39 | } 40 | 41 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 42 | 43 | }; 44 | 45 | 46 | }} // namespace mpeg::isobase 47 | 48 | #endif // __MPEG_ISOBASE_SAMPLE_SCALE_BOX__ 49 | 50 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/sample_size.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_SAMPLE_SIZE_BOX__ 2 | #define __MPEG_ISOBASE_SAMPLE_SIZE_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | namespace mpeg { 11 | namespace isobase { 12 | 13 | 14 | struct SampleSizeBox: FullBox { 15 | 16 | static constexpr Type container_type = 'stbl'; 17 | static constexpr Type box_type = 'stsz'; 18 | static constexpr const char *box_name = "SampleSizeBox"; 19 | 20 | union { Footprint<2 * 32> header; 21 | UInt32< 0> sample_size; 22 | UInt32<32> sample_count; 23 | }; 24 | 25 | struct Entry; 26 | struct Parsed { 27 | using Entries = Box::Parsed::Entries; 28 | }; 29 | struct Composed { 30 | using Entries = Box::Composed::Entries; 31 | }; 32 | 33 | SampleSizeBox(Composer &composer, uint32_t sample_size, uint32_t sample_count, Version version = 0, bool largesize = false): FullBox(composer, box_type, version, Flags(0), largesize) { 34 | composer.get(header); 35 | this->sample_size = sample_size; 36 | this->sample_count = sample_count; 37 | } 38 | 39 | SampleSizeBox(Parser &parser): FullBox(parser, Flags(0)) { 40 | parser.get(header); 41 | 42 | assert(sample_size == 0 || parser.box_payload_size(*this) / sizeof(uint32_t) == sample_count); 43 | } 44 | 45 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 46 | 47 | virtual void parse_payload(Remainder left_payload); 48 | }; 49 | 50 | struct SampleSizeBox::Entry : Box::Entry { 51 | union { Footprint<32> header; 52 | UInt32<0> entry_size; 53 | }; 54 | 55 | Entry(const Entry &entry): header(entry.header), Box::Entry(entry) {} 56 | 57 | template 58 | Entry(const SampleSizeBox &, Composer &composer) { 59 | composer.get(header); 60 | } 61 | 62 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 63 | 64 | }; 65 | 66 | 67 | }} // namespace mpeg::isobase 68 | 69 | #endif // __MPEG_ISOBASE_SAMPLE_SIZE_BOX__ 70 | 71 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/sample_to_chunk.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_SAMPLE_TO_CHUNK_BOX__ 2 | #define __MPEG_ISOBASE_SAMPLE_TO_CHUNK_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | namespace mpeg { 11 | namespace isobase { 12 | 13 | 14 | struct SampleToChunkBox: FullBox { 15 | 16 | static constexpr Type container_type = 'stbl'; 17 | static constexpr Type box_type = 'stsc'; 18 | static constexpr const char *box_name = "SampleToChunkBox"; 19 | 20 | UInt32<0> entry_count; 21 | 22 | struct Entry; 23 | struct Parsed { 24 | using Entries = Box::Parsed::Entries; 25 | }; 26 | struct Composed { 27 | using Entries = Box::Composed::Entries; 28 | }; 29 | 30 | SampleToChunkBox(Composer &composer, uint32_t entry_count, Version version = 0, bool largesize = false): FullBox(composer, box_type, version, Flags(0), largesize) { 31 | composer.get(this->entry_count) = entry_count; 32 | } 33 | 34 | SampleToChunkBox(Parser &parser): FullBox(parser, Flags(0)) { 35 | parser.get(entry_count); 36 | //assert(entry_count > 0); 37 | } 38 | 39 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 40 | 41 | virtual void parse_payload(Remainder left_payload); 42 | }; 43 | 44 | struct SampleToChunkBox::Entry : Box::Entry { 45 | union { Footprint<3 * 32> header; 46 | UInt32< 0> first_chunk; 47 | UInt32<32> samples_per_chunk; 48 | UInt32<64> sample_description_index; 49 | }; 50 | 51 | Entry(const Entry &entry): header(entry.header), Box::Entry(entry) {} 52 | 53 | template 54 | Entry(const SampleToChunkBox &, Composer &composer) { 55 | composer.get(header); 56 | } 57 | 58 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 59 | 60 | }; 61 | 62 | 63 | }} // namespace mpeg::isobase 64 | 65 | #endif // __MPEG_ISOBASE_SAMPLE_TO_CHUNK_BOX__ 66 | 67 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/sample_to_group.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_SAMPLE_TO_GROUP_BOX__ 2 | #define __MPEG_ISOBASE_SAMPLE_TO_GROUP_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | namespace mpeg { 11 | namespace isobase { 12 | 13 | 14 | struct SampleToGroupBox: FullBox { 15 | 16 | static constexpr Type container_type[] = {'stbl', 'traf'}; 17 | static constexpr Type box_type = 'sbgp'; 18 | static constexpr const char *box_name = "SampleToGroupBox"; 19 | 20 | UInt32<> grouping_type; 21 | UInt32<> grouping_type_parameter; // version == 1 22 | UInt32<> entry_count; 23 | 24 | struct Entry; 25 | struct Parsed { 26 | using Entries = Box::Parsed::Entries; 27 | }; 28 | struct Composed { 29 | using Entries = Box::Composed::Entries; 30 | }; 31 | 32 | template ::value> 33 | void SampleToGroupBox_(Composer &composer) { 34 | composer.get(grouping_type); 35 | 36 | if (version == 1) { 37 | composer.get(grouping_type_parameter); 38 | } 39 | composer.get(entry_count); 40 | } 41 | 42 | SampleToGroupBox(Composer &composer, Flags flags, Version version = 0, bool largesize = false): FullBox(composer, box_type, version, Flags(0), largesize) { 43 | SampleToGroupBox_(composer); 44 | } 45 | 46 | SampleToGroupBox(Parser &parser): FullBox(parser, Flags(0)) { 47 | SampleToGroupBox_(parser); 48 | } 49 | 50 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 51 | 52 | virtual void parse_payload(Remainder left_payload); 53 | }; 54 | 55 | struct SampleToGroupBox::Entry : Box::Entry { 56 | union { Footprint<2*32> header; 57 | UInt32<0> sample_count; 58 | UInt32<32> group_description_index; 59 | }; 60 | 61 | Entry(const Entry &entry): header(entry.header), Box::Entry(entry) {} 62 | 63 | template 64 | Entry(const SampleToGroupBox &, Composer &composer) { 65 | composer.get(header); 66 | } 67 | 68 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 69 | 70 | }; 71 | 72 | 73 | }} // namespace mpeg::isobase 74 | 75 | #endif // __MPEG_ISOBASE_SAMPLE_TO_GROUP_BOX__ 76 | 77 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/scheme_information.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_SCHEME_INFORMATION_BOX__ 2 | #define __MPEG_ISOBASE_SCHEME_INFORMATION_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct SchemeInformationBox: Box { 14 | 15 | static constexpr Type container_type[] = {'sinf', 'srpp'}; 16 | static constexpr Type box_type = 'schi'; 17 | static constexpr const char *box_name = "SchemeInformationBox"; 18 | 19 | //Box scheme_specific_data[]; 20 | 21 | SchemeInformationBox(Composer &composer): Box(composer, box_type) {} 22 | SchemeInformationBox(Parser &parser): Box(parser) {} 23 | }; 24 | 25 | 26 | }} // namespace mpeg::isobase 27 | 28 | #endif // __MPEG_ISOBASE_SCHEME_INFORMATION_BOX__ 29 | 30 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/scheme_type.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_SCHEME_TYPE_BOX__ 2 | #define __MPEG_ISOBASE_SCHEME_TYPE_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct SchemeTypeBox: FullBox { 14 | 15 | static constexpr Type container_type[] = {'sinf', 'srpp'}; 16 | static constexpr Type box_type = 'schm'; 17 | static constexpr const char *box_name = "SchemeTypeBox"; 18 | 19 | union { Footprint<2 * 32> header; 20 | UInt32< 0> scheme_type; 21 | UInt32<32> scheme_version; 22 | }; 23 | String scheme_uri; 24 | 25 | SchemeTypeBox(Composer &composer, const std::string &scheme_uri, Flags flags = 0, bool largesize = false) 26 | : FullBox(composer, box_type, Version(0), flags | (scheme_uri.empty() ? 0: 0x000001), largesize) { 27 | composer.get(header); 28 | if (flags & 0x000001) { 29 | composer.get(this->scheme_uri, scheme_uri); 30 | } 31 | } 32 | 33 | SchemeTypeBox(Parser &parser): FullBox(parser, Version(0)) { 34 | parser.get(header); 35 | if (flags & 0x000001) { 36 | parser.get(*this, scheme_uri); 37 | } 38 | } 39 | 40 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 41 | 42 | }; 43 | 44 | 45 | }} // namespace mpeg::isobase 46 | 47 | #endif // __MPEG_ISOBASE_SCHEME_TYPE_BOX__ 48 | 49 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/segment_type.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_SEGMENT_TYPE_BOX__ 2 | #define __MPEG_ISOBASE_SEGMENT_TYPE_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct SegmentTypeBox: FileTypeBox { 14 | static constexpr Type box_type = 'styp'; 15 | static constexpr const char *box_name = "SegmentTypeBox"; 16 | 17 | using FileTypeBox::FileTypeBox; 18 | }; 19 | 20 | 21 | }} // namespace mpeg::isobase 22 | 23 | #endif // __MPEG_ISOBASE_SEGMENT_TYPE_BOX__ 24 | 25 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/shadow_sync_sample.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_SHADOW_SYNC_SAMPLE_BOX__ 2 | #define __MPEG_ISOBASE_SHADOW_SYNC_SAMPLE_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | namespace mpeg { 11 | namespace isobase { 12 | 13 | 14 | struct ShadowSyncSampleBox: FullBox { 15 | 16 | static constexpr Type container_type = 'stbl'; 17 | static constexpr Type box_type = 'stsh'; 18 | static constexpr const char *box_name = "ShadowSyncSampleBox"; 19 | 20 | UInt32<0> entry_count; 21 | 22 | struct Entry; 23 | struct Parsed { 24 | using Entries = Box::Parsed::Entries; 25 | }; 26 | struct Composed { 27 | using Entries = Box::Composed::Entries; 28 | }; 29 | 30 | ShadowSyncSampleBox(Composer &composer, uint32_t entry_count, Version version = 0, bool largesize = false): FullBox(composer, box_type, version, Flags(0), largesize) { 31 | composer.get(this->entry_count) = entry_count; 32 | } 33 | 34 | ShadowSyncSampleBox(Parser &parser): FullBox(parser, Flags(0)) { 35 | parser.get(entry_count); 36 | //assert(entry_count > 0); 37 | } 38 | 39 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 40 | 41 | virtual void parse_payload(Remainder left_payload); 42 | }; 43 | 44 | struct ShadowSyncSampleBox::Entry : Box::Entry { 45 | union { Footprint<2 * 32> header; 46 | UInt32< 0> shadowed_sample_number; 47 | UInt32<32> sync_sample_number; 48 | }; 49 | 50 | Entry(const Entry &entry): header(entry.header), Box::Entry(entry) {} 51 | 52 | template 53 | Entry(const ShadowSyncSampleBox &, Composer &composer) { 54 | composer.get(header); 55 | } 56 | 57 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 58 | 59 | }; 60 | 61 | 62 | }} // namespace mpeg::isobase 63 | 64 | #endif // __MPEG_ISOBASE_SHADOW_SYNC_SAMPLE_BOX__ 65 | 66 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/sound_media_header.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_SOUND_MEDIA_HEADER_BOX__ 2 | #define __MPEG_ISOBASE_SOUND_MEDIA_HEADER_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct SoundMediaHeaderBox: FullBox { 14 | 15 | static constexpr Type container_type = 'minf'; 16 | static constexpr Type box_type = 'smhd'; 17 | static constexpr const char *box_name = "SoundMediaHeaderBox"; 18 | 19 | union { Footprint<2 * 16> header; 20 | Int16< 0> balance; // = 0; 21 | UInt16<16> reserved; // = 0; 22 | }; 23 | 24 | template ::value> 25 | void SoundMediaHeaderBox_(Composer &composer) { 26 | composer.get(header); 27 | 28 | const_field(balance, 0); 29 | const_field(reserved, 0); 30 | } 31 | 32 | SoundMediaHeaderBox(Composer &composer, Version version = 0, bool largesize = false): FullBox(composer, box_type, version, Flags(0), largesize) { 33 | SoundMediaHeaderBox_(composer); 34 | } 35 | 36 | SoundMediaHeaderBox(Parser &parser): FullBox(parser, Flags(0)) { 37 | SoundMediaHeaderBox_(parser); 38 | } 39 | 40 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 41 | 42 | }; 43 | 44 | 45 | }} // namespace mpeg::isobase 46 | 47 | #endif // __MPEG_ISOBASE_SOUND_MEDIA_HEADER_BOX__ 48 | 49 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/sub_track.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_SUB_TRACK__ 2 | #define __MPEG_ISOBASE_SUB_TRACK__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct SubTrack: Box { 14 | 15 | static constexpr Type container_type[] = {'udta', 'trak'}; 16 | static constexpr Type box_type = 'strk'; 17 | static constexpr const char *box_name = "SubTrack"; 18 | 19 | SubTrack(Composer &composer, bool largesize = false): Box(composer, box_type, largesize) {} 20 | SubTrack(Parser &parser): Box(parser) {} 21 | }; 22 | 23 | 24 | }} // namespace mpeg::isobase 25 | 26 | #endif // __MPEG_ISOBASE_SUB_TRACK__ 27 | 28 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/sub_track_information.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_SUB_TRACK_INFORMATION__ 2 | #define __MPEG_ISOBASE_SUB_TRACK_INFORMATION__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct SubTrackInformation: FullBox { 14 | 15 | static constexpr Type container_type = 'strk'; 16 | static constexpr Type box_type = 'stri'; 17 | static constexpr const char *box_name = "SubTrackInformation"; 18 | 19 | 20 | union { Footprint<2*16+32> header; 21 | UInt16<> switch_group; // = 0; 22 | UInt16<16> alternate_group; // = 0; 23 | UInt32<32> sub_track_ID; // = 0; 24 | }; 25 | UInt32<>::Array attribute_list; // to the end of box 26 | 27 | template ::value> 28 | void SubTrackInformation_(Composer &composer) { 29 | composer.get(header); 30 | 31 | const_field(switch_group, 0); 32 | const_field(alternate_group, 0); 33 | const_field(sub_track_ID, 0); 34 | } 35 | 36 | template 37 | SubTrackInformation(Composer &composer, const AttributeList attribute_list, Version version = 0, bool largesize = false): FullBox(composer, box_type, version, Flags(0), largesize) { 38 | SubTrackInformation_(composer); 39 | composer.get(this->attribute_list, attribute_list); 40 | } 41 | 42 | SubTrackInformation(Parser &parser): FullBox(parser, Flags(0)) { 43 | SubTrackInformation_(parser); 44 | parser.get(*this, attribute_list); 45 | } 46 | 47 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 48 | 49 | }; 50 | 51 | 52 | }} // namespace mpeg::isobase 53 | 54 | #endif // __MPEG_ISOBASE_SUB_TRACK_INFORMATION__ 55 | 56 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/subsample_information.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_SUBSAMPLE_INFORMATION_BOX__ 2 | #define __MPEG_ISOBASE_SUBSAMPLE_INFORMATION_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct SubSampleInformationBox: FullBox { 14 | 15 | static constexpr Type container_type[] = {'stbl', 'traf'}; 16 | static constexpr Type box_type = 'subs'; 17 | static constexpr const char *box_name = "SubSampleInformationBox"; 18 | 19 | UInt32<> entry_count; 20 | 21 | SubSampleInformationBox(Composer &composer, uint32_t entry_count, Version version = 0, Flags flags = 0, bool largesize = false): FullBox(composer, box_type, version, flags, largesize) { 22 | composer.get(this->entry_count) = entry_count; 23 | } 24 | 25 | SubSampleInformationBox(Parser &parser): FullBox(parser) { 26 | parser.get(entry_count); 27 | assert(entry_count > 0); 28 | } 29 | 30 | // TODO: PROCESS PAYLOAD 31 | 32 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 33 | 34 | }; 35 | 36 | 37 | }} // namespace mpeg::isobase 38 | 39 | #endif // __MPEG_ISOBASE_SUBSAMPLE_INFORMATION_BOX__ 40 | 41 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/subsegment_index.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_SUBSEGMENT_INDEX_BOX__ 2 | #define __MPEG_ISOBASE_SUBSEGMENT_INDEX_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | namespace mpeg { 11 | namespace isobase { 12 | 13 | 14 | struct SubsegmentIndexBox: FullBox { 15 | 16 | static constexpr Type box_type = 'ssix'; 17 | static constexpr const char *box_name = "SubsegmentIndexBox"; 18 | 19 | UInt32<0> subsegment_count; 20 | 21 | struct Subsegment; 22 | struct Parsed { 23 | using Subsegments = Box::Parsed::Entries; 24 | }; 25 | struct Composed { 26 | using Subsegments = Box::Composed::Entries; 27 | }; 28 | 29 | SubsegmentIndexBox(Composer &composer, uint32_t subsegment_count, bool largesize = false): FullBox(composer, box_type, Version(0), Flags(0), largesize) { 30 | composer.get(this->subsegment_count) = subsegment_count; 31 | } 32 | 33 | SubsegmentIndexBox(Parser &parser): FullBox(parser, Version(0), Flags(0)) { 34 | parser.get(subsegment_count); 35 | //assert(subsegment_count > 0); 36 | } 37 | 38 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 39 | 40 | virtual void parse_payload(Remainder left_payload); 41 | }; 42 | 43 | 44 | struct SubsegmentIndexBox::Subsegment : Box::Entry { 45 | UInt32<> range_count; 46 | 47 | virtual const char *name() const { return "Subsegment"; } 48 | 49 | Subsegment(const Subsegment &) = default; 50 | 51 | template 52 | Subsegment(const SubsegmentIndexBox &, Composer &composer) { 53 | composer.get(range_count); 54 | } 55 | 56 | struct Range; 57 | struct Parsed { 58 | using Ranges = Box::Parsed::Entries; 59 | }; 60 | struct Composed { 61 | using Ranges = Box::Composed::Entries; 62 | }; 63 | 64 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 65 | 66 | }; 67 | 68 | 69 | struct SubsegmentIndexBox::Subsegment::Range : Box::Entry { 70 | union { Footprint<8+24> header; 71 | UInt<8, 0> level; 72 | UInt<24, 8> range_size; 73 | }; 74 | 75 | virtual const char *name() const { return "Range"; } 76 | 77 | Range(const Range &range): header(range.header), Box::Entry(range) {} 78 | 79 | template 80 | Range(const Subsegment &, Composer &composer) { 81 | composer.get(header); 82 | } 83 | 84 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 85 | 86 | }; 87 | 88 | 89 | }} // namespace mpeg::isobase 90 | 91 | #endif // __MPEG_ISOBASE_SUBSEGMENT_INDEX_BOX__ 92 | 93 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/subtitle_media_header.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_SUBTITLE_MEDIA_HEADER_BOX__ 2 | #define __MPEG_ISOBASE_SUBTITLE_MEDIA_HEADER_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct SubtitleMediaHeaderBox: FullBox { 14 | 15 | static constexpr Type container_type = 'minf'; 16 | static constexpr Type box_type = 'sthd'; 17 | static constexpr const char *box_name = "SubtitleMediaHeaderBox"; 18 | 19 | SubtitleMediaHeaderBox(Composer &composer, Version version = 0, Flags flags = 0, bool largesize = false): FullBox(composer, box_type, version, flags, largesize) {} 20 | SubtitleMediaHeaderBox(Parser &parser): FullBox(parser) {} 21 | }; 22 | 23 | 24 | }} // namespace mpeg::isobase 25 | 26 | #endif // __MPEG_ISOBASE_SUBTITLE_MEDIA_HEADER_BOX__ 27 | 28 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/sync_sample.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_SYNC_SAMPLE_BOX__ 2 | #define __MPEG_ISOBASE_SYNC_SAMPLE_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | namespace mpeg { 11 | namespace isobase { 12 | 13 | 14 | struct SyncSampleBox: FullBox { 15 | 16 | static constexpr Type container_type = 'stbl'; 17 | static constexpr Type box_type = 'stss'; 18 | static constexpr const char *box_name = "SyncSampleBox"; 19 | 20 | UInt32<0> entry_count; 21 | 22 | struct Entry; 23 | struct Parsed { 24 | using Entries = Box::Parsed::Entries; 25 | }; 26 | struct Composed { 27 | using Entries = Box::Composed::Entries; 28 | }; 29 | 30 | SyncSampleBox(Composer &composer, uint32_t entry_count, Version version = 0, bool largesize = false): FullBox(composer, box_type, version, Flags(0), largesize) { 31 | composer.get(this->entry_count) = entry_count; 32 | } 33 | 34 | SyncSampleBox(Parser &parser): FullBox(parser, Flags(0)) { 35 | parser.get(entry_count); 36 | //assert(entry_count > 0); 37 | } 38 | 39 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 40 | 41 | virtual void parse_payload(Remainder left_payload); 42 | }; 43 | 44 | struct SyncSampleBox::Entry : Box::Entry { 45 | union { Footprint<32> header; 46 | UInt32<0> sample_number; 47 | }; 48 | 49 | Entry(const Entry &entry): header(entry.header), Box::Entry(entry) {} 50 | 51 | template 52 | Entry(const SyncSampleBox &, Composer &composer) { 53 | composer.get(header); 54 | } 55 | 56 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 57 | 58 | }; 59 | 60 | 61 | }} // namespace mpeg::isobase 62 | 63 | #endif // __MPEG_ISOBASE_SYNC_SAMPLE_BOX__ 64 | 65 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/time_to_sample.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_TIME_TO_SAMPLE_BOX__ 2 | #define __MPEG_ISOBASE_TIME_TO_SAMPLE_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | namespace mpeg { 11 | namespace isobase { 12 | 13 | 14 | struct TimeToSampleBox: FullBox { 15 | 16 | static constexpr Type container_type = 'stbl'; 17 | static constexpr Type box_type = 'stts'; 18 | static constexpr const char *box_name = "TimeToSampleBox"; 19 | 20 | UInt32<0> entry_count; 21 | 22 | struct Entry; 23 | struct Parsed { 24 | using Entries = Box::Parsed::Entries; 25 | }; 26 | struct Composed { 27 | using Entries = Box::Composed::Entries; 28 | }; 29 | 30 | TimeToSampleBox(Composer &composer, uint32_t entry_count, Version version = 0, bool largesize = false): FullBox(composer, box_type, version, Flags(0), largesize) { 31 | composer.get(this->entry_count) = entry_count; 32 | } 33 | 34 | TimeToSampleBox(Parser &parser): FullBox(parser, Flags(0)) { 35 | parser.get(this->entry_count); 36 | //assert(entry_count > 0); 37 | } 38 | 39 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 40 | 41 | virtual void parse_payload(Remainder left_payload); 42 | }; 43 | 44 | struct TimeToSampleBox::Entry : Box::Entry { 45 | union { Footprint<2 * 32> header; 46 | UInt32< 0> sample_count; 47 | UInt32<32> sample_delta; 48 | }; 49 | 50 | Entry(const Entry &entry): header(entry.header), Box::Entry(entry) {} 51 | 52 | template 53 | Entry(const TimeToSampleBox &, Composer &composer) { 54 | composer.get(header); 55 | } 56 | 57 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 58 | 59 | }; 60 | 61 | 62 | }} // namespace mpeg::isobase 63 | 64 | #endif // __MPEG_ISOBASE_TIME_TO_SAMPLE_BOX__ 65 | 66 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/track_extends.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_TRACK_EXTENDS_BOX__ 2 | #define __MPEG_ISOBASE_TRACK_EXTENDS_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct TrackExtendsBox: FullBox { 14 | 15 | static constexpr Type container_type = 'mvex'; 16 | static constexpr Type box_type = 'trex'; 17 | static constexpr const char *box_name = "TrackExtendsBox"; 18 | 19 | union { Footprint<5 * 32> header; 20 | UInt32< 0> track_ID; 21 | UInt32<32> default_sample_description_index; 22 | UInt32<64> default_sample_duration; 23 | UInt32<96> default_sample_size; 24 | UInt32<128> default_sample_flags; 25 | }; 26 | 27 | TrackExtendsBox(Composer &composer, bool largesize = false): FullBox(composer, box_type, Version(0), Flags(0), largesize) { 28 | composer.get(header); 29 | } 30 | 31 | TrackExtendsBox(Parser &parser): FullBox(parser, Version(0), Flags(0)) { 32 | parser.get(header); 33 | } 34 | 35 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 36 | 37 | }; 38 | 39 | 40 | }} // namespace mpeg::isobase 41 | 42 | #endif // __MPEG_ISOBASE_TRACK_EXTENDS_BOX__ 43 | 44 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/track_fragment_base_media_decode_time.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_TRACK_FRAGMENT_BASE_MEDIA_DECODE_TIME_BOX__ 2 | #define __MPEG_ISOBASE_TRACK_FRAGMENT_BASE_MEDIA_DECODE_TIME_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct TrackFragmentBaseMediaDecodeTimeBox: FullBox { 14 | 15 | static constexpr Type container_type = 'traf'; 16 | static constexpr Type box_type = 'tfdt'; 17 | static constexpr const char *box_name = "TrackFragmentBaseMediaDecodeTimeBox"; 18 | 19 | template 20 | struct Header { 21 | UInt baseMediaDecodeTime; 22 | Header() {} 23 | 24 | template 25 | void Header_(Composer &composer) { 26 | composer.get(baseMediaDecodeTime); 27 | } 28 | 29 | void output(bitstream::output::meta::field::Stream &stream_) const; 30 | }; 31 | Header<0> v0; 32 | Header<1> v1; 33 | 34 | uint64_t baseMediaDecodeTime() const { return version == 1 ? uint64_t(v1.baseMediaDecodeTime): uint64_t(v0.baseMediaDecodeTime); } 35 | 36 | template 37 | void TrackFragmentBaseMediaDecodeTimeBox_(Composer &composer) { 38 | if (version == 1) { 39 | v1.Header_(composer); 40 | } else { 41 | v0.Header_(composer); 42 | } 43 | } 44 | 45 | TrackFragmentBaseMediaDecodeTimeBox(Composer &composer, Version version, bool largesize = false): FullBox(composer, box_type, version, Flags(0), largesize) { 46 | TrackFragmentBaseMediaDecodeTimeBox_(composer); 47 | } 48 | 49 | TrackFragmentBaseMediaDecodeTimeBox(Parser &parser): FullBox(parser, Flags(0)) { 50 | TrackFragmentBaseMediaDecodeTimeBox_(parser); 51 | } 52 | 53 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 54 | 55 | }; 56 | 57 | 58 | }} // namespace mpeg::isobase 59 | 60 | #endif // __MPEG_ISOBASE_TRACK_FRAGMENT_BASE_MEDIA_DECODE_TIME_BOX__ 61 | 62 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/track_fragment_header.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_TRACK_FRAGMENT_HEADER_BOX__ 2 | #define __MPEG_ISOBASE_TRACK_FRAGMENT_HEADER_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct TrackFragmentHeaderBox: FullBox { 14 | 15 | static constexpr Type container_type = 'traf'; 16 | static constexpr Type box_type = 'tfhd'; 17 | static constexpr const char *box_name = "TrackFragmentHeaderBox"; 18 | 19 | UInt32<> track_ID; 20 | // all the following are optional fields 21 | UInt64<> base_data_offset; 22 | UInt32<> default_sample_description_index; 23 | UInt32<> default_sample_duration; 24 | UInt32<> default_sample_size; 25 | UInt32<> default_sample_flags; 26 | 27 | template ::value> 28 | void TrackFragmentHeaderBox_(Composer &composer) { 29 | 30 | composer.get(track_ID); 31 | 32 | if (flags & 0x000001) { 33 | composer.get(base_data_offset); 34 | } 35 | if (flags & 0x000002) { 36 | composer.get(default_sample_description_index); 37 | } 38 | if (flags & 0x000008) { 39 | composer.get(default_sample_duration); 40 | } 41 | if (flags & 0x000010) { 42 | composer.get(default_sample_duration); 43 | } 44 | if (flags & 0x000020) { 45 | composer.get(default_sample_flags); 46 | } 47 | } 48 | 49 | TrackFragmentHeaderBox(Composer &composer, Flags flags, bool largesize = false): FullBox(composer, box_type, Version(0), flags, largesize) { 50 | TrackFragmentHeaderBox_(composer); 51 | } 52 | 53 | TrackFragmentHeaderBox(Parser &parser): FullBox(parser, Version(0)) { 54 | TrackFragmentHeaderBox_(parser); 55 | } 56 | 57 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 58 | 59 | }; 60 | 61 | 62 | }} // namespace mpeg::isobase 63 | 64 | #endif // __MPEG_ISOBASE_TRACK_FRAGMENT_HEADER_BOX__ 65 | 66 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/track_fragment_random_access.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_TRACK_FRAGMENT_RANDOM_ACCESS_BOX__ 2 | #define __MPEG_ISOBASE_TRACK_FRAGMENT_RANDOM_ACCESS_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct TrackFragmentRandomAccessBox: FullBox { 14 | 15 | static constexpr Type container_type = 'mfra'; 16 | static constexpr Type box_type = 'tfra'; 17 | static constexpr const char *box_name = "TrackFragmentRandomAccessBox"; 18 | 19 | union { Footprint<32+ 26 + 3 * 2 + 32> header; 20 | UInt32< 0> track_ID; 21 | UInt<26, 32> reserved; // = 0; 22 | UInt<2, 58> length_size_of_traf_num; 23 | UInt<2, 60> length_size_of_trun_num; 24 | UInt<2, 62> length_size_of_sample_num; 25 | UInt32<> number_of_entry; 26 | }; 27 | 28 | TrackFragmentRandomAccessBox(Composer &composer, Version version = 0, bool largesize = false): FullBox(composer, box_type, version, Flags(0)) { 29 | composer.get(header); 30 | } 31 | 32 | TrackFragmentRandomAccessBox(Parser &parser): FullBox(parser, Flags(0)) { 33 | parser.get(header); 34 | } 35 | 36 | // TODO: PROCESS PAYLOAD 37 | 38 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 39 | }; 40 | 41 | 42 | }} // namespace mpeg::isobase 43 | 44 | #endif // __MPEG_ISOBASE_TRACK_FRAGMENT_RANDOM_ACCESS_BOX__ 45 | 46 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/track_reference.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_TRACK_REFERENCE_BOX__ 2 | #define __MPEG_ISOBASE_TRACK_REFERENCE_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct TrackReferenceBox: Box { 14 | 15 | static constexpr Type container_type = 'trak'; 16 | static constexpr Type box_type = 'tref'; 17 | 18 | TrackReferenceBox(Composer &composer, bool largesize = false): Box(composer, box_type, largesize) { 19 | } 20 | 21 | TrackReferenceBox(Parser &parser): Box(parser) { 22 | } 23 | 24 | virtual void parse_payload(Remainder left_payload); 25 | }; 26 | 27 | 28 | }} // namespace mpeg::isobase 29 | 30 | #endif // __MPEG_ISOBASE_TRACK_REFERENCE_BOX__ 31 | 32 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/track_reference_type.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_TRACK_REFERENCE_TYPE_BOX__ 2 | #define __MPEG_ISOBASE_TRACK_REFERENCE_TYPE_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | template 14 | struct TrackReferenceTypeBox: Box { 15 | 16 | static constexpr Type container_type = 'tref'; 17 | static constexpr Type box_type = reference_type; 18 | 19 | UInt32<>::Array track_IDs; // to end of the box 20 | 21 | template 22 | TrackReferenceTypeBox(Composer &composer, const Track_IDs &track_IDs, bool largesize = false): Box(composer, box_type, largesize) { 23 | composer.get(this->track_IDs, track_IDs); 24 | } 25 | 26 | TrackReferenceTypeBox(Parser &parser): Box(parser) { 27 | parser.get(*this, track_IDs); 28 | } 29 | 30 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 31 | 32 | }; 33 | 34 | 35 | }} // namespace mpeg::isobase 36 | 37 | #endif // __MPEG_ISOBASE_TRACK_REFERENCE_TYPE_BOX__ 38 | 39 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/track_selection.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_TRACK_SELECTION_BOX__ 2 | #define __MPEG_ISOBASE_TRACK_SELECTION_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct TrackSelectionBox: FullBox { 14 | 15 | static constexpr Type container_type = 'udta'; 16 | static constexpr Type box_type = 'tsel'; 17 | static constexpr const char *box_name = "TrackSelectionBox"; 18 | 19 | UInt32<> switch_group; // = 0; 20 | UInt32<>::Array attribute_list; // to the end of box 21 | 22 | template ::value> 23 | void TrackSelectionBox_(Composer &composer) { 24 | composer.get(switch_group); 25 | const_field(switch_group, 0); 26 | } 27 | 28 | template 29 | TrackSelectionBox(Composer &composer, const AttributeList attribute_list, Version version = 0, bool largesize = false): FullBox(composer, box_type, version, Flags(0), largesize) { 30 | TrackSelectionBox_(composer); 31 | composer.get(this->attribute_list, attribute_list); 32 | } 33 | 34 | TrackSelectionBox(Parser &parser): FullBox(parser, Flags(0)) { 35 | TrackSelectionBox_(parser); 36 | parser.get(*this, attribute_list); 37 | } 38 | 39 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 40 | 41 | }; 42 | 43 | 44 | }} // namespace mpeg::isobase 45 | 46 | #endif // __MPEG_ISOBASE_TRACK_SELECTION_BOX__ 47 | 48 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/user_data.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_USER_DATA_BOX__ 2 | #define __MPEG_ISOBASE_USER_DATA_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct UserDataBox: Box { 14 | 15 | static constexpr Type container_type[] = {'moov', 'trak'}; 16 | static constexpr Type box_type = 'udta'; 17 | static constexpr const char *box_name = "UserDataBox"; 18 | 19 | UserDataBox(Composer &composer, bool largesize = false): Box(composer, box_type, largesize) {} 20 | UserDataBox(Parser &parser): Box(parser) {} 21 | }; 22 | 23 | 24 | }} // namespace mpeg::isobase 25 | 26 | #endif // __MPEG_ISOBASE_USER_DATA_BOX__ 27 | 28 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/video_media_header.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_VIDEO_MEDIA_HEADER_BOX__ 2 | #define __MPEG_ISOBASE_VIDEO_MEDIA_HEADER_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct VideoMediaHeaderBox: FullBox { 14 | 15 | static constexpr Type container_type = 'minf'; 16 | static constexpr Type box_type = 'vmhd'; 17 | static constexpr const char *box_name = "VideoMediaHeaderBox"; 18 | 19 | union { Footprint<4 * 16> header; 20 | UInt16< 0> graphicsmode; // copy 21 | UInt16<16>::Static::Array<3> opcolor; // = 0; 22 | }; 23 | 24 | template ::value> 25 | void VideoMediaHeaderBox_(Composer &composer) { 26 | composer.get(header); 27 | 28 | const_field(graphicsmode, 0); 29 | const_field(opcolor, {0, 0, 0}); 30 | } 31 | 32 | VideoMediaHeaderBox(Composer &composer, Version version = 0, bool largesize = false): FullBox(composer, box_type, version, Flags(1), largesize) { 33 | VideoMediaHeaderBox_(composer); 34 | } 35 | 36 | VideoMediaHeaderBox(Parser &parser): FullBox(parser, Flags(1)) { 37 | VideoMediaHeaderBox_(parser); 38 | } 39 | 40 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 41 | 42 | }; 43 | 44 | 45 | }} // namespace mpeg::isobase 46 | 47 | #endif // __MPEG_ISOBASE_VIDEO_MEDIA_HEADER_BOX__ 48 | 49 | -------------------------------------------------------------------------------- /include/mpeg-isobase/box/xml.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_XML_BOX__ 2 | #define __MPEG_ISOBASE_XML_BOX__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace mpeg { 10 | namespace isobase { 11 | 12 | 13 | struct XMLBox: FullBox { 14 | 15 | static constexpr Type container_type = 'meta'; 16 | static constexpr Type box_type = 'xml '; 17 | static constexpr const char *box_name = "XMLBox"; 18 | 19 | String xml; 20 | 21 | XMLBox(Composer &composer, const std::string &xml, Version version = 0, bool largesize = false): FullBox(composer, box_type, version, Flags(0), largesize) { 22 | composer.get(this->xml, xml); 23 | } 24 | 25 | XMLBox(Parser &parser): FullBox(parser, Flags(0)) { 26 | parser.get(*this, xml); 27 | } 28 | 29 | virtual void output_fields(bitstream::output::meta::field::Stream &stream) const; 30 | 31 | }; 32 | 33 | 34 | }} // namespace mpeg::isobase 35 | 36 | #endif // __MPEG_ISOBASE_XML_BOX__ 37 | 38 | -------------------------------------------------------------------------------- /include/mpeg-isobase/boxes.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_BOXES__ 2 | #define __MPEG_ISOBASE_BOXES__ 3 | 4 | #include 5 | 6 | 7 | namespace mpeg { 8 | namespace isobase { 9 | 10 | struct Boxes: Box::Map { 11 | 12 | template 13 | void add(const Args &...args) { Box::Map::template add(args...); } 14 | }; 15 | 16 | struct RegisterBoxes : virtual Boxes { 17 | RegisterBoxes(); 18 | }; 19 | 20 | 21 | }} // namespace mpeg::isobase 22 | 23 | 24 | #endif // __MPEG_ISOBASE_BOXES__ 25 | 26 | -------------------------------------------------------------------------------- /include/mpeg-isobase/composer.h: -------------------------------------------------------------------------------- 1 | #ifndef __MPEG_ISOBASE_COMPOSER__ 2 | #define __MPEG_ISOBASE_COMPOSER__ 3 | 4 | #include 5 | #include 6 | 7 | 8 | namespace mpeg { 9 | namespace isobase { 10 | 11 | struct Box::Composer: bitstream::Composer { 12 | }; 13 | 14 | using Composer = Box::Composer; 15 | 16 | }} // namespace mpeg::isobase 17 | 18 | 19 | #endif // __MPEG_ISOBASE_COMPOSER__ 20 | 21 | -------------------------------------------------------------------------------- /src/box/additional_metadata_container.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | 10 | 11 | }} // namespace mpeg::isobase 12 | 13 | -------------------------------------------------------------------------------- /src/box/audio_sample_entry.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void AudioSampleEntry::output_fields(bitstream::output::meta::field::Stream &stream_) const { 10 | SampleEntry::output_fields(stream_); 11 | using namespace bitstream::output::meta::field::tag; 12 | using bitstream::output::meta::field::tag::Stream; 13 | const auto &stream = Stream(stream_); 14 | stream.tag(reserved) << "reserved"; 15 | stream.tag(channelcount) << "channelcount"; 16 | stream.tag(samplesize) << "samplesize"; 17 | stream.tag(pre_defined) << "pre_defined"; 18 | stream.tag(reserved2) << "reserverd"; 19 | stream.tag(samplerate) << "samplerate" << Format("fixed-point"); 20 | } 21 | 22 | 23 | }} // namespace mpeg::isobase 24 | 25 | -------------------------------------------------------------------------------- /src/box/binary_xml.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void BinaryXMLBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 10 | FullBox::output_fields(stream_); 11 | using namespace bitstream::output::meta::field::tag; 12 | using bitstream::output::meta::field::tag::Stream; 13 | const auto &stream = Stream(stream_); 14 | stream.tag(data) << "data"; 15 | } 16 | 17 | 18 | }} // namespace mpeg::isobase 19 | 20 | -------------------------------------------------------------------------------- /src/box/chunk_large_offset.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void ChunkLargeOffsetBox::parse_payload(Remainder left_payload) { 10 | Parsed::Entries entries{*this, parser(), left_payload}; 11 | for(auto entry : entries) { 12 | Parser::Event::Header{parser(), entry}; 13 | } 14 | } 15 | 16 | void ChunkLargeOffsetBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 17 | FullBox::output_fields(stream_); 18 | using namespace bitstream::output::meta::field::tag; 19 | using bitstream::output::meta::field::tag::Stream; 20 | const auto &stream = Stream(stream_); 21 | stream.tag(entry_count) << "entry_count"; 22 | } 23 | 24 | 25 | void ChunkLargeOffsetBox::Entry::output_fields(bitstream::output::meta::field::Stream &stream_) const { 26 | using namespace bitstream::output::meta::field::tag; 27 | using bitstream::output::meta::field::tag::Stream; 28 | const auto &stream = Stream(stream_); 29 | stream.tag(chunk_offset) << "chunk_offset"; 30 | } 31 | 32 | }} // namespace mpeg::isobase 33 | 34 | -------------------------------------------------------------------------------- /src/box/chunk_offset.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void ChunkOffsetBox::parse_payload(Remainder left_payload) { 10 | Parsed::Entries entries{*this, parser(), left_payload}; 11 | for(auto entry : entries) { 12 | Parser::Event::Header{parser(), entry}; 13 | } 14 | } 15 | 16 | void ChunkOffsetBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 17 | FullBox::output_fields(stream_); 18 | using namespace bitstream::output::meta::field::tag; 19 | using bitstream::output::meta::field::tag::Stream; 20 | const auto &stream = Stream(stream_); 21 | stream.tag(entry_count) << "entry_count"; 22 | } 23 | 24 | 25 | void ChunkOffsetBox::Entry::output_fields(bitstream::output::meta::field::Stream &stream_) const { 26 | using namespace bitstream::output::meta::field::tag; 27 | using bitstream::output::meta::field::tag::Stream; 28 | const auto &stream = Stream(stream_); 29 | stream.tag(chunk_offset) << "chunk_offset"; 30 | } 31 | 32 | 33 | }} // namespace mpeg::isobase 34 | 35 | -------------------------------------------------------------------------------- /src/box/compact_sample_size.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void CompactSampleSizeBox::parse_payload(Remainder left_payload) { 10 | switch (uint32_t(field_size)) { 11 | case 4: { 12 | V4::Parsed::Entries entries{*this, parser(), left_payload, [](const auto &box) -> uint32_t { 13 | const uint32_t sample_count = box.sample_count; 14 | return sample_count / 2 + sample_count % 2; 15 | }}; 16 | for(auto entry : entries) { 17 | Parser::Event::Header{parser(), entry}; 18 | } 19 | } break; 20 | case 8: { 21 | V8::Parsed::Entries entries{*this, parser(), left_payload, [](const auto &box) -> uint32_t { return box.sample_count; }}; 22 | for(auto entry : entries) { 23 | Parser::Event::Header{parser(), entry}; 24 | } 25 | } break; 26 | case 16: { 27 | V16::Parsed::Entries entries{*this, parser(), left_payload, [](const auto &box) -> uint32_t { return box.sample_count; }}; 28 | for(auto entry : entries) { 29 | Parser::Event::Header{parser(), entry}; 30 | } 31 | } break; 32 | default: 33 | assert(false); 34 | break; 35 | } 36 | } 37 | 38 | void CompactSampleSizeBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 39 | FullBox::output_fields(stream_); 40 | using namespace bitstream::output::meta::field::tag; 41 | using bitstream::output::meta::field::tag::Stream; 42 | const auto &stream = Stream(stream_); 43 | stream.tag(reserved) << "reserved"; 44 | stream.tag(field_size) << "field_size"; 45 | stream.tag(sample_count) << "sample_count"; 46 | } 47 | 48 | 49 | void CompactSampleSizeBox::V4::Entry::output_fields(bitstream::output::meta::field::Stream &stream_) const { 50 | using namespace bitstream::output::meta::field::tag; 51 | using bitstream::output::meta::field::tag::Stream; 52 | const auto &stream = Stream(stream_); 53 | stream.tag(entry_size_44) << "entry_size"; 54 | } 55 | 56 | void CompactSampleSizeBox::V8::Entry::output_fields(bitstream::output::meta::field::Stream &stream_) const { 57 | using namespace bitstream::output::meta::field::tag; 58 | using bitstream::output::meta::field::tag::Stream; 59 | const auto &stream = Stream(stream_); 60 | stream.tag(entry_size) << "entry_size"; 61 | } 62 | 63 | void CompactSampleSizeBox::V16::Entry::output_fields(bitstream::output::meta::field::Stream &stream_) const { 64 | using namespace bitstream::output::meta::field::tag; 65 | using bitstream::output::meta::field::tag::Stream; 66 | const auto &stream = Stream(stream_); 67 | stream.tag(entry_size) << "entry_size"; 68 | } 69 | 70 | 71 | }} // namespace mpeg::isobase 72 | 73 | -------------------------------------------------------------------------------- /src/box/composition_offset.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void CompositionOffsetBox::parse_payload(Remainder left_payload) { 10 | if (version == 0) { 11 | V0::Parsed::Entries entries{*this, parser(), left_payload}; 12 | for(auto entry : entries) { 13 | Parser::Event::Header{parser(), entry}; 14 | } 15 | } else if (version == 1) { 16 | V1::Parsed::Entries entries{*this, parser(), left_payload}; 17 | for(auto entry : entries) { 18 | Parser::Event::Header{parser(), entry}; 19 | } 20 | } 21 | } 22 | 23 | void CompositionOffsetBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 24 | FullBox::output_fields(stream_); 25 | using namespace bitstream::output::meta::field::tag; 26 | using bitstream::output::meta::field::tag::Stream; 27 | const auto &stream = Stream(stream_); 28 | stream.tag(entry_count) << "entry_count"; 29 | } 30 | 31 | 32 | template 33 | void CompositionOffsetBox::Entry::output_fields(bitstream::output::meta::field::Stream &stream_) const { 34 | using namespace bitstream::output::meta::field::tag; 35 | using bitstream::output::meta::field::tag::Stream; 36 | const auto &stream = Stream(stream_); 37 | stream.tag(sample_count) << "sample_count"; 38 | stream.tag(sample_offset) << "sample_offset"; 39 | } 40 | 41 | template struct CompositionOffsetBox::Entry<0>; 42 | template struct CompositionOffsetBox::Entry<1>; 43 | 44 | }} // namespace mpeg::isobase 45 | 46 | -------------------------------------------------------------------------------- /src/box/composition_to_decode.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void CompositionToDecodeBox::output_fields(bitstream::output::meta::field::Stream &stream) const { 10 | FullBox::output_fields(stream); 11 | if (version == 0) { 12 | v0.output(stream); 13 | } else { 14 | v1.output(stream); 15 | } 16 | } 17 | 18 | template 19 | void CompositionToDecodeBox::Header::output(bitstream::output::meta::field::Stream &stream_) const { 20 | using namespace bitstream::output::meta::field::tag; 21 | using bitstream::output::meta::field::tag::Stream; 22 | const auto &stream = Stream(stream_); 23 | stream.tag(compositionToDTSShift) << "compositionToDTSShift"; 24 | stream.tag(leastDecodeToDisplayDelta) << "leastDecodeToDisplayDelta"; 25 | stream.tag(greatestDecodeToDisplayDelta) << "greatestDecodeToDisplayDelta"; 26 | stream.tag(compositionStartTime) << "compositionStartTime"; 27 | stream.tag(compositionEndTime) << "compositionEndTime"; 28 | } 29 | 30 | 31 | }} // namespace mpeg::isobase 32 | 33 | -------------------------------------------------------------------------------- /src/box/copyright.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void CopyrightBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 10 | FullBox::output_fields(stream_); 11 | using namespace bitstream::output::meta::field::tag; 12 | using bitstream::output::meta::field::tag::Stream; 13 | const auto &stream = Stream(stream_); 14 | stream.tag(pad) << "pad"; 15 | stream.tag(language) << "language" << Format("ISO-639-2/T language code"); 16 | stream.tag(notice) << "notice"; 17 | } 18 | 19 | 20 | }} // namespace mpeg::isobase 21 | 22 | -------------------------------------------------------------------------------- /src/box/data_entry_url.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | 10 | void DataEntryUrlBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 11 | FullBox::output_fields(stream_); 12 | using namespace bitstream::output::meta::field::tag; 13 | using bitstream::output::meta::field::tag::Stream; 14 | const auto &stream = Stream(stream_); 15 | stream.tag(location) << "location"; 16 | } 17 | 18 | 19 | }} // namespace mpeg::isobase 20 | 21 | -------------------------------------------------------------------------------- /src/box/data_entry_urn.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void DataEntryUrnBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 10 | FullBox::output_fields(stream_); 11 | using namespace bitstream::output::meta::field::tag; 12 | using bitstream::output::meta::field::tag::Stream; 13 | const auto &stream = Stream(stream_); 14 | stream.tag(name) << "name"; 15 | stream.tag(location) << "location"; 16 | } 17 | 18 | 19 | }} // namespace mpeg::isobase 20 | 21 | -------------------------------------------------------------------------------- /src/box/data_information.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | 10 | 11 | }} // namespace mpeg::isobase 12 | 13 | -------------------------------------------------------------------------------- /src/box/data_reference.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void DataReferenceBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 10 | FullBox::output_fields(stream_); 11 | using namespace bitstream::output::meta::field::tag; 12 | using bitstream::output::meta::field::tag::Stream; 13 | const auto &stream = Stream(stream_); 14 | stream.tag(entry_count) << "entry_count"; 15 | } 16 | 17 | 18 | }} // namespace mpeg::isobase 19 | 20 | -------------------------------------------------------------------------------- /src/box/degradation_priority.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void DegradationPriorityBox::parse_payload(Remainder left_payload) { 10 | Parsed::Entries entries{*this, parser(), left_payload}; 11 | for(auto entry : entries) { 12 | Parser::Event::Header{parser(), entry}; 13 | } 14 | } 15 | 16 | void DegradationPriorityBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 17 | FullBox::output_fields(stream_); 18 | using namespace bitstream::output::meta::field::tag; 19 | using bitstream::output::meta::field::tag::Stream; 20 | const auto &stream = Stream(stream_); 21 | } 22 | 23 | 24 | void DegradationPriorityBox::Entry::output_fields(bitstream::output::meta::field::Stream &stream_) const { 25 | using namespace bitstream::output::meta::field::tag; 26 | using bitstream::output::meta::field::tag::Stream; 27 | const auto &stream = Stream(stream_); 28 | stream.tag(priority) << "priority"; 29 | } 30 | 31 | 32 | }} // namespace mpeg::isobase 33 | 34 | -------------------------------------------------------------------------------- /src/box/edit_list.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void EditListBox::parse_payload(Remainder left_payload) { 10 | if (version == 1) { 11 | V1::Parsed::Entries entries{*this, parser(), left_payload}; 12 | for(auto entry : entries) { 13 | Parser::Event::Header{parser(), entry}; 14 | } 15 | } else { // version == 0 16 | V0::Parsed::Entries entries{*this, parser(), left_payload}; 17 | for(auto entry : entries) { 18 | Parser::Event::Header{parser(), entry}; 19 | } 20 | } 21 | } 22 | 23 | void EditListBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 24 | FullBox::output_fields(stream_); 25 | using namespace bitstream::output::meta::field::tag; 26 | using bitstream::output::meta::field::tag::Stream; 27 | const auto &stream = Stream(stream_); 28 | stream.tag(entry_count) << "entry_count"; 29 | } 30 | 31 | 32 | template 33 | void EditListBox::Entry::output_fields(bitstream::output::meta::field::Stream &stream_) const { 34 | using namespace bitstream::output::meta::field::tag; 35 | using bitstream::output::meta::field::tag::Stream; 36 | const auto &stream = Stream(stream_); 37 | stream.tag(segment_duration) << "segment_duration"; 38 | stream.tag(media_time) << "media_time"; 39 | //stream.tag(media_rate_integer) << "media_rate_integer"; 40 | //stream.tag(media_rate_fraction) << "media_rate_fraction"; 41 | stream.tag(media_rate) << "media_rate" << Format("fixed-point"); 42 | } 43 | 44 | 45 | template struct EditListBox::Entry<0>; 46 | template struct EditListBox::Entry<1>; 47 | 48 | }} // namespace mpeg::isobase 49 | 50 | -------------------------------------------------------------------------------- /src/box/extended_language.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void ExtendedLanguageBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 10 | FullBox::output_fields(stream_); 11 | using namespace bitstream::output::meta::field::tag; 12 | using bitstream::output::meta::field::tag::Stream; 13 | const auto &stream = Stream(stream_); 14 | stream.tag(extended_language) << "extended_language"; 15 | } 16 | 17 | 18 | }} // namespace mpeg::isobase 19 | 20 | -------------------------------------------------------------------------------- /src/box/fd_item_information.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void FDItemInformationBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 10 | FullBox::output_fields(stream_); 11 | using namespace bitstream::output::meta::field::tag; 12 | using bitstream::output::meta::field::tag::Stream; 13 | const auto &stream = Stream(stream_); 14 | stream.tag(entry_count) << "entry_count"; 15 | } 16 | 17 | 18 | }} // namespace mpeg::isobase 19 | 20 | -------------------------------------------------------------------------------- /src/box/fd_session_group.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void FDSessionGroupBox::parse_payload(Remainder left_payload) { 10 | for(auto i = 0; i < num_session_groups; ++i) { 11 | { 12 | Group group{*this, parser()}; 13 | Parser::Event::Header{parser(), group}; 14 | Group::Parsed::Entries entries{group, parser(), left_payload, [](const auto &group) -> uint32_t { return group.entry_count; }}; 15 | for(auto entry : entries) { 16 | Parser::Event::Header{parser(), entry}; 17 | } 18 | } 19 | { 20 | Channel channel{*this, parser()}; 21 | Parser::Event::Header{parser(), channel}; 22 | Channel::Parsed::Entries entries{channel, parser(), left_payload, [](const auto &channel) -> uint32_t { return channel.num_channels_in_session_group; }}; 23 | for(auto entry : entries) { 24 | Parser::Event::Header{parser(), entry}; 25 | } 26 | } 27 | } 28 | } 29 | 30 | void FDSessionGroupBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 31 | Box::output_fields(stream_); 32 | using namespace bitstream::output::meta::field::tag; 33 | using bitstream::output::meta::field::tag::Stream; 34 | const auto &stream = Stream(stream_); 35 | stream.tag(num_session_groups) << "num_session_groups"; 36 | } 37 | 38 | 39 | void FDSessionGroupBox::Group::output_fields(bitstream::output::meta::field::Stream &stream_) const { 40 | using namespace bitstream::output::meta::field::tag; 41 | using bitstream::output::meta::field::tag::Stream; 42 | const auto &stream = Stream(stream_); 43 | stream.tag(entry_count) << "entry_count"; 44 | } 45 | 46 | void FDSessionGroupBox::Group::Entry::output_fields(bitstream::output::meta::field::Stream &stream_) const { 47 | using namespace bitstream::output::meta::field::tag; 48 | using bitstream::output::meta::field::tag::Stream; 49 | const auto &stream = Stream(stream_); 50 | stream.tag(group_ID) << "group_ID"; 51 | } 52 | 53 | void FDSessionGroupBox::Channel::output_fields(bitstream::output::meta::field::Stream &stream_) const { 54 | using namespace bitstream::output::meta::field::tag; 55 | using bitstream::output::meta::field::tag::Stream; 56 | const auto &stream = Stream(stream_); 57 | stream.tag(num_channels_in_session_group) << "num_channels_in_session_group"; 58 | } 59 | 60 | void FDSessionGroupBox::Channel::Entry::output_fields(bitstream::output::meta::field::Stream &stream_) const { 61 | using namespace bitstream::output::meta::field::tag; 62 | using bitstream::output::meta::field::tag::Stream; 63 | const auto &stream = Stream(stream_); 64 | stream.tag(hint_track_id) << "hint_track_id"; 65 | } 66 | 67 | 68 | }} // namespace mpeg::isobase 69 | 70 | -------------------------------------------------------------------------------- /src/box/fec_reservoir.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | 10 | 11 | }} // namespace mpeg::isobase 12 | 13 | -------------------------------------------------------------------------------- /src/box/file_partition.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void FilePartitionBox::parse_payload(Remainder left_payload) { 10 | Parsed::Entries entries{*this, parser(), left_payload, [](const auto &box) -> uint32_t { return box.entry_count(); }}; 11 | for(auto entry : entries) { 12 | Parser::Event::Header{parser(), entry}; 13 | } 14 | } 15 | 16 | void FilePartitionBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 17 | using namespace bitstream::output::meta::field::tag; 18 | using bitstream::output::meta::field::tag::Stream; 19 | const auto &stream = Stream(stream_); 20 | FullBox::output_fields(stream_); 21 | if (version == 0) { 22 | iiv0.output(stream_); 23 | } else { 24 | iiv1.output(stream_); 25 | } 26 | 27 | stream.tag(packet_payload_size) << "packet_payload_size"; 28 | stream.tag(reserved) << "reserved"; 29 | stream.tag(FEC_encoding_ID) << "FEC_encoding_ID"; 30 | stream.tag(FEC_instance_ID) << "FEC_instance_ID"; 31 | stream.tag(max_source_block_length) << "max_source_block_length"; 32 | stream.tag(encoding_symbol_length) << "encoding_symbol_length"; 33 | stream.tag(max_number_of_encoding_symbols) << "max_number_of_encoding_symbols"; 34 | 35 | if (version == 0) { 36 | v0.output(stream_); 37 | } else { 38 | v1.output(stream_); 39 | } 40 | } 41 | 42 | void FilePartitionBox::Entry::output_fields(bitstream::output::meta::field::Stream &stream_) const { 43 | using namespace bitstream::output::meta::field::tag; 44 | using bitstream::output::meta::field::tag::Stream; 45 | const auto &stream = Stream(stream_); 46 | stream.tag(block_count) << "block_count"; 47 | stream.tag(block_size) << "block_size"; 48 | } 49 | 50 | 51 | template 52 | void FilePartitionBox::ItemIDField::output(bitstream::output::meta::field::Stream &stream_) const { 53 | using namespace bitstream::output::meta::field::tag; 54 | using bitstream::output::meta::field::tag::Stream; 55 | const auto &stream = Stream(stream_); 56 | stream.tag(item_ID) << "item_ID"; 57 | } 58 | 59 | template struct FilePartitionBox::ItemIDField<0>; 60 | template struct FilePartitionBox::ItemIDField<1>; 61 | 62 | 63 | template 64 | void FilePartitionBox::EntryCountField::output(bitstream::output::meta::field::Stream &stream_) const { 65 | using namespace bitstream::output::meta::field::tag; 66 | using bitstream::output::meta::field::tag::Stream; 67 | const auto &stream = Stream(stream_); 68 | stream.tag(entry_count) << "entry_count"; 69 | } 70 | 71 | template struct FilePartitionBox::EntryCountField<0>; 72 | template struct FilePartitionBox::EntryCountField<1>; 73 | 74 | 75 | }} // namespace mpeg::isobase 76 | 77 | -------------------------------------------------------------------------------- /src/box/file_reservoir.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void FileReservoirBox::parse_payload(Remainder left_payload) { 10 | Parsed::Entries entries{*this, parser(), left_payload, [](const auto &box) -> uint32_t { return box.entry_count(); }}; 11 | for(auto entry : entries) { 12 | Parser::Event::Header{parser(), entry}; 13 | } 14 | } 15 | 16 | template 17 | void FileReservoirBox::Header::output(bitstream::output::meta::field::Stream &stream_) const { 18 | using namespace bitstream::output::meta::field::tag; 19 | using bitstream::output::meta::field::tag::Stream; 20 | const auto &stream = Stream(stream_); 21 | stream.tag(entry_count) << "entry_count"; 22 | } 23 | 24 | template struct FileReservoirBox::Header<0>; 25 | template struct FileReservoirBox::Header<1>; 26 | 27 | 28 | void FileReservoirBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 29 | FullBox::output_fields(stream_); 30 | if (version == 0) { 31 | v0.output(stream_); 32 | } else { 33 | v1.output(stream_); 34 | } 35 | } 36 | 37 | template 38 | void FileReservoirBox::Entry::Header::output(bitstream::output::meta::field::Stream &stream_) const { 39 | using namespace bitstream::output::meta::field::tag; 40 | using bitstream::output::meta::field::tag::Stream; 41 | const auto &stream = Stream(stream_); 42 | stream.tag(item_ID) << "item_ID"; 43 | stream.tag(symbol_count) << "symbol_count"; 44 | } 45 | 46 | template struct FileReservoirBox::Entry::Header<0>; 47 | template struct FileReservoirBox::Entry::Header<1>; 48 | 49 | 50 | void FileReservoirBox::Entry::output_fields(bitstream::output::meta::field::Stream &stream_) const { 51 | if (box.version == 0) { 52 | v0.output(stream_); 53 | } else { 54 | v1.output(stream_); 55 | } 56 | } 57 | 58 | 59 | }} // namespace mpeg::isobase 60 | 61 | -------------------------------------------------------------------------------- /src/box/file_type.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void FileTypeBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 10 | Box::output_fields(stream_); 11 | using namespace bitstream::output::meta::field::tag; 12 | using bitstream::output::meta::field::tag::Stream; 13 | const auto &stream = Stream(stream_); 14 | stream.tag(major_brand) << "major_brand" << Format("fourcc"); 15 | stream.tag(minor_version) << "minor_version"; 16 | stream.tag(compatible_brands) << "compatible_brands" << Format("fourcc", "array_item"); 17 | } 18 | 19 | 20 | }} // namespace mpeg::isobase 21 | 22 | -------------------------------------------------------------------------------- /src/box/full.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void FullBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 10 | Box::output_fields(stream_); 11 | using namespace bitstream::output::meta::field::tag; 12 | using bitstream::output::meta::field::tag::Stream; 13 | const auto &stream = Stream(stream_); 14 | stream.tag(version) << "version"; 15 | stream.tag(flags) << "flags"; 16 | } 17 | 18 | 19 | }} // namespace mpeg::isobase 20 | 21 | -------------------------------------------------------------------------------- /src/box/group_id_to_name.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void GroupIdToNameBox::parse_payload(Remainder left_payload) { 10 | Parsed::Entries entries{*this, parser(), left_payload}; 11 | for(auto entry : entries) { 12 | Parser::Event::Header{parser(), entry}; 13 | } 14 | } 15 | 16 | void GroupIdToNameBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 17 | FullBox::output_fields(stream_); 18 | using namespace bitstream::output::meta::field::tag; 19 | using bitstream::output::meta::field::tag::Stream; 20 | const auto &stream = Stream(stream_); 21 | stream.tag(entry_count) << "entry_count"; 22 | } 23 | 24 | 25 | void GroupIdToNameBox::Entry::output_fields(bitstream::output::meta::field::Stream &stream_) const { 26 | using namespace bitstream::output::meta::field::tag; 27 | using bitstream::output::meta::field::tag::Stream; 28 | const auto &stream = Stream(stream_); 29 | stream.tag(group_ID) << "group_ID"; 30 | stream.tag(group_name) << "group_name"; 31 | } 32 | 33 | 34 | }} // namespace mpeg::isobase 35 | 36 | -------------------------------------------------------------------------------- /src/box/handler.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | 10 | void HandlerBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 11 | FullBox::output_fields(stream_); 12 | using namespace bitstream::output::meta::field::tag; 13 | using bitstream::output::meta::field::tag::Stream; 14 | const auto &stream = Stream(stream_); 15 | stream.tag(pre_defined) << "pre_defined"; 16 | stream.tag(handler_type) << "handler_type" << Format("fourcc"); 17 | stream.tag(reserved) << "reserved"; 18 | stream.tag(name) << "name"; 19 | } 20 | 21 | 22 | }} // namespace mpeg::isobase 23 | 24 | -------------------------------------------------------------------------------- /src/box/hint_media_header.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | 10 | void HintMediaHeaderBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 11 | FullBox::output_fields(stream_); 12 | using namespace bitstream::output::meta::field::tag; 13 | using bitstream::output::meta::field::tag::Stream; 14 | const auto &stream = Stream(stream_); 15 | stream.tag(maxPDUsize) << "maxPDUsize"; 16 | stream.tag(avgPDUsize) << "avgPDUsize"; 17 | stream.tag(maxbitrate) << "maxbitrate"; 18 | stream.tag(avgbitrate) << "avgbitrate"; 19 | stream.tag(reserved) << "reserved"; 20 | } 21 | 22 | 23 | }} // namespace mpeg::isobase 24 | 25 | -------------------------------------------------------------------------------- /src/box/hint_sample_entry.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void HintSampleEntry::output_fields(bitstream::output::meta::field::Stream &stream_) const { 10 | Box::output_fields(stream_); 11 | using namespace bitstream::output::meta::field::tag; 12 | using bitstream::output::meta::field::tag::Stream; 13 | const auto &stream = Stream(stream_); 14 | stream.tag(data) << "data"; 15 | } 16 | 17 | 18 | }} // namespace mpeg::isobase 19 | 20 | -------------------------------------------------------------------------------- /src/box/ipmpcontrol.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | 10 | 11 | }} // namespace mpeg::isobase 12 | 13 | -------------------------------------------------------------------------------- /src/box/ipmpinfo.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | 10 | 11 | }} // namespace mpeg::isobase 12 | 13 | -------------------------------------------------------------------------------- /src/box/item_data.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void ItemDataBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 10 | Box::output_fields(stream_); 11 | using namespace bitstream::output::meta::field::tag; 12 | using bitstream::output::meta::field::tag::Stream; 13 | const auto &stream = Stream(stream_); 14 | stream.tag(data) << "data"; 15 | } 16 | 17 | 18 | }} // namespace mpeg::isobase 19 | 20 | -------------------------------------------------------------------------------- /src/box/item_info.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void ItemInfoBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 10 | FullBox::output_fields(stream_); 11 | using namespace bitstream::output::meta::field::tag; 12 | using bitstream::output::meta::field::tag::Stream; 13 | const auto &stream = Stream(stream_); 14 | if (version == 0) { 15 | stream.tag(entry_count16) << "entry_count"; 16 | } else { 17 | stream.tag(entry_count32) << "entry_count"; 18 | } 19 | } 20 | 21 | 22 | }} // namespace mpeg::isobase 23 | 24 | -------------------------------------------------------------------------------- /src/box/item_info_entry.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void ItemInfoEntry::output_fields(bitstream::output::meta::field::Stream &stream_) const { 10 | FullBox::output_fields(stream_); 11 | using namespace bitstream::output::meta::field::tag; 12 | using bitstream::output::meta::field::tag::Stream; 13 | const auto &stream = Stream(stream_); 14 | stream.tag(item_ID) << "item_ID"; 15 | stream.tag(item_protection_index) << "item_protection_index"; 16 | stream.tag(item_name) << "item_name"; 17 | stream.tag(content_type) << "content_type"; 18 | stream.tag(content_encoding) << "content_encoding"; 19 | } 20 | 21 | 22 | }} // namespace mpeg::isobase 23 | 24 | -------------------------------------------------------------------------------- /src/box/item_location.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | 10 | void ItemLocationBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 11 | FullBox::output_fields(stream_); 12 | using namespace bitstream::output::meta::field::tag; 13 | using bitstream::output::meta::field::tag::Stream; 14 | const auto &stream = Stream(stream_); 15 | stream.tag(item_count) << "item_count"; 16 | stream.tag(length_size) << "length_size"; 17 | stream.tag(base_offset_size) << "base_offset_size"; 18 | if (version == 1 || version == 2) { 19 | stream.tag(index_size) << "index_size"; 20 | } else { 21 | stream.tag(reserved) << "reserved"; 22 | } 23 | stream.tag(item_count) << "item_count"; 24 | } 25 | 26 | 27 | }} // namespace mpeg::isobase 28 | 29 | -------------------------------------------------------------------------------- /src/box/item_protection.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | 10 | void ItemProtectionBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 11 | FullBox::output_fields(stream_); 12 | using namespace bitstream::output::meta::field::tag; 13 | using bitstream::output::meta::field::tag::Stream; 14 | const auto &stream = Stream(stream_); 15 | stream.tag(protection_count) << "protection_count"; 16 | } 17 | 18 | 19 | }} // namespace mpeg::isobase 20 | 21 | -------------------------------------------------------------------------------- /src/box/item_reference.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | 10 | 11 | }} // namespace mpeg::isobase 12 | 13 | -------------------------------------------------------------------------------- /src/box/level_assignment.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void LevelAssignmentBox::parse_payload(Remainder left_payload) { 10 | Parsed::Entries entries{*this, parser(), left_payload, [](const auto &box) -> uint32_t { return box.level_count; }}; 11 | for(auto entry : entries) { 12 | Parser::Event::Header{parser(), entry}; 13 | } 14 | } 15 | 16 | void LevelAssignmentBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 17 | FullBox::output_fields(stream_); 18 | using namespace bitstream::output::meta::field::tag; 19 | using bitstream::output::meta::field::tag::Stream; 20 | const auto &stream = Stream(stream_); 21 | stream.tag(level_count) << "level_count"; 22 | } 23 | 24 | 25 | void LevelAssignmentBox::Entry::output_fields(bitstream::output::meta::field::Stream &stream_) const { 26 | using namespace bitstream::output::meta::field::tag; 27 | using bitstream::output::meta::field::tag::Stream; 28 | const auto &stream = Stream(stream_); 29 | stream.tag(track_id) << "track_id"; 30 | stream.tag(padding_flag) << "padding_flag"; 31 | stream.tag(assignment_type) << "assignment_type"; 32 | if (assignment_type == 0) { 33 | stream.tag(grouping_type) << "grouping_type"; 34 | } else if (assignment_type == 1) { 35 | stream.tag(grouping_type) << "grouping_type"; 36 | stream.tag(grouping_type_parameter) << "grouping_type_parameter"; 37 | } else if (assignment_type == 4) { 38 | stream.tag(sub_track_id) << "sub_track_id"; 39 | } 40 | } 41 | 42 | 43 | }} // namespace mpeg::isobase 44 | 45 | -------------------------------------------------------------------------------- /src/box/media_header.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void MediaHeaderBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 10 | FullBox::output_fields(stream_); 11 | using namespace bitstream::output::meta::field::tag; 12 | using bitstream::output::meta::field::tag::Stream; 13 | const auto &stream = Stream(stream_); 14 | if (version == 1) { 15 | v1.output(stream_); 16 | } else { 17 | v0.output(stream_); 18 | } 19 | stream.tag(pad) << "pad"; 20 | stream.tag(language) << "language" << Format("ISO-639-2/T language code"); 21 | stream.tag(pre_defined) << "pre_defined"; 22 | } 23 | 24 | template 25 | void MediaHeaderBox::Header::output(bitstream::output::meta::field::Stream &stream_) const { 26 | using namespace bitstream::output::meta::field::tag; 27 | using bitstream::output::meta::field::tag::Stream; 28 | const auto &stream = Stream(stream_); 29 | stream.tag(creation_time) << "creation_time" << Format("time since 1904"); 30 | stream.tag(modification_time) << "modification_time" << Format("time since 1904"); 31 | stream.tag(timescale) << "timescale"; 32 | stream.tag(duration) << "duration"; 33 | } 34 | 35 | template struct MediaHeaderBox::Header<0>; 36 | template struct MediaHeaderBox::Header<1>; 37 | 38 | 39 | }} // namespace mpeg::isobase 40 | 41 | -------------------------------------------------------------------------------- /src/box/meta.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | 10 | void MetaBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 11 | FullBox::output_fields(stream_); 12 | using namespace bitstream::output::meta::field::tag; 13 | using bitstream::output::meta::field::tag::Stream; 14 | const auto &stream = Stream(stream_); 15 | } 16 | 17 | 18 | }} // namespace mpeg::isobase 19 | 20 | -------------------------------------------------------------------------------- /src/box/metabox_relation.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void MetaboxRelationBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 10 | FullBox::output_fields(stream_); 11 | using namespace bitstream::output::meta::field::tag; 12 | using bitstream::output::meta::field::tag::Stream; 13 | const auto &stream = Stream(stream_); 14 | stream.tag(first_metabox_handler_type) << "first_metabox_handler_type"; 15 | stream.tag(second_metabox_handler_type) << "second_metabox_handler_type"; 16 | stream.tag(metabox_relation) << "metabox_relation"; 17 | } 18 | 19 | 20 | }} // namespace mpeg::isobase 21 | 22 | -------------------------------------------------------------------------------- /src/box/movie_extends_header.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void MovieExtendsHeaderBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 10 | FullBox::output_fields(stream_); 11 | using namespace bitstream::output::meta::field::tag; 12 | using bitstream::output::meta::field::tag::Stream; 13 | const auto &stream = Stream(stream_); 14 | if (version==1) { 15 | stream.tag(fragment_duration64) << "fragment_duration"; 16 | } else { 17 | stream.tag(fragment_duration32) << "fragment_duration"; 18 | } 19 | } 20 | 21 | 22 | }} // namespace mpeg::isobase 23 | 24 | -------------------------------------------------------------------------------- /src/box/movie_fragment_header.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void MovieFragmentHeaderBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 10 | FullBox::output_fields(stream_); 11 | using namespace bitstream::output::meta::field::tag; 12 | using bitstream::output::meta::field::tag::Stream; 13 | const auto &stream = Stream(stream_); 14 | stream.tag(sequence_number) << "sequence_number"; 15 | } 16 | 17 | 18 | }} // namespace mpeg::isobase 19 | 20 | -------------------------------------------------------------------------------- /src/box/movie_fragment_random_access_offset.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void MovieFragmentRandomAccessOffsetBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 10 | FullBox::output_fields(stream_); 11 | using namespace bitstream::output::meta::field::tag; 12 | using bitstream::output::meta::field::tag::Stream; 13 | const auto &stream = Stream(stream_); 14 | stream.tag(size) << "size"; 15 | } 16 | 17 | 18 | }} // namespace mpeg::isobase 19 | 20 | -------------------------------------------------------------------------------- /src/box/movie_header.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void MovieHeaderBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 10 | FullBox::output_fields(stream_); 11 | using namespace bitstream::output::meta::field::tag; 12 | using bitstream::output::meta::field::tag::Stream; 13 | const auto &stream = Stream(stream_); 14 | if (version == 1) { 15 | v1.output(stream_); 16 | } else { 17 | v0.output(stream_); 18 | } 19 | stream.tag(rate) << "rate" << Format("fixed-point"); 20 | stream.tag(volume) << "volume" << Format("fixed-point"); 21 | stream.tag(reserved) << "reserved"; 22 | stream.tag(reserved2) << "reserved"; 23 | stream.tag(matrix) << "matrix"; 24 | stream.tag(pre_defined) << "pre_defined"; 25 | stream.tag(next_track_ID) << "next_track_ID"; 26 | } 27 | 28 | 29 | template 30 | void MovieHeaderBox::Header::output(bitstream::output::meta::field::Stream &stream_) const { 31 | using namespace bitstream::output::meta::field::tag; 32 | using bitstream::output::meta::field::tag::Stream; 33 | const auto &stream = Stream(stream_); 34 | stream.tag(creation_time) << "creation_time" << Format("time since 1904"); 35 | stream.tag(modification_time) << "modification_time" << Format("time since 1904"); 36 | stream.tag(timescale) << "timescale"; 37 | stream.tag(duration) << "duration"; 38 | } 39 | 40 | template struct MovieHeaderBox::Header<0>; 41 | template struct MovieHeaderBox::Header<1>; 42 | 43 | 44 | }} // namespace mpeg::isobase 45 | 46 | -------------------------------------------------------------------------------- /src/box/null_media_header.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | 10 | 11 | }} // namespace mpeg::isobase 12 | 13 | -------------------------------------------------------------------------------- /src/box/original_format.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | 10 | void OriginalFormatBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 11 | Box::output_fields(stream_); 12 | using namespace bitstream::output::meta::field::tag; 13 | using bitstream::output::meta::field::tag::Stream; 14 | const auto &stream = Stream(stream_); 15 | stream.tag(data_format) << "data_format"; 16 | } 17 | 18 | 19 | }} // namespace mpeg::isobase 20 | 21 | -------------------------------------------------------------------------------- /src/box/padding_bits.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void PaddingBitsBox::parse_payload(Remainder left_payload) { 10 | Parsed::Entries entries{*this, parser(), left_payload, [](const auto &box) -> uint32_t { return box.sample_count; }}; 11 | for(auto entry : entries) { 12 | Parser::Event::Header{parser(), entry}; 13 | } 14 | } 15 | 16 | void PaddingBitsBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 17 | FullBox::output_fields(stream_); 18 | using namespace bitstream::output::meta::field::tag; 19 | using bitstream::output::meta::field::tag::Stream; 20 | const auto &stream = Stream(stream_); 21 | stream.tag(sample_count) << "sample_count"; 22 | } 23 | 24 | 25 | void PaddingBitsBox::Entry::output_fields(bitstream::output::meta::field::Stream &stream_) const { 26 | using namespace bitstream::output::meta::field::tag; 27 | using bitstream::output::meta::field::tag::Stream; 28 | const auto &stream = Stream(stream_); 29 | stream.tag(reserved1) << "reserved"; 30 | stream.tag(pad1) << "pad1"; 31 | stream.tag(reserved2) << "reserved"; 32 | stream.tag(pad2) << "pad2"; 33 | } 34 | 35 | 36 | }} // namespace mpeg::isobase 37 | 38 | -------------------------------------------------------------------------------- /src/box/partition_entry.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | 10 | 11 | }} // namespace mpeg::isobase 12 | 13 | -------------------------------------------------------------------------------- /src/box/primary_item.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void PrimaryItemBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 10 | FullBox::output_fields(stream_); 11 | if (version == 0) { 12 | v0.output(stream_); 13 | } else { 14 | v1.output(stream_); 15 | } 16 | } 17 | 18 | template 19 | void PrimaryItemBox::Header::output(bitstream::output::meta::field::Stream &stream_) const { 20 | using namespace bitstream::output::meta::field::tag; 21 | using bitstream::output::meta::field::tag::Stream; 22 | const auto &stream = Stream(stream_); 23 | stream.tag(item_ID) << "item_ID"; 24 | } 25 | 26 | template struct PrimaryItemBox::Header<0>; 27 | template struct PrimaryItemBox::Header<1>; 28 | 29 | 30 | }} // namespace mpeg::isobase 31 | 32 | -------------------------------------------------------------------------------- /src/box/producer_reference_time.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void ProducerReferenceTimeBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 10 | FullBox::output_fields(stream_); 11 | using namespace bitstream::output::meta::field::tag; 12 | using bitstream::output::meta::field::tag::Stream; 13 | const auto &stream = Stream(stream_); 14 | stream.tag(reference_track_ID) << "reference_track_ID"; 15 | stream.tag(ntp_timestamp) << "ntp_timestamp"; 16 | if (version == 0) { 17 | v0.output(stream_); 18 | } else { 19 | v1.output(stream_); 20 | } 21 | } 22 | 23 | 24 | template 25 | void ProducerReferenceTimeBox::MediaTime::output(bitstream::output::meta::field::Stream &stream_) const { 26 | using namespace bitstream::output::meta::field::tag; 27 | using bitstream::output::meta::field::tag::Stream; 28 | const auto &stream = Stream(stream_); 29 | stream.tag(media_time) << "media_time"; 30 | } 31 | 32 | template struct ProducerReferenceTimeBox::MediaTime<0>; 33 | template struct ProducerReferenceTimeBox::MediaTime<1>; 34 | 35 | }} // namespace mpeg::isobase 36 | 37 | -------------------------------------------------------------------------------- /src/box/progressive_download_info.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void ProgressiveDownloadInfoBox::parse_payload(Remainder left_payload) { 10 | Parsed::Entries entries{*this, parser(), left_payload, [](const auto &box) -> uint32_t { return box.entries(); }}; 11 | for(auto entry : entries) { 12 | Parser::Event::Header{parser(), entry}; 13 | } 14 | } 15 | 16 | 17 | void ProgressiveDownloadInfoBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 18 | FullBox::output_fields(stream_); 19 | using namespace bitstream::output::meta::field::tag; 20 | using bitstream::output::meta::field::tag::Stream; 21 | const auto &stream = Stream(stream_); 22 | } 23 | 24 | 25 | void ProgressiveDownloadInfoBox::Entry::output_fields(bitstream::output::meta::field::Stream &stream_) const { 26 | using namespace bitstream::output::meta::field::tag; 27 | using bitstream::output::meta::field::tag::Stream; 28 | const auto &stream = Stream(stream_); 29 | stream.tag(rate) << "rate"; 30 | stream.tag(initial_delay) << "initial_delay"; 31 | } 32 | 33 | }} // namespace mpeg::isobase 34 | 35 | -------------------------------------------------------------------------------- /src/box/protection_scheme_info.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | 10 | 11 | }} // namespace mpeg::isobase 12 | 13 | -------------------------------------------------------------------------------- /src/box/sample_auxiliary_information_sizes.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void SampleAuxiliaryInformationSizesBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 10 | FullBox::output_fields(stream_); 11 | using namespace bitstream::output::meta::field::tag; 12 | using bitstream::output::meta::field::tag::Stream; 13 | const auto &stream = Stream(stream_); 14 | if (flags & 1) { 15 | stream.tag(aux_info_type) << "aux_info_type"; 16 | stream.tag(aux_info_type_parameter) << "aux_info_type_parameter"; 17 | } 18 | stream.tag(default_sample_info_size) << "default_sample_info_size"; 19 | stream.tag(sample_count) << "sample_count"; 20 | if (default_sample_info_size == 0) { 21 | stream.tag(sample_info_size) << "sample_info_size"; 22 | } 23 | } 24 | 25 | 26 | }} // namespace mpeg::isobase 27 | 28 | -------------------------------------------------------------------------------- /src/box/sample_dependency_type.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void SampleDependencyTypeBox::parse_payload(Remainder left_payload) { 10 | Parsed::Entries entries{*this, parser(), left_payload, [](const auto &box) -> uint32_t { return box.entries(); }}; 11 | for(auto entry : entries) { 12 | Parser::Event::Header{parser(), entry}; 13 | } 14 | } 15 | 16 | void SampleDependencyTypeBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 17 | FullBox::output_fields(stream_); 18 | using namespace bitstream::output::meta::field::tag; 19 | using bitstream::output::meta::field::tag::Stream; 20 | const auto &stream = Stream(stream_); 21 | } 22 | 23 | 24 | void SampleDependencyTypeBox::Entry::output_fields(bitstream::output::meta::field::Stream &stream_) const { 25 | using namespace bitstream::output::meta::field::tag; 26 | using bitstream::output::meta::field::tag::Stream; 27 | const auto &stream = Stream(stream_); 28 | stream.tag(is_leading) << "is_leading"; 29 | stream.tag(sample_depends_on) << "sample_depends_on"; 30 | stream.tag(sample_is_depended_on) << "sample_is_depended_on"; 31 | stream.tag(sample_has_redundancy) << "sample_has_redundancy"; 32 | } 33 | 34 | 35 | }} // namespace mpeg::isobase 36 | 37 | -------------------------------------------------------------------------------- /src/box/sample_description.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | 11 | namespace mpeg { 12 | namespace isobase { 13 | 14 | 15 | struct SampleDescriptions: Boxes { 16 | SampleDescriptions() { 17 | add(); 18 | add(); 19 | add(); 20 | } 21 | 22 | } static sample_descriptions; 23 | 24 | static const Box::Desc sample_entry = Box::Desc::for_box(); 25 | 26 | 27 | void SampleDescriptionBox::parse_payload(Remainder left) { 28 | const auto &default_desc = sample_descriptions.get(parser().handler_type, sample_entry); 29 | parser().parse_boxes(left, default_desc); 30 | } 31 | 32 | void SampleDescriptionBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 33 | FullBox::output_fields(stream_); 34 | using namespace bitstream::output::meta::field::tag; 35 | using bitstream::output::meta::field::tag::Stream; 36 | const auto &stream = Stream(stream_); 37 | stream.tag(entry_count) << "entry_count"; 38 | } 39 | 40 | }} // namespace mpeg::isobase 41 | 42 | -------------------------------------------------------------------------------- /src/box/sample_entry.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void SampleEntry::output_fields(bitstream::output::meta::field::Stream &stream_) const { 10 | Box::output_fields(stream_); 11 | using namespace bitstream::output::meta::field::tag; 12 | using bitstream::output::meta::field::tag::Stream; 13 | const auto &stream = Stream(stream_); 14 | stream.tag(reserved) << "reserved"; 15 | stream.tag(data_reference_index) << "data_reference_index"; 16 | } 17 | 18 | 19 | }} // namespace mpeg::isobase 20 | 21 | -------------------------------------------------------------------------------- /src/box/sample_group_description.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void SampleGroupDescriptionBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 10 | FullBox::output_fields(stream_); 11 | using namespace bitstream::output::meta::field::tag; 12 | using bitstream::output::meta::field::tag::Stream; 13 | const auto &stream = Stream(stream_); 14 | stream.tag(grouping_type) << "grouping_type"; 15 | stream.tag(entry_count) << "entry_count"; 16 | } 17 | 18 | 19 | }} // namespace mpeg::isobase 20 | 21 | -------------------------------------------------------------------------------- /src/box/sample_scale.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void SampleScaleBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 10 | FullBox::output_fields(stream_); 11 | using namespace bitstream::output::meta::field::tag; 12 | using bitstream::output::meta::field::tag::Stream; 13 | const auto &stream = Stream(stream_); 14 | stream.tag(reserved) << "reserved"; 15 | stream.tag(constraint_flag) << "constraint_flag"; 16 | stream.tag(scale_method) << "scale_method"; 17 | stream.tag(display_center_x) << "display_center_x"; 18 | stream.tag(display_center_y) << "display_center_y"; 19 | } 20 | 21 | 22 | }} // namespace mpeg::isobase 23 | 24 | -------------------------------------------------------------------------------- /src/box/sample_size.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void SampleSizeBox::parse_payload(Remainder left_payload) { 10 | Parsed::Entries entries{*this, parser(), left_payload, [](const auto &box) -> uint32_t { return box.sample_count; }}; 11 | for(auto entry : entries) { 12 | Parser::Event::Header{parser(), entry}; 13 | } 14 | } 15 | 16 | void SampleSizeBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 17 | FullBox::output_fields(stream_); 18 | using namespace bitstream::output::meta::field::tag; 19 | using bitstream::output::meta::field::tag::Stream; 20 | const auto &stream = Stream(stream_); 21 | stream.tag(sample_size) << "sample_size"; 22 | stream.tag(sample_count) << "sample_count"; 23 | } 24 | 25 | 26 | void SampleSizeBox::Entry::output_fields(bitstream::output::meta::field::Stream &stream_) const { 27 | using namespace bitstream::output::meta::field::tag; 28 | using bitstream::output::meta::field::tag::Stream; 29 | const auto &stream = Stream(stream_); 30 | stream.tag(entry_size) << "entry_size"; 31 | } 32 | 33 | 34 | }} // namespace mpeg::isobase 35 | 36 | -------------------------------------------------------------------------------- /src/box/sample_to_chunk.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void SampleToChunkBox::parse_payload(Remainder left_payload) { 10 | Parsed::Entries entries{*this, parser(), left_payload}; 11 | for(auto entry : entries) { 12 | Parser::Event::Header{parser(), entry}; 13 | } 14 | } 15 | 16 | void SampleToChunkBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 17 | FullBox::output_fields(stream_); 18 | using namespace bitstream::output::meta::field::tag; 19 | using bitstream::output::meta::field::tag::Stream; 20 | const auto &stream = Stream(stream_); 21 | stream.tag(entry_count) << "entry_count"; 22 | } 23 | 24 | 25 | void SampleToChunkBox::Entry::output_fields(bitstream::output::meta::field::Stream &stream_) const { 26 | using namespace bitstream::output::meta::field::tag; 27 | using bitstream::output::meta::field::tag::Stream; 28 | const auto &stream = Stream(stream_); 29 | stream.tag(first_chunk) << "first_chunk"; 30 | stream.tag(samples_per_chunk) << "samples_per_chunk"; 31 | stream.tag(sample_description_index) << "sample_description_index"; 32 | } 33 | 34 | 35 | }} // namespace mpeg::isobase 36 | 37 | -------------------------------------------------------------------------------- /src/box/sample_to_group.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void SampleToGroupBox::parse_payload(Remainder left_payload) { 10 | Parsed::Entries entries{*this, parser(), left_payload}; 11 | for(auto entry : entries) { 12 | Parser::Event::Header{parser(), entry}; 13 | } 14 | } 15 | 16 | void SampleToGroupBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 17 | FullBox::output_fields(stream_); 18 | using namespace bitstream::output::meta::field::tag; 19 | using bitstream::output::meta::field::tag::Stream; 20 | const auto &stream = Stream(stream_); 21 | stream.tag(entry_count) << "entry_count"; 22 | } 23 | 24 | 25 | void SampleToGroupBox::Entry::output_fields(bitstream::output::meta::field::Stream &stream_) const { 26 | using namespace bitstream::output::meta::field::tag; 27 | using bitstream::output::meta::field::tag::Stream; 28 | const auto &stream = Stream(stream_); 29 | stream.tag(sample_count) << "sample_count"; 30 | stream.tag(group_description_index) << "group_description_index"; 31 | } 32 | 33 | 34 | }} // namespace mpeg::isobase 35 | 36 | -------------------------------------------------------------------------------- /src/box/scheme_information.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | 10 | 11 | }} // namespace mpeg::isobase 12 | 13 | -------------------------------------------------------------------------------- /src/box/scheme_type.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void SchemeTypeBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 10 | FullBox::output_fields(stream_); 11 | using namespace bitstream::output::meta::field::tag; 12 | using bitstream::output::meta::field::tag::Stream; 13 | const auto &stream = Stream(stream_); 14 | stream.tag(scheme_type) << "scheme_type" << Format("fourcc"); 15 | stream.tag(scheme_version) << "scheme_version"; 16 | stream.tag(scheme_uri) << "scheme_uri"; 17 | if (flags & 0x000001) { 18 | stream.tag(scheme_version) << "scheme_version"; 19 | } 20 | } 21 | 22 | 23 | }} // namespace mpeg::isobase 24 | 25 | -------------------------------------------------------------------------------- /src/box/segment_index.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void SegmentIndexBox::parse_payload(Remainder left_payload) { 10 | Parsed::Entries entries{*this, parser(), left_payload, [](const auto &box) -> uint32_t { return box.reference_count; }}; 11 | for(auto entry : entries) { 12 | Parser::Event::Header{parser(), entry}; 13 | } 14 | } 15 | 16 | template 17 | void SegmentIndexBox::Header::output(bitstream::output::meta::field::Stream &stream_) const { 18 | using namespace bitstream::output::meta::field::tag; 19 | using bitstream::output::meta::field::tag::Stream; 20 | const auto &stream = Stream(stream_); 21 | stream.tag(earliest_presentation_time) << "earliest_presentation_time"; 22 | stream.tag(first_offset) << "first_offset"; 23 | } 24 | 25 | template struct SegmentIndexBox::Header<0>; 26 | template struct SegmentIndexBox::Header<1>; 27 | 28 | 29 | void SegmentIndexBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 30 | using namespace bitstream::output::meta::field::tag; 31 | using bitstream::output::meta::field::tag::Stream; 32 | const auto &stream = Stream(stream_); 33 | FullBox::output_fields(stream_); 34 | stream.tag(reference_ID) << "reference_ID"; 35 | stream.tag(timescale) << "timescale"; 36 | if (version == 0) { 37 | v0.output(stream_); 38 | } else { 39 | v1.output(stream_); 40 | } 41 | stream.tag(reserved) << "reserved"; 42 | stream.tag(reference_count) << "reference_count"; 43 | } 44 | 45 | 46 | void SegmentIndexBox::Entry::output_fields(bitstream::output::meta::field::Stream &stream_) const { 47 | using namespace bitstream::output::meta::field::tag; 48 | using bitstream::output::meta::field::tag::Stream; 49 | const auto &stream = Stream(stream_); 50 | stream.tag(reference_type) << "reference_type"; 51 | stream.tag(referenced_size) << "referenced_size"; 52 | stream.tag(subsegment_duration) << "subsegment_duration"; 53 | stream.tag(starts_with_SAP) << "starts_with_SAP"; 54 | stream.tag(SAP_type) << "SAP_type"; 55 | stream.tag(SAP_delta_time) << "SAP_delta_time"; 56 | } 57 | 58 | 59 | }} // namespace mpeg::isobase 60 | 61 | -------------------------------------------------------------------------------- /src/box/segment_type.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | 10 | 11 | }} // namespace mpeg::isobase 12 | 13 | -------------------------------------------------------------------------------- /src/box/shadow_sync_sample.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void ShadowSyncSampleBox::parse_payload(Remainder left_payload) { 10 | Parsed::Entries entries{*this, parser(), left_payload}; 11 | for(auto entry : entries) { 12 | Parser::Event::Header{parser(), entry}; 13 | } 14 | } 15 | 16 | void ShadowSyncSampleBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 17 | FullBox::output_fields(stream_); 18 | using namespace bitstream::output::meta::field::tag; 19 | using bitstream::output::meta::field::tag::Stream; 20 | const auto &stream = Stream(stream_); 21 | stream.tag(entry_count) << "entry_count"; 22 | } 23 | 24 | 25 | void ShadowSyncSampleBox::Entry::output_fields(bitstream::output::meta::field::Stream &stream_) const { 26 | using namespace bitstream::output::meta::field::tag; 27 | using bitstream::output::meta::field::tag::Stream; 28 | const auto &stream = Stream(stream_); 29 | stream.tag(shadowed_sample_number) << "shadowed_sample_number"; 30 | stream.tag(sync_sample_number) << "sync_sample_number"; 31 | } 32 | 33 | 34 | }} // namespace mpeg::isobase 35 | 36 | -------------------------------------------------------------------------------- /src/box/sound_media_header.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void SoundMediaHeaderBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 10 | FullBox::output_fields(stream_); 11 | using namespace bitstream::output::meta::field::tag; 12 | using bitstream::output::meta::field::tag::Stream; 13 | const auto &stream = Stream(stream_); 14 | stream.tag(balance) << "balance" << Format("fixed-point"); 15 | stream.tag(reserved) << "reserved"; 16 | } 17 | 18 | 19 | }} // namespace mpeg::isobase 20 | 21 | -------------------------------------------------------------------------------- /src/box/sub_track.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | 10 | 11 | }} // namespace mpeg::isobase 12 | 13 | -------------------------------------------------------------------------------- /src/box/sub_track_information.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void SubTrackInformation::output_fields(bitstream::output::meta::field::Stream &stream_) const { 10 | FullBox::output_fields(stream_); 11 | using namespace bitstream::output::meta::field::tag; 12 | using bitstream::output::meta::field::tag::Stream; 13 | const auto &stream = Stream(stream_); 14 | stream.tag(switch_group) << "switch_group"; 15 | stream.tag(alternate_group) << "alternate_group"; 16 | stream.tag(sub_track_ID) << "sub_track_ID"; 17 | stream.tag(attribute_list) << "attribute_list"; 18 | } 19 | 20 | 21 | }} // namespace mpeg::isobase 22 | 23 | -------------------------------------------------------------------------------- /src/box/subsample_information.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void SubSampleInformationBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 10 | FullBox::output_fields(stream_); 11 | using namespace bitstream::output::meta::field::tag; 12 | using bitstream::output::meta::field::tag::Stream; 13 | const auto &stream = Stream(stream_); 14 | stream.tag(entry_count) << "entry_count"; 15 | } 16 | 17 | 18 | }} // namespace mpeg::isobase 19 | 20 | -------------------------------------------------------------------------------- /src/box/subsegment_index.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void SubsegmentIndexBox::parse_payload(Remainder left_payload) { 10 | Parsed::Subsegments subsegments{*this, parser(), left_payload, [](const auto &box) -> uint32_t { return box.subsegment_count; }}; 11 | for(auto subsegment : subsegments) { 12 | Parser::Event::Header{parser(), subsegment}; 13 | Subsegment::Parsed::Ranges ranges{subsegment, parser(), left_payload, [](const auto &subsegment) -> uint32_t { return subsegment.range_count; }}; 14 | for(auto range : ranges) { 15 | Parser::Event::Header{parser(), range}; 16 | } 17 | } 18 | } 19 | 20 | void SubsegmentIndexBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 21 | FullBox::output_fields(stream_); 22 | using namespace bitstream::output::meta::field::tag; 23 | using bitstream::output::meta::field::tag::Stream; 24 | const auto &stream = Stream(stream_); 25 | stream.tag(subsegment_count) << "subsegment_count"; 26 | } 27 | 28 | 29 | void SubsegmentIndexBox::Subsegment::output_fields(bitstream::output::meta::field::Stream &stream_) const { 30 | using namespace bitstream::output::meta::field::tag; 31 | using bitstream::output::meta::field::tag::Stream; 32 | const auto &stream = Stream(stream_); 33 | stream.tag(range_count) << "range_count"; 34 | } 35 | 36 | void SubsegmentIndexBox::Subsegment::Range::output_fields(bitstream::output::meta::field::Stream &stream_) const { 37 | using namespace bitstream::output::meta::field::tag; 38 | using bitstream::output::meta::field::tag::Stream; 39 | const auto &stream = Stream(stream_); 40 | stream.tag(level) << "level"; 41 | stream.tag(range_size) << "range_size"; 42 | } 43 | 44 | 45 | }} // namespace mpeg::isobase 46 | 47 | -------------------------------------------------------------------------------- /src/box/subtitle_media_header.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | 10 | 11 | }} // namespace mpeg::isobase 12 | 13 | -------------------------------------------------------------------------------- /src/box/sync_sample.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void SyncSampleBox::parse_payload(Remainder left_payload) { 10 | Parsed::Entries entries{*this, parser(), left_payload}; 11 | for(auto entry : entries) { 12 | Parser::Event::Header{parser(), entry}; 13 | } 14 | } 15 | 16 | void SyncSampleBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 17 | FullBox::output_fields(stream_); 18 | using namespace bitstream::output::meta::field::tag; 19 | using bitstream::output::meta::field::tag::Stream; 20 | const auto &stream = Stream(stream_); 21 | stream.tag(entry_count) << "entry_count"; 22 | } 23 | 24 | 25 | void SyncSampleBox::Entry::output_fields(bitstream::output::meta::field::Stream &stream_) const { 26 | using namespace bitstream::output::meta::field::tag; 27 | using bitstream::output::meta::field::tag::Stream; 28 | const auto &stream = Stream(stream_); 29 | stream.tag(sample_number) << "sample_number"; 30 | } 31 | 32 | 33 | }} // namespace mpeg::isobase 34 | 35 | -------------------------------------------------------------------------------- /src/box/time_to_sample.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void TimeToSampleBox::parse_payload(Remainder left_payload) { 10 | Parsed::Entries entries{*this, parser(), left_payload}; 11 | for(auto entry : entries) { 12 | Parser::Event::Header{parser(), entry}; 13 | } 14 | } 15 | 16 | void TimeToSampleBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 17 | FullBox::output_fields(stream_); 18 | using namespace bitstream::output::meta::field::tag; 19 | using bitstream::output::meta::field::tag::Stream; 20 | const auto &stream = Stream(stream_); 21 | stream.tag(entry_count) << "entry_count"; 22 | } 23 | 24 | 25 | void TimeToSampleBox::Entry::output_fields(bitstream::output::meta::field::Stream &stream_) const { 26 | using namespace bitstream::output::meta::field::tag; 27 | using bitstream::output::meta::field::tag::Stream; 28 | const auto &stream = Stream(stream_); 29 | stream.tag(sample_count) << "sample_count"; 30 | stream.tag(sample_delta) << "sample_delta"; 31 | } 32 | 33 | 34 | }} // namespace mpeg::isobase 35 | 36 | -------------------------------------------------------------------------------- /src/box/track_extends.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void TrackExtendsBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 10 | FullBox::output_fields(stream_); 11 | using namespace bitstream::output::meta::field::tag; 12 | using bitstream::output::meta::field::tag::Stream; 13 | const auto &stream = Stream(stream_); 14 | stream.tag(track_ID) << "track_ID"; 15 | stream.tag(default_sample_description_index) << "default_sample_description_index"; 16 | stream.tag(default_sample_duration) << "default_sample_duration"; 17 | stream.tag(default_sample_size) << "default_sample_size"; 18 | stream.tag(default_sample_flags) << "default_sample_flags"; 19 | } 20 | 21 | 22 | }} // namespace mpeg::isobase 23 | 24 | -------------------------------------------------------------------------------- /src/box/track_fragment_base_media_decode_time.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | template 10 | void TrackFragmentBaseMediaDecodeTimeBox::Header::output(bitstream::output::meta::field::Stream &stream_) const { 11 | using namespace bitstream::output::meta::field::tag; 12 | using bitstream::output::meta::field::tag::Stream; 13 | const auto &stream = Stream(stream_); 14 | stream.tag(baseMediaDecodeTime) << "baseMediaDecodeTime"; 15 | } 16 | 17 | template struct TrackFragmentBaseMediaDecodeTimeBox::Header<0>; 18 | template struct TrackFragmentBaseMediaDecodeTimeBox::Header<1>; 19 | 20 | 21 | void TrackFragmentBaseMediaDecodeTimeBox::output_fields(bitstream::output::meta::field::Stream &stream) const { 22 | FullBox::output_fields(stream); 23 | if (version == 1) { 24 | v1.output(stream); 25 | } else { 26 | v0.output(stream); 27 | } 28 | } 29 | 30 | }} // namespace mpeg::isobase 31 | 32 | -------------------------------------------------------------------------------- /src/box/track_fragment_header.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void TrackFragmentHeaderBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 10 | FullBox::output_fields(stream_); 11 | using namespace bitstream::output::meta::field::tag; 12 | using bitstream::output::meta::field::tag::Stream; 13 | const auto &stream = Stream(stream_); 14 | stream.tag(track_ID) << "track_ID"; 15 | if (flags & 0x000001) { 16 | stream.tag(base_data_offset) << "base_data_offset"; 17 | } 18 | if (flags & 0x000002) { 19 | stream.tag(default_sample_description_index) << "default_sample_description_index"; 20 | } 21 | if (flags & 0x000008) { 22 | stream.tag(default_sample_duration) << "default_sample_duration"; 23 | } 24 | if (flags & 0x000010) { 25 | stream.tag(default_sample_size) << "default_sample_size"; 26 | } 27 | if (flags & 0x000020) { 28 | stream.tag(default_sample_flags) << "default_sample_flags"; 29 | } 30 | } 31 | 32 | 33 | }} // namespace mpeg::isobase 34 | 35 | -------------------------------------------------------------------------------- /src/box/track_fragment_random_access.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void TrackFragmentRandomAccessBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 10 | FullBox::output_fields(stream_); 11 | using namespace bitstream::output::meta::field::tag; 12 | using bitstream::output::meta::field::tag::Stream; 13 | const auto &stream = Stream(stream_); 14 | stream.tag(track_ID) << "track_ID"; 15 | stream.tag(reserved) << "reserved"; 16 | stream.tag(length_size_of_traf_num) << "length_size_of_traf_num"; 17 | stream.tag(length_size_of_trun_num) << "length_size_of_trun_num"; 18 | stream.tag(length_size_of_sample_num) << "length_size_of_sample_num"; 19 | stream.tag(number_of_entry) << "number_of_entry"; 20 | } 21 | 22 | 23 | }} // namespace mpeg::isobase 24 | 25 | -------------------------------------------------------------------------------- /src/box/track_header.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void TrackHeaderBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 10 | FullBox::output_fields(stream_); 11 | using namespace bitstream::output::meta::field::tag; 12 | using bitstream::output::meta::field::tag::Stream; 13 | const auto &stream = Stream(stream_); 14 | if (version == 1) { 15 | v1.output(stream_); 16 | } else { 17 | v0.output(stream_); 18 | } 19 | stream.tag(reserved2) << "reserved"; 20 | stream.tag(layer) << "layer"; 21 | stream.tag(alternate_group) << "alternate_group"; 22 | stream.tag(volume) << "volume" << Format("fixed-point"); 23 | stream.tag(reserved3) << "reserved"; 24 | stream.tag(matrix) << "matrix"; 25 | stream.tag(width) << "width" << Format("fixed-point"); 26 | stream.tag(height) << "height" << Format("fixed-point"); 27 | } 28 | 29 | 30 | template 31 | void TrackHeaderBox::Header::output(bitstream::output::meta::field::Stream &stream_) const { 32 | using namespace bitstream::output::meta::field::tag; 33 | using bitstream::output::meta::field::tag::Stream; 34 | const auto &stream = Stream(stream_); 35 | stream.tag(creation_time) << "creation_time" << Format("time since 1904"); 36 | stream.tag(modification_time) << "modification_time" << Format("time since 1904"); 37 | stream.tag(track_ID) << "track_ID"; 38 | stream.tag(reserved) << "reserved"; 39 | stream.tag(duration) << "duration"; 40 | } 41 | 42 | template struct TrackHeaderBox::Header<0>; 43 | template struct TrackHeaderBox::Header<1>; 44 | 45 | 46 | }} // namespace mpeg::isobase 47 | 48 | -------------------------------------------------------------------------------- /src/box/track_reference.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | 7 | namespace mpeg { 8 | namespace isobase { 9 | 10 | extern template struct TrackReferenceTypeBox<'hint'>; 11 | extern template struct TrackReferenceTypeBox<'cdsc'>; 12 | extern template struct TrackReferenceTypeBox<'font'>; 13 | extern template struct TrackReferenceTypeBox<'hind'>; 14 | extern template struct TrackReferenceTypeBox<'vdep'>; 15 | extern template struct TrackReferenceTypeBox<'vplx'>; 16 | extern template struct TrackReferenceTypeBox<'subt'>; 17 | 18 | 19 | struct References: Boxes { 20 | 21 | References() { 22 | add>(); 23 | add>(); 24 | add>(); 25 | add>(); 26 | add>(); 27 | add>(); 28 | add>(); 29 | } 30 | 31 | } static references; 32 | 33 | void TrackReferenceBox::parse_payload(Remainder left) { 34 | parser().parse_boxes(left, references); 35 | } 36 | 37 | }} // namespace mpeg::isobase 38 | 39 | // TODO: PROCESS PAYLOAD (handle particular box types) 40 | 41 | -------------------------------------------------------------------------------- /src/box/track_reference_type.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | template 10 | void TrackReferenceTypeBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 11 | Box::output_fields(stream_); 12 | bitstream::output::meta::field::tag::Stream(stream_) 13 | .tag(track_IDs) << "track_IDs"; 14 | } 15 | 16 | template struct TrackReferenceTypeBox<'hint'>; 17 | template struct TrackReferenceTypeBox<'cdsc'>; 18 | template struct TrackReferenceTypeBox<'font'>; 19 | template struct TrackReferenceTypeBox<'hind'>; 20 | template struct TrackReferenceTypeBox<'vdep'>; 21 | template struct TrackReferenceTypeBox<'vplx'>; 22 | template struct TrackReferenceTypeBox<'subt'>; 23 | 24 | 25 | }} // namespace mpeg::isobase 26 | 27 | -------------------------------------------------------------------------------- /src/box/track_run.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void TrackRunBox::parse_payload(Remainder left_payload) { 10 | if (version == 0) { 11 | V0::Parsed::Entries entries{*this, parser(), left_payload, [](const auto &box) -> uint32_t { return box.sample_count; }}; 12 | for(auto entry : entries) { 13 | Parser::Event::Header{parser(), entry}; 14 | } 15 | } else if (version == 1) { 16 | V1::Parsed::Entries entries{*this, parser(), left_payload, [](const auto &box) -> uint32_t { return box.sample_count; }}; 17 | for(auto entry : entries) { 18 | Parser::Event::Header{parser(), entry}; 19 | } 20 | } 21 | } 22 | 23 | void TrackRunBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 24 | FullBox::output_fields(stream_); 25 | using namespace bitstream::output::meta::field::tag; 26 | using bitstream::output::meta::field::tag::Stream; 27 | const auto &stream = Stream(stream_); 28 | stream.tag(sample_count) << "sample_count"; 29 | if (flags & 0x000001) { 30 | stream.tag(data_offset) << "data_offset"; 31 | } 32 | if (flags & 0x000004) { 33 | stream.tag(first_sample_flags) << "first_sample_flags"; 34 | } 35 | } 36 | 37 | 38 | template 39 | void TrackRunBox::Entry::output_fields(bitstream::output::meta::field::Stream &stream_) const { 40 | using namespace bitstream::output::meta::field::tag; 41 | using bitstream::output::meta::field::tag::Stream; 42 | const auto &stream = Stream(stream_); 43 | if (box.flags & 0x000100) { 44 | stream.tag(sample_duration) << "sample_duration"; 45 | } 46 | if (box.flags & 0x000200) { 47 | stream.tag(sample_size) << "sample_size"; 48 | } 49 | if (box.flags & 0x000400) { 50 | stream.tag(sample_flags) << "sample_flags"; 51 | } 52 | if (box.flags & 0x000800) { 53 | stream.tag(sample_composition_time_offset) << "sample_composition_time_offset"; 54 | } 55 | } 56 | 57 | template struct TrackRunBox::Entry<0>; 58 | template struct TrackRunBox::Entry<1>; 59 | 60 | }} // namespace mpeg::isobase 61 | 62 | -------------------------------------------------------------------------------- /src/box/track_selection.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void TrackSelectionBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 10 | FullBox::output_fields(stream_); 11 | using namespace bitstream::output::meta::field::tag; 12 | using bitstream::output::meta::field::tag::Stream; 13 | const auto &stream = Stream(stream_); 14 | stream.tag(switch_group) << "switch_group"; 15 | stream.tag(attribute_list) << "attribute_list"; 16 | } 17 | 18 | 19 | }} // namespace mpeg::isobase 20 | 21 | -------------------------------------------------------------------------------- /src/box/user_data.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | 10 | 11 | }} // namespace mpeg::isobase 12 | 13 | -------------------------------------------------------------------------------- /src/box/video_media_header.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void VideoMediaHeaderBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 10 | FullBox::output_fields(stream_); 11 | using namespace bitstream::output::meta::field::tag; 12 | using bitstream::output::meta::field::tag::Stream; 13 | const auto &stream = Stream(stream_); 14 | stream.tag(graphicsmode) << "graphicsmode"; 15 | stream.tag(opcolor) << "opcolor"; 16 | } 17 | 18 | 19 | }} // namespace mpeg::isobase 20 | 21 | -------------------------------------------------------------------------------- /src/box/visual_sample_entry.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void VisualSampleEntry::output_fields(bitstream::output::meta::field::Stream &stream_) const { 10 | SampleEntry::output_fields(stream_); 11 | using namespace bitstream::output::meta::field::tag; 12 | using bitstream::output::meta::field::tag::Stream; 13 | const auto &stream = Stream(stream_); 14 | stream.tag(pre_defined) << "pre_defined"; 15 | stream.tag(reserved) << "reserved"; 16 | stream.tag(pre_defined2) << "pre_defined"; 17 | stream.tag(width) << "width"; 18 | stream.tag(height) << "height"; 19 | stream.tag(horizresolution) << "horizresolution" << Format("fixed-point"); 20 | stream.tag(vertresolution) << "vertresolution" << Format("fixed-point"); 21 | stream.tag(reserved2) << "reserved"; 22 | stream.tag(frame_count) << "frame_count"; 23 | //stream.tag((decltype(compressorname)::Base&)compressorname) << "compressorname"; 24 | stream.typed_tag(decltype(compressorname)::Vector(compressorname)) << "compressorname"; 25 | stream.tag(depth) << "depth"; 26 | stream.tag(pre_defined3) << "pre_defined"; 27 | } 28 | 29 | 30 | }} // namespace mpeg::isobase 31 | 32 | -------------------------------------------------------------------------------- /src/box/xml.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | namespace mpeg { 6 | namespace isobase { 7 | 8 | 9 | void XMLBox::output_fields(bitstream::output::meta::field::Stream &stream_) const { 10 | FullBox::output_fields(stream_); 11 | using namespace bitstream::output::meta::field::tag; 12 | using bitstream::output::meta::field::tag::Stream; 13 | const auto &stream = Stream(stream_); 14 | stream.tag(xml) << "xml"; 15 | } 16 | 17 | 18 | }} // namespace mpeg::isobase 19 | 20 | -------------------------------------------------------------------------------- /src/box_entries.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | 6 | namespace mpeg { 7 | namespace isobase { 8 | 9 | bool Box::Entry::output_ellipses(bitstream::output::meta::header::Stream &stream) const { 10 | return stream.ellipses(index, count); 11 | } 12 | 13 | void Box::Entry::output_header(bitstream::output::meta::header::Stream &stream) const { 14 | bitstream::output::meta::Stream::Tag tag = { 15 | .name = SStream() << name() << " #" << index, 16 | .size = 8 * composer->hstream.consumed()}; 17 | stream.header(tag, composer->hstream.data); 18 | } 19 | 20 | }} // namespace mpeg::isobase 21 | -------------------------------------------------------------------------------- /src/box_map.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | 7 | namespace mpeg { 8 | namespace isobase { 9 | 10 | 11 | void Box::Map::print(std::ostream &stream, bool with_top_level) const { 12 | std::string indent; 13 | 14 | std::function print_box = 15 | [&] (const Box::Desc &desc, bool traverse=true) { 16 | 17 | stream << indent << "| "; 18 | 19 | stream << desc.to_string(); 20 | //stream << (desc.name.empty() ? "": desc.name); 21 | //stream << " ["; 22 | //for (const auto &type : desc.containers.types) { 23 | // stream << (*this)[type].name << ", "; 24 | //} 25 | //for (const auto &extended_type : desc.containers.extended_types) { 26 | // stream << (*this)[extended_type].name << ", "; 27 | //} 28 | //stream << "]"; 29 | stream << std::endl; 30 | 31 | struct Indent { 32 | std::string &indent; 33 | Indent(std::string &indent): indent(indent) { 34 | indent += " "; 35 | } 36 | ~Indent() { 37 | indent.erase(indent.end() - 2, indent.end()); 38 | } 39 | } _(indent); 40 | 41 | if (traverse) { 42 | for (const auto &type : desc.children.types) { 43 | auto &child = (*this)[type]; 44 | print_box(child, &desc != &child); 45 | } 46 | for (const auto &extended_type : desc.children.extended_types) { 47 | auto &child = (*this)[extended_type]; 48 | print_box(child, &desc != &child); 49 | } 50 | } 51 | }; 52 | 53 | if (with_top_level) { 54 | print_box(boxes[Box::top_level_box], true); 55 | } else { 56 | auto &top_level = boxes[Box::top_level_box]; 57 | for (const auto &type : top_level.children.types) { 58 | print_box((*this)[type], true); 59 | } 60 | for (const auto &extended_type : top_level.children.extended_types) { 61 | print_box((*this)[extended_type], true); 62 | } 63 | 64 | } 65 | } 66 | 67 | 68 | }} // namespace mpeg::isobase 69 | 70 | -------------------------------------------------------------------------------- /test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include(CTest) 2 | find_package(GTest REQUIRED) 3 | include_directories(${GTEST_INCLUDE_DIRS}) 4 | 5 | file(GLOB sources *.cc) 6 | 7 | add_executable(test_${PROJECT_NAME} ${sources}) 8 | target_link_libraries(test_${PROJECT_NAME} lib${PROJECT_NAME}_shared ${GTEST_BOTH_LIBRARIES}) 9 | add_test(test_${PROJECT_NAME} test_${PROJECT_NAME}) 10 | 11 | -------------------------------------------------------------------------------- /test/test_boxes.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | TEST(Boxes, print) { 6 | mpeg::isobase::Parser::all_boxes.print(std::cout); 7 | } 8 | 9 | -------------------------------------------------------------------------------- /test/test_parser.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include "file_list_processing.h" 8 | 9 | 10 | TEST(Parser, dev) { 11 | struct: mpeg::isobase::test::FileListProcessing { 12 | virtual void process(const std::string &file) { 13 | std::cout << std::endl << file << ":" << std::endl; 14 | bitstream::input::file::Stream stream(file); 15 | mpeg::isobase::Parser parser(stream, bitstream::output::print::to_stdout); 16 | parser.parse(); 17 | } 18 | } processing; 19 | processing.process_files(); 20 | } 21 | 22 | --------------------------------------------------------------------------------