├── .github ├── Readme.md └── workflows │ └── codeql-analysis.yml ├── .gitignore ├── CMakeLists.txt ├── COPYING ├── GNUmakefile.am ├── INSTALL ├── README ├── configure.ac ├── doc ├── GNUmakefile.mk ├── doxygen │ ├── Doxyfile.m4 │ ├── footer.html.m4 │ ├── mainpage.h │ └── project.css ├── html │ ├── banner.png │ ├── footer.html.m4 │ ├── header.html.m4 │ └── project.css └── texi │ ├── Authors.texi │ ├── BuildRepository.texi │ ├── BuildSource.texi │ ├── Documentation.texi │ ├── ReleaseNotes.texi │ ├── ToolGuide.texi │ ├── base │ ├── article.texi │ ├── glossary.texi │ ├── guide.texi │ └── project.texi.m4 │ ├── build │ ├── commands.texi │ ├── overview.texi │ ├── platform.common.bundled.texi │ ├── platform.common.conf.bi.texi │ ├── platform.common.conf.default.texi │ ├── platform.cygwin.texi │ ├── platform.freebsd.texi │ ├── platform.linux.texi │ ├── platform.osx.texi │ ├── platform.solaris.texi │ ├── platform.windows.texi │ ├── platforms.texi │ ├── process.bootstrap.texi │ ├── process.build.texi │ ├── process.checkout.texi │ ├── process.configure.texi │ ├── process.dist.texi │ ├── process.doc.texi │ ├── process.extract.texi │ ├── process.google.texi │ └── process.install.texi │ ├── changelog │ ├── version-1.6.texi │ ├── version-1.9.texi │ ├── version-2.0.texi │ └── version-2.1.texi │ ├── releasenotes │ ├── intro.developer.texi │ └── intro.stable.texi │ └── tool │ ├── mp4art.texi │ ├── mp4chaps.format.texi │ ├── mp4chaps.texi │ ├── mp4file.texi │ └── mp4track.texi ├── example ├── callbacks │ └── callbacks.c └── itmf │ ├── generic.c │ └── tags.c ├── include └── mp4v2 │ ├── chapter.h │ ├── file.h │ ├── file_prop.h │ ├── general.h │ ├── isma.h │ ├── itmf_generic.h │ ├── itmf_tags.h │ ├── mp4v2.h │ ├── platform.h │ ├── project.h.in │ ├── sample.h │ ├── streaming.h │ ├── track.h │ └── track_prop.h ├── libplatform ├── config.h.cmake ├── endian.h ├── impl.h ├── io │ ├── File.cpp │ ├── File.h │ ├── FileSystem.cpp │ ├── FileSystem.h │ ├── FileSystem_posix.cpp │ ├── FileSystem_win32.cpp │ ├── File_posix.cpp │ └── File_win32.cpp ├── number │ ├── random.h │ ├── random_posix.cpp │ └── random_win32.cpp ├── platform.h ├── platform_base.h ├── platform_posix.h ├── platform_win32.cpp ├── platform_win32.h ├── platform_win32_impl.h ├── prog │ ├── option.cpp │ └── option.h ├── sys │ ├── error.cpp │ └── error.h ├── time │ ├── time.cpp │ ├── time.h │ ├── time_posix.cpp │ └── time_win32.cpp └── warning.h ├── libutil ├── Timecode.cpp ├── Timecode.h ├── TrackModifier.cpp ├── TrackModifier.h ├── Utility.cpp ├── Utility.h ├── crc.cpp ├── crc.h ├── impl.h ├── other.cpp ├── other.h └── util.h ├── maintainer ├── HOWTO-ADD_SOURCE.txt ├── HOWTO-AUTOTOOLS.txt ├── HOWTO-RELEASE.txt ├── HOWTO-TEST.txt ├── INTERNALS.txt ├── LIBPLATFORM.txt ├── NAMESPACES.txt └── SOURCE.txt ├── mp4v2.pc.in ├── project ├── htmlcombine.py ├── project.m4.in ├── project.m4sugar └── xml2wiki.py ├── src ├── 3gp.cpp ├── atom_ac3.cpp ├── atom_amr.cpp ├── atom_avc1.cpp ├── atom_avcC.cpp ├── atom_chpl.cpp ├── atom_colr.cpp ├── atom_d263.cpp ├── atom_dac3.cpp ├── atom_damr.cpp ├── atom_dref.cpp ├── atom_elst.cpp ├── atom_enca.cpp ├── atom_encv.cpp ├── atom_free.cpp ├── atom_ftab.cpp ├── atom_ftyp.cpp ├── atom_gmin.cpp ├── atom_hdlr.cpp ├── atom_hinf.cpp ├── atom_hnti.cpp ├── atom_href.cpp ├── atom_mdat.cpp ├── atom_mdhd.cpp ├── atom_meta.cpp ├── atom_mp4s.cpp ├── atom_mp4v.cpp ├── atom_mvhd.cpp ├── atom_nmhd.cpp ├── atom_ohdr.cpp ├── atom_pasp.cpp ├── atom_root.cpp ├── atom_rtp.cpp ├── atom_s263.cpp ├── atom_sdp.cpp ├── atom_sdtp.cpp ├── atom_smi.cpp ├── atom_sound.cpp ├── atom_standard.cpp ├── atom_stbl.cpp ├── atom_stdp.cpp ├── atom_stsc.cpp ├── atom_stsd.cpp ├── atom_stsz.cpp ├── atom_stz2.cpp ├── atom_text.cpp ├── atom_tfhd.cpp ├── atom_tkhd.cpp ├── atom_treftype.cpp ├── atom_trun.cpp ├── atom_tx3g.cpp ├── atom_udta.cpp ├── atom_url.cpp ├── atom_urn.cpp ├── atom_uuid.cpp ├── atom_video.cpp ├── atom_vmhd.cpp ├── atoms.h ├── bmff │ ├── bmff.h │ ├── impl.h │ ├── typebmff.cpp │ └── typebmff.h ├── cmeta.cpp ├── descriptors.cpp ├── descriptors.h ├── enum.h ├── enum.tcc ├── exception.cpp ├── exception.h ├── impl.h ├── isma.cpp ├── itmf │ ├── CoverArtBox.cpp │ ├── CoverArtBox.h │ ├── Tags.cpp │ ├── Tags.h │ ├── generic.cpp │ ├── generic.h │ ├── impl.h │ ├── itmf.h │ ├── type.cpp │ └── type.h ├── log.cpp ├── log.h ├── mp4.cpp ├── mp4array.h ├── mp4atom.cpp ├── mp4atom.h ├── mp4container.cpp ├── mp4container.h ├── mp4descriptor.cpp ├── mp4descriptor.h ├── mp4file.cpp ├── mp4file.h ├── mp4file_io.cpp ├── mp4info.cpp ├── mp4property.cpp ├── mp4property.h ├── mp4track.cpp ├── mp4track.h ├── mp4util.cpp ├── mp4util.h ├── ocidescriptors.cpp ├── ocidescriptors.h ├── odcommands.cpp ├── odcommands.h ├── qosqualifiers.cpp ├── qosqualifiers.h ├── qtff │ ├── ColorParameterBox.cpp │ ├── ColorParameterBox.h │ ├── PictureAspectRatioBox.cpp │ ├── PictureAspectRatioBox.h │ ├── coding.cpp │ ├── coding.h │ ├── impl.h │ └── qtff.h ├── rtphint.cpp ├── rtphint.h ├── src.h ├── text.cpp ├── text.h └── util.h ├── test ├── c_api.c ├── mp4clip.cpp ├── nullcreate.cpp ├── nullvplayer.cpp └── urltrack.cpp ├── testsuite ├── config │ └── unix.exp ├── lib │ └── command.exp └── main │ └── standardUsage.exp ├── util ├── impl.h ├── mp4art.cpp ├── mp4chaps.cpp ├── mp4extract.cpp ├── mp4file.cpp ├── mp4info.cpp ├── mp4subtitle.cpp ├── mp4tags.cpp ├── mp4track.cpp └── mp4trackdump.cpp ├── vstudio ├── include │ └── mp4v2 │ │ └── project.h ├── libmp4v2 │ ├── Version.rc │ ├── libmp4v2.natvis │ ├── libmp4v2.vcxproj │ └── libmp4v2.vcxproj.filters ├── libutil │ └── libutil.vcxproj ├── mp4art │ └── mp4art.vcxproj ├── mp4chaps │ └── mp4chaps.vcxproj ├── mp4extract │ └── mp4extract.vcxproj ├── mp4file │ └── mp4file.vcxproj ├── mp4info │ └── mp4info.vcxproj ├── mp4subtitle │ └── mp4subtitle.vcxproj ├── mp4tags │ └── mp4tags.vcxproj ├── mp4track │ └── mp4track.vcxproj ├── mp4trackdump │ └── mp4trackdump.vcxproj └── mp4v2.sln └── xcode ├── include ├── libplatform │ └── config.h └── mp4v2 │ └── project.h └── mp4v2.xcodeproj ├── project.pbxproj └── project.xcworkspace └── contents.xcworkspacedata /.github/Readme.md: -------------------------------------------------------------------------------- 1 | ## MP4v2 - *A C/C++ library to create, modify and read MP4 files* 2 | [![Last commit](https://img.shields.io/github/last-commit/enzo1982/mp4v2.svg)](https://github.com/enzo1982/mp4v2/commits/main) [![Last commit](https://img.shields.io/github/v/release/enzo1982/mp4v2)](https://github.com/enzo1982/mp4v2/releases) 3 | 4 | This is the *new* MP4v2 project, a fork of the [abandoned MP4v2 library](https://code.google.com/archive/p/mp4v2/) project now archived at Google Code. 5 | 6 | The MP4v2 library provides an API to create and modify MP4 files as defined by ISO-IEC:14496-1:2001 MPEG-4 Systems. This file format is derived from Apple's QuickTime file format that has been used as a multimedia file format in a variety of platforms and applications. It is a very powerful and extensible format that can accommodate practically any type of media. 7 | 8 | Please visit [mp4v2.org](https://mp4v2.org) for more information about this project and its goals. 9 | 10 | ### License 11 | MP4v2 is released under the terms of the Mozilla Public License (MPL) Version 1.1. Please refer to the [`COPYING`](https://raw.githubusercontent.com/enzo1982/mp4v2/main/COPYING) file for the full license text. 12 | 13 | ### Download 14 | Release packages of the MP4v2 library sources are available in the *[Releases](https://github.com/enzo1982/mp4v2/releases)* area. 15 | 16 | ### Building 17 | The MP4v2 library and utilities can be built using the following build systems: 18 | 19 | - **GNU Autotools** 20 | 1. Run `autoreconf -i` in the MP4v2 project base folder 21 | (only necessary when building directly from repository sources) 22 | 2. Run `./configure && make` in the MP4v2 project base folder 23 | 24 | - **CMake** 25 | - Run `cmake . && make` in the MP4v2 project base folder 26 | 27 | - **Visual Studio** 28 | - Use the Visual Studio solution at `vstudio/mp4v2.sln` 29 | 30 | - **Xcode** 31 | - Use the Xcode project at `xcode/mp4v2.xcodeproj` 32 | 33 | MP4v2 has no special dependencies other than a working C++ compiler and build environment. 34 | 35 | ### Support 36 | Please use the *[Issues](https://github.com/enzo1982/mp4v2/issues)* area to report bugs and other issues or make feature requests. For questions and general discussion, please use the *[Discussions](https://github.com/enzo1982/mp4v2/discussions)* area. 37 | 38 | If you need to contact the maintainer, please send an email to [support@mp4v2.org](mailto:support@mp4v2.org). 39 | -------------------------------------------------------------------------------- /.github/workflows/codeql-analysis.yml: -------------------------------------------------------------------------------- 1 | name: "CodeQL Scan" 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | pull_request: 7 | # The branches below must be a subset of the branches above 8 | branches: [ main ] 9 | schedule: 10 | - cron: '19 4 * * 5' 11 | 12 | jobs: 13 | analyze: 14 | name: Analyze 15 | runs-on: ubuntu-latest 16 | permissions: 17 | actions: read 18 | contents: read 19 | security-events: write 20 | 21 | strategy: 22 | fail-fast: false 23 | matrix: 24 | language: [ 'cpp' ] 25 | 26 | steps: 27 | - name: Checkout repository 28 | uses: actions/checkout@v3 29 | 30 | # Initializes the CodeQL tools for scanning. 31 | - name: Initialize CodeQL 32 | uses: github/codeql-action/init@v2 33 | with: 34 | languages: ${{ matrix.language }} 35 | # If you wish to specify custom queries, you can do so here or in a config file. 36 | # By default, queries listed here will override any specified in a config file. 37 | # Prefix the list here with "+" to use these queries and those in the config file. 38 | # queries: ./path/to/local/query, your-org/your-repo/queries@main 39 | 40 | # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). 41 | # If this step fails, then you should remove it and run the build manually (see below) 42 | - name: Autobuild 43 | uses: github/codeql-action/autobuild@v2 44 | 45 | # ℹ️ Command-line programs to run using the OS shell. 46 | # 📚 https://git.io/JvXDl 47 | 48 | # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines 49 | # and modify them (or add more) to build your code if your project 50 | # uses a compiled language 51 | 52 | #- run: | 53 | # make bootstrap 54 | # make release 55 | 56 | - name: Perform CodeQL Analysis 57 | uses: github/codeql-action/analyze@v2 58 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Autotools files 2 | aclocal.m4 3 | config.log 4 | config.status 5 | configure 6 | autoaux 7 | autom4te.cache 8 | libtool 9 | stamp-h1 10 | *~ 11 | 12 | # CMake files 13 | CMakeFiles 14 | *CMakeCache.txt 15 | cmake_install.cmake 16 | 17 | # Visual Studio files 18 | .vs 19 | vstudio/build-* 20 | *.vcxproj.user 21 | 22 | # Generated files 23 | m4 24 | GNUmakefile 25 | GNUmakefile.in 26 | Makefile 27 | mp4v2.pc 28 | include/mp4v2/project.h 29 | libplatform/config.h 30 | libplatform/config.h.in 31 | project/project.m4 32 | 33 | # Build artifacts 34 | .dirstamp 35 | .deps 36 | .libs 37 | doc/man/man1 38 | doc/texi/base/project.texi 39 | impl.h.gch 40 | mp4v2--r* 41 | *.o 42 | *.lo 43 | *.a 44 | *.la 45 | *.lai 46 | *.so 47 | *.dll 48 | *.exe 49 | *.tar.bz2 50 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | All docs are located in doc/ subdirectory. Useful starting points: 2 | 3 | Release Notes -- doc/ReleaseNotes.txt 4 | Guide to Command Line Tools -- doc/ToolGuide.txt 5 | 6 | Building the Source -- doc/BuildSource.txt 7 | Building the Repository -- doc/BuildRepository.txt 8 | 9 | See the COPYING file for license rights and limitations. 10 | -------------------------------------------------------------------------------- /doc/doxygen/footer.html.m4: -------------------------------------------------------------------------------- 1 | changequote(<<,>>)dnl 2 | include(<>)dnl 3 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /doc/doxygen/project.css: -------------------------------------------------------------------------------- 1 | body { 2 | background-color: #D0D0D0; 3 | min-width: 800px; 4 | max-width: 1360px; 5 | margin: 0 auto; 6 | padding-top: 0.5em; 7 | padding-bottom: 1em; 8 | } 9 | 10 | div.header { 11 | background-image: none; 12 | border-bottom: 0; 13 | } 14 | 15 | div#projectname { 16 | margin-left: 3px; 17 | font-weight: bold; 18 | } 19 | 20 | div#top, div.header, div.contents, address.footer { 21 | margin-left: 40px; 22 | margin-right: 40px; 23 | background-color: #FFFFFF; 24 | position: relative; 25 | -webkit-box-shadow: 5px 5px 5px black; 26 | } 27 | 28 | div.contents { 29 | margin-top: 12px; 30 | padding-left: 16px; 31 | padding-top: 16px; 32 | padding-right: 16px; 33 | padding-bottom: 2px; 34 | } 35 | 36 | div.title { 37 | margin-top: 5px; 38 | margin-bottom: 5px; 39 | } 40 | 41 | table.markdownTable { 42 | margin-left: 1em; 43 | } 44 | 45 | td.markdownTableBodyNone { 46 | vertical-align: top; 47 | } 48 | 49 | address.footer { 50 | margin-top: 12px; 51 | } 52 | -------------------------------------------------------------------------------- /doc/html/banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enzo1982/mp4v2/86b5aaf13d03291873608af559fe0399efe898f4/doc/html/banner.png -------------------------------------------------------------------------------- /doc/html/footer.html.m4: -------------------------------------------------------------------------------- 1 | changequote(<<,>>)dnl 2 | include(<>)dnl 3 | 4 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /doc/html/header.html.m4: -------------------------------------------------------------------------------- 1 | changequote(<<,>>)dnl 2 | include(<>)dnl 3 | 4 | 5 | 6 | __TITLE__ 7 | 8 | 9 | 10 |
11 |
12 |
13 | 14 |
15 |
16 | __SHORT_TITLE__ 17 |
18 | 25 |
26 |
27 | -------------------------------------------------------------------------------- /doc/texi/Authors.texi: -------------------------------------------------------------------------------- 1 | \input texinfo @c -*- Texinfo -*- 2 | @c %**start of header 3 | @setfilename Authors.info 4 | @include base/article.texi 5 | @paragraphindent none 6 | @c %**end of header 7 | 8 | @majorheading @value{PROJECT.name.formal} Authors 9 | 10 | This document lists significant contributors to @value{PROJECT.name}. If any contributors are missing please contact one of the project members. More extensive contributor information may be found in sources, docs, and other files where appropriate. 11 | 12 | @example 13 | Edward Groenendaal egroenen@@cisco.com 14 | Jonathon Rubin jb.rubin@@gmail.com 15 | Kona Blend kona8lend@@gmail.com 16 | Rouven Wessling mp4v2@@rouvenwessling.de 17 | @end example 18 | 19 | @heading Authors from original MPEG4IP/libmp4v2 20 | 21 | @example 22 | Dave Mackie dmackie@@cisco.com 23 | Alix Marchandise-Franquet alix@@cisco.com 24 | Bill May wmay@@cisco.com 25 | Ximpo Group Ltd. mp4v2@@ximpo.com 26 | Danijel Kopcinovic danijel.kopcinovic@@adnecto.net 27 | @end example 28 | -------------------------------------------------------------------------------- /doc/texi/BuildRepository.texi: -------------------------------------------------------------------------------- 1 | \input texinfo @c -*- Texinfo -*- 2 | @c %**start of header 3 | @setfilename BuildRepository.info 4 | @include base/article.texi 5 | @include build/commands.texi 6 | @paragraphindent none 7 | @c %**end of header 8 | 9 | @majorheading @value{PROJECT.name.formal} Building the Repository 10 | @contents 11 | 12 | @chapter Overview 13 | @include build/overview.texi 14 | 15 | @chapter Introduction 16 | This document describes the recommended process to build @value{PROJECT.name} from the repository. This process is a @b{superset} of the process to build from a @value{TERM.srcdist} bundle. If you are interested in building from a @value{TERM.srcdist} bundle then this document is not for you. 17 | 18 | @chapter Quickstart 19 | This chapter is for the impatient or those just looking for a quick summary of all the commands used in a typical build. You may skip this summary and jump to @ref{Build Process}. 20 | 21 | @example 22 | @COMMANDcheckout{} 23 | @COMMANDbootstrap{} 24 | @COMMANDconfigure{} 25 | @COMMANDbuild{} 26 | @COMMANDinstall{} 27 | @COMMANDdist{} 28 | @end example 29 | 30 | @anchor{Build Process} 31 | @chapter Build Process 32 | 33 | @include build/process.checkout.texi 34 | @include build/process.bootstrap.texi 35 | @include build/process.configure.texi 36 | @include build/process.build.texi 37 | @include build/process.install.texi 38 | @include build/process.dist.texi 39 | @include build/process.doc.texi 40 | @include build/process.google.texi 41 | 42 | @include build/platforms.texi 43 | -------------------------------------------------------------------------------- /doc/texi/BuildSource.texi: -------------------------------------------------------------------------------- 1 | \input texinfo @c -*- Texinfo -*- 2 | @c %**start of header 3 | @setfilename BuildSource.info 4 | @include base/article.texi 5 | @include build/commands.texi 6 | @paragraphindent none 7 | @c %**end of header 8 | 9 | @majorheading @value{PROJECT.name.formal} Building the Source 10 | @contents 11 | 12 | @chapter Overview 13 | @include build/overview.texi 14 | 15 | @chapter Introduction 16 | This document describes the recommended process to build @value{PROJECT.name} from a @value{TERM.srcdist} bundle. This process is a @b{subset} of the process to build directly from the project's repository. If you are interested in building from the repository then this document is not for you. 17 | 18 | @chapter Quickstart 19 | This chapter is for the impatient or those just looking for a quick summary of all the commands used in a typical build. You may skip this summary and jump to @ref{Build Process}. 20 | 21 | @example 22 | @COMMANDextract{} 23 | @COMMANDconfigure{} 24 | @COMMANDbuild{} 25 | @COMMANDinstall{} 26 | @end example 27 | 28 | @anchor{Build Process} 29 | @chapter Build Process 30 | 31 | @include build/process.extract.texi 32 | @include build/process.configure.texi 33 | @include build/process.build.texi 34 | @include build/process.install.texi 35 | 36 | @include build/platforms.texi 37 | -------------------------------------------------------------------------------- /doc/texi/Documentation.texi: -------------------------------------------------------------------------------- 1 | \input texinfo @c -*- Texinfo -*- 2 | @c %**start of header 3 | @setfilename Documentation.info 4 | @include base/article.texi 5 | @paragraphindent none 6 | @c %**end of header 7 | 8 | @titlepage 9 | @end titlepage 10 | 11 | @majorheading @value{PROJECT.name.formal} Documentation 12 | @include releasenotes/intro.stable.texi 13 | 14 | @heading Introduction 15 | Project @value{PROJECT.name} consists of a C-library and various command-line utilities which permit creation and modification of MP4 files as defined by as defined by @cite{ISO base media file format}, document number @cite{ISO/IEC 14496-12:2005(E)}. 16 | 17 | @heading Official website 18 | The official @url{@value{PROJECT.url.website},website} makes various @url{@value{PROJECT.url.downloads},downloads} available and archives online browesable documentation for releases, including API Reference. 19 | 20 | @heading Issues and discussions 21 | Bug reports and feature requests can be submitted to the @url{@value{PROJECT.url.bugreport},issue tracker}. Questions and general feedback may be posted to the @url{@value{PROJECT.url.discussion},discussion} board. 22 | 23 | @ifnothtml 24 | @unnumbered Articles 25 | See Release Notes (@file{doc/ReleaseNotes.txt}) 26 | @* See Building the Source (@file{doc/BuildSource.txt}) 27 | @* See Building the Repository (@file{doc/BuildRepository.txt}) 28 | @* See Authors (@file{doc/Authors.txt}) 29 | 30 | @unnumbered Guides 31 | See Command-line Tools Guide (@file{doc/ToolGuide.txt}) 32 | @end ifnothtml 33 | 34 | @ifhtml 35 | @unnumbered Articles 36 | @enumerate 37 | @item @url{ReleaseNotes.html,Release Notes}. 38 | @item @url{BuildSource.html,Building the Source}. 39 | @item @url{BuildRepository.html,Building the Repository}. 40 | @item @url{Authors.html,Authors}. 41 | @end enumerate 42 | @unnumbered Guides 43 | @enumerate 44 | @item @url{ToolGuide.html,Command-line Tools Guide}. 45 | @end enumerate 46 | @unnumbered Reference 47 | @enumerate 48 | @item @url{api/index.html,API Reference}. 49 | @end enumerate 50 | @end ifhtml 51 | -------------------------------------------------------------------------------- /doc/texi/ReleaseNotes.texi: -------------------------------------------------------------------------------- 1 | \input texinfo @c -*- Texinfo -*- 2 | @c %**start of header 3 | @setfilename ReleaseNotes.info 4 | @include base/article.texi 5 | @paragraphindent none 6 | @c %**end of header 7 | 8 | @titlepage 9 | @end titlepage 10 | 11 | @majorheading @value{PROJECT.name.formal} Release Notes 12 | @include releasenotes/intro.stable.texi 13 | @contents 14 | 15 | @chapter What's New? 16 | 17 | @unnumberedsec MP4v2 v2.1.3 18 | 19 | Version 2.1.3 fixes several stability issues, including the following CVEs: 20 | 21 | @itemize @minus 22 | @item 23 | https://nvd.nist.gov/vuln/detail/CVE-2023-29584 24 | @item 25 | https://nvd.nist.gov/vuln/detail/CVE-2023-1451 26 | @item 27 | https://nvd.nist.gov/vuln/detail/CVE-2023-1450 28 | @end itemize 29 | 30 | The 2.1.3 update also fixes a performance issue when operating on files with unusually large chunks (containing thousands or 31 | even millions of samples instead of the usual few dozen). 32 | 33 | @unnumberedsec MP4v2 v2.1.2 34 | 35 | Version 2.1.2 fixes build system issues, mainly in the CMake build system support. This release also fixes a file seeking 36 | issue observed on Windows when compiled with _WIN32_WINNT < 0x600 and linked against modern CRT DLLs. In addition, two minor 37 | issues related to data handling are fixed. 38 | 39 | @unnumberedsec MP4v2 v2.1.1 40 | 41 | Version 2.1.1 fixes a type mismatch preventing MP4v2 from compiling on 32 bit systems. 42 | 43 | @unnumberedsec MP4v2 v2.1 44 | 45 | Version 2.1 updates the existing build systems and adds support for building with CMake and Xcode. It also fixes compilation 46 | with newer compilers and integrates smaller improvements and bug fixes from various MP4v2 forks. 47 | 48 | @appendix Changelog 49 | @appendixsection Version 2.1 50 | @include changelog/version-2.1.texi 51 | 52 | @appendixsection Version 2.0 53 | @include changelog/version-2.0.texi 54 | 55 | @appendixsection Version 1.9 56 | @include changelog/version-1.9.texi 57 | 58 | @appendixsection Version 1.6 59 | @include changelog/version-1.6.texi 60 | 61 | @appendix SCM repository details 62 | @example 63 | url: @value{PROJECT.repo.url} 64 | @end example 65 | -------------------------------------------------------------------------------- /doc/texi/base/article.texi: -------------------------------------------------------------------------------- 1 | @ifhtml 2 | @exampleindent 0 3 | @end ifhtml 4 | 5 | @include base/project.texi 6 | @include base/glossary.texi 7 | -------------------------------------------------------------------------------- /doc/texi/base/glossary.texi: -------------------------------------------------------------------------------- 1 | @set OS.cygwin Cygwin 2 | @set OS.freebsd FreeBSD 3 | @set OS.linux Linux 4 | @set OS.osx Mac OS X 5 | @set OS.solaris Solaris 6 | @set OS.unix unix 7 | @set OS.windows Windows 8 | 9 | @set TERM.srcdist source-distribution 10 | -------------------------------------------------------------------------------- /doc/texi/base/guide.texi: -------------------------------------------------------------------------------- 1 | @ifhtml 2 | @exampleindent 0 3 | @end ifhtml 4 | 5 | @include base/project.texi 6 | @include base/glossary.texi 7 | -------------------------------------------------------------------------------- /doc/texi/base/project.texi.m4: -------------------------------------------------------------------------------- 1 | changequote(<<,>>)dnl 2 | include(<>)dnl 3 | @set PROJECT.name __PROJECT_name 4 | @set PROJECT.name.lower __PROJECT_name_lower 5 | @set PROJECT.name.upper __PROJECT_name_upper 6 | @set PROJECT.name.formal __PROJECT_name_formal 7 | @set PROJECT.url.website __PROJECT_url_website 8 | @set PROJECT.url.downloads __PROJECT_url_downloads 9 | @set PROJECT.url.discussion __PROJECT_url_discussion 10 | @set PROJECT.url.bugreport __PROJECT_url_bugreport 11 | @set PROJECT.support patsubst(__PROJECT_support,@,@@) 12 | @set PROJECT.version __PROJECT_version 13 | @set PROJECT.version.hex __PROJECT_version_hex 14 | @set PROJECT.version.major __PROJECT_version_major 15 | @set PROJECT.version.minor __PROJECT_version_minor 16 | @set PROJECT.version.point __PROJECT_version_point 17 | @set PROJECT.repo.url patsubst(__PROJECT_repo_url,@,@@) 18 | @set PROJECT.build __PROJECT_build 19 | -------------------------------------------------------------------------------- /doc/texi/build/commands.texi: -------------------------------------------------------------------------------- 1 | @macro COMMANDcheckout{} 2 | git clone @value{PROJECT.repo.url} @value{PROJECT.name.lower} 3 | cd @value{PROJECT.name.lower} 4 | @end macro 5 | 6 | @macro COMMANDbootstrap{} 7 | autoreconf -fiv 8 | @end macro 9 | 10 | @macro COMMANDextract{} 11 | tar xf @value{PROJECT.name.lower}-@value{PROJECT.version}.tar.bz2 12 | cd @value{PROJECT.name.lower}-@value{PROJECT.version}/ 13 | @end macro 14 | 15 | @macro COMMANDconfigure{} 16 | rm -fr build/ 17 | mkdir build/ 18 | cd build/ 19 | ../configure 20 | @end macro 21 | 22 | @macro COMMANDbuild{} 23 | make 24 | @end macro 25 | 26 | @macro COMMANDinstall{} 27 | make install 28 | make install-man 29 | @end macro 30 | 31 | @macro COMMANDdist{} 32 | make dist 33 | @end macro 34 | -------------------------------------------------------------------------------- /doc/texi/build/overview.texi: -------------------------------------------------------------------------------- 1 | The documented and supported method to build @value{PROJECT.name} uses the GNU build system (also known as the Autotools). You must first obtain the sources by either downloading and extracting the @value{TERM.srcdist} bundle or working directly @value{PROJECT.name}'s Git repository. We have build documents for both methods, but unless you are a member of the @value{PROJECT.name} project, you are @b{strongly encouraged} to use the @value{TERM.srcdist} method. 2 | 3 | On other supported platforms which lack Autotools we provide an alternative method for building the software. Please see the appropriate platform section. 4 | -------------------------------------------------------------------------------- /doc/texi/build/platform.common.bundled.texi: -------------------------------------------------------------------------------- 1 | @quotation Note 2 | It is recommended to use the platform distribution's bundled compiler for maximum C++ compatibility. If you build with a custom compiler it will likely introduce non-standard runtime requirements for your users. There are of course many valid reasons to build with unbundled compilers, but be aware that is generally unsupported and left as an exercise to the reader. 3 | @end quotation 4 | -------------------------------------------------------------------------------- /doc/texi/build/platform.common.conf.bi.texi: -------------------------------------------------------------------------------- 1 | @subsection Bi-arch compilation 2 | The preferred method to produce a bi-arch binary is to specify the target (eg. 32-bit) with the following option to configure. This example will produce a 32-bit binary if compiling on a platform which defaults to producing 64-bit binaries. The inverse is also possible. 3 | 4 | @example 5 | ../configure --enable-bi=32 6 | @end example 7 | 8 | @quotation Warning 9 | Currently bi-arch cross-compilation is not supported due to a bug with libtool which fails miserably during linking. 10 | @end quotation 11 | -------------------------------------------------------------------------------- /doc/texi/build/platform.common.conf.default.texi: -------------------------------------------------------------------------------- 1 | @subsection Default Binaries 2 | The preferred method to produce default binaries is to run configure without any options which will compile with debug+optimize and produce static+shared libraries and dynamic executables. 3 | 4 | @example 5 | ../configure 6 | @end example 7 | 8 | @subsection Release Binaries 9 | The preferred method to produce binaries suitable for releases, (ie. which does not contain debug information) is to pass the following to configure: 10 | 11 | @example 12 | ../configure --disable-debug 13 | @end example 14 | 15 | @subsection Developer Binaries 16 | The preferred method to produce binaries suitable for development is to pass the following to configure. Default Binaries will work, however for the best debugging experience we recommend no optimize and no static libraries. 17 | 18 | @example 19 | ../configure --disable-optimize --disable-static 20 | @end example 21 | -------------------------------------------------------------------------------- /doc/texi/build/platform.cygwin.texi: -------------------------------------------------------------------------------- 1 | @section @value{OS.cygwin} 2 | Building on @value{OS.cygwin} is supported. The following are the recommended specifications for this platform; but is not necessarily the only configuration that is possible: 3 | 4 | @itemize @bullet 5 | @item Intel 32-bit or 64-bit hardware 6 | @item @value{OS.cygwin}, gcc 4.3.2 7 | @item gcc 3.4.0 or higher is reported to work 8 | @end itemize 9 | 10 | @quotation Note 11 | As of this writing, @value{OS.cygwin} has available to it several versions of gcc; only one of which may be found and used in the path as @code{gcc} and @code{g++}. Configure will thus find what is probably the older more stable version of gcc in a typical @value{OS.cygwin} environment. If you desire to build with the newer gcc, it is found in the path as @code{gcc-4} and @code{g++-4} respectively and you must indicate to configure the desired versions. Defining the following variables beforing running configure should do the trick: 12 | @end quotation 13 | 14 | @example 15 | setenv CC gcc-4 16 | setenv CXX gcc-4 17 | ../configure 18 | @end example 19 | 20 | @include build/platform.common.conf.default.texi 21 | -------------------------------------------------------------------------------- /doc/texi/build/platform.freebsd.texi: -------------------------------------------------------------------------------- 1 | @section @value{OS.freebsd} 2 | Building on @value{OS.freebsd} is supported. The following are the recommended specifications for this platform; but is not necessarily the only configuration that is possible: 3 | 4 | @itemize @bullet 5 | @item Intel 32-bit or 64-bit hardware 6 | @item @value{OS.freebsd} 7.0 Release, gcc 4.2.1 7 | @item gcc 3.4.0 or higher is reported to work 8 | @end itemize 9 | 10 | @include build/platform.common.bundled.texi 11 | @include build/platform.common.conf.default.texi 12 | @include build/platform.common.conf.bi.texi 13 | -------------------------------------------------------------------------------- /doc/texi/build/platform.linux.texi: -------------------------------------------------------------------------------- 1 | @section @value{OS.linux} 2 | Building on @value{OS.linux} is well supported as it is used by maintainers of this project. The following are the recommended specifications for this platform; but is not necessarily the only configuration that is possible: 3 | 4 | @itemize @bullet 5 | @item Intel 32-bit or 64-bit hardware 6 | @item Fedora 10, gcc 4.3.2 7 | @item gcc 3.4.0 or higher is reported to work 8 | @end itemize 9 | 10 | @include build/platform.common.bundled.texi 11 | @include build/platform.common.conf.default.texi 12 | @include build/platform.common.conf.bi.texi 13 | -------------------------------------------------------------------------------- /doc/texi/build/platform.osx.texi: -------------------------------------------------------------------------------- 1 | @section @value{OS.osx} 2 | Building on @value{OS.osx} is well supported as it is used by maintainers of this project. The following are the recommended specifications for this platform; but is not necessarily the only configuration that is possible: 3 | 4 | @itemize @bullet 5 | @item Mac Intel hardware 6 | @item Mac OS X 10.5.7 7 | @item Xcode-3.1.2 8 | @item gcc 4.0.1 (Apple Inc. build 5493) 9 | @item gcc 4.2.1 (Apple Inc. build 5570) 10 | @end itemize 11 | 12 | @include build/platform.common.bundled.texi 13 | 14 | @include build/platform.common.conf.default.texi 15 | 16 | @subsection Universal Binaries - all architectures 17 | The preferred method to produce universal binaries for all supported architectures is to pass the following option to configure. As of this writing, architectures @{ i386, x86_64, ppc, ppc64 @} are built. 18 | 19 | @example 20 | ../configure --enable-ub 21 | @end example 22 | 23 | @subsection Universal Binaries - selected architectures 24 | The preferred method to produce universal binaries for selected architectures is to specify a comma-delimited list specifying the desired architecture identifiers. Passing the following option will produce universal binaries for architectures @{ i386, x86_64 @}. 25 | 26 | @example 27 | ../configure --enable-ub=i386,x86_64 28 | @end example 29 | -------------------------------------------------------------------------------- /doc/texi/build/platform.solaris.texi: -------------------------------------------------------------------------------- 1 | @section @value{OS.solaris} 2 | Building on @value{OS.solaris} is supported. The following are the recommended specifications for this platform; but is not necessarily the only configuration that is possible: 3 | 4 | @itemize @bullet 5 | @item Intel 32-bit or 64-bit hardware 6 | @item @value{OS.solaris} 10u6, gcc 3.4.3 7 | @item gcc 3.4.0 or higher is reported to work 8 | @end itemize 9 | 10 | @include build/platform.common.bundled.texi 11 | @quotation Note 12 | @value{OS.solaris} does not (yet) really bundle a compiler. The recommendation is to use the companion-disk compiler for maximum C++ runtime compatibility. It is usually found in @file{/usr/sfw/bin}. 13 | @end quotation 14 | 15 | @include build/platform.common.conf.default.texi 16 | @include build/platform.common.conf.bi.texi 17 | -------------------------------------------------------------------------------- /doc/texi/build/platform.windows.texi: -------------------------------------------------------------------------------- 1 | @section @value{OS.windows} 2 | Native builds on @value{OS.windows} is supported via Microsoft's Visual Studio package. Both the commercial version and free version (express) are known to work. The following are the recommended specifications for this platform; but is not necessarily the only configuration that is possible: 3 | 4 | @itemize @bullet 5 | @item Intel 32-bit or 64-bit hardware 6 | @item @value{OS.windows} 2000 or higher, Visual Studio 17.0 (aka. Visual Studio 2022) 7 | @end itemize 8 | 9 | Win32-API is set to @value{OS.windows} 2000 or higher. Older versions of @value{OS.windows}, or win32-API are not supported. 10 | 11 | @value{PROJECT.name} has directory @file{vstudio/} which contains the necessary solution+project files to produce a basic build of libmp4v2's DLL and several command-line executables. Enabling things such as debugging, optimization, etc, are all left as an exercise to the user. 12 | 13 | @quotation Warning 14 | Project meta-data is stored in header @file{project.h}. A proper source distribution is built using autotools and generates @file{TOP/include/mp4v2/project.h} correctly, which is then bundled with our source distribution. This is adequate for building on the @value{OS.windows} platform. 15 | 16 | However, if you are building from the repository, be warned that there is no method to automatically generate @file{project.h} on Windows. Instead, we periodically checkin a copy of this file (generated using autotools) as @file{vstudio/include/mp4v2/project.h} which may from time to time get out of date. If it is significantly out of date, you should find the latest source distribution and copy the @file{project.h} from there. 17 | @end quotation 18 | -------------------------------------------------------------------------------- /doc/texi/build/platforms.texi: -------------------------------------------------------------------------------- 1 | @chapter Platform Notes 2 | @value{PROJECT.name} builds on many unix-style platforms, also commonly referred to as posix-style systems. Building on @value{OS.osx}, @value{OS.linux}, @value{OS.freebsd}, @value{OS.solaris}, @value{OS.cygwin}, @value{OS.windows} are known to work. 3 | 4 | Similar platforms should also work. Please see the following platform specific notes for instructions on commonly used options for various platforms. 5 | 6 | @include build/platform.osx.texi 7 | @include build/platform.linux.texi 8 | @include build/platform.freebsd.texi 9 | @include build/platform.solaris.texi 10 | @include build/platform.cygwin.texi 11 | @include build/platform.windows.texi 12 | -------------------------------------------------------------------------------- /doc/texi/build/process.bootstrap.texi: -------------------------------------------------------------------------------- 1 | @section Boostrap (Autotools) 2 | 3 | The following command causes forces Autotools to regenerate all files and install helper scripts needed at configure-time and to regenerate all files. 4 | 5 | @example 6 | @COMMANDbootstrap{} 7 | @end example 8 | 9 | If you are a project member and preparing for a release, it is important to note that the versions of Autotools available in your path will directly effect files added to the bundle. At the time of writing, the following versions of Autotools are recommended; in some cases a minimum is hard-coded and warnings will be issued if in violation: 10 | 11 | @itemize 12 | @item GNU autoconf 2.61 or higher (lower versions might work) 13 | @item GNU automake 1.10 or higher (lower versions might work) 14 | @item GNU libtool 1.5.26 or higher (lower versions might work) 15 | @end itemize 16 | -------------------------------------------------------------------------------- /doc/texi/build/process.build.texi: -------------------------------------------------------------------------------- 1 | @section Build 2 | 3 | The following command will build @value{PROJECT.name}. 4 | 5 | @example 6 | @COMMANDbuild{} 7 | @end example 8 | 9 | On some platforms @code{make} refers to a BSD-flavor of make which is not compatible with this project. Check if @code{gmake} is installed, and if it is, substitute @code{gmake} wherever you may see @code{make} in this document. Otherwise you will need to install GNU make package version 3.81 or higher. Lower versions might work. 10 | -------------------------------------------------------------------------------- /doc/texi/build/process.checkout.texi: -------------------------------------------------------------------------------- 1 | @section Checkout Sources 2 | 3 | Checkout sources from the project's Git repository. 4 | 5 | Sources are checked out from either the trunk, release or a branch. This document was generated from one of those, and for example purposes, we will use exactly the same URL which used to create the distribution which contains this document. 6 | 7 | If you are a project member, then you may add the appropriate login/password information as needed. 8 | 9 | @example 10 | @COMMANDcheckout{} 11 | @end example 12 | 13 | It is recommended to use Git 2.17.0 or higher. 14 | Lower versions might work. 15 | -------------------------------------------------------------------------------- /doc/texi/build/process.configure.texi: -------------------------------------------------------------------------------- 1 | @anchor{Configure} 2 | @section Configure 3 | The following command configures the project for a build. It is highly recommended that you invoke configure from an empty directory. 4 | 5 | @example 6 | @COMMANDconfigure{} 7 | @end example 8 | 9 | Please see @file{INSTALL} for details on configure usage, and standard options. Additionally, the following custom options have been added to @file{configure}: 10 | 11 | @table @samp 12 | 13 | @item --disable-debug 14 | Do not generate debug information. Do not direct compiler to generate debugging information. By default the compiler will generate debug information if the platform supports it. 15 | 16 | @item --disable-optimize 17 | Do not optimize. Do not direct compiler to optimize code. By default compiler optimization is enabled if the platform supports it. 18 | 19 | @item --disable-fvisibility 20 | Do not set default ELF symbol visibility. By default configure attempts to detect if the compiler supports this feature. However on some platforms detecting incompatibilty of this feature might not be accurate in which case this option should be given. 21 | 22 | @item --disable-gch 23 | By default certain platforms are marked to use GCC precompiled headers. Generally this greatly decrease build times but may require more diligence for iterative development; that is to say dependencies may not properly be tracked and more frequent @command{make clean} may be required when headers are changed. Use this option to disable GCC precompiled headers. 24 | 25 | @item --disable-largefile 26 | On some 32-bit platforms or configurations it might be desirable to build without largefile (LFS) support. By default configure attempts to detect formal LFS support and enables it if found. 27 | 28 | @item --disable-util 29 | Do not build/install utilities. This is convenience option for users who desire to skip building the utilities (eg. command-line executables) which are enabled by default. 30 | 31 | @item --enable-bi=ARCH 32 | On bi-arch capable platforms it is possible to generate 32 or 64 bit code. This is supported by adding arguments @samp{-m32} or @samp{-m64}, respectively, when compiling or linking. Use this option to override the platform-specific default. 33 | 34 | @item --enable-ub[=ARCHS] 35 | On OSX systems it is possible to generate universal binaries. This is supported by adding one or more argument patterns @samp{-arch ARCH} when compiling or linking. Use this option to either target an architecture different from the platform default, or to produce universal binaries. 36 | 37 | @item --enable-dependency-tracking 38 | Enable automatic dependency tracking for include-files. By default this feature is disabled. 39 | 40 | @end table 41 | -------------------------------------------------------------------------------- /doc/texi/build/process.dist.texi: -------------------------------------------------------------------------------- 1 | @section Create Distribution 2 | 3 | The following command will create a @value{PROJECT.name} source distribution. It is during this step that shipped documentation is generated. 4 | 5 | @example 6 | @COMMANDdist{} 7 | @end example 8 | 9 | This step in the build process introduces additional requirements to the host system. While most of the following utilities are generally available, @command{help2man} is used to generate man-pages; however if this command is not available the man-pages will be empty. This is acceptable for non-release builds but for full quality builds this command is required. 10 | 11 | @itemize 12 | @item GNU help2man 1.36 or higher (lower versions should work) 13 | @item GNU tar 1.15.1 or higher (lower versions should work) 14 | @item GNU gzip 1.3.10 or higher (lower versions should work) 15 | @item bzip2 1.0.4 or higher (lower versions should work) 16 | @item Info-ZIP zip 2.32 or higher (lower versions should work) 17 | @end itemize 18 | -------------------------------------------------------------------------------- /doc/texi/build/process.extract.texi: -------------------------------------------------------------------------------- 1 | @section Extract 2 | Extract sources from a @value{TERM.srcdist} bundle. Releases are available from @url{@value{PROJECT.url.website}} in the @url{@value{PROJECT.url.downloads},downloads} section. 3 | 4 | @example 5 | @COMMANDextract{} 6 | @end example 7 | 8 | Older versions of @code{tar} may not automatically uncompress the bundle, so you might have to either enter additional flags manually, or first decompress the bundle before extracting. Some possible command variations for uncompressing a @file{bz2} file: 9 | 10 | @example 11 | tar xjf @value{PROJECT.name.lower}-@value{PROJECT.version}.tar.bz2 12 | bunzip2 -c @value{PROJECT.name.lower}-@value{PROJECT.version}.tar.bz2 | tar xf - 13 | bzcat @value{PROJECT.name.lower}-@value{PROJECT.version}.tar.bz2 | tar xf - 14 | @end example 15 | 16 | And for a @file{gz} file: 17 | 18 | @example 19 | tar xzf @value{PROJECT.name.lower}-@value{PROJECT.version}.tar.gz 20 | gunzip -c @value{PROJECT.name.lower}-@value{PROJECT.version}.tar.gz | tar xf - 21 | gzcat @value{PROJECT.name.lower}-@value{PROJECT.version}.tar.gz | tar xf - 22 | @end example 23 | -------------------------------------------------------------------------------- /doc/texi/build/process.google.texi: -------------------------------------------------------------------------------- 1 | @section Post Site and API Documentation to project website. 2 | 3 | This step is for project maintainers and can be used to update Site and API documentation. The following components are updated: 4 | 5 | @itemize 6 | @item Featured Wiki article: BuildRepository 7 | @item Featured Wiki article: BuildSource 8 | @item MP4v2 (trunk) docs (includes Release Notes and other articles, and API docs). 9 | @end itemize 10 | 11 | This procedure may only be run from a *nix platform and has only been tested on @value{OS.osx}. 12 | 13 | @table @samp 14 | 15 | @item make google.clean 16 | Clean any local working copy of google changeset. 17 | 18 | @item make google.post 19 | Generate required docs, sparse-checkout google tree, remove files which are no longer generated, add new files which are generated, and update existing files. 20 | 21 | @item svn ci -m "-refreshed GoogleCode site+api docs." google/. 22 | Check-in changes. This might take several minutes, especially if your upstream bandwidth is limited. 23 | 24 | @end table 25 | -------------------------------------------------------------------------------- /doc/texi/build/process.install.texi: -------------------------------------------------------------------------------- 1 | @anchor{Install} 2 | @section Install 3 | 4 | The following command will install @value{PROJECT.name}. 5 | 6 | @example 7 | @COMMANDinstall{} 8 | @end example 9 | -------------------------------------------------------------------------------- /doc/texi/changelog/version-1.6.texi: -------------------------------------------------------------------------------- 1 | @enumerate 2 | @item 3 | Branched libmp4v2 module from mpeg4ip project version 1.6.1. 4 | @end enumerate 5 | -------------------------------------------------------------------------------- /doc/texi/changelog/version-1.9.texi: -------------------------------------------------------------------------------- 1 | @enumerate 2 | @item 3 | Renamed public API top-level header to @code{} and added namespaces for implementation (private) symbols. Only public API symbols are exported for dynamic (shared) or DLL libraries. All other symbols are now private, notwithstanding static-library usage. 4 | 5 | @item 6 | Added initial AC3 support. 7 | 8 | @item 9 | Added native Windows port. The port targets @code{WINVER 0x0500} which is Windows 2000 or higher. 10 | 11 | @item 12 | Added QuickTime and Nero chapter support. See @command{mp4chaps} command-line utility. 13 | @* Contributed by Ullrich Pollähne . 14 | 15 | @item 16 | Enhanced @command{mp4art} to support multiple cover-art atoms. 17 | 18 | @item 19 | Dropped @command{mp4dump} and replaced with @command{mp4file} which supports general file operations. 20 | 21 | @item 22 | Added @command{mp4track} with colr-box and pasp-box support. 23 | 24 | @item 25 | Fixed corruption of @b{udta.name} atom during read-in. 26 | 27 | @item 28 | Enhanced @command{mp4file --dump} to show hexdump-style canonical hex+ASCII data. 29 | 30 | @item 31 | Enhanced @command{mp4file --dump} to show human-readble value for tag @b{typeCode} values. 32 | 33 | @item 34 | Enhanced @command{mp4file --dump} to show human-readble value for ISO-639-2/T language codes. 35 | 36 | @item 37 | Added new public-API: MP4GetTrackLanguage(). 38 | 39 | @item 40 | Added new public-API: MP4SetTrackLanguage(). 41 | 42 | @item 43 | Added support for GCC precompiled-headers on various *nix platforms to speed up builds as we are using quite a few C++ headers. 44 | 45 | @item 46 | Enhanced @command{mp4track} to facilitate modification of @{ enabled, inmovie, inpreview, altgroup, volume, width, height, language, hdlrname, udtaname @} properties. 47 | 48 | @item 49 | Added new public-API: MP4GetTrackDurationPerChunk(). 50 | 51 | @item 52 | Added new public-API: MP4SetTrackDurationPerChunk() to override default per-track chunk duration. 53 | 54 | @item 55 | Added new public-API: MP4WriteSampleDependency(). 56 | 57 | @item 58 | Replaced (undocumented) public-API: MP4CreateEx() with MP4CreateProvider(). 59 | 60 | @item 61 | Added new public-API for iTMF Generic functionality. 62 | @end enumerate 63 | -------------------------------------------------------------------------------- /doc/texi/changelog/version-2.0.texi: -------------------------------------------------------------------------------- 1 | @enumerate 2 | @item 3 | Removed deprecated metadata/free-form API and replaced with iTMF Generic and Tags API. 4 | 5 | @item 6 | Added new public-API: MP4SetLogCallback(). 7 | 8 | @end enumerate 9 | -------------------------------------------------------------------------------- /doc/texi/releasenotes/intro.developer.texi: -------------------------------------------------------------------------------- 1 | @quotation Warning 2 | This is a @b{developer} release which includes all the normal pieces of a stable release but is considered @b{unstable}. 3 | The purpose of a developer release is to make available to @value{PROJECT.name} developers features which require collaborative testing. 4 | @end quotation 5 | 6 | -------------------------------------------------------------------------------- /doc/texi/releasenotes/intro.stable.texi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enzo1982/mp4v2/86b5aaf13d03291873608af559fe0399efe898f4/doc/texi/releasenotes/intro.stable.texi -------------------------------------------------------------------------------- /doc/texi/tool/mp4art.texi: -------------------------------------------------------------------------------- 1 | @chapter mp4art 2 | This tool is used to manage iTunes Metadata Cover-art which is typically used to embed an image to a song file. For example, the songs in an album collection might all contain an image of the album cover art. This data is usually found in @samp{.m4a}, @samp{.m4v} and @samp{.mov} files. 3 | 4 | @table @samp 5 | @item --art-any 6 | act on all covr-boxes (default). 7 | Specifies the scope of the action to operate on all, if applicable, covr-boxes. 8 | 9 | @item --art-index IDX 10 | act on covr-box index IDX. 11 | Specifies the scope of the action to operate on single covr-box INDEX. 12 | @end table 13 | 14 | @table @samp 15 | @item --list 16 | list all covr-boxes. 17 | Example output: 18 | 19 | @example 20 | IDX BYTES CRC32 TYPE FILE 21 | ---------------------------------------------------------------------- 22 | 0 173613 710a3ec9 JPEG 01 Life In Technicolor.m4a 23 | 0 173613 710a3ec9 JPEG 02 Cemeteries Of London.m4a 24 | 0 173613 710a3ec9 JPEG 03 Lost!.m4a 25 | 0 173613 710a3ec9 JPEG 04 42.m4a 26 | 0 173613 710a3ec9 JPEG 05 Lovers In Japan _ Reign Of Love.m4a 27 | 0 173613 710a3ec9 JPEG 06 Yes.m4a 28 | 0 173613 710a3ec9 JPEG 07 Viva La Vida.m4a 29 | 0 173613 710a3ec9 JPEG 08 Violet Hill.m4a 30 | 0 173613 710a3ec9 JPEG 09 Strawberry Swing.m4a 31 | 0 173613 710a3ec9 JPEG 10 Death And All His Friends.m4a 32 | @end example 33 | 34 | @item --add IMG 35 | add covr-box from IMG file. 36 | 37 | @item --replace IMG 38 | replace covr-box with IMG file. 39 | 40 | @item --remove 41 | remove covr-box. 42 | 43 | @item --extract 44 | extract covr-box. 45 | This will extract all covr-box data to image files in the format of @samp{BASENAME.art[INDEX].TYPE} . 46 | 47 | Example, add PNG image file: 48 | @example 49 | mp4art --add ACDC.png mysong.m4a 50 | @end example 51 | 52 | Example, extract image files from file: 53 | @example 54 | mp4art --extract mysong.m4a 55 | @end example 56 | 57 | @end table 58 | -------------------------------------------------------------------------------- /doc/texi/tool/mp4chaps.format.texi: -------------------------------------------------------------------------------- 1 | @appendix mp4chaps chapter file formats 2 | @section @emph{Native} @samp{CHPT_FMT_NATIVE} format 3 | A file in the @samp{CHPT_FMT_NATIVE} format contains chapter information and 4 | 5 | @itemize @minus 6 | @item 7 | SHOULD be stored in the form of @samp{.chapters.txt}, e.g. @samp{an-example.chapters.txt} for @samp{an-example.m4a} 8 | @item 9 | MUST use the @emph{default time format} @samp{HH:MM:SS.fff} for time declarations (e.g. @samp{00:13:14.657}; to handle very long running media, the hours field can have more than two digits) 10 | @item 11 | MUST contain at least one @emph{chapter item} (see below) 12 | @end itemize 13 | 14 | Lines in @samp{CHPT_FMT_NATIVE} can have three different purposes: 15 | 16 | @enumerate 17 | @item 18 | chapter items (with start time and title) 19 | @item 20 | metadata items (starting with @samp{## } - a special form of comments containing metadata) 21 | @item 22 | comments (starting with @samp{#}) 23 | @end enumerate 24 | 25 | @subsection Chapter items 26 | 27 | Chapter items MUST be specified in the following format: 28 | 29 | @example 30 | 31 | @end example 32 | 33 | where 34 | 35 | @itemize @minus 36 | @item 37 | @samp{<start time>} is the start time of a chapter specified in the @emph{default time format} 38 | @item 39 | followed by ONE @samp{ } (space) 40 | @item 41 | @samp{<title>} contains printable UTF-8 encoded characters without line breaks 42 | @end itemize 43 | 44 | @subsection Metadata items 45 | 46 | Metadata items are OPTIONAL, can be used to embed additional information and are specified in the following format: 47 | 48 | @example 49 | ## <key>: <value> 50 | @end example 51 | 52 | Metadata items: 53 | 54 | @itemize @minus 55 | @item 56 | MUST start with @samp{## } 57 | @item 58 | @samp{<key>} SHOULD be one of the following values and MUST use the dasherized syntax (all lowercase, uses hyphens as word separators): 59 | @itemize @minus 60 | @item 61 | @samp{album-artist} - the album artist as string 62 | @item 63 | @samp{album} - the album name as string 64 | @item 65 | @samp{artist} - the artist as string 66 | @item 67 | @samp{title} - the work title as string 68 | @item 69 | @samp{total-duration} - the total duration of the file in the @emph{default time format} 70 | @end itemize 71 | @item 72 | followed by ONE @samp{:} (colon) 73 | @item 74 | @samp{<value>} contains printable UTF-8 encoded characters without line breaks 75 | @end itemize 76 | 77 | @subsection Comments 78 | 79 | Comments are OPTIONAL, may contain any additional textual information to enrich the content and are specified in the following format: 80 | 81 | @example 82 | # <additional information> 83 | @end example 84 | 85 | Comments: 86 | 87 | @itemize @minus 88 | @item 89 | MUST start with @samp{#} 90 | @item 91 | SHOULD NOT start with @samp{## } to prevent being mixed up with @emph{metadata items} 92 | @end itemize 93 | -------------------------------------------------------------------------------- /doc/texi/tool/mp4chaps.texi: -------------------------------------------------------------------------------- 1 | @chapter mp4chaps 2 | This tool is used to manage mp4 chapter information, which is used to embed named seekpoints into a file, for example to identify the start of individual songs in an album or chapters in an audiobook. 3 | 4 | @table @samp 5 | @item --chapter-any 6 | act on any chapter type (default). 7 | Specifies the scope of the action to operate on all, if applicable, chapter types. 8 | 9 | @item --chapter-qt 10 | act on QuickTime chapters. 11 | Specifies the scope of the action to operate on QuickTime chapters. 12 | 13 | @item --chapter-nero 14 | act on Nero chapters. 15 | Specifies the scope of the action to operate on Nero chapters. 16 | @end table 17 | 18 | @table @samp 19 | @item --list 20 | list available chapters. 21 | Example output: 22 | 23 | @example 24 | QuickTime Chapters of "Daft Punk - Human After All.m4a" 25 | Chapter #001 - 00:00:00.000 - "Human After All" 26 | Chapter #002 - 00:05:19.006 - "The Prime Time of Your Life" 27 | Chapter #003 - 00:09:42.379 - "Robot Rock" 28 | Chapter #004 - 00:14:30.139 - "Steam Machine" 29 | Chapter #005 - 00:19:50.939 - "Make Love" 30 | Chapter #006 - 00:24:40.939 - "The Brainwasher" 31 | Chapter #007 - 00:28:49.179 - "On/Off" 32 | Chapter #008 - 00:29:08.512 - "Television Rules The Nation" 33 | Chapter #009 - 00:33:56.245 - "Technologic" 34 | Chapter #010 - 00:38:40.605 - "Emotion" 35 | @end example 36 | 37 | @item --convert 38 | convert available chapters. 39 | 40 | @item --every NUM 41 | create chapters every NUM seconds. 42 | 43 | @item --export 44 | export chapters to mp4file.chapters.txt. 45 | 46 | @item --format-common 47 | export chapters in native format (default). 48 | See Appendix A for a description of the different chapter file formats. 49 | 50 | @item --format-common 51 | export chapters in common format. 52 | See Appendix A for a description of the different chapter file formats. 53 | 54 | @item --import 55 | import chapters from mp4file.chapters.txt. 56 | 57 | @item --remove 58 | remove all chapters. 59 | 60 | @end table 61 | -------------------------------------------------------------------------------- /doc/texi/tool/mp4file.texi: -------------------------------------------------------------------------------- 1 | @chapter mp4file 2 | 3 | @table @samp 4 | @item --list 5 | list (summary information). 6 | This will produce brief report when summarizing each mp4 file. 7 | @b{BRAND} shows the file's main brand identifier. 8 | @b{COMPAT} shows additional brands for which the file purports to be comaptible with. 9 | @b{SIZING} displays if the file has 64-bit extensions of any kind, otherwise 32-bit. 10 | Example output: 11 | @example 12 | BRAND COMPAT SIZING FILE 13 | ---------------------------------------------------------------------- 14 | M4A M4A,isom,mp42 32-bit Song.m4a 15 | mp42 isom,mp42 32-bit Movie1.m4v 16 | mp42 isom,mp42 32-bit Movie2.m4v 17 | @end example 18 | 19 | @item --optimize 20 | optimize mp4 structure. 21 | This will rewrite the entire mp4 file which, if needed, will clean up 22 | any unused (free) sections, and re-order the atoms in a manner somewhat 23 | consistent with the best-practices described in the ISO base media file 24 | specification. 25 | 26 | @item --dump 27 | dump mp4 structure in human-readable format. 28 | An ASCII dump of mp4 atoms is printed to stdout. This action is heavily 29 | influenced by @samp{--debug} option. 30 | 31 | Example, list some files: 32 | @example 33 | mp4file --list *.mp4 *.m4a *.m4v 34 | @end example 35 | 36 | Example, dump a file with more than usual debugging information: 37 | @example 38 | mp4file -dd --dump movie.m4v 39 | @end example 40 | @end table 41 | -------------------------------------------------------------------------------- /example/callbacks/callbacks.c: -------------------------------------------------------------------------------- 1 | /* This example makes use of the MP4IOCallbacks API to use custom input/output 2 | * routines. 3 | */ 4 | 5 | #include <mp4v2/mp4v2.h> 6 | #include <stdio.h> 7 | 8 | /*****************************************************************************/ 9 | 10 | static int my_seek( void* handle, int64_t pos ) 11 | { 12 | if( fseeko( (FILE*)handle, pos, SEEK_SET ) != 0) 13 | return -1; 14 | 15 | return 0; 16 | } 17 | 18 | static int my_read( void* handle, void* buffer, int64_t size, int64_t* nin ) 19 | { 20 | if( fread( buffer, size, 1, (FILE*)handle ) != 1) 21 | return -1; 22 | 23 | *nin = size; 24 | return 0; 25 | } 26 | 27 | static int64_t my_size( void* handle ) 28 | { 29 | int64_t pos = ftello( (FILE*)handle ); 30 | 31 | if( fseeko( (FILE*)handle, 0, SEEK_END ) != 0 ) 32 | return -1; 33 | 34 | int64_t size = ftello( (FILE*)handle ); 35 | 36 | if( fseeko( (FILE*)handle, pos, SEEK_SET ) != 0 ) 37 | return -1; 38 | 39 | return size; 40 | } 41 | 42 | /*****************************************************************************/ 43 | 44 | int main( int argc, char** argv ) 45 | { 46 | if( argc != 2 ) { 47 | printf( "usage: %s file.mp4\n", argv[0] ); 48 | return 1; 49 | } 50 | 51 | /* populate data structure with custom functions. 52 | * safe to put on stack as it will be immediately copied internally. 53 | */ 54 | MP4IOCallbacks callbacks = { 0 }; 55 | 56 | callbacks.seek = my_seek; 57 | callbacks.read = my_read; 58 | callbacks.size = my_size; 59 | 60 | /* open file for read */ 61 | FILE* handle = fopen( argv[1], "rb" ); 62 | if( handle == NULL ) { 63 | printf( "fopen failed\n" ); 64 | return 1; 65 | } 66 | 67 | MP4FileHandle file = MP4ReadCallbacks( &callbacks, handle ); 68 | if( file == MP4_INVALID_FILE_HANDLE ) { 69 | printf( "MP4ReadCallbacks failed\n" ); 70 | return 1; 71 | } 72 | 73 | /* dump file contents */ 74 | if( !MP4Dump( file, 0 )) 75 | printf( "MP4Dump failed\n" ); 76 | 77 | /* cleanup and close */ 78 | MP4Close( file, 0 ); 79 | 80 | fclose( handle ); 81 | 82 | return 0; 83 | } 84 | -------------------------------------------------------------------------------- /include/mp4v2/mp4v2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The contents of this file are subject to the Mozilla Public 3 | * License Version 1.1 (the "License"); you may not use this file 4 | * except in compliance with the License. You may obtain a copy of 5 | * the License at http://www.mozilla.org/MPL/ 6 | * 7 | * Software distributed under the License is distributed on an "AS 8 | * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 9 | * implied. See the License for the specific language governing 10 | * rights and limitations under the License. 11 | * 12 | * The Original Code is MPEG4IP. 13 | * 14 | * The Initial Developer of the Original Code is Cisco Systems Inc. 15 | * Portions created by Cisco Systems Inc. are 16 | * Copyright (C) Cisco Systems Inc. 2001 - 2005. All Rights Reserved. 17 | * 18 | * Contributor(s): 19 | * Dave Mackie, dmackie@cisco.com 20 | * Alix Marchandise-Franquet, alix@cisco.com 21 | * Bill May, wmay@cisco.com 22 | * Kona Blend, kona8lend@gmail.com 23 | */ 24 | #ifndef MP4V2_MP4V2_H 25 | #define MP4V2_MP4V2_H 26 | 27 | /*****************************************************************************/ 28 | 29 | #include <mp4v2/platform.h> 30 | #include <mp4v2/project.h> 31 | 32 | /*****************************************************************************/ 33 | 34 | /* exploit C++ ability of default values for function parameters */ 35 | #if defined( DEFAULT ) 36 | # define __MP4V2_SAVE_DEFAULT DEFAULT 37 | #endif 38 | #undef DEFAULT 39 | #if defined( __cplusplus ) 40 | # define DEFAULT(x) =x 41 | #else 42 | # define DEFAULT(x) 43 | #endif 44 | 45 | #ifdef __cplusplus 46 | extern "C" { 47 | #endif 48 | 49 | /*****************************************************************************/ 50 | 51 | #include <mp4v2/general.h> 52 | #include <mp4v2/file.h> 53 | #include <mp4v2/file_prop.h> 54 | #include <mp4v2/track.h> 55 | #include <mp4v2/track_prop.h> 56 | #include <mp4v2/sample.h> 57 | #include <mp4v2/chapter.h> 58 | #include <mp4v2/itmf_generic.h> 59 | #include <mp4v2/itmf_tags.h> 60 | #include <mp4v2/streaming.h> 61 | #include <mp4v2/isma.h> 62 | 63 | /*****************************************************************************/ 64 | 65 | /* restore macro DEFAULT to state prior to mp4v2 headers */ 66 | #undef DEFAULT 67 | #if defined( __MP4V2_SAVE_DEFAULT ) 68 | # define DEFAULT __MP4V2_SAVE_DEFAULT 69 | #endif 70 | 71 | #ifdef __cplusplus 72 | } // extern "C" 73 | #endif 74 | 75 | /*****************************************************************************/ 76 | 77 | #endif /* MP4V2_MP4V2_H */ 78 | -------------------------------------------------------------------------------- /include/mp4v2/platform.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The contents of this file are subject to the Mozilla Public 3 | * License Version 1.1 (the "License"); you may not use this file 4 | * except in compliance with the License. You may obtain a copy of 5 | * the License at http://www.mozilla.org/MPL/ 6 | * 7 | * Software distributed under the License is distributed on an "AS 8 | * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 9 | * implied. See the License for the specific language governing 10 | * rights and limitations under the License. 11 | * 12 | * The Original Code is MP4v2. 13 | * 14 | * The Initial Developer of the Original Code is Kona Blend. 15 | * Portions created by Kona Blend are Copyright (C) 2008. 16 | * All Rights Reserved. 17 | * 18 | * Contributor(s): 19 | * Kona Blend, kona8lend@gmail.com 20 | */ 21 | #ifndef MP4V2_PLATFORM_H 22 | #define MP4V2_PLATFORM_H 23 | 24 | /*****************************************************************************/ 25 | 26 | #include <stddef.h> 27 | #include <stdio.h> 28 | #include <stdarg.h> 29 | #include <stdint.h> 30 | 31 | #if defined( _WIN32 ) || defined( __MINGW32__ ) 32 | # if defined( MP4V2_EXPORTS ) 33 | # define MP4V2_EXPORT __declspec(dllexport) 34 | # elif defined( MP4V2_USE_DLL_IMPORT ) || !defined( MP4V2_USE_STATIC_LIB ) 35 | # define MP4V2_EXPORT __declspec(dllimport) 36 | # else 37 | # define MP4V2_EXPORT 38 | # endif 39 | #else 40 | # define MP4V2_EXPORT __attribute__((visibility("default"))) 41 | #endif 42 | 43 | #if defined( __GNUC__ ) 44 | # define MP4V2_DEPRECATED __attribute__((deprecated)) 45 | #else 46 | # define MP4V2_DEPRECATED 47 | #endif 48 | 49 | /****************************************************************************** 50 | * 51 | * TODO-KB: cleanup -- absolutely no need for a C-API to fuss with reserved 52 | * C++ keywords. This will involve changing the public interface and current 53 | * plan of action: 54 | * 55 | * typdef enum { 56 | * mp4_false, 57 | * mp4_true, 58 | * } mp4_bool_t; 59 | * 60 | * followed by updating all public signatures and implementation. 61 | */ 62 | 63 | #ifndef FALSE 64 | #define FALSE 0 65 | #endif 66 | 67 | #ifndef TRUE 68 | #define TRUE 1 69 | #endif 70 | 71 | #if !defined( __cplusplus ) 72 | #ifndef bool 73 | #if SIZEOF_BOOL == 8 74 | typedef uint64_t bool; 75 | #else 76 | #if SIZEOF_BOOL == 4 77 | typedef uint32_t bool; 78 | #else 79 | #if SIZEOF_BOOL == 2 80 | typedef uint16_t bool; 81 | #else 82 | typedef unsigned char bool; 83 | #endif 84 | #endif 85 | #endif 86 | #ifndef false 87 | #define false FALSE 88 | #endif 89 | #ifndef true 90 | #define true TRUE 91 | #endif 92 | #endif 93 | #endif 94 | 95 | /*****************************************************************************/ 96 | 97 | #endif /* MP4V2_PLATFORM_H */ 98 | -------------------------------------------------------------------------------- /include/mp4v2/project.h.in: -------------------------------------------------------------------------------- 1 | #ifndef MP4V2_PROJECT_H 2 | #define MP4V2_PROJECT_H 3 | 4 | /*****************************************************************************/ 5 | 6 | #define MP4V2_PROJECT_name "@PROJECT_name@" 7 | #define MP4V2_PROJECT_name_lower "@PROJECT_name_lower@" 8 | #define MP4V2_PROJECT_name_upper "@PROJECT_name_upper@" 9 | #define MP4V2_PROJECT_name_formal "@PROJECT_name_formal@" 10 | #define MP4V2_PROJECT_url_website "@PROJECT_url_website@" 11 | #define MP4V2_PROJECT_url_downloads "@PROJECT_url_downloads@" 12 | #define MP4V2_PROJECT_url_discussion "@PROJECT_url_discussion@" 13 | #define MP4V2_PROJECT_url_bugreport "@PROJECT_url_bugreport@" 14 | #define MP4V2_PROJECT_support "@PROJECT_support@" 15 | #define MP4V2_PROJECT_version "@PROJECT_version@" 16 | #define MP4V2_PROJECT_version_hex @PROJECT_version_hex@ 17 | #define MP4V2_PROJECT_version_major @PROJECT_version_major@ 18 | #define MP4V2_PROJECT_version_minor @PROJECT_version_minor@ 19 | #define MP4V2_PROJECT_version_point @PROJECT_version_point@ 20 | #define MP4V2_PROJECT_repo_url "@PROJECT_repo_url@" 21 | #define MP4V2_PROJECT_build "@PROJECT_build@" 22 | 23 | /*****************************************************************************/ 24 | 25 | #endif /* MP4V2_PROJECT_H */ 26 | -------------------------------------------------------------------------------- /libplatform/config.h.cmake: -------------------------------------------------------------------------------- 1 | /* Define to 1 if you have the <inttypes.h> header file. */ 2 | #cmakedefine HAVE_INTTYPES_H 1 3 | 4 | /* Define to 1 if you have the <stdint.h> header file. */ 5 | #cmakedefine HAVE_STDINT_H 1 6 | 7 | /* Define to 1 if you have the <stdio.h> header file. */ 8 | #cmakedefine HAVE_STDIO_H 1 9 | 10 | /* Define to 1 if you have the <stdlib.h> header file. */ 11 | #cmakedefine HAVE_STDLIB_H 1 12 | 13 | /* Define to 1 if you have the <string.h> header file. */ 14 | #cmakedefine HAVE_STRING_H 1 15 | 16 | /* Define to 1 if you have the <sys/stat.h> header file. */ 17 | #cmakedefine HAVE_SYS_STAT_H 1 18 | 19 | /* Define to 1 if you have the <sys/types.h> header file. */ 20 | #cmakedefine HAVE_SYS_TYPES_H 1 21 | 22 | /* Define to 1 if you have the <unistd.h> header file. */ 23 | #cmakedefine HAVE_UNISTD_H 1 24 | 25 | /* libtool defines DLL_EXPORT for windows dll 26 | builds, but we use MP4V2_EXPORTS instead. */ 27 | #ifdef DLL_EXPORT 28 | # define MP4V2_EXPORTS 29 | #else 30 | # define MP4V2_USE_STATIC_LIB 31 | #endif 32 | 33 | /* Define to 1 if LFS should be activated */ 34 | #cmakedefine NEED_LFS_ACTIVATION 1 35 | 36 | /* Name of package */ 37 | #define PACKAGE "@PROJECT_name_lower@" 38 | 39 | /* Define to the address where bug reports for this package should be sent. */ 40 | #define PACKAGE_BUGREPORT "@PROJECT_email@" 41 | 42 | /* Define to the full name of this package. */ 43 | #define PACKAGE_NAME "@PROJECT_name@" 44 | 45 | /* Define to the full name and version of this package. */ 46 | #define PACKAGE_STRING "@PROJECT_name_formal@" 47 | 48 | /* Define to the one symbol short name of this package. */ 49 | #define PACKAGE_TARNAME "@PROJECT_name_lower@" 50 | 51 | /* Define to the home page for this package. */ 52 | #define PACKAGE_URL "@PROJECT_url_website@" 53 | 54 | /* Define to the version of this package. */ 55 | #define PACKAGE_VERSION "@PROJECT_version@" 56 | 57 | /* Version number of package */ 58 | #define VERSION "@PROJECT_version@" 59 | -------------------------------------------------------------------------------- /libplatform/endian.h: -------------------------------------------------------------------------------- 1 | #ifndef MP4V2_PLATFORM_ENDIAN_H 2 | #define MP4V2_PLATFORM_ENDIAN_H 3 | 4 | /////////////////////////////////////////////////////////////////////////////// 5 | 6 | #define MP4V2_BYTESWAP_16(x) \ 7 | mp4v2::platform::uint16_t( ((mp4v2::platform::uint16_t(x) & 0xff00U) >> 8) \ 8 | | ((mp4v2::platform::uint16_t(x) & 0x00ffU) << 8) ) 9 | 10 | #define MP4V2_BYTESWAP_32(x) \ 11 | mp4v2::platform::uint32_t( ((mp4v2::platform::uint32_t(x) & 0xff000000U) >> 24) \ 12 | | ((mp4v2::platform::uint32_t(x) & 0x00ff0000U) >> 8) \ 13 | | ((mp4v2::platform::uint32_t(x) & 0x0000ff00U) << 8) \ 14 | | ((mp4v2::platform::uint32_t(x) & 0x000000ffU) << 24) ) 15 | 16 | #define MP4V2_BYTESWAP_64(x) \ 17 | mp4v2::platform::uint64_t( ((mp4v2::platform::uint64_t(x) & 0xff00000000000000ULL) >> 56) \ 18 | | ((mp4v2::platform::uint64_t(x) & 0x00ff000000000000ULL) >> 40) \ 19 | | ((mp4v2::platform::uint64_t(x) & 0x0000ff0000000000ULL) >> 24) \ 20 | | ((mp4v2::platform::uint64_t(x) & 0x000000ff00000000ULL) >> 8) \ 21 | | ((mp4v2::platform::uint64_t(x) & 0x00000000ff000000ULL) << 8) \ 22 | | ((mp4v2::platform::uint64_t(x) & 0x0000000000ff0000ULL) << 24) \ 23 | | ((mp4v2::platform::uint64_t(x) & 0x000000000000ff00ULL) << 40) \ 24 | | ((mp4v2::platform::uint64_t(x) & 0x00000000000000ffULL) << 56) ) 25 | 26 | /////////////////////////////////////////////////////////////////////////////// 27 | 28 | #if defined( __BIG_ENDIAN__ ) 29 | # define MP4V2_HTONS(x) (x) 30 | # define MP4V2_HTONL(x) (x) 31 | # define MP4V2_NTOHS(x) (x) 32 | # define MP4V2_NTOHL(x) (x) 33 | #else 34 | # define MP4V2_HTONS(x) MP4V2_BYTESWAP_16(x) 35 | # define MP4V2_HTONL(x) MP4V2_BYTESWAP_32(x) 36 | # define MP4V2_NTOHS(x) MP4V2_BYTESWAP_16(x) 37 | # define MP4V2_NTOHL(x) MP4V2_BYTESWAP_32(x) 38 | #endif 39 | 40 | /////////////////////////////////////////////////////////////////////////////// 41 | 42 | #endif // MP4V2_PLATFORM_ENDIAN_H 43 | -------------------------------------------------------------------------------- /libplatform/impl.h: -------------------------------------------------------------------------------- 1 | #ifndef MP4V2_PLATFORM_IMPL_H 2 | #define MP4V2_PLATFORM_IMPL_H 3 | 4 | /////////////////////////////////////////////////////////////////////////////// 5 | 6 | #include "libplatform/platform.h" 7 | #if defined _WIN32 8 | #include "libplatform/platform_win32_impl.h" 9 | #endif 10 | 11 | /////////////////////////////////////////////////////////////////////////////// 12 | 13 | #endif // MP4V2_PLATFORM_IMPL_H 14 | -------------------------------------------------------------------------------- /libplatform/io/FileSystem_posix.cpp: -------------------------------------------------------------------------------- 1 | #include "libplatform/impl.h" 2 | #include <sys/stat.h> 3 | 4 | namespace mp4v2 { namespace platform { namespace io { 5 | 6 | /////////////////////////////////////////////////////////////////////////////// 7 | 8 | bool 9 | FileSystem::exists( const std::string& path_ ) 10 | { 11 | struct stat buf; 12 | return stat( path_.c_str(), &buf ) == 0; 13 | } 14 | 15 | /////////////////////////////////////////////////////////////////////////////// 16 | 17 | bool 18 | FileSystem::isDirectory( const std::string& path_ ) 19 | { 20 | struct stat buf; 21 | if( stat( path_.c_str(), &buf )) 22 | return false; 23 | return S_ISDIR( buf.st_mode ); 24 | } 25 | 26 | /////////////////////////////////////////////////////////////////////////////// 27 | 28 | bool 29 | FileSystem::isFile( const std::string& path_ ) 30 | { 31 | struct stat buf; 32 | if( stat( path_.c_str(), &buf )) 33 | return false; 34 | return S_ISREG( buf.st_mode ); 35 | } 36 | 37 | /////////////////////////////////////////////////////////////////////////////// 38 | 39 | bool 40 | FileSystem::getFileSize( const std::string& path_, File::Size& size_ ) 41 | { 42 | size_ = 0; 43 | struct stat buf; 44 | if( stat( path_.c_str(), &buf )) 45 | return true; 46 | size_ = buf.st_size; 47 | return false; 48 | } 49 | 50 | /////////////////////////////////////////////////////////////////////////////// 51 | 52 | bool 53 | FileSystem::rename( const std::string& from, const std::string& to ) 54 | { 55 | return ::rename( from.c_str(), to.c_str() ) != 0; 56 | } 57 | 58 | /////////////////////////////////////////////////////////////////////////////// 59 | 60 | string FileSystem::DIR_SEPARATOR = "/"; 61 | string FileSystem::PATH_SEPARATOR = ":"; 62 | 63 | /////////////////////////////////////////////////////////////////////////////// 64 | 65 | }}} // namespace mp4v2::platform::io 66 | -------------------------------------------------------------------------------- /libplatform/number/random.h: -------------------------------------------------------------------------------- 1 | #ifndef MP4V2_PLATFORM_NUMBER_RANDOM_H 2 | #define MP4V2_PLATFORM_NUMBER_RANDOM_H 3 | 4 | namespace mp4v2 { namespace platform { namespace number { 5 | 6 | /////////////////////////////////////////////////////////////////////////////// 7 | 8 | /// Generate 32-bit pseudo-random number. 9 | uint32_t random32(); 10 | 11 | /// Seed pseudo-random number generator. 12 | void srandom( uint32_t ); 13 | 14 | /////////////////////////////////////////////////////////////////////////////// 15 | 16 | }}} // namespace mp4v2::platform::number 17 | 18 | #endif // MP4V2_PLATFORM_NUMBER_RANDOM_H 19 | -------------------------------------------------------------------------------- /libplatform/number/random_posix.cpp: -------------------------------------------------------------------------------- 1 | #include "libplatform/impl.h" 2 | #include <stdlib.h> 3 | 4 | namespace mp4v2 { namespace platform { namespace number { 5 | 6 | /////////////////////////////////////////////////////////////////////////////// 7 | 8 | uint32_t 9 | random32() 10 | { 11 | return uint32_t( ::random() ); 12 | } 13 | 14 | /////////////////////////////////////////////////////////////////////////////// 15 | 16 | void 17 | srandom( uint32_t seed ) 18 | { 19 | ::srandom( seed ); 20 | } 21 | 22 | /////////////////////////////////////////////////////////////////////////////// 23 | 24 | }}} // namespace mp4v2::platform::time 25 | -------------------------------------------------------------------------------- /libplatform/number/random_win32.cpp: -------------------------------------------------------------------------------- 1 | #include "libplatform/impl.h" 2 | #include <stdlib.h> 3 | 4 | namespace mp4v2 { namespace platform { namespace number { 5 | 6 | /////////////////////////////////////////////////////////////////////////////// 7 | 8 | uint32_t 9 | random32() 10 | { 11 | return uint32_t( ::rand() << 16 | ::rand() ); 12 | } 13 | 14 | /////////////////////////////////////////////////////////////////////////////// 15 | 16 | void 17 | srandom( uint32_t seed ) 18 | { 19 | ::srand( seed ); 20 | } 21 | 22 | /////////////////////////////////////////////////////////////////////////////// 23 | 24 | }}} // namespace mp4v2::platform::time 25 | -------------------------------------------------------------------------------- /libplatform/platform.h: -------------------------------------------------------------------------------- 1 | #ifndef MP4V2_PLATFORM_PLATFORM_H 2 | #define MP4V2_PLATFORM_PLATFORM_H 3 | 4 | /// @namespace mp4v2::platform (private) Platform abstraction. 5 | /// <b>WARNING: THIS IS A PRIVATE NAMESPACE. NOT FOR PUBLIC CONSUMPTION.</b> 6 | /// 7 | /// This namespace implements platform abstractions that are useful for 8 | /// keeping the code base portable. 9 | 10 | /// @namespace mp4v2::platform::io (private) I/O. 11 | /// <b>WARNING: THIS IS A PRIVATE NAMESPACE. NOT FOR PUBLIC CONSUMPTION.</b> 12 | 13 | /// @namespace mp4v2::platform::number (private) Number. 14 | /// <b>WARNING: THIS IS A PRIVATE NAMESPACE. NOT FOR PUBLIC CONSUMPTION.</b> 15 | 16 | /// @namespace mp4v2::platform::sys (private) System. 17 | /// <b>WARNING: THIS IS A PRIVATE NAMESPACE. NOT FOR PUBLIC CONSUMPTION.</b> 18 | 19 | /////////////////////////////////////////////////////////////////////////////// 20 | 21 | #if defined( _WIN32 ) 22 | # include "libplatform/platform_win32.h" 23 | #else 24 | # include "libplatform/platform_posix.h" 25 | #endif 26 | 27 | /////////////////////////////////////////////////////////////////////////////// 28 | 29 | #include "libplatform/warning.h" 30 | #include "libplatform/endian.h" 31 | 32 | #include "libplatform/io/File.h" 33 | #include "libplatform/io/FileSystem.h" 34 | 35 | #include "libplatform/number/random.h" 36 | #include "libplatform/prog/option.h" 37 | #include "libplatform/sys/error.h" 38 | #include "libplatform/time/time.h" 39 | 40 | /////////////////////////////////////////////////////////////////////////////// 41 | 42 | #endif // MP4V2_PLATFORM_PLATFORM_H 43 | -------------------------------------------------------------------------------- /libplatform/platform_base.h: -------------------------------------------------------------------------------- 1 | #ifndef MP4V2_PLATFORM_BASE_H 2 | #define MP4V2_PLATFORM_BASE_H 3 | 4 | /////////////////////////////////////////////////////////////////////////////// 5 | 6 | #include <fstream> 7 | #include <iomanip> 8 | #include <iostream> 9 | #include <limits> 10 | #include <list> 11 | #include <locale> 12 | #include <map> 13 | #include <set> 14 | #include <sstream> 15 | #include <string> 16 | #include <vector> 17 | 18 | #include <cassert> 19 | #include <cctype> 20 | #include <cerrno> 21 | #include <climits> 22 | #include <cmath> 23 | #include <cstdarg> 24 | #include <cstddef> 25 | #include <cstdio> 26 | #include <cstdlib> 27 | #include <cstring> 28 | #include <ctime> 29 | #include <cwchar> 30 | #include <cwctype> 31 | 32 | /////////////////////////////////////////////////////////////////////////////// 33 | 34 | #endif // MP4V2_PLATFORM_BASE_H 35 | -------------------------------------------------------------------------------- /libplatform/platform_posix.h: -------------------------------------------------------------------------------- 1 | #ifndef MP4V2_PLATFORM_POSIX_H 2 | #define MP4V2_PLATFORM_POSIX_H 3 | 4 | /////////////////////////////////////////////////////////////////////////////// 5 | 6 | #include "libplatform/config.h" 7 | 8 | /////////////////////////////////////////////////////////////////////////////// 9 | 10 | // constant macros are not usually used with C++ so the standard mechanism to 11 | // activate it is to define before stdint.h 12 | #ifndef __STDC_CONSTANT_MACROS 13 | # define __STDC_CONSTANT_MACROS 14 | #endif 15 | 16 | // format macros are not usually used with C++ so the standard mechanism to 17 | // activate it is to define before inttypes.h 18 | #ifndef __STDC_FORMAT_MACROS 19 | # define __STDC_FORMAT_MACROS 20 | #endif 21 | 22 | #ifdef NEED_LFS_ACTIVATION 23 | # ifndef _LARGEFILE_SOURCE 24 | # define _LARGEFILE_SOURCE 25 | # define _FILE_OFFSET_BITS 64 26 | # endif 27 | #endif 28 | 29 | /////////////////////////////////////////////////////////////////////////////// 30 | 31 | #include "libplatform/platform_base.h" 32 | #include <inttypes.h> 33 | #include <stdint.h> 34 | #include <fcntl.h> 35 | #include <unistd.h> 36 | 37 | #include <mp4v2/mp4v2.h> 38 | 39 | /////////////////////////////////////////////////////////////////////////////// 40 | 41 | namespace mp4v2 { namespace platform { 42 | using namespace std; 43 | 44 | using ::int8_t; 45 | using ::int16_t; 46 | using ::int32_t; 47 | using ::int64_t; 48 | 49 | using ::uint8_t; 50 | using ::uint16_t; 51 | using ::uint32_t; 52 | using ::uint64_t; 53 | }} // namespace mp4v2::platform 54 | 55 | /////////////////////////////////////////////////////////////////////////////// 56 | 57 | // ARM seems to require integer instructions operands to have 4-byte alignment 58 | // so we set this macro to for some int<->string code to manually copy string 59 | // bytes into an int which aligns it. This is much easier than trying to 60 | // align pertinent string data (constants) from in text sections. 61 | #if defined( __arm__ ) 62 | # define MP4V2_INTSTRING_ALIGNMENT 1 63 | #else 64 | # undef MP4V2_INTSTRING_ALIGNMENT 65 | #endif 66 | 67 | /////////////////////////////////////////////////////////////////////////////// 68 | 69 | #endif // MP4V2_PLATFORM_POSIX_H 70 | -------------------------------------------------------------------------------- /libplatform/platform_win32_impl.h: -------------------------------------------------------------------------------- 1 | // Note that we have a separate platform_win32_impl.h to deal with the fact that windows.h defines a macro 2 | // called FindAtom, which mp4v2 also defines. In older versions of visual studio, this actually causes 3 | // some pretty seriously issues with naming collisions and the defined macros (think infamous min/max macro 4 | // of windows.h vs stdc++'s min/max template functions) 5 | #include <windows.h> 6 | 7 | /////////////////////////////////////////////////////////////////////////////// 8 | 9 | namespace mp4v2 { namespace platform { namespace win32 { 10 | 11 | class Utf8ToFilename 12 | { 13 | public: 14 | Utf8ToFilename( const string &utf8string ); 15 | ~Utf8ToFilename( ); 16 | 17 | bool IsUTF16Valid( ) const; 18 | 19 | operator LPCWSTR( ) const { return _wideCharString; } 20 | operator LPWSTR( ) const { return _wideCharString; } 21 | 22 | private: 23 | Utf8ToFilename ( const Utf8ToFilename &src ); 24 | Utf8ToFilename &operator= ( const Utf8ToFilename &src ); 25 | 26 | wchar_t *ConvertToUTF16 ( const string &utf8 ); 27 | 28 | static int ConvertToUTF16Buf ( const char *utf8, 29 | wchar_t *utf16_buf, 30 | size_t num_bytes ); 31 | 32 | static bool HasPrefix ( const string &utf8string ); 33 | static string StripPrefix ( const string &utf8string ); 34 | 35 | static int IsAbsolute ( const string &utf8string ); 36 | 37 | static int IsPathSeparator ( char c ); 38 | 39 | static int IsUncPath ( const string &utf8string ); 40 | 41 | static const uint8_t *Utf8DecodeChar ( 42 | const uint8_t *utf8_char, 43 | size_t num_bytes, 44 | wchar_t *utf16, 45 | int *invalid 46 | ); 47 | 48 | static size_t Utf8LenFromUcs4 ( uint32_t ucs4 ); 49 | 50 | static uint8_t Utf8NumOctets ( uint8_t utf8_first_byte ); 51 | 52 | /** 53 | * The UTF-8 encoding of the filename actually used 54 | */ 55 | string _utf8; 56 | 57 | /** 58 | * The UTF-16 encoding of the filename actually used 59 | */ 60 | wchar_t* _wideCharString; 61 | 62 | public: 63 | 64 | /** 65 | * Accessor for @p _utf8 66 | */ 67 | const string& utf8; 68 | }; 69 | 70 | }}} // namespace mp4v2::platform::win32 71 | -------------------------------------------------------------------------------- /libplatform/sys/error.cpp: -------------------------------------------------------------------------------- 1 | #include "libplatform/impl.h" 2 | 3 | namespace mp4v2 { namespace platform { namespace sys { 4 | 5 | /////////////////////////////////////////////////////////////////////////////// 6 | 7 | const char* 8 | getErrorStr( int errno_ ) 9 | { 10 | return std::strerror( errno_ ); 11 | } 12 | 13 | /////////////////////////////////////////////////////////////////////////////// 14 | 15 | int 16 | getLastError() 17 | { 18 | return errno; 19 | } 20 | 21 | /////////////////////////////////////////////////////////////////////////////// 22 | 23 | const char* 24 | getLastErrorStr() 25 | { 26 | return strerror( errno ); 27 | } 28 | 29 | /////////////////////////////////////////////////////////////////////////////// 30 | 31 | }}} // namespace mp4v2::platform::sys 32 | -------------------------------------------------------------------------------- /libplatform/sys/error.h: -------------------------------------------------------------------------------- 1 | #ifndef MP4V2_PLATFORM_SYS_ERROR_H 2 | #define MP4V2_PLATFORM_SYS_ERROR_H 3 | 4 | namespace mp4v2 { namespace platform { namespace sys { 5 | 6 | /////////////////////////////////////////////////////////////////////////////// 7 | 8 | int getLastError ( ); 9 | MP4V2_EXPORT const char* getLastErrorStr ( ); 10 | const char* getErrorStr ( int ); 11 | 12 | /////////////////////////////////////////////////////////////////////////////// 13 | 14 | }}} // namespace mp4v2::platform::sys 15 | 16 | #endif // MP4V2_PLATFORM_SYS_ERROR_H 17 | -------------------------------------------------------------------------------- /libplatform/time/time.cpp: -------------------------------------------------------------------------------- 1 | #include "libplatform/impl.h" 2 | 3 | namespace mp4v2 { namespace platform { namespace time { 4 | 5 | /////////////////////////////////////////////////////////////////////////////// 6 | 7 | seconds_t 8 | getLocalTimeSeconds() 9 | { 10 | return getLocalTimeMilliseconds() / 1000; 11 | } 12 | 13 | /////////////////////////////////////////////////////////////////////////////// 14 | 15 | }}} // namespace mp4v2::platform::time 16 | -------------------------------------------------------------------------------- /libplatform/time/time.h: -------------------------------------------------------------------------------- 1 | #ifndef MP4V2_PLATFORM_TIME_TIME_H 2 | #define MP4V2_PLATFORM_TIME_TIME_H 3 | 4 | /// @namespace mp4v2::platform::time (private) Time. 5 | /// <b>WARNING: THIS IS A PRIVATE NAMESPACE. NOT FOR PUBLIC CONSUMPTION.</b> 6 | namespace mp4v2 { namespace platform { namespace time { 7 | 8 | //! type used to represent milliseconds 9 | typedef int64_t milliseconds_t; 10 | 11 | //! type used to represent seconds 12 | typedef int64_t seconds_t; 13 | 14 | /////////////////////////////////////////////////////////////////////////////// 15 | //! 16 | //! Get local-time in milliseconds. 17 | //! 18 | //! getLocalTimeMilliseconds obtains the system's notion of current Greenwich 19 | //! time, adjusted according to the current timezone of the host system. 20 | //! The time is expressed as an absolute value since midnight (0 hour), 21 | //! January 1, 1970. This is commonly referred to as the "epoch". 22 | //! 23 | //! @return local-time in milliseconds elapsed since the epoch. 24 | //! 25 | /////////////////////////////////////////////////////////////////////////////// 26 | milliseconds_t getLocalTimeMilliseconds(); 27 | 28 | /////////////////////////////////////////////////////////////////////////////// 29 | //! 30 | //! Get local-time in seconds. 31 | //! 32 | //! getLocalTimeMilliseconds obtains the system's notion of current Greenwich 33 | //! time, adjusted according to the current timezone of the host system. 34 | //! The time is expressed as an absolute value since midnight (0 hour), 35 | //! January 1, 1970. This is commonly referred to as the "epoch". 36 | //! 37 | //! @return local-time in seconds elapsed since the epoch. 38 | //! 39 | /////////////////////////////////////////////////////////////////////////////// 40 | seconds_t getLocalTimeSeconds(); 41 | 42 | }}} // namespace mp4v2::platform::time 43 | 44 | #endif // MP4V2_PLATFORM_TIME_TIME_H 45 | -------------------------------------------------------------------------------- /libplatform/time/time_posix.cpp: -------------------------------------------------------------------------------- 1 | #include "libplatform/impl.h" 2 | #include <sys/time.h> 3 | 4 | namespace mp4v2 { namespace platform { namespace time { 5 | 6 | /////////////////////////////////////////////////////////////////////////////// 7 | 8 | milliseconds_t 9 | getLocalTimeMilliseconds() 10 | { 11 | timeval buf; 12 | if( gettimeofday( &buf, 0 )) 13 | memset( &buf, 0, sizeof( buf )); 14 | return milliseconds_t( buf.tv_sec ) * 1000 + buf.tv_usec / 1000; 15 | } 16 | 17 | /////////////////////////////////////////////////////////////////////////////// 18 | 19 | }}} // namespace mp4v2::platform::time 20 | -------------------------------------------------------------------------------- /libplatform/time/time_win32.cpp: -------------------------------------------------------------------------------- 1 | #include "libplatform/impl.h" 2 | #include <sys/timeb.h> 3 | 4 | namespace mp4v2 { namespace platform { namespace time { 5 | 6 | /////////////////////////////////////////////////////////////////////////////// 7 | 8 | milliseconds_t 9 | getLocalTimeMilliseconds() 10 | { 11 | __timeb64 buf; 12 | _ftime64( &buf ); 13 | return milliseconds_t( buf.time ) * 1000 + buf.millitm; 14 | } 15 | 16 | /////////////////////////////////////////////////////////////////////////////// 17 | 18 | }}} // namespace mp4v2::platform::time 19 | -------------------------------------------------------------------------------- /libplatform/warning.h: -------------------------------------------------------------------------------- 1 | #ifndef MP4V2_PLATFORM_WARNING_H 2 | #define MP4V2_PLATFORM_WARNING_H 3 | 4 | /////////////////////////////////////////////////////////////////////////////// 5 | 6 | // TODO-KB: clean code to avoid disabling warnings 7 | 8 | #if defined( __GNUC__ ) && ( __GNUC__ >= 4 ) && ( __GNUC_MINOR__ >= 2 ) 9 | # pragma GCC diagnostic ignored "-Wwrite-strings" 10 | #elif defined( _MSC_VER ) 11 | # pragma warning( disable: 4244 ) 12 | # pragma warning( disable: 4251 ) 13 | # pragma warning( disable: 4800 ) 14 | # pragma warning( disable: 4996 ) 15 | #endif 16 | 17 | /////////////////////////////////////////////////////////////////////////////// 18 | 19 | // this macro is used to mark printf-style functions for GCC to examine 20 | // the format string and arguments and issue warnings if needed 21 | 22 | #if defined( __GNUC__ ) 23 | # define MP4V2_WFORMAT_PRINTF(i,j) __attribute__((format(__printf__,i,j))) 24 | #else 25 | # define MP4V2_WFORMAT_PRINTF(i,j) 26 | #endif 27 | 28 | /////////////////////////////////////////////////////////////////////////////// 29 | 30 | #endif // MP4V2_PLATFORM_WARNING_H 31 | -------------------------------------------------------------------------------- /libutil/crc.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // The contents of this file are subject to the Mozilla Public License 4 | // Version 1.1 (the "License"); you may not use this file except in 5 | // compliance with the License. You may obtain a copy of the License at 6 | // http://www.mozilla.org/MPL/ 7 | // 8 | // Software distributed under the License is distributed on an "AS IS" 9 | // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 10 | // License for the specific language governing rights and limitations 11 | // under the License. 12 | // 13 | // The Original Code is MP4v2. 14 | // 15 | // The Initial Developer of the Original Code is Kona Blend. 16 | // Portions created by Kona Blend are Copyright (C) 2008. 17 | // All Rights Reserved. 18 | // 19 | // Contributors: 20 | // Kona Blend, kona8lend@@gmail.com 21 | // 22 | /////////////////////////////////////////////////////////////////////////////// 23 | 24 | #ifndef MP4V2_UTIL_CRC_H 25 | #define MP4V2_UTIL_CRC_H 26 | 27 | namespace mp4v2 { namespace util { 28 | 29 | /////////////////////////////////////////////////////////////////////////////// 30 | 31 | uint32_t crc32( const unsigned char*, uint32_t ); // ISO/IEC 8802-3:1989 32 | 33 | /////////////////////////////////////////////////////////////////////////////// 34 | 35 | }} // namespace mp4v2::util 36 | 37 | #endif // MP4V2_UTIL_CRC_H 38 | -------------------------------------------------------------------------------- /libutil/impl.h: -------------------------------------------------------------------------------- 1 | #ifndef MP4V2_UTIL_IMPL_H 2 | #define MP4V2_UTIL_IMPL_H 3 | 4 | /////////////////////////////////////////////////////////////////////////////// 5 | 6 | #include "util.h" 7 | 8 | /////////////////////////////////////////////////////////////////////////////// 9 | 10 | #endif // MP4V2_UTIL_IMPL_H 11 | -------------------------------------------------------------------------------- /libutil/other.h: -------------------------------------------------------------------------------- 1 | #ifndef MP4V2_UTIL_OTHER_H 2 | #define MP4V2_UTIL_OTHER_H 3 | 4 | /////////////////////////////////////////////////////////////////////////////// 5 | 6 | namespace mp4v2 { namespace util { 7 | 8 | /////////////////////////////////////////////////////////////////////////////// 9 | 10 | struct MP4V2_EXPORT FileSummaryInfo { 11 | typedef set<string> BrandSet; 12 | 13 | // standard ftyp box attributes 14 | string major_brand; 15 | uint32_t minor_version; 16 | BrandSet compatible_brands; 17 | 18 | uint32_t nlargesize; 19 | uint32_t nversion1; 20 | uint32_t nspecial; 21 | }; 22 | 23 | /////////////////////////////////////////////////////////////////////////////// 24 | /// 25 | /// Fetch mp4 file summary information. 26 | /// 27 | /// This function fetches summary information for <b>file</b> and information 28 | /// is stored in <b>info</b>. 29 | /// 30 | /// @return On success <b>true</b>. 31 | /// On failure <b>false</b>, and contents of <b>info</b> are undefined. 32 | /// 33 | MP4V2_EXPORT 34 | bool fileFetchSummaryInfo( MP4FileHandle file, FileSummaryInfo& info ); 35 | 36 | /////////////////////////////////////////////////////////////////////////////// 37 | 38 | }} // namespace mp4v2::util 39 | 40 | #endif // MP4V2_UTIL_OTHER_H 41 | -------------------------------------------------------------------------------- /libutil/util.h: -------------------------------------------------------------------------------- 1 | #ifndef MP4V2_UTIL_UTIL_H 2 | #define MP4V2_UTIL_UTIL_H 3 | 4 | /////////////////////////////////////////////////////////////////////////////// 5 | 6 | #include "src/src.h" 7 | 8 | /////////////////////////////////////////////////////////////////////////////// 9 | 10 | /// @namespace mp4v2::util (private) Command-line utility support. 11 | /// <b>WARNING: THIS IS A PRIVATE NAMESPACE. NOT FOR PUBLIC CONSUMPTION.</b> 12 | /// 13 | /// This namespace is used for command-line utilities. Some symbols from this 14 | /// namespace are exported from libmp4v2 in order to support new functionality 15 | /// which may or may not make it into some form of public API, at which time 16 | /// it will be moved out of this namespace. 17 | /// 18 | namespace mp4v2 { namespace util { 19 | using namespace std; 20 | using namespace mp4v2::impl; 21 | }} // namespace mp4v2::util 22 | 23 | /////////////////////////////////////////////////////////////////////////////// 24 | 25 | #include "Timecode.h" 26 | #include "TrackModifier.h" 27 | #include "Utility.h" 28 | #include "crc.h" 29 | #include "other.h" 30 | 31 | /////////////////////////////////////////////////////////////////////////////// 32 | 33 | #endif // MP4V2_UTIL_UTIL_H 34 | -------------------------------------------------------------------------------- /maintainer/HOWTO-ADD_SOURCE.txt: -------------------------------------------------------------------------------- 1 | Maintainer Add Source Files 2 | *************************** 3 | 4 | Almost any new .cpp or .h files will have to be added to GNUmakefile.am . 5 | It is trivial to add hand-written source files. Just add them to the list 6 | for the particular library or program which already exists. For example, 7 | to add a source file to libmp4v2: 8 | 9 | libmp4v2_la_SOURCES = ... 10 | 11 | In the rare situation that you desire to add a header file to be installed 12 | during 'make install' and used by the public API (such as mp4v2.h) then it 13 | should be taken out of libmp4v2_la_SOURCES and added to: 14 | 15 | mp4v2inc_HEADERS = ... 16 | 17 | Once done, autotool files such as configure will need to be regenerated. 18 | This is usually done automatically for you by the generated makefile, 19 | but the following command is always an excellent way to make sure 20 | everything is regenerated properly: 21 | 22 | autoreconf -fiv 23 | 24 | Don't be alarmed at the number of files created by autoreconf. These 25 | files will be part of any dist-bundle created but do not add them to the 26 | repository -- they are dist-only files. 27 | -------------------------------------------------------------------------------- /maintainer/HOWTO-AUTOTOOLS.txt: -------------------------------------------------------------------------------- 1 | Maintainer Autotools Instructions 2 | ********************************* 3 | 4 | This project uses autotools and does not add/checkin files generated by 5 | autoreconf to the repository. These files are to be included only in 6 | dist-bundles. 7 | 8 | There is a clear distinction between building from the repository or 9 | building from a dist-bundle. This document is for project maintainers 10 | building from the repository. 11 | 12 | The maintainer is responsible for generating files associated with 13 | autotools. These files in turn are distributed with dist-bundles, but 14 | never should be added/checked-in to the repository. 15 | 16 | Whenever any information for which autotools may depend on is changed, 17 | then you must issue the following command which will force generation 18 | of all files and install support scripts required at configure-time: 19 | 20 | autoreconf -fiv 21 | 22 | Where is Makefile.am? And what is this GNUmakefile stuff? 23 | We already have a sophisticated project which requires enough GNU-tools 24 | at build-time that it makes no sense to hope-and-pray that BSD flavors 25 | of make will work. As such, the files are renamed to be those which are 26 | only recognized by GNU make. This helps avoid confusion when people run 27 | the wrong make flavor -- it's better to see Makefile not found, rather 28 | than 100 obscure make incompatibility-errors. So we have GNUmakefile.am 29 | which is just like the old Makefile.am only better. 30 | 31 | Post configure, we end up with GNUmakefile in your build directory. 32 | 33 | Care has been taken to avoid subdir makefiles. And while they may 34 | eventually become part of this project, it's nice to avoid them when 35 | when possible. 36 | -------------------------------------------------------------------------------- /maintainer/HOWTO-TEST.txt: -------------------------------------------------------------------------------- 1 | Maintainer Automated Testing Instructions 2 | ***************************************** 3 | 4 | Automated testing is available for the project. It can be used to write tests 5 | for batched and interactive command-line utilities. DejaGNU is the framework 6 | used. Testing is not a mandatory requirement when building, however it is 7 | strongly encouraged. 8 | 9 | Tests may be run after building the project with the following command: 10 | 11 | make check 12 | 13 | And the quick-and-dirty method to see if all tests passed is to look at the 14 | last line of output which indicates the number of expected passes and 15 | failures. Any 'unexpected' results are the ones to be concerned about. 16 | Assuming there are 50 tests for a project, the ideal output might be: 17 | 18 | === <TESTSUITE_NAME> Summary === 19 | # of expected passes 24 20 | 21 | Test output is available in testlog/ with *.log and *.sum for log and 22 | summary files, respectively. 23 | 24 | 25 | Requirements 26 | ------------ 27 | 28 | The testsuite is fairly new so the requirements may or may not be strict. 29 | Listed here are the versions used to by maintainers; be aware that 30 | this testing framework is generally a unix solution only. 31 | 32 | expect 5.43.0 33 | Tcl 8.5 34 | DejaGNU 1.4.4 35 | 36 | 37 | DejaGNU Framework 38 | ----------------- 39 | 40 | The framework is relatively thin; basically a wrapper around things which 41 | can be made to work relatively easily with Autotools. The underlying 42 | tests are actually written using expect/tcl. However, since this project 43 | does not have any interactive command-line tools, the interactive nature 44 | of expect is not leveraged. Thus, most tests have so far been written 45 | using more or less Tcl with the DejaGNU framework. 46 | 47 | 48 | File Locations 49 | -------------- 50 | 51 | All tests are stored in testsuite/ and generally any C/C++ code require 52 | for testing should reside therein. However, sometimes a test utility proves 53 | to be quite useful on its own and may be moved outside of testsuite/ . 54 | 55 | In the future we can for example create tests which might test certain 56 | aspects of the API; here are some useful examples: 57 | 58 | - assert public C API header compiles 59 | - assert private symbols are not available to public compile/linking 60 | - assert contents of MP4Dump output are sane 61 | - etc... 62 | 63 | Hopefully as new tests are added they will serve as good examples. 64 | -------------------------------------------------------------------------------- /maintainer/LIBPLATFORM.txt: -------------------------------------------------------------------------------- 1 | libplatform Notes 2 | ***************** 3 | 4 | libplatform is a private library used by this project for portability 5 | across platforms. Simple file access, getting system time, parsing 6 | command-line arguments, endian byte-swap macros, are examples of 7 | things that belong in this convenience library. 8 | 9 | The implementation means to support the following platforms: 10 | 11 | - posix (the default) 12 | - win32 (Windows 2000 or newer) 13 | 14 | 15 | All symbols in libplatform reside in private namespace mp4v2::platform 16 | and must never be made visible through public interfaces. In general, 17 | implementation .h and .cpp files are free to include this library. 18 | 19 | Both libmp4v2 and various executables created by this project rely on 20 | libplatform and this creates a bit of a dilemma in that libmp4v2 must 21 | ship as a stand-alone library. Thus, when creating libmp4v2 we must always 22 | embed the needed bits from libplatform. In turn, the executables then 23 | link against both libmp4v2 and the remaining bits of libplatform. 24 | 25 | This approach requires advanced linking which is available using 26 | several different methods, varying by platforms. And to complicate 27 | matters further, libtool (even version 2.2.6) makes this impossible. 28 | So the simple solution is to add libplatform symbols to libmp4v2. 29 | The only problem with this is libmp4v2 becomes a little fatter than 30 | it needs to be, but since all the symbols are in a private namespace 31 | and we use set default symbol visibility to hidden, we protect our 32 | clients from inadvertantly becoming dependents. 33 | 34 | If libplatform ever becomes bulky we can revisit this issue, but at 35 | this time using advanced linking would only save ~10KB of binary size. 36 | -------------------------------------------------------------------------------- /maintainer/NAMESPACES.txt: -------------------------------------------------------------------------------- 1 | Maintainer C++ Namespace Notes 2 | ****************************** 3 | 4 | Namespaces have been employed to help organize source and push all private 5 | symbols (those which are not part of the public C API) to a location 6 | that is unlikely to be accidentally used by anyone. It also virtually 7 | eliminates any chance that private impl symbols will cause symbol collisions 8 | at compile or link-time. 9 | 10 | The global namespace is used by C API which generally prefixes all 11 | of its symobls with MP4 to avoid collisions. This space is used by 12 | src/mp4.cpp and include/mp4v2/mp4v2.h . A few exceptions may exist where 13 | additional API is exported from some differently-implemented code. 14 | 15 | The rest of the codebase is tucked into various child-namespaces of 16 | the project's top-level 'mp4v2' namespace. The top-level namespace 17 | is reserved for this project, and unless someone branches our codebase 18 | and ignores their moral responsibility to rename their root namespace, 19 | we should neatly avoid symbol collisions. Code external to the project 20 | should never use any symbols which reside in mp4v2. 21 | 22 | The namespace 'mp4v2::platform' is private and used for code which abstracts 23 | various plaform differences or implements missing features. 24 | 25 | The namespace 'mp4v2::impl' is a private namespace for the main 26 | implementation of libmp4v2. This namespace generally depends on 27 | mp4v2::platform . 28 | 29 | The namespace 'mp4v2::util' is a private namespace which adds 30 | functionality for use with libutil and util/ command-line tools. The 31 | positioning is a little more complicated in that it has symbols which 32 | are exported from libmp4v2, which needs full access to mp4v2::impl 33 | hidden symbols. Then libutil itself adds to the same namespace, but 34 | because libutil does not require direct access to mp4v2::impl hidden 35 | symbols it is a separate static library. And finally, the util/ tools 36 | themselves use the namespace for implementation convenience. 37 | 38 | Nested (child) namespaces of those listed above are used for further 39 | organization when applicable. 40 | 41 | Further documentation is available in the API Reference; 42 | see Namespaces section. 43 | -------------------------------------------------------------------------------- /maintainer/SOURCE.txt: -------------------------------------------------------------------------------- 1 | Maintainer C++ Formatting Suggestions 2 | ************************************* 3 | 4 | Some consistency and readability to C++ source code in the MP4v2 project 5 | is desired. Every coder has different styles, uses different tools, but 6 | we need to find some common ground when possible. So please consider this 7 | document when creating and editing code. 8 | 9 | When in doubt, general suggestions are as follows: 10 | 11 | - format for good readability. 12 | - format in a similar fashion as the file you are editing. 13 | - format code generally no wider than 119 columns. 14 | - format code with 4-space indents (no hard-tabs!) 15 | - the wider an identifier's scope is, the more descriptive it's name 16 | should be (and generally longer). Short identifiers for local scopes 17 | and loops are perfectly acceptable. 18 | - make liberal use of TODO comments as necessary. Following the 19 | pattern of marking *who* placed the TODO with a hyphen followed 20 | by your initials or shortname. ie: TODO-XY; note this does not 21 | imply the person who marked takes responsibility for the task. 22 | - move pointer 'astericks' and reference 'ampersands' towards type 23 | 24 | 25 | EXAMPLE IF/ELSE 26 | --------------- 27 | 28 | if( true ) 29 | doit(); 30 | 31 | if( (a == 1) && (b == 2) ) { 32 | doit(); 33 | doit(); 34 | } 35 | else if( true && /* really long multi-line stuff 36 | another long line 37 | another line */ ) 38 | { 39 | doit(); 40 | } 41 | 42 | 43 | EXAMPLE FUNCTION DELCARATIONS 44 | ----------------------------- 45 | 46 | void processFoo( ); 47 | bool processFoo( const char* name = 0 ); 48 | bool processFoo( const string& name ); 49 | 50 | 51 | EXAMPLE FUNCTION DEFINITIONS 52 | ----------------------------- 53 | 54 | void 55 | processFoo() 56 | { 57 | doit(); 58 | } 59 | 60 | bool 61 | processFoo( const char* name = 0 ) 62 | { 63 | doit(); 64 | return thing != true; // no need for parenthesis 65 | } 66 | 67 | bool 68 | processFoo( const string& name ) 69 | { 70 | doit(); 71 | return (thing != true) || (another == false); // parens help readability 72 | } 73 | 74 | 75 | EXAMPLE CLASS DECL 76 | ------------------ 77 | 78 | class Foo 79 | { 80 | public: 81 | Foo( int value ); 82 | virtual ~Foo(); 83 | 84 | int get( ); 85 | void set( int value ); 86 | 87 | protected: 88 | virtual void doit() = 0; 89 | 90 | private: 91 | int _value; 92 | 93 | public: 94 | const int defaultValue; 95 | 96 | public: 97 | static void foo(); 98 | }; 99 | -------------------------------------------------------------------------------- /mp4v2.pc.in: -------------------------------------------------------------------------------- 1 | # libmp4v2 pkg-config file 2 | 3 | prefix=@prefix@ 4 | exec_prefix=@exec_prefix@ 5 | libdir=@libdir@ 6 | includedir=@includedir@ 7 | 8 | Name: mp4v2 9 | Description: A library for manipulating MP4 container files 10 | Version: @VERSION@ 11 | 12 | Libs: -L${libdir} -lmp4v2 13 | Cflags: -I${includedir} 14 | -------------------------------------------------------------------------------- /project/htmlcombine.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | 4 | import re 5 | import sys 6 | 7 | from optparse import OptionParser 8 | 9 | ############################################################################### 10 | 11 | parser = OptionParser( 'Usage: %prog [OPTIONS]' ) 12 | parser.add_option( '--header', action='store', default=None, help='header file' ) 13 | parser.add_option( '--footer', action='store', default=None, help='footer file' ) 14 | parser.add_option( '--body', action='store', default=None, help='file to extract contents of body from' ) 15 | parser.add_option( '-v', '--verbose', action='count', default=False, help='increase verbosity' ) 16 | 17 | (options, args) = parser.parse_args() 18 | 19 | if( len(args) != 0 ): 20 | parser.error( 'incorrect number of arguments' ) 21 | 22 | if not options.header: 23 | parser.error( '--header must be specified' ) 24 | if not options.footer: 25 | parser.error( '--footer must be specified' ) 26 | if not options.body: 27 | parser.error( '--body must be specified' ) 28 | 29 | ############################################################################### 30 | 31 | title = 'Unknown' 32 | 33 | # parse majorheading 34 | with open( options.body, 'r' ) as f: 35 | rx = re.compile( '^.*class="majorheading".*>([^>]+)</.+>' ) 36 | for line in f: 37 | m = rx.match( line ) 38 | if not m: 39 | continue; 40 | title = m.group( 1 ) 41 | break 42 | 43 | m = re.compile( '(\S+)\s+(\S+)\s+(.+)' ).match( title ) 44 | if m: 45 | shortTitle = m.group(3) 46 | else: 47 | shortTitle = title 48 | 49 | menu = '' 50 | if not shortTitle == 'Documentation': 51 | menu += '<li><a href="index.html">Documentation</a></li>\n' 52 | menu += '<li class="active">%s</li>' % (shortTitle) 53 | else: 54 | menu += '<li class="active">Documentation</li>' 55 | 56 | with open( options.header, 'r' ) as f: 57 | rxTitle = re.compile( '__TITLE__' ) 58 | rxShortTitle = re.compile( '__SHORT_TITLE__' ) 59 | rxMenu = re.compile( '__MENU__' ) 60 | for line in f: 61 | line = re.sub( rxTitle, title, line ) 62 | line = re.sub( rxShortTitle, shortTitle, line ) 63 | line = re.sub( rxMenu, menu, line ) 64 | sys.stdout.write( line ) 65 | 66 | # out everything *after* first <body> and *before* </body> 67 | with open( options.body, 'r' ) as f: 68 | rxBegin = re.compile( '<body>' ) 69 | rxEnd = re.compile( '</body>' ) 70 | inside = False 71 | lstrip = False 72 | for line in f: 73 | if rxBegin.match( line ): 74 | inside = True 75 | continue 76 | if rxEnd.match( line ): 77 | outside = False 78 | continue 79 | 80 | if lstrip: 81 | line = line.lstrip() 82 | if inside: 83 | sys.stdout.write( line ) 84 | 85 | with open( options.footer, 'r' ) as f: 86 | for line in f: 87 | sys.stdout.write( line ) 88 | -------------------------------------------------------------------------------- /project/project.m4.in: -------------------------------------------------------------------------------- 1 | define(<<__PROJECT_name>>, <<@PROJECT_name@>>)dnl 2 | define(<<__PROJECT_name_lower>>, <<@PROJECT_name_lower@>>)dnl 3 | define(<<__PROJECT_name_upper>>, <<@PROJECT_name_upper@>>)dnl 4 | define(<<__PROJECT_name_formal>>, <<@PROJECT_name_formal@>>)dnl 5 | define(<<__PROJECT_url_website>>, <<@PROJECT_url_website@>>)dnl 6 | define(<<__PROJECT_url_downloads>>, <<@PROJECT_url_downloads@>>)dnl 7 | define(<<__PROJECT_url_discussion>>, <<@PROJECT_url_discussion@>>)dnl 8 | define(<<__PROJECT_url_bugreport>>, <<@PROJECT_url_bugreport@>>)dnl 9 | define(<<__PROJECT_support>>, <<@PROJECT_support@>>)dnl 10 | define(<<__PROJECT_version>>, <<@PROJECT_version@>>)dnl 11 | define(<<__PROJECT_version_hex>>, <<@PROJECT_version_hex@>>)dnl 12 | define(<<__PROJECT_version_major>>, <<@PROJECT_version_major@>>)dnl 13 | define(<<__PROJECT_version_minor>>, <<@PROJECT_version_minor@>>)dnl 14 | define(<<__PROJECT_version_point>>, <<@PROJECT_version_point@>>)dnl 15 | define(<<__PROJECT_repo_url>>, <<@PROJECT_repo_url@>>)dnl 16 | define(<<__PROJECT_build>>, <<@PROJECT_build@>>)dnl 17 | dnl 18 | define(<<__MAKE_ABS_TOP_BUILDDIR>>, <<@abs_top_builddir@>>)dnl 19 | define(<<__MAKE_ABS_TOP_SRCDIR>>, <<@abs_top_srcdir@>>)dnl 20 | -------------------------------------------------------------------------------- /project/project.m4sugar: -------------------------------------------------------------------------------- 1 | dnl 2 | dnl This file defines highest-level project meta-data in autoconf M4 format. 3 | dnl It is needed downstream by configure.ac. 4 | dnl 5 | define([PRJ_name], [MP4v2]) 6 | define([PRJ_name_lower], [mp4v2]) 7 | define([PRJ_name_upper], [MP4V2]) 8 | define([PRJ_url_website], [https://mp4v2.org]) 9 | define([PRJ_url_downloads], [https://github.com/enzo1982/releases]) 10 | define([PRJ_url_discussion], [https://github.com/enzo1982/discussions]) 11 | define([PRJ_url_bugreport], [https://github.com/enzo1982/issues]) 12 | define([PRJ_support], [support@mp4v2.org]) 13 | define([PRJ_version_major], [2]) 14 | define([PRJ_version_minor], [1]) 15 | define([PRJ_version_point], [3]) 16 | define([PRJ_repo_url], [git@github.com:enzo1982/mp4v2.git]) 17 | -------------------------------------------------------------------------------- /src/3gp.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * The contents of this file are subject to the Mozilla Public 3 | * License Version 1.1 (the "License"); you may not use this file 4 | * except in compliance with the License. You may obtain a copy of 5 | * the License at http://www.mozilla.org/MPL/ 6 | * 7 | * Software distributed under the License is distributed on an "AS 8 | * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 9 | * implied. See the License for the specific language governing 10 | * rights and limitations under the License. 11 | * 12 | * The Original Code is MPEG4IP. 13 | * 14 | * The Initial Developer of the Original Code is Cisco Systems Inc. 15 | * Portions created by Cisco Systems Inc. are 16 | * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. 17 | * 18 | * 3GPP features implementation is based on 3GPP's TS26.234-v5.60, 19 | * and was contributed by Ximpo Group Ltd. 20 | * 21 | * Portions created by Ximpo Group Ltd. are 22 | * Copyright (C) Ximpo Group Ltd. 2003, 2004. All Rights Reserved. 23 | * 24 | * Contributor(s): 25 | * Ximpo Group Ltd. mp4v2@ximpo.com 26 | */ 27 | 28 | #include "src/impl.h" 29 | 30 | namespace mp4v2 { namespace impl { 31 | 32 | /////////////////////////////////////////////////////////////////////////////// 33 | 34 | #define _3GP_MAJOR_BRAND "3gp5" 35 | #define _3GP_MINOR_VERSION 0x0001 36 | 37 | void MP4File::Make3GPCompliant(const char* fileName, char* majorBrand, uint32_t minorVersion, char** supportedBrands, uint32_t supportedBrandsCount, bool deleteIodsAtom) 38 | { 39 | char brand[5] = "3gp5"; 40 | char* _3gpSupportedBrands[1] = { (char*)&brand }; 41 | 42 | if (majorBrand) { 43 | if (!supportedBrands || !supportedBrandsCount) { 44 | throw new EXCEPTION("Invalid parameters"); 45 | } 46 | } 47 | 48 | MakeFtypAtom( 49 | majorBrand ? majorBrand : (char*)brand, 50 | majorBrand ? minorVersion : _3GP_MINOR_VERSION, 51 | majorBrand ? supportedBrands : (char**)_3gpSupportedBrands, 52 | majorBrand ? supportedBrandsCount : 1); 53 | 54 | if (deleteIodsAtom) { 55 | // Delete the iods atom, if it exists.... 56 | MP4Atom* iodsAtom = m_pRootAtom->FindAtom("moov.iods"); 57 | if (iodsAtom) { 58 | MP4Atom* moovAtom = m_pRootAtom->FindAtom("moov"); 59 | ASSERT(moovAtom); 60 | 61 | moovAtom->DeleteChildAtom(iodsAtom); 62 | } 63 | } 64 | 65 | } 66 | 67 | /////////////////////////////////////////////////////////////////////////////// 68 | 69 | }} // namespace mp4v2::impl 70 | -------------------------------------------------------------------------------- /src/atom_ac3.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * The contents of this file are subject to the Mozilla Public 3 | * License Version 1.1 (the "License"); you may not use this file 4 | * except in compliance with the License. You may obtain a copy of 5 | * the License at http://www.mozilla.org/MPL/ 6 | * 7 | * Software distributed under the License is distributed on an "AS 8 | * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 9 | * implied. See the License for the specific language governing 10 | * rights and limitations under the License. 11 | * 12 | * The Original Code is MPEG4IP. 13 | * 14 | * The Initial Developer of the Original Code is Cisco Systems Inc. 15 | * Portions created by Cisco Systems Inc. are 16 | * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. 17 | * 18 | * See ETSI TS 102 366 V1.2.1 Annex F for how to put Ac3 in MP4. 19 | * 20 | * Contributor(s): 21 | * Edward Groenendaal egroenen@cisco.com 22 | */ 23 | 24 | #include "src/impl.h" 25 | 26 | namespace mp4v2 { 27 | namespace impl { 28 | 29 | /////////////////////////////////////////////////////////////////////////////// 30 | 31 | MP4Ac3Atom::MP4Ac3Atom(MP4File &file) 32 | : MP4Atom(file, "ac-3") 33 | { 34 | AddReserved(*this, "reserved1", 6); /* 0 */ 35 | 36 | AddProperty( /* 1 */ 37 | new MP4Integer16Property(*this,"dataReferenceIndex")); 38 | 39 | AddReserved(*this,"reserved2", 8); /* 2 */ 40 | 41 | AddProperty( /* 3 */ 42 | new MP4Integer16Property(*this,"channelCount")); 43 | 44 | AddProperty( /* 4 */ 45 | new MP4Integer16Property(*this,"sampleSize")); 46 | 47 | AddReserved(*this,"reserved3", 4); /* 5 */ 48 | 49 | AddProperty( /* 6 */ 50 | new MP4Integer16Property(*this,"samplingRate")); 51 | 52 | AddReserved(*this,"reserved4", 2); /* 7 */ 53 | 54 | ExpectChildAtom("dac3", Required, OnlyOne); 55 | } 56 | 57 | void MP4Ac3Atom::Generate() 58 | { 59 | MP4Atom::Generate(); 60 | 61 | ((MP4Integer16Property*)m_pProperties[1])->SetValue(1); // data-reference-index 62 | ((MP4Integer16Property*)m_pProperties[3])->SetValue(2); // channelCount - ignored 63 | ((MP4Integer16Property*)m_pProperties[4])->SetValue(0x0010); // sampleSize - ignored 64 | 65 | // The user should set the samplingRate as appropriate - and create the dac3 atom 66 | } 67 | 68 | /////////////////////////////////////////////////////////////////////////////// 69 | 70 | } 71 | } // namespace mp4v2::impl 72 | -------------------------------------------------------------------------------- /src/atom_amr.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * The contents of this file are subject to the Mozilla Public 3 | * License Version 1.1 (the "License"); you may not use this file 4 | * except in compliance with the License. You may obtain a copy of 5 | * the License at http://www.mozilla.org/MPL/ 6 | * 7 | * Software distributed under the License is distributed on an "AS 8 | * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 9 | * implied. See the License for the specific language governing 10 | * rights and limitations under the License. 11 | * 12 | * The Original Code is MPEG4IP. 13 | * 14 | * The Initial Developer of the Original Code is Cisco Systems Inc. 15 | * Portions created by Cisco Systems Inc. are 16 | * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. 17 | * 18 | * 3GPP features implementation is based on 3GPP's TS26.234-v5.60, 19 | * and was contributed by Ximpo Group Ltd. 20 | * 21 | * Portions created by Ximpo Group Ltd. are 22 | * Copyright (C) Ximpo Group Ltd. 2003, 2004. All Rights Reserved. 23 | * 24 | * Contributor(s): 25 | * Ximpo Group Ltd. mp4v2@ximpo.com 26 | */ 27 | 28 | #include "src/impl.h" 29 | 30 | namespace mp4v2 { 31 | namespace impl { 32 | 33 | /////////////////////////////////////////////////////////////////////////////// 34 | 35 | MP4AmrAtom::MP4AmrAtom(MP4File &file, const char *type) 36 | : MP4Atom(file, type) 37 | { 38 | AddReserved(*this,"reserved1", 6); /* 0 */ 39 | 40 | AddProperty( /* 1 */ 41 | new MP4Integer16Property(*this,"dataReferenceIndex")); 42 | 43 | AddReserved(*this,"reserved2", 16); /* 2 */ 44 | 45 | AddProperty( /* 3 */ 46 | new MP4Integer16Property(*this,"timeScale")); 47 | 48 | AddReserved(*this,"reserved3", 2); /* 4 */ 49 | 50 | ExpectChildAtom("damr", Required, OnlyOne); 51 | } 52 | 53 | void MP4AmrAtom::Generate() 54 | { 55 | MP4Atom::Generate(); 56 | 57 | ((MP4Integer16Property*)m_pProperties[1])->SetValue(1); 58 | 59 | // property reserved2 has non-zero fixed values 60 | static uint8_t reserved2[16] = { 61 | 0x00, 0x00, 0x00, 0x00, 62 | 0x00, 0x00, 0x00, 0x00, 63 | 0x00, 0x02, 0x00, 0x10, 64 | 0x00, 0x00, 0x00, 0x00, 65 | }; 66 | m_pProperties[2]->SetReadOnly(false); 67 | ((MP4BytesProperty*)m_pProperties[2])-> 68 | SetValue(reserved2, sizeof(reserved2)); 69 | m_pProperties[2]->SetReadOnly(true); 70 | } 71 | 72 | /////////////////////////////////////////////////////////////////////////////// 73 | 74 | } 75 | } // namespace mp4v2::impl 76 | -------------------------------------------------------------------------------- /src/atom_chpl.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * The contents of this file are subject to the Mozilla Public 3 | * License Version 1.1 (the "License"); you may not use this file 4 | * except in compliance with the License. You may obtain a copy of 5 | * the License at http://www.mozilla.org/MPL/ 6 | * 7 | * Software distributed under the License is distributed on an "AS 8 | * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 9 | * implied. See the License for the specific language governing 10 | * rights and limitations under the License. 11 | * 12 | * The Original Code is MPEG4IP. 13 | * 14 | * The Initial Developer of the Original Code is Cisco Systems Inc. 15 | * Portions created by Cisco Systems Inc. are 16 | * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. 17 | */ 18 | 19 | #include "src/impl.h" 20 | 21 | namespace mp4v2 { 22 | namespace impl { 23 | 24 | /////////////////////////////////////////////////////////////////////////////// 25 | 26 | // MP4ChplAtom is for Nero chapter list atom which is a child of udta 27 | MP4ChplAtom::MP4ChplAtom (MP4File &file) 28 | : MP4Atom(file, "chpl") 29 | { 30 | // it is not completely clear if version, flags, reserved and chaptercount 31 | // have the right sizes but 32 | // one thing is clear: chaptercount is not only 8-bit it is at least 16-bit 33 | 34 | // add the version 35 | AddVersionAndFlags(); 36 | 37 | // add reserved bytes 38 | AddReserved(*this,"reserved", 1); 39 | 40 | // define the chaptercount 41 | MP4Integer32Property * counter = new MP4Integer32Property(*this,"chaptercount"); 42 | AddProperty(counter); 43 | 44 | // define the chapterlist 45 | MP4TableProperty * list = new MP4TableProperty(*this,"chapters", counter); 46 | 47 | // the start time as 100 nanoseconds units 48 | list->AddProperty(new MP4Integer64Property(*this,"starttime")); 49 | 50 | // the chapter name as UTF-8 51 | list->AddProperty(new MP4StringProperty(*this,"title", true)); 52 | 53 | // add the chapterslist 54 | AddProperty(list); 55 | } 56 | 57 | void MP4ChplAtom::Generate () 58 | { 59 | SetVersion(1); 60 | } 61 | 62 | /////////////////////////////////////////////////////////////////////////////// 63 | 64 | } 65 | } // namespace mp4v2::impl 66 | -------------------------------------------------------------------------------- /src/atom_colr.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * The contents of this file are subject to the Mozilla Public 3 | * License Version 1.1 (the "License"); you may not use this file 4 | * except in compliance with the License. You may obtain a copy of 5 | * the License at http://www.mozilla.org/MPL/ 6 | * 7 | * Software distributed under the License is distributed on an "AS 8 | * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 9 | * implied. See the License for the specific language governing 10 | * rights and limitations under the License. 11 | * 12 | * The Original Code is MPEG4IP. 13 | * 14 | * Contributer has declined to give copyright information, and gives 15 | * it freely to the world. 16 | * 17 | * Contributor(s): 18 | */ 19 | 20 | #include "src/impl.h" 21 | 22 | namespace mp4v2 { 23 | namespace impl { 24 | 25 | /////////////////////////////////////////////////////////////////////////////// 26 | 27 | MP4ColrAtom::MP4ColrAtom(MP4File &file) 28 | : MP4Atom(file, "colr") 29 | { 30 | MP4StringProperty* cpt = new MP4StringProperty(*this,"colorParameterType"); 31 | cpt->SetFixedLength(4); 32 | AddProperty(cpt); /* 0 */ 33 | 34 | AddProperty( /* 1 */ new MP4Integer16Property(*this,"primariesIndex")); 35 | 36 | AddProperty( /* 2 */ new MP4Integer16Property(*this,"transferFunctionIndex")); 37 | 38 | AddProperty( /* 3 */ new MP4Integer16Property(*this,"matrixIndex")); 39 | } 40 | 41 | void MP4ColrAtom::Generate() 42 | { 43 | MP4Atom::Generate(); 44 | 45 | ((MP4StringProperty*)m_pProperties[0])->SetValue("nclc"); 46 | // default to ITU BT.709 values 47 | ((MP4Integer16Property*)m_pProperties[1])->SetValue(1); 48 | ((MP4Integer16Property*)m_pProperties[2])->SetValue(1); 49 | ((MP4Integer16Property*)m_pProperties[3])->SetValue(1); 50 | } 51 | 52 | /////////////////////////////////////////////////////////////////////////////// 53 | 54 | } 55 | } // namespace mp4v2::impl 56 | -------------------------------------------------------------------------------- /src/atom_damr.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * The contents of this file are subject to the Mozilla Public 3 | * License Version 1.1 (the "License"); you may not use this file 4 | * except in compliance with the License. You may obtain a copy of 5 | * the License at http://www.mozilla.org/MPL/ 6 | * 7 | * Software distributed under the License is distributed on an "AS 8 | * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 9 | * implied. See the License for the specific language governing 10 | * rights and limitations under the License. 11 | * 12 | * The Original Code is MPEG4IP. 13 | * 14 | * The Initial Developer of the Original Code is Cisco Systems Inc. 15 | * Portions created by Cisco Systems Inc. are 16 | * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. 17 | * 18 | * 3GPP features implementation is based on 3GPP's TS26.234-v5.60, 19 | * and was contributed by Ximpo Group Ltd. 20 | * 21 | * Portions created by Ximpo Group Ltd. are 22 | * Copyright (C) Ximpo Group Ltd. 2003, 2004. All Rights Reserved. 23 | * 24 | * Contributor(s): 25 | * Ximpo Group Ltd. mp4v2@ximpo.com 26 | */ 27 | 28 | #include "src/impl.h" 29 | 30 | namespace mp4v2 { 31 | namespace impl { 32 | 33 | /////////////////////////////////////////////////////////////////////////////// 34 | 35 | #define AMR_VENDOR 0x6d346970 36 | 37 | MP4DamrAtom::MP4DamrAtom(MP4File &file) 38 | : MP4Atom(file, "damr") 39 | { 40 | AddProperty( /* 0 */ 41 | new MP4Integer32Property(*this, "vendor")); 42 | 43 | AddProperty( /* 1 */ 44 | new MP4Integer8Property(*this, "decoderVersion")); 45 | 46 | AddProperty( /* 2 */ 47 | new MP4Integer16Property(*this, "modeSet")); 48 | 49 | AddProperty( /* 3 */ 50 | new MP4Integer8Property(*this, "modeChangePeriod")); 51 | 52 | AddProperty( /* 4 */ 53 | new MP4Integer8Property(*this, "framesPerSample")); 54 | 55 | } 56 | 57 | void MP4DamrAtom::Generate() 58 | { 59 | MP4Atom::Generate(); 60 | 61 | ((MP4Integer32Property*)m_pProperties[0])->SetValue(AMR_VENDOR); 62 | ((MP4Integer8Property*)m_pProperties[1])->SetValue(1); 63 | 64 | } 65 | 66 | /////////////////////////////////////////////////////////////////////////////// 67 | 68 | } 69 | } // namespace mp4v2::impl 70 | -------------------------------------------------------------------------------- /src/atom_dref.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * The contents of this file are subject to the Mozilla Public 3 | * License Version 1.1 (the "License"); you may not use this file 4 | * except in compliance with the License. You may obtain a copy of 5 | * the License at http://www.mozilla.org/MPL/ 6 | * 7 | * Software distributed under the License is distributed on an "AS 8 | * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 9 | * implied. See the License for the specific language governing 10 | * rights and limitations under the License. 11 | * 12 | * The Original Code is MPEG4IP. 13 | * 14 | * The Initial Developer of the Original Code is Cisco Systems Inc. 15 | * Portions created by Cisco Systems Inc. are 16 | * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. 17 | * 18 | * Contributor(s): 19 | * Dave Mackie dmackie@cisco.com 20 | */ 21 | 22 | #include "src/impl.h" 23 | 24 | namespace mp4v2 { 25 | namespace impl { 26 | 27 | /////////////////////////////////////////////////////////////////////////////// 28 | 29 | MP4DrefAtom::MP4DrefAtom(MP4File &file) 30 | : MP4Atom(file, "dref") 31 | { 32 | AddVersionAndFlags(); 33 | 34 | MP4Integer32Property* pCount = 35 | new MP4Integer32Property(*this, "entryCount"); 36 | pCount->SetReadOnly(); 37 | AddProperty(pCount); 38 | 39 | ExpectChildAtom("url ", Optional, Many); 40 | ExpectChildAtom("urn ", Optional, Many); 41 | ExpectChildAtom("alis", Optional, Many); 42 | } 43 | 44 | void MP4DrefAtom::Read() 45 | { 46 | /* do the usual read */ 47 | MP4Atom::Read(); 48 | 49 | // check that number of children == entryCount 50 | MP4Integer32Property* pCount = 51 | (MP4Integer32Property*)m_pProperties[2]; 52 | 53 | if (m_pChildAtoms.Size() != pCount->GetValue()) { 54 | log.warningf("%s: \"%s\": dref inconsistency with number of entries", 55 | __FUNCTION__, GetFile().GetFilename().c_str() ); 56 | 57 | /* fix it */ 58 | pCount->SetReadOnly(false); 59 | pCount->SetValue(m_pChildAtoms.Size()); 60 | pCount->SetReadOnly(true); 61 | } 62 | } 63 | 64 | /////////////////////////////////////////////////////////////////////////////// 65 | 66 | } 67 | } // namespace mp4v2::impl 68 | -------------------------------------------------------------------------------- /src/atom_elst.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * The contents of this file are subject to the Mozilla Public 3 | * License Version 1.1 (the "License"); you may not use this file 4 | * except in compliance with the License. You may obtain a copy of 5 | * the License at http://www.mozilla.org/MPL/ 6 | * 7 | * Software distributed under the License is distributed on an "AS 8 | * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 9 | * implied. See the License for the specific language governing 10 | * rights and limitations under the License. 11 | * 12 | * The Original Code is MPEG4IP. 13 | * 14 | * The Initial Developer of the Original Code is Cisco Systems Inc. 15 | * Portions created by Cisco Systems Inc. are 16 | * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. 17 | * 18 | * Contributor(s): 19 | * Dave Mackie dmackie@cisco.com 20 | */ 21 | 22 | #include "src/impl.h" 23 | 24 | namespace mp4v2 { 25 | namespace impl { 26 | 27 | /////////////////////////////////////////////////////////////////////////////// 28 | 29 | MP4ElstAtom::MP4ElstAtom(MP4File &file) 30 | : MP4Atom(file, "elst") 31 | { 32 | AddVersionAndFlags(); 33 | 34 | MP4Integer32Property* pCount = 35 | new MP4Integer32Property(*this, "entryCount"); 36 | AddProperty(pCount); 37 | 38 | MP4TableProperty* pTable = new MP4TableProperty(*this, "entries", pCount); 39 | AddProperty(pTable); 40 | } 41 | 42 | void MP4ElstAtom::AddProperties(uint8_t version) 43 | { 44 | MP4TableProperty* pTable = (MP4TableProperty*)m_pProperties[3]; 45 | 46 | if (version == 1) { 47 | pTable->AddProperty( 48 | new MP4Integer64Property(pTable->GetParentAtom(), "segmentDuration")); 49 | pTable->AddProperty( 50 | new MP4Integer64Property(pTable->GetParentAtom(), "mediaTime")); 51 | } else { 52 | pTable->AddProperty( 53 | new MP4Integer32Property(pTable->GetParentAtom(), "segmentDuration")); 54 | pTable->AddProperty( 55 | new MP4Integer32Property(pTable->GetParentAtom(), "mediaTime")); 56 | } 57 | 58 | pTable->AddProperty( 59 | new MP4Integer16Property(pTable->GetParentAtom(), "mediaRate")); 60 | pTable->AddProperty( 61 | new MP4Integer16Property(pTable->GetParentAtom(), "reserved")); 62 | } 63 | 64 | void MP4ElstAtom::Generate() 65 | { 66 | SetVersion(0); 67 | AddProperties(GetVersion()); 68 | 69 | MP4Atom::Generate(); 70 | } 71 | 72 | void MP4ElstAtom::Read() 73 | { 74 | /* read atom version */ 75 | ReadProperties(0, 1); 76 | 77 | /* need to create the properties based on the atom version */ 78 | AddProperties(GetVersion()); 79 | 80 | /* now we can read the remaining properties */ 81 | ReadProperties(1); 82 | 83 | Skip(); // to end of atom 84 | } 85 | 86 | /////////////////////////////////////////////////////////////////////////////// 87 | 88 | } 89 | } // namespace mp4v2::impl 90 | -------------------------------------------------------------------------------- /src/atom_enca.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * The contents of this file are subject to the Mozilla Public 3 | * License Version 1.1 (the "License"); you may not use this file 4 | * except in compliance with the License. You may obtain a copy of 5 | * the License at http://www.mozilla.org/MPL/ 6 | * 7 | * Software distributed under the License is distributed on an "AS 8 | * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 9 | * implied. See the License for the specific language governing 10 | * rights and limitations under the License. 11 | * 12 | * The Original Code is MPEG4IP. 13 | * 14 | * The Initial Developer of the Original Code is Cisco Systems Inc. 15 | * Portions created by Cisco Systems Inc. are 16 | * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. 17 | * 18 | * Contributor(s): 19 | * Dave Mackie dmackie@cisco.com 20 | * Alix Marchandise-Franquet alix@cisco.com 21 | */ 22 | 23 | #include "src/impl.h" 24 | 25 | namespace mp4v2 { 26 | namespace impl { 27 | 28 | /////////////////////////////////////////////////////////////////////////////// 29 | 30 | MP4EncaAtom::MP4EncaAtom(MP4File &file) 31 | : MP4Atom(file, "enca") 32 | { 33 | AddReserved(*this, "reserved1", 6); /* 0 */ 34 | 35 | AddProperty( /* 1 */ 36 | new MP4Integer16Property(*this, "dataReferenceIndex")); 37 | 38 | AddReserved(*this, "reserved2", 16); /* 2 */ 39 | 40 | AddProperty( /* 3 */ 41 | new MP4Integer16Property(*this, "timeScale")); 42 | 43 | AddReserved(*this, "reserved3", 2); /* 4 */ 44 | 45 | ExpectChildAtom("esds", Required, OnlyOne); 46 | ExpectChildAtom("sinf", Required, OnlyOne); 47 | } 48 | 49 | void MP4EncaAtom::Generate() 50 | { 51 | MP4Atom::Generate(); 52 | 53 | ((MP4Integer16Property*)m_pProperties[1])->SetValue(1); 54 | 55 | // property reserved2 has non-zero fixed values 56 | static uint8_t reserved2[16] = { 57 | 0x00, 0x00, 0x00, 0x00, 58 | 0x00, 0x00, 0x00, 0x00, 59 | 0x00, 0x02, 0x00, 0x10, 60 | 0x00, 0x00, 0x00, 0x00, 61 | }; 62 | m_pProperties[2]->SetReadOnly(false); 63 | ((MP4BytesProperty*)m_pProperties[2])-> 64 | SetValue(reserved2, sizeof(reserved2)); 65 | m_pProperties[2]->SetReadOnly(true); 66 | } 67 | 68 | /////////////////////////////////////////////////////////////////////////////// 69 | 70 | } 71 | } // namespace mp4v2::impl 72 | -------------------------------------------------------------------------------- /src/atom_free.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * The contents of this file are subject to the Mozilla Public 3 | * License Version 1.1 (the "License"); you may not use this file 4 | * except in compliance with the License. You may obtain a copy of 5 | * the License at http://www.mozilla.org/MPL/ 6 | * 7 | * Software distributed under the License is distributed on an "AS 8 | * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 9 | * implied. See the License for the specific language governing 10 | * rights and limitations under the License. 11 | * 12 | * The Original Code is MPEG4IP. 13 | * 14 | * The Initial Developer of the Original Code is Cisco Systems Inc. 15 | * Portions created by Cisco Systems Inc. are 16 | * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. 17 | * 18 | * Contributor(s): 19 | * Dave Mackie dmackie@cisco.com 20 | */ 21 | 22 | #include "src/impl.h" 23 | 24 | namespace mp4v2 { 25 | namespace impl { 26 | 27 | /////////////////////////////////////////////////////////////////////////////// 28 | 29 | MP4FreeAtom::MP4FreeAtom( MP4File &file, const char* type ) 30 | : MP4Atom( file, type ? type : "free" ) 31 | { 32 | } 33 | 34 | void MP4FreeAtom::Read() 35 | { 36 | Skip(); 37 | } 38 | 39 | void MP4FreeAtom::Write() 40 | { 41 | bool use64 = (GetSize() > (0xFFFFFFFF - 8)); 42 | BeginWrite(use64); 43 | 44 | static uint8_t freebuf[1024]; 45 | for (uint64_t ix = 0; ix < GetSize(); ix += sizeof(freebuf)) { 46 | m_File.WriteBytes(freebuf, min(GetSize() - ix, (uint64_t)sizeof(freebuf))); 47 | } 48 | 49 | FinishWrite(use64); 50 | } 51 | 52 | /////////////////////////////////////////////////////////////////////////////// 53 | 54 | } 55 | } // namespace mp4v2::impl 56 | -------------------------------------------------------------------------------- /src/atom_ftab.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * The contents of this file are subject to the Mozilla Public 3 | * License Version 1.1 (the "License"); you may not use this file 4 | * except in compliance with the License. You may obtain a copy of 5 | * the License at http://www.mozilla.org/MPL/ 6 | * 7 | * Software distributed under the License is distributed on an "AS 8 | * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 9 | * implied. See the License for the specific language governing 10 | * rights and limitations under the License. 11 | * 12 | * The Original Code is MPEG4IP. 13 | * 14 | * The Initial Developer of the Original Code is Cisco Systems Inc. 15 | * Portions created by Cisco Systems Inc. are 16 | * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. 17 | */ 18 | 19 | #include "src/impl.h" 20 | 21 | namespace mp4v2 { 22 | namespace impl { 23 | 24 | /////////////////////////////////////////////////////////////////////////////// 25 | 26 | MP4FtabAtom::MP4FtabAtom(MP4File &file) 27 | : MP4Atom(file, "ftab") 28 | { 29 | MP4Integer16Property* pCount = new MP4Integer16Property(*this, "entryCount"); /* 0 */ 30 | AddProperty(pCount); 31 | 32 | MP4TableProperty* pTable = new MP4TableProperty(*this, "fontEntries", pCount); /* 1 */ 33 | AddProperty(pTable); 34 | 35 | pTable->AddProperty(new MP4Integer16Property(pTable->GetParentAtom(), "fontID")); /* 0 */ 36 | pTable->AddProperty(new MP4StringProperty(pTable->GetParentAtom(), "name", true)); /* 1 */ 37 | } 38 | 39 | /////////////////////////////////////////////////////////////////////////////// 40 | 41 | } 42 | } // namespace mp4v2::impl 43 | -------------------------------------------------------------------------------- /src/atom_ftyp.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * The contents of this file are subject to the Mozilla Public 3 | * License Version 1.1 (the "License"); you may not use this file 4 | * except in compliance with the License. You may obtain a copy of 5 | * the License at http://www.mozilla.org/MPL/ 6 | * 7 | * Software distributed under the License is distributed on an "AS 8 | * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 9 | * implied. See the License for the specific language governing 10 | * rights and limitations under the License. 11 | * 12 | * The Original Code is MPEG4IP. 13 | * 14 | * The Initial Developer of the Original Code is Cisco Systems Inc. 15 | * Portions created by Cisco Systems Inc. are 16 | * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. 17 | * 18 | * Contributor(s): 19 | * Dave Mackie dmackie@cisco.com 20 | */ 21 | 22 | #include "src/impl.h" 23 | 24 | namespace mp4v2 { namespace impl { 25 | 26 | /////////////////////////////////////////////////////////////////////////////// 27 | 28 | MP4FtypAtom::MP4FtypAtom(MP4File &file) 29 | : MP4Atom( file, "ftyp" ) 30 | , majorBrand ( *new MP4StringProperty( *this, "majorBrand" )) 31 | , minorVersion ( *new MP4Integer32Property( *this, "minorVersion" )) 32 | , compatibleBrands ( *new MP4StringProperty( *this, "compatibleBrands", false, false, true )) 33 | { 34 | majorBrand.SetFixedLength( 4 ); 35 | compatibleBrands.SetFixedLength( 4 ); 36 | 37 | AddProperty( &majorBrand ); 38 | AddProperty( &minorVersion ); 39 | AddProperty( &compatibleBrands ); 40 | } 41 | 42 | void MP4FtypAtom::Generate() 43 | { 44 | MP4Atom::Generate(); 45 | 46 | majorBrand.SetValue( "mp42" ); 47 | minorVersion.SetValue( 0 ); 48 | 49 | compatibleBrands.SetCount( 2 ); 50 | compatibleBrands.SetValue( "mp42", 0 ); 51 | compatibleBrands.SetValue( "isom", 1 ); 52 | } 53 | 54 | void MP4FtypAtom::Read() 55 | { 56 | if ( m_size < 8 ) 57 | throw new EXCEPTION("Invalid ftyp atom size"); 58 | 59 | compatibleBrands.SetCount( (m_size - 8) / 4 ); // brands array fills rest of atom 60 | MP4Atom::Read(); 61 | } 62 | 63 | /////////////////////////////////////////////////////////////////////////////// 64 | 65 | }} // namespace mp4v2::impl 66 | -------------------------------------------------------------------------------- /src/atom_gmin.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * The contents of this file are subject to the Mozilla Public 3 | * License Version 1.1 (the "License"); you may not use this file 4 | * except in compliance with the License. You may obtain a copy of 5 | * the License at http://www.mozilla.org/MPL/ 6 | * 7 | * Software distributed under the License is distributed on an "AS 8 | * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 9 | * implied. See the License for the specific language governing 10 | * rights and limitations under the License. 11 | * 12 | * The Original Code is MPEG4IP. 13 | * 14 | * Contributer has declined to give copyright information, and gives 15 | * it freely to the world. 16 | * 17 | * Contributor(s): 18 | */ 19 | 20 | #include "src/impl.h" 21 | 22 | namespace mp4v2 { 23 | namespace impl { 24 | 25 | /////////////////////////////////////////////////////////////////////////////// 26 | 27 | MP4GminAtom::MP4GminAtom(MP4File &file) 28 | : MP4Atom(file, "gmin") 29 | { 30 | 31 | AddVersionAndFlags(); /* 0, 1 */ 32 | 33 | AddProperty(new MP4Integer16Property(*this, "graphicsMode")); /* 2 */ 34 | AddProperty(new MP4Integer16Property(*this, "opColorRed")); /* 3 */ 35 | AddProperty(new MP4Integer16Property(*this, "opColorGreen")); /* 4 */ 36 | AddProperty(new MP4Integer16Property(*this, "opColorBlue")); /* 5 */ 37 | AddProperty(new MP4Integer16Property(*this, "balance")); /* 6 */ 38 | AddReserved(*this, "reserved", 2); /* 7 */ 39 | 40 | } 41 | 42 | void MP4GminAtom::Generate() 43 | { 44 | 45 | MP4Atom::Generate(); 46 | 47 | ((MP4Integer16Property*)m_pProperties[2])->SetValue(0x0040); 48 | ((MP4Integer16Property*)m_pProperties[3])->SetValue(0x8000); 49 | ((MP4Integer16Property*)m_pProperties[4])->SetValue(0x8000); 50 | ((MP4Integer16Property*)m_pProperties[5])->SetValue(0x8000); 51 | ((MP4Integer16Property*)m_pProperties[6])->SetValue(0x0000); 52 | 53 | } 54 | 55 | /////////////////////////////////////////////////////////////////////////////// 56 | 57 | } 58 | } // namespace mp4v2::impl 59 | -------------------------------------------------------------------------------- /src/atom_hinf.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * The contents of this file are subject to the Mozilla Public 3 | * License Version 1.1 (the "License"); you may not use this file 4 | * except in compliance with the License. You may obtain a copy of 5 | * the License at http://www.mozilla.org/MPL/ 6 | * 7 | * Software distributed under the License is distributed on an "AS 8 | * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 9 | * implied. See the License for the specific language governing 10 | * rights and limitations under the License. 11 | * 12 | * The Original Code is MPEG4IP. 13 | * 14 | * The Initial Developer of the Original Code is Cisco Systems Inc. 15 | * Portions created by Cisco Systems Inc. are 16 | * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. 17 | * 18 | * Contributor(s): 19 | * Dave Mackie dmackie@cisco.com 20 | */ 21 | 22 | #include "src/impl.h" 23 | 24 | namespace mp4v2 { namespace impl { 25 | 26 | /////////////////////////////////////////////////////////////////////////////// 27 | 28 | MP4HinfAtom::MP4HinfAtom(MP4File &file) 29 | : MP4Atom(file, "hinf") 30 | { 31 | ExpectChildAtom("trpy", Optional, OnlyOne); 32 | ExpectChildAtom("nump", Optional, OnlyOne); 33 | ExpectChildAtom("tpyl", Optional, OnlyOne); 34 | ExpectChildAtom("maxr", Optional, Many); 35 | ExpectChildAtom("dmed", Optional, OnlyOne); 36 | ExpectChildAtom("dimm", Optional, OnlyOne); 37 | ExpectChildAtom("drep", Optional, OnlyOne); 38 | ExpectChildAtom("tmin", Optional, OnlyOne); 39 | ExpectChildAtom("tmax", Optional, OnlyOne); 40 | ExpectChildAtom("pmax", Optional, OnlyOne); 41 | ExpectChildAtom("dmax", Optional, OnlyOne); 42 | ExpectChildAtom("payt", Optional, OnlyOne); 43 | } 44 | 45 | void MP4HinfAtom::Generate() 46 | { 47 | // hinf is special in that although all it's child atoms 48 | // are optional (on read), if we generate it for writing 49 | // we really want all the children 50 | 51 | for (uint32_t i = 0; i < m_pChildAtomInfos.Size(); i++) { 52 | MP4Atom* pChildAtom = 53 | CreateAtom(m_File, this, m_pChildAtomInfos[i]->m_name); 54 | 55 | AddChildAtom(pChildAtom); 56 | 57 | // and ask it to self generate 58 | pChildAtom->Generate(); 59 | } 60 | } 61 | 62 | /////////////////////////////////////////////////////////////////////////////// 63 | 64 | }} // namespace mp4v2::impl 65 | -------------------------------------------------------------------------------- /src/atom_hnti.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * The contents of this file are subject to the Mozilla Public 3 | * License Version 1.1 (the "License"); you may not use this file 4 | * except in compliance with the License. You may obtain a copy of 5 | * the License at http://www.mozilla.org/MPL/ 6 | * 7 | * Software distributed under the License is distributed on an "AS 8 | * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 9 | * implied. See the License for the specific language governing 10 | * rights and limitations under the License. 11 | * 12 | * The Original Code is MPEG4IP. 13 | * 14 | * The Initial Developer of the Original Code is Cisco Systems Inc. 15 | * Portions created by Cisco Systems Inc. are 16 | * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. 17 | * 18 | * Contributor(s): 19 | * Dave Mackie dmackie@cisco.com 20 | */ 21 | 22 | #include "src/impl.h" 23 | 24 | namespace mp4v2 { 25 | namespace impl { 26 | 27 | /////////////////////////////////////////////////////////////////////////////// 28 | 29 | MP4HntiAtom::MP4HntiAtom(MP4File &file) 30 | : MP4Atom(file, "hnti") 31 | { 32 | } 33 | 34 | void MP4HntiAtom::Read() 35 | { 36 | MP4Atom* grandParent = m_pParentAtom->GetParentAtom(); 37 | ASSERT(grandParent); 38 | if (ATOMID(grandParent->GetType()) == ATOMID("trak")) { 39 | ExpectChildAtom("sdp ", Optional, OnlyOne); 40 | } else { 41 | ExpectChildAtom("rtp ", Optional, OnlyOne); 42 | } 43 | 44 | MP4Atom::Read(); 45 | } 46 | 47 | /////////////////////////////////////////////////////////////////////////////// 48 | 49 | } 50 | } // namespace mp4v2::impl 51 | -------------------------------------------------------------------------------- /src/atom_href.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * The contents of this file are subject to the Mozilla Public 3 | * License Version 1.1 (the "License"); you may not use this file 4 | * except in compliance with the License. You may obtain a copy of 5 | * the License at http://www.mozilla.org/MPL/ 6 | * 7 | * Software distributed under the License is distributed on an "AS 8 | * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 9 | * implied. See the License for the specific language governing 10 | * rights and limitations under the License. 11 | * 12 | * The Original Code is MPEG4IP. 13 | * 14 | * The Initial Developer of the Original Code is Cisco Systems Inc. 15 | * Portions created by Cisco Systems Inc. are 16 | * Copyright (C) Cisco Systems Inc. 2005. All Rights Reserved. 17 | * 18 | * Contributor(s): 19 | * Bill May wmay@cisco.com 20 | */ 21 | 22 | #include "src/impl.h" 23 | 24 | namespace mp4v2 { 25 | namespace impl { 26 | 27 | /////////////////////////////////////////////////////////////////////////////// 28 | 29 | MP4HrefAtom::MP4HrefAtom(MP4File &file) 30 | : MP4Atom(file, "href") 31 | { 32 | AddReserved(*this, "reserved1", 6); /* 0 */ 33 | 34 | AddProperty( /* 1 */ 35 | new MP4Integer16Property(*this, "dataReferenceIndex")); 36 | ExpectChildAtom("burl", Optional, OnlyOne); 37 | } 38 | 39 | void MP4HrefAtom::Generate() 40 | { 41 | MP4Atom::Generate(); 42 | 43 | ((MP4Integer16Property*)m_pProperties[1])->SetValue(1); 44 | 45 | } 46 | 47 | /////////////////////////////////////////////////////////////////////////////// 48 | 49 | } 50 | } // namespace mp4v2::impl 51 | -------------------------------------------------------------------------------- /src/atom_mdat.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * The contents of this file are subject to the Mozilla Public 3 | * License Version 1.1 (the "License"); you may not use this file 4 | * except in compliance with the License. You may obtain a copy of 5 | * the License at http://www.mozilla.org/MPL/ 6 | * 7 | * Software distributed under the License is distributed on an "AS 8 | * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 9 | * implied. See the License for the specific language governing 10 | * rights and limitations under the License. 11 | * 12 | * The Original Code is MPEG4IP. 13 | * 14 | * The Initial Developer of the Original Code is Cisco Systems Inc. 15 | * Portions created by Cisco Systems Inc. are 16 | * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. 17 | * 18 | * Contributor(s): 19 | * Dave Mackie dmackie@cisco.com 20 | */ 21 | 22 | #include "src/impl.h" 23 | 24 | namespace mp4v2 { 25 | namespace impl { 26 | 27 | /////////////////////////////////////////////////////////////////////////////// 28 | 29 | MP4MdatAtom::MP4MdatAtom(MP4File &file) 30 | : MP4Atom(file, "mdat") 31 | { 32 | } 33 | 34 | void MP4MdatAtom::Read() 35 | { 36 | Skip(); 37 | } 38 | 39 | void MP4MdatAtom::Write() 40 | { 41 | // should never get here 42 | ASSERT(false); 43 | } 44 | 45 | /////////////////////////////////////////////////////////////////////////////// 46 | 47 | } 48 | } // namespace mp4v2::impl 49 | -------------------------------------------------------------------------------- /src/atom_mp4s.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * The contents of this file are subject to the Mozilla Public 3 | * License Version 1.1 (the "License"); you may not use this file 4 | * except in compliance with the License. You may obtain a copy of 5 | * the License at http://www.mozilla.org/MPL/ 6 | * 7 | * Software distributed under the License is distributed on an "AS 8 | * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 9 | * implied. See the License for the specific language governing 10 | * rights and limitations under the License. 11 | * 12 | * The Original Code is MPEG4IP. 13 | * 14 | * The Initial Developer of the Original Code is Cisco Systems Inc. 15 | * Portions created by Cisco Systems Inc. are 16 | * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. 17 | * 18 | * Contributor(s): 19 | * Dave Mackie dmackie@cisco.com 20 | */ 21 | 22 | #include "src/impl.h" 23 | 24 | namespace mp4v2 { 25 | namespace impl { 26 | 27 | /////////////////////////////////////////////////////////////////////////////// 28 | 29 | MP4Mp4sAtom::MP4Mp4sAtom(MP4File &file) 30 | : MP4Atom(file, "mp4s") 31 | { 32 | AddReserved(*this, "reserved1", 6); 33 | AddProperty( 34 | new MP4Integer16Property(*this, "dataReferenceIndex")); 35 | 36 | ExpectChildAtom("esds", Required, OnlyOne); 37 | } 38 | 39 | void MP4Mp4sAtom::Generate() 40 | { 41 | MP4Atom::Generate(); 42 | 43 | ((MP4Integer16Property*)m_pProperties[1])->SetValue(1); 44 | } 45 | 46 | /////////////////////////////////////////////////////////////////////////////// 47 | 48 | } 49 | } // namespace mp4v2::impl 50 | -------------------------------------------------------------------------------- /src/atom_mp4v.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * The contents of this file are subject to the Mozilla Public 3 | * License Version 1.1 (the "License"); you may not use this file 4 | * except in compliance with the License. You may obtain a copy of 5 | * the License at http://www.mozilla.org/MPL/ 6 | * 7 | * Software distributed under the License is distributed on an "AS 8 | * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 9 | * implied. See the License for the specific language governing 10 | * rights and limitations under the License. 11 | * 12 | * The Original Code is MPEG4IP. 13 | * 14 | * The Initial Developer of the Original Code is Cisco Systems Inc. 15 | * Portions created by Cisco Systems Inc. are 16 | * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. 17 | * 18 | * Contributor(s): 19 | * Dave Mackie dmackie@cisco.com 20 | */ 21 | 22 | #include "src/impl.h" 23 | 24 | namespace mp4v2 { 25 | namespace impl { 26 | 27 | /////////////////////////////////////////////////////////////////////////////// 28 | 29 | MP4Mp4vAtom::MP4Mp4vAtom(MP4File &file) 30 | : MP4Atom(file, "mp4v") 31 | { 32 | AddReserved(*this, "reserved1", 6); /* 0 */ 33 | 34 | AddProperty( /* 1 */ 35 | new MP4Integer16Property(*this, "dataReferenceIndex")); 36 | 37 | AddReserved(*this, "reserved2", 16); /* 2 */ 38 | 39 | AddProperty( /* 3 */ 40 | new MP4Integer16Property(*this, "width")); 41 | AddProperty( /* 4 */ 42 | new MP4Integer16Property(*this, "height")); 43 | 44 | AddReserved(*this, "reserved3", 14); /* 5 */ 45 | 46 | MP4StringProperty* pProp = 47 | new MP4StringProperty(*this, "compressorName"); 48 | pProp->SetFixedLength(32); 49 | pProp->SetCountedFormat(true); 50 | pProp->SetValue(""); 51 | AddProperty(pProp); /* 6 */ 52 | 53 | AddReserved(*this, "reserved4", 4); /* 7 */ 54 | 55 | ExpectChildAtom("colr", Optional, OnlyOne); 56 | ExpectChildAtom("esds", Required, OnlyOne); 57 | ExpectChildAtom("pasp", Optional, OnlyOne); 58 | } 59 | 60 | void MP4Mp4vAtom::Generate() 61 | { 62 | MP4Atom::Generate(); 63 | 64 | ((MP4Integer16Property*)m_pProperties[1])->SetValue(1); 65 | 66 | // property reserved3 has non-zero fixed values 67 | static uint8_t reserved3[14] = { 68 | 0x00, 0x48, 0x00, 0x00, 69 | 0x00, 0x48, 0x00, 0x00, 70 | 0x00, 0x00, 0x00, 0x00, 71 | 0x00, 0x01, 72 | }; 73 | m_pProperties[5]->SetReadOnly(false); 74 | ((MP4BytesProperty*)m_pProperties[5])-> 75 | SetValue(reserved3, sizeof(reserved3)); 76 | m_pProperties[5]->SetReadOnly(true); 77 | 78 | // property reserved4 has non-zero fixed values 79 | static uint8_t reserved4[4] = { 80 | 0x00, 0x18, 0xFF, 0xFF, 81 | }; 82 | m_pProperties[7]->SetReadOnly(false); 83 | ((MP4BytesProperty*)m_pProperties[7])-> 84 | SetValue(reserved4, sizeof(reserved4)); 85 | m_pProperties[7]->SetReadOnly(true); 86 | } 87 | 88 | /////////////////////////////////////////////////////////////////////////////// 89 | 90 | } 91 | } // namespace mp4v2::impl 92 | -------------------------------------------------------------------------------- /src/atom_nmhd.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * The contents of this file are subject to the Mozilla Public 3 | * License Version 1.1 (the "License"); you may not use this file 4 | * except in compliance with the License. You may obtain a copy of 5 | * the License at http://www.mozilla.org/MPL/ 6 | * 7 | * Software distributed under the License is distributed on an "AS 8 | * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 9 | * implied. See the License for the specific language governing 10 | * rights and limitations under the License. 11 | * 12 | * The Original Code is MPEG4IP. 13 | * 14 | * The Initial Developer of the Original Code is Cisco Systems Inc. 15 | * Portions created by Cisco Systems Inc. are 16 | * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. 17 | */ 18 | 19 | #include "src/impl.h" 20 | 21 | namespace mp4v2 { 22 | namespace impl { 23 | 24 | /////////////////////////////////////////////////////////////////////////////// 25 | 26 | MP4NmhdAtom::MP4NmhdAtom(MP4File &file) 27 | : MP4Atom(file, "nmhd") 28 | { 29 | AddVersionAndFlags(); 30 | } 31 | 32 | /////////////////////////////////////////////////////////////////////////////// 33 | 34 | } 35 | } // namespace mp4v2::impl 36 | -------------------------------------------------------------------------------- /src/atom_pasp.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * The contents of this file are subject to the Mozilla Public 3 | * License Version 1.1 (the "License"); you may not use this file 4 | * except in compliance with the License. You may obtain a copy of 5 | * the License at http://www.mozilla.org/MPL/ 6 | * 7 | * Software distributed under the License is distributed on an "AS 8 | * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 9 | * implied. See the License for the specific language governing 10 | * rights and limitations under the License. 11 | * 12 | * The Original Code is MPEG4IP. 13 | * 14 | * Contributer has declined to give copyright information, and gives 15 | * it freely to the world. 16 | * 17 | * Contributor(s): 18 | */ 19 | 20 | #include "src/impl.h" 21 | 22 | namespace mp4v2 { 23 | namespace impl { 24 | 25 | /////////////////////////////////////////////////////////////////////////////// 26 | 27 | MP4PaspAtom::MP4PaspAtom(MP4File &file) 28 | : MP4Atom(file, "pasp") 29 | { 30 | 31 | AddProperty( /* 0 */ 32 | new MP4Integer32Property(*this, "hSpacing")); 33 | 34 | AddProperty( /* 1 */ 35 | new MP4Integer32Property(*this, "vSpacing")); 36 | 37 | } 38 | 39 | void MP4PaspAtom::Generate() 40 | { 41 | 42 | MP4Atom::Generate(); 43 | 44 | ((MP4Integer32Property*)m_pProperties[0])->SetValue(1); 45 | ((MP4Integer32Property*)m_pProperties[1])->SetValue(1); 46 | 47 | } 48 | 49 | /////////////////////////////////////////////////////////////////////////////// 50 | 51 | } 52 | } // namespace mp4v2::impl 53 | -------------------------------------------------------------------------------- /src/atom_s263.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * The contents of this file are subject to the Mozilla Public 3 | * License Version 1.1 (the "License"); you may not use this file 4 | * except in compliance with the License. You may obtain a copy of 5 | * the License at http://www.mozilla.org/MPL/ 6 | * 7 | * Software distributed under the License is distributed on an "AS 8 | * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 9 | * implied. See the License for the specific language governing 10 | * rights and limitations under the License. 11 | * 12 | * The Original Code is MPEG4IP. 13 | * 14 | * The Initial Developer of the Original Code is Cisco Systems Inc. 15 | * Portions created by Cisco Systems Inc. are 16 | * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. 17 | * 18 | * 3GPP features implementation is based on 3GPP's TS26.234-v5.60, 19 | * and was contributed by Ximpo Group Ltd. 20 | * 21 | * Portions created by Ximpo Group Ltd. are 22 | * Copyright (C) Ximpo Group Ltd. 2003, 2004. All Rights Reserved. 23 | * 24 | * Contributor(s): 25 | * Ximpo Group Ltd. mp4v2@ximpo.com 26 | */ 27 | 28 | #include "src/impl.h" 29 | 30 | namespace mp4v2 { 31 | namespace impl { 32 | 33 | /////////////////////////////////////////////////////////////////////////////// 34 | 35 | MP4S263Atom::MP4S263Atom(MP4File &file) 36 | : MP4Atom(file, "s263") 37 | { 38 | AddReserved(*this, "reserved1", 6); /* 0 */ 39 | 40 | AddProperty( /* 1 */ 41 | new MP4Integer16Property(*this, "dataReferenceIndex")); 42 | 43 | AddReserved(*this, "reserved2", 16); /* 2 */ 44 | 45 | AddProperty( /* 3 */ 46 | new MP4Integer16Property(*this, "width")); 47 | 48 | AddProperty( /* 4 */ 49 | new MP4Integer16Property(*this, "height")); 50 | 51 | AddReserved(*this, "reserved3", 50); /* 5 */ 52 | 53 | 54 | ExpectChildAtom("d263", Required, OnlyOne); 55 | } 56 | 57 | void MP4S263Atom::Generate() 58 | { 59 | MP4Atom::Generate(); 60 | 61 | ((MP4Integer16Property*)m_pProperties[1])->SetValue(1); 62 | 63 | // property reserved2 has non-zero fixed values 64 | static uint8_t reserved3[50] = { 65 | 0x00, 0x48, 0x00, 0x00, 66 | 0x00, 0x48, 0x00, 0x00, 67 | 0x00, 0x00, 0x00, 0x00, 68 | 0x00, 0x01, 0x00, 0x00, 69 | 0x00, 0x00, 0x00, 0x00, 70 | 0x00, 0x00, 0x00, 0x00, 71 | 0x00, 0x00, 0x00, 0x00, 72 | 0x00, 0x00, 0x00, 0x00, 73 | 0x00, 0x00, 0x00, 0x00, 74 | 0x00, 0x00, 0x00, 0x00, 75 | 0x00, 0x00, 0x00, 0x00, 76 | 0x00, 0x00, 0x00, 0x24, 77 | 0xFF, 0xFF 78 | }; 79 | m_pProperties[5]->SetReadOnly(false); 80 | ((MP4BytesProperty*)m_pProperties[5])-> 81 | SetValue(reserved3, sizeof(reserved3)); 82 | m_pProperties[5]->SetReadOnly(true); 83 | } 84 | 85 | /////////////////////////////////////////////////////////////////////////////// 86 | 87 | } 88 | } // namespace mp4v2::impl 89 | -------------------------------------------------------------------------------- /src/atom_sdp.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * The contents of this file are subject to the Mozilla Public 3 | * License Version 1.1 (the "License"); you may not use this file 4 | * except in compliance with the License. You may obtain a copy of 5 | * the License at http://www.mozilla.org/MPL/ 6 | * 7 | * Software distributed under the License is distributed on an "AS 8 | * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 9 | * implied. See the License for the specific language governing 10 | * rights and limitations under the License. 11 | * 12 | * The Original Code is MPEG4IP. 13 | * 14 | * The Initial Developer of the Original Code is Cisco Systems Inc. 15 | * Portions created by Cisco Systems Inc. are 16 | * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. 17 | * 18 | * Contributor(s): 19 | * Dave Mackie dmackie@cisco.com 20 | */ 21 | 22 | #include "src/impl.h" 23 | 24 | namespace mp4v2 { 25 | namespace impl { 26 | 27 | /////////////////////////////////////////////////////////////////////////////// 28 | 29 | MP4SdpAtom::MP4SdpAtom(MP4File &file) : MP4Atom(file, "sdp ") 30 | { 31 | AddProperty( 32 | new MP4StringProperty(*this, "sdpText")); 33 | } 34 | 35 | void MP4SdpAtom::Read() 36 | { 37 | // read sdp string, length is implicit in size of atom 38 | uint64_t size = GetEnd() - m_File.GetPosition(); 39 | char* data = (char*) MP4Malloc(size + 1); 40 | ASSERT(data != NULL); 41 | try { 42 | m_File.ReadBytes((uint8_t*) data, size); 43 | data[size] = '\0'; 44 | ((MP4StringProperty*) m_pProperties[0])->SetValue(data); 45 | MP4Free(data); 46 | } 47 | catch (Exception*) { 48 | // free memory and rethrow 49 | MP4Free(data); 50 | throw; 51 | } 52 | } 53 | 54 | void MP4SdpAtom::Write() 55 | { 56 | // since length of string is implicit in size of atom 57 | // we need to handle this specially, and not write the terminating \0 58 | MP4StringProperty* pSdp = (MP4StringProperty*)m_pProperties[0]; 59 | const char* sdpText = pSdp->GetValue(); 60 | if (sdpText) { 61 | pSdp->SetFixedLength((uint32_t)strlen(sdpText)); 62 | } 63 | MP4Atom::Write(); 64 | pSdp->SetFixedLength(0); 65 | } 66 | 67 | /////////////////////////////////////////////////////////////////////////////// 68 | 69 | } 70 | } // namespace mp4v2::impl 71 | -------------------------------------------------------------------------------- /src/atom_sdtp.cpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // The contents of this file are subject to the Mozilla Public License 4 | // Version 1.1 (the "License"); you may not use this file except in 5 | // compliance with the License. You may obtain a copy of the License at 6 | // http://www.mozilla.org/MPL/ 7 | // 8 | // Software distributed under the License is distributed on an "AS IS" 9 | // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 10 | // License for the specific language governing rights and limitations 11 | // under the License. 12 | // 13 | // The Original Code is MP4v2. 14 | // 15 | // The Initial Developer of the Original Code is Kona Blend. 16 | // Portions created by Kona Blend are Copyright (C) 2008. 17 | // All Rights Reserved. 18 | // 19 | // Contributors: 20 | // Kona Blend, kona8lend@@gmail.com 21 | // 22 | /////////////////////////////////////////////////////////////////////////////// 23 | 24 | #include "src/impl.h" 25 | 26 | namespace mp4v2 { namespace impl { 27 | 28 | /////////////////////////////////////////////////////////////////////////////// 29 | 30 | MP4SdtpAtom::MP4SdtpAtom(MP4File &file) 31 | : MP4FullAtom ( file, "sdtp" ) 32 | , data ( *new MP4BytesProperty( *this, "data" )) 33 | { 34 | AddProperty( &data ); 35 | } 36 | 37 | /////////////////////////////////////////////////////////////////////////////// 38 | 39 | void MP4SdtpAtom::Read() 40 | { 41 | data.SetValueSize( m_size - 4 ); 42 | MP4FullAtom::Read(); 43 | } 44 | 45 | /////////////////////////////////////////////////////////////////////////////// 46 | 47 | }} // namespace mp4v2::impl 48 | -------------------------------------------------------------------------------- /src/atom_smi.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * The contents of this file are subject to the Mozilla Public 3 | * License Version 1.1 (the "License"); you may not use this file 4 | * except in compliance with the License. You may obtain a copy of 5 | * the License at http://www.mozilla.org/MPL/ 6 | * 7 | * Software distributed under the License is distributed on an "AS 8 | * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 9 | * implied. See the License for the specific language governing 10 | * rights and limitations under the License. 11 | * 12 | * The Original Code is MPEG4IP. 13 | * 14 | * The Initial Developer of the Original Code is Cisco Systems Inc. 15 | * Portions created by Cisco Systems Inc. are 16 | * Copyright (C) Cisco Systems Inc. 2004. All Rights Reserved. 17 | * 18 | * Contributor(s): 19 | * Bill May wmay@cisco.com 20 | * 21 | * Apple iTunes META data 22 | */ 23 | 24 | #include "src/impl.h" 25 | 26 | namespace mp4v2 { 27 | namespace impl { 28 | 29 | /////////////////////////////////////////////////////////////////////////////// 30 | 31 | MP4SmiAtom::MP4SmiAtom(MP4File &file) 32 | : MP4Atom(file, "meta") 33 | { 34 | 35 | AddProperty( new MP4BytesProperty(*this, "metadata")); 36 | 37 | } 38 | 39 | void MP4SmiAtom::Read() 40 | { 41 | // calculate size of the metadata from the atom size 42 | ((MP4BytesProperty*)m_pProperties[0])->SetValueSize(m_size); 43 | 44 | MP4Atom::Read(); 45 | } 46 | 47 | /////////////////////////////////////////////////////////////////////////////// 48 | 49 | } 50 | } // namespace mp4v2::impl 51 | -------------------------------------------------------------------------------- /src/atom_stbl.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * The contents of this file are subject to the Mozilla Public 3 | * License Version 1.1 (the "License"); you may not use this file 4 | * except in compliance with the License. You may obtain a copy of 5 | * the License at http://www.mozilla.org/MPL/ 6 | * 7 | * Software distributed under the License is distributed on an "AS 8 | * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 9 | * implied. See the License for the specific language governing 10 | * rights and limitations under the License. 11 | * 12 | * The Original Code is MPEG4IP. 13 | * 14 | * The Initial Developer of the Original Code is Cisco Systems Inc. 15 | * Portions created by Cisco Systems Inc. are 16 | * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. 17 | * 18 | * Contributor(s): 19 | * Dave Mackie dmackie@cisco.com 20 | */ 21 | 22 | #include "src/impl.h" 23 | 24 | namespace mp4v2 { namespace impl { 25 | 26 | /////////////////////////////////////////////////////////////////////////////// 27 | 28 | MP4StblAtom::MP4StblAtom(MP4File &file) 29 | : MP4Atom(file, "stbl") 30 | { 31 | ExpectChildAtom("stsd", Required, OnlyOne); 32 | ExpectChildAtom("stts", Required, OnlyOne); 33 | ExpectChildAtom("ctts", Optional, OnlyOne); 34 | ExpectChildAtom("stsz", Required, OnlyOne); 35 | ExpectChildAtom("stz2", Optional, OnlyOne); 36 | ExpectChildAtom("stsc", Required, OnlyOne); 37 | ExpectChildAtom("stco", Optional, OnlyOne); 38 | ExpectChildAtom("co64", Optional, OnlyOne); 39 | ExpectChildAtom("stss", Optional, OnlyOne); 40 | ExpectChildAtom("stsh", Optional, OnlyOne); 41 | ExpectChildAtom("stdp", Optional, OnlyOne); 42 | ExpectChildAtom("sdtp", Optional, OnlyOne); 43 | } 44 | 45 | void MP4StblAtom::Generate() 46 | { 47 | // as usual 48 | MP4Atom::Generate(); 49 | 50 | // but we also need one of the chunk offset atoms 51 | MP4Atom* pChunkOffsetAtom; 52 | if (m_File.Use64Bits(GetType())) { 53 | pChunkOffsetAtom = CreateAtom(m_File, this, "co64"); 54 | } else { 55 | pChunkOffsetAtom = CreateAtom(m_File, this, "stco"); 56 | } 57 | 58 | AddChildAtom(pChunkOffsetAtom); 59 | 60 | // and ask it to self generate 61 | pChunkOffsetAtom->Generate(); 62 | } 63 | 64 | /////////////////////////////////////////////////////////////////////////////// 65 | 66 | }} // namespace mp4v2::impl 67 | -------------------------------------------------------------------------------- /src/atom_stdp.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * The contents of this file are subject to the Mozilla Public 3 | * License Version 1.1 (the "License"); you may not use this file 4 | * except in compliance with the License. You may obtain a copy of 5 | * the License at http://www.mozilla.org/MPL/ 6 | * 7 | * Software distributed under the License is distributed on an "AS 8 | * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 9 | * implied. See the License for the specific language governing 10 | * rights and limitations under the License. 11 | * 12 | * The Original Code is MPEG4IP. 13 | * 14 | * The Initial Developer of the Original Code is Cisco Systems Inc. 15 | * Portions created by Cisco Systems Inc. are 16 | * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. 17 | * 18 | * Contributor(s): 19 | * Dave Mackie dmackie@cisco.com 20 | */ 21 | 22 | #include "src/impl.h" 23 | 24 | namespace mp4v2 { 25 | namespace impl { 26 | 27 | /////////////////////////////////////////////////////////////////////////////// 28 | 29 | MP4StdpAtom::MP4StdpAtom(MP4File &file) 30 | : MP4Atom(file, "stdp") 31 | { 32 | AddVersionAndFlags(); 33 | 34 | MP4Integer32Property* pCount = 35 | new MP4Integer32Property(*this, "entryCount"); 36 | pCount->SetImplicit(); 37 | AddProperty(pCount); 38 | 39 | MP4TableProperty* pTable = new MP4TableProperty(*this, "entries", pCount); 40 | AddProperty(pTable); 41 | 42 | pTable->AddProperty( 43 | new MP4Integer16Property(pTable->GetParentAtom(), "priority")); 44 | } 45 | 46 | void MP4StdpAtom::Read() 47 | { 48 | // table entry count computed from atom size 49 | ((MP4Integer32Property*)m_pProperties[2])->SetReadOnly(false); 50 | ((MP4Integer32Property*)m_pProperties[2])->SetValue((m_size - 4) / 2); 51 | ((MP4Integer32Property*)m_pProperties[2])->SetReadOnly(true); 52 | 53 | MP4Atom::Read(); 54 | } 55 | 56 | /////////////////////////////////////////////////////////////////////////////// 57 | 58 | } 59 | } // namespace mp4v2::impl 60 | -------------------------------------------------------------------------------- /src/atom_stsz.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * The contents of this file are subject to the Mozilla Public 3 | * License Version 1.1 (the "License"); you may not use this file 4 | * except in compliance with the License. You may obtain a copy of 5 | * the License at http://www.mozilla.org/MPL/ 6 | * 7 | * Software distributed under the License is distributed on an "AS 8 | * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 9 | * implied. See the License for the specific language governing 10 | * rights and limitations under the License. 11 | * 12 | * The Original Code is MPEG4IP. 13 | * 14 | * The Initial Developer of the Original Code is Cisco Systems Inc. 15 | * Portions created by Cisco Systems Inc. are 16 | * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. 17 | * 18 | * Contributor(s): 19 | * Dave Mackie dmackie@cisco.com 20 | */ 21 | 22 | #include "src/impl.h" 23 | 24 | namespace mp4v2 { 25 | namespace impl { 26 | 27 | /////////////////////////////////////////////////////////////////////////////// 28 | 29 | MP4StszAtom::MP4StszAtom(MP4File &file) 30 | : MP4Atom(file, "stsz") 31 | { 32 | AddVersionAndFlags(); /* 0, 1 */ 33 | 34 | AddProperty( /* 2 */ 35 | new MP4Integer32Property(*this, "sampleSize")); 36 | 37 | MP4Integer32Property* pCount = 38 | new MP4Integer32Property(*this, "sampleCount"); 39 | AddProperty(pCount); /* 3 */ 40 | 41 | MP4TableProperty* pTable = new MP4TableProperty(*this, "entries", pCount); 42 | AddProperty(pTable); /* 4 */ 43 | 44 | pTable->AddProperty( /* 4/0 */ 45 | new MP4Integer32Property(pTable->GetParentAtom(), "entrySize")); 46 | } 47 | 48 | void MP4StszAtom::Read() 49 | { 50 | ReadProperties(0, 4); 51 | 52 | uint32_t sampleSize = 53 | ((MP4Integer32Property*)m_pProperties[2])->GetValue(); 54 | 55 | // only attempt to read entries table if sampleSize is zero 56 | // i.e sample size is not constant 57 | m_pProperties[4]->SetImplicit(sampleSize != 0); 58 | 59 | ReadProperties(4); 60 | 61 | Skip(); // to end of atom 62 | } 63 | 64 | void MP4StszAtom::Write() 65 | { 66 | uint32_t sampleSize = 67 | ((MP4Integer32Property*)m_pProperties[2])->GetValue(); 68 | 69 | // only attempt to write entries table if sampleSize is zero 70 | // i.e sample size is not constant 71 | m_pProperties[4]->SetImplicit(sampleSize != 0); 72 | 73 | MP4Atom::Write(); 74 | } 75 | 76 | /////////////////////////////////////////////////////////////////////////////// 77 | 78 | } 79 | } // namespace mp4v2::impl 80 | -------------------------------------------------------------------------------- /src/atom_tfhd.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * The contents of this file are subject to the Mozilla Public 3 | * License Version 1.1 (the "License"); you may not use this file 4 | * except in compliance with the License. You may obtain a copy of 5 | * the License at http://www.mozilla.org/MPL/ 6 | * 7 | * Software distributed under the License is distributed on an "AS 8 | * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 9 | * implied. See the License for the specific language governing 10 | * rights and limitations under the License. 11 | * 12 | * The Original Code is MPEG4IP. 13 | * 14 | * The Initial Developer of the Original Code is Cisco Systems Inc. 15 | * Portions created by Cisco Systems Inc. are 16 | * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. 17 | * 18 | * Contributor(s): 19 | * Dave Mackie dmackie@cisco.com 20 | */ 21 | 22 | #include "src/impl.h" 23 | 24 | namespace mp4v2 { 25 | namespace impl { 26 | 27 | /////////////////////////////////////////////////////////////////////////////// 28 | 29 | MP4TfhdAtom::MP4TfhdAtom(MP4File &file) 30 | : MP4Atom(file, "tfhd") 31 | { 32 | AddVersionAndFlags(); /* 0, 1 */ 33 | AddProperty( /* 2 */ 34 | new MP4Integer32Property(*this, "trackId")); 35 | } 36 | 37 | void MP4TfhdAtom::AddProperties(uint32_t flags) 38 | { 39 | if (flags & 0x01) { 40 | // note this property is signed 64! 41 | AddProperty( 42 | new MP4Integer64Property(*this, "baseDataOffset")); 43 | } 44 | if (flags & 0x02) { 45 | AddProperty( 46 | new MP4Integer32Property(*this, "sampleDescriptionIndex")); 47 | } 48 | if (flags & 0x08) { 49 | AddProperty( 50 | new MP4Integer32Property(*this, "defaultSampleDuration")); 51 | } 52 | if (flags & 0x10) { 53 | AddProperty( 54 | new MP4Integer32Property(*this, "defaultSampleSize")); 55 | } 56 | if (flags & 0x20) { 57 | AddProperty( 58 | new MP4Integer32Property(*this, "defaultSampleFlags")); 59 | } 60 | } 61 | 62 | void MP4TfhdAtom::Read() 63 | { 64 | /* read atom version, flags, and trackId */ 65 | ReadProperties(0, 3); 66 | 67 | /* need to create the properties based on the atom flags */ 68 | AddProperties(GetFlags()); 69 | 70 | /* now we can read the remaining properties */ 71 | ReadProperties(3); 72 | 73 | Skip(); // to end of atom 74 | } 75 | 76 | /////////////////////////////////////////////////////////////////////////////// 77 | 78 | } 79 | } // namespace mp4v2::impl 80 | -------------------------------------------------------------------------------- /src/atom_treftype.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * The contents of this file are subject to the Mozilla Public 3 | * License Version 1.1 (the "License"); you may not use this file 4 | * except in compliance with the License. You may obtain a copy of 5 | * the License at http://www.mozilla.org/MPL/ 6 | * 7 | * Software distributed under the License is distributed on an "AS 8 | * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 9 | * implied. See the License for the specific language governing 10 | * rights and limitations under the License. 11 | * 12 | * The Original Code is MPEG4IP. 13 | * 14 | * The Initial Developer of the Original Code is Cisco Systems Inc. 15 | * Portions created by Cisco Systems Inc. are 16 | * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. 17 | * 18 | * Contributor(s): 19 | * Dave Mackie dmackie@cisco.com 20 | */ 21 | 22 | #include "src/impl.h" 23 | 24 | namespace mp4v2 { 25 | namespace impl { 26 | 27 | /////////////////////////////////////////////////////////////////////////////// 28 | 29 | MP4TrefTypeAtom::MP4TrefTypeAtom(MP4File &file, const char* type) 30 | : MP4Atom(file, type) 31 | { 32 | MP4Integer32Property* pCount = 33 | new MP4Integer32Property(*this, "entryCount"); 34 | pCount->SetImplicit(); 35 | AddProperty(pCount); /* 0 */ 36 | 37 | MP4TableProperty* pTable = new MP4TableProperty(*this, "entries", pCount); 38 | AddProperty(pTable); /* 1 */ 39 | 40 | pTable->AddProperty( /* 1, 0 */ 41 | new MP4Integer32Property(pTable->GetParentAtom(), "trackId")); 42 | } 43 | 44 | void MP4TrefTypeAtom::Read() 45 | { 46 | // table entry count computed from atom size 47 | ((MP4Integer32Property*)m_pProperties[0])->SetReadOnly(false); 48 | ((MP4Integer32Property*)m_pProperties[0])->SetValue(m_size / 4); 49 | ((MP4Integer32Property*)m_pProperties[0])->SetReadOnly(true); 50 | 51 | MP4Atom::Read(); 52 | } 53 | 54 | /////////////////////////////////////////////////////////////////////////////// 55 | 56 | } 57 | } // namespace mp4v2::impl 58 | -------------------------------------------------------------------------------- /src/atom_trun.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * The contents of this file are subject to the Mozilla Public 3 | * License Version 1.1 (the "License"); you may not use this file 4 | * except in compliance with the License. You may obtain a copy of 5 | * the License at http://www.mozilla.org/MPL/ 6 | * 7 | * Software distributed under the License is distributed on an "AS 8 | * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 9 | * implied. See the License for the specific language governing 10 | * rights and limitations under the License. 11 | * 12 | * The Original Code is MPEG4IP. 13 | * 14 | * The Initial Developer of the Original Code is Cisco Systems Inc. 15 | * Portions created by Cisco Systems Inc. are 16 | * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. 17 | * 18 | * Contributor(s): 19 | * Dave Mackie dmackie@cisco.com 20 | */ 21 | 22 | #include "src/impl.h" 23 | 24 | namespace mp4v2 { 25 | namespace impl { 26 | 27 | /////////////////////////////////////////////////////////////////////////////// 28 | 29 | MP4TrunAtom::MP4TrunAtom(MP4File &file) 30 | : MP4Atom(file, "trun") 31 | { 32 | AddVersionAndFlags(); /* 0, 1 */ 33 | AddProperty( /* 2 */ 34 | new MP4Integer32Property(*this, "sampleCount")); 35 | } 36 | 37 | void MP4TrunAtom::AddProperties(uint32_t flags) 38 | { 39 | if (flags & 0x01) { 40 | // Note this is a signed 32 value 41 | AddProperty( 42 | new MP4Integer32Property(*this, "dataOffset")); 43 | } 44 | if (flags & 0x04) { 45 | AddProperty( 46 | new MP4Integer32Property(*this, "firstSampleFlags")); 47 | } 48 | 49 | MP4TableProperty* pTable = 50 | new MP4TableProperty(*this, "samples", 51 | (MP4Integer32Property *)m_pProperties[2]); 52 | AddProperty(pTable); 53 | 54 | if (flags & 0x100) { 55 | pTable->AddProperty( 56 | new MP4Integer32Property(*this, "sampleDuration")); 57 | } 58 | if (flags & 0x200) { 59 | pTable->AddProperty( 60 | new MP4Integer32Property(*this, "sampleSize")); 61 | } 62 | if (flags & 0x400) { 63 | pTable->AddProperty( 64 | new MP4Integer32Property(*this, "sampleFlags")); 65 | } 66 | if (flags & 0x800) { 67 | pTable->AddProperty( 68 | new MP4Integer32Property(*this, "sampleCompositionTimeOffset")); 69 | } 70 | } 71 | 72 | void MP4TrunAtom::Read() 73 | { 74 | /* read atom version, flags, and sampleCount */ 75 | ReadProperties(0, 3); 76 | 77 | /* need to create the properties based on the atom flags */ 78 | AddProperties(GetFlags()); 79 | 80 | /* now we can read the remaining properties */ 81 | ReadProperties(3); 82 | 83 | Skip(); // to end of atom 84 | } 85 | 86 | /////////////////////////////////////////////////////////////////////////////// 87 | 88 | } 89 | } // namespace mp4v2::impl 90 | -------------------------------------------------------------------------------- /src/atom_udta.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * The contents of this file are subject to the Mozilla Public 3 | * License Version 1.1 (the "License"); you may not use this file 4 | * except in compliance with the License. You may obtain a copy of 5 | * the License at http://www.mozilla.org/MPL/ 6 | * 7 | * Software distributed under the License is distributed on an "AS 8 | * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 9 | * implied. See the License for the specific language governing 10 | * rights and limitations under the License. 11 | * 12 | * The Original Code is MPEG4IP. 13 | * 14 | * The Initial Developer of the Original Code is Cisco Systems Inc. 15 | * Portions created by Cisco Systems Inc. are 16 | * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. 17 | * 18 | * Contributor(s): 19 | * Dave Mackie dmackie@cisco.com 20 | */ 21 | 22 | #include "src/impl.h" 23 | 24 | namespace mp4v2 { 25 | namespace impl { 26 | 27 | /////////////////////////////////////////////////////////////////////////////// 28 | 29 | MP4UdtaAtom::MP4UdtaAtom(MP4File &file) 30 | : MP4Atom(file, "udta") 31 | { 32 | ExpectChildAtom("chpl", Optional, OnlyOne); 33 | ExpectChildAtom("cprt", Optional, Many); 34 | ExpectChildAtom("hnti", Optional, OnlyOne); 35 | ExpectChildAtom("meta", Optional, OnlyOne); 36 | ExpectChildAtom("\251cpy", Optional, OnlyOne); 37 | ExpectChildAtom("\251des", Optional, OnlyOne); 38 | ExpectChildAtom("\251nam", Optional, OnlyOne); 39 | ExpectChildAtom("\251cmt", Optional, OnlyOne); 40 | ExpectChildAtom("\251prd", Optional, OnlyOne); 41 | } 42 | 43 | void MP4UdtaAtom::Read() 44 | { 45 | if (ATOMID(m_pParentAtom->GetType()) == ATOMID("trak")) { 46 | ExpectChildAtom("hinf", Optional, OnlyOne); 47 | ExpectChildAtom("name", Optional, OnlyOne); 48 | } 49 | 50 | MP4Atom::Read(); 51 | } 52 | 53 | /////////////////////////////////////////////////////////////////////////////// 54 | 55 | } 56 | } // namespace mp4v2::impl 57 | -------------------------------------------------------------------------------- /src/atom_url.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * The contents of this file are subject to the Mozilla Public 3 | * License Version 1.1 (the "License"); you may not use this file 4 | * except in compliance with the License. You may obtain a copy of 5 | * the License at http://www.mozilla.org/MPL/ 6 | * 7 | * Software distributed under the License is distributed on an "AS 8 | * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 9 | * implied. See the License for the specific language governing 10 | * rights and limitations under the License. 11 | * 12 | * The Original Code is MPEG4IP. 13 | * 14 | * The Initial Developer of the Original Code is Cisco Systems Inc. 15 | * Portions created by Cisco Systems Inc. are 16 | * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. 17 | * 18 | * Contributor(s): 19 | * Dave Mackie dmackie@cisco.com 20 | */ 21 | 22 | #include "src/impl.h" 23 | 24 | namespace mp4v2 { 25 | namespace impl { 26 | 27 | /////////////////////////////////////////////////////////////////////////////// 28 | 29 | MP4UrlAtom::MP4UrlAtom(MP4File &file, const char *type) 30 | : MP4Atom(file, type) 31 | { 32 | AddVersionAndFlags(); 33 | AddProperty(new MP4StringProperty(*this, "location")); 34 | } 35 | 36 | void MP4UrlAtom::Read() 37 | { 38 | // read the version and flags properties 39 | ReadProperties(0, 2); 40 | 41 | // check if self-contained flag is set 42 | if (!(GetFlags() & 1)) { 43 | // if not then read url location 44 | ReadProperties(2); 45 | } 46 | 47 | Skip(); // to end of atom 48 | } 49 | 50 | void MP4UrlAtom::Write() 51 | { 52 | MP4StringProperty* pLocationProp = 53 | (MP4StringProperty*)m_pProperties[2]; 54 | 55 | // if no url location has been set 56 | // then set self-contained flag 57 | // and don't attempt to write anything 58 | if (pLocationProp->GetValue() == NULL) { 59 | SetFlags(GetFlags() | 1); 60 | pLocationProp->SetImplicit(true); 61 | } else { 62 | SetFlags(GetFlags() & 0xFFFFFE); 63 | pLocationProp->SetImplicit(false); 64 | } 65 | 66 | // write atom as usual 67 | MP4Atom::Write(); 68 | } 69 | 70 | /////////////////////////////////////////////////////////////////////////////// 71 | 72 | } 73 | } // namespace mp4v2::impl 74 | -------------------------------------------------------------------------------- /src/atom_urn.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * The contents of this file are subject to the Mozilla Public 3 | * License Version 1.1 (the "License"); you may not use this file 4 | * except in compliance with the License. You may obtain a copy of 5 | * the License at http://www.mozilla.org/MPL/ 6 | * 7 | * Software distributed under the License is distributed on an "AS 8 | * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 9 | * implied. See the License for the specific language governing 10 | * rights and limitations under the License. 11 | * 12 | * The Original Code is MPEG4IP. 13 | * 14 | * The Initial Developer of the Original Code is Cisco Systems Inc. 15 | * Portions created by Cisco Systems Inc. are 16 | * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. 17 | * 18 | * Contributor(s): 19 | * Dave Mackie dmackie@cisco.com 20 | */ 21 | 22 | #include "src/impl.h" 23 | 24 | namespace mp4v2 { 25 | namespace impl { 26 | 27 | /////////////////////////////////////////////////////////////////////////////// 28 | 29 | MP4UrnAtom::MP4UrnAtom(MP4File &file) 30 | : MP4Atom(file, "urn ") 31 | { 32 | AddVersionAndFlags(); 33 | AddProperty(new MP4StringProperty(*this, "name")); 34 | AddProperty(new MP4StringProperty(*this, "location")); 35 | } 36 | 37 | void MP4UrnAtom::Read() 38 | { 39 | // read the version, flags, and name properties 40 | ReadProperties(0, 3); 41 | 42 | // check if location is present 43 | if (m_File.GetPosition() < GetEnd()) { 44 | // read it 45 | ReadProperties(3); 46 | } 47 | 48 | Skip(); // to end of atom 49 | } 50 | 51 | /////////////////////////////////////////////////////////////////////////////// 52 | 53 | } 54 | } // namespace mp4v2::impl 55 | -------------------------------------------------------------------------------- /src/atom_uuid.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * The contents of this file are subject to the Mozilla Public 3 | * License Version 1.1 (the "License"); you may not use this file 4 | * except in compliance with the License. You may obtain a copy of 5 | * the License at http://www.mozilla.org/MPL/ 6 | * 7 | * Software distributed under the License is distributed on an "AS 8 | * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 9 | * implied. See the License for the specific language governing 10 | * rights and limitations under the License. 11 | * 12 | * The Original Code is MPEG4IP. 13 | * 14 | * The Initial Developer of the Original Code is Cisco Systems Inc. 15 | * Portions created by Cisco Systems Inc. are 16 | * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. 17 | * 18 | * Contributor(s): 19 | * 20 | */ 21 | 22 | #include "src/impl.h" 23 | 24 | namespace mp4v2 { 25 | namespace impl { 26 | 27 | /////////////////////////////////////////////////////////////////////////////// 28 | 29 | IPodUUIDAtom::IPodUUIDAtom(MP4File &file) 30 | : MP4Atom(file, "uuid") 31 | { 32 | // 33 | // This is a hack, the contents of this atom need to be well defined. 34 | // 35 | static uint8_t ipod_magic[] = { 36 | 0x6b, 0x68, 0x40, 0xf2, 0x5f, 0x24, 0x4f, 0xc5, 37 | 0xba, 0x39, 0xa5, 0x1b, 0xcf, 0x03, 0x23, 0xf3 38 | }; 39 | 40 | SetExtendedType(ipod_magic); 41 | 42 | MP4Integer32Property* value = new MP4Integer32Property(*this, "value"); 43 | value->SetValue(1); 44 | AddProperty(value); 45 | } 46 | 47 | /////////////////////////////////////////////////////////////////////////////// 48 | 49 | } 50 | } // namespace mp4v2::impl 51 | -------------------------------------------------------------------------------- /src/atom_video.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * The contents of this file are subject to the Mozilla Public 3 | * License Version 1.1 (the "License"); you may not use this file 4 | * except in compliance with the License. You may obtain a copy of 5 | * the License at http://www.mozilla.org/MPL/ 6 | * 7 | * Software distributed under the License is distributed on an "AS 8 | * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 9 | * implied. See the License for the specific language governing 10 | * rights and limitations under the License. 11 | * 12 | * The Original Code is MPEG4IP. 13 | * 14 | * The Initial Developer of the Original Code is Cisco Systems Inc. 15 | * Portions created by Cisco Systems Inc. are 16 | * Copyright (C) Cisco Systems Inc. 2004. All Rights Reserved. 17 | * 18 | * Contributor(s): 19 | * Bill May wmay@cisco.com 20 | */ 21 | 22 | #include "src/impl.h" 23 | 24 | namespace mp4v2 { 25 | namespace impl { 26 | 27 | /////////////////////////////////////////////////////////////////////////////// 28 | 29 | MP4VideoAtom::MP4VideoAtom (MP4File &file, const char *type) 30 | : MP4Atom(file, type) 31 | { 32 | AddReserved(*this, "reserved1", 6); /* 0 */ 33 | 34 | AddProperty( /* 1 */ 35 | new MP4Integer16Property(*this, "dataReferenceIndex")); 36 | 37 | AddReserved(*this, "reserved2", 16); /* 2 */ 38 | 39 | AddProperty( /* 3 */ 40 | new MP4Integer16Property(*this, "width")); 41 | AddProperty( /* 4 */ 42 | new MP4Integer16Property(*this, "height")); 43 | 44 | AddReserved(*this, "reserved3", 14); /* 5 */ 45 | 46 | MP4StringProperty* pProp = 47 | new MP4StringProperty(*this, "compressorName"); 48 | pProp->SetFixedLength(32); 49 | pProp->SetCountedFormat(true); 50 | pProp->SetValue(""); 51 | AddProperty(pProp); /* 6 */ 52 | 53 | AddProperty(/* 7 */ 54 | new MP4Integer16Property(*this, "depth")); 55 | AddProperty(/* 8 */ 56 | new MP4Integer16Property(*this, "colorTableId")); 57 | ExpectChildAtom("smi ", Optional, OnlyOne); 58 | } 59 | 60 | void MP4VideoAtom::Generate() 61 | { 62 | MP4Atom::Generate(); 63 | 64 | ((MP4Integer16Property*)m_pProperties[1])->SetValue(1); 65 | 66 | // property reserved3 has non-zero fixed values 67 | static uint8_t reserved3[14] = { 68 | 0x00, 0x48, 0x00, 0x00, 69 | 0x00, 0x48, 0x00, 0x00, 70 | 0x00, 0x00, 0x00, 0x00, 71 | 0x00, 0x01, 72 | }; 73 | m_pProperties[5]->SetReadOnly(false); 74 | ((MP4BytesProperty*)m_pProperties[5])-> 75 | SetValue(reserved3, sizeof(reserved3)); 76 | m_pProperties[5]->SetReadOnly(true); 77 | 78 | // depth and color table id values - should be set later 79 | // as far as depth - color table is most likely 0xff 80 | ((MP4IntegerProperty *)m_pProperties[7])->SetValue(0x18); 81 | ((MP4IntegerProperty *)m_pProperties[8])->SetValue(0xffff); 82 | 83 | } 84 | 85 | /////////////////////////////////////////////////////////////////////////////// 86 | 87 | } 88 | } // namespace mp4v2::impl 89 | -------------------------------------------------------------------------------- /src/atom_vmhd.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * The contents of this file are subject to the Mozilla Public 3 | * License Version 1.1 (the "License"); you may not use this file 4 | * except in compliance with the License. You may obtain a copy of 5 | * the License at http://www.mozilla.org/MPL/ 6 | * 7 | * Software distributed under the License is distributed on an "AS 8 | * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 9 | * implied. See the License for the specific language governing 10 | * rights and limitations under the License. 11 | * 12 | * The Original Code is MPEG4IP. 13 | * 14 | * The Initial Developer of the Original Code is Cisco Systems Inc. 15 | * Portions created by Cisco Systems Inc. are 16 | * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. 17 | * 18 | * Contributor(s): 19 | * Dave Mackie dmackie@cisco.com 20 | */ 21 | 22 | #include "src/impl.h" 23 | 24 | namespace mp4v2 { 25 | namespace impl { 26 | 27 | /////////////////////////////////////////////////////////////////////////////// 28 | 29 | MP4VmhdAtom::MP4VmhdAtom(MP4File &file) 30 | : MP4Atom(file, "vmhd") 31 | { 32 | AddVersionAndFlags(); 33 | AddReserved(*this, "reserved", 8); 34 | } 35 | 36 | void MP4VmhdAtom::Generate() 37 | { 38 | MP4Atom::Generate(); 39 | 40 | SetFlags(1); 41 | } 42 | 43 | /////////////////////////////////////////////////////////////////////////////// 44 | 45 | } 46 | } // namespace mp4v2::impl 47 | -------------------------------------------------------------------------------- /src/bmff/bmff.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // The contents of this file are subject to the Mozilla Public License 4 | // Version 1.1 (the "License"); you may not use this file except in 5 | // compliance with the License. You may obtain a copy of the License at 6 | // http://www.mozilla.org/MPL/ 7 | // 8 | // Software distributed under the License is distributed on an "AS IS" 9 | // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 10 | // License for the specific language governing rights and limitations 11 | // under the License. 12 | // 13 | // The Original Code is MP4v2. 14 | // 15 | // The Initial Developer of the Original Code is Kona Blend. 16 | // Portions created by Kona Blend are Copyright (C) 2008. 17 | // All Rights Reserved. 18 | // 19 | // Contributors: 20 | // Kona Blend, kona8lend@@gmail.com 21 | // 22 | /////////////////////////////////////////////////////////////////////////////// 23 | 24 | #ifndef MP4V2_IMPL_BMFF_BMFF_H 25 | #define MP4V2_IMPL_BMFF_BMFF_H 26 | 27 | /// @namespace mp4v2::impl::bmff (private) ISO base media file format. 28 | /// <b>WARNING: THIS IS A PRIVATE NAMESPACE. NOT FOR PUBLIC CONSUMPTION.</b> 29 | /// 30 | /// This namespace implements some features that are specified by 31 | /// ISO base media file format, ISO/IEC 14496-12:2005(E). 32 | /// 33 | namespace mp4v2 { namespace impl { namespace bmff { 34 | 35 | }}} 36 | 37 | /////////////////////////////////////////////////////////////////////////////// 38 | 39 | #include "typebmff.h" 40 | 41 | /////////////////////////////////////////////////////////////////////////////// 42 | 43 | #endif // MP4V2_IMPL_BMFF_BMFF_H 44 | -------------------------------------------------------------------------------- /src/bmff/impl.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // The contents of this file are subject to the Mozilla Public License 4 | // Version 1.1 (the "License"); you may not use this file except in 5 | // compliance with the License. You may obtain a copy of the License at 6 | // http://www.mozilla.org/MPL/ 7 | // 8 | // Software distributed under the License is distributed on an "AS IS" 9 | // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 10 | // License for the specific language governing rights and limitations 11 | // under the License. 12 | // 13 | // The Original Code is MP4v2. 14 | // 15 | // The Initial Developer of the Original Code is Kona Blend. 16 | // Portions created by Kona Blend are Copyright (C) 2008. 17 | // All Rights Reserved. 18 | // 19 | // Contributors: 20 | // Kona Blend, kona8lend@@gmail.com 21 | // 22 | /////////////////////////////////////////////////////////////////////////////// 23 | 24 | #ifndef MP4V2_IMPL_BMFF_IMPL_H 25 | #define MP4V2_IMPL_BMFF_IMPL_H 26 | 27 | /////////////////////////////////////////////////////////////////////////////// 28 | 29 | #include "src/impl.h" 30 | #include "bmff.h" 31 | 32 | /////////////////////////////////////////////////////////////////////////////// 33 | 34 | #endif // MP4V2_IMPL_BMFF_IMPL_H 35 | -------------------------------------------------------------------------------- /src/exception.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // The contents of this file are subject to the Mozilla Public License 4 | // Version 1.1 (the "License"); you may not use this file except in 5 | // compliance with the License. You may obtain a copy of the License at 6 | // http://www.mozilla.org/MPL/ 7 | // 8 | // Software distributed under the License is distributed on an "AS IS" 9 | // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 10 | // License for the specific language governing rights and limitations 11 | // under the License. 12 | // 13 | // The Original Code is MP4v2. 14 | // 15 | // The Initial Developer of the Original Code is Kona Blend. 16 | // Portions created by Kona Blend are Copyright (C) 2008. 17 | // All Rights Reserved. 18 | // 19 | // Contributors: 20 | // Kona Blend, kona8lend@@gmail.com 21 | // David Byron, dbyron0@gmail.com 22 | // 23 | /////////////////////////////////////////////////////////////////////////////// 24 | 25 | #ifndef MP4V2_IMPL_MP4EXCEPTION_H 26 | #define MP4V2_IMPL_MP4EXCEPTION_H 27 | 28 | namespace mp4v2 { namespace impl { 29 | 30 | /////////////////////////////////////////////////////////////////////////////// 31 | 32 | #ifdef NDEBUG 33 | # define EXCEPTION(message) mp4v2::impl::Exception(message) 34 | # define PLATFORM_EXCEPTION(message, errno) mp4v2::impl::PlatformException(message, errno) 35 | #else 36 | # define EXCEPTION(message) mp4v2::impl::Exception(message, __FILE__, __LINE__, __FUNCTION__) 37 | # define PLATFORM_EXCEPTION(message, errno) mp4v2::impl::PlatformException(message, errno, __FILE__, __LINE__, __FUNCTION__) 38 | #endif 39 | 40 | class Exception 41 | { 42 | public: 43 | explicit Exception( const string& what_ ); 44 | explicit Exception( const string& what_, 45 | const char *file_, 46 | int line_, 47 | const char *function_ ); 48 | virtual ~Exception(); 49 | 50 | virtual string msg() const; 51 | 52 | public: 53 | const string what; 54 | const string file; 55 | const int line; 56 | const string function; 57 | }; 58 | 59 | class PlatformException : public Exception 60 | { 61 | public: 62 | explicit PlatformException( const string& what_, 63 | int errno_ ); 64 | explicit PlatformException( const string& what_, 65 | int errno_, 66 | const char *file_, 67 | int line_, 68 | const char *function_ ); 69 | virtual ~PlatformException(); 70 | 71 | virtual string msg() const; 72 | 73 | public: 74 | const int m_errno; 75 | }; 76 | 77 | /////////////////////////////////////////////////////////////////////////////// 78 | 79 | }} // namespace mp4v2::impl 80 | 81 | #endif // MP4V2_IMPL_MP4EXCEPTION_H 82 | -------------------------------------------------------------------------------- /src/impl.h: -------------------------------------------------------------------------------- 1 | #ifndef MP4V2_IMPL_IMPL_H 2 | #define MP4V2_IMPL_IMPL_H 3 | 4 | /////////////////////////////////////////////////////////////////////////////// 5 | 6 | #include "src.h" 7 | 8 | /////////////////////////////////////////////////////////////////////////////// 9 | 10 | #endif // MP4V2_IMPL_IMPL_H 11 | -------------------------------------------------------------------------------- /src/itmf/generic.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // The contents of this file are subject to the Mozilla Public License 4 | // Version 1.1 (the "License"); you may not use this file except in 5 | // compliance with the License. You may obtain a copy of the License at 6 | // http://www.mozilla.org/MPL/ 7 | // 8 | // Software distributed under the License is distributed on an "AS IS" 9 | // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 10 | // License for the specific language governing rights and limitations 11 | // under the License. 12 | // 13 | // The Original Code is MP4v2. 14 | // 15 | // The Initial Developer of the Original Code is Kona Blend. 16 | // Portions created by Kona Blend are Copyright (C) 2008. 17 | // All Rights Reserved. 18 | // 19 | // Contributors: 20 | // KonaBlend, kona8lend@gmail.com 21 | // 22 | /////////////////////////////////////////////////////////////////////////////// 23 | 24 | #ifndef MP4V2_IMPL_ITMF_GENERIC_H 25 | #define MP4V2_IMPL_ITMF_GENERIC_H 26 | 27 | namespace mp4v2 { namespace impl { namespace itmf { 28 | 29 | /////////////////////////////////////////////////////////////////////////////// 30 | 31 | MP4ItmfItem* 32 | genericItemAlloc( const string& code, uint32_t numData ); 33 | 34 | void 35 | genericItemFree( MP4ItmfItem* item ); 36 | 37 | void 38 | genericItemListFree( MP4ItmfItemList* list ); 39 | 40 | /////////////////////////////////////////////////////////////////////////////// 41 | 42 | MP4ItmfItemList* 43 | genericGetItems( MP4File& file ); 44 | 45 | MP4ItmfItemList* 46 | genericGetItemsByCode( MP4File& file, const string& code ); 47 | 48 | MP4ItmfItemList* 49 | genericGetItemsByMeaning( MP4File& file, const string& meaning, const string& name ); 50 | 51 | /////////////////////////////////////////////////////////////////////////////// 52 | 53 | bool 54 | genericAddItem( MP4File& file, const MP4ItmfItem* item ); 55 | 56 | bool 57 | genericSetItem( MP4File& file, const MP4ItmfItem* item ); 58 | 59 | bool 60 | genericRemoveItem( MP4File& file, const MP4ItmfItem* item ); 61 | 62 | /////////////////////////////////////////////////////////////////////////////// 63 | 64 | }}} // namespace mp4v2::impl::itmf 65 | 66 | #endif // MP4V2_IMPL_ITMF_GENERIC_H 67 | -------------------------------------------------------------------------------- /src/itmf/impl.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // The contents of this file are subject to the Mozilla Public License 4 | // Version 1.1 (the "License"); you may not use this file except in 5 | // compliance with the License. You may obtain a copy of the License at 6 | // http://www.mozilla.org/MPL/ 7 | // 8 | // Software distributed under the License is distributed on an "AS IS" 9 | // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 10 | // License for the specific language governing rights and limitations 11 | // under the License. 12 | // 13 | // The Original Code is MP4v2. 14 | // 15 | // The Initial Developer of the Original Code is Kona Blend. 16 | // Portions created by Kona Blend are Copyright (C) 2008. 17 | // All Rights Reserved. 18 | // 19 | // Contributors: 20 | // Kona Blend, kona8lend@@gmail.com 21 | // 22 | /////////////////////////////////////////////////////////////////////////////// 23 | 24 | #ifndef MP4V2_IMPL_ITMF_IMPL_H 25 | #define MP4V2_IMPL_ITMF_IMPL_H 26 | 27 | /////////////////////////////////////////////////////////////////////////////// 28 | 29 | #include "src/impl.h" 30 | #include "itmf.h" 31 | 32 | /////////////////////////////////////////////////////////////////////////////// 33 | 34 | #endif // MP4V2_IMPL_ITMF_IMPL_H 35 | -------------------------------------------------------------------------------- /src/itmf/itmf.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // The contents of this file are subject to the Mozilla Public License 4 | // Version 1.1 (the "License"); you may not use this file except in 5 | // compliance with the License. You may obtain a copy of the License at 6 | // http://www.mozilla.org/MPL/ 7 | // 8 | // Software distributed under the License is distributed on an "AS IS" 9 | // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 10 | // License for the specific language governing rights and limitations 11 | // under the License. 12 | // 13 | // The Original Code is MP4v2. 14 | // 15 | // The Initial Developer of the Original Code is Kona Blend. 16 | // Portions created by Kona Blend are Copyright (C) 2008. 17 | // All Rights Reserved. 18 | // 19 | // Contributors: 20 | // Kona Blend, kona8lend@@gmail.com 21 | // 22 | /////////////////////////////////////////////////////////////////////////////// 23 | 24 | #ifndef MP4V2_IMPL_ITMF_ITMF_H 25 | #define MP4V2_IMPL_ITMF_ITMF_H 26 | 27 | /// @namespace mp4v2::impl::itmf (private) iTunes Metadata Format. 28 | /// <b>WARNING: THIS IS A PRIVATE NAMESPACE. NOT FOR PUBLIC CONSUMPTION.</b> 29 | /// 30 | /// This namespace implements some features that are specified by the 31 | /// iTunes Metadata Format Specification, revision 2008-04-16. 32 | /// 33 | namespace mp4v2 { namespace impl { namespace itmf { 34 | 35 | }}} 36 | 37 | /////////////////////////////////////////////////////////////////////////////// 38 | 39 | #include "CoverArtBox.h" 40 | #include "Tags.h" 41 | #include "generic.h" 42 | 43 | /////////////////////////////////////////////////////////////////////////////// 44 | 45 | #endif // MP4V2_IMPL_ITMF_ITMF_H 46 | -------------------------------------------------------------------------------- /src/qosqualifiers.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The contents of this file are subject to the Mozilla Public 3 | * License Version 1.1 (the "License"); you may not use this file 4 | * except in compliance with the License. You may obtain a copy of 5 | * the License at http://www.mozilla.org/MPL/ 6 | * 7 | * Software distributed under the License is distributed on an "AS 8 | * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 9 | * implied. See the License for the specific language governing 10 | * rights and limitations under the License. 11 | * 12 | * The Original Code is MPEG4IP. 13 | * 14 | * The Initial Developer of the Original Code is Cisco Systems Inc. 15 | * Portions created by Cisco Systems Inc. are 16 | * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. 17 | * 18 | * Contributor(s): 19 | * Dave Mackie dmackie@cisco.com 20 | */ 21 | 22 | #ifndef MP4V2_IMPL_QOSQUALIFIERS_H 23 | #define MP4V2_IMPL_QOSQUALIFIERS_H 24 | 25 | namespace mp4v2 { 26 | namespace impl { 27 | 28 | /////////////////////////////////////////////////////////////////////////////// 29 | 30 | const uint8_t MP4QosDescrTag = 0x0C; 31 | const uint8_t MP4QosTagsStart = 0x01; 32 | const uint8_t MP4MaxDelayQosTag = 0x01; 33 | const uint8_t MP4PrefMaxDelayQosTag = 0x02; 34 | const uint8_t MP4LossProbQosTag = 0x03; 35 | const uint8_t MP4MaxGapLossQosTag = 0x04; 36 | const uint8_t MP4MaxAUSizeQosTag = 0x41; 37 | const uint8_t MP4AvgAUSizeQosTag = 0x42; 38 | const uint8_t MP4MaxAURateQosTag = 0x43; 39 | const uint8_t MP4QosTagsEnd = 0xFF; 40 | 41 | class MP4QosDescriptorBase : public MP4Descriptor { 42 | public: 43 | MP4QosDescriptorBase(MP4Atom &parentAtom, uint8_t tag); 44 | private: 45 | MP4QosDescriptorBase(); 46 | MP4QosDescriptorBase ( const MP4QosDescriptorBase &src ); 47 | MP4QosDescriptorBase &operator= ( const MP4QosDescriptorBase &src ); 48 | }; 49 | 50 | class MP4UnknownQosQualifier : public MP4Descriptor { 51 | public: 52 | MP4UnknownQosQualifier(MP4Atom &parentAtom); 53 | void Read(MP4File& file); 54 | private: 55 | MP4UnknownQosQualifier(); 56 | MP4UnknownQosQualifier ( const MP4UnknownQosQualifier &src ); 57 | MP4UnknownQosQualifier &operator= ( const MP4UnknownQosQualifier &src ); 58 | }; 59 | 60 | /////////////////////////////////////////////////////////////////////////////// 61 | 62 | } 63 | } // namespace mp4v2::impl 64 | 65 | #endif // MP4V2_IMPL_QOSQUALIFIERS_H 66 | -------------------------------------------------------------------------------- /src/qtff/coding.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // The contents of this file are subject to the Mozilla Public License 4 | // Version 1.1 (the "License"); you may not use this file except in 5 | // compliance with the License. You may obtain a copy of the License at 6 | // http://www.mozilla.org/MPL/ 7 | // 8 | // Software distributed under the License is distributed on an "AS IS" 9 | // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 10 | // License for the specific language governing rights and limitations 11 | // under the License. 12 | // 13 | // The Original Code is MP4v2. 14 | // 15 | // The Initial Developer of the Original Code is Kona Blend. 16 | // Portions created by Kona Blend are Copyright (C) 2008. 17 | // All Rights Reserved. 18 | // 19 | // Contributors: 20 | // Kona Blend, kona8lend@@gmail.com 21 | // 22 | /////////////////////////////////////////////////////////////////////////////// 23 | 24 | #ifndef MP4V2_IMPL_QTFF_CODING_H 25 | #define MP4V2_IMPL_QTFF_CODING_H 26 | 27 | namespace mp4v2 { namespace impl { namespace qtff { 28 | 29 | /////////////////////////////////////////////////////////////////////////////// 30 | 31 | bool findCoding( MP4FileHandle file, uint16_t trackIndex, MP4Atom*& coding ); 32 | 33 | /////////////////////////////////////////////////////////////////////////////// 34 | 35 | }}} // namespace mp4v2::impl::qtff 36 | 37 | #endif // MP4V2_IMPL_QTTF_CODING_H 38 | -------------------------------------------------------------------------------- /src/qtff/impl.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // The contents of this file are subject to the Mozilla Public License 4 | // Version 1.1 (the "License"); you may not use this file except in 5 | // compliance with the License. You may obtain a copy of the License at 6 | // http://www.mozilla.org/MPL/ 7 | // 8 | // Software distributed under the License is distributed on an "AS IS" 9 | // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 10 | // License for the specific language governing rights and limitations 11 | // under the License. 12 | // 13 | // The Original Code is MP4v2. 14 | // 15 | // The Initial Developer of the Original Code is Kona Blend. 16 | // Portions created by Kona Blend are Copyright (C) 2008. 17 | // All Rights Reserved. 18 | // 19 | // Contributors: 20 | // Kona Blend, kona8lend@@gmail.com 21 | // 22 | /////////////////////////////////////////////////////////////////////////////// 23 | 24 | #ifndef MP4V2_IMPL_QTFF_IMPL_H 25 | #define MP4V2_IMPL_QTFF_IMPL_H 26 | 27 | /////////////////////////////////////////////////////////////////////////////// 28 | 29 | #include "src/impl.h" 30 | #include "qtff.h" 31 | 32 | /////////////////////////////////////////////////////////////////////////////// 33 | 34 | #endif // MP4V2_IMPL_QTFF_IMPL_H 35 | -------------------------------------------------------------------------------- /src/qtff/qtff.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // The contents of this file are subject to the Mozilla Public License 4 | // Version 1.1 (the "License"); you may not use this file except in 5 | // compliance with the License. You may obtain a copy of the License at 6 | // http://www.mozilla.org/MPL/ 7 | // 8 | // Software distributed under the License is distributed on an "AS IS" 9 | // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 10 | // License for the specific language governing rights and limitations 11 | // under the License. 12 | // 13 | // The Original Code is MP4v2. 14 | // 15 | // The Initial Developer of the Original Code is Kona Blend. 16 | // Portions created by Kona Blend are Copyright (C) 2008. 17 | // All Rights Reserved. 18 | // 19 | // Contributors: 20 | // Kona Blend, kona8lend@@gmail.com 21 | // 22 | /////////////////////////////////////////////////////////////////////////////// 23 | 24 | #ifndef MP4V2_IMPL_QTFF_QTFF_H 25 | #define MP4V2_IMPL_QTFF_QTFF_H 26 | 27 | /// @namespace mp4v2::impl::qtff (private) QuickTime File Format. 28 | /// <b>WARNING: THIS IS A PRIVATE NAMESPACE. NOT FOR PUBLIC CONSUMPTION.</b> 29 | /// 30 | /// This namespace implements some features that are specified by the 31 | /// QuickTime File Format Specification, revision 2007-09-04. 32 | /// 33 | namespace mp4v2 { namespace impl { namespace qtff { 34 | 35 | }}} 36 | 37 | /////////////////////////////////////////////////////////////////////////////// 38 | 39 | #include "ColorParameterBox.h" 40 | #include "PictureAspectRatioBox.h" 41 | #include "coding.h" 42 | 43 | /////////////////////////////////////////////////////////////////////////////// 44 | 45 | #endif // MP4V2_IMPL_QTTF_QTFF_H 46 | -------------------------------------------------------------------------------- /src/src.h: -------------------------------------------------------------------------------- 1 | #ifndef MP4V2_IMPL_SRC_H 2 | #define MP4V2_IMPL_SRC_H 3 | 4 | /////////////////////////////////////////////////////////////////////////////// 5 | 6 | #include "libplatform/platform.h" 7 | #include <mp4v2/mp4v2.h> 8 | 9 | /////////////////////////////////////////////////////////////////////////////// 10 | 11 | namespace mp4v2 { namespace impl { 12 | using namespace mp4v2::platform; 13 | using io::File; 14 | using io::FileSystem; 15 | }} // namspace mp4v2::impl 16 | 17 | /////////////////////////////////////////////////////////////////////////////// 18 | 19 | #include "text.h" 20 | #include "enum.h" 21 | #include "exception.h" 22 | 23 | #include "bmff/typebmff.h" 24 | #include "itmf/type.h" 25 | 26 | #include "util.h" 27 | #include "log.h" 28 | #include "mp4util.h" 29 | #include "mp4array.h" 30 | #include "mp4track.h" 31 | #include "mp4file.h" 32 | #include "mp4property.h" 33 | #include "mp4container.h" 34 | 35 | #include "mp4atom.h" 36 | #include "atoms.h" 37 | 38 | #include "bmff/bmff.h" 39 | #include "itmf/itmf.h" 40 | #include "qtff/qtff.h" 41 | 42 | #include "mp4descriptor.h" 43 | #include "descriptors.h" 44 | #include "ocidescriptors.h" 45 | 46 | #include "qosqualifiers.h" 47 | #include "odcommands.h" 48 | #include "rtphint.h" 49 | 50 | /////////////////////////////////////////////////////////////////////////////// 51 | 52 | #endif // MP4V2_IMPL_SRC_H 53 | -------------------------------------------------------------------------------- /src/text.cpp: -------------------------------------------------------------------------------- 1 | #include "src/impl.h" 2 | 3 | namespace mp4v2 { namespace impl { 4 | 5 | /////////////////////////////////////////////////////////////////////////////// 6 | 7 | bool 8 | LessIgnoreCase::operator()( const string& xstr, const string& ystr ) const 9 | { 10 | const string::size_type xlen = xstr.length(); 11 | const string::size_type ylen = ystr.length(); 12 | 13 | if( xlen < ylen ) { 14 | for( string::size_type i = 0; i < xlen; i++ ) { 15 | const char x = std::toupper( xstr[i] ); 16 | const char y = std::toupper( ystr[i] ); 17 | 18 | if( x < y ) 19 | return true; 20 | else if ( x > y ) 21 | return false; 22 | } 23 | return true; 24 | } 25 | else { 26 | for( string::size_type i = 0; i < ylen; i++ ) { 27 | const char x = std::toupper( xstr[i] ); 28 | const char y = std::toupper( ystr[i] ); 29 | 30 | if( x < y ) 31 | return true; 32 | else if ( x > y ) 33 | return false; 34 | } 35 | return false; 36 | } 37 | } 38 | 39 | /////////////////////////////////////////////////////////////////////////////// 40 | 41 | }} // namespace mp4v2::impl 42 | -------------------------------------------------------------------------------- /src/text.h: -------------------------------------------------------------------------------- 1 | #ifndef MP4V2_IMPL_TEXT_H 2 | #define MP4V2_IMPL_TEXT_H 3 | 4 | namespace mp4v2 { namespace impl { 5 | 6 | /////////////////////////////////////////////////////////////////////////////// 7 | 8 | struct MP4V2_EXPORT LessIgnoreCase : less<string> 9 | { 10 | bool operator()( const string&, const string& ) const; 11 | }; 12 | 13 | /////////////////////////////////////////////////////////////////////////////// 14 | 15 | }} // namespace mp4v2::impl 16 | 17 | #endif // MP4V2_IMPL_TEXT_H 18 | -------------------------------------------------------------------------------- /src/util.h: -------------------------------------------------------------------------------- 1 | #ifndef MP4V2_IMPL_UTIL_H 2 | #define MP4V2_IMPL_UTIL_H 3 | 4 | namespace mp4v2 { namespace impl { 5 | 6 | /////////////////////////////////////////////////////////////////////////////// 7 | 8 | inline int8_t max( int8_t a, int8_t b ) { 9 | return ( a > b ) ? a : b; 10 | } 11 | 12 | inline int16_t max( int16_t a, int16_t b ) { 13 | return ( a > b ) ? a : b; 14 | } 15 | 16 | inline int32_t max( int32_t a, int32_t b ) { 17 | return ( a > b ) ? a : b; 18 | } 19 | 20 | inline int64_t max( int64_t a, int64_t b ) { 21 | return ( a > b ) ? a : b; 22 | } 23 | 24 | /////////////////////////////////////////////////////////////////////////////// 25 | 26 | inline uint8_t max( uint8_t a, uint8_t b ) { 27 | return ( a > b ) ? a : b; 28 | } 29 | 30 | inline uint16_t max( uint16_t a, uint16_t b ) { 31 | return ( a > b ) ? a : b; 32 | } 33 | 34 | inline uint32_t max( uint32_t a, uint32_t b ) { 35 | return ( a > b ) ? a : b; 36 | } 37 | 38 | inline uint64_t max( uint64_t a, uint64_t b ) { 39 | return ( a > b ) ? a : b; 40 | } 41 | 42 | /////////////////////////////////////////////////////////////////////////////// 43 | 44 | inline int8_t min( int8_t a, int8_t b ) { 45 | return ( a < b ) ? a : b; 46 | } 47 | 48 | inline int16_t min( int16_t a, int16_t b ) { 49 | return ( a < b ) ? a : b; 50 | } 51 | 52 | inline int32_t min( int32_t a, int32_t b ) { 53 | return ( a < b ) ? a : b; 54 | } 55 | 56 | inline int64_t min( int64_t a, int64_t b ) { 57 | return ( a < b ) ? a : b; 58 | } 59 | 60 | /////////////////////////////////////////////////////////////////////////////// 61 | 62 | inline uint8_t min( uint8_t a, uint8_t b ) { 63 | return ( a < b ) ? a : b; 64 | } 65 | 66 | inline uint16_t min( uint16_t a, uint16_t b ) { 67 | return ( a < b ) ? a : b; 68 | } 69 | 70 | inline uint32_t min( uint32_t a, uint32_t b ) { 71 | return ( a < b ) ? a : b; 72 | } 73 | 74 | inline uint64_t min( uint64_t a, uint64_t b ) { 75 | return ( a < b ) ? a : b; 76 | } 77 | 78 | /////////////////////////////////////////////////////////////////////////////// 79 | 80 | }} // namespace mp4v2::impl 81 | 82 | #endif // MP4V2_IMPL_UTIL_H 83 | -------------------------------------------------------------------------------- /test/c_api.c: -------------------------------------------------------------------------------- 1 | /* 2 | * The contents of this file are subject to the Mozilla Public 3 | * License Version 1.1 (the "License"); you may not use this file 4 | * except in compliance with the License. You may obtain a copy of 5 | * the License at http://www.mozilla.org/MPL/ 6 | * 7 | * Software distributed under the License is distributed on an "AS 8 | * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 9 | * implied. See the License for the specific language governing 10 | * rights and limitations under the License. 11 | * 12 | * The Original Code is MPEG4IP. 13 | * 14 | * The Initial Developer of the Original Code is Cisco Systems Inc. 15 | * Portions created by Cisco Systems Inc. are 16 | * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. 17 | * 18 | * Contributor(s): 19 | * Dave Mackie dmackie@cisco.com 20 | */ 21 | 22 | #include <mp4v2/mp4v2.h> 23 | #include <string.h> 24 | 25 | int main(int argc, char** argv) 26 | { 27 | #if 0 28 | MP4FileHandle mp4File = MP4Read(argv[1]); 29 | if (!mp4File) 30 | return 1; 31 | 32 | MP4Dump(mp4File, 0); 33 | MP4Close(mp4File, 0); 34 | 35 | return 0; 36 | #else 37 | MP4FileHandle mp4File = MP4Read(argv[1]); 38 | MP4LogSetLevel(MP4_LOG_VERBOSE4); 39 | if (MP4HaveAtom(mp4File, "moov.mvhd")) { 40 | printf("found moov.mvhd\n"); 41 | } 42 | if (MP4HaveTrackAtom(mp4File, 1, argv[2])) { 43 | printf("found %s\n", argv[2]); 44 | } else { 45 | printf("didn't find it\n"); 46 | } 47 | 48 | #if 0 49 | uint8_t* data = (uint8_t*)"this is my tag data"; 50 | uint32_t len = strlen((char*)data); 51 | MP4SetMetadataFreeForm(mp4File, "mytag1", data, len); 52 | MP4SetMetadataFreeForm(mp4File, "my_tag2", data, len); 53 | #endif 54 | MP4Close(mp4File, 0); 55 | return 0; 56 | #endif 57 | } 58 | 59 | -------------------------------------------------------------------------------- /test/urltrack.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * The contents of this file are subject to the Mozilla Public 3 | * License Version 1.1 (the "License"); you may not use this file 4 | * except in compliance with the License. You may obtain a copy of 5 | * the License at http://www.mozilla.org/MPL/ 6 | * 7 | * Software distributed under the License is distributed on an "AS 8 | * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 9 | * implied. See the License for the specific language governing 10 | * rights and limitations under the License. 11 | * 12 | * The Original Code is MPEG4IP. 13 | * 14 | * The Initial Developer of the Original Code is Cisco Systems Inc. 15 | * Portions created by Cisco Systems Inc. are 16 | * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. 17 | * 18 | * Contributor(s): 19 | * Dave Mackie dmackie@cisco.com 20 | */ 21 | 22 | #include <mp4v2/mp4v2.h> 23 | #include <string.h> 24 | 25 | main(int argc, char** argv) 26 | { 27 | if (argc < 2) { 28 | fprintf(stderr, "Usage: %s <file>\n", argv[0]); 29 | return 1; 30 | } 31 | 32 | MP4LogSetLevel(MP4_LOG_VERBOSE4); 33 | MP4FileHandle mp4File = MP4Create(argv[1]); 34 | if (!mp4File) 35 | return 1; 36 | 37 | MP4TrackId urlTrackId = 38 | #if 0 39 | MP4AddTrack(mp4File, "URLF"); 40 | #else 41 | MP4AddHrefTrack(mp4File, 90000, MP4_INVALID_DURATION); 42 | #endif 43 | printf("urlTrackId %d\n", urlTrackId); 44 | 45 | uint8_t i; 46 | char url[128]; 47 | 48 | for (i = 1; i <= 5; i++) { 49 | sprintf(url, "http://server.com/foo/bar%u.html", i); 50 | 51 | MP4WriteSample(mp4File, urlTrackId, 52 | (uint8_t*)url, strlen(url) + 1, (MP4Duration)i); 53 | } 54 | 55 | MP4Close(mp4File); 56 | 57 | mp4File = MP4Read(argv[1]); 58 | 59 | // check that we can find the track again 60 | #if 0 61 | urlTrackId = MP4FindTrackId(mp4File, 0, "URLF"); 62 | #else 63 | urlTrackId = MP4FindTrackId(mp4File, 0, MP4_CNTL_TRACK_TYPE); 64 | #endif 65 | printf("urlTrackId %d\n", urlTrackId); 66 | 67 | for (i = 1; i <= 5; i++) { 68 | uint8_t* pSample = NULL; 69 | uint32_t sampleSize = 0; 70 | MP4Duration duration; 71 | bool rc; 72 | 73 | rc = MP4ReadSample(mp4File, urlTrackId, i, 74 | &pSample, &sampleSize, NULL, &duration); 75 | 76 | if (rc) { 77 | printf("Sample %i duration %llu: %s\n", 78 | i, duration, pSample); 79 | MP4Free(pSample); 80 | } else { 81 | printf("Couldn't read sample %i\n", i); 82 | } 83 | } 84 | 85 | MP4Close(mp4File); 86 | 87 | return 0; 88 | } 89 | 90 | -------------------------------------------------------------------------------- /testsuite/config/unix.exp: -------------------------------------------------------------------------------- 1 | load_lib command.exp 2 | -------------------------------------------------------------------------------- /testsuite/main/standardUsage.exp: -------------------------------------------------------------------------------- 1 | ::command::test_standardUsage mp4art 2 | ::command::test_standardUsage mp4file 3 | ::command::test_standardUsage mp4subtitle 4 | ::command::test_standardUsage mp4track 5 | -------------------------------------------------------------------------------- /util/impl.h: -------------------------------------------------------------------------------- 1 | #ifndef MP4V2_UTIL_IMPL_H 2 | #define MP4V2_UTIL_IMPL_H 3 | 4 | /////////////////////////////////////////////////////////////////////////////// 5 | 6 | #include "libutil/util.h" 7 | 8 | /////////////////////////////////////////////////////////////////////////////// 9 | 10 | #endif // MP4V2_UTIL_IMPL_H 11 | -------------------------------------------------------------------------------- /vstudio/include/mp4v2/project.h: -------------------------------------------------------------------------------- 1 | #ifndef MP4V2_PROJECT_H 2 | #define MP4V2_PROJECT_H 3 | 4 | /*****************************************************************************/ 5 | 6 | #define MP4V2_PROJECT_name "MP4v2" 7 | #define MP4V2_PROJECT_name_lower "mp4v2" 8 | #define MP4V2_PROJECT_name_upper "MP4V2" 9 | #define MP4V2_PROJECT_name_formal "MP4v2 2.1.3" 10 | #define MP4V2_PROJECT_url_website "https://mp4v2.org" 11 | #define MP4V2_PROJECT_url_downloads "https://github.com/enzo1982/releases" 12 | #define MP4V2_PROJECT_url_discussion "https://github.com/enzo1982/discussions" 13 | #define MP4V2_PROJECT_url_bugreport "https://github.com/enzo1982/issues" 14 | #define MP4V2_PROJECT_support "<support@mp4v2.org>" 15 | #define MP4V2_PROJECT_version "2.1.3" 16 | #define MP4V2_PROJECT_version_hex 0x00020103 17 | #define MP4V2_PROJECT_version_major 2 18 | #define MP4V2_PROJECT_version_minor 1 19 | #define MP4V2_PROJECT_version_point 3 20 | #define MP4V2_PROJECT_repo_url "git@github.com:enzo1982/mp4v2.git" 21 | #define MP4V2_PROJECT_build "Wed May 10 22:42:12 UTC 2023" 22 | 23 | /*****************************************************************************/ 24 | 25 | #endif /* MP4V2_PROJECT_H */ 26 | -------------------------------------------------------------------------------- /vstudio/libmp4v2/Version.rc: -------------------------------------------------------------------------------- 1 | #include <winver.h> 2 | #include <mp4v2\project.h> 3 | 4 | ///////////////////////////////////////////////////////////////////////////// 5 | // 6 | // Version 7 | // 8 | 9 | VS_VERSION_INFO VERSIONINFO 10 | FILEVERSION MP4V2_PROJECT_version_major, MP4V2_PROJECT_version_minor, MP4V2_PROJECT_version_point, 0 11 | PRODUCTVERSION MP4V2_PROJECT_version_major, MP4V2_PROJECT_version_minor, MP4V2_PROJECT_version_point, 0 12 | FILEFLAGSMASK 0x17L 13 | #ifdef _DEBUG 14 | FILEFLAGS 0x1L 15 | #else 16 | FILEFLAGS 0x0L 17 | #endif 18 | FILEOS 0x4L 19 | FILETYPE 0x2L 20 | FILESUBTYPE 0x0L 21 | BEGIN 22 | BLOCK "StringFileInfo" 23 | BEGIN 24 | BLOCK "040904b0" 25 | BEGIN 26 | VALUE "CompanyName", MP4V2_PROJECT_name 27 | VALUE "FileDescription", MP4V2_PROJECT_name_formal 28 | VALUE "FileVersion", MP4V2_PROJECT_version 29 | VALUE "InternalName", MP4V2_PROJECT_name_formal 30 | VALUE "LegalCopyright", MP4V2_PROJECT_name 31 | VALUE "OriginalFilename", "libmp4v2.dll" 32 | VALUE "ProductName", MP4V2_PROJECT_name 33 | VALUE "ProductVersion", MP4V2_PROJECT_version 34 | VALUE "Url", MP4V2_PROJECT_url_website 35 | END 36 | END 37 | BLOCK "VarFileInfo" 38 | BEGIN 39 | VALUE "Translation", 0x409, 1200 40 | END 41 | END 42 | -------------------------------------------------------------------------------- /vstudio/libmp4v2/libmp4v2.natvis: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="utf-8"?> 2 | <AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010"> 3 | <Type Name="mp4v2::impl::MP4RootAtom"> 4 | <DisplayString>{{{"root"} m_size={m_size} ...}}</DisplayString> 5 | <Expand> 6 | <Item Name="m_pChildAtoms">m_pChildAtoms</Item> 7 | </Expand> 8 | </Type> 9 | <Type Name="mp4v2::impl::MP4Atom"> 10 | <DisplayString>{{{m_type,s} m_size={m_size} ...}}</DisplayString> 11 | <Expand> 12 | <Item Name="m_pParentAtom">m_pParentAtom</Item> 13 | <Item Name="m_pChildAtoms">m_pChildAtoms</Item> 14 | <Item Name="m_pProperties">m_pProperties</Item> 15 | </Expand> 16 | </Type> 17 | <Type Name="mp4v2::impl::MP4Property"> 18 | <DisplayString>{{{m_name,s} ...}}</DisplayString> 19 | </Type> 20 | <Type Name="mp4v2::impl::MP4SizedIntegerProperty<*,*>"> 21 | <DisplayString>{{{m_name,s} = {uint64_t(m_values[0])}}}</DisplayString> 22 | </Type> 23 | <Type Name="mp4v2::impl::MP4Float32Property"> 24 | <DisplayString>{{{m_name,s} = {m_values[0],s}}}</DisplayString> 25 | </Type> 26 | <Type Name="mp4v2::impl::MP4StringProperty"> 27 | <DisplayString>{{{m_name,s} = {m_values[0],s}}}</DisplayString> 28 | </Type> 29 | <Type Name="mp4v2::impl::MP4Array<*>"> 30 | <DisplayString>{{m_numElements={m_numElements}}}</DisplayString> 31 | <Expand> 32 | <IndexListItems> 33 | <Size>m_numElements</Size> 34 | <ValueNode>m_elements[$i]</ValueNode> 35 | </IndexListItems> 36 | </Expand> 37 | </Type> 38 | </AutoVisualizer> -------------------------------------------------------------------------------- /xcode/include/libplatform/config.h: -------------------------------------------------------------------------------- 1 | /* libplatform/config.h. Generated from config.h.in by configure. */ 2 | /* libplatform/config.h.in. Generated from configure.ac by autoheader. */ 3 | 4 | /* Define to 1 if you have the <inttypes.h> header file. */ 5 | #define HAVE_INTTYPES_H 1 6 | 7 | /* Define to 1 if you have the <stdint.h> header file. */ 8 | #define HAVE_STDINT_H 1 9 | 10 | /* Define to 1 if you have the <stdio.h> header file. */ 11 | #define HAVE_STDIO_H 1 12 | 13 | /* Define to 1 if you have the <stdlib.h> header file. */ 14 | #define HAVE_STDLIB_H 1 15 | 16 | /* Define to 1 if you have the <string.h> header file. */ 17 | #define HAVE_STRING_H 1 18 | 19 | /* Define to 1 if you have the <sys/stat.h> header file. */ 20 | #define HAVE_SYS_STAT_H 1 21 | 22 | /* Define to 1 if you have the <sys/types.h> header file. */ 23 | #define HAVE_SYS_TYPES_H 1 24 | 25 | /* Define to 1 if you have the <unistd.h> header file. */ 26 | #define HAVE_UNISTD_H 1 27 | 28 | /* Define to the sub-directory where libtool stores uninstalled libraries. */ 29 | #define LT_OBJDIR ".libs/" 30 | 31 | /* libtool defines DLL_EXPORT for windows dll 32 | builds, but we use MP4V2_EXPORTS instead. */ 33 | #ifdef DLL_EXPORT 34 | # define MP4V2_EXPORTS 35 | #else 36 | # define MP4V2_USE_STATIC_LIB 37 | #endif 38 | 39 | /* Define to 1 if LFS should be activated */ 40 | /* #undef NEED_LFS_ACTIVATION */ 41 | 42 | /* Name of package */ 43 | #define PACKAGE "mp4v2" 44 | 45 | /* Define to the address where bug reports for this package should be sent. */ 46 | #define PACKAGE_BUGREPORT "support@mp4v2.org" 47 | 48 | /* Define to the full name of this package. */ 49 | #define PACKAGE_NAME "MP4v2" 50 | 51 | /* Define to the full name and version of this package. */ 52 | #define PACKAGE_STRING "MP4v2 2.1.3" 53 | 54 | /* Define to the one symbol short name of this package. */ 55 | #define PACKAGE_TARNAME "mp4v2" 56 | 57 | /* Define to the home page for this package. */ 58 | #define PACKAGE_URL "https://mp4v2.org" 59 | 60 | /* Define to the version of this package. */ 61 | #define PACKAGE_VERSION "2.1.3" 62 | 63 | /* Define to 1 if all of the C90 standard headers exist (not just the ones 64 | required in a freestanding environment). This macro is provided for 65 | backward compatibility; new code need not use it. */ 66 | #define STDC_HEADERS 1 67 | 68 | /* Version number of package */ 69 | #define VERSION "2.1.3" 70 | -------------------------------------------------------------------------------- /xcode/include/mp4v2/project.h: -------------------------------------------------------------------------------- 1 | #ifndef MP4V2_PROJECT_H 2 | #define MP4V2_PROJECT_H 3 | 4 | /*****************************************************************************/ 5 | 6 | #define MP4V2_PROJECT_name "MP4v2" 7 | #define MP4V2_PROJECT_name_lower "mp4v2" 8 | #define MP4V2_PROJECT_name_upper "MP4V2" 9 | #define MP4V2_PROJECT_name_formal "MP4v2 2.1.3" 10 | #define MP4V2_PROJECT_url_website "https://mp4v2.org" 11 | #define MP4V2_PROJECT_url_downloads "https://github.com/enzo1982/releases" 12 | #define MP4V2_PROJECT_url_discussion "https://github.com/enzo1982/discussions" 13 | #define MP4V2_PROJECT_url_bugreport "https://github.com/enzo1982/issues" 14 | #define MP4V2_PROJECT_support "<support@mp4v2.org>" 15 | #define MP4V2_PROJECT_version "2.1.3" 16 | #define MP4V2_PROJECT_version_hex 0x00020103 17 | #define MP4V2_PROJECT_version_major 2 18 | #define MP4V2_PROJECT_version_minor 1 19 | #define MP4V2_PROJECT_version_point 3 20 | #define MP4V2_PROJECT_repo_url "git@github.com:enzo1982/mp4v2.git" 21 | #define MP4V2_PROJECT_build "Wed May 10 22:42:12 UTC 2023" 22 | 23 | /*****************************************************************************/ 24 | 25 | #endif /* MP4V2_PROJECT_H */ 26 | -------------------------------------------------------------------------------- /xcode/mp4v2.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="UTF-8"?> 2 | <Workspace 3 | version = "1.0"> 4 | <FileRef 5 | location = "self:mp4v2.xcodeproj"> 6 | </FileRef> 7 | </Workspace> 8 | --------------------------------------------------------------------------------