diff options
author | Lucas Eckels <eckels@google.com> | 2012-08-06 15:17:20 -0700 |
---|---|---|
committer | Lucas Eckels <eckels@google.com> | 2012-08-08 09:29:15 -0700 |
commit | 185cebee41a061bb66761249b3c82a10bcc2232d (patch) | |
tree | 850aac28f5cddc13f0092423987c632e16aa3a2f | |
parent | 8c49c89342efb45fce032fcddc68ad5e799c5347 (diff) | |
download | mp4v2-main.tar.gz |
Change-Id: Ia0a22a54055612a710169919e1ec81deca33ac23
233 files changed, 94258 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5703a2e --- /dev/null +++ b/.gitignore @@ -0,0 +1,66 @@ +/build +/source/build +*.mode1v3 +*.pbxuser +*.pbxindex/ +!user.pbxuser +/*.log +*.user +*.ncb +*.suo +*.pdb +*.pdf +*.html +*.idb +*.o +*.lo +*.a +*.so +*.so.0 +*.la +.deps +.libs +*.pyc +.DS_Store +# Emacs and other editor backup files +*~ + +# builds on Windows +Debug/ +Release/ +release/ + +/.libs/ +/GNUmakefile +/config.log +/config.status +/include/mp4v2/project.h +/libplatform/config.h +/libplatform/impl.h.gch/ +/libplatform/io/.dirstamp +/libplatform/number/.dirstamp +/libplatform/process/.dirstamp +/libplatform/prog/.dirstamp +/libplatform/stamp-h1 +/libplatform/sys/.dirstamp +/libplatform/time/.dirstamp +/libtool +/libutil/.dirstamp +/libutil/impl.h.gch/ +/mp4art +/mp4chaps +/mp4extract +/mp4file +/mp4info +/mp4subtitle +/mp4tags +/mp4track +/mp4trackdump +/project/project.m4 +/src/.dirstamp +/src/bmff/.dirstamp +/src/impl.h.gch/ +/src/itmf/.dirstamp +/src/qtff/.dirstamp +/util/.dirstamp +/util/impl.h.gch/
\ No newline at end of file @@ -0,0 +1,481 @@ + GNU LIBRARY GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1991 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the library GPL. It is + numbered 2 because it goes with version 2 of the ordinary GPL.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Library General Public License, applies to some +specially designated Free Software Foundation software, and to any +other libraries whose authors decide to use it. You can use it for +your libraries, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if +you distribute copies of the library, or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link a program with the library, you must provide +complete object files to the recipients so that they can relink them +with the library, after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + Our method of protecting your rights has two steps: (1) copyright +the library, and (2) offer you this license which gives you legal +permission to copy, distribute and/or modify the library. + + Also, for each distributor's protection, we want to make certain +that everyone understands that there is no warranty for this free +library. If the library is modified by someone else and passed on, we +want its recipients to know that what they have is not the original +version, so that any problems introduced by others will not reflect on +the original authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that companies distributing free +software will individually obtain patent licenses, thus in effect +transforming the program into proprietary software. To prevent this, +we have made it clear that any patent must be licensed for everyone's +free use or not licensed at all. + + Most GNU software, including some libraries, is covered by the ordinary +GNU General Public License, which was designed for utility programs. This +license, the GNU Library General Public License, applies to certain +designated libraries. This license is quite different from the ordinary +one; be sure to read it in full, and don't assume that anything in it is +the same as in the ordinary license. + + The reason we have a separate public license for some libraries is that +they blur the distinction we usually make between modifying or adding to a +program and simply using it. Linking a program with a library, without +changing the library, is in some sense simply using the library, and is +analogous to running a utility program or application program. However, in +a textual and legal sense, the linked executable is a combined work, a +derivative of the original library, and the ordinary General Public License +treats it as such. + + Because of this blurred distinction, using the ordinary General +Public License for libraries did not effectively promote software +sharing, because most developers did not use the libraries. We +concluded that weaker conditions might promote sharing better. + + However, unrestricted linking of non-free programs would deprive the +users of those programs of all benefit from the free status of the +libraries themselves. This Library General Public License is intended to +permit developers of non-free programs to use free libraries, while +preserving your freedom as a user of such programs to change the free +libraries that are incorporated in them. (We have not seen how to achieve +this as regards changes in header files, but we have achieved it as regards +changes in the actual functions of the Library.) The hope is that this +will lead to faster development of free libraries. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, while the latter only +works together with the library. + + Note that it is possible for a library to be covered by the ordinary +General Public License rather than by this special one. + + GNU LIBRARY GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library which +contains a notice placed by the copyright holder or other authorized +party saying it may be distributed under the terms of this Library +General Public License (also called "this License"). Each licensee is +addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also compile or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + c) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + d) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the source code distributed need not include anything that is normally +distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Library General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + <one line to give the library's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + <signature of Ty Coon>, 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! diff --git a/GNUmakefile.am b/GNUmakefile.am new file mode 100644 index 0000000..0f2f7da --- /dev/null +++ b/GNUmakefile.am @@ -0,0 +1,321 @@ +lib_LTLIBRARIES = libmp4v2.la + +bin_PROGRAMS = + +check_PROGRAMS = + +############################################################################### + +libmp4v2_la_LDFLAGS = -version-number $(PROJECT_version_major):$(PROJECT_version_minor):$(PROJECT_version_point) $(X_libmp4v2_la_LDFLAGS) + +libmp4v2_la_SOURCES = \ + src/3gp.cpp \ + src/atom_ac3.cpp \ + src/atom_amr.cpp \ + src/atom_avc1.cpp \ + src/atom_avcC.cpp \ + src/atom_chpl.cpp \ + src/atom_colr.cpp \ + src/atom_d263.cpp \ + src/atom_dac3.cpp \ + src/atom_damr.cpp \ + src/atom_dref.cpp \ + src/atom_elst.cpp \ + src/atom_enca.cpp \ + src/atom_encv.cpp \ + src/atom_free.cpp \ + src/atom_ftyp.cpp \ + src/atom_ftab.cpp \ + src/atom_gmin.cpp \ + src/atom_hdlr.cpp \ + src/atom_hinf.cpp \ + src/atom_hnti.cpp \ + src/atom_href.cpp \ + src/atom_mdat.cpp \ + src/atom_mdhd.cpp \ + src/atom_meta.cpp \ + src/atom_mp4s.cpp \ + src/atom_mp4v.cpp \ + src/atom_mvhd.cpp \ + src/atom_nmhd.cpp \ + src/atom_ohdr.cpp \ + src/atom_pasp.cpp \ + src/atom_root.cpp \ + src/atom_rtp.cpp \ + src/atom_s263.cpp \ + src/atom_sdp.cpp \ + src/atom_sdtp.cpp \ + src/atom_smi.cpp \ + src/atom_sound.cpp \ + src/atom_standard.cpp \ + src/atom_stbl.cpp \ + src/atom_stdp.cpp \ + src/atom_stsc.cpp \ + src/atom_stsd.cpp \ + src/atom_stsz.cpp \ + src/atom_stz2.cpp \ + src/atom_text.cpp \ + src/atom_tfhd.cpp \ + src/atom_tkhd.cpp \ + src/atom_treftype.cpp \ + src/atom_trun.cpp \ + src/atom_tx3g.cpp \ + src/atom_udta.cpp \ + src/atom_url.cpp \ + src/atom_urn.cpp \ + src/atom_uuid.cpp \ + src/atom_video.cpp \ + src/atom_vmhd.cpp \ + src/atoms.h \ + src/cmeta.cpp \ + src/descriptors.cpp \ + src/descriptors.h \ + src/exception.cpp \ + src/exception.h \ + src/enum.h \ + src/enum.tcc \ + src/impl.h \ + src/isma.cpp \ + src/mp4.cpp \ + src/mp4array.h \ + src/mp4atom.cpp \ + src/mp4atom.h \ + src/mp4container.cpp \ + src/mp4container.h \ + src/mp4descriptor.cpp \ + src/mp4descriptor.h \ + src/mp4error.h \ + src/mp4file.cpp \ + src/mp4file.h \ + src/mp4file_io.cpp \ + src/mp4info.cpp \ + src/mp4meta.cpp \ + src/mp4property.cpp \ + src/mp4property.h \ + src/mp4track.cpp \ + src/mp4track.h \ + src/mp4util.cpp \ + src/mp4util.h \ + src/ocidescriptors.cpp \ + src/ocidescriptors.h \ + src/odcommands.cpp \ + src/odcommands.h \ + src/qosqualifiers.cpp \ + src/qosqualifiers.h \ + src/rtphint.cpp \ + src/rtphint.h \ + src/src.h \ + src/text.cpp \ + src/text.h \ + src/util.h + +libmp4v2_la_SOURCES += \ + src/bmff/bmff.h \ + src/bmff/impl.h \ + src/bmff/typebmff.cpp \ + src/bmff/typebmff.h + +libmp4v2_la_SOURCES += \ + src/itmf/CoverArtBox.cpp \ + src/itmf/CoverArtBox.h \ + src/itmf/Tags.cpp \ + src/itmf/Tags.h \ + src/itmf/generic.cpp \ + src/itmf/generic.h \ + src/itmf/impl.h \ + src/itmf/itmf.h \ + src/itmf/type.cpp \ + src/itmf/type.h + +libmp4v2_la_SOURCES += \ + src/qtff/ColorParameterBox.cpp \ + src/qtff/ColorParameterBox.h \ + src/qtff/PictureAspectRatioBox.cpp \ + src/qtff/PictureAspectRatioBox.h \ + src/qtff/coding.cpp \ + src/qtff/coding.h \ + src/qtff/impl.h \ + src/qtff/qtff.h + +libmp4v2_la_SOURCES += \ + libplatform/endian.h \ + libplatform/impl.h \ + libplatform/io/File.cpp \ + libplatform/io/File.h \ + libplatform/io/FileSystem.cpp \ + libplatform/io/FileSystem.h \ + libplatform/number/random.h \ + libplatform/platform.h \ + libplatform/platform_base.h \ + libplatform/platform_posix.h \ + libplatform/platform_win32.h \ + libplatform/process/process.h \ + libplatform/prog/option.cpp \ + libplatform/prog/option.h \ + libplatform/sys/error.cpp \ + libplatform/sys/error.h \ + libplatform/time/time.cpp \ + libplatform/time/time.h \ + libplatform/warning.h + +if ADD_PLATFORM_POSIX + libmp4v2_la_SOURCES += \ + libplatform/io/File_posix.cpp \ + libplatform/io/FileSystem_posix.cpp \ + libplatform/number/random_posix.cpp \ + libplatform/process/process_posix.cpp \ + libplatform/time/time_posix.cpp +endif +if ADD_PLATFORM_WIN32 + libmp4v2_la_SOURCES += \ + libplatform/io/File_win32.cpp \ + libplatform/io/FileSystem_win32.cpp \ + libplatform/number/random_win32.cpp \ + libplatform/process/process_win32.cpp \ + libplatform/time/time_win32.cpp +endif + +if ADD_UTIL + libmp4v2_la_SOURCES += \ + libutil/Database.cpp \ + libutil/Database.h \ + libutil/Timecode.cpp \ + libutil/Timecode.h \ + libutil/TrackModifier.cpp \ + libutil/TrackModifier.h \ + libutil/Utility.cpp \ + libutil/Utility.h \ + libutil/crc.cpp \ + libutil/crc.h \ + libutil/impl.h \ + libutil/other.cpp \ + libutil/other.h \ + libutil/util.h + + bin_PROGRAMS += mp4art + bin_PROGRAMS += mp4chaps + bin_PROGRAMS += mp4extract + bin_PROGRAMS += mp4file + bin_PROGRAMS += mp4info + bin_PROGRAMS += mp4subtitle + bin_PROGRAMS += mp4tags + bin_PROGRAMS += mp4track + bin_PROGRAMS += mp4trackdump +endif + +mp4art_SOURCES = util/impl.h util/mp4art.cpp +mp4chaps_SOURCES = util/impl.h util/mp4chaps.cpp +mp4extract_SOURCES = util/impl.h util/mp4extract.cpp +mp4file_SOURCES = util/impl.h util/mp4file.cpp +mp4info_SOURCES = util/impl.h util/mp4info.cpp +mp4subtitle_SOURCES = util/impl.h util/mp4subtitle.cpp +mp4tags_SOURCES = util/impl.h util/mp4tags.cpp +mp4track_SOURCES = util/impl.h util/mp4track.cpp +mp4trackdump_SOURCES = util/impl.h util/mp4trackdump.cpp + +mp4art_LDADD = libmp4v2.la $(X_LDFLAGS) +mp4chaps_LDADD = libmp4v2.la $(X_LDFLAGS) +mp4extract_LDADD = libmp4v2.la $(X_LDFLAGS) +mp4file_LDADD = libmp4v2.la $(X_LDFLAGS) +mp4info_LDADD = libmp4v2.la $(X_LDFLAGS) +mp4subtitle_LDADD = libmp4v2.la $(X_LDFLAGS) +mp4tags_LDADD = libmp4v2.la $(X_LDFLAGS) +mp4track_LDADD = libmp4v2.la $(X_LDFLAGS) +mp4trackdump_LDADD = libmp4v2.la $(X_LDFLAGS) + +############################################################################### + +DEJATOOL = main + +TESTLOGDIR = $(builddir)/testlog + +override RUNTESTDEFAULTFLAGS = --tool $$tool --srcdir $$srcdir/testsuite --outdir $(TESTLOGDIR) + +############################################################################### + +mp4v2incdir = $(pkgincludedir) + +mp4v2inc_HEADERS = \ + include/mp4v2/project.h \ + \ + include/mp4v2/chapter.h \ + include/mp4v2/file.h \ + include/mp4v2/file_prop.h \ + include/mp4v2/general.h \ + include/mp4v2/isma.h \ + include/mp4v2/itmf_generic.h \ + include/mp4v2/itmf_tags.h \ + include/mp4v2/meta.h \ + include/mp4v2/mp4v2.h \ + include/mp4v2/platform.h \ + include/mp4v2/sample.h \ + include/mp4v2/streaming.h \ + include/mp4v2/track.h \ + include/mp4v2/track_prop.h + +############################################################################### + +EXTRA_DIST = project/project.m4 + +############################################################################### + +clean-local: + +distclean-local: + rm -f $(top_builddir)/Makefile + rm -f $(top_builddir)/testlog/*.log + rm -f $(top_builddir)/testlog/*.sum + +############################################################################### + +AM_CPPFLAGS = $(strip $(MK_CXX_ARCH) $(X_CXX_ARCH) $(MK_CXX_I) $(X_CXX_I)) + +AM_LDFLAGS = $(strip $(MK_CXX_ARCH) $(X_CXX_ARCH)) + +AM_CXXFLAGS = $(strip $(MK_CXX_W) $(X_CXX_W)) + +LIBS := $(LIBS) $(X_MINGW_LIBS) + +############################################################################### + +MK_CXX_ARCH = +MK_CXX_W = -Wall -Wformat +MK_CXX_D = + +MK_CXX_I = \ + -I$(top_builddir)/include -I$(top_srcdir)/include \ + -I$(top_builddir) -I$(top_srcdir) + +############################################################################### + +if ADD_UTIL +if ADD_MANS + man1_MANS = \ + doc/man/man1/mp4art.1 \ + doc/man/man1/mp4file.1 \ + doc/man/man1/mp4subtitle.1 \ + doc/man/man1/mp4track.1 +endif +endif + +############################################################################### + +## +## workaround: DejaGNU adds a hard-coded dependency on Makefile +## and need to create logdir +## +Makefile: ${Makefile} + touch $@ + $(mkdir_p) $(TESTLOGDIR) + +dist-hook: + +############################################################################### + +## +## include GNUmakefiles which are not full-fledged automake citizens but +## they are aware of automake variables and targets. Note that we purposely +## use a GNUmakefile extension (-include) to prevent automake from parsing +## the file. +## +-include $(top_srcdir)/doc/GNUmakefile.mk diff --git a/GNUmakefile.in b/GNUmakefile.in new file mode 100644 index 0000000..2953103 --- /dev/null +++ b/GNUmakefile.in @@ -0,0 +1,1775 @@ +# GNUmakefile.in generated by automake 1.9.6 from GNUmakefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = . +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +bin_PROGRAMS = $(am__EXEEXT_1) +check_PROGRAMS = +@ADD_PLATFORM_POSIX_TRUE@am__append_1 = \ +@ADD_PLATFORM_POSIX_TRUE@ libplatform/io/File_posix.cpp \ +@ADD_PLATFORM_POSIX_TRUE@ libplatform/io/FileSystem_posix.cpp \ +@ADD_PLATFORM_POSIX_TRUE@ libplatform/number/random_posix.cpp \ +@ADD_PLATFORM_POSIX_TRUE@ libplatform/process/process_posix.cpp \ +@ADD_PLATFORM_POSIX_TRUE@ libplatform/time/time_posix.cpp + +@ADD_PLATFORM_WIN32_TRUE@am__append_2 = \ +@ADD_PLATFORM_WIN32_TRUE@ libplatform/io/File_win32.cpp \ +@ADD_PLATFORM_WIN32_TRUE@ libplatform/io/FileSystem_win32.cpp \ +@ADD_PLATFORM_WIN32_TRUE@ libplatform/number/random_win32.cpp \ +@ADD_PLATFORM_WIN32_TRUE@ libplatform/process/process_win32.cpp \ +@ADD_PLATFORM_WIN32_TRUE@ libplatform/time/time_win32.cpp + +@ADD_UTIL_TRUE@am__append_3 = \ +@ADD_UTIL_TRUE@ libutil/Database.cpp \ +@ADD_UTIL_TRUE@ libutil/Database.h \ +@ADD_UTIL_TRUE@ libutil/Timecode.cpp \ +@ADD_UTIL_TRUE@ libutil/Timecode.h \ +@ADD_UTIL_TRUE@ libutil/TrackModifier.cpp \ +@ADD_UTIL_TRUE@ libutil/TrackModifier.h \ +@ADD_UTIL_TRUE@ libutil/Utility.cpp \ +@ADD_UTIL_TRUE@ libutil/Utility.h \ +@ADD_UTIL_TRUE@ libutil/crc.cpp \ +@ADD_UTIL_TRUE@ libutil/crc.h \ +@ADD_UTIL_TRUE@ libutil/impl.h \ +@ADD_UTIL_TRUE@ libutil/other.cpp \ +@ADD_UTIL_TRUE@ libutil/other.h \ +@ADD_UTIL_TRUE@ libutil/util.h + +@ADD_UTIL_TRUE@am__append_4 = mp4art mp4chaps mp4extract mp4file \ +@ADD_UTIL_TRUE@ mp4info mp4subtitle mp4tags mp4track \ +@ADD_UTIL_TRUE@ mp4trackdump +DIST_COMMON = README $(am__configure_deps) $(mp4v2inc_HEADERS) \ + $(srcdir)/GNUmakefile.am $(srcdir)/GNUmakefile.in \ + $(top_srcdir)/configure \ + $(top_srcdir)/include/mp4v2/project.h.in \ + $(top_srcdir)/libplatform/config.h.in \ + $(top_srcdir)/project/project.m4.in COPYING INSTALL \ + autoaux/config.guess autoaux/config.sub autoaux/depcomp \ + autoaux/install-sh autoaux/ltmain.sh autoaux/missing +subdir = . +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/project/project.m4sugar \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ + configure.lineno configure.status.lineno +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/libplatform/config.h +CONFIG_CLEAN_FILES = include/mp4v2/project.h project/project.m4 +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" \ + "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(mp4v2incdir)" +libLTLIBRARIES_INSTALL = $(INSTALL) +LTLIBRARIES = $(lib_LTLIBRARIES) +libmp4v2_la_LIBADD = +am__libmp4v2_la_SOURCES_DIST = src/3gp.cpp src/atom_ac3.cpp \ + src/atom_amr.cpp src/atom_avc1.cpp src/atom_avcC.cpp \ + src/atom_chpl.cpp src/atom_colr.cpp src/atom_d263.cpp \ + src/atom_dac3.cpp src/atom_damr.cpp src/atom_dref.cpp \ + src/atom_elst.cpp src/atom_enca.cpp src/atom_encv.cpp \ + src/atom_free.cpp src/atom_ftyp.cpp src/atom_ftab.cpp \ + src/atom_gmin.cpp src/atom_hdlr.cpp src/atom_hinf.cpp \ + src/atom_hnti.cpp src/atom_href.cpp src/atom_mdat.cpp \ + src/atom_mdhd.cpp src/atom_meta.cpp src/atom_mp4s.cpp \ + src/atom_mp4v.cpp src/atom_mvhd.cpp src/atom_nmhd.cpp \ + src/atom_ohdr.cpp src/atom_pasp.cpp src/atom_root.cpp \ + src/atom_rtp.cpp src/atom_s263.cpp src/atom_sdp.cpp \ + src/atom_sdtp.cpp src/atom_smi.cpp src/atom_sound.cpp \ + src/atom_standard.cpp src/atom_stbl.cpp src/atom_stdp.cpp \ + src/atom_stsc.cpp src/atom_stsd.cpp src/atom_stsz.cpp \ + src/atom_stz2.cpp src/atom_text.cpp src/atom_tfhd.cpp \ + src/atom_tkhd.cpp src/atom_treftype.cpp src/atom_trun.cpp \ + src/atom_tx3g.cpp src/atom_udta.cpp src/atom_url.cpp \ + src/atom_urn.cpp src/atom_uuid.cpp src/atom_video.cpp \ + src/atom_vmhd.cpp src/atoms.h src/cmeta.cpp \ + src/descriptors.cpp src/descriptors.h src/exception.cpp \ + src/exception.h src/enum.h src/enum.tcc src/impl.h \ + src/isma.cpp src/mp4.cpp src/mp4array.h src/mp4atom.cpp \ + src/mp4atom.h src/mp4container.cpp src/mp4container.h \ + src/mp4descriptor.cpp src/mp4descriptor.h src/mp4error.h \ + src/mp4file.cpp src/mp4file.h src/mp4file_io.cpp \ + src/mp4info.cpp src/mp4meta.cpp src/mp4property.cpp \ + src/mp4property.h src/mp4track.cpp src/mp4track.h \ + src/mp4util.cpp src/mp4util.h src/ocidescriptors.cpp \ + src/ocidescriptors.h src/odcommands.cpp src/odcommands.h \ + src/qosqualifiers.cpp src/qosqualifiers.h src/rtphint.cpp \ + src/rtphint.h src/src.h src/text.cpp src/text.h src/util.h \ + src/bmff/bmff.h src/bmff/impl.h src/bmff/typebmff.cpp \ + src/bmff/typebmff.h src/itmf/CoverArtBox.cpp \ + src/itmf/CoverArtBox.h src/itmf/Tags.cpp src/itmf/Tags.h \ + src/itmf/generic.cpp src/itmf/generic.h src/itmf/impl.h \ + src/itmf/itmf.h src/itmf/type.cpp src/itmf/type.h \ + src/qtff/ColorParameterBox.cpp src/qtff/ColorParameterBox.h \ + src/qtff/PictureAspectRatioBox.cpp \ + src/qtff/PictureAspectRatioBox.h src/qtff/coding.cpp \ + src/qtff/coding.h src/qtff/impl.h src/qtff/qtff.h \ + libplatform/endian.h libplatform/impl.h \ + libplatform/io/File.cpp libplatform/io/File.h \ + libplatform/io/FileSystem.cpp libplatform/io/FileSystem.h \ + libplatform/number/random.h libplatform/platform.h \ + libplatform/platform_base.h libplatform/platform_posix.h \ + libplatform/platform_win32.h libplatform/process/process.h \ + libplatform/prog/option.cpp libplatform/prog/option.h \ + libplatform/sys/error.cpp libplatform/sys/error.h \ + libplatform/time/time.cpp libplatform/time/time.h \ + libplatform/warning.h libplatform/io/File_posix.cpp \ + libplatform/io/FileSystem_posix.cpp \ + libplatform/number/random_posix.cpp \ + libplatform/process/process_posix.cpp \ + libplatform/time/time_posix.cpp libplatform/io/File_win32.cpp \ + libplatform/io/FileSystem_win32.cpp \ + libplatform/number/random_win32.cpp \ + libplatform/process/process_win32.cpp \ + libplatform/time/time_win32.cpp libutil/Database.cpp \ + libutil/Database.h libutil/Timecode.cpp libutil/Timecode.h \ + libutil/TrackModifier.cpp libutil/TrackModifier.h \ + libutil/Utility.cpp libutil/Utility.h libutil/crc.cpp \ + libutil/crc.h libutil/impl.h libutil/other.cpp libutil/other.h \ + libutil/util.h +am__dirstamp = $(am__leading_dot)dirstamp +@ADD_PLATFORM_POSIX_TRUE@am__objects_1 = libplatform/io/File_posix.lo \ +@ADD_PLATFORM_POSIX_TRUE@ libplatform/io/FileSystem_posix.lo \ +@ADD_PLATFORM_POSIX_TRUE@ libplatform/number/random_posix.lo \ +@ADD_PLATFORM_POSIX_TRUE@ libplatform/process/process_posix.lo \ +@ADD_PLATFORM_POSIX_TRUE@ libplatform/time/time_posix.lo +@ADD_PLATFORM_WIN32_TRUE@am__objects_2 = libplatform/io/File_win32.lo \ +@ADD_PLATFORM_WIN32_TRUE@ libplatform/io/FileSystem_win32.lo \ +@ADD_PLATFORM_WIN32_TRUE@ libplatform/number/random_win32.lo \ +@ADD_PLATFORM_WIN32_TRUE@ libplatform/process/process_win32.lo \ +@ADD_PLATFORM_WIN32_TRUE@ libplatform/time/time_win32.lo +@ADD_UTIL_TRUE@am__objects_3 = libutil/Database.lo libutil/Timecode.lo \ +@ADD_UTIL_TRUE@ libutil/TrackModifier.lo libutil/Utility.lo \ +@ADD_UTIL_TRUE@ libutil/crc.lo libutil/other.lo +am_libmp4v2_la_OBJECTS = src/3gp.lo src/atom_ac3.lo src/atom_amr.lo \ + src/atom_avc1.lo src/atom_avcC.lo src/atom_chpl.lo \ + src/atom_colr.lo src/atom_d263.lo src/atom_dac3.lo \ + src/atom_damr.lo src/atom_dref.lo src/atom_elst.lo \ + src/atom_enca.lo src/atom_encv.lo src/atom_free.lo \ + src/atom_ftyp.lo src/atom_ftab.lo src/atom_gmin.lo \ + src/atom_hdlr.lo src/atom_hinf.lo src/atom_hnti.lo \ + src/atom_href.lo src/atom_mdat.lo src/atom_mdhd.lo \ + src/atom_meta.lo src/atom_mp4s.lo src/atom_mp4v.lo \ + src/atom_mvhd.lo src/atom_nmhd.lo src/atom_ohdr.lo \ + src/atom_pasp.lo src/atom_root.lo src/atom_rtp.lo \ + src/atom_s263.lo src/atom_sdp.lo src/atom_sdtp.lo \ + src/atom_smi.lo src/atom_sound.lo src/atom_standard.lo \ + src/atom_stbl.lo src/atom_stdp.lo src/atom_stsc.lo \ + src/atom_stsd.lo src/atom_stsz.lo src/atom_stz2.lo \ + src/atom_text.lo src/atom_tfhd.lo src/atom_tkhd.lo \ + src/atom_treftype.lo src/atom_trun.lo src/atom_tx3g.lo \ + src/atom_udta.lo src/atom_url.lo src/atom_urn.lo \ + src/atom_uuid.lo src/atom_video.lo src/atom_vmhd.lo \ + src/cmeta.lo src/descriptors.lo src/exception.lo src/isma.lo \ + src/mp4.lo src/mp4atom.lo src/mp4container.lo \ + src/mp4descriptor.lo src/mp4file.lo src/mp4file_io.lo \ + src/mp4info.lo src/mp4meta.lo src/mp4property.lo \ + src/mp4track.lo src/mp4util.lo src/ocidescriptors.lo \ + src/odcommands.lo src/qosqualifiers.lo src/rtphint.lo \ + src/text.lo src/bmff/typebmff.lo src/itmf/CoverArtBox.lo \ + src/itmf/Tags.lo src/itmf/generic.lo src/itmf/type.lo \ + src/qtff/ColorParameterBox.lo \ + src/qtff/PictureAspectRatioBox.lo src/qtff/coding.lo \ + libplatform/io/File.lo libplatform/io/FileSystem.lo \ + libplatform/prog/option.lo libplatform/sys/error.lo \ + libplatform/time/time.lo $(am__objects_1) $(am__objects_2) \ + $(am__objects_3) +libmp4v2_la_OBJECTS = $(am_libmp4v2_la_OBJECTS) +@ADD_UTIL_TRUE@am__EXEEXT_1 = mp4art$(EXEEXT) mp4chaps$(EXEEXT) \ +@ADD_UTIL_TRUE@ mp4extract$(EXEEXT) mp4file$(EXEEXT) \ +@ADD_UTIL_TRUE@ mp4info$(EXEEXT) mp4subtitle$(EXEEXT) \ +@ADD_UTIL_TRUE@ mp4tags$(EXEEXT) mp4track$(EXEEXT) \ +@ADD_UTIL_TRUE@ mp4trackdump$(EXEEXT) +binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) +PROGRAMS = $(bin_PROGRAMS) +am_mp4art_OBJECTS = util/mp4art.$(OBJEXT) +mp4art_OBJECTS = $(am_mp4art_OBJECTS) +mp4art_DEPENDENCIES = libmp4v2.la +am_mp4chaps_OBJECTS = util/mp4chaps.$(OBJEXT) +mp4chaps_OBJECTS = $(am_mp4chaps_OBJECTS) +mp4chaps_DEPENDENCIES = libmp4v2.la +am_mp4extract_OBJECTS = util/mp4extract.$(OBJEXT) +mp4extract_OBJECTS = $(am_mp4extract_OBJECTS) +mp4extract_DEPENDENCIES = libmp4v2.la +am_mp4file_OBJECTS = util/mp4file.$(OBJEXT) +mp4file_OBJECTS = $(am_mp4file_OBJECTS) +mp4file_DEPENDENCIES = libmp4v2.la +am_mp4info_OBJECTS = util/mp4info.$(OBJEXT) +mp4info_OBJECTS = $(am_mp4info_OBJECTS) +mp4info_DEPENDENCIES = libmp4v2.la +am_mp4subtitle_OBJECTS = util/mp4subtitle.$(OBJEXT) +mp4subtitle_OBJECTS = $(am_mp4subtitle_OBJECTS) +mp4subtitle_DEPENDENCIES = libmp4v2.la +am_mp4tags_OBJECTS = util/mp4tags.$(OBJEXT) +mp4tags_OBJECTS = $(am_mp4tags_OBJECTS) +mp4tags_DEPENDENCIES = libmp4v2.la +am_mp4track_OBJECTS = util/mp4track.$(OBJEXT) +mp4track_OBJECTS = $(am_mp4track_OBJECTS) +mp4track_DEPENDENCIES = libmp4v2.la +am_mp4trackdump_OBJECTS = util/mp4trackdump.$(OBJEXT) +mp4trackdump_OBJECTS = $(am_mp4trackdump_OBJECTS) +mp4trackdump_DEPENDENCIES = libmp4v2.la +DEFAULT_INCLUDES = +depcomp = $(SHELL) $(top_srcdir)/autoaux/depcomp +am__depfiles_maybe = depfiles +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +LTCXXCOMPILE = $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +CXXLINK = $(LIBTOOL) --tag=CXX --mode=link $(CXXLD) $(AM_CXXFLAGS) \ + $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +SOURCES = $(libmp4v2_la_SOURCES) $(mp4art_SOURCES) $(mp4chaps_SOURCES) \ + $(mp4extract_SOURCES) $(mp4file_SOURCES) $(mp4info_SOURCES) \ + $(mp4subtitle_SOURCES) $(mp4tags_SOURCES) $(mp4track_SOURCES) \ + $(mp4trackdump_SOURCES) +DIST_SOURCES = $(am__libmp4v2_la_SOURCES_DIST) $(mp4art_SOURCES) \ + $(mp4chaps_SOURCES) $(mp4extract_SOURCES) $(mp4file_SOURCES) \ + $(mp4info_SOURCES) $(mp4subtitle_SOURCES) $(mp4tags_SOURCES) \ + $(mp4track_SOURCES) $(mp4trackdump_SOURCES) +man1dir = $(mandir)/man1 +NROFF = nroff +MANS = $(man1_MANS) +mp4v2incHEADERS_INSTALL = $(INSTALL_HEADER) +HEADERS = $(mp4v2inc_HEADERS) +ETAGS = etags +CTAGS = ctags +RUNTESTDEFAULTFLAGS = --tool $$tool --srcdir $$srcdir +EXPECT = expect +RUNTEST = runtest +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +distdir = $(PACKAGE)-$(VERSION) +top_distdir = $(distdir) +am__remove_distdir = \ + { test ! -d $(distdir) \ + || { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \ + && rm -fr $(distdir); }; } +GZIP_ENV = --best +DIST_ARCHIVES = $(distdir).tar.bz2 $(distdir).zip +distuninstallcheck_listfiles = find . -type f -print +distcleancheck_listfiles = find . -type f -print +ACLOCAL = @ACLOCAL@ +ADD_MANS_FALSE = @ADD_MANS_FALSE@ +ADD_MANS_TRUE = @ADD_MANS_TRUE@ +ADD_PLATFORM_POSIX_FALSE = @ADD_PLATFORM_POSIX_FALSE@ +ADD_PLATFORM_POSIX_TRUE = @ADD_PLATFORM_POSIX_TRUE@ +ADD_PLATFORM_WIN32_FALSE = @ADD_PLATFORM_WIN32_FALSE@ +ADD_PLATFORM_WIN32_TRUE = @ADD_PLATFORM_WIN32_TRUE@ +ADD_UTIL_FALSE = @ADD_UTIL_FALSE@ +ADD_UTIL_TRUE = @ADD_UTIL_TRUE@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DSYMUTIL = @DSYMUTIL@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FOUND_HELP2MAN = @FOUND_HELP2MAN@ +GREP = @GREP@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS := $(LIBS) $(X_MINGW_LIBS) +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +NMEDIT = @NMEDIT@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PROJECT_bugreport = @PROJECT_bugreport@ +PROJECT_build = @PROJECT_build@ +PROJECT_irc = @PROJECT_irc@ +PROJECT_name = @PROJECT_name@ +PROJECT_name_formal = @PROJECT_name_formal@ +PROJECT_name_lower = @PROJECT_name_lower@ +PROJECT_name_upper = @PROJECT_name_upper@ +PROJECT_repo_date = @PROJECT_repo_date@ +PROJECT_repo_rev = @PROJECT_repo_rev@ +PROJECT_repo_root = @PROJECT_repo_root@ +PROJECT_repo_type = @PROJECT_repo_type@ +PROJECT_repo_url = @PROJECT_repo_url@ +PROJECT_repo_uuid = @PROJECT_repo_uuid@ +PROJECT_url_discussion = @PROJECT_url_discussion@ +PROJECT_url_downloads = @PROJECT_url_downloads@ +PROJECT_url_website = @PROJECT_url_website@ +PROJECT_version = @PROJECT_version@ +PROJECT_version_hex = @PROJECT_version_hex@ +PROJECT_version_major = @PROJECT_version_major@ +PROJECT_version_minor = @PROJECT_version_minor@ +PROJECT_version_point = @PROJECT_version_point@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +X_CXX_ARCH = @X_CXX_ARCH@ +X_CXX_D = @X_CXX_D@ +X_CXX_I = @X_CXX_I@ +X_CXX_W = @X_CXX_W@ +X_GCH = @X_GCH@ +X_GCH_FLAGS = @X_GCH_FLAGS@ +X_GCH_SHARED = @X_GCH_SHARED@ +X_GCH_SHARED_FLAGS = @X_GCH_SHARED_FLAGS@ +X_GCH_STATIC = @X_GCH_STATIC@ +X_GCH_STATIC_FLAGS = @X_GCH_STATIC_FLAGS@ +X_MINGW_LIBS = @X_MINGW_LIBS@ +X_libmp4v2_la_LDFLAGS = @X_libmp4v2_la_LDFLAGS@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +lib_LTLIBRARIES = libmp4v2.la + +############################################################################### +libmp4v2_la_LDFLAGS = -version-number $(PROJECT_version_major):$(PROJECT_version_minor):$(PROJECT_version_point) $(X_libmp4v2_la_LDFLAGS) +libmp4v2_la_SOURCES = src/3gp.cpp src/atom_ac3.cpp src/atom_amr.cpp \ + src/atom_avc1.cpp src/atom_avcC.cpp src/atom_chpl.cpp \ + src/atom_colr.cpp src/atom_d263.cpp src/atom_dac3.cpp \ + src/atom_damr.cpp src/atom_dref.cpp src/atom_elst.cpp \ + src/atom_enca.cpp src/atom_encv.cpp src/atom_free.cpp \ + src/atom_ftyp.cpp src/atom_ftab.cpp src/atom_gmin.cpp \ + src/atom_hdlr.cpp src/atom_hinf.cpp src/atom_hnti.cpp \ + src/atom_href.cpp src/atom_mdat.cpp src/atom_mdhd.cpp \ + src/atom_meta.cpp src/atom_mp4s.cpp src/atom_mp4v.cpp \ + src/atom_mvhd.cpp src/atom_nmhd.cpp src/atom_ohdr.cpp \ + src/atom_pasp.cpp src/atom_root.cpp src/atom_rtp.cpp \ + src/atom_s263.cpp src/atom_sdp.cpp src/atom_sdtp.cpp \ + src/atom_smi.cpp src/atom_sound.cpp src/atom_standard.cpp \ + src/atom_stbl.cpp src/atom_stdp.cpp src/atom_stsc.cpp \ + src/atom_stsd.cpp src/atom_stsz.cpp src/atom_stz2.cpp \ + src/atom_text.cpp src/atom_tfhd.cpp src/atom_tkhd.cpp \ + src/atom_treftype.cpp src/atom_trun.cpp src/atom_tx3g.cpp \ + src/atom_udta.cpp src/atom_url.cpp src/atom_urn.cpp \ + src/atom_uuid.cpp src/atom_video.cpp src/atom_vmhd.cpp \ + src/atoms.h src/cmeta.cpp src/descriptors.cpp \ + src/descriptors.h src/exception.cpp src/exception.h src/enum.h \ + src/enum.tcc src/impl.h src/isma.cpp src/mp4.cpp \ + src/mp4array.h src/mp4atom.cpp src/mp4atom.h \ + src/mp4container.cpp src/mp4container.h src/mp4descriptor.cpp \ + src/mp4descriptor.h src/mp4error.h src/mp4file.cpp \ + src/mp4file.h src/mp4file_io.cpp src/mp4info.cpp \ + src/mp4meta.cpp src/mp4property.cpp src/mp4property.h \ + src/mp4track.cpp src/mp4track.h src/mp4util.cpp src/mp4util.h \ + src/ocidescriptors.cpp src/ocidescriptors.h src/odcommands.cpp \ + src/odcommands.h src/qosqualifiers.cpp src/qosqualifiers.h \ + src/rtphint.cpp src/rtphint.h src/src.h src/text.cpp \ + src/text.h src/util.h src/bmff/bmff.h src/bmff/impl.h \ + src/bmff/typebmff.cpp src/bmff/typebmff.h \ + src/itmf/CoverArtBox.cpp src/itmf/CoverArtBox.h \ + src/itmf/Tags.cpp src/itmf/Tags.h src/itmf/generic.cpp \ + src/itmf/generic.h src/itmf/impl.h src/itmf/itmf.h \ + src/itmf/type.cpp src/itmf/type.h \ + src/qtff/ColorParameterBox.cpp src/qtff/ColorParameterBox.h \ + src/qtff/PictureAspectRatioBox.cpp \ + src/qtff/PictureAspectRatioBox.h src/qtff/coding.cpp \ + src/qtff/coding.h src/qtff/impl.h src/qtff/qtff.h \ + libplatform/endian.h libplatform/impl.h \ + libplatform/io/File.cpp libplatform/io/File.h \ + libplatform/io/FileSystem.cpp libplatform/io/FileSystem.h \ + libplatform/number/random.h libplatform/platform.h \ + libplatform/platform_base.h libplatform/platform_posix.h \ + libplatform/platform_win32.h libplatform/process/process.h \ + libplatform/prog/option.cpp libplatform/prog/option.h \ + libplatform/sys/error.cpp libplatform/sys/error.h \ + libplatform/time/time.cpp libplatform/time/time.h \ + libplatform/warning.h $(am__append_1) $(am__append_2) \ + $(am__append_3) +mp4art_SOURCES = util/impl.h util/mp4art.cpp +mp4chaps_SOURCES = util/impl.h util/mp4chaps.cpp +mp4extract_SOURCES = util/impl.h util/mp4extract.cpp +mp4file_SOURCES = util/impl.h util/mp4file.cpp +mp4info_SOURCES = util/impl.h util/mp4info.cpp +mp4subtitle_SOURCES = util/impl.h util/mp4subtitle.cpp +mp4tags_SOURCES = util/impl.h util/mp4tags.cpp +mp4track_SOURCES = util/impl.h util/mp4track.cpp +mp4trackdump_SOURCES = util/impl.h util/mp4trackdump.cpp +mp4art_LDADD = libmp4v2.la $(X_LDFLAGS) +mp4chaps_LDADD = libmp4v2.la $(X_LDFLAGS) +mp4extract_LDADD = libmp4v2.la $(X_LDFLAGS) +mp4file_LDADD = libmp4v2.la $(X_LDFLAGS) +mp4info_LDADD = libmp4v2.la $(X_LDFLAGS) +mp4subtitle_LDADD = libmp4v2.la $(X_LDFLAGS) +mp4tags_LDADD = libmp4v2.la $(X_LDFLAGS) +mp4track_LDADD = libmp4v2.la $(X_LDFLAGS) +mp4trackdump_LDADD = libmp4v2.la $(X_LDFLAGS) + +############################################################################### +DEJATOOL = main +TESTLOGDIR = $(builddir)/testlog + +############################################################################### +mp4v2incdir = $(pkgincludedir) +mp4v2inc_HEADERS = \ + include/mp4v2/project.h \ + \ + include/mp4v2/chapter.h \ + include/mp4v2/file.h \ + include/mp4v2/file_prop.h \ + include/mp4v2/general.h \ + include/mp4v2/isma.h \ + include/mp4v2/itmf_generic.h \ + include/mp4v2/itmf_tags.h \ + include/mp4v2/meta.h \ + include/mp4v2/mp4v2.h \ + include/mp4v2/platform.h \ + include/mp4v2/sample.h \ + include/mp4v2/streaming.h \ + include/mp4v2/track.h \ + include/mp4v2/track_prop.h + + +############################################################################### +EXTRA_DIST = project/project.m4 + +############################################################################### +AM_CPPFLAGS = $(strip $(MK_CXX_ARCH) $(X_CXX_ARCH) $(MK_CXX_I) $(X_CXX_I)) +AM_LDFLAGS = $(strip $(MK_CXX_ARCH) $(X_CXX_ARCH)) +AM_CXXFLAGS = $(strip $(MK_CXX_W) $(X_CXX_W)) + +############################################################################### +MK_CXX_ARCH = +MK_CXX_W = -Wall -Wformat +MK_CXX_D = +MK_CXX_I = \ + -I$(top_builddir)/include -I$(top_srcdir)/include \ + -I$(top_builddir) -I$(top_srcdir) + + +############################################################################### +@ADD_MANS_TRUE@@ADD_UTIL_TRUE@man1_MANS = \ +@ADD_MANS_TRUE@@ADD_UTIL_TRUE@ doc/man/man1/mp4art.1 \ +@ADD_MANS_TRUE@@ADD_UTIL_TRUE@ doc/man/man1/mp4file.1 \ +@ADD_MANS_TRUE@@ADD_UTIL_TRUE@ doc/man/man1/mp4subtitle.1 \ +@ADD_MANS_TRUE@@ADD_UTIL_TRUE@ doc/man/man1/mp4track.1 + +all: all-am + +.SUFFIXES: +.SUFFIXES: .cpp .lo .o .obj +am--refresh: + @: +$(srcdir)/GNUmakefile.in: $(srcdir)/GNUmakefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + echo ' cd $(srcdir) && $(AUTOMAKE) --foreign '; \ + cd $(srcdir) && $(AUTOMAKE) --foreign \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign GNUmakefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign GNUmakefile +.PRECIOUS: GNUmakefile +GNUmakefile: $(srcdir)/GNUmakefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + echo ' $(SHELL) ./config.status'; \ + $(SHELL) ./config.status;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + $(SHELL) ./config.status --recheck + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(srcdir) && $(AUTOCONF) +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) + +libplatform/config.h: libplatform/stamp-h1 + @if test ! -f $@; then \ + rm -f libplatform/stamp-h1; \ + $(MAKE) libplatform/stamp-h1; \ + else :; fi + +libplatform/stamp-h1: $(top_srcdir)/libplatform/config.h.in $(top_builddir)/config.status + @rm -f libplatform/stamp-h1 + cd $(top_builddir) && $(SHELL) ./config.status libplatform/config.h +$(top_srcdir)/libplatform/config.h.in: $(am__configure_deps) + cd $(top_srcdir) && $(AUTOHEADER) + rm -f libplatform/stamp-h1 + touch $@ + +distclean-hdr: + -rm -f libplatform/config.h libplatform/stamp-h1 +include/mp4v2/project.h: $(top_builddir)/config.status $(top_srcdir)/include/mp4v2/project.h.in + cd $(top_builddir) && $(SHELL) ./config.status $@ +project/project.m4: $(top_builddir)/config.status $(top_srcdir)/project/project.m4.in + cd $(top_builddir) && $(SHELL) ./config.status $@ +install-libLTLIBRARIES: $(lib_LTLIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(libdir)" || $(mkdir_p) "$(DESTDIR)$(libdir)" + @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + f=$(am__strip_dir) \ + echo " $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(libdir)/$$f'"; \ + $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(libdir)/$$f"; \ + else :; fi; \ + done + +uninstall-libLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @set -x; list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + p=$(am__strip_dir) \ + echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$p'"; \ + $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$p"; \ + done + +clean-libLTLIBRARIES: + -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) + @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +src/$(am__dirstamp): + @$(mkdir_p) src + @: > src/$(am__dirstamp) +src/$(DEPDIR)/$(am__dirstamp): + @$(mkdir_p) src/$(DEPDIR) + @: > src/$(DEPDIR)/$(am__dirstamp) +src/3gp.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/atom_ac3.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/atom_amr.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/atom_avc1.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/atom_avcC.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/atom_chpl.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/atom_colr.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/atom_d263.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/atom_dac3.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/atom_damr.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/atom_dref.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/atom_elst.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/atom_enca.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/atom_encv.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/atom_free.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/atom_ftyp.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/atom_ftab.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/atom_gmin.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/atom_hdlr.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/atom_hinf.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/atom_hnti.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/atom_href.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/atom_mdat.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/atom_mdhd.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/atom_meta.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/atom_mp4s.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/atom_mp4v.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/atom_mvhd.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/atom_nmhd.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/atom_ohdr.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/atom_pasp.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/atom_root.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/atom_rtp.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/atom_s263.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/atom_sdp.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/atom_sdtp.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/atom_smi.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/atom_sound.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/atom_standard.lo: src/$(am__dirstamp) \ + src/$(DEPDIR)/$(am__dirstamp) +src/atom_stbl.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/atom_stdp.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/atom_stsc.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/atom_stsd.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/atom_stsz.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/atom_stz2.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/atom_text.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/atom_tfhd.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/atom_tkhd.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/atom_treftype.lo: src/$(am__dirstamp) \ + src/$(DEPDIR)/$(am__dirstamp) +src/atom_trun.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/atom_tx3g.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/atom_udta.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/atom_url.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/atom_urn.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/atom_uuid.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/atom_video.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/atom_vmhd.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/cmeta.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/descriptors.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/exception.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/isma.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/mp4.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/mp4atom.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/mp4container.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/mp4descriptor.lo: src/$(am__dirstamp) \ + src/$(DEPDIR)/$(am__dirstamp) +src/mp4file.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/mp4file_io.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/mp4info.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/mp4meta.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/mp4property.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/mp4track.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/mp4util.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/ocidescriptors.lo: src/$(am__dirstamp) \ + src/$(DEPDIR)/$(am__dirstamp) +src/odcommands.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/qosqualifiers.lo: src/$(am__dirstamp) \ + src/$(DEPDIR)/$(am__dirstamp) +src/rtphint.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/text.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/bmff/$(am__dirstamp): + @$(mkdir_p) src/bmff + @: > src/bmff/$(am__dirstamp) +src/bmff/$(DEPDIR)/$(am__dirstamp): + @$(mkdir_p) src/bmff/$(DEPDIR) + @: > src/bmff/$(DEPDIR)/$(am__dirstamp) +src/bmff/typebmff.lo: src/bmff/$(am__dirstamp) \ + src/bmff/$(DEPDIR)/$(am__dirstamp) +src/itmf/$(am__dirstamp): + @$(mkdir_p) src/itmf + @: > src/itmf/$(am__dirstamp) +src/itmf/$(DEPDIR)/$(am__dirstamp): + @$(mkdir_p) src/itmf/$(DEPDIR) + @: > src/itmf/$(DEPDIR)/$(am__dirstamp) +src/itmf/CoverArtBox.lo: src/itmf/$(am__dirstamp) \ + src/itmf/$(DEPDIR)/$(am__dirstamp) +src/itmf/Tags.lo: src/itmf/$(am__dirstamp) \ + src/itmf/$(DEPDIR)/$(am__dirstamp) +src/itmf/generic.lo: src/itmf/$(am__dirstamp) \ + src/itmf/$(DEPDIR)/$(am__dirstamp) +src/itmf/type.lo: src/itmf/$(am__dirstamp) \ + src/itmf/$(DEPDIR)/$(am__dirstamp) +src/qtff/$(am__dirstamp): + @$(mkdir_p) src/qtff + @: > src/qtff/$(am__dirstamp) +src/qtff/$(DEPDIR)/$(am__dirstamp): + @$(mkdir_p) src/qtff/$(DEPDIR) + @: > src/qtff/$(DEPDIR)/$(am__dirstamp) +src/qtff/ColorParameterBox.lo: src/qtff/$(am__dirstamp) \ + src/qtff/$(DEPDIR)/$(am__dirstamp) +src/qtff/PictureAspectRatioBox.lo: src/qtff/$(am__dirstamp) \ + src/qtff/$(DEPDIR)/$(am__dirstamp) +src/qtff/coding.lo: src/qtff/$(am__dirstamp) \ + src/qtff/$(DEPDIR)/$(am__dirstamp) +libplatform/io/$(am__dirstamp): + @$(mkdir_p) libplatform/io + @: > libplatform/io/$(am__dirstamp) +libplatform/io/$(DEPDIR)/$(am__dirstamp): + @$(mkdir_p) libplatform/io/$(DEPDIR) + @: > libplatform/io/$(DEPDIR)/$(am__dirstamp) +libplatform/io/File.lo: libplatform/io/$(am__dirstamp) \ + libplatform/io/$(DEPDIR)/$(am__dirstamp) +libplatform/io/FileSystem.lo: libplatform/io/$(am__dirstamp) \ + libplatform/io/$(DEPDIR)/$(am__dirstamp) +libplatform/prog/$(am__dirstamp): + @$(mkdir_p) libplatform/prog + @: > libplatform/prog/$(am__dirstamp) +libplatform/prog/$(DEPDIR)/$(am__dirstamp): + @$(mkdir_p) libplatform/prog/$(DEPDIR) + @: > libplatform/prog/$(DEPDIR)/$(am__dirstamp) +libplatform/prog/option.lo: libplatform/prog/$(am__dirstamp) \ + libplatform/prog/$(DEPDIR)/$(am__dirstamp) +libplatform/sys/$(am__dirstamp): + @$(mkdir_p) libplatform/sys + @: > libplatform/sys/$(am__dirstamp) +libplatform/sys/$(DEPDIR)/$(am__dirstamp): + @$(mkdir_p) libplatform/sys/$(DEPDIR) + @: > libplatform/sys/$(DEPDIR)/$(am__dirstamp) +libplatform/sys/error.lo: libplatform/sys/$(am__dirstamp) \ + libplatform/sys/$(DEPDIR)/$(am__dirstamp) +libplatform/time/$(am__dirstamp): + @$(mkdir_p) libplatform/time + @: > libplatform/time/$(am__dirstamp) +libplatform/time/$(DEPDIR)/$(am__dirstamp): + @$(mkdir_p) libplatform/time/$(DEPDIR) + @: > libplatform/time/$(DEPDIR)/$(am__dirstamp) +libplatform/time/time.lo: libplatform/time/$(am__dirstamp) \ + libplatform/time/$(DEPDIR)/$(am__dirstamp) +libplatform/io/File_posix.lo: libplatform/io/$(am__dirstamp) \ + libplatform/io/$(DEPDIR)/$(am__dirstamp) +libplatform/io/FileSystem_posix.lo: libplatform/io/$(am__dirstamp) \ + libplatform/io/$(DEPDIR)/$(am__dirstamp) +libplatform/number/$(am__dirstamp): + @$(mkdir_p) libplatform/number + @: > libplatform/number/$(am__dirstamp) +libplatform/number/$(DEPDIR)/$(am__dirstamp): + @$(mkdir_p) libplatform/number/$(DEPDIR) + @: > libplatform/number/$(DEPDIR)/$(am__dirstamp) +libplatform/number/random_posix.lo: \ + libplatform/number/$(am__dirstamp) \ + libplatform/number/$(DEPDIR)/$(am__dirstamp) +libplatform/process/$(am__dirstamp): + @$(mkdir_p) libplatform/process + @: > libplatform/process/$(am__dirstamp) +libplatform/process/$(DEPDIR)/$(am__dirstamp): + @$(mkdir_p) libplatform/process/$(DEPDIR) + @: > libplatform/process/$(DEPDIR)/$(am__dirstamp) +libplatform/process/process_posix.lo: \ + libplatform/process/$(am__dirstamp) \ + libplatform/process/$(DEPDIR)/$(am__dirstamp) +libplatform/time/time_posix.lo: libplatform/time/$(am__dirstamp) \ + libplatform/time/$(DEPDIR)/$(am__dirstamp) +libplatform/io/File_win32.lo: libplatform/io/$(am__dirstamp) \ + libplatform/io/$(DEPDIR)/$(am__dirstamp) +libplatform/io/FileSystem_win32.lo: libplatform/io/$(am__dirstamp) \ + libplatform/io/$(DEPDIR)/$(am__dirstamp) +libplatform/number/random_win32.lo: \ + libplatform/number/$(am__dirstamp) \ + libplatform/number/$(DEPDIR)/$(am__dirstamp) +libplatform/process/process_win32.lo: \ + libplatform/process/$(am__dirstamp) \ + libplatform/process/$(DEPDIR)/$(am__dirstamp) +libplatform/time/time_win32.lo: libplatform/time/$(am__dirstamp) \ + libplatform/time/$(DEPDIR)/$(am__dirstamp) +libutil/$(am__dirstamp): + @$(mkdir_p) libutil + @: > libutil/$(am__dirstamp) +libutil/$(DEPDIR)/$(am__dirstamp): + @$(mkdir_p) libutil/$(DEPDIR) + @: > libutil/$(DEPDIR)/$(am__dirstamp) +libutil/Database.lo: libutil/$(am__dirstamp) \ + libutil/$(DEPDIR)/$(am__dirstamp) +libutil/Timecode.lo: libutil/$(am__dirstamp) \ + libutil/$(DEPDIR)/$(am__dirstamp) +libutil/TrackModifier.lo: libutil/$(am__dirstamp) \ + libutil/$(DEPDIR)/$(am__dirstamp) +libutil/Utility.lo: libutil/$(am__dirstamp) \ + libutil/$(DEPDIR)/$(am__dirstamp) +libutil/crc.lo: libutil/$(am__dirstamp) \ + libutil/$(DEPDIR)/$(am__dirstamp) +libutil/other.lo: libutil/$(am__dirstamp) \ + libutil/$(DEPDIR)/$(am__dirstamp) +libmp4v2.la: $(libmp4v2_la_OBJECTS) $(libmp4v2_la_DEPENDENCIES) + $(CXXLINK) -rpath $(libdir) $(libmp4v2_la_LDFLAGS) $(libmp4v2_la_OBJECTS) $(libmp4v2_la_LIBADD) $(LIBS) +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)" + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + if test -f $$p \ + || test -f $$p1 \ + ; then \ + f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ + else :; fi; \ + done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ + rm -f "$(DESTDIR)$(bindir)/$$f"; \ + done + +clean-binPROGRAMS: + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f $$p $$f"; \ + rm -f $$p $$f ; \ + done + +clean-checkPROGRAMS: + @list='$(check_PROGRAMS)'; for p in $$list; do \ + f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f $$p $$f"; \ + rm -f $$p $$f ; \ + done +util/$(am__dirstamp): + @$(mkdir_p) util + @: > util/$(am__dirstamp) +util/$(DEPDIR)/$(am__dirstamp): + @$(mkdir_p) util/$(DEPDIR) + @: > util/$(DEPDIR)/$(am__dirstamp) +util/mp4art.$(OBJEXT): util/$(am__dirstamp) \ + util/$(DEPDIR)/$(am__dirstamp) +mp4art$(EXEEXT): $(mp4art_OBJECTS) $(mp4art_DEPENDENCIES) + @rm -f mp4art$(EXEEXT) + $(CXXLINK) $(mp4art_LDFLAGS) $(mp4art_OBJECTS) $(mp4art_LDADD) $(LIBS) +util/mp4chaps.$(OBJEXT): util/$(am__dirstamp) \ + util/$(DEPDIR)/$(am__dirstamp) +mp4chaps$(EXEEXT): $(mp4chaps_OBJECTS) $(mp4chaps_DEPENDENCIES) + @rm -f mp4chaps$(EXEEXT) + $(CXXLINK) $(mp4chaps_LDFLAGS) $(mp4chaps_OBJECTS) $(mp4chaps_LDADD) $(LIBS) +util/mp4extract.$(OBJEXT): util/$(am__dirstamp) \ + util/$(DEPDIR)/$(am__dirstamp) +mp4extract$(EXEEXT): $(mp4extract_OBJECTS) $(mp4extract_DEPENDENCIES) + @rm -f mp4extract$(EXEEXT) + $(CXXLINK) $(mp4extract_LDFLAGS) $(mp4extract_OBJECTS) $(mp4extract_LDADD) $(LIBS) +util/mp4file.$(OBJEXT): util/$(am__dirstamp) \ + util/$(DEPDIR)/$(am__dirstamp) +mp4file$(EXEEXT): $(mp4file_OBJECTS) $(mp4file_DEPENDENCIES) + @rm -f mp4file$(EXEEXT) + $(CXXLINK) $(mp4file_LDFLAGS) $(mp4file_OBJECTS) $(mp4file_LDADD) $(LIBS) +util/mp4info.$(OBJEXT): util/$(am__dirstamp) \ + util/$(DEPDIR)/$(am__dirstamp) +mp4info$(EXEEXT): $(mp4info_OBJECTS) $(mp4info_DEPENDENCIES) + @rm -f mp4info$(EXEEXT) + $(CXXLINK) $(mp4info_LDFLAGS) $(mp4info_OBJECTS) $(mp4info_LDADD) $(LIBS) +util/mp4subtitle.$(OBJEXT): util/$(am__dirstamp) \ + util/$(DEPDIR)/$(am__dirstamp) +mp4subtitle$(EXEEXT): $(mp4subtitle_OBJECTS) $(mp4subtitle_DEPENDENCIES) + @rm -f mp4subtitle$(EXEEXT) + $(CXXLINK) $(mp4subtitle_LDFLAGS) $(mp4subtitle_OBJECTS) $(mp4subtitle_LDADD) $(LIBS) +util/mp4tags.$(OBJEXT): util/$(am__dirstamp) \ + util/$(DEPDIR)/$(am__dirstamp) +mp4tags$(EXEEXT): $(mp4tags_OBJECTS) $(mp4tags_DEPENDENCIES) + @rm -f mp4tags$(EXEEXT) + $(CXXLINK) $(mp4tags_LDFLAGS) $(mp4tags_OBJECTS) $(mp4tags_LDADD) $(LIBS) +util/mp4track.$(OBJEXT): util/$(am__dirstamp) \ + util/$(DEPDIR)/$(am__dirstamp) +mp4track$(EXEEXT): $(mp4track_OBJECTS) $(mp4track_DEPENDENCIES) + @rm -f mp4track$(EXEEXT) + $(CXXLINK) $(mp4track_LDFLAGS) $(mp4track_OBJECTS) $(mp4track_LDADD) $(LIBS) +util/mp4trackdump.$(OBJEXT): util/$(am__dirstamp) \ + util/$(DEPDIR)/$(am__dirstamp) +mp4trackdump$(EXEEXT): $(mp4trackdump_OBJECTS) $(mp4trackdump_DEPENDENCIES) + @rm -f mp4trackdump$(EXEEXT) + $(CXXLINK) $(mp4trackdump_LDFLAGS) $(mp4trackdump_OBJECTS) $(mp4trackdump_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + -rm -f libplatform/io/File.$(OBJEXT) + -rm -f libplatform/io/File.lo + -rm -f libplatform/io/FileSystem.$(OBJEXT) + -rm -f libplatform/io/FileSystem.lo + -rm -f libplatform/io/FileSystem_posix.$(OBJEXT) + -rm -f libplatform/io/FileSystem_posix.lo + -rm -f libplatform/io/FileSystem_win32.$(OBJEXT) + -rm -f libplatform/io/FileSystem_win32.lo + -rm -f libplatform/io/File_posix.$(OBJEXT) + -rm -f libplatform/io/File_posix.lo + -rm -f libplatform/io/File_win32.$(OBJEXT) + -rm -f libplatform/io/File_win32.lo + -rm -f libplatform/number/random_posix.$(OBJEXT) + -rm -f libplatform/number/random_posix.lo + -rm -f libplatform/number/random_win32.$(OBJEXT) + -rm -f libplatform/number/random_win32.lo + -rm -f libplatform/process/process_posix.$(OBJEXT) + -rm -f libplatform/process/process_posix.lo + -rm -f libplatform/process/process_win32.$(OBJEXT) + -rm -f libplatform/process/process_win32.lo + -rm -f libplatform/prog/option.$(OBJEXT) + -rm -f libplatform/prog/option.lo + -rm -f libplatform/sys/error.$(OBJEXT) + -rm -f libplatform/sys/error.lo + -rm -f libplatform/time/time.$(OBJEXT) + -rm -f libplatform/time/time.lo + -rm -f libplatform/time/time_posix.$(OBJEXT) + -rm -f libplatform/time/time_posix.lo + -rm -f libplatform/time/time_win32.$(OBJEXT) + -rm -f libplatform/time/time_win32.lo + -rm -f libutil/Database.$(OBJEXT) + -rm -f libutil/Database.lo + -rm -f libutil/Timecode.$(OBJEXT) + -rm -f libutil/Timecode.lo + -rm -f libutil/TrackModifier.$(OBJEXT) + -rm -f libutil/TrackModifier.lo + -rm -f libutil/Utility.$(OBJEXT) + -rm -f libutil/Utility.lo + -rm -f libutil/crc.$(OBJEXT) + -rm -f libutil/crc.lo + -rm -f libutil/other.$(OBJEXT) + -rm -f libutil/other.lo + -rm -f src/3gp.$(OBJEXT) + -rm -f src/3gp.lo + -rm -f src/atom_ac3.$(OBJEXT) + -rm -f src/atom_ac3.lo + -rm -f src/atom_amr.$(OBJEXT) + -rm -f src/atom_amr.lo + -rm -f src/atom_avc1.$(OBJEXT) + -rm -f src/atom_avc1.lo + -rm -f src/atom_avcC.$(OBJEXT) + -rm -f src/atom_avcC.lo + -rm -f src/atom_chpl.$(OBJEXT) + -rm -f src/atom_chpl.lo + -rm -f src/atom_colr.$(OBJEXT) + -rm -f src/atom_colr.lo + -rm -f src/atom_d263.$(OBJEXT) + -rm -f src/atom_d263.lo + -rm -f src/atom_dac3.$(OBJEXT) + -rm -f src/atom_dac3.lo + -rm -f src/atom_damr.$(OBJEXT) + -rm -f src/atom_damr.lo + -rm -f src/atom_dref.$(OBJEXT) + -rm -f src/atom_dref.lo + -rm -f src/atom_elst.$(OBJEXT) + -rm -f src/atom_elst.lo + -rm -f src/atom_enca.$(OBJEXT) + -rm -f src/atom_enca.lo + -rm -f src/atom_encv.$(OBJEXT) + -rm -f src/atom_encv.lo + -rm -f src/atom_free.$(OBJEXT) + -rm -f src/atom_free.lo + -rm -f src/atom_ftab.$(OBJEXT) + -rm -f src/atom_ftab.lo + -rm -f src/atom_ftyp.$(OBJEXT) + -rm -f src/atom_ftyp.lo + -rm -f src/atom_gmin.$(OBJEXT) + -rm -f src/atom_gmin.lo + -rm -f src/atom_hdlr.$(OBJEXT) + -rm -f src/atom_hdlr.lo + -rm -f src/atom_hinf.$(OBJEXT) + -rm -f src/atom_hinf.lo + -rm -f src/atom_hnti.$(OBJEXT) + -rm -f src/atom_hnti.lo + -rm -f src/atom_href.$(OBJEXT) + -rm -f src/atom_href.lo + -rm -f src/atom_mdat.$(OBJEXT) + -rm -f src/atom_mdat.lo + -rm -f src/atom_mdhd.$(OBJEXT) + -rm -f src/atom_mdhd.lo + -rm -f src/atom_meta.$(OBJEXT) + -rm -f src/atom_meta.lo + -rm -f src/atom_mp4s.$(OBJEXT) + -rm -f src/atom_mp4s.lo + -rm -f src/atom_mp4v.$(OBJEXT) + -rm -f src/atom_mp4v.lo + -rm -f src/atom_mvhd.$(OBJEXT) + -rm -f src/atom_mvhd.lo + -rm -f src/atom_nmhd.$(OBJEXT) + -rm -f src/atom_nmhd.lo + -rm -f src/atom_ohdr.$(OBJEXT) + -rm -f src/atom_ohdr.lo + -rm -f src/atom_pasp.$(OBJEXT) + -rm -f src/atom_pasp.lo + -rm -f src/atom_root.$(OBJEXT) + -rm -f src/atom_root.lo + -rm -f src/atom_rtp.$(OBJEXT) + -rm -f src/atom_rtp.lo + -rm -f src/atom_s263.$(OBJEXT) + -rm -f src/atom_s263.lo + -rm -f src/atom_sdp.$(OBJEXT) + -rm -f src/atom_sdp.lo + -rm -f src/atom_sdtp.$(OBJEXT) + -rm -f src/atom_sdtp.lo + -rm -f src/atom_smi.$(OBJEXT) + -rm -f src/atom_smi.lo + -rm -f src/atom_sound.$(OBJEXT) + -rm -f src/atom_sound.lo + -rm -f src/atom_standard.$(OBJEXT) + -rm -f src/atom_standard.lo + -rm -f src/atom_stbl.$(OBJEXT) + -rm -f src/atom_stbl.lo + -rm -f src/atom_stdp.$(OBJEXT) + -rm -f src/atom_stdp.lo + -rm -f src/atom_stsc.$(OBJEXT) + -rm -f src/atom_stsc.lo + -rm -f src/atom_stsd.$(OBJEXT) + -rm -f src/atom_stsd.lo + -rm -f src/atom_stsz.$(OBJEXT) + -rm -f src/atom_stsz.lo + -rm -f src/atom_stz2.$(OBJEXT) + -rm -f src/atom_stz2.lo + -rm -f src/atom_text.$(OBJEXT) + -rm -f src/atom_text.lo + -rm -f src/atom_tfhd.$(OBJEXT) + -rm -f src/atom_tfhd.lo + -rm -f src/atom_tkhd.$(OBJEXT) + -rm -f src/atom_tkhd.lo + -rm -f src/atom_treftype.$(OBJEXT) + -rm -f src/atom_treftype.lo + -rm -f src/atom_trun.$(OBJEXT) + -rm -f src/atom_trun.lo + -rm -f src/atom_tx3g.$(OBJEXT) + -rm -f src/atom_tx3g.lo + -rm -f src/atom_udta.$(OBJEXT) + -rm -f src/atom_udta.lo + -rm -f src/atom_url.$(OBJEXT) + -rm -f src/atom_url.lo + -rm -f src/atom_urn.$(OBJEXT) + -rm -f src/atom_urn.lo + -rm -f src/atom_uuid.$(OBJEXT) + -rm -f src/atom_uuid.lo + -rm -f src/atom_video.$(OBJEXT) + -rm -f src/atom_video.lo + -rm -f src/atom_vmhd.$(OBJEXT) + -rm -f src/atom_vmhd.lo + -rm -f src/bmff/typebmff.$(OBJEXT) + -rm -f src/bmff/typebmff.lo + -rm -f src/cmeta.$(OBJEXT) + -rm -f src/cmeta.lo + -rm -f src/descriptors.$(OBJEXT) + -rm -f src/descriptors.lo + -rm -f src/exception.$(OBJEXT) + -rm -f src/exception.lo + -rm -f src/isma.$(OBJEXT) + -rm -f src/isma.lo + -rm -f src/itmf/CoverArtBox.$(OBJEXT) + -rm -f src/itmf/CoverArtBox.lo + -rm -f src/itmf/Tags.$(OBJEXT) + -rm -f src/itmf/Tags.lo + -rm -f src/itmf/generic.$(OBJEXT) + -rm -f src/itmf/generic.lo + -rm -f src/itmf/type.$(OBJEXT) + -rm -f src/itmf/type.lo + -rm -f src/mp4.$(OBJEXT) + -rm -f src/mp4.lo + -rm -f src/mp4atom.$(OBJEXT) + -rm -f src/mp4atom.lo + -rm -f src/mp4container.$(OBJEXT) + -rm -f src/mp4container.lo + -rm -f src/mp4descriptor.$(OBJEXT) + -rm -f src/mp4descriptor.lo + -rm -f src/mp4file.$(OBJEXT) + -rm -f src/mp4file.lo + -rm -f src/mp4file_io.$(OBJEXT) + -rm -f src/mp4file_io.lo + -rm -f src/mp4info.$(OBJEXT) + -rm -f src/mp4info.lo + -rm -f src/mp4meta.$(OBJEXT) + -rm -f src/mp4meta.lo + -rm -f src/mp4property.$(OBJEXT) + -rm -f src/mp4property.lo + -rm -f src/mp4track.$(OBJEXT) + -rm -f src/mp4track.lo + -rm -f src/mp4util.$(OBJEXT) + -rm -f src/mp4util.lo + -rm -f src/ocidescriptors.$(OBJEXT) + -rm -f src/ocidescriptors.lo + -rm -f src/odcommands.$(OBJEXT) + -rm -f src/odcommands.lo + -rm -f src/qosqualifiers.$(OBJEXT) + -rm -f src/qosqualifiers.lo + -rm -f src/qtff/ColorParameterBox.$(OBJEXT) + -rm -f src/qtff/ColorParameterBox.lo + -rm -f src/qtff/PictureAspectRatioBox.$(OBJEXT) + -rm -f src/qtff/PictureAspectRatioBox.lo + -rm -f src/qtff/coding.$(OBJEXT) + -rm -f src/qtff/coding.lo + -rm -f src/rtphint.$(OBJEXT) + -rm -f src/rtphint.lo + -rm -f src/text.$(OBJEXT) + -rm -f src/text.lo + -rm -f util/mp4art.$(OBJEXT) + -rm -f util/mp4chaps.$(OBJEXT) + -rm -f util/mp4extract.$(OBJEXT) + -rm -f util/mp4file.$(OBJEXT) + -rm -f util/mp4info.$(OBJEXT) + -rm -f util/mp4subtitle.$(OBJEXT) + -rm -f util/mp4tags.$(OBJEXT) + -rm -f util/mp4track.$(OBJEXT) + -rm -f util/mp4trackdump.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@libplatform/io/$(DEPDIR)/File.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@libplatform/io/$(DEPDIR)/FileSystem.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@libplatform/io/$(DEPDIR)/FileSystem_posix.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@libplatform/io/$(DEPDIR)/FileSystem_win32.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@libplatform/io/$(DEPDIR)/File_posix.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@libplatform/io/$(DEPDIR)/File_win32.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@libplatform/number/$(DEPDIR)/random_posix.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@libplatform/number/$(DEPDIR)/random_win32.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@libplatform/process/$(DEPDIR)/process_posix.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@libplatform/process/$(DEPDIR)/process_win32.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@libplatform/prog/$(DEPDIR)/option.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@libplatform/sys/$(DEPDIR)/error.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@libplatform/time/$(DEPDIR)/time.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@libplatform/time/$(DEPDIR)/time_posix.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@libplatform/time/$(DEPDIR)/time_win32.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@libutil/$(DEPDIR)/Database.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@libutil/$(DEPDIR)/Timecode.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@libutil/$(DEPDIR)/TrackModifier.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@libutil/$(DEPDIR)/Utility.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@libutil/$(DEPDIR)/crc.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@libutil/$(DEPDIR)/other.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/3gp.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_ac3.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_amr.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_avc1.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_avcC.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_chpl.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_colr.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_d263.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_dac3.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_damr.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_dref.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_elst.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_enca.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_encv.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_free.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_ftab.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_ftyp.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_gmin.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_hdlr.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_hinf.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_hnti.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_href.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_mdat.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_mdhd.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_meta.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_mp4s.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_mp4v.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_mvhd.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_nmhd.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_ohdr.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_pasp.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_root.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_rtp.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_s263.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_sdp.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_sdtp.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_smi.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_sound.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_standard.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_stbl.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_stdp.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_stsc.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_stsd.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_stsz.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_stz2.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_text.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_tfhd.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_tkhd.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_treftype.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_trun.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_tx3g.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_udta.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_url.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_urn.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_uuid.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_video.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom_vmhd.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/cmeta.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/descriptors.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/exception.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/isma.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/mp4.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/mp4atom.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/mp4container.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/mp4descriptor.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/mp4file.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/mp4file_io.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/mp4info.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/mp4meta.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/mp4property.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/mp4track.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/mp4util.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/ocidescriptors.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/odcommands.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/qosqualifiers.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/rtphint.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/text.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/bmff/$(DEPDIR)/typebmff.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/itmf/$(DEPDIR)/CoverArtBox.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/itmf/$(DEPDIR)/Tags.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/itmf/$(DEPDIR)/generic.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/itmf/$(DEPDIR)/type.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/qtff/$(DEPDIR)/ColorParameterBox.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/qtff/$(DEPDIR)/PictureAspectRatioBox.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/qtff/$(DEPDIR)/coding.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@util/$(DEPDIR)/mp4art.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@util/$(DEPDIR)/mp4chaps.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@util/$(DEPDIR)/mp4extract.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@util/$(DEPDIR)/mp4file.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@util/$(DEPDIR)/mp4info.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@util/$(DEPDIR)/mp4subtitle.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@util/$(DEPDIR)/mp4tags.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@util/$(DEPDIR)/mp4track.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@util/$(DEPDIR)/mp4trackdump.Po@am__quote@ + +.cpp.o: +@am__fastdepCXX_TRUE@ depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`; \ +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$$depbase.Tpo" -c -o $@ $<; \ +@am__fastdepCXX_TRUE@ then mv -f "$$depbase.Tpo" "$$depbase.Po"; else rm -f "$$depbase.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: +@am__fastdepCXX_TRUE@ depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`; \ +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$$depbase.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCXX_TRUE@ then mv -f "$$depbase.Tpo" "$$depbase.Po"; else rm -f "$$depbase.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.cpp.lo: +@am__fastdepCXX_TRUE@ depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`; \ +@am__fastdepCXX_TRUE@ if $(LTCXXCOMPILE) -MT $@ -MD -MP -MF "$$depbase.Tpo" -c -o $@ $<; \ +@am__fastdepCXX_TRUE@ then mv -f "$$depbase.Tpo" "$$depbase.Plo"; else rm -f "$$depbase.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + -rm -rf libplatform/io/.libs libplatform/io/_libs + -rm -rf libplatform/number/.libs libplatform/number/_libs + -rm -rf libplatform/process/.libs libplatform/process/_libs + -rm -rf libplatform/prog/.libs libplatform/prog/_libs + -rm -rf libplatform/sys/.libs libplatform/sys/_libs + -rm -rf libplatform/time/.libs libplatform/time/_libs + -rm -rf libutil/.libs libutil/_libs + -rm -rf src/.libs src/_libs + -rm -rf src/bmff/.libs src/bmff/_libs + -rm -rf src/itmf/.libs src/itmf/_libs + -rm -rf src/qtff/.libs src/qtff/_libs + +distclean-libtool: + -rm -f libtool +uninstall-info-am: +install-man1: $(man1_MANS) $(man_MANS) + @$(NORMAL_INSTALL) + test -z "$(man1dir)" || $(mkdir_p) "$(DESTDIR)$(man1dir)" + @list='$(man1_MANS) $(dist_man1_MANS) $(nodist_man1_MANS)'; \ + l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \ + for i in $$l2; do \ + case "$$i" in \ + *.1*) list="$$list $$i" ;; \ + esac; \ + done; \ + for i in $$list; do \ + if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \ + else file=$$i; fi; \ + ext=`echo $$i | sed -e 's/^.*\\.//'`; \ + case "$$ext" in \ + 1*) ;; \ + *) ext='1' ;; \ + esac; \ + inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ + inst=`echo $$inst | sed -e 's/^.*\///'`; \ + inst=`echo $$inst | sed '$(transform)'`.$$ext; \ + echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \ + $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst"; \ + done +uninstall-man1: + @$(NORMAL_UNINSTALL) + @list='$(man1_MANS) $(dist_man1_MANS) $(nodist_man1_MANS)'; \ + l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \ + for i in $$l2; do \ + case "$$i" in \ + *.1*) list="$$list $$i" ;; \ + esac; \ + done; \ + for i in $$list; do \ + ext=`echo $$i | sed -e 's/^.*\\.//'`; \ + case "$$ext" in \ + 1*) ;; \ + *) ext='1' ;; \ + esac; \ + inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ + inst=`echo $$inst | sed -e 's/^.*\///'`; \ + inst=`echo $$inst | sed '$(transform)'`.$$ext; \ + echo " rm -f '$(DESTDIR)$(man1dir)/$$inst'"; \ + rm -f "$(DESTDIR)$(man1dir)/$$inst"; \ + done +install-mp4v2incHEADERS: $(mp4v2inc_HEADERS) + @$(NORMAL_INSTALL) + test -z "$(mp4v2incdir)" || $(mkdir_p) "$(DESTDIR)$(mp4v2incdir)" + @list='$(mp4v2inc_HEADERS)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(mp4v2incHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(mp4v2incdir)/$$f'"; \ + $(mp4v2incHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(mp4v2incdir)/$$f"; \ + done + +uninstall-mp4v2incHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(mp4v2inc_HEADERS)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(mp4v2incdir)/$$f'"; \ + rm -f "$(DESTDIR)$(mp4v2incdir)/$$f"; \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +check-DEJAGNU: site.exp + srcdir=`$(am__cd) $(srcdir) && pwd`; export srcdir; \ + EXPECT=$(EXPECT); export EXPECT; \ + runtest=$(RUNTEST); \ + if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \ + l='$(DEJATOOL)'; for tool in $$l; do \ + $$runtest $(AM_RUNTESTFLAGS) $(RUNTESTDEFAULTFLAGS) $(RUNTESTFLAGS); \ + done; \ + else echo "WARNING: could not find \`runtest'" 1>&2; :;\ + fi +site.exp: Makefile + @echo 'Making a new site.exp file...' + @echo '## these variables are automatically generated by make ##' >site.tmp + @echo '# Do not edit here. If you wish to override these values' >>site.tmp + @echo '# edit the last section' >>site.tmp + @echo 'set srcdir $(srcdir)' >>site.tmp + @echo "set objdir `pwd`" >>site.tmp + @echo 'set build_alias "$(build_alias)"' >>site.tmp + @echo 'set build_triplet $(build_triplet)' >>site.tmp + @echo 'set host_alias "$(host_alias)"' >>site.tmp + @echo 'set host_triplet $(host_triplet)' >>site.tmp + @echo '## All variables above are generated by configure. Do Not Edit ##' >>site.tmp + @test ! -f site.exp || \ + sed '1,/^## All variables above are.*##/ d' site.exp >> site.tmp + @-rm -f site.bak + @test ! -f site.exp || mv site.exp site.bak + @mv site.tmp site.exp + +distclean-DEJAGNU: + -rm -f site.exp site.bak + -l='$(DEJATOOL)'; for tool in $$l; do \ + rm -f $$tool.sum $$tool.log; \ + done + +distdir: $(DISTFILES) + $(am__remove_distdir) + mkdir $(distdir) + $(mkdir_p) $(distdir)/autoaux $(distdir)/include/mp4v2 $(distdir)/libplatform $(distdir)/project + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$(top_distdir)" distdir="$(distdir)" \ + dist-hook + -find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \ + ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ + ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ + ! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \ + || chmod -R a+r $(distdir) +dist-gzip: distdir + tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz + $(am__remove_distdir) +dist-bzip2: distdir + tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 + $(am__remove_distdir) + +dist-tarZ: distdir + tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z + $(am__remove_distdir) + +dist-shar: distdir + shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz + $(am__remove_distdir) +dist-zip: distdir + -rm -f $(distdir).zip + zip -rq $(distdir).zip $(distdir) + $(am__remove_distdir) + +dist dist-all: distdir + tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 + -rm -f $(distdir).zip + zip -rq $(distdir).zip $(distdir) + $(am__remove_distdir) + +# This target untars the dist file and tries a VPATH configuration. Then +# it guarantees that the distribution is self-contained by making another +# tarfile. +distcheck: dist + case '$(DIST_ARCHIVES)' in \ + *.tar.gz*) \ + GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\ + *.tar.bz2*) \ + bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\ + *.tar.Z*) \ + uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ + *.shar.gz*) \ + GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\ + *.zip*) \ + unzip $(distdir).zip ;;\ + esac + chmod -R a-w $(distdir); chmod a+w $(distdir) + mkdir $(distdir)/_build + mkdir $(distdir)/_inst + chmod a-w $(distdir) + dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ + && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ + && cd $(distdir)/_build \ + && ../configure --srcdir=.. --prefix="$$dc_install_base" \ + $(DISTCHECK_CONFIGURE_FLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) dvi \ + && $(MAKE) $(AM_MAKEFLAGS) check \ + && $(MAKE) $(AM_MAKEFLAGS) install \ + && $(MAKE) $(AM_MAKEFLAGS) installcheck \ + && $(MAKE) $(AM_MAKEFLAGS) uninstall \ + && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ + distuninstallcheck \ + && chmod -R a-w "$$dc_install_base" \ + && ({ \ + (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ + distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ + } || { rm -rf "$$dc_destdir"; exit 1; }) \ + && rm -rf "$$dc_destdir" \ + && $(MAKE) $(AM_MAKEFLAGS) dist \ + && rm -rf $(DIST_ARCHIVES) \ + && $(MAKE) $(AM_MAKEFLAGS) distcleancheck + $(am__remove_distdir) + @(echo "$(distdir) archives ready for distribution: "; \ + list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ + sed -e '1{h;s/./=/g;p;x;}' -e '$${p;x;}' +distuninstallcheck: + @cd $(distuninstallcheck_dir) \ + && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \ + || { echo "ERROR: files left after uninstall:" ; \ + if test -n "$(DESTDIR)"; then \ + echo " (check DESTDIR support)"; \ + fi ; \ + $(distuninstallcheck_listfiles) ; \ + exit 1; } >&2 +distcleancheck: distclean + @if test '$(srcdir)' = . ; then \ + echo "ERROR: distcleancheck can only run from a VPATH build" ; \ + exit 1 ; \ + fi + @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ + || { echo "ERROR: files left in build directory after distclean:" ; \ + $(distcleancheck_listfiles) ; \ + exit 1; } >&2 +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) + $(MAKE) $(AM_MAKEFLAGS) check-DEJAGNU +check: check-am +all-am: GNUmakefile $(LTLIBRARIES) $(PROGRAMS) $(MANS) $(HEADERS) +install-binPROGRAMS: install-libLTLIBRARIES + +installdirs: + for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(mp4v2incdir)"; do \ + test -z "$$dir" || $(mkdir_p) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -rm -f libplatform/io/$(DEPDIR)/$(am__dirstamp) + -rm -f libplatform/io/$(am__dirstamp) + -rm -f libplatform/number/$(DEPDIR)/$(am__dirstamp) + -rm -f libplatform/number/$(am__dirstamp) + -rm -f libplatform/process/$(DEPDIR)/$(am__dirstamp) + -rm -f libplatform/process/$(am__dirstamp) + -rm -f libplatform/prog/$(DEPDIR)/$(am__dirstamp) + -rm -f libplatform/prog/$(am__dirstamp) + -rm -f libplatform/sys/$(DEPDIR)/$(am__dirstamp) + -rm -f libplatform/sys/$(am__dirstamp) + -rm -f libplatform/time/$(DEPDIR)/$(am__dirstamp) + -rm -f libplatform/time/$(am__dirstamp) + -rm -f libutil/$(DEPDIR)/$(am__dirstamp) + -rm -f libutil/$(am__dirstamp) + -rm -f src/$(DEPDIR)/$(am__dirstamp) + -rm -f src/$(am__dirstamp) + -rm -f src/bmff/$(DEPDIR)/$(am__dirstamp) + -rm -f src/bmff/$(am__dirstamp) + -rm -f src/itmf/$(DEPDIR)/$(am__dirstamp) + -rm -f src/itmf/$(am__dirstamp) + -rm -f src/qtff/$(DEPDIR)/$(am__dirstamp) + -rm -f src/qtff/$(am__dirstamp) + -rm -f util/$(DEPDIR)/$(am__dirstamp) + -rm -f util/$(am__dirstamp) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-binPROGRAMS clean-checkPROGRAMS clean-generic \ + clean-libLTLIBRARIES clean-libtool clean-local mostlyclean-am + +distclean: distclean-am + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -rf libplatform/io/$(DEPDIR) libplatform/number/$(DEPDIR) libplatform/process/$(DEPDIR) libplatform/prog/$(DEPDIR) libplatform/sys/$(DEPDIR) libplatform/time/$(DEPDIR) libutil/$(DEPDIR) src/$(DEPDIR) src/bmff/$(DEPDIR) src/itmf/$(DEPDIR) src/qtff/$(DEPDIR) util/$(DEPDIR) + -rm -f GNUmakefile +distclean-am: clean-am distclean-DEJAGNU distclean-compile \ + distclean-generic distclean-hdr distclean-libtool \ + distclean-local distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-man install-mp4v2incHEADERS + +install-exec-am: install-binPROGRAMS install-libLTLIBRARIES + +install-info: install-info-am + +install-man: install-man1 + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -rf $(top_srcdir)/autom4te.cache + -rm -rf libplatform/io/$(DEPDIR) libplatform/number/$(DEPDIR) libplatform/process/$(DEPDIR) libplatform/prog/$(DEPDIR) libplatform/sys/$(DEPDIR) libplatform/time/$(DEPDIR) libutil/$(DEPDIR) src/$(DEPDIR) src/bmff/$(DEPDIR) src/itmf/$(DEPDIR) src/qtff/$(DEPDIR) util/$(DEPDIR) + -rm -f GNUmakefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-binPROGRAMS uninstall-info-am \ + uninstall-libLTLIBRARIES uninstall-man \ + uninstall-mp4v2incHEADERS + +uninstall-man: uninstall-man1 + +.PHONY: CTAGS GTAGS all all-am am--refresh check check-DEJAGNU \ + check-am clean clean-binPROGRAMS clean-checkPROGRAMS \ + clean-generic clean-libLTLIBRARIES clean-libtool clean-local \ + ctags dist dist-all dist-bzip2 dist-gzip dist-hook dist-shar \ + dist-tarZ dist-zip distcheck distclean distclean-DEJAGNU \ + distclean-compile distclean-generic distclean-hdr \ + distclean-libtool distclean-local distclean-tags \ + distcleancheck distdir distuninstallcheck dvi dvi-am html \ + html-am info info-am install install-am install-binPROGRAMS \ + install-data install-data-am install-exec install-exec-am \ + install-info install-info-am install-libLTLIBRARIES \ + install-man install-man1 install-mp4v2incHEADERS install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags uninstall uninstall-am uninstall-binPROGRAMS \ + uninstall-info-am uninstall-libLTLIBRARIES uninstall-man \ + uninstall-man1 uninstall-mp4v2incHEADERS + + +override RUNTESTDEFAULTFLAGS = --tool $$tool --srcdir $$srcdir/testsuite --outdir $(TESTLOGDIR) + +############################################################################### + +clean-local: + +distclean-local: + rm -f $(top_builddir)/Makefile + rm -f $(top_builddir)/testlog/*.log + rm -f $(top_builddir)/testlog/*.sum + +############################################################################### + +Makefile: ${Makefile} + touch $@ + $(mkdir_p) $(TESTLOGDIR) + +dist-hook: + +############################################################################### + +-include $(top_srcdir)/doc/GNUmakefile.mk +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: @@ -0,0 +1,237 @@ +Installation Instructions +************************* + +Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, +2006, 2007 Free Software Foundation, Inc. + +This file is free documentation; the Free Software Foundation gives +unlimited permission to copy, distribute and modify it. + +Basic Installation +================== + +Briefly, the shell commands `./configure; make; make install' should +configure, build, and install this package. The following +more-detailed instructions are generic; see the `README' file for +instructions specific to this package. + + The `configure' shell script attempts to guess correct values for +various system-dependent variables used during compilation. It uses +those values to create a `Makefile' in each directory of the package. +It may also create one or more `.h' files containing system-dependent +definitions. Finally, it creates a shell script `config.status' that +you can run in the future to recreate the current configuration, and a +file `config.log' containing compiler output (useful mainly for +debugging `configure'). + + It can also use an optional file (typically called `config.cache' +and enabled with `--cache-file=config.cache' or simply `-C') that saves +the results of its tests to speed up reconfiguring. Caching is +disabled by default to prevent problems with accidental use of stale +cache files. + + If you need to do unusual things to compile the package, please try +to figure out how `configure' could check whether to do them, and mail +diffs or instructions to the address given in the `README' so they can +be considered for the next release. If you are using the cache, and at +some point `config.cache' contains results you don't want to keep, you +may remove or edit it. + + The file `configure.ac' (or `configure.in') is used to create +`configure' by a program called `autoconf'. You need `configure.ac' if +you want to change it or regenerate `configure' using a newer version +of `autoconf'. + +The simplest way to compile this package is: + + 1. `cd' to the directory containing the package's source code and type + `./configure' to configure the package for your system. + + Running `configure' might take a while. While running, it prints + some messages telling which features it is checking for. + + 2. Type `make' to compile the package. + + 3. Optionally, type `make check' to run any self-tests that come with + the package. + + 4. Type `make install' to install the programs and any data files and + documentation. + + 5. You can remove the program binaries and object files from the + source code directory by typing `make clean'. To also remove the + files that `configure' created (so you can compile the package for + a different kind of computer), type `make distclean'. There is + also a `make maintainer-clean' target, but that is intended mainly + for the package's developers. If you use it, you may have to get + all sorts of other programs in order to regenerate files that came + with the distribution. + + 6. Often, you can also type `make uninstall' to remove the installed + files again. + +Compilers and Options +===================== + +Some systems require unusual options for compilation or linking that the +`configure' script does not know about. Run `./configure --help' for +details on some of the pertinent environment variables. + + You can give `configure' initial values for configuration parameters +by setting variables in the command line or in the environment. Here +is an example: + + ./configure CC=c99 CFLAGS=-g LIBS=-lposix + + *Note Defining Variables::, for more details. + +Compiling For Multiple Architectures +==================================== + +You can compile the package for more than one kind of computer at the +same time, by placing the object files for each architecture in their +own directory. To do this, you can use GNU `make'. `cd' to the +directory where you want the object files and executables to go and run +the `configure' script. `configure' automatically checks for the +source code in the directory that `configure' is in and in `..'. + + With a non-GNU `make', it is safer to compile the package for one +architecture at a time in the source code directory. After you have +installed the package for one architecture, use `make distclean' before +reconfiguring for another architecture. + +Installation Names +================== + +By default, `make install' installs the package's commands under +`/usr/local/bin', include files under `/usr/local/include', etc. You +can specify an installation prefix other than `/usr/local' by giving +`configure' the option `--prefix=PREFIX'. + + You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If you +pass the option `--exec-prefix=PREFIX' to `configure', the package uses +PREFIX as the prefix for installing programs and libraries. +Documentation and other data files still use the regular prefix. + + In addition, if you use an unusual directory layout you can give +options like `--bindir=DIR' to specify different values for particular +kinds of files. Run `configure --help' for a list of the directories +you can set and what kinds of files go in them. + + If the package supports it, you can cause programs to be installed +with an extra prefix or suffix on their names by giving `configure' the +option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. + +Optional Features +================= + +Some packages pay attention to `--enable-FEATURE' options to +`configure', where FEATURE indicates an optional part of the package. +They may also pay attention to `--with-PACKAGE' options, where PACKAGE +is something like `gnu-as' or `x' (for the X Window System). The +`README' should mention any `--enable-' and `--with-' options that the +package recognizes. + + For packages that use the X Window System, `configure' can usually +find the X include and library files automatically, but if it doesn't, +you can use the `configure' options `--x-includes=DIR' and +`--x-libraries=DIR' to specify their locations. + +Specifying the System Type +========================== + +There may be some features `configure' cannot figure out automatically, +but needs to determine by the type of machine the package will run on. +Usually, assuming the package is built to be run on the _same_ +architectures, `configure' can figure that out, but if it prints a +message saying it cannot guess the machine type, give it the +`--build=TYPE' option. TYPE can either be a short name for the system +type, such as `sun4', or a canonical name which has the form: + + CPU-COMPANY-SYSTEM + +where SYSTEM can have one of these forms: + + OS KERNEL-OS + + See the file `config.sub' for the possible values of each field. If +`config.sub' isn't included in this package, then this package doesn't +need to know the machine type. + + If you are _building_ compiler tools for cross-compiling, you should +use the option `--target=TYPE' to select the type of system they will +produce code for. + + If you want to _use_ a cross compiler, that generates code for a +platform different from the build platform, you should specify the +"host" platform (i.e., that on which the generated programs will +eventually be run) with `--host=TYPE'. + +Sharing Defaults +================ + +If you want to set default values for `configure' scripts to share, you +can create a site shell script called `config.site' that gives default +values for variables like `CC', `cache_file', and `prefix'. +`configure' looks for `PREFIX/share/config.site' if it exists, then +`PREFIX/etc/config.site' if it exists. Or, you can set the +`CONFIG_SITE' environment variable to the location of the site script. +A warning: not all `configure' scripts look for a site script. + +Defining Variables +================== + +Variables not defined in a site shell script can be set in the +environment passed to `configure'. However, some packages may run +configure again during the build, and the customized values of these +variables may be lost. In order to avoid this problem, you should set +them in the `configure' command line, using `VAR=value'. For example: + + ./configure CC=/usr/local2/bin/gcc + +causes the specified `gcc' to be used as the C compiler (unless it is +overridden in the site shell script). + +Unfortunately, this technique does not work for `CONFIG_SHELL' due to +an Autoconf bug. Until the bug is fixed you can use this workaround: + + CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash + +`configure' Invocation +====================== + +`configure' recognizes the following options to control how it operates. + +`--help' +`-h' + Print a summary of the options to `configure', and exit. + +`--version' +`-V' + Print the version of Autoconf used to generate the `configure' + script, and exit. + +`--cache-file=FILE' + Enable the cache: use and save the results of the tests in FILE, + traditionally `config.cache'. FILE defaults to `/dev/null' to + disable caching. + +`--config-cache' +`-C' + Alias for `--cache-file=config.cache'. + +`--quiet' +`--silent' +`-q' + Do not print messages saying which checks are being made. To + suppress all normal output, redirect it to `/dev/null' (any error + messages will still be shown). + +`--srcdir=DIR' + Look for the package's source code in directory DIR. Usually + `configure' can determine that directory automatically. + +`configure' also accepts some other, not widely useful, options. Run +`configure --help' for more details. + @@ -0,0 +1,5 @@ +All docs are located in doc/ subdirectory. Useful starting points: + +Release Notes -- doc/ReleaseNotes.txt +Building the Source -- doc/BuildSource.txt +Building the Repository -- doc/BuildRepository.txt diff --git a/aclocal.m4 b/aclocal.m4 new file mode 100644 index 0000000..662457b --- /dev/null +++ b/aclocal.m4 @@ -0,0 +1,7468 @@ +# generated automatically by aclocal 1.9.6 -*- Autoconf -*- + +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, +# 2005 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- + +# serial 52 AC_PROG_LIBTOOL + + +# AC_PROVIDE_IFELSE(MACRO-NAME, IF-PROVIDED, IF-NOT-PROVIDED) +# ----------------------------------------------------------- +# If this macro is not defined by Autoconf, define it here. +m4_ifdef([AC_PROVIDE_IFELSE], + [], + [m4_define([AC_PROVIDE_IFELSE], + [m4_ifdef([AC_PROVIDE_$1], + [$2], [$3])])]) + + +# AC_PROG_LIBTOOL +# --------------- +AC_DEFUN([AC_PROG_LIBTOOL], +[AC_REQUIRE([_AC_PROG_LIBTOOL])dnl +dnl If AC_PROG_CXX has already been expanded, run AC_LIBTOOL_CXX +dnl immediately, otherwise, hook it in at the end of AC_PROG_CXX. + AC_PROVIDE_IFELSE([AC_PROG_CXX], + [AC_LIBTOOL_CXX], + [define([AC_PROG_CXX], defn([AC_PROG_CXX])[AC_LIBTOOL_CXX + ])]) +dnl And a similar setup for Fortran 77 support + AC_PROVIDE_IFELSE([AC_PROG_F77], + [AC_LIBTOOL_F77], + [define([AC_PROG_F77], defn([AC_PROG_F77])[AC_LIBTOOL_F77 +])]) + +dnl Quote A][M_PROG_GCJ so that aclocal doesn't bring it in needlessly. +dnl If either AC_PROG_GCJ or A][M_PROG_GCJ have already been expanded, run +dnl AC_LIBTOOL_GCJ immediately, otherwise, hook it in at the end of both. + AC_PROVIDE_IFELSE([AC_PROG_GCJ], + [AC_LIBTOOL_GCJ], + [AC_PROVIDE_IFELSE([A][M_PROG_GCJ], + [AC_LIBTOOL_GCJ], + [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ], + [AC_LIBTOOL_GCJ], + [ifdef([AC_PROG_GCJ], + [define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[AC_LIBTOOL_GCJ])]) + ifdef([A][M_PROG_GCJ], + [define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[AC_LIBTOOL_GCJ])]) + ifdef([LT_AC_PROG_GCJ], + [define([LT_AC_PROG_GCJ], + defn([LT_AC_PROG_GCJ])[AC_LIBTOOL_GCJ])])])]) +])])# AC_PROG_LIBTOOL + + +# _AC_PROG_LIBTOOL +# ---------------- +AC_DEFUN([_AC_PROG_LIBTOOL], +[AC_REQUIRE([AC_LIBTOOL_SETUP])dnl +AC_BEFORE([$0],[AC_LIBTOOL_CXX])dnl +AC_BEFORE([$0],[AC_LIBTOOL_F77])dnl +AC_BEFORE([$0],[AC_LIBTOOL_GCJ])dnl + +# This can be used to rebuild libtool when needed +LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh" + +# Always use our own libtool. +LIBTOOL='$(SHELL) $(top_builddir)/libtool' +AC_SUBST(LIBTOOL)dnl + +# Prevent multiple expansion +define([AC_PROG_LIBTOOL], []) +])# _AC_PROG_LIBTOOL + + +# AC_LIBTOOL_SETUP +# ---------------- +AC_DEFUN([AC_LIBTOOL_SETUP], +[AC_PREREQ(2.50)dnl +AC_REQUIRE([AC_ENABLE_SHARED])dnl +AC_REQUIRE([AC_ENABLE_STATIC])dnl +AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl +AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_PROG_LD])dnl +AC_REQUIRE([AC_PROG_LD_RELOAD_FLAG])dnl +AC_REQUIRE([AC_PROG_NM])dnl + +AC_REQUIRE([AC_PROG_LN_S])dnl +AC_REQUIRE([AC_DEPLIBS_CHECK_METHOD])dnl +# Autoconf 2.13's AC_OBJEXT and AC_EXEEXT macros only works for C compilers! +AC_REQUIRE([AC_OBJEXT])dnl +AC_REQUIRE([AC_EXEEXT])dnl +dnl +AC_LIBTOOL_SYS_MAX_CMD_LEN +AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE +AC_LIBTOOL_OBJDIR + +AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl +_LT_AC_PROG_ECHO_BACKSLASH + +case $host_os in +aix3*) + # AIX sometimes has problems with the GCC collect2 program. For some + # reason, if we set the COLLECT_NAMES environment variable, the problems + # vanish in a puff of smoke. + if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES + fi + ;; +esac + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed='sed -e 1s/^X//' +[sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g'] + +# Same as above, but do not quote variable references. +[double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g'] + +# Sed substitution to delay expansion of an escaped shell variable in a +# double_quote_subst'ed string. +delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' + +# Sed substitution to avoid accidental globbing in evaled expressions +no_glob_subst='s/\*/\\\*/g' + +# Constants: +rm="rm -f" + +# Global variables: +default_ofile=libtool +can_build_shared=yes + +# All known linkers require a `.a' archive for static linking (except MSVC, +# which needs '.lib'). +libext=a +ltmain="$ac_aux_dir/ltmain.sh" +ofile="$default_ofile" +with_gnu_ld="$lt_cv_prog_gnu_ld" + +AC_CHECK_TOOL(AR, ar, false) +AC_CHECK_TOOL(RANLIB, ranlib, :) +AC_CHECK_TOOL(STRIP, strip, :) + +old_CC="$CC" +old_CFLAGS="$CFLAGS" + +# Set sane defaults for various variables +test -z "$AR" && AR=ar +test -z "$AR_FLAGS" && AR_FLAGS=cru +test -z "$AS" && AS=as +test -z "$CC" && CC=cc +test -z "$LTCC" && LTCC=$CC +test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS +test -z "$DLLTOOL" && DLLTOOL=dlltool +test -z "$LD" && LD=ld +test -z "$LN_S" && LN_S="ln -s" +test -z "$MAGIC_CMD" && MAGIC_CMD=file +test -z "$NM" && NM=nm +test -z "$SED" && SED=sed +test -z "$OBJDUMP" && OBJDUMP=objdump +test -z "$RANLIB" && RANLIB=: +test -z "$STRIP" && STRIP=: +test -z "$ac_objext" && ac_objext=o + +# Determine commands to create old-style static archives. +old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' +old_postinstall_cmds='chmod 644 $oldlib' +old_postuninstall_cmds= + +if test -n "$RANLIB"; then + case $host_os in + openbsd*) + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib" + ;; + *) + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib" + ;; + esac + old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" +fi + +_LT_CC_BASENAME([$compiler]) + +# Only perform the check for file, if the check method requires it +case $deplibs_check_method in +file_magic*) + if test "$file_magic_cmd" = '$MAGIC_CMD'; then + AC_PATH_MAGIC + fi + ;; +esac + +_LT_REQUIRED_DARWIN_CHECKS + +AC_PROVIDE_IFELSE([AC_LIBTOOL_DLOPEN], enable_dlopen=yes, enable_dlopen=no) +AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL], +enable_win32_dll=yes, enable_win32_dll=no) + +AC_ARG_ENABLE([libtool-lock], + [AC_HELP_STRING([--disable-libtool-lock], + [avoid locking (might break parallel builds)])]) +test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes + +AC_ARG_WITH([pic], + [AC_HELP_STRING([--with-pic], + [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], + [pic_mode="$withval"], + [pic_mode=default]) +test -z "$pic_mode" && pic_mode=default + +# Use C for the default configuration in the libtool script +tagname= +AC_LIBTOOL_LANG_C_CONFIG +_LT_AC_TAGCONFIG +])# AC_LIBTOOL_SETUP + + +# _LT_AC_SYS_COMPILER +# ------------------- +AC_DEFUN([_LT_AC_SYS_COMPILER], +[AC_REQUIRE([AC_PROG_CC])dnl + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# If no C compiler flags were specified, use CFLAGS. +LTCFLAGS=${LTCFLAGS-"$CFLAGS"} + +# Allow CC to be a program name with arguments. +compiler=$CC +])# _LT_AC_SYS_COMPILER + + +# _LT_CC_BASENAME(CC) +# ------------------- +# Calculate cc_basename. Skip known compiler wrappers and cross-prefix. +AC_DEFUN([_LT_CC_BASENAME], +[for cc_temp in $1""; do + case $cc_temp in + compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;; + distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;; + \-*) ;; + *) break;; + esac +done +cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` +]) + + +# _LT_COMPILER_BOILERPLATE +# ------------------------ +# Check for compiler boilerplate output or warnings with +# the simple compiler test code. +AC_DEFUN([_LT_COMPILER_BOILERPLATE], +[AC_REQUIRE([LT_AC_PROG_SED])dnl +ac_outfile=conftest.$ac_objext +echo "$lt_simple_compile_test_code" >conftest.$ac_ext +eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_compiler_boilerplate=`cat conftest.err` +$rm conftest* +])# _LT_COMPILER_BOILERPLATE + + +# _LT_LINKER_BOILERPLATE +# ---------------------- +# Check for linker boilerplate output or warnings with +# the simple link test code. +AC_DEFUN([_LT_LINKER_BOILERPLATE], +[AC_REQUIRE([LT_AC_PROG_SED])dnl +ac_outfile=conftest.$ac_objext +echo "$lt_simple_link_test_code" >conftest.$ac_ext +eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_linker_boilerplate=`cat conftest.err` +$rm -r conftest* +])# _LT_LINKER_BOILERPLATE + +# _LT_REQUIRED_DARWIN_CHECKS +# -------------------------- +# Check for some things on darwin +AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS],[ + case $host_os in + rhapsody* | darwin*) + AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:]) + AC_CHECK_TOOL([NMEDIT], [nmedit], [:]) + + AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod], + [lt_cv_apple_cc_single_mod=no + if test -z "${LT_MULTI_MODULE}"; then + # By default we will add the -single_module flag. You can override + # by either setting the environment variable LT_MULTI_MODULE + # non-empty at configure time, or by adding -multi_module to the + # link flags. + echo "int foo(void){return 1;}" > conftest.c + $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ + -dynamiclib ${wl}-single_module conftest.c + if test -f libconftest.dylib; then + lt_cv_apple_cc_single_mod=yes + rm -rf libconftest.dylib* + fi + rm conftest.c + fi]) + AC_CACHE_CHECK([for -exported_symbols_list linker flag], + [lt_cv_ld_exported_symbols_list], + [lt_cv_ld_exported_symbols_list=no + save_LDFLAGS=$LDFLAGS + echo "_main" > conftest.sym + LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" + AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], + [lt_cv_ld_exported_symbols_list=yes], + [lt_cv_ld_exported_symbols_list=no]) + LDFLAGS="$save_LDFLAGS" + ]) + case $host_os in + rhapsody* | darwin1.[[0123]]) + _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; + darwin1.*) + _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; + darwin*) + # if running on 10.5 or later, the deployment target defaults + # to the OS version, if on x86, and 10.4, the deployment + # target defaults to 10.4. Don't you love it? + case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in + 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*) + _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; + 10.[[012]]*) + _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; + 10.*) + _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; + esac + ;; + esac + if test "$lt_cv_apple_cc_single_mod" = "yes"; then + _lt_dar_single_mod='$single_module' + fi + if test "$lt_cv_ld_exported_symbols_list" = "yes"; then + _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' + else + _lt_dar_export_syms="~$NMEDIT -s \$output_objdir/\${libname}-symbols.expsym \${lib}" + fi + if test "$DSYMUTIL" != ":"; then + _lt_dsymutil="~$DSYMUTIL \$lib || :" + else + _lt_dsymutil= + fi + ;; + esac +]) + +# _LT_AC_SYS_LIBPATH_AIX +# ---------------------- +# Links a minimal program and checks the executable +# for the system default hardcoded library path. In most cases, +# this is /usr/lib:/lib, but when the MPI compilers are used +# the location of the communication and MPI libs are included too. +# If we don't find anything, use the default library path according +# to the aix ld manual. +AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX], +[AC_REQUIRE([LT_AC_PROG_SED])dnl +AC_LINK_IFELSE(AC_LANG_PROGRAM,[ +lt_aix_libpath_sed=' + /Import File Strings/,/^$/ { + /^0/ { + s/^0 *\(.*\)$/\1/ + p + } + }' +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then + aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` +fi],[]) +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +])# _LT_AC_SYS_LIBPATH_AIX + + +# _LT_AC_SHELL_INIT(ARG) +# ---------------------- +AC_DEFUN([_LT_AC_SHELL_INIT], +[ifdef([AC_DIVERSION_NOTICE], + [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)], + [AC_DIVERT_PUSH(NOTICE)]) +$1 +AC_DIVERT_POP +])# _LT_AC_SHELL_INIT + + +# _LT_AC_PROG_ECHO_BACKSLASH +# -------------------------- +# Add some code to the start of the generated configure script which +# will find an echo command which doesn't interpret backslashes. +AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH], +[_LT_AC_SHELL_INIT([ +# Check that we are running under the correct shell. +SHELL=${CONFIG_SHELL-/bin/sh} + +case X$ECHO in +X*--fallback-echo) + # Remove one level of quotation (which was required for Make). + ECHO=`echo "$ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','` + ;; +esac + +echo=${ECHO-echo} +if test "X[$]1" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift +elif test "X[$]1" = X--fallback-echo; then + # Avoid inline document here, it may be left over + : +elif test "X`($echo '\t') 2>/dev/null`" = 'X\t' ; then + # Yippee, $echo works! + : +else + # Restart under the correct shell. + exec $SHELL "[$]0" --no-reexec ${1+"[$]@"} +fi + +if test "X[$]1" = X--fallback-echo; then + # used as fallback echo + shift + cat <<EOF +[$]* +EOF + exit 0 +fi + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +if test -z "$ECHO"; then +if test "X${echo_test_string+set}" != Xset; then +# find a string as large as possible, as long as the shell can cope with it + for cmd in 'sed 50q "[$]0"' 'sed 20q "[$]0"' 'sed 10q "[$]0"' 'sed 2q "[$]0"' 'echo test'; do + # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ... + if (echo_test_string=`eval $cmd`) 2>/dev/null && + echo_test_string=`eval $cmd` && + (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null + then + break + fi + done +fi + +if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + : +else + # The Solaris, AIX, and Digital Unix default echo programs unquote + # backslashes. This makes it impossible to quote backslashes using + # echo "$something" | sed 's/\\/\\\\/g' + # + # So, first we look for a working echo in the user's PATH. + + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for dir in $PATH /usr/ucb; do + IFS="$lt_save_ifs" + if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && + test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + echo="$dir/echo" + break + fi + done + IFS="$lt_save_ifs" + + if test "X$echo" = Xecho; then + # We didn't find a better echo, so look for alternatives. + if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`(print -r "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + # This shell has a builtin print -r that does the trick. + echo='print -r' + elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) && + test "X$CONFIG_SHELL" != X/bin/ksh; then + # If we have ksh, try running configure again with it. + ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} + export ORIGINAL_CONFIG_SHELL + CONFIG_SHELL=/bin/ksh + export CONFIG_SHELL + exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"} + else + # Try using printf. + echo='printf %s\n' + if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + # Cool, printf works + : + elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && + test "X$echo_testing_string" = 'X\t' && + echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL + export CONFIG_SHELL + SHELL="$CONFIG_SHELL" + export SHELL + echo="$CONFIG_SHELL [$]0 --fallback-echo" + elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && + test "X$echo_testing_string" = 'X\t' && + echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + echo="$CONFIG_SHELL [$]0 --fallback-echo" + else + # maybe with a smaller string... + prev=: + + for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do + if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null + then + break + fi + prev="$cmd" + done + + if test "$prev" != 'sed 50q "[$]0"'; then + echo_test_string=`eval $prev` + export echo_test_string + exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"} + else + # Oops. We lost completely, so just stick with echo. + echo=echo + fi + fi + fi + fi +fi +fi + +# Copy echo and quote the copy suitably for passing to libtool from +# the Makefile, instead of quoting the original, which is used later. +ECHO=$echo +if test "X$ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then + ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo" +fi + +AC_SUBST(ECHO) +])])# _LT_AC_PROG_ECHO_BACKSLASH + + +# _LT_AC_LOCK +# ----------- +AC_DEFUN([_LT_AC_LOCK], +[AC_ARG_ENABLE([libtool-lock], + [AC_HELP_STRING([--disable-libtool-lock], + [avoid locking (might break parallel builds)])]) +test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes + +# Some flags need to be propagated to the compiler or linker for good +# libtool support. +case $host in +ia64-*-hpux*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case `/usr/bin/file conftest.$ac_objext` in + *ELF-32*) + HPUX_IA64_MODE="32" + ;; + *ELF-64*) + HPUX_IA64_MODE="64" + ;; + esac + fi + rm -rf conftest* + ;; +*-*-irix6*) + # Find out which ABI we are using. + echo '[#]line __oline__ "configure"' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + if test "$lt_cv_prog_gnu_ld" = yes; then + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -melf32bsmip" + ;; + *N32*) + LD="${LD-ld} -melf32bmipn32" + ;; + *64-bit*) + LD="${LD-ld} -melf64bmip" + ;; + esac + else + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -32" + ;; + *N32*) + LD="${LD-ld} -n32" + ;; + *64-bit*) + LD="${LD-ld} -64" + ;; + esac + fi + fi + rm -rf conftest* + ;; + +x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \ +s390*-*linux*|sparc*-*linux*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case `/usr/bin/file conftest.o` in + *32-bit*) + case $host in + x86_64-*kfreebsd*-gnu) + LD="${LD-ld} -m elf_i386_fbsd" + ;; + x86_64-*linux*) + LD="${LD-ld} -m elf_i386" + ;; + ppc64-*linux*|powerpc64-*linux*) + LD="${LD-ld} -m elf32ppclinux" + ;; + s390x-*linux*) + LD="${LD-ld} -m elf_s390" + ;; + sparc64-*linux*) + LD="${LD-ld} -m elf32_sparc" + ;; + esac + ;; + *64-bit*) + case $host in + x86_64-*kfreebsd*-gnu) + LD="${LD-ld} -m elf_x86_64_fbsd" + ;; + x86_64-*linux*) + LD="${LD-ld} -m elf_x86_64" + ;; + ppc*-*linux*|powerpc*-*linux*) + LD="${LD-ld} -m elf64ppc" + ;; + s390*-*linux*) + LD="${LD-ld} -m elf64_s390" + ;; + sparc*-*linux*) + LD="${LD-ld} -m elf64_sparc" + ;; + esac + ;; + esac + fi + rm -rf conftest* + ;; + +*-*-sco3.2v5*) + # On SCO OpenServer 5, we need -belf to get full-featured binaries. + SAVE_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -belf" + AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, + [AC_LANG_PUSH(C) + AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) + AC_LANG_POP]) + if test x"$lt_cv_cc_needs_belf" != x"yes"; then + # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf + CFLAGS="$SAVE_CFLAGS" + fi + ;; +sparc*-*solaris*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case `/usr/bin/file conftest.o` in + *64-bit*) + case $lt_cv_prog_gnu_ld in + yes*) LD="${LD-ld} -m elf64_sparc" ;; + *) + if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then + LD="${LD-ld} -64" + fi + ;; + esac + ;; + esac + fi + rm -rf conftest* + ;; + +AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL], +[*-*-cygwin* | *-*-mingw* | *-*-pw32*) + AC_CHECK_TOOL(DLLTOOL, dlltool, false) + AC_CHECK_TOOL(AS, as, false) + AC_CHECK_TOOL(OBJDUMP, objdump, false) + ;; + ]) +esac + +need_locks="$enable_libtool_lock" + +])# _LT_AC_LOCK + + +# AC_LIBTOOL_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, +# [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE]) +# ---------------------------------------------------------------- +# Check whether the given compiler option works +AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], +[AC_REQUIRE([LT_AC_PROG_SED]) +AC_CACHE_CHECK([$1], [$2], + [$2=no + ifelse([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4]) + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="$3" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&AS_MESSAGE_LOG_FD + echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings other than the usual output. + $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then + $2=yes + fi + fi + $rm conftest* +]) + +if test x"[$]$2" = xyes; then + ifelse([$5], , :, [$5]) +else + ifelse([$6], , :, [$6]) +fi +])# AC_LIBTOOL_COMPILER_OPTION + + +# AC_LIBTOOL_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, +# [ACTION-SUCCESS], [ACTION-FAILURE]) +# ------------------------------------------------------------ +# Check whether the given compiler option works +AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], +[AC_REQUIRE([LT_AC_PROG_SED])dnl +AC_CACHE_CHECK([$1], [$2], + [$2=no + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS $3" + echo "$lt_simple_link_test_code" > conftest.$ac_ext + if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then + # The linker can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + # Append any errors to the config.log. + cat conftest.err 1>&AS_MESSAGE_LOG_FD + $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if diff conftest.exp conftest.er2 >/dev/null; then + $2=yes + fi + else + $2=yes + fi + fi + $rm -r conftest* + LDFLAGS="$save_LDFLAGS" +]) + +if test x"[$]$2" = xyes; then + ifelse([$4], , :, [$4]) +else + ifelse([$5], , :, [$5]) +fi +])# AC_LIBTOOL_LINKER_OPTION + + +# AC_LIBTOOL_SYS_MAX_CMD_LEN +# -------------------------- +AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], +[# find the maximum length of command line arguments +AC_MSG_CHECKING([the maximum length of command line arguments]) +AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl + i=0 + teststring="ABCD" + + case $build_os in + msdosdjgpp*) + # On DJGPP, this test can blow up pretty badly due to problems in libc + # (any single argument exceeding 2000 bytes causes a buffer overrun + # during glob expansion). Even if it were fixed, the result of this + # check would be larger than it should be. + lt_cv_sys_max_cmd_len=12288; # 12K is about right + ;; + + gnu*) + # Under GNU Hurd, this test is not required because there is + # no limit to the length of command line arguments. + # Libtool will interpret -1 as no limit whatsoever + lt_cv_sys_max_cmd_len=-1; + ;; + + cygwin* | mingw*) + # On Win9x/ME, this test blows up -- it succeeds, but takes + # about 5 minutes as the teststring grows exponentially. + # Worse, since 9x/ME are not pre-emptively multitasking, + # you end up with a "frozen" computer, even though with patience + # the test eventually succeeds (with a max line length of 256k). + # Instead, let's just punt: use the minimum linelength reported by + # all of the supported platforms: 8192 (on NT/2K/XP). + lt_cv_sys_max_cmd_len=8192; + ;; + + amigaos*) + # On AmigaOS with pdksh, this test takes hours, literally. + # So we just punt and use a minimum line length of 8192. + lt_cv_sys_max_cmd_len=8192; + ;; + + netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) + # This has been around since 386BSD, at least. Likely further. + if test -x /sbin/sysctl; then + lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` + elif test -x /usr/sbin/sysctl; then + lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` + else + lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs + fi + # And add a safety zone + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` + ;; + + interix*) + # We know the value 262144 and hardcode it with a safety zone (like BSD) + lt_cv_sys_max_cmd_len=196608 + ;; + + osf*) + # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure + # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not + # nice to cause kernel panics so lets avoid the loop below. + # First set a reasonable default. + lt_cv_sys_max_cmd_len=16384 + # + if test -x /sbin/sysconfig; then + case `/sbin/sysconfig -q proc exec_disable_arg_limit` in + *1*) lt_cv_sys_max_cmd_len=-1 ;; + esac + fi + ;; + sco3.2v5*) + lt_cv_sys_max_cmd_len=102400 + ;; + sysv5* | sco5v6* | sysv4.2uw2*) + kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` + if test -n "$kargmax"; then + lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'` + else + lt_cv_sys_max_cmd_len=32768 + fi + ;; + *) + lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` + if test -n "$lt_cv_sys_max_cmd_len"; then + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` + else + SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} + while (test "X"`$SHELL [$]0 --fallback-echo "X$teststring" 2>/dev/null` \ + = "XX$teststring") >/dev/null 2>&1 && + new_result=`expr "X$teststring" : ".*" 2>&1` && + lt_cv_sys_max_cmd_len=$new_result && + test $i != 17 # 1/2 MB should be enough + do + i=`expr $i + 1` + teststring=$teststring$teststring + done + teststring= + # Add a significant safety factor because C++ compilers can tack on massive + # amounts of additional arguments before passing them to the linker. + # It appears as though 1/2 is a usable value. + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` + fi + ;; + esac +]) +if test -n $lt_cv_sys_max_cmd_len ; then + AC_MSG_RESULT($lt_cv_sys_max_cmd_len) +else + AC_MSG_RESULT(none) +fi +])# AC_LIBTOOL_SYS_MAX_CMD_LEN + + +# _LT_AC_CHECK_DLFCN +# ------------------ +AC_DEFUN([_LT_AC_CHECK_DLFCN], +[AC_CHECK_HEADERS(dlfcn.h)dnl +])# _LT_AC_CHECK_DLFCN + + +# _LT_AC_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, +# ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) +# --------------------------------------------------------------------- +AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF], +[AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl +if test "$cross_compiling" = yes; then : + [$4] +else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext <<EOF +[#line __oline__ "configure" +#include "confdefs.h" + +#if HAVE_DLFCN_H +#include <dlfcn.h> +#endif + +#include <stdio.h> + +#ifdef RTLD_GLOBAL +# define LT_DLGLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LT_DLGLOBAL DL_GLOBAL +# else +# define LT_DLGLOBAL 0 +# endif +#endif + +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LT_DLLAZY_OR_NOW +# ifdef RTLD_LAZY +# define LT_DLLAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LT_DLLAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LT_DLLAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LT_DLLAZY_OR_NOW DL_NOW +# else +# define LT_DLLAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +#ifdef __cplusplus +extern "C" void exit (int); +#endif + +void fnord() { int i=42;} +int main () +{ + void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); + int status = $lt_dlunknown; + + if (self) + { + if (dlsym (self,"fnord")) status = $lt_dlno_uscore; + else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + /* dlclose (self); */ + } + else + puts (dlerror ()); + + exit (status); +}] +EOF + if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then + (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null + lt_status=$? + case x$lt_status in + x$lt_dlno_uscore) $1 ;; + x$lt_dlneed_uscore) $2 ;; + x$lt_dlunknown|x*) $3 ;; + esac + else : + # compilation failed + $3 + fi +fi +rm -fr conftest* +])# _LT_AC_TRY_DLOPEN_SELF + + +# AC_LIBTOOL_DLOPEN_SELF +# ---------------------- +AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], +[AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl +if test "x$enable_dlopen" != xyes; then + enable_dlopen=unknown + enable_dlopen_self=unknown + enable_dlopen_self_static=unknown +else + lt_cv_dlopen=no + lt_cv_dlopen_libs= + + case $host_os in + beos*) + lt_cv_dlopen="load_add_on" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ;; + + mingw* | pw32*) + lt_cv_dlopen="LoadLibrary" + lt_cv_dlopen_libs= + ;; + + cygwin*) + lt_cv_dlopen="dlopen" + lt_cv_dlopen_libs= + ;; + + darwin*) + # if libdl is installed we need to link against it + AC_CHECK_LIB([dl], [dlopen], + [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[ + lt_cv_dlopen="dyld" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ]) + ;; + + *) + AC_CHECK_FUNC([shl_load], + [lt_cv_dlopen="shl_load"], + [AC_CHECK_LIB([dld], [shl_load], + [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"], + [AC_CHECK_FUNC([dlopen], + [lt_cv_dlopen="dlopen"], + [AC_CHECK_LIB([dl], [dlopen], + [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"], + [AC_CHECK_LIB([svld], [dlopen], + [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"], + [AC_CHECK_LIB([dld], [dld_link], + [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"]) + ]) + ]) + ]) + ]) + ]) + ;; + esac + + if test "x$lt_cv_dlopen" != xno; then + enable_dlopen=yes + else + enable_dlopen=no + fi + + case $lt_cv_dlopen in + dlopen) + save_CPPFLAGS="$CPPFLAGS" + test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" + + save_LDFLAGS="$LDFLAGS" + wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" + + save_LIBS="$LIBS" + LIBS="$lt_cv_dlopen_libs $LIBS" + + AC_CACHE_CHECK([whether a program can dlopen itself], + lt_cv_dlopen_self, [dnl + _LT_AC_TRY_DLOPEN_SELF( + lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes, + lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross) + ]) + + if test "x$lt_cv_dlopen_self" = xyes; then + wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" + AC_CACHE_CHECK([whether a statically linked program can dlopen itself], + lt_cv_dlopen_self_static, [dnl + _LT_AC_TRY_DLOPEN_SELF( + lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes, + lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross) + ]) + fi + + CPPFLAGS="$save_CPPFLAGS" + LDFLAGS="$save_LDFLAGS" + LIBS="$save_LIBS" + ;; + esac + + case $lt_cv_dlopen_self in + yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; + *) enable_dlopen_self=unknown ;; + esac + + case $lt_cv_dlopen_self_static in + yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; + *) enable_dlopen_self_static=unknown ;; + esac +fi +])# AC_LIBTOOL_DLOPEN_SELF + + +# AC_LIBTOOL_PROG_CC_C_O([TAGNAME]) +# --------------------------------- +# Check to see if options -c and -o are simultaneously supported by compiler +AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O], +[AC_REQUIRE([LT_AC_PROG_SED])dnl +AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl +AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext], + [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)], + [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no + $rm -r conftest 2>/dev/null + mkdir conftest + cd conftest + mkdir out + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + lt_compiler_flag="-o out/conftest2.$ac_objext" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&AS_MESSAGE_LOG_FD + echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp + $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 + if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then + _LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes + fi + fi + chmod u+w . 2>&AS_MESSAGE_LOG_FD + $rm conftest* + # SGI C++ compiler will create directory out/ii_files/ for + # template instantiation + test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files + $rm out/* && rmdir out + cd .. + rmdir conftest + $rm conftest* +]) +])# AC_LIBTOOL_PROG_CC_C_O + + +# AC_LIBTOOL_SYS_HARD_LINK_LOCKS([TAGNAME]) +# ----------------------------------------- +# Check to see if we can do hard links to lock some files if needed +AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], +[AC_REQUIRE([_LT_AC_LOCK])dnl + +hard_links="nottested" +if test "$_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then + # do not overwrite the value of need_locks provided by the user + AC_MSG_CHECKING([if we can lock with hard links]) + hard_links=yes + $rm conftest* + ln conftest.a conftest.b 2>/dev/null && hard_links=no + touch conftest.a + ln conftest.a conftest.b 2>&5 || hard_links=no + ln conftest.a conftest.b 2>/dev/null && hard_links=no + AC_MSG_RESULT([$hard_links]) + if test "$hard_links" = no; then + AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe]) + need_locks=warn + fi +else + need_locks=no +fi +])# AC_LIBTOOL_SYS_HARD_LINK_LOCKS + + +# AC_LIBTOOL_OBJDIR +# ----------------- +AC_DEFUN([AC_LIBTOOL_OBJDIR], +[AC_CACHE_CHECK([for objdir], [lt_cv_objdir], +[rm -f .libs 2>/dev/null +mkdir .libs 2>/dev/null +if test -d .libs; then + lt_cv_objdir=.libs +else + # MS-DOS does not allow filenames that begin with a dot. + lt_cv_objdir=_libs +fi +rmdir .libs 2>/dev/null]) +objdir=$lt_cv_objdir +])# AC_LIBTOOL_OBJDIR + + +# AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH([TAGNAME]) +# ---------------------------------------------- +# Check hardcoding attributes. +AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], +[AC_MSG_CHECKING([how to hardcode library paths into programs]) +_LT_AC_TAGVAR(hardcode_action, $1)= +if test -n "$_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)" || \ + test -n "$_LT_AC_TAGVAR(runpath_var, $1)" || \ + test "X$_LT_AC_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then + + # We can hardcode non-existant directories. + if test "$_LT_AC_TAGVAR(hardcode_direct, $1)" != no && + # If the only mechanism to avoid hardcoding is shlibpath_var, we + # have to relink, otherwise we might link with an installed library + # when we should be linking with a yet-to-be-installed one + ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)" != no && + test "$_LT_AC_TAGVAR(hardcode_minus_L, $1)" != no; then + # Linking always hardcodes the temporary library directory. + _LT_AC_TAGVAR(hardcode_action, $1)=relink + else + # We can link without hardcoding, and we can hardcode nonexisting dirs. + _LT_AC_TAGVAR(hardcode_action, $1)=immediate + fi +else + # We cannot hardcode anything, or else we can only hardcode existing + # directories. + _LT_AC_TAGVAR(hardcode_action, $1)=unsupported +fi +AC_MSG_RESULT([$_LT_AC_TAGVAR(hardcode_action, $1)]) + +if test "$_LT_AC_TAGVAR(hardcode_action, $1)" = relink; then + # Fast installation is not supported + enable_fast_install=no +elif test "$shlibpath_overrides_runpath" = yes || + test "$enable_shared" = no; then + # Fast installation is not necessary + enable_fast_install=needless +fi +])# AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH + + +# AC_LIBTOOL_SYS_LIB_STRIP +# ------------------------ +AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP], +[striplib= +old_striplib= +AC_MSG_CHECKING([whether stripping libraries is possible]) +if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then + test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" + test -z "$striplib" && striplib="$STRIP --strip-unneeded" + AC_MSG_RESULT([yes]) +else +# FIXME - insert some real tests, host_os isn't really good enough + case $host_os in + darwin*) + if test -n "$STRIP" ; then + striplib="$STRIP -x" + old_striplib="$STRIP -S" + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) +fi + ;; + *) + AC_MSG_RESULT([no]) + ;; + esac +fi +])# AC_LIBTOOL_SYS_LIB_STRIP + + +# AC_LIBTOOL_SYS_DYNAMIC_LINKER +# ----------------------------- +# PORTME Fill in your ld.so characteristics +AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER], +[AC_REQUIRE([LT_AC_PROG_SED])dnl +AC_MSG_CHECKING([dynamic linker characteristics]) +library_names_spec= +libname_spec='lib$name' +soname_spec= +shrext_cmds=".so" +postinstall_cmds= +postuninstall_cmds= +finish_cmds= +finish_eval= +shlibpath_var= +shlibpath_overrides_runpath=unknown +version_type=none +dynamic_linker="$host_os ld.so" +sys_lib_dlsearch_path_spec="/lib /usr/lib" +m4_if($1,[],[ +if test "$GCC" = yes; then + case $host_os in + darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; + *) lt_awk_arg="/^libraries:/" ;; + esac + lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if echo "$lt_search_path_spec" | grep ';' >/dev/null ; then + # if the path contains ";" then we assume it to be the separator + # otherwise default to the standard path separator (i.e. ":") - it is + # assumed that no part of a normal pathname contains ";" but that should + # okay in the real world where ";" in dirpaths is itself problematic. + lt_search_path_spec=`echo "$lt_search_path_spec" | $SED -e 's/;/ /g'` + else + lt_search_path_spec=`echo "$lt_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + # Ok, now we have the path, separated by spaces, we can step through it + # and add multilib dir if necessary. + lt_tmp_lt_search_path_spec= + lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` + for lt_sys_path in $lt_search_path_spec; do + if test -d "$lt_sys_path/$lt_multi_os_dir"; then + lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" + else + test -d "$lt_sys_path" && \ + lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" + fi + done + lt_search_path_spec=`echo $lt_tmp_lt_search_path_spec | awk ' +BEGIN {RS=" "; FS="/|\n";} { + lt_foo=""; + lt_count=0; + for (lt_i = NF; lt_i > 0; lt_i--) { + if ($lt_i != "" && $lt_i != ".") { + if ($lt_i == "..") { + lt_count++; + } else { + if (lt_count == 0) { + lt_foo="/" $lt_i lt_foo; + } else { + lt_count--; + } + } + } + } + if (lt_foo != "") { lt_freq[[lt_foo]]++; } + if (lt_freq[[lt_foo]] == 1) { print lt_foo; } +}'` + sys_lib_search_path_spec=`echo $lt_search_path_spec` +else + sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" +fi]) +need_lib_prefix=unknown +hardcode_into_libs=no + +# when you set need_version to no, make sure it does not cause -set_version +# flags to be left without arguments +need_version=unknown + +case $host_os in +aix3*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' + shlibpath_var=LIBPATH + + # AIX 3 has no versioning support, so we append a major version to the name. + soname_spec='${libname}${release}${shared_ext}$major' + ;; + +aix[[4-9]]*) + version_type=linux + need_lib_prefix=no + need_version=no + hardcode_into_libs=yes + if test "$host_cpu" = ia64; then + # AIX 5 supports IA64 + library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + else + # With GCC up to 2.95.x, collect2 would create an import file + # for dependence libraries. The import file would start with + # the line `#! .'. This would cause the generated library to + # depend on `.', always an invalid library. This was fixed in + # development snapshots of GCC prior to 3.0. + case $host_os in + aix4 | aix4.[[01]] | aix4.[[01]].*) + if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' + echo ' yes ' + echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then + : + else + can_build_shared=no + fi + ;; + esac + # AIX (on Power*) has no versioning support, so currently we can not hardcode correct + # soname into executable. Probably we can add versioning support to + # collect2, so additional links can be useful in future. + if test "$aix_use_runtimelinking" = yes; then + # If using run time linking (on AIX 4.2 or later) use lib<name>.so + # instead of lib<name>.a to let people know that these are not + # typical AIX shared libraries. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + else + # We preserve .a as extension for shared libraries through AIX4.2 + # and later when we are not doing run time linking. + library_names_spec='${libname}${release}.a $libname.a' + soname_spec='${libname}${release}${shared_ext}$major' + fi + shlibpath_var=LIBPATH + fi + ;; + +amigaos*) + library_names_spec='$libname.ixlibrary $libname.a' + # Create ${libname}_ixlibrary.a entries in /sys/libs. + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' + ;; + +beos*) + library_names_spec='${libname}${shared_ext}' + dynamic_linker="$host_os ld.so" + shlibpath_var=LIBRARY_PATH + ;; + +bsdi[[45]]*) + version_type=linux + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" + sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" + # the default ld.so.conf also contains /usr/contrib/lib and + # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow + # libtool to hard-code these into programs + ;; + +cygwin* | mingw* | pw32*) + version_type=windows + shrext_cmds=".dll" + need_version=no + need_lib_prefix=no + + case $GCC,$host_os in + yes,cygwin* | yes,mingw* | yes,pw32*) + library_names_spec='$libname.dll.a' + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \${file}`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname~ + chmod a+x \$dldir/$dlname' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $rm \$dlpath' + shlibpath_overrides_runpath=yes + + case $host_os in + cygwin*) + # Cygwin DLLs use 'cyg' prefix rather than 'lib' + soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" + ;; + mingw*) + # MinGW DLLs use traditional 'lib' prefix + soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if echo "$sys_lib_search_path_spec" | [grep ';[c-zC-Z]:/' >/dev/null]; then + # It is most probably a Windows format PATH printed by + # mingw gcc, but we are running on Cygwin. Gcc prints its search + # path with ; separators, and with drive letters. We can handle the + # drive letters (cygwin fileutils understands them), so leave them, + # especially as we might pass files found there to a mingw objdump, + # which wouldn't understand a cygwinified path. Ahh. + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + ;; + pw32*) + # pw32 DLLs use 'pw' prefix rather than 'lib' + library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' + ;; + esac + ;; + + *) + library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib' + ;; + esac + dynamic_linker='Win32 ld.exe' + # FIXME: first we should search . and the directory the executable is in + shlibpath_var=PATH + ;; + +darwin* | rhapsody*) + dynamic_linker="$host_os dyld" + version_type=darwin + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext' + soname_spec='${libname}${release}${major}$shared_ext' + shlibpath_overrides_runpath=yes + shlibpath_var=DYLD_LIBRARY_PATH + shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' + m4_if([$1], [],[ + sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"]) + sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' + ;; + +dgux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +freebsd1*) + dynamic_linker=no + ;; + +freebsd* | dragonfly*) + # DragonFly does not have aout. When/if they implement a new + # versioning mechanism, adjust this. + if test -x /usr/bin/objformat; then + objformat=`/usr/bin/objformat` + else + case $host_os in + freebsd[[123]]*) objformat=aout ;; + *) objformat=elf ;; + esac + fi + version_type=freebsd-$objformat + case $version_type in + freebsd-elf*) + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + need_version=no + need_lib_prefix=no + ;; + freebsd-*) + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' + need_version=yes + ;; + esac + shlibpath_var=LD_LIBRARY_PATH + case $host_os in + freebsd2*) + shlibpath_overrides_runpath=yes + ;; + freebsd3.[[01]]* | freebsdelf3.[[01]]*) + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \ + freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1) + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + *) # from 4.6 on, and DragonFly + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + esac + ;; + +gnu*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + hardcode_into_libs=yes + ;; + +hpux9* | hpux10* | hpux11*) + # Give a soname corresponding to the major version so that dld.sl refuses to + # link against other versions. + version_type=sunos + need_lib_prefix=no + need_version=no + case $host_cpu in + ia64*) + shrext_cmds='.so' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.so" + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + if test "X$HPUX_IA64_MODE" = X32; then + sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" + else + sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" + fi + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + hppa*64*) + shrext_cmds='.sl' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.sl" + shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + *) + shrext_cmds='.sl' + dynamic_linker="$host_os dld.sl" + shlibpath_var=SHLIB_PATH + shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + ;; + esac + # HP-UX runs *really* slowly unless shared libraries are mode 555. + postinstall_cmds='chmod 555 $lib' + ;; + +interix[[3-9]]*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + +irix5* | irix6* | nonstopux*) + case $host_os in + nonstopux*) version_type=nonstopux ;; + *) + if test "$lt_cv_prog_gnu_ld" = yes; then + version_type=linux + else + version_type=irix + fi ;; + esac + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' + case $host_os in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in # libtool.m4 will add one of these switches to LD + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") + libsuff= shlibsuff= libmagic=32-bit;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") + libsuff=32 shlibsuff=N32 libmagic=N32;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") + libsuff=64 shlibsuff=64 libmagic=64-bit;; + *) libsuff= shlibsuff= libmagic=never-match;; + esac + ;; + esac + shlibpath_var=LD_LIBRARY${shlibsuff}_PATH + shlibpath_overrides_runpath=no + sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" + sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" + hardcode_into_libs=yes + ;; + +# No shared lib support for Linux oldld, aout, or coff. +linux*oldld* | linux*aout* | linux*coff*) + dynamic_linker=no + ;; + +# This must be Linux ELF. +linux* | k*bsd*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + # Append ld.so.conf contents to the search path + if test -f /etc/ld.so.conf; then + lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` + sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" + fi + + # We used to test for /lib/ld.so.1 and disable shared libraries on + # powerpc, because MkLinux only supported shared libraries with the + # GNU dynamic linker. Since this was broken with cross compilers, + # most powerpc-linux boxes support dynamic linking these days and + # people can always --disable-shared, the test was removed, and we + # assume the GNU/Linux dynamic linker is in use. + dynamic_linker='GNU/Linux ld.so' + ;; + +netbsd*) + version_type=sunos + need_lib_prefix=no + need_version=no + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + dynamic_linker='NetBSD (a.out) ld.so' + else + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='NetBSD ld.elf_so' + fi + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + +newsos6) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +nto-qnx*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +openbsd*) + version_type=sunos + sys_lib_dlsearch_path_spec="/usr/lib" + need_lib_prefix=no + # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. + case $host_os in + openbsd3.3 | openbsd3.3.*) need_version=yes ;; + *) need_version=no ;; + esac + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + shlibpath_var=LD_LIBRARY_PATH + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + case $host_os in + openbsd2.[[89]] | openbsd2.[[89]].*) + shlibpath_overrides_runpath=no + ;; + *) + shlibpath_overrides_runpath=yes + ;; + esac + else + shlibpath_overrides_runpath=yes + fi + ;; + +os2*) + libname_spec='$name' + shrext_cmds=".dll" + need_lib_prefix=no + library_names_spec='$libname${shared_ext} $libname.a' + dynamic_linker='OS/2 ld.exe' + shlibpath_var=LIBPATH + ;; + +osf3* | osf4* | osf5*) + version_type=osf + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" + sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" + ;; + +rdos*) + dynamic_linker=no + ;; + +solaris*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + # ldd complains unless libraries are executable + postinstall_cmds='chmod +x $lib' + ;; + +sunos4*) + version_type=sunos + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + if test "$with_gnu_ld" = yes; then + need_lib_prefix=no + fi + need_version=yes + ;; + +sysv4 | sysv4.3*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + case $host_vendor in + sni) + shlibpath_overrides_runpath=no + need_lib_prefix=no + export_dynamic_flag_spec='${wl}-Blargedynsym' + runpath_var=LD_RUN_PATH + ;; + siemens) + need_lib_prefix=no + ;; + motorola) + need_lib_prefix=no + need_version=no + shlibpath_overrides_runpath=no + sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' + ;; + esac + ;; + +sysv4*MP*) + if test -d /usr/nec ;then + version_type=linux + library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' + soname_spec='$libname${shared_ext}.$major' + shlibpath_var=LD_LIBRARY_PATH + fi + ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + version_type=freebsd-elf + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + hardcode_into_libs=yes + if test "$with_gnu_ld" = yes; then + sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' + shlibpath_overrides_runpath=no + else + sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' + shlibpath_overrides_runpath=yes + case $host_os in + sco3.2v5*) + sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" + ;; + esac + fi + sys_lib_dlsearch_path_spec='/usr/lib' + ;; + +uts4*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +*) + dynamic_linker=no + ;; +esac +AC_MSG_RESULT([$dynamic_linker]) +test "$dynamic_linker" = no && can_build_shared=no + +AC_CACHE_VAL([lt_cv_sys_lib_search_path_spec], +[lt_cv_sys_lib_search_path_spec="$sys_lib_search_path_spec"]) +sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" +AC_CACHE_VAL([lt_cv_sys_lib_dlsearch_path_spec], +[lt_cv_sys_lib_dlsearch_path_spec="$sys_lib_dlsearch_path_spec"]) +sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" + +variables_saved_for_relink="PATH $shlibpath_var $runpath_var" +if test "$GCC" = yes; then + variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" +fi +])# AC_LIBTOOL_SYS_DYNAMIC_LINKER + + +# _LT_AC_TAGCONFIG +# ---------------- +AC_DEFUN([_LT_AC_TAGCONFIG], +[AC_REQUIRE([LT_AC_PROG_SED])dnl +AC_ARG_WITH([tags], + [AC_HELP_STRING([--with-tags@<:@=TAGS@:>@], + [include additional configurations @<:@automatic@:>@])], + [tagnames="$withval"]) + +if test -f "$ltmain" && test -n "$tagnames"; then + if test ! -f "${ofile}"; then + AC_MSG_WARN([output file `$ofile' does not exist]) + fi + + if test -z "$LTCC"; then + eval "`$SHELL ${ofile} --config | grep '^LTCC='`" + if test -z "$LTCC"; then + AC_MSG_WARN([output file `$ofile' does not look like a libtool script]) + else + AC_MSG_WARN([using `LTCC=$LTCC', extracted from `$ofile']) + fi + fi + if test -z "$LTCFLAGS"; then + eval "`$SHELL ${ofile} --config | grep '^LTCFLAGS='`" + fi + + # Extract list of available tagged configurations in $ofile. + # Note that this assumes the entire list is on one line. + available_tags=`grep "^available_tags=" "${ofile}" | $SED -e 's/available_tags=\(.*$\)/\1/' -e 's/\"//g'` + + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for tagname in $tagnames; do + IFS="$lt_save_ifs" + # Check whether tagname contains only valid characters + case `$echo "X$tagname" | $Xsed -e 's:[[-_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,/]]::g'` in + "") ;; + *) AC_MSG_ERROR([invalid tag name: $tagname]) + ;; + esac + + if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "${ofile}" > /dev/null + then + AC_MSG_ERROR([tag name \"$tagname\" already exists]) + fi + + # Update the list of available tags. + if test -n "$tagname"; then + echo appending configuration tag \"$tagname\" to $ofile + + case $tagname in + CXX) + if test -n "$CXX" && ( test "X$CXX" != "Xno" && + ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || + (test "X$CXX" != "Xg++"))) ; then + AC_LIBTOOL_LANG_CXX_CONFIG + else + tagname="" + fi + ;; + + F77) + if test -n "$F77" && test "X$F77" != "Xno"; then + AC_LIBTOOL_LANG_F77_CONFIG + else + tagname="" + fi + ;; + + GCJ) + if test -n "$GCJ" && test "X$GCJ" != "Xno"; then + AC_LIBTOOL_LANG_GCJ_CONFIG + else + tagname="" + fi + ;; + + RC) + AC_LIBTOOL_LANG_RC_CONFIG + ;; + + *) + AC_MSG_ERROR([Unsupported tag name: $tagname]) + ;; + esac + + # Append the new tag name to the list of available tags. + if test -n "$tagname" ; then + available_tags="$available_tags $tagname" + fi + fi + done + IFS="$lt_save_ifs" + + # Now substitute the updated list of available tags. + if eval "sed -e 's/^available_tags=.*\$/available_tags=\"$available_tags\"/' \"$ofile\" > \"${ofile}T\""; then + mv "${ofile}T" "$ofile" + chmod +x "$ofile" + else + rm -f "${ofile}T" + AC_MSG_ERROR([unable to update list of available tagged configurations.]) + fi +fi +])# _LT_AC_TAGCONFIG + + +# AC_LIBTOOL_DLOPEN +# ----------------- +# enable checks for dlopen support +AC_DEFUN([AC_LIBTOOL_DLOPEN], + [AC_BEFORE([$0],[AC_LIBTOOL_SETUP]) +])# AC_LIBTOOL_DLOPEN + + +# AC_LIBTOOL_WIN32_DLL +# -------------------- +# declare package support for building win32 DLLs +AC_DEFUN([AC_LIBTOOL_WIN32_DLL], +[AC_BEFORE([$0], [AC_LIBTOOL_SETUP]) +])# AC_LIBTOOL_WIN32_DLL + + +# AC_ENABLE_SHARED([DEFAULT]) +# --------------------------- +# implement the --enable-shared flag +# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. +AC_DEFUN([AC_ENABLE_SHARED], +[define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl +AC_ARG_ENABLE([shared], + [AC_HELP_STRING([--enable-shared@<:@=PKGS@:>@], + [build shared libraries @<:@default=]AC_ENABLE_SHARED_DEFAULT[@:>@])], + [p=${PACKAGE-default} + case $enableval in + yes) enable_shared=yes ;; + no) enable_shared=no ;; + *) + enable_shared=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_shared=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac], + [enable_shared=]AC_ENABLE_SHARED_DEFAULT) +])# AC_ENABLE_SHARED + + +# AC_DISABLE_SHARED +# ----------------- +# set the default shared flag to --disable-shared +AC_DEFUN([AC_DISABLE_SHARED], +[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +AC_ENABLE_SHARED(no) +])# AC_DISABLE_SHARED + + +# AC_ENABLE_STATIC([DEFAULT]) +# --------------------------- +# implement the --enable-static flag +# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. +AC_DEFUN([AC_ENABLE_STATIC], +[define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl +AC_ARG_ENABLE([static], + [AC_HELP_STRING([--enable-static@<:@=PKGS@:>@], + [build static libraries @<:@default=]AC_ENABLE_STATIC_DEFAULT[@:>@])], + [p=${PACKAGE-default} + case $enableval in + yes) enable_static=yes ;; + no) enable_static=no ;; + *) + enable_static=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_static=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac], + [enable_static=]AC_ENABLE_STATIC_DEFAULT) +])# AC_ENABLE_STATIC + + +# AC_DISABLE_STATIC +# ----------------- +# set the default static flag to --disable-static +AC_DEFUN([AC_DISABLE_STATIC], +[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +AC_ENABLE_STATIC(no) +])# AC_DISABLE_STATIC + + +# AC_ENABLE_FAST_INSTALL([DEFAULT]) +# --------------------------------- +# implement the --enable-fast-install flag +# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. +AC_DEFUN([AC_ENABLE_FAST_INSTALL], +[define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl +AC_ARG_ENABLE([fast-install], + [AC_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@], + [optimize for fast installation @<:@default=]AC_ENABLE_FAST_INSTALL_DEFAULT[@:>@])], + [p=${PACKAGE-default} + case $enableval in + yes) enable_fast_install=yes ;; + no) enable_fast_install=no ;; + *) + enable_fast_install=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_fast_install=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac], + [enable_fast_install=]AC_ENABLE_FAST_INSTALL_DEFAULT) +])# AC_ENABLE_FAST_INSTALL + + +# AC_DISABLE_FAST_INSTALL +# ----------------------- +# set the default to --disable-fast-install +AC_DEFUN([AC_DISABLE_FAST_INSTALL], +[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +AC_ENABLE_FAST_INSTALL(no) +])# AC_DISABLE_FAST_INSTALL + + +# AC_LIBTOOL_PICMODE([MODE]) +# -------------------------- +# implement the --with-pic flag +# MODE is either `yes' or `no'. If omitted, it defaults to `both'. +AC_DEFUN([AC_LIBTOOL_PICMODE], +[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +pic_mode=ifelse($#,1,$1,default) +])# AC_LIBTOOL_PICMODE + + +# AC_PROG_EGREP +# ------------- +# This is predefined starting with Autoconf 2.54, so this conditional +# definition can be removed once we require Autoconf 2.54 or later. +m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP], +[AC_CACHE_CHECK([for egrep], [ac_cv_prog_egrep], + [if echo a | (grep -E '(a|b)') >/dev/null 2>&1 + then ac_cv_prog_egrep='grep -E' + else ac_cv_prog_egrep='egrep' + fi]) + EGREP=$ac_cv_prog_egrep + AC_SUBST([EGREP]) +])]) + + +# AC_PATH_TOOL_PREFIX +# ------------------- +# find a file program which can recognize shared library +AC_DEFUN([AC_PATH_TOOL_PREFIX], +[AC_REQUIRE([AC_PROG_EGREP])dnl +AC_MSG_CHECKING([for $1]) +AC_CACHE_VAL(lt_cv_path_MAGIC_CMD, +[case $MAGIC_CMD in +[[\\/*] | ?:[\\/]*]) + lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. + ;; +*) + lt_save_MAGIC_CMD="$MAGIC_CMD" + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR +dnl $ac_dummy forces splitting on constant user-supplied paths. +dnl POSIX.2 word splitting is done only on the output of word expansions, +dnl not every word. This closes a longstanding sh security hole. + ac_dummy="ifelse([$2], , $PATH, [$2])" + for ac_dir in $ac_dummy; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$1; then + lt_cv_path_MAGIC_CMD="$ac_dir/$1" + if test -n "$file_magic_test_file"; then + case $deplibs_check_method in + "file_magic "*) + file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` + MAGIC_CMD="$lt_cv_path_MAGIC_CMD" + if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | + $EGREP "$file_magic_regex" > /dev/null; then + : + else + cat <<EOF 1>&2 + +*** Warning: the command libtool uses to detect shared libraries, +*** $file_magic_cmd, produces output that libtool cannot recognize. +*** The result is that libtool may fail to recognize shared libraries +*** as such. This will affect the creation of libtool libraries that +*** depend on shared libraries, but programs linked with such libtool +*** libraries will work regardless of this problem. Nevertheless, you +*** may want to report the problem to your system manager and/or to +*** bug-libtool@gnu.org + +EOF + fi ;; + esac + fi + break + fi + done + IFS="$lt_save_ifs" + MAGIC_CMD="$lt_save_MAGIC_CMD" + ;; +esac]) +MAGIC_CMD="$lt_cv_path_MAGIC_CMD" +if test -n "$MAGIC_CMD"; then + AC_MSG_RESULT($MAGIC_CMD) +else + AC_MSG_RESULT(no) +fi +])# AC_PATH_TOOL_PREFIX + + +# AC_PATH_MAGIC +# ------------- +# find a file program which can recognize a shared library +AC_DEFUN([AC_PATH_MAGIC], +[AC_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH) +if test -z "$lt_cv_path_MAGIC_CMD"; then + if test -n "$ac_tool_prefix"; then + AC_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH) + else + MAGIC_CMD=: + fi +fi +])# AC_PATH_MAGIC + + +# AC_PROG_LD +# ---------- +# find the pathname to the GNU or non-GNU linker +AC_DEFUN([AC_PROG_LD], +[AC_ARG_WITH([gnu-ld], + [AC_HELP_STRING([--with-gnu-ld], + [assume the C compiler uses GNU ld @<:@default=no@:>@])], + [test "$withval" = no || with_gnu_ld=yes], + [with_gnu_ld=no]) +AC_REQUIRE([LT_AC_PROG_SED])dnl +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +ac_prog=ld +if test "$GCC" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + AC_MSG_CHECKING([for ld used by $CC]) + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return which upsets mingw + ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $ac_prog in + # Accept absolute paths. + [[\\/]]* | ?:[[\\/]]*) + re_direlt='/[[^/]][[^/]]*/\.\./' + # Canonicalize the pathname of ld + ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'` + while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do + ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test "$with_gnu_ld" = yes; then + AC_MSG_CHECKING([for GNU ld]) +else + AC_MSG_CHECKING([for non-GNU ld]) +fi +AC_CACHE_VAL(lt_cv_path_LD, +[if test -z "$LD"; then + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + lt_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some variants of GNU ld only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in + *GNU* | *'with BFD'*) + test "$with_gnu_ld" != no && break + ;; + *) + test "$with_gnu_ld" != yes && break + ;; + esac + fi + done + IFS="$lt_save_ifs" +else + lt_cv_path_LD="$LD" # Let the user override the test with a path. +fi]) +LD="$lt_cv_path_LD" +if test -n "$LD"; then + AC_MSG_RESULT($LD) +else + AC_MSG_RESULT(no) +fi +test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH]) +AC_PROG_LD_GNU +])# AC_PROG_LD + + +# AC_PROG_LD_GNU +# -------------- +AC_DEFUN([AC_PROG_LD_GNU], +[AC_REQUIRE([AC_PROG_EGREP])dnl +AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld, +[# I'd rather use --version here, but apparently some GNU lds only accept -v. +case `$LD -v 2>&1 </dev/null` in +*GNU* | *'with BFD'*) + lt_cv_prog_gnu_ld=yes + ;; +*) + lt_cv_prog_gnu_ld=no + ;; +esac]) +with_gnu_ld=$lt_cv_prog_gnu_ld +])# AC_PROG_LD_GNU + + +# AC_PROG_LD_RELOAD_FLAG +# ---------------------- +# find reload flag for linker +# -- PORTME Some linkers may need a different reload flag. +AC_DEFUN([AC_PROG_LD_RELOAD_FLAG], +[AC_CACHE_CHECK([for $LD option to reload object files], + lt_cv_ld_reload_flag, + [lt_cv_ld_reload_flag='-r']) +reload_flag=$lt_cv_ld_reload_flag +case $reload_flag in +"" | " "*) ;; +*) reload_flag=" $reload_flag" ;; +esac +reload_cmds='$LD$reload_flag -o $output$reload_objs' +case $host_os in + darwin*) + if test "$GCC" = yes; then + reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs' + else + reload_cmds='$LD$reload_flag -o $output$reload_objs' + fi + ;; +esac +])# AC_PROG_LD_RELOAD_FLAG + + +# AC_DEPLIBS_CHECK_METHOD +# ----------------------- +# how to check for library dependencies +# -- PORTME fill in with the dynamic library characteristics +AC_DEFUN([AC_DEPLIBS_CHECK_METHOD], +[AC_CACHE_CHECK([how to recognize dependent libraries], +lt_cv_deplibs_check_method, +[lt_cv_file_magic_cmd='$MAGIC_CMD' +lt_cv_file_magic_test_file= +lt_cv_deplibs_check_method='unknown' +# Need to set the preceding variable on all platforms that support +# interlibrary dependencies. +# 'none' -- dependencies not supported. +# `unknown' -- same as none, but documents that we really don't know. +# 'pass_all' -- all dependencies passed with no checks. +# 'test_compile' -- check by making test program. +# 'file_magic [[regex]]' -- check by looking for files in library path +# which responds to the $file_magic_cmd with a given extended regex. +# If you have `file' or equivalent on your system and you're not sure +# whether `pass_all' will *always* work, you probably want this one. + +case $host_os in +aix[[4-9]]*) + lt_cv_deplibs_check_method=pass_all + ;; + +beos*) + lt_cv_deplibs_check_method=pass_all + ;; + +bsdi[[45]]*) + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib)' + lt_cv_file_magic_cmd='/usr/bin/file -L' + lt_cv_file_magic_test_file=/shlib/libc.so + ;; + +cygwin*) + # func_win32_libid is a shell function defined in ltmain.sh + lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' + lt_cv_file_magic_cmd='func_win32_libid' + ;; + +mingw* | pw32*) + # Base MSYS/MinGW do not provide the 'file' command needed by + # func_win32_libid shell function, so use a weaker test based on 'objdump', + # unless we find 'file', for example because we are cross-compiling. + if ( file / ) >/dev/null 2>&1; then + lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' + lt_cv_file_magic_cmd='func_win32_libid' + else + lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?' + lt_cv_file_magic_cmd='$OBJDUMP -f' + fi + ;; + +darwin* | rhapsody*) + lt_cv_deplibs_check_method=pass_all + ;; + +freebsd* | dragonfly*) + if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then + case $host_cpu in + i*86 ) + # Not sure whether the presence of OpenBSD here was a mistake. + # Let's accept both of them until this is cleared up. + lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` + ;; + esac + else + lt_cv_deplibs_check_method=pass_all + fi + ;; + +gnu*) + lt_cv_deplibs_check_method=pass_all + ;; + +hpux10.20* | hpux11*) + lt_cv_file_magic_cmd=/usr/bin/file + case $host_cpu in + ia64*) + lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64' + lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so + ;; + hppa*64*) + [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]'] + lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl + ;; + *) + lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]].[[0-9]]) shared library' + lt_cv_file_magic_test_file=/usr/lib/libc.sl + ;; + esac + ;; + +interix[[3-9]]*) + # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$' + ;; + +irix5* | irix6* | nonstopux*) + case $LD in + *-32|*"-32 ") libmagic=32-bit;; + *-n32|*"-n32 ") libmagic=N32;; + *-64|*"-64 ") libmagic=64-bit;; + *) libmagic=never-match;; + esac + lt_cv_deplibs_check_method=pass_all + ;; + +# This must be Linux ELF. +linux* | k*bsd*-gnu) + lt_cv_deplibs_check_method=pass_all + ;; + +netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' + else + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$' + fi + ;; + +newos6*) + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=/usr/lib/libnls.so + ;; + +nto-qnx*) + lt_cv_deplibs_check_method=unknown + ;; + +openbsd*) + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$' + else + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' + fi + ;; + +osf3* | osf4* | osf5*) + lt_cv_deplibs_check_method=pass_all + ;; + +rdos*) + lt_cv_deplibs_check_method=pass_all + ;; + +solaris*) + lt_cv_deplibs_check_method=pass_all + ;; + +sysv4 | sysv4.3*) + case $host_vendor in + motorola) + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]' + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` + ;; + ncr) + lt_cv_deplibs_check_method=pass_all + ;; + sequent) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' + ;; + sni) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib" + lt_cv_file_magic_test_file=/lib/libc.so + ;; + siemens) + lt_cv_deplibs_check_method=pass_all + ;; + pc) + lt_cv_deplibs_check_method=pass_all + ;; + esac + ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + lt_cv_deplibs_check_method=pass_all + ;; +esac +]) +file_magic_cmd=$lt_cv_file_magic_cmd +deplibs_check_method=$lt_cv_deplibs_check_method +test -z "$deplibs_check_method" && deplibs_check_method=unknown +])# AC_DEPLIBS_CHECK_METHOD + + +# AC_PROG_NM +# ---------- +# find the pathname to a BSD-compatible name lister +AC_DEFUN([AC_PROG_NM], +[AC_CACHE_CHECK([for BSD-compatible nm], lt_cv_path_NM, +[if test -n "$NM"; then + # Let the user override the test. + lt_cv_path_NM="$NM" +else + lt_nm_to_check="${ac_tool_prefix}nm" + if test -n "$ac_tool_prefix" && test "$build" = "$host"; then + lt_nm_to_check="$lt_nm_to_check nm" + fi + for lt_tmp_nm in $lt_nm_to_check; do + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + tmp_nm="$ac_dir/$lt_tmp_nm" + if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then + # Check to see if the nm accepts a BSD-compat flag. + # Adding the `sed 1q' prevents false positives on HP-UX, which says: + # nm: unknown option "B" ignored + # Tru64's nm complains that /dev/null is an invalid object file + case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in + */dev/null* | *'Invalid file or object type'*) + lt_cv_path_NM="$tmp_nm -B" + break + ;; + *) + case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in + */dev/null*) + lt_cv_path_NM="$tmp_nm -p" + break + ;; + *) + lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but + continue # so that we can try to find one that supports BSD flags + ;; + esac + ;; + esac + fi + done + IFS="$lt_save_ifs" + done + test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm +fi]) +NM="$lt_cv_path_NM" +])# AC_PROG_NM + + +# AC_CHECK_LIBM +# ------------- +# check for math library +AC_DEFUN([AC_CHECK_LIBM], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +LIBM= +case $host in +*-*-beos* | *-*-cygwin* | *-*-pw32* | *-*-darwin*) + # These system don't have libm, or don't need it + ;; +*-ncr-sysv4.3*) + AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw") + AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm") + ;; +*) + AC_CHECK_LIB(m, cos, LIBM="-lm") + ;; +esac +])# AC_CHECK_LIBM + + +# AC_LIBLTDL_CONVENIENCE([DIRECTORY]) +# ----------------------------------- +# sets LIBLTDL to the link flags for the libltdl convenience library and +# LTDLINCL to the include flags for the libltdl header and adds +# --enable-ltdl-convenience to the configure arguments. Note that +# AC_CONFIG_SUBDIRS is not called here. If DIRECTORY is not provided, +# it is assumed to be `libltdl'. LIBLTDL will be prefixed with +# '${top_builddir}/' and LTDLINCL will be prefixed with '${top_srcdir}/' +# (note the single quotes!). If your package is not flat and you're not +# using automake, define top_builddir and top_srcdir appropriately in +# the Makefiles. +AC_DEFUN([AC_LIBLTDL_CONVENIENCE], +[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl + case $enable_ltdl_convenience in + no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;; + "") enable_ltdl_convenience=yes + ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;; + esac + LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdlc.la + LTDLINCL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl']) + # For backwards non-gettext consistent compatibility... + INCLTDL="$LTDLINCL" +])# AC_LIBLTDL_CONVENIENCE + + +# AC_LIBLTDL_INSTALLABLE([DIRECTORY]) +# ----------------------------------- +# sets LIBLTDL to the link flags for the libltdl installable library and +# LTDLINCL to the include flags for the libltdl header and adds +# --enable-ltdl-install to the configure arguments. Note that +# AC_CONFIG_SUBDIRS is not called here. If DIRECTORY is not provided, +# and an installed libltdl is not found, it is assumed to be `libltdl'. +# LIBLTDL will be prefixed with '${top_builddir}/'# and LTDLINCL with +# '${top_srcdir}/' (note the single quotes!). If your package is not +# flat and you're not using automake, define top_builddir and top_srcdir +# appropriately in the Makefiles. +# In the future, this macro may have to be called after AC_PROG_LIBTOOL. +AC_DEFUN([AC_LIBLTDL_INSTALLABLE], +[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl + AC_CHECK_LIB(ltdl, lt_dlinit, + [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no], + [if test x"$enable_ltdl_install" = xno; then + AC_MSG_WARN([libltdl not installed, but installation disabled]) + else + enable_ltdl_install=yes + fi + ]) + if test x"$enable_ltdl_install" = x"yes"; then + ac_configure_args="$ac_configure_args --enable-ltdl-install" + LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdl.la + LTDLINCL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl']) + else + ac_configure_args="$ac_configure_args --enable-ltdl-install=no" + LIBLTDL="-lltdl" + LTDLINCL= + fi + # For backwards non-gettext consistent compatibility... + INCLTDL="$LTDLINCL" +])# AC_LIBLTDL_INSTALLABLE + + +# AC_LIBTOOL_CXX +# -------------- +# enable support for C++ libraries +AC_DEFUN([AC_LIBTOOL_CXX], +[AC_REQUIRE([_LT_AC_LANG_CXX]) +])# AC_LIBTOOL_CXX + + +# _LT_AC_LANG_CXX +# --------------- +AC_DEFUN([_LT_AC_LANG_CXX], +[AC_REQUIRE([AC_PROG_CXX]) +AC_REQUIRE([_LT_AC_PROG_CXXCPP]) +_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}CXX]) +])# _LT_AC_LANG_CXX + +# _LT_AC_PROG_CXXCPP +# ------------------ +AC_DEFUN([_LT_AC_PROG_CXXCPP], +[ +AC_REQUIRE([AC_PROG_CXX]) +if test -n "$CXX" && ( test "X$CXX" != "Xno" && + ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || + (test "X$CXX" != "Xg++"))) ; then + AC_PROG_CXXCPP +fi +])# _LT_AC_PROG_CXXCPP + +# AC_LIBTOOL_F77 +# -------------- +# enable support for Fortran 77 libraries +AC_DEFUN([AC_LIBTOOL_F77], +[AC_REQUIRE([_LT_AC_LANG_F77]) +])# AC_LIBTOOL_F77 + + +# _LT_AC_LANG_F77 +# --------------- +AC_DEFUN([_LT_AC_LANG_F77], +[AC_REQUIRE([AC_PROG_F77]) +_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}F77]) +])# _LT_AC_LANG_F77 + + +# AC_LIBTOOL_GCJ +# -------------- +# enable support for GCJ libraries +AC_DEFUN([AC_LIBTOOL_GCJ], +[AC_REQUIRE([_LT_AC_LANG_GCJ]) +])# AC_LIBTOOL_GCJ + + +# _LT_AC_LANG_GCJ +# --------------- +AC_DEFUN([_LT_AC_LANG_GCJ], +[AC_PROVIDE_IFELSE([AC_PROG_GCJ],[], + [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],[], + [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ],[], + [ifdef([AC_PROG_GCJ],[AC_REQUIRE([AC_PROG_GCJ])], + [ifdef([A][M_PROG_GCJ],[AC_REQUIRE([A][M_PROG_GCJ])], + [AC_REQUIRE([A][C_PROG_GCJ_OR_A][M_PROG_GCJ])])])])])]) +_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}GCJ]) +])# _LT_AC_LANG_GCJ + + +# AC_LIBTOOL_RC +# ------------- +# enable support for Windows resource files +AC_DEFUN([AC_LIBTOOL_RC], +[AC_REQUIRE([LT_AC_PROG_RC]) +_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}RC]) +])# AC_LIBTOOL_RC + + +# AC_LIBTOOL_LANG_C_CONFIG +# ------------------------ +# Ensure that the configuration vars for the C compiler are +# suitably defined. Those variables are subsequently used by +# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'. +AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG], [_LT_AC_LANG_C_CONFIG]) +AC_DEFUN([_LT_AC_LANG_C_CONFIG], +[lt_save_CC="$CC" +AC_LANG_PUSH(C) + +# Source file extension for C test sources. +ac_ext=c + +# Object file extension for compiled C test sources. +objext=o +_LT_AC_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="int some_variable = 0;" + +# Code to be used in simple link tests +lt_simple_link_test_code='int main(){return(0);}' + +_LT_AC_SYS_COMPILER + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +AC_LIBTOOL_PROG_COMPILER_NO_RTTI($1) +AC_LIBTOOL_PROG_COMPILER_PIC($1) +AC_LIBTOOL_PROG_CC_C_O($1) +AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1) +AC_LIBTOOL_PROG_LD_SHLIBS($1) +AC_LIBTOOL_SYS_DYNAMIC_LINKER($1) +AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1) +AC_LIBTOOL_SYS_LIB_STRIP +AC_LIBTOOL_DLOPEN_SELF + +# Report which library types will actually be built +AC_MSG_CHECKING([if libtool supports shared libraries]) +AC_MSG_RESULT([$can_build_shared]) + +AC_MSG_CHECKING([whether to build shared libraries]) +test "$can_build_shared" = "no" && enable_shared=no + +# On AIX, shared libraries and static libraries use the same namespace, and +# are all built from PIC. +case $host_os in +aix3*) + test "$enable_shared" = yes && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + +aix[[4-9]]*) + if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then + test "$enable_shared" = yes && enable_static=no + fi + ;; +esac +AC_MSG_RESULT([$enable_shared]) + +AC_MSG_CHECKING([whether to build static libraries]) +# Make sure either enable_shared or enable_static is yes. +test "$enable_shared" = yes || enable_static=yes +AC_MSG_RESULT([$enable_static]) + +AC_LIBTOOL_CONFIG($1) + +AC_LANG_POP +CC="$lt_save_CC" +])# AC_LIBTOOL_LANG_C_CONFIG + + +# AC_LIBTOOL_LANG_CXX_CONFIG +# -------------------------- +# Ensure that the configuration vars for the C compiler are +# suitably defined. Those variables are subsequently used by +# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'. +AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG], [_LT_AC_LANG_CXX_CONFIG(CXX)]) +AC_DEFUN([_LT_AC_LANG_CXX_CONFIG], +[AC_LANG_PUSH(C++) +AC_REQUIRE([AC_PROG_CXX]) +AC_REQUIRE([_LT_AC_PROG_CXXCPP]) + +_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no +_LT_AC_TAGVAR(allow_undefined_flag, $1)= +_LT_AC_TAGVAR(always_export_symbols, $1)=no +_LT_AC_TAGVAR(archive_expsym_cmds, $1)= +_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)= +_LT_AC_TAGVAR(hardcode_direct, $1)=no +_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)= +_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= +_LT_AC_TAGVAR(hardcode_libdir_separator, $1)= +_LT_AC_TAGVAR(hardcode_minus_L, $1)=no +_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported +_LT_AC_TAGVAR(hardcode_automatic, $1)=no +_LT_AC_TAGVAR(module_cmds, $1)= +_LT_AC_TAGVAR(module_expsym_cmds, $1)= +_LT_AC_TAGVAR(link_all_deplibs, $1)=unknown +_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_AC_TAGVAR(no_undefined_flag, $1)= +_LT_AC_TAGVAR(whole_archive_flag_spec, $1)= +_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no + +# Dependencies to place before and after the object being linked: +_LT_AC_TAGVAR(predep_objects, $1)= +_LT_AC_TAGVAR(postdep_objects, $1)= +_LT_AC_TAGVAR(predeps, $1)= +_LT_AC_TAGVAR(postdeps, $1)= +_LT_AC_TAGVAR(compiler_lib_search_path, $1)= +_LT_AC_TAGVAR(compiler_lib_search_dirs, $1)= + +# Source file extension for C++ test sources. +ac_ext=cpp + +# Object file extension for compiled C++ test sources. +objext=o +_LT_AC_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="int some_variable = 0;" + +# Code to be used in simple link tests +lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }' + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. +_LT_AC_SYS_COMPILER + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +# Allow CC to be a program name with arguments. +lt_save_CC=$CC +lt_save_LD=$LD +lt_save_GCC=$GCC +GCC=$GXX +lt_save_with_gnu_ld=$with_gnu_ld +lt_save_path_LD=$lt_cv_path_LD +if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then + lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx +else + $as_unset lt_cv_prog_gnu_ld +fi +if test -n "${lt_cv_path_LDCXX+set}"; then + lt_cv_path_LD=$lt_cv_path_LDCXX +else + $as_unset lt_cv_path_LD +fi +test -z "${LDCXX+set}" || LD=$LDCXX +CC=${CXX-"c++"} +compiler=$CC +_LT_AC_TAGVAR(compiler, $1)=$CC +_LT_CC_BASENAME([$compiler]) + +# We don't want -fno-exception wen compiling C++ code, so set the +# no_builtin_flag separately +if test "$GXX" = yes; then + _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' +else + _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= +fi + +if test "$GXX" = yes; then + # Set up default GNU C++ configuration + + AC_PROG_LD + + # Check if GNU C++ uses GNU ld as the underlying linker, since the + # archiving commands below assume that GNU ld is being used. + if test "$with_gnu_ld" = yes; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + + # If archive_cmds runs LD, not CC, wlarc should be empty + # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to + # investigate it a little bit more. (MM) + wlarc='${wl}' + + # ancient GNU ld didn't support --whole-archive et. al. + if eval "`$CC -print-prog-name=ld` --help 2>&1" | \ + grep 'no-whole-archive' > /dev/null; then + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)= + fi + else + with_gnu_ld=no + wlarc= + + # A generic and very simple default shared library creation + # command for GNU C++ for the case where it uses the native + # linker, instead of GNU ld. If possible, this setting should + # overridden to take advantage of the native linker features on + # the platform it is being used on. + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' + fi + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"' + +else + GXX=no + with_gnu_ld=no + wlarc= +fi + +# PORTME: fill in a description of your system's C++ link characteristics +AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) +_LT_AC_TAGVAR(ld_shlibs, $1)=yes +case $host_os in + aix3*) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + aix[[4-9]]*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag="" + else + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) + for ld_flag in $LDFLAGS; do + case $ld_flag in + *-brtl*) + aix_use_runtimelinking=yes + break + ;; + esac + done + ;; + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + _LT_AC_TAGVAR(archive_cmds, $1)='' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + + if test "$GXX" = yes; then + case $host_os in aix4.[[012]]|aix4.[[012]].*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && \ + strings "$collect2name" | grep resolve_lib_name >/dev/null + then + # We have reworked collect2 + : + else + # We have old collect2 + _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)= + fi + ;; + esac + shared_flag='-shared' + if test "$aix_use_runtimelinking" = yes; then + shared_flag="$shared_flag "'${wl}-G' + fi + else + # not using gcc + if test "$host_cpu" = ia64; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test "$aix_use_runtimelinking" = yes; then + shared_flag='${wl}-G' + else + shared_flag='${wl}-bM:SRE' + fi + fi + fi + + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to export. + _LT_AC_TAGVAR(always_export_symbols, $1)=yes + if test "$aix_use_runtimelinking" = yes; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + _LT_AC_TAGVAR(allow_undefined_flag, $1)='-berok' + # Determine the default libpath from the value encoded in an empty executable. + _LT_AC_SYS_LIBPATH_AIX + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" + + _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" + else + if test "$host_cpu" = ia64; then + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' + _LT_AC_TAGVAR(allow_undefined_flag, $1)="-z nodefs" + _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an empty executable. + _LT_AC_SYS_LIBPATH_AIX + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' + # Exported symbols can be pulled into shared objects from archives + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='$convenience' + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes + # This is similar to how AIX traditionally builds its shared libraries. + _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' + fi + fi + ;; + + beos*) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported + # Joseph Beckenbach <jrb3@best.com> says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + else + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + chorus*) + case $cc_basename in + *) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + cygwin* | mingw* | pw32*) + # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, + # as there is no search path for DLLs. + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_AC_TAGVAR(always_export_symbols, $1)=no + _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + + if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + # If the export-symbols file already is a .def file (1st line + # is EXPORTS), use it as is; otherwise, prepend... + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + else + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + darwin* | rhapsody*) + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_AC_TAGVAR(hardcode_direct, $1)=no + _LT_AC_TAGVAR(hardcode_automatic, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='' + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + _LT_AC_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined" + if test "$GXX" = yes ; then + output_verbose_link_cmd='echo' + _LT_AC_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" + _LT_AC_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" + _LT_AC_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" + _LT_AC_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" + if test "$lt_cv_apple_cc_single_mod" != "yes"; then + _LT_AC_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}" + _LT_AC_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}" + fi + else + case $cc_basename in + xlc*) + output_verbose_link_cmd='echo' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $xlcverstring' + _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' + # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $xlcverstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + ;; + *) + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + esac + fi + ;; + + dgux*) + case $cc_basename in + ec++*) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + ghcx*) + # Green Hills C++ Compiler + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + freebsd[[12]]*) + # C++ shared libraries reported to be fairly broken before switch to ELF + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + freebsd-elf*) + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no + ;; + freebsd* | dragonfly*) + # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF + # conventions + _LT_AC_TAGVAR(ld_shlibs, $1)=yes + ;; + gnu*) + ;; + hpux9*) + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, + # but as the default + # location of the library. + + case $cc_basename in + CC*) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + aCC*) + _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "[[-]]L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + ;; + *) + if test "$GXX" = yes; then + _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + else + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + hpux10*|hpux11*) + if test $with_gnu_ld = no; then + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + + case $host_cpu in + hppa*64*|ia64*) ;; + *) + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + ;; + esac + fi + case $host_cpu in + hppa*64*|ia64*) + _LT_AC_TAGVAR(hardcode_direct, $1)=no + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + *) + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, + # but as the default + # location of the library. + ;; + esac + + case $cc_basename in + CC*) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + aCC*) + case $host_cpu in + hppa*64*) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + ia64*) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + *) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + esac + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + ;; + *) + if test "$GXX" = yes; then + if test $with_gnu_ld = no; then + case $host_cpu in + hppa*64*) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + ia64*) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + *) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + esac + fi + else + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + interix[[3-9]]*) + _LT_AC_TAGVAR(hardcode_direct, $1)=no + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. + # Instead, shared libraries are loaded at an image base (0x10000000 by + # default) and relocated if they conflict, which is a slow very memory + # consuming and fragmenting process. To avoid this, we pick a random, + # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link + # time. Moving up from 0x10000000 also allows more sbrk(2) space. + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + ;; + irix5* | irix6*) + case $cc_basename in + CC*) + # SGI C++ + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + + # Archives containing C++ object files must be created using + # "CC -ar", where "CC" is the IRIX C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs' + ;; + *) + if test "$GXX" = yes; then + if test "$with_gnu_ld" = no; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` -o $lib' + fi + fi + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + ;; + esac + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + ;; + linux* | k*bsd*-gnu) + case $cc_basename in + KCC*) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | grep "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath,$libdir' + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + + # Archives containing C++ object files must be created using + # "CC -Bstatic", where "CC" is the KAI C++ compiler. + _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' + ;; + icpc*) + # Intel C++ + with_gnu_ld=yes + # version 8.0 and above of icpc choke on multiply defined symbols + # if we add $predep_objects and $postdep_objects, however 7.1 and + # earlier do not add the objects themselves. + case `$CC -V 2>&1` in + *"Version 7."*) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + ;; + *) # Version 8.0 or newer + tmp_idyn= + case $host_cpu in + ia64*) tmp_idyn=' -i_dynamic';; + esac + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + ;; + esac + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' + ;; + pgCC* | pgcpp*) + # Portland Group C++ compiler + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' + ;; + cxx*) + # Compaq C++ + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' + + runpath_var=LD_RUN_PATH + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + # Sun C++ 5.9 + _LT_AC_TAGVAR(no_undefined_flag, $1)=' -zdefs' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' + + # Not sure whether something based on + # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 + # would be better. + output_verbose_link_cmd='echo' + + # Archives containing C++ object files must be created using + # "CC -xar", where "CC" is the Sun C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' + ;; + esac + ;; + esac + ;; + lynxos*) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + m88k*) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + mvs*) + case $cc_basename in + cxx*) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' + wlarc= + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + fi + # Workaround some broken pre-1.5 toolchains + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' + ;; + openbsd2*) + # C++ shared libraries are fairly broken + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + openbsd*) + if test -f /usr/libexec/ld.so; then + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib' + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + fi + output_verbose_link_cmd='echo' + else + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + osf3*) + case $cc_basename in + KCC*) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + + # Archives containing C++ object files must be created using + # "CC -Bstatic", where "CC" is the KAI C++ compiler. + _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' + + ;; + RCC*) + # Rational C++ 2.4.1 + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + cxx*) + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + ;; + *) + if test "$GXX" = yes && test "$with_gnu_ld" = no; then + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"' + + else + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + osf4* | osf5*) + case $cc_basename in + KCC*) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + + # Archives containing C++ object files must be created using + # the KAI C++ compiler. + _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' + ;; + RCC*) + # Rational C++ 2.4.1 + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + cxx*) + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ + echo "-hidden">> $lib.exp~ + $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname -Wl,-input -Wl,$lib.exp `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~ + $rm $lib.exp' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + ;; + *) + if test "$GXX" = yes && test "$with_gnu_ld" = no; then + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"' + + else + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + psos*) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + sunos4*) + case $cc_basename in + CC*) + # Sun C++ 4.x + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + lcc*) + # Lucid + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + solaris*) + case $cc_basename in + CC*) + # Sun C++ 4.2, 5.x and Centerline C++ + _LT_AC_TAGVAR(archive_cmds_need_lc,$1)=yes + _LT_AC_TAGVAR(no_undefined_flag, $1)=' -zdefs' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + case $host_os in + solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; + *) + # The compiler driver will combine and reorder linker options, + # but understands `-z linker_flag'. + # Supported since Solaris 2.6 (maybe 2.5.1?) + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' + ;; + esac + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + + output_verbose_link_cmd='echo' + + # Archives containing C++ object files must be created using + # "CC -xar", where "CC" is the Sun C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' + ;; + gcx*) + # Green Hills C++ Compiler + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + + # The C++ compiler must be used to create the archive. + _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs' + ;; + *) + # GNU C++ compiler with Solaris linker + if test "$GXX" = yes && test "$with_gnu_ld" = no; then + _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs' + if $CC --version | grep -v '^2\.7' > /dev/null; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd="$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\"" + else + # g++ 2.7 appears to require `-G' NOT `-shared' on this + # platform. + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd="$CC -G $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\"" + fi + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir' + case $host_os in + solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; + *) + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' + ;; + esac + fi + ;; + esac + ;; + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) + _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + runpath_var='LD_RUN_PATH' + + case $cc_basename in + CC*) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + ;; + sysv5* | sco3.2v5* | sco5v6*) + # Note: We can NOT use -z defs as we might desire, because we do not + # link with -lc, and that would cause any symbols used from libc to + # always be unresolved, which means just about no library would + # ever link correctly. If we're not using GNU ld we use -z text + # though, which does catch some bad symbols but isn't as heavy-handed + # as -z defs. + # For security reasons, it is highly recommended that you always + # use absolute paths for naming shared libraries, and exclude the + # DT_RUNPATH tag from executables and libraries. But doing so + # requires that you compile everything twice, which is a pain. + # So that behaviour is only enabled if SCOABSPATH is set to a + # non-empty value in the environment. Most likely only useful for + # creating official distributions of packages. + # This is a hack until libtool officially supports absolute path + # names for shared libraries. + _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' + _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' + runpath_var='LD_RUN_PATH' + + case $cc_basename in + CC*) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + ;; + tandem*) + case $cc_basename in + NCC*) + # NonStop-UX NCC 3.20 + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + vxworks*) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; +esac +AC_MSG_RESULT([$_LT_AC_TAGVAR(ld_shlibs, $1)]) +test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no + +_LT_AC_TAGVAR(GCC, $1)="$GXX" +_LT_AC_TAGVAR(LD, $1)="$LD" + +AC_LIBTOOL_POSTDEP_PREDEP($1) +AC_LIBTOOL_PROG_COMPILER_PIC($1) +AC_LIBTOOL_PROG_CC_C_O($1) +AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1) +AC_LIBTOOL_PROG_LD_SHLIBS($1) +AC_LIBTOOL_SYS_DYNAMIC_LINKER($1) +AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1) + +AC_LIBTOOL_CONFIG($1) + +AC_LANG_POP +CC=$lt_save_CC +LDCXX=$LD +LD=$lt_save_LD +GCC=$lt_save_GCC +with_gnu_ldcxx=$with_gnu_ld +with_gnu_ld=$lt_save_with_gnu_ld +lt_cv_path_LDCXX=$lt_cv_path_LD +lt_cv_path_LD=$lt_save_path_LD +lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld +lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld +])# AC_LIBTOOL_LANG_CXX_CONFIG + +# AC_LIBTOOL_POSTDEP_PREDEP([TAGNAME]) +# ------------------------------------ +# Figure out "hidden" library dependencies from verbose +# compiler output when linking a shared library. +# Parse the compiler output and extract the necessary +# objects, libraries and library flags. +AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP], +[AC_REQUIRE([LT_AC_PROG_SED])dnl +dnl we can't use the lt_simple_compile_test_code here, +dnl because it contains code intended for an executable, +dnl not a library. It's possible we should let each +dnl tag define a new lt_????_link_test_code variable, +dnl but it's only used here... +ifelse([$1],[],[cat > conftest.$ac_ext <<EOF +int a; +void foo (void) { a = 0; } +EOF +],[$1],[CXX],[cat > conftest.$ac_ext <<EOF +class Foo +{ +public: + Foo (void) { a = 0; } +private: + int a; +}; +EOF +],[$1],[F77],[cat > conftest.$ac_ext <<EOF + subroutine foo + implicit none + integer*4 a + a=0 + return + end +EOF +],[$1],[GCJ],[cat > conftest.$ac_ext <<EOF +public class foo { + private int a; + public void bar (void) { + a = 0; + } +}; +EOF +]) +dnl Parse the compiler output and extract the necessary +dnl objects, libraries and library flags. +if AC_TRY_EVAL(ac_compile); then + # Parse the compiler output and extract the necessary + # objects, libraries and library flags. + + # Sentinel used to keep track of whether or not we are before + # the conftest object file. + pre_test_object_deps_done=no + + # The `*' in the case matches for architectures that use `case' in + # $output_verbose_cmd can trigger glob expansion during the loop + # eval without this substitution. + output_verbose_link_cmd=`$echo "X$output_verbose_link_cmd" | $Xsed -e "$no_glob_subst"` + + for p in `eval $output_verbose_link_cmd`; do + case $p in + + -L* | -R* | -l*) + # Some compilers place space between "-{L,R}" and the path. + # Remove the space. + if test $p = "-L" \ + || test $p = "-R"; then + prev=$p + continue + else + prev= + fi + + if test "$pre_test_object_deps_done" = no; then + case $p in + -L* | -R*) + # Internal compiler library paths should come after those + # provided the user. The postdeps already come after the + # user supplied libs so there is no need to process them. + if test -z "$_LT_AC_TAGVAR(compiler_lib_search_path, $1)"; then + _LT_AC_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}" + else + _LT_AC_TAGVAR(compiler_lib_search_path, $1)="${_LT_AC_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}" + fi + ;; + # The "-l" case would never come before the object being + # linked, so don't bother handling this case. + esac + else + if test -z "$_LT_AC_TAGVAR(postdeps, $1)"; then + _LT_AC_TAGVAR(postdeps, $1)="${prev}${p}" + else + _LT_AC_TAGVAR(postdeps, $1)="${_LT_AC_TAGVAR(postdeps, $1)} ${prev}${p}" + fi + fi + ;; + + *.$objext) + # This assumes that the test object file only shows up + # once in the compiler output. + if test "$p" = "conftest.$objext"; then + pre_test_object_deps_done=yes + continue + fi + + if test "$pre_test_object_deps_done" = no; then + if test -z "$_LT_AC_TAGVAR(predep_objects, $1)"; then + _LT_AC_TAGVAR(predep_objects, $1)="$p" + else + _LT_AC_TAGVAR(predep_objects, $1)="$_LT_AC_TAGVAR(predep_objects, $1) $p" + fi + else + if test -z "$_LT_AC_TAGVAR(postdep_objects, $1)"; then + _LT_AC_TAGVAR(postdep_objects, $1)="$p" + else + _LT_AC_TAGVAR(postdep_objects, $1)="$_LT_AC_TAGVAR(postdep_objects, $1) $p" + fi + fi + ;; + + *) ;; # Ignore the rest. + + esac + done + + # Clean up. + rm -f a.out a.exe +else + echo "libtool.m4: error: problem compiling $1 test program" +fi + +$rm -f confest.$objext + +_LT_AC_TAGVAR(compiler_lib_search_dirs, $1)= +if test -n "$_LT_AC_TAGVAR(compiler_lib_search_path, $1)"; then + _LT_AC_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_AC_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'` +fi + +# PORTME: override above test on systems where it is broken +ifelse([$1],[CXX], +[case $host_os in +interix[[3-9]]*) + # Interix 3.5 installs completely hosed .la files for C++, so rather than + # hack all around it, let's just trust "g++" to DTRT. + _LT_AC_TAGVAR(predep_objects,$1)= + _LT_AC_TAGVAR(postdep_objects,$1)= + _LT_AC_TAGVAR(postdeps,$1)= + ;; + +linux*) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + # Sun C++ 5.9 + # + # The more standards-conforming stlport4 library is + # incompatible with the Cstd library. Avoid specifying + # it if it's in CXXFLAGS. Ignore libCrun as + # -library=stlport4 depends on it. + case " $CXX $CXXFLAGS " in + *" -library=stlport4 "*) + solaris_use_stlport4=yes + ;; + esac + if test "$solaris_use_stlport4" != yes; then + _LT_AC_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' + fi + ;; + esac + ;; + +solaris*) + case $cc_basename in + CC*) + # The more standards-conforming stlport4 library is + # incompatible with the Cstd library. Avoid specifying + # it if it's in CXXFLAGS. Ignore libCrun as + # -library=stlport4 depends on it. + case " $CXX $CXXFLAGS " in + *" -library=stlport4 "*) + solaris_use_stlport4=yes + ;; + esac + + # Adding this requires a known-good setup of shared libraries for + # Sun compiler versions before 5.6, else PIC objects from an old + # archive will be linked into the output, leading to subtle bugs. + if test "$solaris_use_stlport4" != yes; then + _LT_AC_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' + fi + ;; + esac + ;; +esac +]) +case " $_LT_AC_TAGVAR(postdeps, $1) " in +*" -lc "*) _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no ;; +esac +])# AC_LIBTOOL_POSTDEP_PREDEP + +# AC_LIBTOOL_LANG_F77_CONFIG +# -------------------------- +# Ensure that the configuration vars for the C compiler are +# suitably defined. Those variables are subsequently used by +# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'. +AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG], [_LT_AC_LANG_F77_CONFIG(F77)]) +AC_DEFUN([_LT_AC_LANG_F77_CONFIG], +[AC_REQUIRE([AC_PROG_F77]) +AC_LANG_PUSH(Fortran 77) + +_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no +_LT_AC_TAGVAR(allow_undefined_flag, $1)= +_LT_AC_TAGVAR(always_export_symbols, $1)=no +_LT_AC_TAGVAR(archive_expsym_cmds, $1)= +_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)= +_LT_AC_TAGVAR(hardcode_direct, $1)=no +_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)= +_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= +_LT_AC_TAGVAR(hardcode_libdir_separator, $1)= +_LT_AC_TAGVAR(hardcode_minus_L, $1)=no +_LT_AC_TAGVAR(hardcode_automatic, $1)=no +_LT_AC_TAGVAR(module_cmds, $1)= +_LT_AC_TAGVAR(module_expsym_cmds, $1)= +_LT_AC_TAGVAR(link_all_deplibs, $1)=unknown +_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_AC_TAGVAR(no_undefined_flag, $1)= +_LT_AC_TAGVAR(whole_archive_flag_spec, $1)= +_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no + +# Source file extension for f77 test sources. +ac_ext=f + +# Object file extension for compiled f77 test sources. +objext=o +_LT_AC_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="\ + subroutine t + return + end +" + +# Code to be used in simple link tests +lt_simple_link_test_code="\ + program t + end +" + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. +_LT_AC_SYS_COMPILER + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +# Allow CC to be a program name with arguments. +lt_save_CC="$CC" +CC=${F77-"f77"} +compiler=$CC +_LT_AC_TAGVAR(compiler, $1)=$CC +_LT_CC_BASENAME([$compiler]) + +AC_MSG_CHECKING([if libtool supports shared libraries]) +AC_MSG_RESULT([$can_build_shared]) + +AC_MSG_CHECKING([whether to build shared libraries]) +test "$can_build_shared" = "no" && enable_shared=no + +# On AIX, shared libraries and static libraries use the same namespace, and +# are all built from PIC. +case $host_os in +aix3*) + test "$enable_shared" = yes && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; +aix[[4-9]]*) + if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then + test "$enable_shared" = yes && enable_static=no + fi + ;; +esac +AC_MSG_RESULT([$enable_shared]) + +AC_MSG_CHECKING([whether to build static libraries]) +# Make sure either enable_shared or enable_static is yes. +test "$enable_shared" = yes || enable_static=yes +AC_MSG_RESULT([$enable_static]) + +_LT_AC_TAGVAR(GCC, $1)="$G77" +_LT_AC_TAGVAR(LD, $1)="$LD" + +AC_LIBTOOL_PROG_COMPILER_PIC($1) +AC_LIBTOOL_PROG_CC_C_O($1) +AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1) +AC_LIBTOOL_PROG_LD_SHLIBS($1) +AC_LIBTOOL_SYS_DYNAMIC_LINKER($1) +AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1) + +AC_LIBTOOL_CONFIG($1) + +AC_LANG_POP +CC="$lt_save_CC" +])# AC_LIBTOOL_LANG_F77_CONFIG + + +# AC_LIBTOOL_LANG_GCJ_CONFIG +# -------------------------- +# Ensure that the configuration vars for the C compiler are +# suitably defined. Those variables are subsequently used by +# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'. +AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG], [_LT_AC_LANG_GCJ_CONFIG(GCJ)]) +AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG], +[AC_LANG_SAVE + +# Source file extension for Java test sources. +ac_ext=java + +# Object file extension for compiled Java test sources. +objext=o +_LT_AC_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="class foo {}" + +# Code to be used in simple link tests +lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }' + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. +_LT_AC_SYS_COMPILER + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +# Allow CC to be a program name with arguments. +lt_save_CC="$CC" +CC=${GCJ-"gcj"} +compiler=$CC +_LT_AC_TAGVAR(compiler, $1)=$CC +_LT_CC_BASENAME([$compiler]) + +# GCJ did not exist at the time GCC didn't implicitly link libc in. +_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no + +_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds + +AC_LIBTOOL_PROG_COMPILER_NO_RTTI($1) +AC_LIBTOOL_PROG_COMPILER_PIC($1) +AC_LIBTOOL_PROG_CC_C_O($1) +AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1) +AC_LIBTOOL_PROG_LD_SHLIBS($1) +AC_LIBTOOL_SYS_DYNAMIC_LINKER($1) +AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1) + +AC_LIBTOOL_CONFIG($1) + +AC_LANG_RESTORE +CC="$lt_save_CC" +])# AC_LIBTOOL_LANG_GCJ_CONFIG + + +# AC_LIBTOOL_LANG_RC_CONFIG +# ------------------------- +# Ensure that the configuration vars for the Windows resource compiler are +# suitably defined. Those variables are subsequently used by +# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'. +AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG], [_LT_AC_LANG_RC_CONFIG(RC)]) +AC_DEFUN([_LT_AC_LANG_RC_CONFIG], +[AC_LANG_SAVE + +# Source file extension for RC test sources. +ac_ext=rc + +# Object file extension for compiled RC test sources. +objext=o +_LT_AC_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }' + +# Code to be used in simple link tests +lt_simple_link_test_code="$lt_simple_compile_test_code" + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. +_LT_AC_SYS_COMPILER + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +# Allow CC to be a program name with arguments. +lt_save_CC="$CC" +CC=${RC-"windres"} +compiler=$CC +_LT_AC_TAGVAR(compiler, $1)=$CC +_LT_CC_BASENAME([$compiler]) +_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes + +AC_LIBTOOL_CONFIG($1) + +AC_LANG_RESTORE +CC="$lt_save_CC" +])# AC_LIBTOOL_LANG_RC_CONFIG + + +# AC_LIBTOOL_CONFIG([TAGNAME]) +# ---------------------------- +# If TAGNAME is not passed, then create an initial libtool script +# with a default configuration from the untagged config vars. Otherwise +# add code to config.status for appending the configuration named by +# TAGNAME from the matching tagged config vars. +AC_DEFUN([AC_LIBTOOL_CONFIG], +[# The else clause should only fire when bootstrapping the +# libtool distribution, otherwise you forgot to ship ltmain.sh +# with your package, and you will get complaints that there are +# no rules to generate ltmain.sh. +if test -f "$ltmain"; then + # See if we are running on zsh, and set the options which allow our commands through + # without removal of \ escapes. + if test -n "${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST + fi + # Now quote all the things that may contain metacharacters while being + # careful not to overquote the AC_SUBSTed values. We take copies of the + # variables and quote the copies for generation of the libtool script. + for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \ + SED SHELL STRIP \ + libname_spec library_names_spec soname_spec extract_expsyms_cmds \ + old_striplib striplib file_magic_cmd finish_cmds finish_eval \ + deplibs_check_method reload_flag reload_cmds need_locks \ + lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \ + lt_cv_sys_global_symbol_to_c_name_address \ + sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ + old_postinstall_cmds old_postuninstall_cmds \ + _LT_AC_TAGVAR(compiler, $1) \ + _LT_AC_TAGVAR(CC, $1) \ + _LT_AC_TAGVAR(LD, $1) \ + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1) \ + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1) \ + _LT_AC_TAGVAR(lt_prog_compiler_static, $1) \ + _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) \ + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1) \ + _LT_AC_TAGVAR(thread_safe_flag_spec, $1) \ + _LT_AC_TAGVAR(whole_archive_flag_spec, $1) \ + _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1) \ + _LT_AC_TAGVAR(old_archive_cmds, $1) \ + _LT_AC_TAGVAR(old_archive_from_new_cmds, $1) \ + _LT_AC_TAGVAR(predep_objects, $1) \ + _LT_AC_TAGVAR(postdep_objects, $1) \ + _LT_AC_TAGVAR(predeps, $1) \ + _LT_AC_TAGVAR(postdeps, $1) \ + _LT_AC_TAGVAR(compiler_lib_search_path, $1) \ + _LT_AC_TAGVAR(compiler_lib_search_dirs, $1) \ + _LT_AC_TAGVAR(archive_cmds, $1) \ + _LT_AC_TAGVAR(archive_expsym_cmds, $1) \ + _LT_AC_TAGVAR(postinstall_cmds, $1) \ + _LT_AC_TAGVAR(postuninstall_cmds, $1) \ + _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1) \ + _LT_AC_TAGVAR(allow_undefined_flag, $1) \ + _LT_AC_TAGVAR(no_undefined_flag, $1) \ + _LT_AC_TAGVAR(export_symbols_cmds, $1) \ + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) \ + _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1) \ + _LT_AC_TAGVAR(hardcode_libdir_separator, $1) \ + _LT_AC_TAGVAR(hardcode_automatic, $1) \ + _LT_AC_TAGVAR(module_cmds, $1) \ + _LT_AC_TAGVAR(module_expsym_cmds, $1) \ + _LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1) \ + _LT_AC_TAGVAR(fix_srcfile_path, $1) \ + _LT_AC_TAGVAR(exclude_expsyms, $1) \ + _LT_AC_TAGVAR(include_expsyms, $1); do + + case $var in + _LT_AC_TAGVAR(old_archive_cmds, $1) | \ + _LT_AC_TAGVAR(old_archive_from_new_cmds, $1) | \ + _LT_AC_TAGVAR(archive_cmds, $1) | \ + _LT_AC_TAGVAR(archive_expsym_cmds, $1) | \ + _LT_AC_TAGVAR(module_cmds, $1) | \ + _LT_AC_TAGVAR(module_expsym_cmds, $1) | \ + _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1) | \ + _LT_AC_TAGVAR(export_symbols_cmds, $1) | \ + extract_expsyms_cmds | reload_cmds | finish_cmds | \ + postinstall_cmds | postuninstall_cmds | \ + old_postinstall_cmds | old_postuninstall_cmds | \ + sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) + # Double-quote double-evaled strings. + eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" + ;; + *) + eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" + ;; + esac + done + + case $lt_echo in + *'\[$]0 --fallback-echo"') + lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\[$]0 --fallback-echo"[$]/[$]0 --fallback-echo"/'` + ;; + esac + +ifelse([$1], [], + [cfgfile="${ofile}T" + trap "$rm \"$cfgfile\"; exit 1" 1 2 15 + $rm -f "$cfgfile" + AC_MSG_NOTICE([creating $ofile])], + [cfgfile="$ofile"]) + + cat <<__EOF__ >> "$cfgfile" +ifelse([$1], [], +[#! $SHELL + +# `$echo "$cfgfile" | sed 's%^.*/%%'` - Provide generalized library-building support services. +# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP) +# NOTE: Changes made to this file will be lost: look at ltmain.sh. +# +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 +# Free Software Foundation, Inc. +# +# This file is part of GNU Libtool: +# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# A sed program that does not truncate output. +SED=$lt_SED + +# Sed that helps us avoid accidentally triggering echo(1) options like -n. +Xsed="$SED -e 1s/^X//" + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +# The names of the tagged configurations supported by this script. +available_tags= + +# ### BEGIN LIBTOOL CONFIG], +[# ### BEGIN LIBTOOL TAG CONFIG: $tagname]) + +# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: + +# Shell to use when invoking shell scripts. +SHELL=$lt_SHELL + +# Whether or not to build shared libraries. +build_libtool_libs=$enable_shared + +# Whether or not to build static libraries. +build_old_libs=$enable_static + +# Whether or not to add -lc for building shared libraries. +build_libtool_need_lc=$_LT_AC_TAGVAR(archive_cmds_need_lc, $1) + +# Whether or not to disallow shared libs when runtime libs are static +allow_libtool_libs_with_static_runtimes=$_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1) + +# Whether or not to optimize for fast installation. +fast_install=$enable_fast_install + +# The host system. +host_alias=$host_alias +host=$host +host_os=$host_os + +# The build system. +build_alias=$build_alias +build=$build +build_os=$build_os + +# An echo program that does not interpret backslashes. +echo=$lt_echo + +# The archiver. +AR=$lt_AR +AR_FLAGS=$lt_AR_FLAGS + +# A C compiler. +LTCC=$lt_LTCC + +# LTCC compiler flags. +LTCFLAGS=$lt_LTCFLAGS + +# A language-specific compiler. +CC=$lt_[]_LT_AC_TAGVAR(compiler, $1) + +# Is the compiler the GNU C compiler? +with_gcc=$_LT_AC_TAGVAR(GCC, $1) + +# An ERE matcher. +EGREP=$lt_EGREP + +# The linker used to build libraries. +LD=$lt_[]_LT_AC_TAGVAR(LD, $1) + +# Whether we need hard or soft links. +LN_S=$lt_LN_S + +# A BSD-compatible nm program. +NM=$lt_NM + +# A symbol stripping program +STRIP=$lt_STRIP + +# Used to examine libraries when file_magic_cmd begins "file" +MAGIC_CMD=$MAGIC_CMD + +# Used on cygwin: DLL creation program. +DLLTOOL="$DLLTOOL" + +# Used on cygwin: object dumper. +OBJDUMP="$OBJDUMP" + +# Used on cygwin: assembler. +AS="$AS" + +# The name of the directory that contains temporary libtool files. +objdir=$objdir + +# How to create reloadable object files. +reload_flag=$lt_reload_flag +reload_cmds=$lt_reload_cmds + +# How to pass a linker flag through the compiler. +wl=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_wl, $1) + +# Object file suffix (normally "o"). +objext="$ac_objext" + +# Old archive suffix (normally "a"). +libext="$libext" + +# Shared library suffix (normally ".so"). +shrext_cmds='$shrext_cmds' + +# Executable file suffix (normally ""). +exeext="$exeext" + +# Additional compiler flags for building library objects. +pic_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) +pic_mode=$pic_mode + +# What is the maximum length of a command? +max_cmd_len=$lt_cv_sys_max_cmd_len + +# Does compiler simultaneously support -c and -o options? +compiler_c_o=$lt_[]_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1) + +# Must we lock files when doing compilation? +need_locks=$lt_need_locks + +# Do we need the lib prefix for modules? +need_lib_prefix=$need_lib_prefix + +# Do we need a version for libraries? +need_version=$need_version + +# Whether dlopen is supported. +dlopen_support=$enable_dlopen + +# Whether dlopen of programs is supported. +dlopen_self=$enable_dlopen_self + +# Whether dlopen of statically linked programs is supported. +dlopen_self_static=$enable_dlopen_self_static + +# Compiler flag to prevent dynamic linking. +link_static_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_static, $1) + +# Compiler flag to turn off builtin functions. +no_builtin_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) + +# Compiler flag to allow reflexive dlopens. +export_dynamic_flag_spec=$lt_[]_LT_AC_TAGVAR(export_dynamic_flag_spec, $1) + +# Compiler flag to generate shared objects directly from archives. +whole_archive_flag_spec=$lt_[]_LT_AC_TAGVAR(whole_archive_flag_spec, $1) + +# Compiler flag to generate thread-safe objects. +thread_safe_flag_spec=$lt_[]_LT_AC_TAGVAR(thread_safe_flag_spec, $1) + +# Library versioning type. +version_type=$version_type + +# Format of library name prefix. +libname_spec=$lt_libname_spec + +# List of archive names. First name is the real one, the rest are links. +# The last name is the one that the linker finds with -lNAME. +library_names_spec=$lt_library_names_spec + +# The coded name of the library, if different from the real name. +soname_spec=$lt_soname_spec + +# Commands used to build and install an old-style archive. +RANLIB=$lt_RANLIB +old_archive_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_cmds, $1) +old_postinstall_cmds=$lt_old_postinstall_cmds +old_postuninstall_cmds=$lt_old_postuninstall_cmds + +# Create an old-style archive from a shared archive. +old_archive_from_new_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_from_new_cmds, $1) + +# Create a temporary old-style archive to link instead of a shared archive. +old_archive_from_expsyms_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1) + +# Commands used to build and install a shared archive. +archive_cmds=$lt_[]_LT_AC_TAGVAR(archive_cmds, $1) +archive_expsym_cmds=$lt_[]_LT_AC_TAGVAR(archive_expsym_cmds, $1) +postinstall_cmds=$lt_postinstall_cmds +postuninstall_cmds=$lt_postuninstall_cmds + +# Commands used to build a loadable module (assumed same as above if empty) +module_cmds=$lt_[]_LT_AC_TAGVAR(module_cmds, $1) +module_expsym_cmds=$lt_[]_LT_AC_TAGVAR(module_expsym_cmds, $1) + +# Commands to strip libraries. +old_striplib=$lt_old_striplib +striplib=$lt_striplib + +# Dependencies to place before the objects being linked to create a +# shared library. +predep_objects=$lt_[]_LT_AC_TAGVAR(predep_objects, $1) + +# Dependencies to place after the objects being linked to create a +# shared library. +postdep_objects=$lt_[]_LT_AC_TAGVAR(postdep_objects, $1) + +# Dependencies to place before the objects being linked to create a +# shared library. +predeps=$lt_[]_LT_AC_TAGVAR(predeps, $1) + +# Dependencies to place after the objects being linked to create a +# shared library. +postdeps=$lt_[]_LT_AC_TAGVAR(postdeps, $1) + +# The directories searched by this compiler when creating a shared +# library +compiler_lib_search_dirs=$lt_[]_LT_AC_TAGVAR(compiler_lib_search_dirs, $1) + +# The library search path used internally by the compiler when linking +# a shared library. +compiler_lib_search_path=$lt_[]_LT_AC_TAGVAR(compiler_lib_search_path, $1) + +# Method to check whether dependent libraries are shared objects. +deplibs_check_method=$lt_deplibs_check_method + +# Command to use when deplibs_check_method == file_magic. +file_magic_cmd=$lt_file_magic_cmd + +# Flag that allows shared libraries with undefined symbols to be built. +allow_undefined_flag=$lt_[]_LT_AC_TAGVAR(allow_undefined_flag, $1) + +# Flag that forces no undefined symbols. +no_undefined_flag=$lt_[]_LT_AC_TAGVAR(no_undefined_flag, $1) + +# Commands used to finish a libtool library installation in a directory. +finish_cmds=$lt_finish_cmds + +# Same as above, but a single script fragment to be evaled but not shown. +finish_eval=$lt_finish_eval + +# Take the output of nm and produce a listing of raw symbols and C names. +global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe + +# Transform the output of nm in a proper C declaration +global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl + +# Transform the output of nm in a C name address pair +global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address + +# This is the shared library runtime path variable. +runpath_var=$runpath_var + +# This is the shared library path variable. +shlibpath_var=$shlibpath_var + +# Is shlibpath searched before the hard-coded library search path? +shlibpath_overrides_runpath=$shlibpath_overrides_runpath + +# How to hardcode a shared library path into an executable. +hardcode_action=$_LT_AC_TAGVAR(hardcode_action, $1) + +# Whether we should hardcode library paths into libraries. +hardcode_into_libs=$hardcode_into_libs + +# Flag to hardcode \$libdir into a binary during linking. +# This must work even if \$libdir does not exist. +hardcode_libdir_flag_spec=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) + +# If ld is used when linking, flag to hardcode \$libdir into +# a binary during linking. This must work even if \$libdir does +# not exist. +hardcode_libdir_flag_spec_ld=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1) + +# Whether we need a single -rpath flag with a separated argument. +hardcode_libdir_separator=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_separator, $1) + +# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the +# resulting binary. +hardcode_direct=$_LT_AC_TAGVAR(hardcode_direct, $1) + +# Set to yes if using the -LDIR flag during linking hardcodes DIR into the +# resulting binary. +hardcode_minus_L=$_LT_AC_TAGVAR(hardcode_minus_L, $1) + +# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into +# the resulting binary. +hardcode_shlibpath_var=$_LT_AC_TAGVAR(hardcode_shlibpath_var, $1) + +# Set to yes if building a shared library automatically hardcodes DIR into the library +# and all subsequent libraries and executables linked against it. +hardcode_automatic=$_LT_AC_TAGVAR(hardcode_automatic, $1) + +# Variables whose values should be saved in libtool wrapper scripts and +# restored at relink time. +variables_saved_for_relink="$variables_saved_for_relink" + +# Whether libtool must link a program against all its dependency libraries. +link_all_deplibs=$_LT_AC_TAGVAR(link_all_deplibs, $1) + +# Compile-time system search path for libraries +sys_lib_search_path_spec=$lt_sys_lib_search_path_spec + +# Run-time system search path for libraries +sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec + +# Fix the shell variable \$srcfile for the compiler. +fix_srcfile_path=$lt_fix_srcfile_path + +# Set to yes if exported symbols are required. +always_export_symbols=$_LT_AC_TAGVAR(always_export_symbols, $1) + +# The commands to list exported symbols. +export_symbols_cmds=$lt_[]_LT_AC_TAGVAR(export_symbols_cmds, $1) + +# The commands to extract the exported symbol list from a shared archive. +extract_expsyms_cmds=$lt_extract_expsyms_cmds + +# Symbols that should not be listed in the preloaded symbols. +exclude_expsyms=$lt_[]_LT_AC_TAGVAR(exclude_expsyms, $1) + +# Symbols that must always be exported. +include_expsyms=$lt_[]_LT_AC_TAGVAR(include_expsyms, $1) + +ifelse([$1],[], +[# ### END LIBTOOL CONFIG], +[# ### END LIBTOOL TAG CONFIG: $tagname]) + +__EOF__ + +ifelse([$1],[], [ + case $host_os in + aix3*) + cat <<\EOF >> "$cfgfile" + +# AIX sometimes has problems with the GCC collect2 program. For some +# reason, if we set the COLLECT_NAMES environment variable, the problems +# vanish in a puff of smoke. +if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES +fi +EOF + ;; + esac + + # We use sed instead of cat because bash on DJGPP gets confused if + # if finds mixed CR/LF and LF-only lines. Since sed operates in + # text mode, it properly converts lines to CR/LF. This bash problem + # is reportedly fixed, but why not run on old versions too? + sed '$q' "$ltmain" >> "$cfgfile" || (rm -f "$cfgfile"; exit 1) + + mv -f "$cfgfile" "$ofile" || \ + (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") + chmod +x "$ofile" +]) +else + # If there is no Makefile yet, we rely on a make rule to execute + # `config.status --recheck' to rerun these tests and create the + # libtool script then. + ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'` + if test -f "$ltmain_in"; then + test -f Makefile && make "$ltmain" + fi +fi +])# AC_LIBTOOL_CONFIG + + +# AC_LIBTOOL_PROG_COMPILER_NO_RTTI([TAGNAME]) +# ------------------------------------------- +AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], +[AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl + +_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= + +if test "$GCC" = yes; then + _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' + + AC_LIBTOOL_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions], + lt_cv_prog_compiler_rtti_exceptions, + [-fno-rtti -fno-exceptions], [], + [_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"]) +fi +])# AC_LIBTOOL_PROG_COMPILER_NO_RTTI + + +# AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE +# --------------------------------- +AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], +[AC_REQUIRE([AC_CANONICAL_HOST]) +AC_REQUIRE([LT_AC_PROG_SED]) +AC_REQUIRE([AC_PROG_NM]) +AC_REQUIRE([AC_OBJEXT]) +# Check for command to grab the raw symbol name followed by C symbol from nm. +AC_MSG_CHECKING([command to parse $NM output from $compiler object]) +AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe], +[ +# These are sane defaults that work on at least a few old systems. +# [They come from Ultrix. What could be older than Ultrix?!! ;)] + +# Character class describing NM global symbol codes. +symcode='[[BCDEGRST]]' + +# Regexp to match symbols that can be accessed directly from C. +sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)' + +# Transform an extracted symbol line into a proper C declaration +lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern int \1;/p'" + +# Transform an extracted symbol line into symbol name and symbol address +lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" + +# Define system-specific variables. +case $host_os in +aix*) + symcode='[[BCDT]]' + ;; +cygwin* | mingw* | pw32*) + symcode='[[ABCDGISTW]]' + ;; +hpux*) # Its linker distinguishes data from code symbols + if test "$host_cpu" = ia64; then + symcode='[[ABCDEGRST]]' + fi + lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" + lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" + ;; +linux* | k*bsd*-gnu) + if test "$host_cpu" = ia64; then + symcode='[[ABCDGIRSTW]]' + lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" + lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" + fi + ;; +irix* | nonstopux*) + symcode='[[BCDEGRST]]' + ;; +osf*) + symcode='[[BCDEGQRST]]' + ;; +solaris*) + symcode='[[BDRT]]' + ;; +sco3.2v5*) + symcode='[[DT]]' + ;; +sysv4.2uw2*) + symcode='[[DT]]' + ;; +sysv5* | sco5v6* | unixware* | OpenUNIX*) + symcode='[[ABDT]]' + ;; +sysv4) + symcode='[[DFNSTU]]' + ;; +esac + +# Handle CRLF in mingw tool chain +opt_cr= +case $build_os in +mingw*) + opt_cr=`echo 'x\{0,1\}' | tr x '\015'` # option cr in regexp + ;; +esac + +# If we're using GNU nm, then use its standard symbol codes. +case `$NM -V 2>&1` in +*GNU* | *'with BFD'*) + symcode='[[ABCDGIRSTW]]' ;; +esac + +# Try without a prefix undercore, then with it. +for ac_symprfx in "" "_"; do + + # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. + symxfrm="\\1 $ac_symprfx\\2 \\2" + + # Write the raw and C identifiers. + lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" + + # Check to see that the pipe works correctly. + pipe_works=no + + rm -f conftest* + cat > conftest.$ac_ext <<EOF +#ifdef __cplusplus +extern "C" { +#endif +char nm_test_var; +void nm_test_func(){} +#ifdef __cplusplus +} +#endif +int main(){nm_test_var='a';nm_test_func();return(0);} +EOF + + if AC_TRY_EVAL(ac_compile); then + # Now try to grab the symbols. + nlist=conftest.nm + if AC_TRY_EVAL(NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) && test -s "$nlist"; then + # Try sorting and uniquifying the output. + if sort "$nlist" | uniq > "$nlist"T; then + mv -f "$nlist"T "$nlist" + else + rm -f "$nlist"T + fi + + # Make sure that we snagged all the symbols we need. + if grep ' nm_test_var$' "$nlist" >/dev/null; then + if grep ' nm_test_func$' "$nlist" >/dev/null; then + cat <<EOF > conftest.$ac_ext +#ifdef __cplusplus +extern "C" { +#endif + +EOF + # Now generate the symbol file. + eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | grep -v main >> conftest.$ac_ext' + + cat <<EOF >> conftest.$ac_ext +#if defined (__STDC__) && __STDC__ +# define lt_ptr_t void * +#else +# define lt_ptr_t char * +# define const +#endif + +/* The mapping between symbol names and symbols. */ +const struct { + const char *name; + lt_ptr_t address; +} +lt_preloaded_symbols[[]] = +{ +EOF + $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (lt_ptr_t) \&\2},/" < "$nlist" | grep -v main >> conftest.$ac_ext + cat <<\EOF >> conftest.$ac_ext + {0, (lt_ptr_t) 0} +}; + +#ifdef __cplusplus +} +#endif +EOF + # Now try linking the two files. + mv conftest.$ac_objext conftstm.$ac_objext + lt_save_LIBS="$LIBS" + lt_save_CFLAGS="$CFLAGS" + LIBS="conftstm.$ac_objext" + CFLAGS="$CFLAGS$_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)" + if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then + pipe_works=yes + fi + LIBS="$lt_save_LIBS" + CFLAGS="$lt_save_CFLAGS" + else + echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD + fi + else + echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD + fi + else + echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD + fi + else + echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD + cat conftest.$ac_ext >&5 + fi + rm -rf conftest* conftst* + + # Do not use the global_symbol_pipe unless it works. + if test "$pipe_works" = yes; then + break + else + lt_cv_sys_global_symbol_pipe= + fi +done +]) +if test -z "$lt_cv_sys_global_symbol_pipe"; then + lt_cv_sys_global_symbol_to_cdecl= +fi +if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then + AC_MSG_RESULT(failed) +else + AC_MSG_RESULT(ok) +fi +]) # AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE + + +# AC_LIBTOOL_PROG_COMPILER_PIC([TAGNAME]) +# --------------------------------------- +AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC], +[_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)= +_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= +_LT_AC_TAGVAR(lt_prog_compiler_static, $1)= + +AC_MSG_CHECKING([for $compiler option to produce PIC]) + ifelse([$1],[CXX],[ + # C++ specific cases for pic, static, wl, etc. + if test "$GXX" = yes; then + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + fi + ;; + amigaos*) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the `-m68020' flag to GCC prevents building anything better, + # like `-m68040'. + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' + ;; + beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + mingw* | cygwin* | os2* | pw32*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + # Although the cygwin gcc ignores -fPIC, still need this for old-style + # (--disable-auto-import) libraries + m4_if([$1], [GCJ], [], + [_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) + ;; + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' + ;; + *djgpp*) + # DJGPP does not support shared libraries at all + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= + ;; + interix[[3-9]]*) + # Interix 3.x gcc -fpic/-fPIC options generate broken code. + # Instead, we relocate shared libraries at runtime. + ;; + sysv4*MP*) + if test -d /usr/nec; then + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic + fi + ;; + hpux*) + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case $host_cpu in + hppa*64*|ia64*) + ;; + *) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + ;; + *) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + else + case $host_os in + aix[[4-9]]*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + else + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' + fi + ;; + chorus*) + case $cc_basename in + cxch68*) + # Green Hills C++ Compiler + # _LT_AC_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" + ;; + esac + ;; + darwin*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + case $cc_basename in + xlc*) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-qnocommon' + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + ;; + esac + ;; + dgux*) + case $cc_basename in + ec++*) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + ;; + ghcx*) + # Green Hills C++ Compiler + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + ;; + *) + ;; + esac + ;; + freebsd* | dragonfly*) + # FreeBSD uses GNU C++ + ;; + hpux9* | hpux10* | hpux11*) + case $cc_basename in + CC*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' + if test "$host_cpu" != ia64; then + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z' + fi + ;; + aCC*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z' + ;; + esac + ;; + *) + ;; + esac + ;; + interix*) + # This is c89, which is MS Visual C++ (no shared libs) + # Anyone wants to do a port? + ;; + irix5* | irix6* | nonstopux*) + case $cc_basename in + CC*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + # CC pic flag -KPIC is the default. + ;; + *) + ;; + esac + ;; + linux* | k*bsd*-gnu) + case $cc_basename in + KCC*) + # KAI C++ Compiler + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + icpc* | ecpc*) + # Intel C++ + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + pgCC* | pgcpp*) + # Portland Group C++ compiler. + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + cxx*) + # Compaq C++ + # Make sure the PIC flag is empty. It appears that all Alpha + # Linux and Compaq Tru64 Unix objects are PIC. + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + # Sun C++ 5.9 + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + ;; + esac + ;; + esac + ;; + lynxos*) + ;; + m88k*) + ;; + mvs*) + case $cc_basename in + cxx*) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall' + ;; + *) + ;; + esac + ;; + netbsd*) + ;; + osf3* | osf4* | osf5*) + case $cc_basename in + KCC*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' + ;; + RCC*) + # Rational C++ 2.4.1 + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + ;; + cxx*) + # Digital/Compaq C++ + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # Make sure the PIC flag is empty. It appears that all Alpha + # Linux and Compaq Tru64 Unix objects are PIC. + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + *) + ;; + esac + ;; + psos*) + ;; + solaris*) + case $cc_basename in + CC*) + # Sun C++ 4.2, 5.x and Centerline C++ + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + ;; + gcx*) + # Green Hills C++ Compiler + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' + ;; + *) + ;; + esac + ;; + sunos4*) + case $cc_basename in + CC*) + # Sun C++ 4.x + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + lcc*) + # Lucid + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + ;; + *) + ;; + esac + ;; + tandem*) + case $cc_basename in + NCC*) + # NonStop-UX NCC 3.20 + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + ;; + *) + ;; + esac + ;; + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + case $cc_basename in + CC*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + esac + ;; + vxworks*) + ;; + *) + _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + ;; + esac + fi +], +[ + if test "$GCC" = yes; then + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + fi + ;; + + amigaos*) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the `-m68020' flag to GCC prevents building anything better, + # like `-m68040'. + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' + ;; + + beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + + mingw* | cygwin* | pw32* | os2*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + # Although the cygwin gcc ignores -fPIC, still need this for old-style + # (--disable-auto-import) libraries + m4_if([$1], [GCJ], [], + [_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) + ;; + + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' + ;; + + interix[[3-9]]*) + # Interix 3.x gcc -fpic/-fPIC options generate broken code. + # Instead, we relocate shared libraries at runtime. + ;; + + msdosdjgpp*) + # Just because we use GCC doesn't mean we suddenly get shared libraries + # on systems that don't support them. + _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + enable_shared=no + ;; + + sysv4*MP*) + if test -d /usr/nec; then + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic + fi + ;; + + hpux*) + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + ;; + + *) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + else + # PORTME Check for flag to pass linker flags through the system compiler. + case $host_os in + aix*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + else + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' + fi + ;; + darwin*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + case $cc_basename in + xlc*) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-qnocommon' + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + ;; + esac + ;; + + mingw* | cygwin* | pw32* | os2*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + m4_if([$1], [GCJ], [], + [_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) + ;; + + hpux9* | hpux10* | hpux11*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z' + ;; + esac + # Is there a better lt_prog_compiler_static that works with the bundled CC? + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' + ;; + + irix5* | irix6* | nonstopux*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # PIC (with -KPIC) is the default. + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + + newsos6) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + linux* | k*bsd*-gnu) + case $cc_basename in + icc* | ecc*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + pgcc* | pgf77* | pgf90* | pgf95*) + # Portland Group compilers (*not* the Pentium gcc compiler, + # which looks to be a dead project) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + ccc*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # All Alpha code is PIC. + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + # Sun C 5.9 + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + ;; + *Sun\ F*) + # Sun Fortran 8.3 passes all unrecognized flags to the linker + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='' + ;; + esac + ;; + esac + ;; + + osf3* | osf4* | osf5*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # All OSF/1 code is PIC. + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + + rdos*) + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + + solaris*) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + case $cc_basename in + f77* | f90* | f95*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';; + *) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';; + esac + ;; + + sunos4*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + sysv4 | sysv4.2uw2* | sysv4.3*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + sysv4*MP*) + if test -d /usr/nec ;then + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + fi + ;; + + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + unicos*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + ;; + + uts4*) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + *) + _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + ;; + esac + fi +]) +AC_MSG_RESULT([$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)]) + +# +# Check to make sure the PIC flag actually works. +# +if test -n "$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)"; then + AC_LIBTOOL_COMPILER_OPTION([if $compiler PIC flag $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) works], + _LT_AC_TAGVAR(lt_cv_prog_compiler_pic_works, $1), + [$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])], [], + [case $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) in + "" | " "*) ;; + *) _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)" ;; + esac], + [_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= + _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no]) +fi +case $host_os in + # For platforms which do not support PIC, -DPIC is meaningless: + *djgpp*) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= + ;; + *) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])" + ;; +esac + +# +# Check to make sure the static flag actually works. +# +wl=$_LT_AC_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_AC_TAGVAR(lt_prog_compiler_static, $1)\" +AC_LIBTOOL_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works], + _LT_AC_TAGVAR(lt_cv_prog_compiler_static_works, $1), + $lt_tmp_static_flag, + [], + [_LT_AC_TAGVAR(lt_prog_compiler_static, $1)=]) +]) + + +# AC_LIBTOOL_PROG_LD_SHLIBS([TAGNAME]) +# ------------------------------------ +# See if the linker supports building shared libraries. +AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS], +[AC_REQUIRE([LT_AC_PROG_SED])dnl +AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) +ifelse([$1],[CXX],[ + _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + case $host_os in + aix[[4-9]]*) + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to AIX nm, but means don't demangle with GNU nm + if $NM -V 2>&1 | grep 'GNU' > /dev/null; then + _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols' + else + _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols' + fi + ;; + pw32*) + _LT_AC_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds" + ;; + cygwin* | mingw*) + _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;/^.*[[ ]]__nm__/s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols' + ;; + *) + _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + ;; + esac + _LT_AC_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] +],[ + runpath_var= + _LT_AC_TAGVAR(allow_undefined_flag, $1)= + _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no + _LT_AC_TAGVAR(archive_cmds, $1)= + _LT_AC_TAGVAR(archive_expsym_cmds, $1)= + _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)= + _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1)= + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)= + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)= + _LT_AC_TAGVAR(thread_safe_flag_spec, $1)= + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)= + _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)= + _LT_AC_TAGVAR(hardcode_direct, $1)=no + _LT_AC_TAGVAR(hardcode_minus_L, $1)=no + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported + _LT_AC_TAGVAR(link_all_deplibs, $1)=unknown + _LT_AC_TAGVAR(hardcode_automatic, $1)=no + _LT_AC_TAGVAR(module_cmds, $1)= + _LT_AC_TAGVAR(module_expsym_cmds, $1)= + _LT_AC_TAGVAR(always_export_symbols, $1)=no + _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + # include_expsyms should be a list of space-separated symbols to be *always* + # included in the symbol list + _LT_AC_TAGVAR(include_expsyms, $1)= + # exclude_expsyms can be an extended regexp of symbols to exclude + # it will be wrapped by ` (' and `)$', so one must not match beginning or + # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', + # as well as any symbol that contains `d'. + _LT_AC_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] + # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out + # platforms (ab)use it in PIC code, but their linkers get confused if + # the symbol is explicitly referenced. Since portable code cannot + # rely on this symbol name, it's probably fine to never include it in + # preloaded symbol tables. + # Exclude shared library initialization/finalization symbols. +dnl Note also adjust exclude_expsyms for C++ above. + extract_expsyms_cmds= + # Just being paranoid about ensuring that cc_basename is set. + _LT_CC_BASENAME([$compiler]) + case $host_os in + cygwin* | mingw* | pw32*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + if test "$GCC" != yes; then + with_gnu_ld=no + fi + ;; + interix*) + # we just hope/assume this is gcc and not c89 (= MSVC++) + with_gnu_ld=yes + ;; + openbsd*) + with_gnu_ld=no + ;; + esac + + _LT_AC_TAGVAR(ld_shlibs, $1)=yes + if test "$with_gnu_ld" = yes; then + # If archive_cmds runs LD, not CC, wlarc should be empty + wlarc='${wl}' + + # Set some defaults for GNU ld with shared library support. These + # are reset later if shared libraries are not supported. Putting them + # here allows them to be overridden if necessary. + runpath_var=LD_RUN_PATH + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + # ancient GNU ld didn't support --whole-archive et. al. + if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)= + fi + supports_anon_versioning=no + case `$LD -v 2>/dev/null` in + *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11 + *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... + *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... + *\ 2.11.*) ;; # other 2.11 versions + *) supports_anon_versioning=yes ;; + esac + + # See if GNU ld supports shared libraries. + case $host_os in + aix[[3-9]]*) + # On AIX/PPC, the GNU linker is very broken + if test "$host_cpu" != ia64; then + _LT_AC_TAGVAR(ld_shlibs, $1)=no + cat <<EOF 1>&2 + +*** Warning: the GNU linker, at least up to release 2.9.1, is reported +*** to be unable to reliably create shared libraries on AIX. +*** Therefore, libtool is disabling shared libraries support. If you +*** really care for shared libraries, you may want to modify your PATH +*** so that a non-GNU linker is found, and then restart. + +EOF + fi + ;; + + amigaos*) + _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + + # Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports + # that the semantics of dynamic libraries on AmigaOS, at least up + # to version 4, is to share data among multiple programs linked + # with the same dynamic library. Since this doesn't match the + # behavior of shared libraries on other platforms, we can't use + # them. + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + + beos*) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported + # Joseph Beckenbach <jrb3@best.com> says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + else + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + cygwin* | mingw* | pw32*) + # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, + # as there is no search path for DLLs. + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_AC_TAGVAR(always_export_symbols, $1)=no + _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/'\'' -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols' + + if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + # If the export-symbols file already is a .def file (1st line + # is EXPORTS), use it as is; otherwise, prepend... + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + else + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + interix[[3-9]]*) + _LT_AC_TAGVAR(hardcode_direct, $1)=no + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. + # Instead, shared libraries are loaded at an image base (0x10000000 by + # default) and relocated if they conflict, which is a slow very memory + # consuming and fragmenting process. To avoid this, we pick a random, + # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link + # time. Moving up from 0x10000000 also allows more sbrk(2) space. + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + ;; + + gnu* | linux* | k*bsd*-gnu) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + tmp_addflag= + case $cc_basename,$host_cpu in + pgcc*) # Portland Group C compiler + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' + tmp_addflag=' $pic_flag' + ;; + pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' + tmp_addflag=' $pic_flag -Mnomain' ;; + ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 + tmp_addflag=' -i_dynamic' ;; + efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 + tmp_addflag=' -i_dynamic -nofor_main' ;; + ifc* | ifort*) # Intel Fortran compiler + tmp_addflag=' -nofor_main' ;; + esac + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) # Sun C 5.9 + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' + tmp_sharedflag='-G' ;; + *Sun\ F*) # Sun Fortran 8.3 + tmp_sharedflag='-G' ;; + *) + tmp_sharedflag='-shared' ;; + esac + _LT_AC_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + + if test $supports_anon_versioning = yes; then + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + $echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' + fi + else + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' + wlarc= + else + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + fi + ;; + + solaris*) + if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then + _LT_AC_TAGVAR(ld_shlibs, $1)=no + cat <<EOF 1>&2 + +*** Warning: The releases 2.8.* of the GNU linker cannot reliably +*** create shared libraries on Solaris systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.9.1 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +EOF + elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) + case `$LD -v 2>&1` in + *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*) + _LT_AC_TAGVAR(ld_shlibs, $1)=no + cat <<_LT_EOF 1>&2 + +*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not +*** reliably create shared libraries on SCO systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.16.91.0.3 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +_LT_EOF + ;; + *) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname,-retain-symbols-file,$export_symbols -o $lib' + else + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + + sunos4*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' + wlarc= + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + *) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + + if test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no; then + runpath_var= + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)= + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)= + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)= + fi + else + # PORTME fill in a description of your system's linker (not GNU ld) + case $host_os in + aix3*) + _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_AC_TAGVAR(always_export_symbols, $1)=yes + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported + fi + ;; + + aix[[4-9]]*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag="" + else + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to AIX nm, but means don't demangle with GNU nm + if $NM -V 2>&1 | grep 'GNU' > /dev/null; then + _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols' + else + _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols' + fi + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) + for ld_flag in $LDFLAGS; do + if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then + aix_use_runtimelinking=yes + break + fi + done + ;; + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + _LT_AC_TAGVAR(archive_cmds, $1)='' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + + if test "$GCC" = yes; then + case $host_os in aix4.[[012]]|aix4.[[012]].*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && \ + strings "$collect2name" | grep resolve_lib_name >/dev/null + then + # We have reworked collect2 + : + else + # We have old collect2 + _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)= + fi + ;; + esac + shared_flag='-shared' + if test "$aix_use_runtimelinking" = yes; then + shared_flag="$shared_flag "'${wl}-G' + fi + else + # not using gcc + if test "$host_cpu" = ia64; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test "$aix_use_runtimelinking" = yes; then + shared_flag='${wl}-G' + else + shared_flag='${wl}-bM:SRE' + fi + fi + fi + + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to export. + _LT_AC_TAGVAR(always_export_symbols, $1)=yes + if test "$aix_use_runtimelinking" = yes; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + _LT_AC_TAGVAR(allow_undefined_flag, $1)='-berok' + # Determine the default libpath from the value encoded in an empty executable. + _LT_AC_SYS_LIBPATH_AIX + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" + _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" + else + if test "$host_cpu" = ia64; then + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' + _LT_AC_TAGVAR(allow_undefined_flag, $1)="-z nodefs" + _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an empty executable. + _LT_AC_SYS_LIBPATH_AIX + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' + # Exported symbols can be pulled into shared objects from archives + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='$convenience' + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes + # This is similar to how AIX traditionally builds its shared libraries. + _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' + fi + fi + ;; + + amigaos*) + _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + # see comment about different semantics on the GNU ld section + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + + bsdi[[45]]*) + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic + ;; + + cygwin* | mingw* | pw32*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' + _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=".dll" + # FIXME: Setting linknames here is a bad hack. + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames=' + # The linker will automatically build a .lib file if we build a DLL. + _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)='true' + # FIXME: Should let the user specify the lib program. + _LT_AC_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs' + _LT_AC_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`' + _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + ;; + + darwin* | rhapsody*) + _LT_AC_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined" + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_AC_TAGVAR(hardcode_direct, $1)=no + _LT_AC_TAGVAR(hardcode_automatic, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='' + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + if test "$GCC" = yes ; then + output_verbose_link_cmd='echo' + _LT_AC_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" + _LT_AC_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" + _LT_AC_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" + _LT_AC_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" + else + case $cc_basename in + xlc*) + output_verbose_link_cmd='echo' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $xlcverstring' + _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' + # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $xlcverstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + ;; + *) + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + esac + fi + ;; + + dgux*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + freebsd1*) + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + + # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor + # support. Future versions do this automatically, but an explicit c++rt0.o + # does not break anything, and helps significantly (at the cost of a little + # extra space). + freebsd2.2*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + # Unfortunately, older versions of FreeBSD 2 do not have this feature. + freebsd2*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + # FreeBSD 3 and greater uses gcc -shared to do shared libraries. + freebsd* | dragonfly*) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + hpux9*) + if test "$GCC" = yes; then + _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + else + _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + fi + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + ;; + + hpux10*) + if test "$GCC" = yes -a "$with_gnu_ld" = no; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' + fi + if test "$with_gnu_ld" = no; then + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + fi + ;; + + hpux11*) + if test "$GCC" = yes -a "$with_gnu_ld" = no; then + case $host_cpu in + hppa*64*) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + else + case $host_cpu in + hppa*64*) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + fi + if test "$with_gnu_ld" = no; then + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + + case $host_cpu in + hppa*64*|ia64*) + _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir' + _LT_AC_TAGVAR(hardcode_direct, $1)=no + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + *) + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + ;; + esac + fi + ;; + + irix5* | irix6* | nonstopux*) + if test "$GCC" = yes; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir' + fi + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out + else + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF + fi + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + newsos6) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + openbsd*) + if test -f /usr/libexec/ld.so; then + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + else + case $host_os in + openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + ;; + *) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + ;; + esac + fi + else + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + os2*) + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_AC_TAGVAR(archive_cmds, $1)='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' + _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' + ;; + + osf3*) + if test "$GCC" = yes; then + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + fi + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + ;; + + osf4* | osf5*) # as osf3* with the addition of -msym flag + if test "$GCC" = yes; then + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + else + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~ + $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp' + + # Both c and cxx compiler support -rpath directly + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' + fi + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + ;; + + solaris*) + _LT_AC_TAGVAR(no_undefined_flag, $1)=' -z text' + if test "$GCC" = yes; then + wlarc='${wl}' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp' + else + wlarc='' + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' + fi + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + case $host_os in + solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; + *) + # The compiler driver will combine and reorder linker options, + # but understands `-z linker_flag'. GCC discards it without `$wl', + # but is careful enough not to reorder. + # Supported since Solaris 2.6 (maybe 2.5.1?) + if test "$GCC" = yes; then + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' + else + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' + fi + ;; + esac + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + ;; + + sunos4*) + if test "x$host_vendor" = xsequent; then + # Use $CC to link under sequent, because it throws in some extra .o + # files that make .init and .fini sections work. + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' + fi + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + sysv4) + case $host_vendor in + sni) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes # is this really true??? + ;; + siemens) + ## LD is ld it makes a PLAMLIB + ## CC just makes a GrossModule. + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs' + _LT_AC_TAGVAR(hardcode_direct, $1)=no + ;; + motorola) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie + ;; + esac + runpath_var='LD_RUN_PATH' + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + sysv4.3*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + _LT_AC_TAGVAR(ld_shlibs, $1)=yes + fi + ;; + + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) + _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + runpath_var='LD_RUN_PATH' + + if test "$GCC" = yes; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + sysv5* | sco3.2v5* | sco5v6*) + # Note: We can NOT use -z defs as we might desire, because we do not + # link with -lc, and that would cause any symbols used from libc to + # always be unresolved, which means just about no library would + # ever link correctly. If we're not using GNU ld we use -z text + # though, which does catch some bad symbols but isn't as heavy-handed + # as -z defs. + _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' + _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' + runpath_var='LD_RUN_PATH' + + if test "$GCC" = yes; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + uts4*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + *) + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + esac + fi +]) +AC_MSG_RESULT([$_LT_AC_TAGVAR(ld_shlibs, $1)]) +test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no + +# +# Do we need to explicitly link libc? +# +case "x$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)" in +x|xyes) + # Assume -lc should be added + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes + + if test "$enable_shared" = yes && test "$GCC" = yes; then + case $_LT_AC_TAGVAR(archive_cmds, $1) in + *'~'*) + # FIXME: we may have to deal with multi-command sequences. + ;; + '$CC '*) + # Test whether the compiler implicitly links with -lc since on some + # systems, -lgcc has to come before -lc. If gcc already passes -lc + # to ld, don't add -lc before -lgcc. + AC_MSG_CHECKING([whether -lc should be explicitly linked in]) + $rm conftest* + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + if AC_TRY_EVAL(ac_compile) 2>conftest.err; then + soname=conftest + lib=conftest + libobjs=conftest.$ac_objext + deplibs= + wl=$_LT_AC_TAGVAR(lt_prog_compiler_wl, $1) + pic_flag=$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) + compiler_flags=-v + linker_flags=-v + verstring= + output_objdir=. + libname=conftest + lt_save_allow_undefined_flag=$_LT_AC_TAGVAR(allow_undefined_flag, $1) + _LT_AC_TAGVAR(allow_undefined_flag, $1)= + if AC_TRY_EVAL(_LT_AC_TAGVAR(archive_cmds, $1) 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) + then + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no + else + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes + fi + _LT_AC_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag + else + cat conftest.err 1>&5 + fi + $rm conftest* + AC_MSG_RESULT([$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)]) + ;; + esac + fi + ;; +esac +])# AC_LIBTOOL_PROG_LD_SHLIBS + + +# _LT_AC_FILE_LTDLL_C +# ------------------- +# Be careful that the start marker always follows a newline. +AC_DEFUN([_LT_AC_FILE_LTDLL_C], [ +# /* ltdll.c starts here */ +# #define WIN32_LEAN_AND_MEAN +# #include <windows.h> +# #undef WIN32_LEAN_AND_MEAN +# #include <stdio.h> +# +# #ifndef __CYGWIN__ +# # ifdef __CYGWIN32__ +# # define __CYGWIN__ __CYGWIN32__ +# # endif +# #endif +# +# #ifdef __cplusplus +# extern "C" { +# #endif +# BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved); +# #ifdef __cplusplus +# } +# #endif +# +# #ifdef __CYGWIN__ +# #include <cygwin/cygwin_dll.h> +# DECLARE_CYGWIN_DLL( DllMain ); +# #endif +# HINSTANCE __hDllInstance_base; +# +# BOOL APIENTRY +# DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved) +# { +# __hDllInstance_base = hInst; +# return TRUE; +# } +# /* ltdll.c ends here */ +])# _LT_AC_FILE_LTDLL_C + + +# _LT_AC_TAGVAR(VARNAME, [TAGNAME]) +# --------------------------------- +AC_DEFUN([_LT_AC_TAGVAR], [ifelse([$2], [], [$1], [$1_$2])]) + + +# old names +AC_DEFUN([AM_PROG_LIBTOOL], [AC_PROG_LIBTOOL]) +AC_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)]) +AC_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)]) +AC_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)]) +AC_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)]) +AC_DEFUN([AM_PROG_LD], [AC_PROG_LD]) +AC_DEFUN([AM_PROG_NM], [AC_PROG_NM]) + +# This is just to silence aclocal about the macro not being used +ifelse([AC_DISABLE_FAST_INSTALL]) + +AC_DEFUN([LT_AC_PROG_GCJ], +[AC_CHECK_TOOL(GCJ, gcj, no) + test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2" + AC_SUBST(GCJFLAGS) +]) + +AC_DEFUN([LT_AC_PROG_RC], +[AC_CHECK_TOOL(RC, windres, no) +]) + + +# Cheap backport of AS_EXECUTABLE_P and required macros +# from Autoconf 2.59; we should not use $as_executable_p directly. + +# _AS_TEST_PREPARE +# ---------------- +m4_ifndef([_AS_TEST_PREPARE], +[m4_defun([_AS_TEST_PREPARE], +[if test -x / >/dev/null 2>&1; then + as_executable_p='test -x' +else + as_executable_p='test -f' +fi +])])# _AS_TEST_PREPARE + +# AS_EXECUTABLE_P +# --------------- +# Check whether a file is executable. +m4_ifndef([AS_EXECUTABLE_P], +[m4_defun([AS_EXECUTABLE_P], +[AS_REQUIRE([_AS_TEST_PREPARE])dnl +$as_executable_p $1[]dnl +])])# AS_EXECUTABLE_P + +# NOTE: This macro has been submitted for inclusion into # +# GNU Autoconf as AC_PROG_SED. When it is available in # +# a released version of Autoconf we should remove this # +# macro and use it instead. # +# LT_AC_PROG_SED +# -------------- +# Check for a fully-functional sed program, that truncates +# as few characters as possible. Prefer GNU sed if found. +AC_DEFUN([LT_AC_PROG_SED], +[AC_MSG_CHECKING([for a sed that does not truncate output]) +AC_CACHE_VAL(lt_cv_path_SED, +[# Loop through the user's path and test for sed and gsed. +# Then use that list of sed's as ones to test for truncation. +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for lt_ac_prog in sed gsed; do + for ac_exec_ext in '' $ac_executable_extensions; do + if AS_EXECUTABLE_P(["$as_dir/$lt_ac_prog$ac_exec_ext"]); then + lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" + fi + done + done +done +IFS=$as_save_IFS +lt_ac_max=0 +lt_ac_count=0 +# Add /usr/xpg4/bin/sed as it is typically found on Solaris +# along with /bin/sed that truncates output. +for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do + test ! -f $lt_ac_sed && continue + cat /dev/null > conftest.in + lt_ac_count=0 + echo $ECHO_N "0123456789$ECHO_C" >conftest.in + # Check for GNU sed and select it if it is found. + if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then + lt_cv_path_SED=$lt_ac_sed + break + fi + while true; do + cat conftest.in conftest.in >conftest.tmp + mv conftest.tmp conftest.in + cp conftest.in conftest.nl + echo >>conftest.nl + $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break + cmp -s conftest.out conftest.nl || break + # 10000 chars as input seems more than enough + test $lt_ac_count -gt 10 && break + lt_ac_count=`expr $lt_ac_count + 1` + if test $lt_ac_count -gt $lt_ac_max; then + lt_ac_max=$lt_ac_count + lt_cv_path_SED=$lt_ac_sed + fi + done +done +]) +SED=$lt_cv_path_SED +AC_SUBST([SED]) +AC_MSG_RESULT([$SED]) +]) + +# Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_AUTOMAKE_VERSION(VERSION) +# ---------------------------- +# Automake X.Y traces this macro to ensure aclocal.m4 has been +# generated from the m4 files accompanying Automake X.Y. +AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version="1.9"]) + +# AM_SET_CURRENT_AUTOMAKE_VERSION +# ------------------------------- +# Call AM_AUTOMAKE_VERSION so it can be traced. +# This function is AC_REQUIREd by AC_INIT_AUTOMAKE. +AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], + [AM_AUTOMAKE_VERSION([1.9.6])]) + +# AM_AUX_DIR_EXPAND -*- Autoconf -*- + +# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets +# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to +# `$srcdir', `$srcdir/..', or `$srcdir/../..'. +# +# Of course, Automake must honor this variable whenever it calls a +# tool from the auxiliary directory. The problem is that $srcdir (and +# therefore $ac_aux_dir as well) can be either absolute or relative, +# depending on how configure is run. This is pretty annoying, since +# it makes $ac_aux_dir quite unusable in subdirectories: in the top +# source directory, any form will work fine, but in subdirectories a +# relative path needs to be adjusted first. +# +# $ac_aux_dir/missing +# fails when called from a subdirectory if $ac_aux_dir is relative +# $top_srcdir/$ac_aux_dir/missing +# fails if $ac_aux_dir is absolute, +# fails when called from a subdirectory in a VPATH build with +# a relative $ac_aux_dir +# +# The reason of the latter failure is that $top_srcdir and $ac_aux_dir +# are both prefixed by $srcdir. In an in-source build this is usually +# harmless because $srcdir is `.', but things will broke when you +# start a VPATH build or use an absolute $srcdir. +# +# So we could use something similar to $top_srcdir/$ac_aux_dir/missing, +# iff we strip the leading $srcdir from $ac_aux_dir. That would be: +# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` +# and then we would define $MISSING as +# MISSING="\${SHELL} $am_aux_dir/missing" +# This will work as long as MISSING is not called from configure, because +# unfortunately $(top_srcdir) has no meaning in configure. +# However there are other variables, like CC, which are often used in +# configure, and could therefore not use this "fixed" $ac_aux_dir. +# +# Another solution, used here, is to always expand $ac_aux_dir to an +# absolute PATH. The drawback is that using absolute paths prevent a +# configured tree to be moved without reconfiguration. + +AC_DEFUN([AM_AUX_DIR_EXPAND], +[dnl Rely on autoconf to set up CDPATH properly. +AC_PREREQ([2.50])dnl +# expand $ac_aux_dir to an absolute path +am_aux_dir=`cd $ac_aux_dir && pwd` +]) + +# AM_CONDITIONAL -*- Autoconf -*- + +# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 7 + +# AM_CONDITIONAL(NAME, SHELL-CONDITION) +# ------------------------------------- +# Define a conditional. +AC_DEFUN([AM_CONDITIONAL], +[AC_PREREQ(2.52)dnl + ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], + [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl +AC_SUBST([$1_TRUE]) +AC_SUBST([$1_FALSE]) +if $2; then + $1_TRUE= + $1_FALSE='#' +else + $1_TRUE='#' + $1_FALSE= +fi +AC_CONFIG_COMMANDS_PRE( +[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then + AC_MSG_ERROR([[conditional "$1" was never defined. +Usually this means the macro was only invoked conditionally.]]) +fi])]) + + +# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 8 + +# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be +# written in clear, in which case automake, when reading aclocal.m4, +# will think it sees a *use*, and therefore will trigger all it's +# C support machinery. Also note that it means that autoscan, seeing +# CC etc. in the Makefile, will ask for an AC_PROG_CC use... + + +# _AM_DEPENDENCIES(NAME) +# ---------------------- +# See how the compiler implements dependency checking. +# NAME is "CC", "CXX", "GCJ", or "OBJC". +# We try a few techniques and use that to set a single cache variable. +# +# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was +# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular +# dependency, and given that the user is not expected to run this macro, +# just rely on AC_PROG_CC. +AC_DEFUN([_AM_DEPENDENCIES], +[AC_REQUIRE([AM_SET_DEPDIR])dnl +AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl +AC_REQUIRE([AM_MAKE_INCLUDE])dnl +AC_REQUIRE([AM_DEP_TRACK])dnl + +ifelse([$1], CC, [depcc="$CC" am_compiler_list=], + [$1], CXX, [depcc="$CXX" am_compiler_list=], + [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'], + [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'], + [depcc="$$1" am_compiler_list=]) + +AC_CACHE_CHECK([dependency style of $depcc], + [am_cv_$1_dependencies_compiler_type], +[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_$1_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` + fi + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with + # Solaris 8's {/usr,}/bin/sh. + touch sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + case $depmode in + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + none) break ;; + esac + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. + if depmode=$depmode \ + source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_$1_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_$1_dependencies_compiler_type=none +fi +]) +AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) +AM_CONDITIONAL([am__fastdep$1], [ + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) +]) + + +# AM_SET_DEPDIR +# ------------- +# Choose a directory name for dependency files. +# This macro is AC_REQUIREd in _AM_DEPENDENCIES +AC_DEFUN([AM_SET_DEPDIR], +[AC_REQUIRE([AM_SET_LEADING_DOT])dnl +AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl +]) + + +# AM_DEP_TRACK +# ------------ +AC_DEFUN([AM_DEP_TRACK], +[AC_ARG_ENABLE(dependency-tracking, +[ --disable-dependency-tracking speeds up one-time build + --enable-dependency-tracking do not reject slow dependency extractors]) +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' +fi +AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) +AC_SUBST([AMDEPBACKSLASH]) +]) + +# Generate code to set up dependency tracking. -*- Autoconf -*- + +# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +#serial 3 + +# _AM_OUTPUT_DEPENDENCY_COMMANDS +# ------------------------------ +AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], +[for mf in $CONFIG_FILES; do + # Strip MF so we end up with the name of the file. + mf=`echo "$mf" | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile or not. + # We used to match only the files named `Makefile.in', but + # some people rename them; so instead we look at the file content. + # Grep'ing the first line is not enough: some people post-process + # each Makefile.in and add a new line on top of each file to say so. + # So let's grep whole file. + if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then + dirpart=`AS_DIRNAME("$mf")` + else + continue + fi + # Extract the definition of DEPDIR, am__include, and am__quote + # from the Makefile without running `make'. + DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` + test -z "$DEPDIR" && continue + am__include=`sed -n 's/^am__include = //p' < "$mf"` + test -z "am__include" && continue + am__quote=`sed -n 's/^am__quote = //p' < "$mf"` + # When using ansi2knr, U may be empty or an underscore; expand it + U=`sed -n 's/^U = //p' < "$mf"` + # Find all dependency output files, they are included files with + # $(DEPDIR) in their names. We invoke sed twice because it is the + # simplest approach to changing $(DEPDIR) to its actual value in the + # expansion. + for file in `sed -n " + s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ + sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do + # Make sure the directory exists. + test -f "$dirpart/$file" && continue + fdir=`AS_DIRNAME(["$file"])` + AS_MKDIR_P([$dirpart/$fdir]) + # echo "creating $dirpart/$file" + echo '# dummy' > "$dirpart/$file" + done +done +])# _AM_OUTPUT_DEPENDENCY_COMMANDS + + +# AM_OUTPUT_DEPENDENCY_COMMANDS +# ----------------------------- +# This macro should only be invoked once -- use via AC_REQUIRE. +# +# This code is only required when automatic dependency tracking +# is enabled. FIXME. This creates each `.P' file that we will +# need in order to bootstrap the dependency handling code. +AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], +[AC_CONFIG_COMMANDS([depfiles], + [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], + [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) +]) + +# Do all the work for Automake. -*- Autoconf -*- + +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 12 + +# This macro actually does too much. Some checks are only needed if +# your package does certain things. But this isn't really a big deal. + +# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) +# AM_INIT_AUTOMAKE([OPTIONS]) +# ----------------------------------------------- +# The call with PACKAGE and VERSION arguments is the old style +# call (pre autoconf-2.50), which is being phased out. PACKAGE +# and VERSION should now be passed to AC_INIT and removed from +# the call to AM_INIT_AUTOMAKE. +# We support both call styles for the transition. After +# the next Automake release, Autoconf can make the AC_INIT +# arguments mandatory, and then we can depend on a new Autoconf +# release and drop the old call support. +AC_DEFUN([AM_INIT_AUTOMAKE], +[AC_PREREQ([2.58])dnl +dnl Autoconf wants to disallow AM_ names. We explicitly allow +dnl the ones we care about. +m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl +AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl +AC_REQUIRE([AC_PROG_INSTALL])dnl +# test to see if srcdir already configured +if test "`cd $srcdir && pwd`" != "`pwd`" && + test -f $srcdir/config.status; then + AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) +fi + +# test whether we have cygpath +if test -z "$CYGPATH_W"; then + if (cygpath --version) >/dev/null 2>/dev/null; then + CYGPATH_W='cygpath -w' + else + CYGPATH_W=echo + fi +fi +AC_SUBST([CYGPATH_W]) + +# Define the identity of the package. +dnl Distinguish between old-style and new-style calls. +m4_ifval([$2], +[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl + AC_SUBST([PACKAGE], [$1])dnl + AC_SUBST([VERSION], [$2])], +[_AM_SET_OPTIONS([$1])dnl + AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl + AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl + +_AM_IF_OPTION([no-define],, +[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) + AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl + +# Some tools Automake needs. +AC_REQUIRE([AM_SANITY_CHECK])dnl +AC_REQUIRE([AC_ARG_PROGRAM])dnl +AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}) +AM_MISSING_PROG(AUTOCONF, autoconf) +AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) +AM_MISSING_PROG(AUTOHEADER, autoheader) +AM_MISSING_PROG(MAKEINFO, makeinfo) +AM_PROG_INSTALL_SH +AM_PROG_INSTALL_STRIP +AC_REQUIRE([AM_PROG_MKDIR_P])dnl +# We need awk for the "check" target. The system "awk" is bad on +# some platforms. +AC_REQUIRE([AC_PROG_AWK])dnl +AC_REQUIRE([AC_PROG_MAKE_SET])dnl +AC_REQUIRE([AM_SET_LEADING_DOT])dnl +_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], + [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], + [_AM_PROG_TAR([v7])])]) +_AM_IF_OPTION([no-dependencies],, +[AC_PROVIDE_IFELSE([AC_PROG_CC], + [_AM_DEPENDENCIES(CC)], + [define([AC_PROG_CC], + defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl +AC_PROVIDE_IFELSE([AC_PROG_CXX], + [_AM_DEPENDENCIES(CXX)], + [define([AC_PROG_CXX], + defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl +]) +]) + + +# When config.status generates a header, we must update the stamp-h file. +# This file resides in the same directory as the config header +# that is generated. The stamp files are numbered to have different names. + +# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the +# loop where config.status creates the headers, so we can generate +# our stamp files there. +AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], +[# Compute $1's index in $config_headers. +_am_stamp_count=1 +for _am_header in $config_headers :; do + case $_am_header in + $1 | $1:* ) + break ;; + * ) + _am_stamp_count=`expr $_am_stamp_count + 1` ;; + esac +done +echo "timestamp for $1" >`AS_DIRNAME([$1])`/stamp-h[]$_am_stamp_count]) + +# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_PROG_INSTALL_SH +# ------------------ +# Define $install_sh. +AC_DEFUN([AM_PROG_INSTALL_SH], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +install_sh=${install_sh-"$am_aux_dir/install-sh"} +AC_SUBST(install_sh)]) + +# Copyright (C) 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 2 + +# Check whether the underlying file-system supports filenames +# with a leading dot. For instance MS-DOS doesn't. +AC_DEFUN([AM_SET_LEADING_DOT], +[rm -rf .tst 2>/dev/null +mkdir .tst 2>/dev/null +if test -d .tst; then + am__leading_dot=. +else + am__leading_dot=_ +fi +rmdir .tst 2>/dev/null +AC_SUBST([am__leading_dot])]) + +# Check to see how 'make' treats includes. -*- Autoconf -*- + +# Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 3 + +# AM_MAKE_INCLUDE() +# ----------------- +# Check to see how make treats includes. +AC_DEFUN([AM_MAKE_INCLUDE], +[am_make=${MAKE-make} +cat > confinc << 'END' +am__doit: + @echo done +.PHONY: am__doit +END +# If we don't find an include directive, just comment out the code. +AC_MSG_CHECKING([for style of include used by $am_make]) +am__include="#" +am__quote= +_am_result=none +# First try GNU make style include. +echo "include confinc" > confmf +# We grep out `Entering directory' and `Leaving directory' +# messages which can occur if `w' ends up in MAKEFLAGS. +# In particular we don't look at `^make:' because GNU make might +# be invoked under some other name (usually "gmake"), in which +# case it prints its new name instead of `make'. +if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then + am__include=include + am__quote= + _am_result=GNU +fi +# Now try BSD make style include. +if test "$am__include" = "#"; then + echo '.include "confinc"' > confmf + if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then + am__include=.include + am__quote="\"" + _am_result=BSD + fi +fi +AC_SUBST([am__include]) +AC_SUBST([am__quote]) +AC_MSG_RESULT([$_am_result]) +rm -f confinc confmf +]) + +# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- + +# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2005 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 4 + +# AM_MISSING_PROG(NAME, PROGRAM) +# ------------------------------ +AC_DEFUN([AM_MISSING_PROG], +[AC_REQUIRE([AM_MISSING_HAS_RUN]) +$1=${$1-"${am_missing_run}$2"} +AC_SUBST($1)]) + + +# AM_MISSING_HAS_RUN +# ------------------ +# Define MISSING if not defined so far and test if it supports --run. +# If it does, set am_missing_run to use it, otherwise, to nothing. +AC_DEFUN([AM_MISSING_HAS_RUN], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" +# Use eval to expand $SHELL +if eval "$MISSING --run true"; then + am_missing_run="$MISSING --run " +else + am_missing_run= + AC_MSG_WARN([`missing' script is too old or missing]) +fi +]) + +# Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_PROG_MKDIR_P +# --------------- +# Check whether `mkdir -p' is supported, fallback to mkinstalldirs otherwise. +# +# Automake 1.8 used `mkdir -m 0755 -p --' to ensure that directories +# created by `make install' are always world readable, even if the +# installer happens to have an overly restrictive umask (e.g. 077). +# This was a mistake. There are at least two reasons why we must not +# use `-m 0755': +# - it causes special bits like SGID to be ignored, +# - it may be too restrictive (some setups expect 775 directories). +# +# Do not use -m 0755 and let people choose whatever they expect by +# setting umask. +# +# We cannot accept any implementation of `mkdir' that recognizes `-p'. +# Some implementations (such as Solaris 8's) are not thread-safe: if a +# parallel make tries to run `mkdir -p a/b' and `mkdir -p a/c' +# concurrently, both version can detect that a/ is missing, but only +# one can create it and the other will error out. Consequently we +# restrict ourselves to GNU make (using the --version option ensures +# this.) +AC_DEFUN([AM_PROG_MKDIR_P], +[if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then + # We used to keeping the `.' as first argument, in order to + # allow $(mkdir_p) to be used without argument. As in + # $(mkdir_p) $(somedir) + # where $(somedir) is conditionally defined. However this is wrong + # for two reasons: + # 1. if the package is installed by a user who cannot write `.' + # make install will fail, + # 2. the above comment should most certainly read + # $(mkdir_p) $(DESTDIR)$(somedir) + # so it does not work when $(somedir) is undefined and + # $(DESTDIR) is not. + # To support the latter case, we have to write + # test -z "$(somedir)" || $(mkdir_p) $(DESTDIR)$(somedir), + # so the `.' trick is pointless. + mkdir_p='mkdir -p --' +else + # On NextStep and OpenStep, the `mkdir' command does not + # recognize any option. It will interpret all options as + # directories to create, and then abort because `.' already + # exists. + for d in ./-p ./--version; + do + test -d $d && rmdir $d + done + # $(mkinstalldirs) is defined by Automake if mkinstalldirs exists. + if test -f "$ac_aux_dir/mkinstalldirs"; then + mkdir_p='$(mkinstalldirs)' + else + mkdir_p='$(install_sh) -d' + fi +fi +AC_SUBST([mkdir_p])]) + +# Helper functions for option handling. -*- Autoconf -*- + +# Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 3 + +# _AM_MANGLE_OPTION(NAME) +# ----------------------- +AC_DEFUN([_AM_MANGLE_OPTION], +[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) + +# _AM_SET_OPTION(NAME) +# ------------------------------ +# Set option NAME. Presently that only means defining a flag for this option. +AC_DEFUN([_AM_SET_OPTION], +[m4_define(_AM_MANGLE_OPTION([$1]), 1)]) + +# _AM_SET_OPTIONS(OPTIONS) +# ---------------------------------- +# OPTIONS is a space-separated list of Automake options. +AC_DEFUN([_AM_SET_OPTIONS], +[AC_FOREACH([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) + +# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) +# ------------------------------------------- +# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. +AC_DEFUN([_AM_IF_OPTION], +[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) + +# Check to make sure that the build environment is sane. -*- Autoconf -*- + +# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 4 + +# AM_SANITY_CHECK +# --------------- +AC_DEFUN([AM_SANITY_CHECK], +[AC_MSG_CHECKING([whether build environment is sane]) +# Just in case +sleep 1 +echo timestamp > conftest.file +# Do `set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null` + if test "$[*]" = "X"; then + # -L didn't work. + set X `ls -t $srcdir/configure conftest.file` + fi + rm -f conftest.file + if test "$[*]" != "X $srcdir/configure conftest.file" \ + && test "$[*]" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken +alias in your environment]) + fi + + test "$[2]" = conftest.file + ) +then + # Ok. + : +else + AC_MSG_ERROR([newly created file is older than distributed files! +Check your system clock]) +fi +AC_MSG_RESULT(yes)]) + +# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_PROG_INSTALL_STRIP +# --------------------- +# One issue with vendor `install' (even GNU) is that you can't +# specify the program used to strip binaries. This is especially +# annoying in cross-compiling environments, where the build's strip +# is unlikely to handle the host's binaries. +# Fortunately install-sh will honor a STRIPPROG variable, so we +# always use install-sh in `make install-strip', and initialize +# STRIPPROG with the value of the STRIP variable (set by the user). +AC_DEFUN([AM_PROG_INSTALL_STRIP], +[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl +# Installed binaries are usually stripped using `strip' when the user +# run `make install-strip'. However `strip' might not be the right +# tool to use in cross-compilation environments, therefore Automake +# will honor the `STRIP' environment variable to overrule this program. +dnl Don't test for $cross_compiling = yes, because it might be `maybe'. +if test "$cross_compiling" != no; then + AC_CHECK_TOOL([STRIP], [strip], :) +fi +INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s" +AC_SUBST([INSTALL_STRIP_PROGRAM])]) + +# Check how to create a tarball. -*- Autoconf -*- + +# Copyright (C) 2004, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 2 + +# _AM_PROG_TAR(FORMAT) +# -------------------- +# Check how to create a tarball in format FORMAT. +# FORMAT should be one of `v7', `ustar', or `pax'. +# +# Substitute a variable $(am__tar) that is a command +# writing to stdout a FORMAT-tarball containing the directory +# $tardir. +# tardir=directory && $(am__tar) > result.tar +# +# Substitute a variable $(am__untar) that extract such +# a tarball read from stdin. +# $(am__untar) < result.tar +AC_DEFUN([_AM_PROG_TAR], +[# Always define AMTAR for backward compatibility. +AM_MISSING_PROG([AMTAR], [tar]) +m4_if([$1], [v7], + [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'], + [m4_case([$1], [ustar],, [pax],, + [m4_fatal([Unknown tar format])]) +AC_MSG_CHECKING([how to create a $1 tar archive]) +# Loop over all known methods to create a tar archive until one works. +_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' +_am_tools=${am_cv_prog_tar_$1-$_am_tools} +# Do not fold the above two line into one, because Tru64 sh and +# Solaris sh will not grok spaces in the rhs of `-'. +for _am_tool in $_am_tools +do + case $_am_tool in + gnutar) + for _am_tar in tar gnutar gtar; + do + AM_RUN_LOG([$_am_tar --version]) && break + done + am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' + am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' + am__untar="$_am_tar -xf -" + ;; + plaintar) + # Must skip GNU tar: if it does not support --format= it doesn't create + # ustar tarball either. + (tar --version) >/dev/null 2>&1 && continue + am__tar='tar chf - "$$tardir"' + am__tar_='tar chf - "$tardir"' + am__untar='tar xf -' + ;; + pax) + am__tar='pax -L -x $1 -w "$$tardir"' + am__tar_='pax -L -x $1 -w "$tardir"' + am__untar='pax -r' + ;; + cpio) + am__tar='find "$$tardir" -print | cpio -o -H $1 -L' + am__tar_='find "$tardir" -print | cpio -o -H $1 -L' + am__untar='cpio -i -H $1 -d' + ;; + none) + am__tar=false + am__tar_=false + am__untar=false + ;; + esac + + # If the value was cached, stop now. We just wanted to have am__tar + # and am__untar set. + test -n "${am_cv_prog_tar_$1}" && break + + # tar/untar a dummy directory, and stop if the command works + rm -rf conftest.dir + mkdir conftest.dir + echo GrepMe > conftest.dir/file + AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) + rm -rf conftest.dir + if test -s conftest.tar; then + AM_RUN_LOG([$am__untar <conftest.tar]) + grep GrepMe conftest.dir/file >/dev/null 2>&1 && break + fi +done +rm -rf conftest.dir + +AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) +AC_MSG_RESULT([$am_cv_prog_tar_$1])]) +AC_SUBST([am__tar]) +AC_SUBST([am__untar]) +]) # _AM_PROG_TAR + diff --git a/autoaux/config.guess b/autoaux/config.guess new file mode 100755 index 0000000..917bbc5 --- /dev/null +++ b/autoaux/config.guess @@ -0,0 +1,1463 @@ +#! /bin/sh +# Attempt to guess a canonical system name. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. + +timestamp='2005-07-08' + +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA +# 02110-1301, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + + +# Originally written by Per Bothner <per@bothner.com>. +# Please send patches to <config-patches@gnu.org>. Submit a context +# diff and a properly formatted ChangeLog entry. +# +# This script attempts to guess a canonical system name similar to +# config.sub. If it succeeds, it prints the system name on stdout, and +# exits with 0. Otherwise, it exits with 1. +# +# The plan is that this can be called by configure scripts if you +# don't specify an explicit build system type. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] + +Output the configuration name of the system \`$me' is run on. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to <config-patches@gnu.org>." + +version="\ +GNU config.guess ($timestamp) + +Originally written by Per Bothner. +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 +Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" >&2 + exit 1 ;; + * ) + break ;; + esac +done + +if test $# != 0; then + echo "$me: too many arguments$help" >&2 + exit 1 +fi + +trap 'exit 1' 1 2 15 + +# CC_FOR_BUILD -- compiler used by this script. Note that the use of a +# compiler to aid in system detection is discouraged as it requires +# temporary files to be created and, as you can see below, it is a +# headache to deal with in a portable fashion. + +# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still +# use `HOST_CC' if defined, but it is deprecated. + +# Portable tmp directory creation inspired by the Autoconf team. + +set_cc_for_build=' +trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; +trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; +: ${TMPDIR=/tmp} ; + { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || + { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || + { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; +dummy=$tmp/dummy ; +tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; +case $CC_FOR_BUILD,$HOST_CC,$CC in + ,,) echo "int x;" > $dummy.c ; + for c in cc gcc c89 c99 ; do + if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then + CC_FOR_BUILD="$c"; break ; + fi ; + done ; + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found ; + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; +esac ; set_cc_for_build= ;' + +# This is needed to find uname on a Pyramid OSx when run in the BSD universe. +# (ghazi@noc.rutgers.edu 1994-08-24) +if (test -f /.attbin/uname) >/dev/null 2>&1 ; then + PATH=$PATH:/.attbin ; export PATH +fi + +UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown +UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown + +# Note: order is significant - the case branches are not exclusive. + +case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in + *:NetBSD:*:*) + # NetBSD (nbsd) targets should (where applicable) match one or + # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, + # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently + # switched to ELF, *-*-netbsd* would select the old + # object file format. This provides both forward + # compatibility and a consistent mechanism for selecting the + # object file format. + # + # Note: NetBSD doesn't particularly care about the vendor + # portion of the name. We always set it to "unknown". + sysctl="sysctl -n hw.machine_arch" + UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ + /usr/sbin/$sysctl 2>/dev/null || echo unknown)` + case "${UNAME_MACHINE_ARCH}" in + armeb) machine=armeb-unknown ;; + arm*) machine=arm-unknown ;; + sh3el) machine=shl-unknown ;; + sh3eb) machine=sh-unknown ;; + *) machine=${UNAME_MACHINE_ARCH}-unknown ;; + esac + # The Operating System including object format, if it has switched + # to ELF recently, or will in the future. + case "${UNAME_MACHINE_ARCH}" in + arm*|i386|m68k|ns32k|sh3*|sparc|vax) + eval $set_cc_for_build + if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep __ELF__ >/dev/null + then + # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). + # Return netbsd for either. FIX? + os=netbsd + else + os=netbsdelf + fi + ;; + *) + os=netbsd + ;; + esac + # The OS release + # Debian GNU/NetBSD machines have a different userland, and + # thus, need a distinct triplet. However, they do not need + # kernel version information, so it can be replaced with a + # suitable tag, in the style of linux-gnu. + case "${UNAME_VERSION}" in + Debian*) + release='-gnu' + ;; + *) + release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + ;; + esac + # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: + # contains redundant information, the shorter form: + # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. + echo "${machine}-${os}${release}" + exit ;; + *:OpenBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} + exit ;; + *:ekkoBSD:*:*) + echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} + exit ;; + macppc:MirBSD:*:*) + echo powerppc-unknown-mirbsd${UNAME_RELEASE} + exit ;; + *:MirBSD:*:*) + echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} + exit ;; + alpha:OSF1:*:*) + case $UNAME_RELEASE in + *4.0) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` + ;; + *5.*) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` + ;; + esac + # According to Compaq, /usr/sbin/psrinfo has been available on + # OSF/1 and Tru64 systems produced since 1995. I hope that + # covers most systems running today. This code pipes the CPU + # types through head -n 1, so we only detect the type of CPU 0. + ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` + case "$ALPHA_CPU_TYPE" in + "EV4 (21064)") + UNAME_MACHINE="alpha" ;; + "EV4.5 (21064)") + UNAME_MACHINE="alpha" ;; + "LCA4 (21066/21068)") + UNAME_MACHINE="alpha" ;; + "EV5 (21164)") + UNAME_MACHINE="alphaev5" ;; + "EV5.6 (21164A)") + UNAME_MACHINE="alphaev56" ;; + "EV5.6 (21164PC)") + UNAME_MACHINE="alphapca56" ;; + "EV5.7 (21164PC)") + UNAME_MACHINE="alphapca57" ;; + "EV6 (21264)") + UNAME_MACHINE="alphaev6" ;; + "EV6.7 (21264A)") + UNAME_MACHINE="alphaev67" ;; + "EV6.8CB (21264C)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8AL (21264B)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8CX (21264D)") + UNAME_MACHINE="alphaev68" ;; + "EV6.9A (21264/EV69A)") + UNAME_MACHINE="alphaev69" ;; + "EV7 (21364)") + UNAME_MACHINE="alphaev7" ;; + "EV7.9 (21364A)") + UNAME_MACHINE="alphaev79" ;; + esac + # A Pn.n version is a patched version. + # A Vn.n version is a released version. + # A Tn.n version is a released field test version. + # A Xn.n version is an unreleased experimental baselevel. + # 1.2 uses "1.2" for uname -r. + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + exit ;; + Alpha\ *:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # Should we change UNAME_MACHINE based on the output of uname instead + # of the specific Alpha model? + echo alpha-pc-interix + exit ;; + 21064:Windows_NT:50:3) + echo alpha-dec-winnt3.5 + exit ;; + Amiga*:UNIX_System_V:4.0:*) + echo m68k-unknown-sysv4 + exit ;; + *:[Aa]miga[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-amigaos + exit ;; + *:[Mm]orph[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-morphos + exit ;; + *:OS/390:*:*) + echo i370-ibm-openedition + exit ;; + *:z/VM:*:*) + echo s390-ibm-zvmoe + exit ;; + *:OS400:*:*) + echo powerpc-ibm-os400 + exit ;; + arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) + echo arm-acorn-riscix${UNAME_RELEASE} + exit ;; + arm:riscos:*:*|arm:RISCOS:*:*) + echo arm-unknown-riscos + exit ;; + SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) + echo hppa1.1-hitachi-hiuxmpp + exit ;; + Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) + # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. + if test "`(/bin/universe) 2>/dev/null`" = att ; then + echo pyramid-pyramid-sysv3 + else + echo pyramid-pyramid-bsd + fi + exit ;; + NILE*:*:*:dcosx) + echo pyramid-pyramid-svr4 + exit ;; + DRS?6000:unix:4.0:6*) + echo sparc-icl-nx6 + exit ;; + DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) + case `/usr/bin/uname -p` in + sparc) echo sparc-icl-nx7; exit ;; + esac ;; + sun4H:SunOS:5.*:*) + echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) + echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + i86pc:SunOS:5.*:*) + echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:6*:*) + # According to config.sub, this is the proper way to canonicalize + # SunOS6. Hard to guess exactly what SunOS6 will be like, but + # it's likely to be more like Solaris than SunOS4. + echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:*:*) + case "`/usr/bin/arch -k`" in + Series*|S4*) + UNAME_RELEASE=`uname -v` + ;; + esac + # Japanese Language versions have a version number like `4.1.3-JL'. + echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + exit ;; + sun3*:SunOS:*:*) + echo m68k-sun-sunos${UNAME_RELEASE} + exit ;; + sun*:*:4.2BSD:*) + UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 + case "`/bin/arch`" in + sun3) + echo m68k-sun-sunos${UNAME_RELEASE} + ;; + sun4) + echo sparc-sun-sunos${UNAME_RELEASE} + ;; + esac + exit ;; + aushp:SunOS:*:*) + echo sparc-auspex-sunos${UNAME_RELEASE} + exit ;; + # The situation for MiNT is a little confusing. The machine name + # can be virtually everything (everything which is not + # "atarist" or "atariste" at least should have a processor + # > m68000). The system name ranges from "MiNT" over "FreeMiNT" + # to the lowercase version "mint" (or "freemint"). Finally + # the system name "TOS" denotes a system which is actually not + # MiNT. But MiNT is downward compatible to TOS, so this should + # be no problem. + atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) + echo m68k-milan-mint${UNAME_RELEASE} + exit ;; + hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) + echo m68k-hades-mint${UNAME_RELEASE} + exit ;; + *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) + echo m68k-unknown-mint${UNAME_RELEASE} + exit ;; + m68k:machten:*:*) + echo m68k-apple-machten${UNAME_RELEASE} + exit ;; + powerpc:machten:*:*) + echo powerpc-apple-machten${UNAME_RELEASE} + exit ;; + RISC*:Mach:*:*) + echo mips-dec-mach_bsd4.3 + exit ;; + RISC*:ULTRIX:*:*) + echo mips-dec-ultrix${UNAME_RELEASE} + exit ;; + VAX*:ULTRIX*:*:*) + echo vax-dec-ultrix${UNAME_RELEASE} + exit ;; + 2020:CLIX:*:* | 2430:CLIX:*:*) + echo clipper-intergraph-clix${UNAME_RELEASE} + exit ;; + mips:*:*:UMIPS | mips:*:*:RISCos) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c +#ifdef __cplusplus +#include <stdio.h> /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif + #if defined (host_mips) && defined (MIPSEB) + #if defined (SYSTYPE_SYSV) + printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_SVR4) + printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) + printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + #endif + #endif + exit (-1); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && + dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && + SYSTEM_NAME=`$dummy $dummyarg` && + { echo "$SYSTEM_NAME"; exit; } + echo mips-mips-riscos${UNAME_RELEASE} + exit ;; + Motorola:PowerMAX_OS:*:*) + echo powerpc-motorola-powermax + exit ;; + Motorola:*:4.3:PL8-*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:Power_UNIX:*:*) + echo powerpc-harris-powerunix + exit ;; + m88k:CX/UX:7*:*) + echo m88k-harris-cxux7 + exit ;; + m88k:*:4*:R4*) + echo m88k-motorola-sysv4 + exit ;; + m88k:*:3*:R3*) + echo m88k-motorola-sysv3 + exit ;; + AViiON:dgux:*:*) + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` + if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + then + if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ + [ ${TARGET_BINARY_INTERFACE}x = x ] + then + echo m88k-dg-dgux${UNAME_RELEASE} + else + echo m88k-dg-dguxbcs${UNAME_RELEASE} + fi + else + echo i586-dg-dgux${UNAME_RELEASE} + fi + exit ;; + M88*:DolphinOS:*:*) # DolphinOS (SVR3) + echo m88k-dolphin-sysv3 + exit ;; + M88*:*:R3*:*) + # Delta 88k system running SVR3 + echo m88k-motorola-sysv3 + exit ;; + XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) + echo m88k-tektronix-sysv3 + exit ;; + Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) + echo m68k-tektronix-bsd + exit ;; + *:IRIX*:*:*) + echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + exit ;; + ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. + echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id + exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + i*86:AIX:*:*) + echo i386-ibm-aix + exit ;; + ia64:AIX:*:*) + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} + exit ;; + *:AIX:2:3) + if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include <sys/systemcfg.h> + + main() + { + if (!__power_pc()) + exit(1); + puts("powerpc-ibm-aix3.2.5"); + exit(0); + } +EOF + if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` + then + echo "$SYSTEM_NAME" + else + echo rs6000-ibm-aix3.2.5 + fi + elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then + echo rs6000-ibm-aix3.2.4 + else + echo rs6000-ibm-aix3.2 + fi + exit ;; + *:AIX:*:[45]) + IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` + if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then + IBM_ARCH=rs6000 + else + IBM_ARCH=powerpc + fi + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${IBM_ARCH}-ibm-aix${IBM_REV} + exit ;; + *:AIX:*:*) + echo rs6000-ibm-aix + exit ;; + ibmrt:4.4BSD:*|romp-ibm:BSD:*) + echo romp-ibm-bsd4.4 + exit ;; + ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and + echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + exit ;; # report: romp-ibm BSD 4.3 + *:BOSX:*:*) + echo rs6000-bull-bosx + exit ;; + DPX/2?00:B.O.S.:*:*) + echo m68k-bull-sysv3 + exit ;; + 9000/[34]??:4.3bsd:1.*:*) + echo m68k-hp-bsd + exit ;; + hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) + echo m68k-hp-bsd4.4 + exit ;; + 9000/[34678]??:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + case "${UNAME_MACHINE}" in + 9000/31? ) HP_ARCH=m68000 ;; + 9000/[34]?? ) HP_ARCH=m68k ;; + 9000/[678][0-9][0-9]) + if [ -x /usr/bin/getconf ]; then + sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case "${sc_cpu_version}" in + 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 + 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case "${sc_kernel_bits}" in + 32) HP_ARCH="hppa2.0n" ;; + 64) HP_ARCH="hppa2.0w" ;; + '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 + esac ;; + esac + fi + if [ "${HP_ARCH}" = "" ]; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + + #define _HPUX_SOURCE + #include <stdlib.h> + #include <unistd.h> + + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); + + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } +EOF + (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + test -z "$HP_ARCH" && HP_ARCH=hppa + fi ;; + esac + if [ ${HP_ARCH} = "hppa2.0w" ] + then + eval $set_cc_for_build + + # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating + # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler + # generating 64-bit code. GNU and HP use different nomenclature: + # + # $ CC_FOR_BUILD=cc ./config.guess + # => hppa2.0w-hp-hpux11.23 + # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess + # => hppa64-hp-hpux11.23 + + if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | + grep __LP64__ >/dev/null + then + HP_ARCH="hppa2.0w" + else + HP_ARCH="hppa64" + fi + fi + echo ${HP_ARCH}-hp-hpux${HPUX_REV} + exit ;; + ia64:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + echo ia64-hp-hpux${HPUX_REV} + exit ;; + 3050*:HI-UX:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include <unistd.h> + int + main () + { + long cpu = sysconf (_SC_CPU_VERSION); + /* The order matters, because CPU_IS_HP_MC68K erroneously returns + true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct + results, however. */ + if (CPU_IS_PA_RISC (cpu)) + { + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; + case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; + default: puts ("hppa-hitachi-hiuxwe2"); break; + } + } + else if (CPU_IS_HP_MC68K (cpu)) + puts ("m68k-hitachi-hiuxwe2"); + else puts ("unknown-hitachi-hiuxwe2"); + exit (0); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } + echo unknown-hitachi-hiuxwe2 + exit ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) + echo hppa1.1-hp-bsd + exit ;; + 9000/8??:4.3bsd:*:*) + echo hppa1.0-hp-bsd + exit ;; + *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) + echo hppa1.0-hp-mpeix + exit ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) + echo hppa1.1-hp-osf + exit ;; + hp8??:OSF1:*:*) + echo hppa1.0-hp-osf + exit ;; + i*86:OSF1:*:*) + if [ -x /usr/sbin/sysversion ] ; then + echo ${UNAME_MACHINE}-unknown-osf1mk + else + echo ${UNAME_MACHINE}-unknown-osf1 + fi + exit ;; + parisc*:Lites*:*:*) + echo hppa1.1-hp-lites + exit ;; + C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) + echo c1-convex-bsd + exit ;; + C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit ;; + C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) + echo c34-convex-bsd + exit ;; + C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) + echo c38-convex-bsd + exit ;; + C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) + echo c4-convex-bsd + exit ;; + CRAY*Y-MP:*:*:*) + echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*[A-Z]90:*:*:*) + echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ + -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ + -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*TS:*:*:*) + echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*T3E:*:*:*) + echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*SV1:*:*:*) + echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + *:UNICOS/mp:*:*) + echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) + FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; + 5000:UNIX_System_V:4.*:*) + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` + echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; + i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) + echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} + exit ;; + sparc*:BSD/OS:*:*) + echo sparc-unknown-bsdi${UNAME_RELEASE} + exit ;; + *:BSD/OS:*:*) + echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} + exit ;; + *:FreeBSD:*:*) + echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + exit ;; + i*:CYGWIN*:*) + echo ${UNAME_MACHINE}-pc-cygwin + exit ;; + i*:MINGW*:*) + echo ${UNAME_MACHINE}-pc-mingw32 + exit ;; + i*:windows32*:*) + # uname -m includes "-pc" on this system. + echo ${UNAME_MACHINE}-mingw32 + exit ;; + i*:PW*:*) + echo ${UNAME_MACHINE}-pc-pw32 + exit ;; + x86:Interix*:[34]*) + echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//' + exit ;; + [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) + echo i${UNAME_MACHINE}-pc-mks + exit ;; + i*:Windows_NT*:* | Pentium*:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we + # UNAME_MACHINE based on the output of uname instead of i386? + echo i586-pc-interix + exit ;; + i*:UWIN*:*) + echo ${UNAME_MACHINE}-pc-uwin + exit ;; + amd64:CYGWIN*:*:*) + echo x86_64-unknown-cygwin + exit ;; + p*:CYGWIN*:*) + echo powerpcle-unknown-cygwin + exit ;; + prep*:SunOS:5.*:*) + echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + *:GNU:*:*) + # the GNU system + echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + exit ;; + *:GNU/*:*:*) + # other systems with GNU libc and userland + echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu + exit ;; + i*86:Minix:*:*) + echo ${UNAME_MACHINE}-pc-minix + exit ;; + arm*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + cris:Linux:*:*) + echo cris-axis-linux-gnu + exit ;; + crisv32:Linux:*:*) + echo crisv32-axis-linux-gnu + exit ;; + frv:Linux:*:*) + echo frv-unknown-linux-gnu + exit ;; + ia64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + m32r*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + m68*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + mips:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef mips + #undef mipsel + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=mipsel + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=mips + #else + CPU= + #endif + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` + test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } + ;; + mips64:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef mips64 + #undef mips64el + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=mips64el + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=mips64 + #else + CPU= + #endif + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` + test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } + ;; + ppc:Linux:*:*) + echo powerpc-unknown-linux-gnu + exit ;; + ppc64:Linux:*:*) + echo powerpc64-unknown-linux-gnu + exit ;; + alpha:Linux:*:*) + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + EV5) UNAME_MACHINE=alphaev5 ;; + EV56) UNAME_MACHINE=alphaev56 ;; + PCA56) UNAME_MACHINE=alphapca56 ;; + PCA57) UNAME_MACHINE=alphapca56 ;; + EV6) UNAME_MACHINE=alphaev6 ;; + EV67) UNAME_MACHINE=alphaev67 ;; + EV68*) UNAME_MACHINE=alphaev68 ;; + esac + objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null + if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi + echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} + exit ;; + parisc:Linux:*:* | hppa:Linux:*:*) + # Look for CPU level + case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in + PA7*) echo hppa1.1-unknown-linux-gnu ;; + PA8*) echo hppa2.0-unknown-linux-gnu ;; + *) echo hppa-unknown-linux-gnu ;; + esac + exit ;; + parisc64:Linux:*:* | hppa64:Linux:*:*) + echo hppa64-unknown-linux-gnu + exit ;; + s390:Linux:*:* | s390x:Linux:*:*) + echo ${UNAME_MACHINE}-ibm-linux + exit ;; + sh64*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + sh*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + sparc:Linux:*:* | sparc64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + x86_64:Linux:*:*) + echo x86_64-unknown-linux-gnu + exit ;; + i*86:Linux:*:*) + # The BFD linker knows what the default object file format is, so + # first see if it will tell us. cd to the root directory to prevent + # problems with other programs or directories called `ld' in the path. + # Set LC_ALL=C to ensure ld outputs messages in English. + ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ + | sed -ne '/supported targets:/!d + s/[ ][ ]*/ /g + s/.*supported targets: *// + s/ .*// + p'` + case "$ld_supported_targets" in + elf32-i386) + TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" + ;; + a.out-i386-linux) + echo "${UNAME_MACHINE}-pc-linux-gnuaout" + exit ;; + coff-i386) + echo "${UNAME_MACHINE}-pc-linux-gnucoff" + exit ;; + "") + # Either a pre-BFD a.out linker (linux-gnuoldld) or + # one that does not give us useful --help. + echo "${UNAME_MACHINE}-pc-linux-gnuoldld" + exit ;; + esac + # Determine whether the default compiler is a.out or elf + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include <features.h> + #ifdef __ELF__ + # ifdef __GLIBC__ + # if __GLIBC__ >= 2 + LIBC=gnu + # else + LIBC=gnulibc1 + # endif + # else + LIBC=gnulibc1 + # endif + #else + #ifdef __INTEL_COMPILER + LIBC=gnu + #else + LIBC=gnuaout + #endif + #endif + #ifdef __dietlibc__ + LIBC=dietlibc + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` + test x"${LIBC}" != x && { + echo "${UNAME_MACHINE}-pc-linux-${LIBC}" + exit + } + test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; } + ;; + i*86:DYNIX/ptx:4*:*) + # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. + # earlier versions are messed up and put the nodename in both + # sysname and nodename. + echo i386-sequent-sysv4 + exit ;; + i*86:UNIX_SV:4.2MP:2.*) + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, + # I just have to hope. -- rms. + # Use sysv4.2uw... so that sysv4* matches it. + echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + exit ;; + i*86:OS/2:*:*) + # If we were able to find `uname', then EMX Unix compatibility + # is probably installed. + echo ${UNAME_MACHINE}-pc-os2-emx + exit ;; + i*86:XTS-300:*:STOP) + echo ${UNAME_MACHINE}-unknown-stop + exit ;; + i*86:atheos:*:*) + echo ${UNAME_MACHINE}-unknown-atheos + exit ;; + i*86:syllable:*:*) + echo ${UNAME_MACHINE}-pc-syllable + exit ;; + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) + echo i386-unknown-lynxos${UNAME_RELEASE} + exit ;; + i*86:*DOS:*:*) + echo ${UNAME_MACHINE}-pc-msdosdjgpp + exit ;; + i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) + UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then + echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} + else + echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + fi + exit ;; + i*86:*:5:[678]*) + # UnixWare 7.x, OpenUNIX and OpenServer 6. + case `/bin/uname -X | grep "^Machine"` in + *486*) UNAME_MACHINE=i486 ;; + *Pentium) UNAME_MACHINE=i586 ;; + *Pent*|*Celeron) UNAME_MACHINE=i686 ;; + esac + echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + exit ;; + i*86:*:3.2:*) + if test -f /usr/options/cb.name; then + UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name` + echo ${UNAME_MACHINE}-pc-isc$UNAME_REL + elif /bin/uname -X 2>/dev/null >/dev/null ; then + UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` + (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ + && UNAME_MACHINE=i586 + (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ + && UNAME_MACHINE=i686 + (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ + && UNAME_MACHINE=i686 + echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + else + echo ${UNAME_MACHINE}-pc-sysv32 + fi + exit ;; + pc:*:*:*) + # Left here for compatibility: + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i386. + echo i386-pc-msdosdjgpp + exit ;; + Intel:Mach:3*:*) + echo i386-pc-mach3 + exit ;; + paragon:*:*:*) + echo i860-intel-osf1 + exit ;; + i860:*:4.*:*) # i860-SVR4 + if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then + echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + else # Add other i860-SVR4 vendors below as they are discovered. + echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + fi + exit ;; + mini*:CTIX:SYS*5:*) + # "miniframe" + echo m68010-convergent-sysv + exit ;; + mc68k:UNIX:SYSTEM5:3.51m) + echo m68k-convergent-sysv + exit ;; + M680?0:D-NIX:5.3:*) + echo m68k-diab-dnix + exit ;; + M68*:*:R3V[5678]*:*) + test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; + 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) + OS_REL='' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4; exit; } ;; + m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) + echo m68k-unknown-lynxos${UNAME_RELEASE} + exit ;; + mc68030:UNIX_System_V:4.*:*) + echo m68k-atari-sysv4 + exit ;; + TSUNAMI:LynxOS:2.*:*) + echo sparc-unknown-lynxos${UNAME_RELEASE} + exit ;; + rs6000:LynxOS:2.*:*) + echo rs6000-unknown-lynxos${UNAME_RELEASE} + exit ;; + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) + echo powerpc-unknown-lynxos${UNAME_RELEASE} + exit ;; + SM[BE]S:UNIX_SV:*:*) + echo mips-dde-sysv${UNAME_RELEASE} + exit ;; + RM*:ReliantUNIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + RM*:SINIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + *:SINIX-*:*:*) + if uname -p 2>/dev/null >/dev/null ; then + UNAME_MACHINE=`(uname -p) 2>/dev/null` + echo ${UNAME_MACHINE}-sni-sysv4 + else + echo ns32k-sni-sysv + fi + exit ;; + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says <Richard.M.Bartel@ccMail.Census.GOV> + echo i586-unisys-sysv4 + exit ;; + *:UNIX_System_V:4*:FTX*) + # From Gerald Hewes <hewes@openmarket.com>. + # How about differentiating between stratus architectures? -djm + echo hppa1.1-stratus-sysv4 + exit ;; + *:*:*:FTX*) + # From seanf@swdc.stratus.com. + echo i860-stratus-sysv4 + exit ;; + i*86:VOS:*:*) + # From Paul.Green@stratus.com. + echo ${UNAME_MACHINE}-stratus-vos + exit ;; + *:VOS:*:*) + # From Paul.Green@stratus.com. + echo hppa1.1-stratus-vos + exit ;; + mc68*:A/UX:*:*) + echo m68k-apple-aux${UNAME_RELEASE} + exit ;; + news*:NEWS-OS:6*:*) + echo mips-sony-newsos6 + exit ;; + R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) + if [ -d /usr/nec ]; then + echo mips-nec-sysv${UNAME_RELEASE} + else + echo mips-unknown-sysv${UNAME_RELEASE} + fi + exit ;; + BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. + echo powerpc-be-beos + exit ;; + BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. + echo powerpc-apple-beos + exit ;; + BePC:BeOS:*:*) # BeOS running on Intel PC compatible. + echo i586-pc-beos + exit ;; + SX-4:SUPER-UX:*:*) + echo sx4-nec-superux${UNAME_RELEASE} + exit ;; + SX-5:SUPER-UX:*:*) + echo sx5-nec-superux${UNAME_RELEASE} + exit ;; + SX-6:SUPER-UX:*:*) + echo sx6-nec-superux${UNAME_RELEASE} + exit ;; + Power*:Rhapsody:*:*) + echo powerpc-apple-rhapsody${UNAME_RELEASE} + exit ;; + *:Rhapsody:*:*) + echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} + exit ;; + *:Darwin:*:*) + UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown + case $UNAME_PROCESSOR in + *86) UNAME_PROCESSOR=i686 ;; + unknown) UNAME_PROCESSOR=powerpc ;; + esac + echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} + exit ;; + *:procnto*:*:* | *:QNX:[0123456789]*:*) + UNAME_PROCESSOR=`uname -p` + if test "$UNAME_PROCESSOR" = "x86"; then + UNAME_PROCESSOR=i386 + UNAME_MACHINE=pc + fi + echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} + exit ;; + *:QNX:*:4*) + echo i386-pc-qnx + exit ;; + NSE-?:NONSTOP_KERNEL:*:*) + echo nse-tandem-nsk${UNAME_RELEASE} + exit ;; + NSR-?:NONSTOP_KERNEL:*:*) + echo nsr-tandem-nsk${UNAME_RELEASE} + exit ;; + *:NonStop-UX:*:*) + echo mips-compaq-nonstopux + exit ;; + BS2000:POSIX*:*:*) + echo bs2000-siemens-sysv + exit ;; + DS/*:UNIX_System_V:*:*) + echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} + exit ;; + *:Plan9:*:*) + # "uname -m" is not consistent, so use $cputype instead. 386 + # is converted to i386 for consistency with other x86 + # operating systems. + if test "$cputype" = "386"; then + UNAME_MACHINE=i386 + else + UNAME_MACHINE="$cputype" + fi + echo ${UNAME_MACHINE}-unknown-plan9 + exit ;; + *:TOPS-10:*:*) + echo pdp10-unknown-tops10 + exit ;; + *:TENEX:*:*) + echo pdp10-unknown-tenex + exit ;; + KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) + echo pdp10-dec-tops20 + exit ;; + XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) + echo pdp10-xkl-tops20 + exit ;; + *:TOPS-20:*:*) + echo pdp10-unknown-tops20 + exit ;; + *:ITS:*:*) + echo pdp10-unknown-its + exit ;; + SEI:*:*:SEIUX) + echo mips-sei-seiux${UNAME_RELEASE} + exit ;; + *:DragonFly:*:*) + echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + exit ;; + *:*VMS:*:*) + UNAME_MACHINE=`(uname -p) 2>/dev/null` + case "${UNAME_MACHINE}" in + A*) echo alpha-dec-vms ; exit ;; + I*) echo ia64-dec-vms ; exit ;; + V*) echo vax-dec-vms ; exit ;; + esac ;; + *:XENIX:*:SysV) + echo i386-pc-xenix + exit ;; + i*86:skyos:*:*) + echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' + exit ;; +esac + +#echo '(No uname command or uname output not recognized.)' 1>&2 +#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 + +eval $set_cc_for_build +cat >$dummy.c <<EOF +#ifdef _SEQUENT_ +# include <sys/types.h> +# include <sys/utsname.h> +#endif +main () +{ +#if defined (sony) +#if defined (MIPSEB) + /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, + I don't know.... */ + printf ("mips-sony-bsd\n"); exit (0); +#else +#include <sys/param.h> + printf ("m68k-sony-newsos%s\n", +#ifdef NEWSOS4 + "4" +#else + "" +#endif + ); exit (0); +#endif +#endif + +#if defined (__arm) && defined (__acorn) && defined (__unix) + printf ("arm-acorn-riscix\n"); exit (0); +#endif + +#if defined (hp300) && !defined (hpux) + printf ("m68k-hp-bsd\n"); exit (0); +#endif + +#if defined (NeXT) +#if !defined (__ARCHITECTURE__) +#define __ARCHITECTURE__ "m68k" +#endif + int version; + version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; + if (version < 4) + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); + else + printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); + exit (0); +#endif + +#if defined (MULTIMAX) || defined (n16) +#if defined (UMAXV) + printf ("ns32k-encore-sysv\n"); exit (0); +#else +#if defined (CMU) + printf ("ns32k-encore-mach\n"); exit (0); +#else + printf ("ns32k-encore-bsd\n"); exit (0); +#endif +#endif +#endif + +#if defined (__386BSD__) + printf ("i386-pc-bsd\n"); exit (0); +#endif + +#if defined (sequent) +#if defined (i386) + printf ("i386-sequent-dynix\n"); exit (0); +#endif +#if defined (ns32000) + printf ("ns32k-sequent-dynix\n"); exit (0); +#endif +#endif + +#if defined (_SEQUENT_) + struct utsname un; + + uname(&un); + + if (strncmp(un.version, "V2", 2) == 0) { + printf ("i386-sequent-ptx2\n"); exit (0); + } + if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ + printf ("i386-sequent-ptx1\n"); exit (0); + } + printf ("i386-sequent-ptx\n"); exit (0); + +#endif + +#if defined (vax) +# if !defined (ultrix) +# include <sys/param.h> +# if defined (BSD) +# if BSD == 43 + printf ("vax-dec-bsd4.3\n"); exit (0); +# else +# if BSD == 199006 + printf ("vax-dec-bsd4.3reno\n"); exit (0); +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# endif +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# else + printf ("vax-dec-ultrix\n"); exit (0); +# endif +#endif + +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); +#endif + + exit (1); +} +EOF + +$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } + +# Apollos put the system type in the environment. + +test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } + +# Convex versions that predate uname can use getsysinfo(1) + +if [ -x /usr/convex/getsysinfo ] +then + case `getsysinfo -f cpu_type` in + c1*) + echo c1-convex-bsd + exit ;; + c2*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit ;; + c34*) + echo c34-convex-bsd + exit ;; + c38*) + echo c38-convex-bsd + exit ;; + c4*) + echo c4-convex-bsd + exit ;; + esac +fi + +cat >&2 <<EOF +$0: unable to guess system type + +This script, last modified $timestamp, has failed to recognize +the operating system you are using. It is advised that you +download the most up to date version of the config scripts from + + http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.guess +and + http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.sub + +If the version you run ($0) is already up to date, please +send the following data and any information you think might be +pertinent to <config-patches@gnu.org> in order to provide the needed +information to handle your system. + +config.guess timestamp = $timestamp + +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null` + +hostinfo = `(hostinfo) 2>/dev/null` +/bin/universe = `(/bin/universe) 2>/dev/null` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` +/bin/arch = `(/bin/arch) 2>/dev/null` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` + +UNAME_MACHINE = ${UNAME_MACHINE} +UNAME_RELEASE = ${UNAME_RELEASE} +UNAME_SYSTEM = ${UNAME_SYSTEM} +UNAME_VERSION = ${UNAME_VERSION} +EOF + +exit 1 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/autoaux/config.sub b/autoaux/config.sub new file mode 100755 index 0000000..1c366df --- /dev/null +++ b/autoaux/config.sub @@ -0,0 +1,1579 @@ +#! /bin/sh +# Configuration validation subroutine script. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. + +timestamp='2005-07-08' + +# This file is (in principle) common to ALL GNU software. +# The presence of a machine in this file suggests that SOME GNU software +# can handle that machine. It does not imply ALL GNU software can. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA +# 02110-1301, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + + +# Please send patches to <config-patches@gnu.org>. Submit a context +# diff and a properly formatted ChangeLog entry. +# +# Configuration subroutine to validate and canonicalize a configuration type. +# Supply the specified configuration type as an argument. +# If it is invalid, we print an error message on stderr and exit with code 1. +# Otherwise, we print the canonical config type on stdout and succeed. + +# This file is supposed to be the same for all GNU packages +# and recognize all the CPU types, system types and aliases +# that are meaningful with *any* GNU software. +# Each package is responsible for reporting which valid configurations +# it does not support. The user should be able to distinguish +# a failure to support a valid configuration from a meaningless +# configuration. + +# The goal of this file is to map all the various variations of a given +# machine specification into a single specification in the form: +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or in some cases, the newer four-part form: +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# It is wrong to echo any other type of specification. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] CPU-MFR-OPSYS + $0 [OPTION] ALIAS + +Canonicalize a configuration name. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to <config-patches@gnu.org>." + +version="\ +GNU config.sub ($timestamp) + +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 +Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" + exit 1 ;; + + *local*) + # First pass through any local machine types. + echo $1 + exit ;; + + * ) + break ;; + esac +done + +case $# in + 0) echo "$me: missing argument$help" >&2 + exit 1;; + 1) ;; + *) echo "$me: too many arguments$help" >&2 + exit 1;; +esac + +# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). +# Here we must recognize all the valid KERNEL-OS combinations. +maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` +case $maybe_os in + nto-qnx* | linux-gnu* | linux-dietlibc | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | \ + kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*) + os=-$maybe_os + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` + ;; + *) + basic_machine=`echo $1 | sed 's/-[^-]*$//'` + if [ $basic_machine != $1 ] + then os=`echo $1 | sed 's/.*-/-/'` + else os=; fi + ;; +esac + +### Let's recognize common machines as not being operating systems so +### that things like config.sub decstation-3100 work. We also +### recognize some manufacturers as not being operating systems, so we +### can provide default operating systems below. +case $os in + -sun*os*) + # Prevent following clause from handling this invalid input. + ;; + -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ + -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ + -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ + -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ + -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ + -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ + -apple | -axis | -knuth | -cray) + os= + basic_machine=$1 + ;; + -sim | -cisco | -oki | -wec | -winbond) + os= + basic_machine=$1 + ;; + -scout) + ;; + -wrs) + os=-vxworks + basic_machine=$1 + ;; + -chorusos*) + os=-chorusos + basic_machine=$1 + ;; + -chorusrdb) + os=-chorusrdb + basic_machine=$1 + ;; + -hiux*) + os=-hiuxwe2 + ;; + -sco5) + os=-sco3.2v5 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco4) + os=-sco3.2v4 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2.[4-9]*) + os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2v[4-9]*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco*) + os=-sco3.2v2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -udk*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -isc) + os=-isc2.2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -clix*) + basic_machine=clipper-intergraph + ;; + -isc*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -lynx*) + os=-lynxos + ;; + -ptx*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + ;; + -windowsnt*) + os=`echo $os | sed -e 's/windowsnt/winnt/'` + ;; + -psos*) + os=-psos + ;; + -mint | -mint[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; +esac + +# Decode aliases for certain CPU-COMPANY combinations. +case $basic_machine in + # Recognize the basic CPU types without company name. + # Some are omitted here because they have special meanings below. + 1750a | 580 \ + | a29k \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ + | am33_2.0 \ + | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ + | bfin \ + | c4x | clipper \ + | d10v | d30v | dlx | dsp16xx \ + | fr30 | frv \ + | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | i370 | i860 | i960 | ia64 \ + | ip2k | iq2000 \ + | m32r | m32rle | m68000 | m68k | m88k | maxq | mcore \ + | mips | mipsbe | mipseb | mipsel | mipsle \ + | mips16 \ + | mips64 | mips64el \ + | mips64vr | mips64vrel \ + | mips64orion | mips64orionel \ + | mips64vr4100 | mips64vr4100el \ + | mips64vr4300 | mips64vr4300el \ + | mips64vr5000 | mips64vr5000el \ + | mips64vr5900 | mips64vr5900el \ + | mipsisa32 | mipsisa32el \ + | mipsisa32r2 | mipsisa32r2el \ + | mipsisa64 | mipsisa64el \ + | mipsisa64r2 | mipsisa64r2el \ + | mipsisa64sb1 | mipsisa64sb1el \ + | mipsisa64sr71k | mipsisa64sr71kel \ + | mipstx39 | mipstx39el \ + | mn10200 | mn10300 \ + | ms1 \ + | msp430 \ + | ns16k | ns32k \ + | or32 \ + | pdp10 | pdp11 | pj | pjl \ + | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ + | pyramid \ + | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \ + | sh64 | sh64le \ + | sparc | sparc64 | sparc64b | sparc86x | sparclet | sparclite \ + | sparcv8 | sparcv9 | sparcv9b \ + | strongarm \ + | tahoe | thumb | tic4x | tic80 | tron \ + | v850 | v850e \ + | we32k \ + | x86 | xscale | xscalee[bl] | xstormy16 | xtensa \ + | z8k) + basic_machine=$basic_machine-unknown + ;; + m32c) + basic_machine=$basic_machine-unknown + ;; + m6811 | m68hc11 | m6812 | m68hc12) + # Motorola 68HC11/12. + basic_machine=$basic_machine-unknown + os=-none + ;; + m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) + ;; + + # We use `pc' rather than `unknown' + # because (1) that's what they normally are, and + # (2) the word "unknown" tends to confuse beginning users. + i*86 | x86_64) + basic_machine=$basic_machine-pc + ;; + # Object if more than one company name word. + *-*-*) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; + # Recognize the basic CPU types with company name. + 580-* \ + | a29k-* \ + | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ + | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ + | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ + | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ + | avr-* \ + | bfin-* | bs2000-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ + | clipper-* | craynv-* | cydra-* \ + | d10v-* | d30v-* | dlx-* \ + | elxsi-* \ + | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \ + | h8300-* | h8500-* \ + | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ + | i*86-* | i860-* | i960-* | ia64-* \ + | ip2k-* | iq2000-* \ + | m32r-* | m32rle-* \ + | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ + | m88110-* | m88k-* | maxq-* | mcore-* \ + | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ + | mips16-* \ + | mips64-* | mips64el-* \ + | mips64vr-* | mips64vrel-* \ + | mips64orion-* | mips64orionel-* \ + | mips64vr4100-* | mips64vr4100el-* \ + | mips64vr4300-* | mips64vr4300el-* \ + | mips64vr5000-* | mips64vr5000el-* \ + | mips64vr5900-* | mips64vr5900el-* \ + | mipsisa32-* | mipsisa32el-* \ + | mipsisa32r2-* | mipsisa32r2el-* \ + | mipsisa64-* | mipsisa64el-* \ + | mipsisa64r2-* | mipsisa64r2el-* \ + | mipsisa64sb1-* | mipsisa64sb1el-* \ + | mipsisa64sr71k-* | mipsisa64sr71kel-* \ + | mipstx39-* | mipstx39el-* \ + | mmix-* \ + | ms1-* \ + | msp430-* \ + | none-* | np1-* | ns16k-* | ns32k-* \ + | orion-* \ + | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ + | pyramid-* \ + | romp-* | rs6000-* \ + | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | shbe-* \ + | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ + | sparc-* | sparc64-* | sparc64b-* | sparc86x-* | sparclet-* \ + | sparclite-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \ + | tahoe-* | thumb-* \ + | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ + | tron-* \ + | v850-* | v850e-* | vax-* \ + | we32k-* \ + | x86-* | x86_64-* | xps100-* | xscale-* | xscalee[bl]-* \ + | xstormy16-* | xtensa-* \ + | ymp-* \ + | z8k-*) + ;; + m32c-*) + ;; + # Recognize the various machine names and aliases which stand + # for a CPU type and a company and sometimes even an OS. + 386bsd) + basic_machine=i386-unknown + os=-bsd + ;; + 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) + basic_machine=m68000-att + ;; + 3b*) + basic_machine=we32k-att + ;; + a29khif) + basic_machine=a29k-amd + os=-udi + ;; + abacus) + basic_machine=abacus-unknown + ;; + adobe68k) + basic_machine=m68010-adobe + os=-scout + ;; + alliant | fx80) + basic_machine=fx80-alliant + ;; + altos | altos3068) + basic_machine=m68k-altos + ;; + am29k) + basic_machine=a29k-none + os=-bsd + ;; + amd64) + basic_machine=x86_64-pc + ;; + amd64-*) + basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + amdahl) + basic_machine=580-amdahl + os=-sysv + ;; + amiga | amiga-*) + basic_machine=m68k-unknown + ;; + amigaos | amigados) + basic_machine=m68k-unknown + os=-amigaos + ;; + amigaunix | amix) + basic_machine=m68k-unknown + os=-sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + os=-sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + os=-bsd + ;; + aux) + basic_machine=m68k-apple + os=-aux + ;; + balance) + basic_machine=ns32k-sequent + os=-dynix + ;; + c90) + basic_machine=c90-cray + os=-unicos + ;; + convex-c1) + basic_machine=c1-convex + os=-bsd + ;; + convex-c2) + basic_machine=c2-convex + os=-bsd + ;; + convex-c32) + basic_machine=c32-convex + os=-bsd + ;; + convex-c34) + basic_machine=c34-convex + os=-bsd + ;; + convex-c38) + basic_machine=c38-convex + os=-bsd + ;; + cray | j90) + basic_machine=j90-cray + os=-unicos + ;; + craynv) + basic_machine=craynv-cray + os=-unicosmp + ;; + cr16c) + basic_machine=cr16c-unknown + os=-elf + ;; + crds | unos) + basic_machine=m68k-crds + ;; + crisv32 | crisv32-* | etraxfs*) + basic_machine=crisv32-axis + ;; + cris | cris-* | etrax*) + basic_machine=cris-axis + ;; + crx) + basic_machine=crx-unknown + os=-elf + ;; + da30 | da30-*) + basic_machine=m68k-da30 + ;; + decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) + basic_machine=mips-dec + ;; + decsystem10* | dec10*) + basic_machine=pdp10-dec + os=-tops10 + ;; + decsystem20* | dec20*) + basic_machine=pdp10-dec + os=-tops20 + ;; + delta | 3300 | motorola-3300 | motorola-delta \ + | 3300-motorola | delta-motorola) + basic_machine=m68k-motorola + ;; + delta88) + basic_machine=m88k-motorola + os=-sysv3 + ;; + djgpp) + basic_machine=i586-pc + os=-msdosdjgpp + ;; + dpx20 | dpx20-*) + basic_machine=rs6000-bull + os=-bosx + ;; + dpx2* | dpx2*-bull) + basic_machine=m68k-bull + os=-sysv3 + ;; + ebmon29k) + basic_machine=a29k-amd + os=-ebmon + ;; + elxsi) + basic_machine=elxsi-elxsi + os=-bsd + ;; + encore | umax | mmax) + basic_machine=ns32k-encore + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + os=-ose + ;; + fx2800) + basic_machine=i860-alliant + ;; + genix) + basic_machine=ns32k-ns + ;; + gmicro) + basic_machine=tron-gmicro + os=-sysv + ;; + go32) + basic_machine=i386-pc + os=-go32 + ;; + h3050r* | hiux*) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + h8300hms) + basic_machine=h8300-hitachi + os=-hms + ;; + h8300xray) + basic_machine=h8300-hitachi + os=-xray + ;; + h8500hms) + basic_machine=h8500-hitachi + os=-hms + ;; + harris) + basic_machine=m88k-harris + os=-sysv3 + ;; + hp300-*) + basic_machine=m68k-hp + ;; + hp300bsd) + basic_machine=m68k-hp + os=-bsd + ;; + hp300hpux) + basic_machine=m68k-hp + os=-hpux + ;; + hp3k9[0-9][0-9] | hp9[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k2[0-9][0-9] | hp9k31[0-9]) + basic_machine=m68000-hp + ;; + hp9k3[2-9][0-9]) + basic_machine=m68k-hp + ;; + hp9k6[0-9][0-9] | hp6[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k7[0-79][0-9] | hp7[0-79][0-9]) + basic_machine=hppa1.1-hp + ;; + hp9k78[0-9] | hp78[0-9]) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][13679] | hp8[0-9][13679]) + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][0-9] | hp8[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hppa-next) + os=-nextstep3 + ;; + hppaosf) + basic_machine=hppa1.1-hp + os=-osf + ;; + hppro) + basic_machine=hppa1.1-hp + os=-proelf + ;; + i370-ibm* | ibm*) + basic_machine=i370-ibm + ;; +# I'm not sure what "Sysv32" means. Should this be sysv3.2? + i*86v32) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv32 + ;; + i*86v4*) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv4 + ;; + i*86v) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv + ;; + i*86sol2) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-solaris2 + ;; + i386mach) + basic_machine=i386-mach + os=-mach + ;; + i386-vsta | vsta) + basic_machine=i386-unknown + os=-vsta + ;; + iris | iris4d) + basic_machine=mips-sgi + case $os in + -irix*) + ;; + *) + os=-irix4 + ;; + esac + ;; + isi68 | isi) + basic_machine=m68k-isi + os=-sysv + ;; + m88k-omron*) + basic_machine=m88k-omron + ;; + magnum | m3230) + basic_machine=mips-mips + os=-sysv + ;; + merlin) + basic_machine=ns32k-utek + os=-sysv + ;; + mingw32) + basic_machine=i386-pc + os=-mingw32 + ;; + miniframe) + basic_machine=m68000-convergent + ;; + *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; + mips3*-*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` + ;; + mips3*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown + ;; + monitor) + basic_machine=m68k-rom68k + os=-coff + ;; + morphos) + basic_machine=powerpc-unknown + os=-morphos + ;; + msdos) + basic_machine=i386-pc + os=-msdos + ;; + mvs) + basic_machine=i370-ibm + os=-mvs + ;; + ncr3000) + basic_machine=i486-ncr + os=-sysv4 + ;; + netbsd386) + basic_machine=i386-unknown + os=-netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + os=-linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + os=-newsos + ;; + news1000) + basic_machine=m68030-sony + os=-newsos + ;; + news-3600 | risc-news) + basic_machine=mips-sony + os=-newsos + ;; + necv70) + basic_machine=v70-nec + os=-sysv + ;; + next | m*-next ) + basic_machine=m68k-next + case $os in + -nextstep* ) + ;; + -ns2*) + os=-nextstep2 + ;; + *) + os=-nextstep3 + ;; + esac + ;; + nh3000) + basic_machine=m68k-harris + os=-cxux + ;; + nh[45]000) + basic_machine=m88k-harris + os=-cxux + ;; + nindy960) + basic_machine=i960-intel + os=-nindy + ;; + mon960) + basic_machine=i960-intel + os=-mon960 + ;; + nonstopux) + basic_machine=mips-compaq + os=-nonstopux + ;; + np1) + basic_machine=np1-gould + ;; + nsr-tandem) + basic_machine=nsr-tandem + ;; + op50n-* | op60c-*) + basic_machine=hppa1.1-oki + os=-proelf + ;; + openrisc | openrisc-*) + basic_machine=or32-unknown + ;; + os400) + basic_machine=powerpc-ibm + os=-os400 + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + os=-ose + ;; + os68k) + basic_machine=m68k-none + os=-os68k + ;; + pa-hitachi) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + paragon) + basic_machine=i860-intel + os=-osf + ;; + pbd) + basic_machine=sparc-tti + ;; + pbb) + basic_machine=m68k-tti + ;; + pc532 | pc532-*) + basic_machine=ns32k-pc532 + ;; + pentium | p5 | k5 | k6 | nexgen | viac3) + basic_machine=i586-pc + ;; + pentiumpro | p6 | 6x86 | athlon | athlon_*) + basic_machine=i686-pc + ;; + pentiumii | pentium2 | pentiumiii | pentium3) + basic_machine=i686-pc + ;; + pentium4) + basic_machine=i786-pc + ;; + pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) + basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumpro-* | p6-* | 6x86-* | athlon-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentium4-*) + basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pn) + basic_machine=pn-gould + ;; + power) basic_machine=power-ibm + ;; + ppc) basic_machine=powerpc-unknown + ;; + ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppcle | powerpclittle | ppc-le | powerpc-little) + basic_machine=powerpcle-unknown + ;; + ppcle-* | powerpclittle-*) + basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64) basic_machine=powerpc64-unknown + ;; + ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64le | powerpc64little | ppc64-le | powerpc64-little) + basic_machine=powerpc64le-unknown + ;; + ppc64le-* | powerpc64little-*) + basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ps2) + basic_machine=i386-ibm + ;; + pw32) + basic_machine=i586-unknown + os=-pw32 + ;; + rom68k) + basic_machine=m68k-rom68k + os=-coff + ;; + rm[46]00) + basic_machine=mips-siemens + ;; + rtpc | rtpc-*) + basic_machine=romp-ibm + ;; + s390 | s390-*) + basic_machine=s390-ibm + ;; + s390x | s390x-*) + basic_machine=s390x-ibm + ;; + sa29200) + basic_machine=a29k-amd + os=-udi + ;; + sb1) + basic_machine=mipsisa64sb1-unknown + ;; + sb1el) + basic_machine=mipsisa64sb1el-unknown + ;; + sei) + basic_machine=mips-sei + os=-seiux + ;; + sequent) + basic_machine=i386-sequent + ;; + sh) + basic_machine=sh-hitachi + os=-hms + ;; + sh64) + basic_machine=sh64-unknown + ;; + sparclite-wrs | simso-wrs) + basic_machine=sparclite-wrs + os=-vxworks + ;; + sps7) + basic_machine=m68k-bull + os=-sysv2 + ;; + spur) + basic_machine=spur-unknown + ;; + st2000) + basic_machine=m68k-tandem + ;; + stratus) + basic_machine=i860-stratus + os=-sysv4 + ;; + sun2) + basic_machine=m68000-sun + ;; + sun2os3) + basic_machine=m68000-sun + os=-sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + os=-sunos4 + ;; + sun3os3) + basic_machine=m68k-sun + os=-sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + os=-sunos4 + ;; + sun4os3) + basic_machine=sparc-sun + os=-sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + os=-sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + os=-solaris2 + ;; + sun3 | sun3-*) + basic_machine=m68k-sun + ;; + sun4) + basic_machine=sparc-sun + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + ;; + sv1) + basic_machine=sv1-cray + os=-unicos + ;; + symmetry) + basic_machine=i386-sequent + os=-dynix + ;; + t3e) + basic_machine=alphaev5-cray + os=-unicos + ;; + t90) + basic_machine=t90-cray + os=-unicos + ;; + tic54x | c54x*) + basic_machine=tic54x-unknown + os=-coff + ;; + tic55x | c55x*) + basic_machine=tic55x-unknown + os=-coff + ;; + tic6x | c6x*) + basic_machine=tic6x-unknown + os=-coff + ;; + tx39) + basic_machine=mipstx39-unknown + ;; + tx39el) + basic_machine=mipstx39el-unknown + ;; + toad1) + basic_machine=pdp10-xkl + os=-tops20 + ;; + tower | tower-32) + basic_machine=m68k-ncr + ;; + tpf) + basic_machine=s390x-ibm + os=-tpf + ;; + udi29k) + basic_machine=a29k-amd + os=-udi + ;; + ultra3) + basic_machine=a29k-nyu + os=-sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + os=-none + ;; + vaxv) + basic_machine=vax-dec + os=-sysv + ;; + vms) + basic_machine=vax-dec + os=-vms + ;; + vpp*|vx|vx-*) + basic_machine=f301-fujitsu + ;; + vxworks960) + basic_machine=i960-wrs + os=-vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + os=-vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + os=-vxworks + ;; + w65*) + basic_machine=w65-wdc + os=-none + ;; + w89k-*) + basic_machine=hppa1.1-winbond + os=-proelf + ;; + xbox) + basic_machine=i686-pc + os=-mingw32 + ;; + xps | xps100) + basic_machine=xps100-honeywell + ;; + ymp) + basic_machine=ymp-cray + os=-unicos + ;; + z8k-*-coff) + basic_machine=z8k-unknown + os=-sim + ;; + none) + basic_machine=none-none + os=-none + ;; + +# Here we handle the default manufacturer of certain CPU types. It is in +# some cases the only manufacturer, in others, it is the most popular. + w89k) + basic_machine=hppa1.1-winbond + ;; + op50n) + basic_machine=hppa1.1-oki + ;; + op60c) + basic_machine=hppa1.1-oki + ;; + romp) + basic_machine=romp-ibm + ;; + mmix) + basic_machine=mmix-knuth + ;; + rs6000) + basic_machine=rs6000-ibm + ;; + vax) + basic_machine=vax-dec + ;; + pdp10) + # there are many clones, so DEC is not a safe bet + basic_machine=pdp10-unknown + ;; + pdp11) + basic_machine=pdp11-dec + ;; + we32k) + basic_machine=we32k-att + ;; + sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele) + basic_machine=sh-unknown + ;; + sparc | sparcv8 | sparcv9 | sparcv9b) + basic_machine=sparc-sun + ;; + cydra) + basic_machine=cydra-cydrome + ;; + orion) + basic_machine=orion-highlevel + ;; + orion105) + basic_machine=clipper-highlevel + ;; + mac | mpw | mac-mpw) + basic_machine=m68k-apple + ;; + pmac | pmac-mpw) + basic_machine=powerpc-apple + ;; + *-unknown) + # Make sure to match an already-canonicalized machine name. + ;; + *) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; +esac + +# Here we canonicalize certain aliases for manufacturers. +case $basic_machine in + *-digital*) + basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` + ;; + *-commodore*) + basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + ;; + *) + ;; +esac + +# Decode manufacturer-specific aliases for certain operating systems. + +if [ x"$os" != x"" ] +then +case $os in + # First match some system type aliases + # that might get confused with valid system types. + # -solaris* is a basic system type, with this one exception. + -solaris1 | -solaris1.*) + os=`echo $os | sed -e 's|solaris1|sunos4|'` + ;; + -solaris) + os=-solaris2 + ;; + -svr4*) + os=-sysv4 + ;; + -unixware*) + os=-sysv4.2uw + ;; + -gnu/linux*) + os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` + ;; + # First accept the basic system types. + # The portable systems comes first. + # Each alternative MUST END IN A *, to match a version number. + # -sysv* is not here because it comes later, after sysvr4. + -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* | -openbsd* \ + | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ + | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ + | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ + | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ + | -chorusos* | -chorusrdb* \ + | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -linux-gnu* | -linux-uclibc* | -uxpv* | -beos* | -mpeix* | -udk* \ + | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ + | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ + | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ + | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ + | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ + | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ + | -skyos* | -haiku*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; + -qnx*) + case $basic_machine in + x86-* | i*86-*) + ;; + *) + os=-nto$os + ;; + esac + ;; + -nto-qnx*) + ;; + -nto*) + os=`echo $os | sed -e 's|nto|nto-qnx|'` + ;; + -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ + | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ + | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) + ;; + -mac*) + os=`echo $os | sed -e 's|mac|macos|'` + ;; + -linux-dietlibc) + os=-linux-dietlibc + ;; + -linux*) + os=`echo $os | sed -e 's|linux|linux-gnu|'` + ;; + -sunos5*) + os=`echo $os | sed -e 's|sunos5|solaris2|'` + ;; + -sunos6*) + os=`echo $os | sed -e 's|sunos6|solaris3|'` + ;; + -opened*) + os=-openedition + ;; + -os400*) + os=-os400 + ;; + -wince*) + os=-wince + ;; + -osfrose*) + os=-osfrose + ;; + -osf*) + os=-osf + ;; + -utek*) + os=-bsd + ;; + -dynix*) + os=-bsd + ;; + -acis*) + os=-aos + ;; + -atheos*) + os=-atheos + ;; + -syllable*) + os=-syllable + ;; + -386bsd) + os=-bsd + ;; + -ctix* | -uts*) + os=-sysv + ;; + -nova*) + os=-rtmk-nova + ;; + -ns2 ) + os=-nextstep2 + ;; + -nsk*) + os=-nsk + ;; + # Preserve the version number of sinix5. + -sinix5.*) + os=`echo $os | sed -e 's|sinix|sysv|'` + ;; + -sinix*) + os=-sysv4 + ;; + -tpf*) + os=-tpf + ;; + -triton*) + os=-sysv3 + ;; + -oss*) + os=-sysv3 + ;; + -svr4) + os=-sysv4 + ;; + -svr3) + os=-sysv3 + ;; + -sysvr4) + os=-sysv4 + ;; + # This must come after -sysvr4. + -sysv*) + ;; + -ose*) + os=-ose + ;; + -es1800*) + os=-ose + ;; + -xenix) + os=-xenix + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + os=-mint + ;; + -aros*) + os=-aros + ;; + -kaos*) + os=-kaos + ;; + -zvmoe) + os=-zvmoe + ;; + -none) + ;; + *) + # Get rid of the `-' at the beginning of $os. + os=`echo $os | sed 's/[^-]*-//'` + echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 + exit 1 + ;; +esac +else + +# Here we handle the default operating systems that come with various machines. +# The value should be what the vendor currently ships out the door with their +# machine or put another way, the most popular os provided with the machine. + +# Note that if you're going to try to match "-MANUFACTURER" here (say, +# "-sun"), then you have to tell the case statement up towards the top +# that MANUFACTURER isn't an operating system. Otherwise, code above +# will signal an error saying that MANUFACTURER isn't an operating +# system, and we'll never get to this point. + +case $basic_machine in + *-acorn) + os=-riscix1.2 + ;; + arm*-rebel) + os=-linux + ;; + arm*-semi) + os=-aout + ;; + c4x-* | tic4x-*) + os=-coff + ;; + # This must come before the *-dec entry. + pdp10-*) + os=-tops20 + ;; + pdp11-*) + os=-none + ;; + *-dec | vax-*) + os=-ultrix4.2 + ;; + m68*-apollo) + os=-domain + ;; + i386-sun) + os=-sunos4.0.2 + ;; + m68000-sun) + os=-sunos3 + # This also exists in the configure program, but was not the + # default. + # os=-sunos4 + ;; + m68*-cisco) + os=-aout + ;; + mips*-cisco) + os=-elf + ;; + mips*-*) + os=-elf + ;; + or32-*) + os=-coff + ;; + *-tti) # must be before sparc entry or we get the wrong os. + os=-sysv3 + ;; + sparc-* | *-sun) + os=-sunos4.1.1 + ;; + *-be) + os=-beos + ;; + *-haiku) + os=-haiku + ;; + *-ibm) + os=-aix + ;; + *-knuth) + os=-mmixware + ;; + *-wec) + os=-proelf + ;; + *-winbond) + os=-proelf + ;; + *-oki) + os=-proelf + ;; + *-hp) + os=-hpux + ;; + *-hitachi) + os=-hiux + ;; + i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) + os=-sysv + ;; + *-cbm) + os=-amigaos + ;; + *-dg) + os=-dgux + ;; + *-dolphin) + os=-sysv3 + ;; + m68k-ccur) + os=-rtu + ;; + m88k-omron*) + os=-luna + ;; + *-next ) + os=-nextstep + ;; + *-sequent) + os=-ptx + ;; + *-crds) + os=-unos + ;; + *-ns) + os=-genix + ;; + i370-*) + os=-mvs + ;; + *-next) + os=-nextstep3 + ;; + *-gould) + os=-sysv + ;; + *-highlevel) + os=-bsd + ;; + *-encore) + os=-bsd + ;; + *-sgi) + os=-irix + ;; + *-siemens) + os=-sysv4 + ;; + *-masscomp) + os=-rtu + ;; + f30[01]-fujitsu | f700-fujitsu) + os=-uxpv + ;; + *-rom68k) + os=-coff + ;; + *-*bug) + os=-coff + ;; + *-apple) + os=-macos + ;; + *-atari*) + os=-mint + ;; + *) + os=-none + ;; +esac +fi + +# Here we handle the case where we know the os, and the CPU type, but not the +# manufacturer. We pick the logical manufacturer. +vendor=unknown +case $basic_machine in + *-unknown) + case $os in + -riscix*) + vendor=acorn + ;; + -sunos*) + vendor=sun + ;; + -aix*) + vendor=ibm + ;; + -beos*) + vendor=be + ;; + -hpux*) + vendor=hp + ;; + -mpeix*) + vendor=hp + ;; + -hiux*) + vendor=hitachi + ;; + -unos*) + vendor=crds + ;; + -dgux*) + vendor=dg + ;; + -luna*) + vendor=omron + ;; + -genix*) + vendor=ns + ;; + -mvs* | -opened*) + vendor=ibm + ;; + -os400*) + vendor=ibm + ;; + -ptx*) + vendor=sequent + ;; + -tpf*) + vendor=ibm + ;; + -vxsim* | -vxworks* | -windiss*) + vendor=wrs + ;; + -aux*) + vendor=apple + ;; + -hms*) + vendor=hitachi + ;; + -mpw* | -macos*) + vendor=apple + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + vendor=atari + ;; + -vos*) + vendor=stratus + ;; + esac + basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` + ;; +esac + +echo $basic_machine$os +exit + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/autoaux/depcomp b/autoaux/depcomp new file mode 100644 index 0000000..04701da --- /dev/null +++ b/autoaux/depcomp @@ -0,0 +1,530 @@ +#! /bin/sh +# depcomp - compile a program generating dependencies as side-effects + +scriptversion=2005-07-09.11 + +# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. + +case $1 in + '') + echo "$0: No command. Try \`$0 --help' for more information." 1>&2 + exit 1; + ;; + -h | --h*) + cat <<\EOF +Usage: depcomp [--help] [--version] PROGRAM [ARGS] + +Run PROGRAMS ARGS to compile a file, generating dependencies +as side-effects. + +Environment variables: + depmode Dependency tracking mode. + source Source file read by `PROGRAMS ARGS'. + object Object file output by `PROGRAMS ARGS'. + DEPDIR directory where to store dependencies. + depfile Dependency file to output. + tmpdepfile Temporary file to use when outputing dependencies. + libtool Whether libtool is used (yes/no). + +Report bugs to <bug-automake@gnu.org>. +EOF + exit $? + ;; + -v | --v*) + echo "depcomp $scriptversion" + exit $? + ;; +esac + +if test -z "$depmode" || test -z "$source" || test -z "$object"; then + echo "depcomp: Variables source, object and depmode must be set" 1>&2 + exit 1 +fi + +# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. +depfile=${depfile-`echo "$object" | + sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} +tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} + +rm -f "$tmpdepfile" + +# Some modes work just like other modes, but use different flags. We +# parameterize here, but still list the modes in the big case below, +# to make depend.m4 easier to write. Note that we *cannot* use a case +# here, because this file can only contain one case statement. +if test "$depmode" = hp; then + # HP compiler uses -M and no extra arg. + gccflag=-M + depmode=gcc +fi + +if test "$depmode" = dashXmstdout; then + # This is just like dashmstdout with a different argument. + dashmflag=-xM + depmode=dashmstdout +fi + +case "$depmode" in +gcc3) +## gcc 3 implements dependency tracking that does exactly what +## we want. Yay! Note: for some reason libtool 1.4 doesn't like +## it if -MD -MP comes after the -MF stuff. Hmm. + "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + mv "$tmpdepfile" "$depfile" + ;; + +gcc) +## There are various ways to get dependency output from gcc. Here's +## why we pick this rather obscure method: +## - Don't want to use -MD because we'd like the dependencies to end +## up in a subdir. Having to rename by hand is ugly. +## (We might end up doing this anyway to support other compilers.) +## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like +## -MM, not -M (despite what the docs say). +## - Using -M directly means running the compiler twice (even worse +## than renaming). + if test -z "$gccflag"; then + gccflag=-MD, + fi + "$@" -Wp,"$gccflag$tmpdepfile" + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + echo "$object : \\" > "$depfile" + alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz +## The second -e expression handles DOS-style file names with drive letters. + sed -e 's/^[^:]*: / /' \ + -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" +## This next piece of magic avoids the `deleted header file' problem. +## The problem is that when a header file which appears in a .P file +## is deleted, the dependency causes make to die (because there is +## typically no way to rebuild the header). We avoid this by adding +## dummy dependencies for each header file. Too bad gcc doesn't do +## this for us directly. + tr ' ' ' +' < "$tmpdepfile" | +## Some versions of gcc put a space before the `:'. On the theory +## that the space means something, we add a space to the output as +## well. +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +hp) + # This case exists only to let depend.m4 do its work. It works by + # looking at the text of this script. This case will never be run, + # since it is checked for above. + exit 1 + ;; + +sgi) + if test "$libtool" = yes; then + "$@" "-Wp,-MDupdate,$tmpdepfile" + else + "$@" -MDupdate "$tmpdepfile" + fi + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + + if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files + echo "$object : \\" > "$depfile" + + # Clip off the initial element (the dependent). Don't try to be + # clever and replace this with sed code, as IRIX sed won't handle + # lines with more than a fixed number of characters (4096 in + # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; + # the IRIX cc adds comments like `#:fec' to the end of the + # dependency line. + tr ' ' ' +' < "$tmpdepfile" \ + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ + tr ' +' ' ' >> $depfile + echo >> $depfile + + # The second pass generates a dummy entry for each header file. + tr ' ' ' +' < "$tmpdepfile" \ + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ + >> $depfile + else + # The sourcefile does not contain any dependencies, so just + # store a dummy comment line, to avoid errors with the Makefile + # "include basename.Plo" scheme. + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" + ;; + +aix) + # The C for AIX Compiler uses -M and outputs the dependencies + # in a .u file. In older versions, this file always lives in the + # current directory. Also, the AIX compiler puts `$object:' at the + # start of each line; $object doesn't have directory information. + # Version 6 uses the directory in both cases. + stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'` + tmpdepfile="$stripped.u" + if test "$libtool" = yes; then + "$@" -Wc,-M + else + "$@" -M + fi + stat=$? + + if test -f "$tmpdepfile"; then : + else + stripped=`echo "$stripped" | sed 's,^.*/,,'` + tmpdepfile="$stripped.u" + fi + + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + + if test -f "$tmpdepfile"; then + outname="$stripped.o" + # Each line is of the form `foo.o: dependent.h'. + # Do two passes, one to just change these to + # `$object: dependent.h' and one to simply `dependent.h:'. + sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile" + sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile" + else + # The sourcefile does not contain any dependencies, so just + # store a dummy comment line, to avoid errors with the Makefile + # "include basename.Plo" scheme. + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" + ;; + +icc) + # Intel's C compiler understands `-MD -MF file'. However on + # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c + # ICC 7.0 will fill foo.d with something like + # foo.o: sub/foo.c + # foo.o: sub/foo.h + # which is wrong. We want: + # sub/foo.o: sub/foo.c + # sub/foo.o: sub/foo.h + # sub/foo.c: + # sub/foo.h: + # ICC 7.1 will output + # foo.o: sub/foo.c sub/foo.h + # and will wrap long lines using \ : + # foo.o: sub/foo.c ... \ + # sub/foo.h ... \ + # ... + + "$@" -MD -MF "$tmpdepfile" + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + # Each line is of the form `foo.o: dependent.h', + # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. + # Do two passes, one to just change these to + # `$object: dependent.h' and one to simply `dependent.h:'. + sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" + # Some versions of the HPUX 10.20 sed can't process this invocation + # correctly. Breaking it into two sed invocations is a workaround. + sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | + sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +tru64) + # The Tru64 compiler uses -MD to generate dependencies as a side + # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. + # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put + # dependencies in `foo.d' instead, so we check for that too. + # Subdirectories are respected. + dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` + test "x$dir" = "x$object" && dir= + base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` + + if test "$libtool" = yes; then + # With Tru64 cc, shared objects can also be used to make a + # static library. This mecanism is used in libtool 1.4 series to + # handle both shared and static libraries in a single compilation. + # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. + # + # With libtool 1.5 this exception was removed, and libtool now + # generates 2 separate objects for the 2 libraries. These two + # compilations output dependencies in in $dir.libs/$base.o.d and + # in $dir$base.o.d. We have to check for both files, because + # one of the two compilations can be disabled. We should prefer + # $dir$base.o.d over $dir.libs/$base.o.d because the latter is + # automatically cleaned when .libs/ is deleted, while ignoring + # the former would cause a distcleancheck panic. + tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 + tmpdepfile2=$dir$base.o.d # libtool 1.5 + tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 + tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 + "$@" -Wc,-MD + else + tmpdepfile1=$dir$base.o.d + tmpdepfile2=$dir$base.d + tmpdepfile3=$dir$base.d + tmpdepfile4=$dir$base.d + "$@" -MD + fi + + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" + exit $stat + fi + + for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" + do + test -f "$tmpdepfile" && break + done + if test -f "$tmpdepfile"; then + sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" + # That's a tab and a space in the []. + sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" + else + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" + ;; + +#nosideeffect) + # This comment above is used by automake to tell side-effect + # dependency tracking mechanisms from slower ones. + +dashmstdout) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout, regardless of -o. + "$@" || exit $? + + # Remove the call to Libtool. + if test "$libtool" = yes; then + while test $1 != '--mode=compile'; do + shift + done + shift + fi + + # Remove `-o $object'. + IFS=" " + for arg + do + case $arg in + -o) + shift + ;; + $object) + shift + ;; + *) + set fnord "$@" "$arg" + shift # fnord + shift # $arg + ;; + esac + done + + test -z "$dashmflag" && dashmflag=-M + # Require at least two characters before searching for `:' + # in the target name. This is to cope with DOS-style filenames: + # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. + "$@" $dashmflag | + sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" + rm -f "$depfile" + cat < "$tmpdepfile" > "$depfile" + tr ' ' ' +' < "$tmpdepfile" | \ +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +dashXmstdout) + # This case only exists to satisfy depend.m4. It is never actually + # run, as this mode is specially recognized in the preamble. + exit 1 + ;; + +makedepend) + "$@" || exit $? + # Remove any Libtool call + if test "$libtool" = yes; then + while test $1 != '--mode=compile'; do + shift + done + shift + fi + # X makedepend + shift + cleared=no + for arg in "$@"; do + case $cleared in + no) + set ""; shift + cleared=yes ;; + esac + case "$arg" in + -D*|-I*) + set fnord "$@" "$arg"; shift ;; + # Strip any option that makedepend may not understand. Remove + # the object too, otherwise makedepend will parse it as a source file. + -*|$object) + ;; + *) + set fnord "$@" "$arg"; shift ;; + esac + done + obj_suffix="`echo $object | sed 's/^.*\././'`" + touch "$tmpdepfile" + ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" + rm -f "$depfile" + cat < "$tmpdepfile" > "$depfile" + sed '1,2d' "$tmpdepfile" | tr ' ' ' +' | \ +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" "$tmpdepfile".bak + ;; + +cpp) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout. + "$@" || exit $? + + # Remove the call to Libtool. + if test "$libtool" = yes; then + while test $1 != '--mode=compile'; do + shift + done + shift + fi + + # Remove `-o $object'. + IFS=" " + for arg + do + case $arg in + -o) + shift + ;; + $object) + shift + ;; + *) + set fnord "$@" "$arg" + shift # fnord + shift # $arg + ;; + esac + done + + "$@" -E | + sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ + -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | + sed '$ s: \\$::' > "$tmpdepfile" + rm -f "$depfile" + echo "$object : \\" > "$depfile" + cat < "$tmpdepfile" >> "$depfile" + sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +msvisualcpp) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout, regardless of -o, + # because we must use -o when running libtool. + "$@" || exit $? + IFS=" " + for arg + do + case "$arg" in + "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") + set fnord "$@" + shift + shift + ;; + *) + set fnord "$@" "$arg" + shift + shift + ;; + esac + done + "$@" -E | + sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" + rm -f "$depfile" + echo "$object : \\" > "$depfile" + . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" + echo " " >> "$depfile" + . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +none) + exec "$@" + ;; + +*) + echo "Unknown depmode $depmode" 1>&2 + exit 1 + ;; +esac + +exit 0 + +# Local Variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-end: "$" +# End: diff --git a/autoaux/install-sh b/autoaux/install-sh new file mode 100644 index 0000000..4d4a951 --- /dev/null +++ b/autoaux/install-sh @@ -0,0 +1,323 @@ +#!/bin/sh +# install - install a program, script, or datafile + +scriptversion=2005-05-14.22 + +# This originates from X11R5 (mit/util/scripts/install.sh), which was +# later released in X11R6 (xc/config/util/install.sh) with the +# following copyright and license. +# +# Copyright (C) 1994 X Consortium +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- +# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +# Except as contained in this notice, the name of the X Consortium shall not +# be used in advertising or otherwise to promote the sale, use or other deal- +# ings in this Software without prior written authorization from the X Consor- +# tium. +# +# +# FSF changes to this file are in the public domain. +# +# Calling this script install-sh is preferred over install.sh, to prevent +# `make' implicit rules from creating a file called install from it +# when there is no Makefile. +# +# This script is compatible with the BSD install script, but was written +# from scratch. It can only install one file at a time, a restriction +# shared with many OS's install programs. + +# set DOITPROG to echo to test this script + +# Don't use :- since 4.3BSD and earlier shells don't like it. +doit="${DOITPROG-}" + +# put in absolute paths if you don't have them in your path; or use env. vars. + +mvprog="${MVPROG-mv}" +cpprog="${CPPROG-cp}" +chmodprog="${CHMODPROG-chmod}" +chownprog="${CHOWNPROG-chown}" +chgrpprog="${CHGRPPROG-chgrp}" +stripprog="${STRIPPROG-strip}" +rmprog="${RMPROG-rm}" +mkdirprog="${MKDIRPROG-mkdir}" + +chmodcmd="$chmodprog 0755" +chowncmd= +chgrpcmd= +stripcmd= +rmcmd="$rmprog -f" +mvcmd="$mvprog" +src= +dst= +dir_arg= +dstarg= +no_target_directory= + +usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE + or: $0 [OPTION]... SRCFILES... DIRECTORY + or: $0 [OPTION]... -t DIRECTORY SRCFILES... + or: $0 [OPTION]... -d DIRECTORIES... + +In the 1st form, copy SRCFILE to DSTFILE. +In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. +In the 4th, create DIRECTORIES. + +Options: +-c (ignored) +-d create directories instead of installing files. +-g GROUP $chgrpprog installed files to GROUP. +-m MODE $chmodprog installed files to MODE. +-o USER $chownprog installed files to USER. +-s $stripprog installed files. +-t DIRECTORY install into DIRECTORY. +-T report an error if DSTFILE is a directory. +--help display this help and exit. +--version display version info and exit. + +Environment variables override the default commands: + CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG +" + +while test -n "$1"; do + case $1 in + -c) shift + continue;; + + -d) dir_arg=true + shift + continue;; + + -g) chgrpcmd="$chgrpprog $2" + shift + shift + continue;; + + --help) echo "$usage"; exit $?;; + + -m) chmodcmd="$chmodprog $2" + shift + shift + continue;; + + -o) chowncmd="$chownprog $2" + shift + shift + continue;; + + -s) stripcmd=$stripprog + shift + continue;; + + -t) dstarg=$2 + shift + shift + continue;; + + -T) no_target_directory=true + shift + continue;; + + --version) echo "$0 $scriptversion"; exit $?;; + + *) # When -d is used, all remaining arguments are directories to create. + # When -t is used, the destination is already specified. + test -n "$dir_arg$dstarg" && break + # Otherwise, the last argument is the destination. Remove it from $@. + for arg + do + if test -n "$dstarg"; then + # $@ is not empty: it contains at least $arg. + set fnord "$@" "$dstarg" + shift # fnord + fi + shift # arg + dstarg=$arg + done + break;; + esac +done + +if test -z "$1"; then + if test -z "$dir_arg"; then + echo "$0: no input file specified." >&2 + exit 1 + fi + # It's OK to call `install-sh -d' without argument. + # This can happen when creating conditional directories. + exit 0 +fi + +for src +do + # Protect names starting with `-'. + case $src in + -*) src=./$src ;; + esac + + if test -n "$dir_arg"; then + dst=$src + src= + + if test -d "$dst"; then + mkdircmd=: + chmodcmd= + else + mkdircmd=$mkdirprog + fi + else + # Waiting for this to be detected by the "$cpprog $src $dsttmp" command + # might cause directories to be created, which would be especially bad + # if $src (and thus $dsttmp) contains '*'. + if test ! -f "$src" && test ! -d "$src"; then + echo "$0: $src does not exist." >&2 + exit 1 + fi + + if test -z "$dstarg"; then + echo "$0: no destination specified." >&2 + exit 1 + fi + + dst=$dstarg + # Protect names starting with `-'. + case $dst in + -*) dst=./$dst ;; + esac + + # If destination is a directory, append the input filename; won't work + # if double slashes aren't ignored. + if test -d "$dst"; then + if test -n "$no_target_directory"; then + echo "$0: $dstarg: Is a directory" >&2 + exit 1 + fi + dst=$dst/`basename "$src"` + fi + fi + + # This sed command emulates the dirname command. + dstdir=`echo "$dst" | sed -e 's,/*$,,;s,[^/]*$,,;s,/*$,,;s,^$,.,'` + + # Make sure that the destination directory exists. + + # Skip lots of stat calls in the usual case. + if test ! -d "$dstdir"; then + defaultIFS=' + ' + IFS="${IFS-$defaultIFS}" + + oIFS=$IFS + # Some sh's can't handle IFS=/ for some reason. + IFS='%' + set x `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'` + shift + IFS=$oIFS + + pathcomp= + + while test $# -ne 0 ; do + pathcomp=$pathcomp$1 + shift + if test ! -d "$pathcomp"; then + $mkdirprog "$pathcomp" + # mkdir can fail with a `File exist' error in case several + # install-sh are creating the directory concurrently. This + # is OK. + test -d "$pathcomp" || exit + fi + pathcomp=$pathcomp/ + done + fi + + if test -n "$dir_arg"; then + $doit $mkdircmd "$dst" \ + && { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \ + && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \ + && { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \ + && { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; } + + else + dstfile=`basename "$dst"` + + # Make a couple of temp file names in the proper directory. + dsttmp=$dstdir/_inst.$$_ + rmtmp=$dstdir/_rm.$$_ + + # Trap to clean up those temp files at exit. + trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 + trap '(exit $?); exit' 1 2 13 15 + + # Copy the file name to the temp name. + $doit $cpprog "$src" "$dsttmp" && + + # and set any options; do chmod last to preserve setuid bits. + # + # If any of these fail, we abort the whole thing. If we want to + # ignore errors from any of these, just make sure not to ignore + # errors from the above "$doit $cpprog $src $dsttmp" command. + # + { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \ + && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \ + && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \ + && { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } && + + # Now rename the file to the real destination. + { $doit $mvcmd -f "$dsttmp" "$dstdir/$dstfile" 2>/dev/null \ + || { + # The rename failed, perhaps because mv can't rename something else + # to itself, or perhaps because mv is so ancient that it does not + # support -f. + + # Now remove or move aside any old file at destination location. + # We try this two ways since rm can't unlink itself on some + # systems and the destination file might be busy for other + # reasons. In this case, the final cleanup might fail but the new + # file should still install successfully. + { + if test -f "$dstdir/$dstfile"; then + $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \ + || $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \ + || { + echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2 + (exit 1); exit 1 + } + else + : + fi + } && + + # Now rename the file to the real destination. + $doit $mvcmd "$dsttmp" "$dstdir/$dstfile" + } + } + fi || { (exit 1); exit 1; } +done + +# The final little trick to "correctly" pass the exit status to the exit trap. +{ + (exit 0); exit 0 +} + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-end: "$" +# End: diff --git a/autoaux/ltmain.sh b/autoaux/ltmain.sh new file mode 100755 index 0000000..27d498a --- /dev/null +++ b/autoaux/ltmain.sh @@ -0,0 +1,6956 @@ +# ltmain.sh - Provide generalized library-building support services. +# NOTE: Changing this file will not affect anything until you rerun configure. +# +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, +# 2007, 2008 Free Software Foundation, Inc. +# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +basename="s,^.*/,,g" + +# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh +# is ksh but when the shell is invoked as "sh" and the current value of +# the _XPG environment variable is not equal to 1 (one), the special +# positional parameter $0, within a function call, is the name of the +# function. +progpath="$0" + +# The name of this program: +progname=`echo "$progpath" | $SED $basename` +modename="$progname" + +# Global variables: +EXIT_SUCCESS=0 +EXIT_FAILURE=1 + +PROGRAM=ltmain.sh +PACKAGE=libtool +VERSION=1.5.26 +TIMESTAMP=" (1.1220.2.492 2008/01/30 06:40:56)" + +# Be Bourne compatible (taken from Autoconf:_AS_BOURNE_COMPATIBLE). +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac +fi +BIN_SH=xpg4; export BIN_SH # for Tru64 +DUALCASE=1; export DUALCASE # for MKS sh + +# Check that we have a working $echo. +if test "X$1" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift +elif test "X$1" = X--fallback-echo; then + # Avoid inline document here, it may be left over + : +elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then + # Yippee, $echo works! + : +else + # Restart under the correct shell, and then maybe $echo will work. + exec $SHELL "$progpath" --no-reexec ${1+"$@"} +fi + +if test "X$1" = X--fallback-echo; then + # used as fallback echo + shift + cat <<EOF +$* +EOF + exit $EXIT_SUCCESS +fi + +default_mode= +help="Try \`$progname --help' for more information." +magic="%%%MAGIC variable%%%" +mkdir="mkdir" +mv="mv -f" +rm="rm -f" + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed="${SED}"' -e 1s/^X//' +sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g' +# test EBCDIC or ASCII +case `echo X|tr X '\101'` in + A) # ASCII based system + # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr + SP2NL='tr \040 \012' + NL2SP='tr \015\012 \040\040' + ;; + *) # EBCDIC based system + SP2NL='tr \100 \n' + NL2SP='tr \r\n \100\100' + ;; +esac + +# NLS nuisances. +# Only set LANG and LC_ALL to C if already set. +# These must not be set unconditionally because not all systems understand +# e.g. LANG=C (notably SCO). +# We save the old values to restore during execute mode. +lt_env= +for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES +do + eval "if test \"\${$lt_var+set}\" = set; then + save_$lt_var=\$$lt_var + lt_env=\"$lt_var=\$$lt_var \$lt_env\" + $lt_var=C + export $lt_var + fi" +done + +if test -n "$lt_env"; then + lt_env="env $lt_env" +fi + +# Make sure IFS has a sensible default +lt_nl=' +' +IFS=" $lt_nl" + +if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then + $echo "$modename: not configured to build any kind of library" 1>&2 + $echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 + exit $EXIT_FAILURE +fi + +# Global variables. +mode=$default_mode +nonopt= +prev= +prevopt= +run= +show="$echo" +show_help= +execute_dlfiles= +duplicate_deps=no +preserve_args= +lo2o="s/\\.lo\$/.${objext}/" +o2lo="s/\\.${objext}\$/.lo/" +extracted_archives= +extracted_serial=0 + +##################################### +# Shell function definitions: +# This seems to be the best place for them + +# func_mktempdir [string] +# Make a temporary directory that won't clash with other running +# libtool processes, and avoids race conditions if possible. If +# given, STRING is the basename for that directory. +func_mktempdir () +{ + my_template="${TMPDIR-/tmp}/${1-$progname}" + + if test "$run" = ":"; then + # Return a directory name, but don't create it in dry-run mode + my_tmpdir="${my_template}-$$" + else + + # If mktemp works, use that first and foremost + my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` + + if test ! -d "$my_tmpdir"; then + # Failing that, at least try and use $RANDOM to avoid a race + my_tmpdir="${my_template}-${RANDOM-0}$$" + + save_mktempdir_umask=`umask` + umask 0077 + $mkdir "$my_tmpdir" + umask $save_mktempdir_umask + fi + + # If we're not in dry-run mode, bomb out on failure + test -d "$my_tmpdir" || { + $echo "cannot create temporary directory \`$my_tmpdir'" 1>&2 + exit $EXIT_FAILURE + } + fi + + $echo "X$my_tmpdir" | $Xsed +} + + +# func_win32_libid arg +# return the library type of file 'arg' +# +# Need a lot of goo to handle *both* DLLs and import libs +# Has to be a shell function in order to 'eat' the argument +# that is supplied when $file_magic_command is called. +func_win32_libid () +{ + win32_libid_type="unknown" + win32_fileres=`file -L $1 2>/dev/null` + case $win32_fileres in + *ar\ archive\ import\ library*) # definitely import + win32_libid_type="x86 archive import" + ;; + *ar\ archive*) # could be an import, or static + if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \ + $EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then + win32_nmres=`eval $NM -f posix -A $1 | \ + $SED -n -e '1,100{ + / I /{ + s,.*,import, + p + q + } + }'` + case $win32_nmres in + import*) win32_libid_type="x86 archive import";; + *) win32_libid_type="x86 archive static";; + esac + fi + ;; + *DLL*) + win32_libid_type="x86 DLL" + ;; + *executable*) # but shell scripts are "executable" too... + case $win32_fileres in + *MS\ Windows\ PE\ Intel*) + win32_libid_type="x86 DLL" + ;; + esac + ;; + esac + $echo $win32_libid_type +} + + +# func_infer_tag arg +# Infer tagged configuration to use if any are available and +# if one wasn't chosen via the "--tag" command line option. +# Only attempt this if the compiler in the base compile +# command doesn't match the default compiler. +# arg is usually of the form 'gcc ...' +func_infer_tag () +{ + if test -n "$available_tags" && test -z "$tagname"; then + CC_quoted= + for arg in $CC; do + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + arg="\"$arg\"" + ;; + esac + CC_quoted="$CC_quoted $arg" + done + case $@ in + # Blanks in the command may have been stripped by the calling shell, + # but not from the CC environment variable when configure was run. + " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) ;; + # Blanks at the start of $base_compile will cause this to fail + # if we don't check for them as well. + *) + for z in $available_tags; do + if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then + # Evaluate the configuration. + eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" + CC_quoted= + for arg in $CC; do + # Double-quote args containing other shell metacharacters. + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + arg="\"$arg\"" + ;; + esac + CC_quoted="$CC_quoted $arg" + done + case "$@ " in + " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) + # The compiler in the base compile command matches + # the one in the tagged configuration. + # Assume this is the tagged configuration we want. + tagname=$z + break + ;; + esac + fi + done + # If $tagname still isn't set, then no tagged configuration + # was found and let the user know that the "--tag" command + # line option must be used. + if test -z "$tagname"; then + $echo "$modename: unable to infer tagged configuration" + $echo "$modename: specify a tag with \`--tag'" 1>&2 + exit $EXIT_FAILURE +# else +# $echo "$modename: using $tagname tagged configuration" + fi + ;; + esac + fi +} + + +# func_extract_an_archive dir oldlib +func_extract_an_archive () +{ + f_ex_an_ar_dir="$1"; shift + f_ex_an_ar_oldlib="$1" + + $show "(cd $f_ex_an_ar_dir && $AR x $f_ex_an_ar_oldlib)" + $run eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_oldlib)" || exit $? + if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then + : + else + $echo "$modename: ERROR: object name conflicts: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 1>&2 + exit $EXIT_FAILURE + fi +} + +# func_extract_archives gentop oldlib ... +func_extract_archives () +{ + my_gentop="$1"; shift + my_oldlibs=${1+"$@"} + my_oldobjs="" + my_xlib="" + my_xabs="" + my_xdir="" + my_status="" + + $show "${rm}r $my_gentop" + $run ${rm}r "$my_gentop" + $show "$mkdir $my_gentop" + $run $mkdir "$my_gentop" + my_status=$? + if test "$my_status" -ne 0 && test ! -d "$my_gentop"; then + exit $my_status + fi + + for my_xlib in $my_oldlibs; do + # Extract the objects. + case $my_xlib in + [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; + *) my_xabs=`pwd`"/$my_xlib" ;; + esac + my_xlib=`$echo "X$my_xlib" | $Xsed -e 's%^.*/%%'` + my_xlib_u=$my_xlib + while :; do + case " $extracted_archives " in + *" $my_xlib_u "*) + extracted_serial=`expr $extracted_serial + 1` + my_xlib_u=lt$extracted_serial-$my_xlib ;; + *) break ;; + esac + done + extracted_archives="$extracted_archives $my_xlib_u" + my_xdir="$my_gentop/$my_xlib_u" + + $show "${rm}r $my_xdir" + $run ${rm}r "$my_xdir" + $show "$mkdir $my_xdir" + $run $mkdir "$my_xdir" + exit_status=$? + if test "$exit_status" -ne 0 && test ! -d "$my_xdir"; then + exit $exit_status + fi + case $host in + *-darwin*) + $show "Extracting $my_xabs" + # Do not bother doing anything if just a dry run + if test -z "$run"; then + darwin_orig_dir=`pwd` + cd $my_xdir || exit $? + darwin_archive=$my_xabs + darwin_curdir=`pwd` + darwin_base_archive=`$echo "X$darwin_archive" | $Xsed -e 's%^.*/%%'` + darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $EGREP Architectures 2>/dev/null` + if test -n "$darwin_arches"; then + darwin_arches=`echo "$darwin_arches" | $SED -e 's/.*are://'` + darwin_arch= + $show "$darwin_base_archive has multiple architectures $darwin_arches" + for darwin_arch in $darwin_arches ; do + mkdir -p "unfat-$$/${darwin_base_archive}-${darwin_arch}" + lipo -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" + cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" + func_extract_an_archive "`pwd`" "${darwin_base_archive}" + cd "$darwin_curdir" + $rm "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" + done # $darwin_arches + ## Okay now we have a bunch of thin objects, gotta fatten them up :) + darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print| xargs basename | sort -u | $NL2SP` + darwin_file= + darwin_files= + for darwin_file in $darwin_filelist; do + darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP` + lipo -create -output "$darwin_file" $darwin_files + done # $darwin_filelist + ${rm}r unfat-$$ + cd "$darwin_orig_dir" + else + cd "$darwin_orig_dir" + func_extract_an_archive "$my_xdir" "$my_xabs" + fi # $darwin_arches + fi # $run + ;; + *) + func_extract_an_archive "$my_xdir" "$my_xabs" + ;; + esac + my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP` + done + func_extract_archives_result="$my_oldobjs" +} +# End of Shell function definitions +##################################### + +# Darwin sucks +eval std_shrext=\"$shrext_cmds\" + +disable_libs=no + +# Parse our command line options once, thoroughly. +while test "$#" -gt 0 +do + arg="$1" + shift + + case $arg in + -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;; + *) optarg= ;; + esac + + # If the previous option needs an argument, assign it. + if test -n "$prev"; then + case $prev in + execute_dlfiles) + execute_dlfiles="$execute_dlfiles $arg" + ;; + tag) + tagname="$arg" + preserve_args="${preserve_args}=$arg" + + # Check whether tagname contains only valid characters + case $tagname in + *[!-_A-Za-z0-9,/]*) + $echo "$progname: invalid tag name: $tagname" 1>&2 + exit $EXIT_FAILURE + ;; + esac + + case $tagname in + CC) + # Don't test for the "default" C tag, as we know, it's there, but + # not specially marked. + ;; + *) + if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$progpath" > /dev/null; then + taglist="$taglist $tagname" + # Evaluate the configuration. + eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$tagname'$/,/^# ### END LIBTOOL TAG CONFIG: '$tagname'$/p' < $progpath`" + else + $echo "$progname: ignoring unknown tag $tagname" 1>&2 + fi + ;; + esac + ;; + *) + eval "$prev=\$arg" + ;; + esac + + prev= + prevopt= + continue + fi + + # Have we seen a non-optional argument yet? + case $arg in + --help) + show_help=yes + ;; + + --version) + echo "\ +$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP + +Copyright (C) 2008 Free Software Foundation, Inc. +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + exit $? + ;; + + --config) + ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $progpath + # Now print the configurations for the tags. + for tagname in $taglist; do + ${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$progpath" + done + exit $? + ;; + + --debug) + $echo "$progname: enabling shell trace mode" + set -x + preserve_args="$preserve_args $arg" + ;; + + --dry-run | -n) + run=: + ;; + + --features) + $echo "host: $host" + if test "$build_libtool_libs" = yes; then + $echo "enable shared libraries" + else + $echo "disable shared libraries" + fi + if test "$build_old_libs" = yes; then + $echo "enable static libraries" + else + $echo "disable static libraries" + fi + exit $? + ;; + + --finish) mode="finish" ;; + + --mode) prevopt="--mode" prev=mode ;; + --mode=*) mode="$optarg" ;; + + --preserve-dup-deps) duplicate_deps="yes" ;; + + --quiet | --silent) + show=: + preserve_args="$preserve_args $arg" + ;; + + --tag) + prevopt="--tag" + prev=tag + preserve_args="$preserve_args --tag" + ;; + --tag=*) + set tag "$optarg" ${1+"$@"} + shift + prev=tag + preserve_args="$preserve_args --tag" + ;; + + -dlopen) + prevopt="-dlopen" + prev=execute_dlfiles + ;; + + -*) + $echo "$modename: unrecognized option \`$arg'" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + ;; + + *) + nonopt="$arg" + break + ;; + esac +done + +if test -n "$prevopt"; then + $echo "$modename: option \`$prevopt' requires an argument" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE +fi + +case $disable_libs in +no) + ;; +shared) + build_libtool_libs=no + build_old_libs=yes + ;; +static) + build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` + ;; +esac + +# If this variable is set in any of the actions, the command in it +# will be execed at the end. This prevents here-documents from being +# left over by shells. +exec_cmd= + +if test -z "$show_help"; then + + # Infer the operation mode. + if test -z "$mode"; then + $echo "*** Warning: inferring the mode of operation is deprecated." 1>&2 + $echo "*** Future versions of Libtool will require --mode=MODE be specified." 1>&2 + case $nonopt in + *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*) + mode=link + for arg + do + case $arg in + -c) + mode=compile + break + ;; + esac + done + ;; + *db | *dbx | *strace | *truss) + mode=execute + ;; + *install*|cp|mv) + mode=install + ;; + *rm) + mode=uninstall + ;; + *) + # If we have no mode, but dlfiles were specified, then do execute mode. + test -n "$execute_dlfiles" && mode=execute + + # Just use the default operation mode. + if test -z "$mode"; then + if test -n "$nonopt"; then + $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2 + else + $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2 + fi + fi + ;; + esac + fi + + # Only execute mode is allowed to have -dlopen flags. + if test -n "$execute_dlfiles" && test "$mode" != execute; then + $echo "$modename: unrecognized option \`-dlopen'" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + + # Change the help message to a mode-specific one. + generic_help="$help" + help="Try \`$modename --help --mode=$mode' for more information." + + # These modes are in order of execution frequency so that they run quickly. + case $mode in + # libtool compile mode + compile) + modename="$modename: compile" + # Get the compilation command and the source file. + base_compile= + srcfile="$nonopt" # always keep a non-empty value in "srcfile" + suppress_opt=yes + suppress_output= + arg_mode=normal + libobj= + later= + + for arg + do + case $arg_mode in + arg ) + # do not "continue". Instead, add this to base_compile + lastarg="$arg" + arg_mode=normal + ;; + + target ) + libobj="$arg" + arg_mode=normal + continue + ;; + + normal ) + # Accept any command-line options. + case $arg in + -o) + if test -n "$libobj" ; then + $echo "$modename: you cannot specify \`-o' more than once" 1>&2 + exit $EXIT_FAILURE + fi + arg_mode=target + continue + ;; + + -static | -prefer-pic | -prefer-non-pic) + later="$later $arg" + continue + ;; + + -no-suppress) + suppress_opt=no + continue + ;; + + -Xcompiler) + arg_mode=arg # the next one goes into the "base_compile" arg list + continue # The current "srcfile" will either be retained or + ;; # replaced later. I would guess that would be a bug. + + -Wc,*) + args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"` + lastarg= + save_ifs="$IFS"; IFS=',' + for arg in $args; do + IFS="$save_ifs" + + # Double-quote args containing other shell metacharacters. + # Many Bourne shells cannot handle close brackets correctly + # in scan sets, so we specify it separately. + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + arg="\"$arg\"" + ;; + esac + lastarg="$lastarg $arg" + done + IFS="$save_ifs" + lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"` + + # Add the arguments to base_compile. + base_compile="$base_compile $lastarg" + continue + ;; + + * ) + # Accept the current argument as the source file. + # The previous "srcfile" becomes the current argument. + # + lastarg="$srcfile" + srcfile="$arg" + ;; + esac # case $arg + ;; + esac # case $arg_mode + + # Aesthetically quote the previous argument. + lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"` + + case $lastarg in + # Double-quote args containing other shell metacharacters. + # Many Bourne shells cannot handle close brackets correctly + # in scan sets, and some SunOS ksh mistreat backslash-escaping + # in scan sets (worked around with variable expansion), + # and furthermore cannot handle '|' '&' '(' ')' in scan sets + # at all, so we specify them separately. + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + lastarg="\"$lastarg\"" + ;; + esac + + base_compile="$base_compile $lastarg" + done # for arg + + case $arg_mode in + arg) + $echo "$modename: you must specify an argument for -Xcompile" + exit $EXIT_FAILURE + ;; + target) + $echo "$modename: you must specify a target with \`-o'" 1>&2 + exit $EXIT_FAILURE + ;; + *) + # Get the name of the library object. + [ -z "$libobj" ] && libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'` + ;; + esac + + # Recognize several different file suffixes. + # If the user specifies -o file.o, it is replaced with file.lo + xform='[cCFSifmso]' + case $libobj in + *.ada) xform=ada ;; + *.adb) xform=adb ;; + *.ads) xform=ads ;; + *.asm) xform=asm ;; + *.c++) xform=c++ ;; + *.cc) xform=cc ;; + *.ii) xform=ii ;; + *.class) xform=class ;; + *.cpp) xform=cpp ;; + *.cxx) xform=cxx ;; + *.[fF][09]?) xform=[fF][09]. ;; + *.for) xform=for ;; + *.java) xform=java ;; + *.obj) xform=obj ;; + *.sx) xform=sx ;; + esac + + libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"` + + case $libobj in + *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;; + *) + $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2 + exit $EXIT_FAILURE + ;; + esac + + func_infer_tag $base_compile + + for arg in $later; do + case $arg in + -static) + build_old_libs=yes + continue + ;; + + -prefer-pic) + pic_mode=yes + continue + ;; + + -prefer-non-pic) + pic_mode=no + continue + ;; + esac + done + + qlibobj=`$echo "X$libobj" | $Xsed -e "$sed_quote_subst"` + case $qlibobj in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + qlibobj="\"$qlibobj\"" ;; + esac + test "X$libobj" != "X$qlibobj" \ + && $echo "X$libobj" | grep '[]~#^*{};<>?"'"'"' &()|`$[]' \ + && $echo "$modename: libobj name \`$libobj' may not contain shell special characters." + objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'` + xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$obj"; then + xdir= + else + xdir=$xdir/ + fi + lobj=${xdir}$objdir/$objname + + if test -z "$base_compile"; then + $echo "$modename: you must specify a compilation command" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + + # Delete any leftover library objects. + if test "$build_old_libs" = yes; then + removelist="$obj $lobj $libobj ${libobj}T" + else + removelist="$lobj $libobj ${libobj}T" + fi + + $run $rm $removelist + trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15 + + # On Cygwin there's no "real" PIC flag so we must build both object types + case $host_os in + cygwin* | mingw* | pw32* | os2*) + pic_mode=default + ;; + esac + if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then + # non-PIC code in shared libraries is not supported + pic_mode=default + fi + + # Calculate the filename of the output object if compiler does + # not support -o with -c + if test "$compiler_c_o" = no; then + output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext} + lockfile="$output_obj.lock" + removelist="$removelist $output_obj $lockfile" + trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15 + else + output_obj= + need_locks=no + lockfile= + fi + + # Lock this critical section if it is needed + # We use this script file to make the link, it avoids creating a new file + if test "$need_locks" = yes; then + until $run ln "$progpath" "$lockfile" 2>/dev/null; do + $show "Waiting for $lockfile to be removed" + sleep 2 + done + elif test "$need_locks" = warn; then + if test -f "$lockfile"; then + $echo "\ +*** ERROR, $lockfile exists and contains: +`cat $lockfile 2>/dev/null` + +This indicates that another process is trying to use the same +temporary object file, and libtool could not work around it because +your compiler does not support \`-c' and \`-o' together. If you +repeat this compilation, it may succeed, by chance, but you had better +avoid parallel builds (make -j) in this platform, or get a better +compiler." + + $run $rm $removelist + exit $EXIT_FAILURE + fi + $echo "$srcfile" > "$lockfile" + fi + + if test -n "$fix_srcfile_path"; then + eval srcfile=\"$fix_srcfile_path\" + fi + qsrcfile=`$echo "X$srcfile" | $Xsed -e "$sed_quote_subst"` + case $qsrcfile in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + qsrcfile="\"$qsrcfile\"" ;; + esac + + $run $rm "$libobj" "${libobj}T" + + # Create a libtool object file (analogous to a ".la" file), + # but don't create it if we're doing a dry run. + test -z "$run" && cat > ${libobj}T <<EOF +# $libobj - a libtool object file +# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# Name of the PIC object. +EOF + + # Only build a PIC object if we are building libtool libraries. + if test "$build_libtool_libs" = yes; then + # Without this assignment, base_compile gets emptied. + fbsd_hideous_sh_bug=$base_compile + + if test "$pic_mode" != no; then + command="$base_compile $qsrcfile $pic_flag" + else + # Don't build PIC code + command="$base_compile $qsrcfile" + fi + + if test ! -d "${xdir}$objdir"; then + $show "$mkdir ${xdir}$objdir" + $run $mkdir ${xdir}$objdir + exit_status=$? + if test "$exit_status" -ne 0 && test ! -d "${xdir}$objdir"; then + exit $exit_status + fi + fi + + if test -z "$output_obj"; then + # Place PIC objects in $objdir + command="$command -o $lobj" + fi + + $run $rm "$lobj" "$output_obj" + + $show "$command" + if $run eval $lt_env "$command"; then : + else + test -n "$output_obj" && $run $rm $removelist + exit $EXIT_FAILURE + fi + + if test "$need_locks" = warn && + test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then + $echo "\ +*** ERROR, $lockfile contains: +`cat $lockfile 2>/dev/null` + +but it should contain: +$srcfile + +This indicates that another process is trying to use the same +temporary object file, and libtool could not work around it because +your compiler does not support \`-c' and \`-o' together. If you +repeat this compilation, it may succeed, by chance, but you had better +avoid parallel builds (make -j) in this platform, or get a better +compiler." + + $run $rm $removelist + exit $EXIT_FAILURE + fi + + # Just move the object if needed, then go on to compile the next one + if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then + $show "$mv $output_obj $lobj" + if $run $mv $output_obj $lobj; then : + else + error=$? + $run $rm $removelist + exit $error + fi + fi + + # Append the name of the PIC object to the libtool object file. + test -z "$run" && cat >> ${libobj}T <<EOF +pic_object='$objdir/$objname' + +EOF + + # Allow error messages only from the first compilation. + if test "$suppress_opt" = yes; then + suppress_output=' >/dev/null 2>&1' + fi + else + # No PIC object so indicate it doesn't exist in the libtool + # object file. + test -z "$run" && cat >> ${libobj}T <<EOF +pic_object=none + +EOF + fi + + # Only build a position-dependent object if we build old libraries. + if test "$build_old_libs" = yes; then + if test "$pic_mode" != yes; then + # Don't build PIC code + command="$base_compile $qsrcfile" + else + command="$base_compile $qsrcfile $pic_flag" + fi + if test "$compiler_c_o" = yes; then + command="$command -o $obj" + fi + + # Suppress compiler output if we already did a PIC compilation. + command="$command$suppress_output" + $run $rm "$obj" "$output_obj" + $show "$command" + if $run eval $lt_env "$command"; then : + else + $run $rm $removelist + exit $EXIT_FAILURE + fi + + if test "$need_locks" = warn && + test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then + $echo "\ +*** ERROR, $lockfile contains: +`cat $lockfile 2>/dev/null` + +but it should contain: +$srcfile + +This indicates that another process is trying to use the same +temporary object file, and libtool could not work around it because +your compiler does not support \`-c' and \`-o' together. If you +repeat this compilation, it may succeed, by chance, but you had better +avoid parallel builds (make -j) in this platform, or get a better +compiler." + + $run $rm $removelist + exit $EXIT_FAILURE + fi + + # Just move the object if needed + if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then + $show "$mv $output_obj $obj" + if $run $mv $output_obj $obj; then : + else + error=$? + $run $rm $removelist + exit $error + fi + fi + + # Append the name of the non-PIC object the libtool object file. + # Only append if the libtool object file exists. + test -z "$run" && cat >> ${libobj}T <<EOF +# Name of the non-PIC object. +non_pic_object='$objname' + +EOF + else + # Append the name of the non-PIC object the libtool object file. + # Only append if the libtool object file exists. + test -z "$run" && cat >> ${libobj}T <<EOF +# Name of the non-PIC object. +non_pic_object=none + +EOF + fi + + $run $mv "${libobj}T" "${libobj}" + + # Unlock the critical section if it was locked + if test "$need_locks" != no; then + $run $rm "$lockfile" + fi + + exit $EXIT_SUCCESS + ;; + + # libtool link mode + link | relink) + modename="$modename: link" + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) + # It is impossible to link a dll without this setting, and + # we shouldn't force the makefile maintainer to figure out + # which system we are compiling for in order to pass an extra + # flag for every libtool invocation. + # allow_undefined=no + + # FIXME: Unfortunately, there are problems with the above when trying + # to make a dll which has undefined symbols, in which case not + # even a static library is built. For now, we need to specify + # -no-undefined on the libtool link line when we can be certain + # that all symbols are satisfied, otherwise we get a static library. + allow_undefined=yes + ;; + *) + allow_undefined=yes + ;; + esac + libtool_args="$nonopt" + base_compile="$nonopt $@" + compile_command="$nonopt" + finalize_command="$nonopt" + + compile_rpath= + finalize_rpath= + compile_shlibpath= + finalize_shlibpath= + convenience= + old_convenience= + deplibs= + old_deplibs= + compiler_flags= + linker_flags= + dllsearchpath= + lib_search_path=`pwd` + inst_prefix_dir= + + avoid_version=no + dlfiles= + dlprefiles= + dlself=no + export_dynamic=no + export_symbols= + export_symbols_regex= + generated= + libobjs= + ltlibs= + module=no + no_install=no + objs= + non_pic_objects= + notinst_path= # paths that contain not-installed libtool libraries + precious_files_regex= + prefer_static_libs=no + preload=no + prev= + prevarg= + release= + rpath= + xrpath= + perm_rpath= + temp_rpath= + thread_safe=no + vinfo= + vinfo_number=no + single_module="${wl}-single_module" + + func_infer_tag $base_compile + + # We need to know -static, to get the right output filenames. + for arg + do + case $arg in + -all-static | -static | -static-libtool-libs) + case $arg in + -all-static) + if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then + $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2 + fi + if test -n "$link_static_flag"; then + dlopen_self=$dlopen_self_static + fi + prefer_static_libs=yes + ;; + -static) + if test -z "$pic_flag" && test -n "$link_static_flag"; then + dlopen_self=$dlopen_self_static + fi + prefer_static_libs=built + ;; + -static-libtool-libs) + if test -z "$pic_flag" && test -n "$link_static_flag"; then + dlopen_self=$dlopen_self_static + fi + prefer_static_libs=yes + ;; + esac + build_libtool_libs=no + build_old_libs=yes + break + ;; + esac + done + + # See if our shared archives depend on static archives. + test -n "$old_archive_from_new_cmds" && build_old_libs=yes + + # Go through the arguments, transforming them on the way. + while test "$#" -gt 0; do + arg="$1" + shift + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + qarg=\"`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`\" ### testsuite: skip nested quoting test + ;; + *) qarg=$arg ;; + esac + libtool_args="$libtool_args $qarg" + + # If the previous option needs an argument, assign it. + if test -n "$prev"; then + case $prev in + output) + compile_command="$compile_command @OUTPUT@" + finalize_command="$finalize_command @OUTPUT@" + ;; + esac + + case $prev in + dlfiles|dlprefiles) + if test "$preload" = no; then + # Add the symbol object into the linking commands. + compile_command="$compile_command @SYMFILE@" + finalize_command="$finalize_command @SYMFILE@" + preload=yes + fi + case $arg in + *.la | *.lo) ;; # We handle these cases below. + force) + if test "$dlself" = no; then + dlself=needless + export_dynamic=yes + fi + prev= + continue + ;; + self) + if test "$prev" = dlprefiles; then + dlself=yes + elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then + dlself=yes + else + dlself=needless + export_dynamic=yes + fi + prev= + continue + ;; + *) + if test "$prev" = dlfiles; then + dlfiles="$dlfiles $arg" + else + dlprefiles="$dlprefiles $arg" + fi + prev= + continue + ;; + esac + ;; + expsyms) + export_symbols="$arg" + if test ! -f "$arg"; then + $echo "$modename: symbol file \`$arg' does not exist" + exit $EXIT_FAILURE + fi + prev= + continue + ;; + expsyms_regex) + export_symbols_regex="$arg" + prev= + continue + ;; + inst_prefix) + inst_prefix_dir="$arg" + prev= + continue + ;; + precious_regex) + precious_files_regex="$arg" + prev= + continue + ;; + release) + release="-$arg" + prev= + continue + ;; + objectlist) + if test -f "$arg"; then + save_arg=$arg + moreargs= + for fil in `cat $save_arg` + do +# moreargs="$moreargs $fil" + arg=$fil + # A libtool-controlled object. + + # Check to see that this really is a libtool object. + if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + pic_object= + non_pic_object= + + # Read the .lo file + # If there is no directory component, then add one. + case $arg in + */* | *\\*) . $arg ;; + *) . ./$arg ;; + esac + + if test -z "$pic_object" || \ + test -z "$non_pic_object" || + test "$pic_object" = none && \ + test "$non_pic_object" = none; then + $echo "$modename: cannot find name of object for \`$arg'" 1>&2 + exit $EXIT_FAILURE + fi + + # Extract subdirectory from the argument. + xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$arg"; then + xdir= + else + xdir="$xdir/" + fi + + if test "$pic_object" != none; then + # Prepend the subdirectory the object is found in. + pic_object="$xdir$pic_object" + + if test "$prev" = dlfiles; then + if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then + dlfiles="$dlfiles $pic_object" + prev= + continue + else + # If libtool objects are unsupported, then we need to preload. + prev=dlprefiles + fi + fi + + # CHECK ME: I think I busted this. -Ossama + if test "$prev" = dlprefiles; then + # Preload the old-style object. + dlprefiles="$dlprefiles $pic_object" + prev= + fi + + # A PIC object. + libobjs="$libobjs $pic_object" + arg="$pic_object" + fi + + # Non-PIC object. + if test "$non_pic_object" != none; then + # Prepend the subdirectory the object is found in. + non_pic_object="$xdir$non_pic_object" + + # A standard non-PIC object + non_pic_objects="$non_pic_objects $non_pic_object" + if test -z "$pic_object" || test "$pic_object" = none ; then + arg="$non_pic_object" + fi + else + # If the PIC object exists, use it instead. + # $xdir was prepended to $pic_object above. + non_pic_object="$pic_object" + non_pic_objects="$non_pic_objects $non_pic_object" + fi + else + # Only an error if not doing a dry-run. + if test -z "$run"; then + $echo "$modename: \`$arg' is not a valid libtool object" 1>&2 + exit $EXIT_FAILURE + else + # Dry-run case. + + # Extract subdirectory from the argument. + xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$arg"; then + xdir= + else + xdir="$xdir/" + fi + + pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"` + non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"` + libobjs="$libobjs $pic_object" + non_pic_objects="$non_pic_objects $non_pic_object" + fi + fi + done + else + $echo "$modename: link input file \`$save_arg' does not exist" + exit $EXIT_FAILURE + fi + arg=$save_arg + prev= + continue + ;; + rpath | xrpath) + # We need an absolute path. + case $arg in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + $echo "$modename: only absolute run-paths are allowed" 1>&2 + exit $EXIT_FAILURE + ;; + esac + if test "$prev" = rpath; then + case "$rpath " in + *" $arg "*) ;; + *) rpath="$rpath $arg" ;; + esac + else + case "$xrpath " in + *" $arg "*) ;; + *) xrpath="$xrpath $arg" ;; + esac + fi + prev= + continue + ;; + xcompiler) + compiler_flags="$compiler_flags $qarg" + prev= + compile_command="$compile_command $qarg" + finalize_command="$finalize_command $qarg" + continue + ;; + xlinker) + linker_flags="$linker_flags $qarg" + compiler_flags="$compiler_flags $wl$qarg" + prev= + compile_command="$compile_command $wl$qarg" + finalize_command="$finalize_command $wl$qarg" + continue + ;; + xcclinker) + linker_flags="$linker_flags $qarg" + compiler_flags="$compiler_flags $qarg" + prev= + compile_command="$compile_command $qarg" + finalize_command="$finalize_command $qarg" + continue + ;; + shrext) + shrext_cmds="$arg" + prev= + continue + ;; + darwin_framework|darwin_framework_skip) + test "$prev" = "darwin_framework" && compiler_flags="$compiler_flags $arg" + compile_command="$compile_command $arg" + finalize_command="$finalize_command $arg" + prev= + continue + ;; + *) + eval "$prev=\"\$arg\"" + prev= + continue + ;; + esac + fi # test -n "$prev" + + prevarg="$arg" + + case $arg in + -all-static) + if test -n "$link_static_flag"; then + compile_command="$compile_command $link_static_flag" + finalize_command="$finalize_command $link_static_flag" + fi + continue + ;; + + -allow-undefined) + # FIXME: remove this flag sometime in the future. + $echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2 + continue + ;; + + -avoid-version) + avoid_version=yes + continue + ;; + + -dlopen) + prev=dlfiles + continue + ;; + + -dlpreopen) + prev=dlprefiles + continue + ;; + + -export-dynamic) + export_dynamic=yes + continue + ;; + + -export-symbols | -export-symbols-regex) + if test -n "$export_symbols" || test -n "$export_symbols_regex"; then + $echo "$modename: more than one -exported-symbols argument is not allowed" + exit $EXIT_FAILURE + fi + if test "X$arg" = "X-export-symbols"; then + prev=expsyms + else + prev=expsyms_regex + fi + continue + ;; + + -framework|-arch|-isysroot) + case " $CC " in + *" ${arg} ${1} "* | *" ${arg} ${1} "*) + prev=darwin_framework_skip ;; + *) compiler_flags="$compiler_flags $arg" + prev=darwin_framework ;; + esac + compile_command="$compile_command $arg" + finalize_command="$finalize_command $arg" + continue + ;; + + -inst-prefix-dir) + prev=inst_prefix + continue + ;; + + # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* + # so, if we see these flags be careful not to treat them like -L + -L[A-Z][A-Z]*:*) + case $with_gcc/$host in + no/*-*-irix* | /*-*-irix*) + compile_command="$compile_command $arg" + finalize_command="$finalize_command $arg" + ;; + esac + continue + ;; + + -L*) + dir=`$echo "X$arg" | $Xsed -e 's/^-L//'` + # We need an absolute path. + case $dir in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + absdir=`cd "$dir" && pwd` + if test -z "$absdir"; then + $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2 + absdir="$dir" + notinst_path="$notinst_path $dir" + fi + dir="$absdir" + ;; + esac + case "$deplibs " in + *" -L$dir "*) ;; + *) + deplibs="$deplibs -L$dir" + lib_search_path="$lib_search_path $dir" + ;; + esac + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) + testbindir=`$echo "X$dir" | $Xsed -e 's*/lib$*/bin*'` + case :$dllsearchpath: in + *":$dir:"*) ;; + *) dllsearchpath="$dllsearchpath:$dir";; + esac + case :$dllsearchpath: in + *":$testbindir:"*) ;; + *) dllsearchpath="$dllsearchpath:$testbindir";; + esac + ;; + esac + continue + ;; + + -l*) + if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos*) + # These systems don't actually have a C or math library (as such) + continue + ;; + *-*-os2*) + # These systems don't actually have a C library (as such) + test "X$arg" = "X-lc" && continue + ;; + *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) + # Do not include libc due to us having libc/libc_r. + test "X$arg" = "X-lc" && continue + ;; + *-*-rhapsody* | *-*-darwin1.[012]) + # Rhapsody C and math libraries are in the System framework + deplibs="$deplibs -framework System" + continue + ;; + *-*-sco3.2v5* | *-*-sco5v6*) + # Causes problems with __ctype + test "X$arg" = "X-lc" && continue + ;; + *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) + # Compiler inserts libc in the correct place for threads to work + test "X$arg" = "X-lc" && continue + ;; + esac + elif test "X$arg" = "X-lc_r"; then + case $host in + *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) + # Do not include libc_r directly, use -pthread flag. + continue + ;; + esac + fi + deplibs="$deplibs $arg" + continue + ;; + + # Tru64 UNIX uses -model [arg] to determine the layout of C++ + # classes, name mangling, and exception handling. + -model) + compile_command="$compile_command $arg" + compiler_flags="$compiler_flags $arg" + finalize_command="$finalize_command $arg" + prev=xcompiler + continue + ;; + + -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) + compiler_flags="$compiler_flags $arg" + compile_command="$compile_command $arg" + finalize_command="$finalize_command $arg" + continue + ;; + + -multi_module) + single_module="${wl}-multi_module" + continue + ;; + + -module) + module=yes + continue + ;; + + # -64, -mips[0-9] enable 64-bit mode on the SGI compiler + # -r[0-9][0-9]* specifies the processor on the SGI compiler + # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler + # +DA*, +DD* enable 64-bit mode on the HP compiler + # -q* pass through compiler args for the IBM compiler + # -m* pass through architecture-specific compiler args for GCC + # -m*, -t[45]*, -txscale* pass through architecture-specific + # compiler args for GCC + # -p, -pg, --coverage, -fprofile-* pass through profiling flag for GCC + # -F/path gives path to uninstalled frameworks, gcc on darwin + # @file GCC response files + -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ + -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*) + + # Unknown arguments in both finalize_command and compile_command need + # to be aesthetically quoted because they are evaled later. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + arg="\"$arg\"" + ;; + esac + compile_command="$compile_command $arg" + finalize_command="$finalize_command $arg" + compiler_flags="$compiler_flags $arg" + continue + ;; + + -shrext) + prev=shrext + continue + ;; + + -no-fast-install) + fast_install=no + continue + ;; + + -no-install) + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin*) + # The PATH hackery in wrapper scripts is required on Windows + # and Darwin in order for the loader to find any dlls it needs. + $echo "$modename: warning: \`-no-install' is ignored for $host" 1>&2 + $echo "$modename: warning: assuming \`-no-fast-install' instead" 1>&2 + fast_install=no + ;; + *) no_install=yes ;; + esac + continue + ;; + + -no-undefined) + allow_undefined=no + continue + ;; + + -objectlist) + prev=objectlist + continue + ;; + + -o) prev=output ;; + + -precious-files-regex) + prev=precious_regex + continue + ;; + + -release) + prev=release + continue + ;; + + -rpath) + prev=rpath + continue + ;; + + -R) + prev=xrpath + continue + ;; + + -R*) + dir=`$echo "X$arg" | $Xsed -e 's/^-R//'` + # We need an absolute path. + case $dir in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + $echo "$modename: only absolute run-paths are allowed" 1>&2 + exit $EXIT_FAILURE + ;; + esac + case "$xrpath " in + *" $dir "*) ;; + *) xrpath="$xrpath $dir" ;; + esac + continue + ;; + + -static | -static-libtool-libs) + # The effects of -static are defined in a previous loop. + # We used to do the same as -all-static on platforms that + # didn't have a PIC flag, but the assumption that the effects + # would be equivalent was wrong. It would break on at least + # Digital Unix and AIX. + continue + ;; + + -thread-safe) + thread_safe=yes + continue + ;; + + -version-info) + prev=vinfo + continue + ;; + -version-number) + prev=vinfo + vinfo_number=yes + continue + ;; + + -Wc,*) + args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'` + arg= + save_ifs="$IFS"; IFS=',' + for flag in $args; do + IFS="$save_ifs" + case $flag in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + flag="\"$flag\"" + ;; + esac + arg="$arg $wl$flag" + compiler_flags="$compiler_flags $flag" + done + IFS="$save_ifs" + arg=`$echo "X$arg" | $Xsed -e "s/^ //"` + ;; + + -Wl,*) + args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wl,//'` + arg= + save_ifs="$IFS"; IFS=',' + for flag in $args; do + IFS="$save_ifs" + case $flag in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + flag="\"$flag\"" + ;; + esac + arg="$arg $wl$flag" + compiler_flags="$compiler_flags $wl$flag" + linker_flags="$linker_flags $flag" + done + IFS="$save_ifs" + arg=`$echo "X$arg" | $Xsed -e "s/^ //"` + ;; + + -Xcompiler) + prev=xcompiler + continue + ;; + + -Xlinker) + prev=xlinker + continue + ;; + + -XCClinker) + prev=xcclinker + continue + ;; + + # Some other compiler flag. + -* | +*) + # Unknown arguments in both finalize_command and compile_command need + # to be aesthetically quoted because they are evaled later. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + arg="\"$arg\"" + ;; + esac + ;; + + *.$objext) + # A standard object. + objs="$objs $arg" + ;; + + *.lo) + # A libtool-controlled object. + + # Check to see that this really is a libtool object. + if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + pic_object= + non_pic_object= + + # Read the .lo file + # If there is no directory component, then add one. + case $arg in + */* | *\\*) . $arg ;; + *) . ./$arg ;; + esac + + if test -z "$pic_object" || \ + test -z "$non_pic_object" || + test "$pic_object" = none && \ + test "$non_pic_object" = none; then + $echo "$modename: cannot find name of object for \`$arg'" 1>&2 + exit $EXIT_FAILURE + fi + + # Extract subdirectory from the argument. + xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$arg"; then + xdir= + else + xdir="$xdir/" + fi + + if test "$pic_object" != none; then + # Prepend the subdirectory the object is found in. + pic_object="$xdir$pic_object" + + if test "$prev" = dlfiles; then + if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then + dlfiles="$dlfiles $pic_object" + prev= + continue + else + # If libtool objects are unsupported, then we need to preload. + prev=dlprefiles + fi + fi + + # CHECK ME: I think I busted this. -Ossama + if test "$prev" = dlprefiles; then + # Preload the old-style object. + dlprefiles="$dlprefiles $pic_object" + prev= + fi + + # A PIC object. + libobjs="$libobjs $pic_object" + arg="$pic_object" + fi + + # Non-PIC object. + if test "$non_pic_object" != none; then + # Prepend the subdirectory the object is found in. + non_pic_object="$xdir$non_pic_object" + + # A standard non-PIC object + non_pic_objects="$non_pic_objects $non_pic_object" + if test -z "$pic_object" || test "$pic_object" = none ; then + arg="$non_pic_object" + fi + else + # If the PIC object exists, use it instead. + # $xdir was prepended to $pic_object above. + non_pic_object="$pic_object" + non_pic_objects="$non_pic_objects $non_pic_object" + fi + else + # Only an error if not doing a dry-run. + if test -z "$run"; then + $echo "$modename: \`$arg' is not a valid libtool object" 1>&2 + exit $EXIT_FAILURE + else + # Dry-run case. + + # Extract subdirectory from the argument. + xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$arg"; then + xdir= + else + xdir="$xdir/" + fi + + pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"` + non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"` + libobjs="$libobjs $pic_object" + non_pic_objects="$non_pic_objects $non_pic_object" + fi + fi + ;; + + *.$libext) + # An archive. + deplibs="$deplibs $arg" + old_deplibs="$old_deplibs $arg" + continue + ;; + + *.la) + # A libtool-controlled library. + + if test "$prev" = dlfiles; then + # This library was specified with -dlopen. + dlfiles="$dlfiles $arg" + prev= + elif test "$prev" = dlprefiles; then + # The library was specified with -dlpreopen. + dlprefiles="$dlprefiles $arg" + prev= + else + deplibs="$deplibs $arg" + fi + continue + ;; + + # Some other compiler argument. + *) + # Unknown arguments in both finalize_command and compile_command need + # to be aesthetically quoted because they are evaled later. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + arg="\"$arg\"" + ;; + esac + ;; + esac # arg + + # Now actually substitute the argument into the commands. + if test -n "$arg"; then + compile_command="$compile_command $arg" + finalize_command="$finalize_command $arg" + fi + done # argument parsing loop + + if test -n "$prev"; then + $echo "$modename: the \`$prevarg' option requires an argument" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + + if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then + eval arg=\"$export_dynamic_flag_spec\" + compile_command="$compile_command $arg" + finalize_command="$finalize_command $arg" + fi + + oldlibs= + # calculate the name of the file, without its directory + outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'` + libobjs_save="$libobjs" + + if test -n "$shlibpath_var"; then + # get the directories listed in $shlibpath_var + eval shlib_search_path=\`\$echo \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\` + else + shlib_search_path= + fi + eval sys_lib_search_path=\"$sys_lib_search_path_spec\" + eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" + + output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'` + if test "X$output_objdir" = "X$output"; then + output_objdir="$objdir" + else + output_objdir="$output_objdir/$objdir" + fi + # Create the object directory. + if test ! -d "$output_objdir"; then + $show "$mkdir $output_objdir" + $run $mkdir $output_objdir + exit_status=$? + if test "$exit_status" -ne 0 && test ! -d "$output_objdir"; then + exit $exit_status + fi + fi + + # Determine the type of output + case $output in + "") + $echo "$modename: you must specify an output file" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + ;; + *.$libext) linkmode=oldlib ;; + *.lo | *.$objext) linkmode=obj ;; + *.la) linkmode=lib ;; + *) linkmode=prog ;; # Anything else should be a program. + esac + + case $host in + *cygwin* | *mingw* | *pw32*) + # don't eliminate duplications in $postdeps and $predeps + duplicate_compiler_generated_deps=yes + ;; + *) + duplicate_compiler_generated_deps=$duplicate_deps + ;; + esac + specialdeplibs= + + libs= + # Find all interdependent deplibs by searching for libraries + # that are linked more than once (e.g. -la -lb -la) + for deplib in $deplibs; do + if test "X$duplicate_deps" = "Xyes" ; then + case "$libs " in + *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; + esac + fi + libs="$libs $deplib" + done + + if test "$linkmode" = lib; then + libs="$predeps $libs $compiler_lib_search_path $postdeps" + + # Compute libraries that are listed more than once in $predeps + # $postdeps and mark them as special (i.e., whose duplicates are + # not to be eliminated). + pre_post_deps= + if test "X$duplicate_compiler_generated_deps" = "Xyes" ; then + for pre_post_dep in $predeps $postdeps; do + case "$pre_post_deps " in + *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;; + esac + pre_post_deps="$pre_post_deps $pre_post_dep" + done + fi + pre_post_deps= + fi + + deplibs= + newdependency_libs= + newlib_search_path= + need_relink=no # whether we're linking any uninstalled libtool libraries + notinst_deplibs= # not-installed libtool libraries + case $linkmode in + lib) + passes="conv link" + for file in $dlfiles $dlprefiles; do + case $file in + *.la) ;; + *) + $echo "$modename: libraries can \`-dlopen' only libtool libraries: $file" 1>&2 + exit $EXIT_FAILURE + ;; + esac + done + ;; + prog) + compile_deplibs= + finalize_deplibs= + alldeplibs=no + newdlfiles= + newdlprefiles= + passes="conv scan dlopen dlpreopen link" + ;; + *) passes="conv" + ;; + esac + for pass in $passes; do + if test "$linkmode,$pass" = "lib,link" || + test "$linkmode,$pass" = "prog,scan"; then + libs="$deplibs" + deplibs= + fi + if test "$linkmode" = prog; then + case $pass in + dlopen) libs="$dlfiles" ;; + dlpreopen) libs="$dlprefiles" ;; + link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; + esac + fi + if test "$pass" = dlopen; then + # Collect dlpreopened libraries + save_deplibs="$deplibs" + deplibs= + fi + for deplib in $libs; do + lib= + found=no + case $deplib in + -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) + if test "$linkmode,$pass" = "prog,link"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + compiler_flags="$compiler_flags $deplib" + fi + continue + ;; + -l*) + if test "$linkmode" != lib && test "$linkmode" != prog; then + $echo "$modename: warning: \`-l' is ignored for archives/objects" 1>&2 + continue + fi + name=`$echo "X$deplib" | $Xsed -e 's/^-l//'` + if test "$linkmode" = lib; then + searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" + else + searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" + fi + for searchdir in $searchdirs; do + for search_ext in .la $std_shrext .so .a; do + # Search the libtool library + lib="$searchdir/lib${name}${search_ext}" + if test -f "$lib"; then + if test "$search_ext" = ".la"; then + found=yes + else + found=no + fi + break 2 + fi + done + done + if test "$found" != yes; then + # deplib doesn't seem to be a libtool library + if test "$linkmode,$pass" = "prog,link"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + deplibs="$deplib $deplibs" + test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" + fi + continue + else # deplib is a libtool library + # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, + # We need to do some special things here, and not later. + if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then + case " $predeps $postdeps " in + *" $deplib "*) + if (${SED} -e '2q' $lib | + grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + library_names= + old_library= + case $lib in + */* | *\\*) . $lib ;; + *) . ./$lib ;; + esac + for l in $old_library $library_names; do + ll="$l" + done + if test "X$ll" = "X$old_library" ; then # only static version available + found=no + ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'` + test "X$ladir" = "X$lib" && ladir="." + lib=$ladir/$old_library + if test "$linkmode,$pass" = "prog,link"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + deplibs="$deplib $deplibs" + test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" + fi + continue + fi + fi + ;; + *) ;; + esac + fi + fi + ;; # -l + -L*) + case $linkmode in + lib) + deplibs="$deplib $deplibs" + test "$pass" = conv && continue + newdependency_libs="$deplib $newdependency_libs" + newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'` + ;; + prog) + if test "$pass" = conv; then + deplibs="$deplib $deplibs" + continue + fi + if test "$pass" = scan; then + deplibs="$deplib $deplibs" + else + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + fi + newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'` + ;; + *) + $echo "$modename: warning: \`-L' is ignored for archives/objects" 1>&2 + ;; + esac # linkmode + continue + ;; # -L + -R*) + if test "$pass" = link; then + dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'` + # Make sure the xrpath contains only unique directories. + case "$xrpath " in + *" $dir "*) ;; + *) xrpath="$xrpath $dir" ;; + esac + fi + deplibs="$deplib $deplibs" + continue + ;; + *.la) lib="$deplib" ;; + *.$libext) + if test "$pass" = conv; then + deplibs="$deplib $deplibs" + continue + fi + case $linkmode in + lib) + valid_a_lib=no + case $deplibs_check_method in + match_pattern*) + set dummy $deplibs_check_method + match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"` + if eval $echo \"$deplib\" 2>/dev/null \ + | $SED 10q \ + | $EGREP "$match_pattern_regex" > /dev/null; then + valid_a_lib=yes + fi + ;; + pass_all) + valid_a_lib=yes + ;; + esac + if test "$valid_a_lib" != yes; then + $echo + $echo "*** Warning: Trying to link with static lib archive $deplib." + $echo "*** I have the capability to make that library automatically link in when" + $echo "*** you link to this library. But I can only do this if you have a" + $echo "*** shared version of the library, which you do not appear to have" + $echo "*** because the file extensions .$libext of this argument makes me believe" + $echo "*** that it is just a static archive that I should not used here." + else + $echo + $echo "*** Warning: Linking the shared library $output against the" + $echo "*** static library $deplib is not portable!" + deplibs="$deplib $deplibs" + fi + continue + ;; + prog) + if test "$pass" != link; then + deplibs="$deplib $deplibs" + else + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + fi + continue + ;; + esac # linkmode + ;; # *.$libext + *.lo | *.$objext) + if test "$pass" = conv; then + deplibs="$deplib $deplibs" + elif test "$linkmode" = prog; then + if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then + # If there is no dlopen support or we're linking statically, + # we need to preload. + newdlprefiles="$newdlprefiles $deplib" + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + newdlfiles="$newdlfiles $deplib" + fi + fi + continue + ;; + %DEPLIBS%) + alldeplibs=yes + continue + ;; + esac # case $deplib + if test "$found" = yes || test -f "$lib"; then : + else + $echo "$modename: cannot find the library \`$lib' or unhandled argument \`$deplib'" 1>&2 + exit $EXIT_FAILURE + fi + + # Check to see that this really is a libtool archive. + if (${SED} -e '2q' $lib | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : + else + $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 + exit $EXIT_FAILURE + fi + + ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'` + test "X$ladir" = "X$lib" && ladir="." + + dlname= + dlopen= + dlpreopen= + libdir= + library_names= + old_library= + # If the library was installed with an old release of libtool, + # it will not redefine variables installed, or shouldnotlink + installed=yes + shouldnotlink=no + avoidtemprpath= + + + # Read the .la file + case $lib in + */* | *\\*) . $lib ;; + *) . ./$lib ;; + esac + + if test "$linkmode,$pass" = "lib,link" || + test "$linkmode,$pass" = "prog,scan" || + { test "$linkmode" != prog && test "$linkmode" != lib; }; then + test -n "$dlopen" && dlfiles="$dlfiles $dlopen" + test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen" + fi + + if test "$pass" = conv; then + # Only check for convenience libraries + deplibs="$lib $deplibs" + if test -z "$libdir"; then + if test -z "$old_library"; then + $echo "$modename: cannot find name of link library for \`$lib'" 1>&2 + exit $EXIT_FAILURE + fi + # It is a libtool convenience library, so add in its objects. + convenience="$convenience $ladir/$objdir/$old_library" + old_convenience="$old_convenience $ladir/$objdir/$old_library" + tmp_libs= + for deplib in $dependency_libs; do + deplibs="$deplib $deplibs" + if test "X$duplicate_deps" = "Xyes" ; then + case "$tmp_libs " in + *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; + esac + fi + tmp_libs="$tmp_libs $deplib" + done + elif test "$linkmode" != prog && test "$linkmode" != lib; then + $echo "$modename: \`$lib' is not a convenience library" 1>&2 + exit $EXIT_FAILURE + fi + continue + fi # $pass = conv + + + # Get the name of the library we link against. + linklib= + for l in $old_library $library_names; do + linklib="$l" + done + if test -z "$linklib"; then + $echo "$modename: cannot find name of link library for \`$lib'" 1>&2 + exit $EXIT_FAILURE + fi + + # This library was specified with -dlopen. + if test "$pass" = dlopen; then + if test -z "$libdir"; then + $echo "$modename: cannot -dlopen a convenience library: \`$lib'" 1>&2 + exit $EXIT_FAILURE + fi + if test -z "$dlname" || + test "$dlopen_support" != yes || + test "$build_libtool_libs" = no; then + # If there is no dlname, no dlopen support or we're linking + # statically, we need to preload. We also need to preload any + # dependent libraries so libltdl's deplib preloader doesn't + # bomb out in the load deplibs phase. + dlprefiles="$dlprefiles $lib $dependency_libs" + else + newdlfiles="$newdlfiles $lib" + fi + continue + fi # $pass = dlopen + + # We need an absolute path. + case $ladir in + [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; + *) + abs_ladir=`cd "$ladir" && pwd` + if test -z "$abs_ladir"; then + $echo "$modename: warning: cannot determine absolute directory name of \`$ladir'" 1>&2 + $echo "$modename: passing it literally to the linker, although it might fail" 1>&2 + abs_ladir="$ladir" + fi + ;; + esac + laname=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` + + # Find the relevant object directory and library name. + if test "X$installed" = Xyes; then + if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then + $echo "$modename: warning: library \`$lib' was moved." 1>&2 + dir="$ladir" + absdir="$abs_ladir" + libdir="$abs_ladir" + else + dir="$libdir" + absdir="$libdir" + fi + test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes + else + if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then + dir="$ladir" + absdir="$abs_ladir" + # Remove this search path later + notinst_path="$notinst_path $abs_ladir" + else + dir="$ladir/$objdir" + absdir="$abs_ladir/$objdir" + # Remove this search path later + notinst_path="$notinst_path $abs_ladir" + fi + fi # $installed = yes + name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'` + + # This library was specified with -dlpreopen. + if test "$pass" = dlpreopen; then + if test -z "$libdir"; then + $echo "$modename: cannot -dlpreopen a convenience library: \`$lib'" 1>&2 + exit $EXIT_FAILURE + fi + # Prefer using a static library (so that no silly _DYNAMIC symbols + # are required to link). + if test -n "$old_library"; then + newdlprefiles="$newdlprefiles $dir/$old_library" + # Otherwise, use the dlname, so that lt_dlopen finds it. + elif test -n "$dlname"; then + newdlprefiles="$newdlprefiles $dir/$dlname" + else + newdlprefiles="$newdlprefiles $dir/$linklib" + fi + fi # $pass = dlpreopen + + if test -z "$libdir"; then + # Link the convenience library + if test "$linkmode" = lib; then + deplibs="$dir/$old_library $deplibs" + elif test "$linkmode,$pass" = "prog,link"; then + compile_deplibs="$dir/$old_library $compile_deplibs" + finalize_deplibs="$dir/$old_library $finalize_deplibs" + else + deplibs="$lib $deplibs" # used for prog,scan pass + fi + continue + fi + + + if test "$linkmode" = prog && test "$pass" != link; then + newlib_search_path="$newlib_search_path $ladir" + deplibs="$lib $deplibs" + + linkalldeplibs=no + if test "$link_all_deplibs" != no || test -z "$library_names" || + test "$build_libtool_libs" = no; then + linkalldeplibs=yes + fi + + tmp_libs= + for deplib in $dependency_libs; do + case $deplib in + -L*) newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`;; ### testsuite: skip nested quoting test + esac + # Need to link against all dependency_libs? + if test "$linkalldeplibs" = yes; then + deplibs="$deplib $deplibs" + else + # Need to hardcode shared library paths + # or/and link against static libraries + newdependency_libs="$deplib $newdependency_libs" + fi + if test "X$duplicate_deps" = "Xyes" ; then + case "$tmp_libs " in + *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; + esac + fi + tmp_libs="$tmp_libs $deplib" + done # for deplib + continue + fi # $linkmode = prog... + + if test "$linkmode,$pass" = "prog,link"; then + if test -n "$library_names" && + { { test "$prefer_static_libs" = no || + test "$prefer_static_libs,$installed" = "built,yes"; } || + test -z "$old_library"; }; then + # We need to hardcode the library path + if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then + # Make sure the rpath contains only unique directories. + case "$temp_rpath " in + *" $dir "*) ;; + *" $absdir "*) ;; + *) temp_rpath="$temp_rpath $absdir" ;; + esac + fi + + # Hardcode the library path. + # Skip directories that are in the system default run-time + # search path. + case " $sys_lib_dlsearch_path " in + *" $absdir "*) ;; + *) + case "$compile_rpath " in + *" $absdir "*) ;; + *) compile_rpath="$compile_rpath $absdir" + esac + ;; + esac + case " $sys_lib_dlsearch_path " in + *" $libdir "*) ;; + *) + case "$finalize_rpath " in + *" $libdir "*) ;; + *) finalize_rpath="$finalize_rpath $libdir" + esac + ;; + esac + fi # $linkmode,$pass = prog,link... + + if test "$alldeplibs" = yes && + { test "$deplibs_check_method" = pass_all || + { test "$build_libtool_libs" = yes && + test -n "$library_names"; }; }; then + # We only need to search for static libraries + continue + fi + fi + + link_static=no # Whether the deplib will be linked statically + use_static_libs=$prefer_static_libs + if test "$use_static_libs" = built && test "$installed" = yes ; then + use_static_libs=no + fi + if test -n "$library_names" && + { test "$use_static_libs" = no || test -z "$old_library"; }; then + if test "$installed" = no; then + notinst_deplibs="$notinst_deplibs $lib" + need_relink=yes + fi + # This is a shared library + + # Warn about portability, can't link against -module's on + # some systems (darwin) + if test "$shouldnotlink" = yes && test "$pass" = link ; then + $echo + if test "$linkmode" = prog; then + $echo "*** Warning: Linking the executable $output against the loadable module" + else + $echo "*** Warning: Linking the shared library $output against the loadable module" + fi + $echo "*** $linklib is not portable!" + fi + if test "$linkmode" = lib && + test "$hardcode_into_libs" = yes; then + # Hardcode the library path. + # Skip directories that are in the system default run-time + # search path. + case " $sys_lib_dlsearch_path " in + *" $absdir "*) ;; + *) + case "$compile_rpath " in + *" $absdir "*) ;; + *) compile_rpath="$compile_rpath $absdir" + esac + ;; + esac + case " $sys_lib_dlsearch_path " in + *" $libdir "*) ;; + *) + case "$finalize_rpath " in + *" $libdir "*) ;; + *) finalize_rpath="$finalize_rpath $libdir" + esac + ;; + esac + fi + + if test -n "$old_archive_from_expsyms_cmds"; then + # figure out the soname + set dummy $library_names + realname="$2" + shift; shift + libname=`eval \\$echo \"$libname_spec\"` + # use dlname if we got it. it's perfectly good, no? + if test -n "$dlname"; then + soname="$dlname" + elif test -n "$soname_spec"; then + # bleh windows + case $host in + *cygwin* | mingw*) + major=`expr $current - $age` + versuffix="-$major" + ;; + esac + eval soname=\"$soname_spec\" + else + soname="$realname" + fi + + # Make a new name for the extract_expsyms_cmds to use + soroot="$soname" + soname=`$echo $soroot | ${SED} -e 's/^.*\///'` + newlib="libimp-`$echo $soname | ${SED} 's/^lib//;s/\.dll$//'`.a" + + # If the library has no export list, then create one now + if test -f "$output_objdir/$soname-def"; then : + else + $show "extracting exported symbol list from \`$soname'" + save_ifs="$IFS"; IFS='~' + cmds=$extract_expsyms_cmds + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + fi + + # Create $newlib + if test -f "$output_objdir/$newlib"; then :; else + $show "generating import library for \`$soname'" + save_ifs="$IFS"; IFS='~' + cmds=$old_archive_from_expsyms_cmds + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + fi + # make sure the library variables are pointing to the new library + dir=$output_objdir + linklib=$newlib + fi # test -n "$old_archive_from_expsyms_cmds" + + if test "$linkmode" = prog || test "$mode" != relink; then + add_shlibpath= + add_dir= + add= + lib_linked=yes + case $hardcode_action in + immediate | unsupported) + if test "$hardcode_direct" = no; then + add="$dir/$linklib" + case $host in + *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; + *-*-sysv4*uw2*) add_dir="-L$dir" ;; + *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ + *-*-unixware7*) add_dir="-L$dir" ;; + *-*-darwin* ) + # if the lib is a module then we can not link against + # it, someone is ignoring the new warnings I added + if /usr/bin/file -L $add 2> /dev/null | + $EGREP ": [^:]* bundle" >/dev/null ; then + $echo "** Warning, lib $linklib is a module, not a shared library" + if test -z "$old_library" ; then + $echo + $echo "** And there doesn't seem to be a static archive available" + $echo "** The link will probably fail, sorry" + else + add="$dir/$old_library" + fi + fi + esac + elif test "$hardcode_minus_L" = no; then + case $host in + *-*-sunos*) add_shlibpath="$dir" ;; + esac + add_dir="-L$dir" + add="-l$name" + elif test "$hardcode_shlibpath_var" = no; then + add_shlibpath="$dir" + add="-l$name" + else + lib_linked=no + fi + ;; + relink) + if test "$hardcode_direct" = yes; then + add="$dir/$linklib" + elif test "$hardcode_minus_L" = yes; then + add_dir="-L$dir" + # Try looking first in the location we're being installed to. + if test -n "$inst_prefix_dir"; then + case $libdir in + [\\/]*) + add_dir="$add_dir -L$inst_prefix_dir$libdir" + ;; + esac + fi + add="-l$name" + elif test "$hardcode_shlibpath_var" = yes; then + add_shlibpath="$dir" + add="-l$name" + else + lib_linked=no + fi + ;; + *) lib_linked=no ;; + esac + + if test "$lib_linked" != yes; then + $echo "$modename: configuration error: unsupported hardcode properties" + exit $EXIT_FAILURE + fi + + if test -n "$add_shlibpath"; then + case :$compile_shlibpath: in + *":$add_shlibpath:"*) ;; + *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;; + esac + fi + if test "$linkmode" = prog; then + test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" + test -n "$add" && compile_deplibs="$add $compile_deplibs" + else + test -n "$add_dir" && deplibs="$add_dir $deplibs" + test -n "$add" && deplibs="$add $deplibs" + if test "$hardcode_direct" != yes && \ + test "$hardcode_minus_L" != yes && \ + test "$hardcode_shlibpath_var" = yes; then + case :$finalize_shlibpath: in + *":$libdir:"*) ;; + *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; + esac + fi + fi + fi + + if test "$linkmode" = prog || test "$mode" = relink; then + add_shlibpath= + add_dir= + add= + # Finalize command for both is simple: just hardcode it. + if test "$hardcode_direct" = yes; then + add="$libdir/$linklib" + elif test "$hardcode_minus_L" = yes; then + add_dir="-L$libdir" + add="-l$name" + elif test "$hardcode_shlibpath_var" = yes; then + case :$finalize_shlibpath: in + *":$libdir:"*) ;; + *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; + esac + add="-l$name" + elif test "$hardcode_automatic" = yes; then + if test -n "$inst_prefix_dir" && + test -f "$inst_prefix_dir$libdir/$linklib" ; then + add="$inst_prefix_dir$libdir/$linklib" + else + add="$libdir/$linklib" + fi + else + # We cannot seem to hardcode it, guess we'll fake it. + add_dir="-L$libdir" + # Try looking first in the location we're being installed to. + if test -n "$inst_prefix_dir"; then + case $libdir in + [\\/]*) + add_dir="$add_dir -L$inst_prefix_dir$libdir" + ;; + esac + fi + add="-l$name" + fi + + if test "$linkmode" = prog; then + test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" + test -n "$add" && finalize_deplibs="$add $finalize_deplibs" + else + test -n "$add_dir" && deplibs="$add_dir $deplibs" + test -n "$add" && deplibs="$add $deplibs" + fi + fi + elif test "$linkmode" = prog; then + # Here we assume that one of hardcode_direct or hardcode_minus_L + # is not unsupported. This is valid on all known static and + # shared platforms. + if test "$hardcode_direct" != unsupported; then + test -n "$old_library" && linklib="$old_library" + compile_deplibs="$dir/$linklib $compile_deplibs" + finalize_deplibs="$dir/$linklib $finalize_deplibs" + else + compile_deplibs="-l$name -L$dir $compile_deplibs" + finalize_deplibs="-l$name -L$dir $finalize_deplibs" + fi + elif test "$build_libtool_libs" = yes; then + # Not a shared library + if test "$deplibs_check_method" != pass_all; then + # We're trying link a shared library against a static one + # but the system doesn't support it. + + # Just print a warning and add the library to dependency_libs so + # that the program can be linked against the static library. + $echo + $echo "*** Warning: This system can not link to static lib archive $lib." + $echo "*** I have the capability to make that library automatically link in when" + $echo "*** you link to this library. But I can only do this if you have a" + $echo "*** shared version of the library, which you do not appear to have." + if test "$module" = yes; then + $echo "*** But as you try to build a module library, libtool will still create " + $echo "*** a static module, that should work as long as the dlopening application" + $echo "*** is linked with the -dlopen flag to resolve symbols at runtime." + if test -z "$global_symbol_pipe"; then + $echo + $echo "*** However, this would only work if libtool was able to extract symbol" + $echo "*** lists from a program, using \`nm' or equivalent, but libtool could" + $echo "*** not find such a program. So, this module is probably useless." + $echo "*** \`nm' from GNU binutils and a full rebuild may help." + fi + if test "$build_old_libs" = no; then + build_libtool_libs=module + build_old_libs=yes + else + build_libtool_libs=no + fi + fi + else + deplibs="$dir/$old_library $deplibs" + link_static=yes + fi + fi # link shared/static library? + + if test "$linkmode" = lib; then + if test -n "$dependency_libs" && + { test "$hardcode_into_libs" != yes || + test "$build_old_libs" = yes || + test "$link_static" = yes; }; then + # Extract -R from dependency_libs + temp_deplibs= + for libdir in $dependency_libs; do + case $libdir in + -R*) temp_xrpath=`$echo "X$libdir" | $Xsed -e 's/^-R//'` + case " $xrpath " in + *" $temp_xrpath "*) ;; + *) xrpath="$xrpath $temp_xrpath";; + esac;; + *) temp_deplibs="$temp_deplibs $libdir";; + esac + done + dependency_libs="$temp_deplibs" + fi + + newlib_search_path="$newlib_search_path $absdir" + # Link against this library + test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" + # ... and its dependency_libs + tmp_libs= + for deplib in $dependency_libs; do + newdependency_libs="$deplib $newdependency_libs" + if test "X$duplicate_deps" = "Xyes" ; then + case "$tmp_libs " in + *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; + esac + fi + tmp_libs="$tmp_libs $deplib" + done + + if test "$link_all_deplibs" != no; then + # Add the search paths of all dependency libraries + for deplib in $dependency_libs; do + case $deplib in + -L*) path="$deplib" ;; + *.la) + dir=`$echo "X$deplib" | $Xsed -e 's%/[^/]*$%%'` + test "X$dir" = "X$deplib" && dir="." + # We need an absolute path. + case $dir in + [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; + *) + absdir=`cd "$dir" && pwd` + if test -z "$absdir"; then + $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2 + absdir="$dir" + fi + ;; + esac + if grep "^installed=no" $deplib > /dev/null; then + path="$absdir/$objdir" + else + eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` + if test -z "$libdir"; then + $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2 + exit $EXIT_FAILURE + fi + if test "$absdir" != "$libdir"; then + $echo "$modename: warning: \`$deplib' seems to be moved" 1>&2 + fi + path="$absdir" + fi + depdepl= + case $host in + *-*-darwin*) + # we do not want to link against static libs, + # but need to link against shared + eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` + eval deplibdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` + if test -n "$deplibrary_names" ; then + for tmp in $deplibrary_names ; do + depdepl=$tmp + done + if test -f "$deplibdir/$depdepl" ; then + depdepl="$deplibdir/$depdepl" + elif test -f "$path/$depdepl" ; then + depdepl="$path/$depdepl" + else + # Can't find it, oh well... + depdepl= + fi + # do not add paths which are already there + case " $newlib_search_path " in + *" $path "*) ;; + *) newlib_search_path="$newlib_search_path $path";; + esac + fi + path="" + ;; + *) + path="-L$path" + ;; + esac + ;; + -l*) + case $host in + *-*-darwin*) + # Again, we only want to link against shared libraries + eval tmp_libs=`$echo "X$deplib" | $Xsed -e "s,^\-l,,"` + for tmp in $newlib_search_path ; do + if test -f "$tmp/lib$tmp_libs.dylib" ; then + eval depdepl="$tmp/lib$tmp_libs.dylib" + break + fi + done + path="" + ;; + *) continue ;; + esac + ;; + *) continue ;; + esac + case " $deplibs " in + *" $path "*) ;; + *) deplibs="$path $deplibs" ;; + esac + case " $deplibs " in + *" $depdepl "*) ;; + *) deplibs="$depdepl $deplibs" ;; + esac + done + fi # link_all_deplibs != no + fi # linkmode = lib + done # for deplib in $libs + dependency_libs="$newdependency_libs" + if test "$pass" = dlpreopen; then + # Link the dlpreopened libraries before other libraries + for deplib in $save_deplibs; do + deplibs="$deplib $deplibs" + done + fi + if test "$pass" != dlopen; then + if test "$pass" != conv; then + # Make sure lib_search_path contains only unique directories. + lib_search_path= + for dir in $newlib_search_path; do + case "$lib_search_path " in + *" $dir "*) ;; + *) lib_search_path="$lib_search_path $dir" ;; + esac + done + newlib_search_path= + fi + + if test "$linkmode,$pass" != "prog,link"; then + vars="deplibs" + else + vars="compile_deplibs finalize_deplibs" + fi + for var in $vars dependency_libs; do + # Add libraries to $var in reverse order + eval tmp_libs=\"\$$var\" + new_libs= + for deplib in $tmp_libs; do + # FIXME: Pedantically, this is the right thing to do, so + # that some nasty dependency loop isn't accidentally + # broken: + #new_libs="$deplib $new_libs" + # Pragmatically, this seems to cause very few problems in + # practice: + case $deplib in + -L*) new_libs="$deplib $new_libs" ;; + -R*) ;; + *) + # And here is the reason: when a library appears more + # than once as an explicit dependence of a library, or + # is implicitly linked in more than once by the + # compiler, it is considered special, and multiple + # occurrences thereof are not removed. Compare this + # with having the same library being listed as a + # dependency of multiple other libraries: in this case, + # we know (pedantically, we assume) the library does not + # need to be listed more than once, so we keep only the + # last copy. This is not always right, but it is rare + # enough that we require users that really mean to play + # such unportable linking tricks to link the library + # using -Wl,-lname, so that libtool does not consider it + # for duplicate removal. + case " $specialdeplibs " in + *" $deplib "*) new_libs="$deplib $new_libs" ;; + *) + case " $new_libs " in + *" $deplib "*) ;; + *) new_libs="$deplib $new_libs" ;; + esac + ;; + esac + ;; + esac + done + tmp_libs= + for deplib in $new_libs; do + case $deplib in + -L*) + case " $tmp_libs " in + *" $deplib "*) ;; + *) tmp_libs="$tmp_libs $deplib" ;; + esac + ;; + *) tmp_libs="$tmp_libs $deplib" ;; + esac + done + eval $var=\"$tmp_libs\" + done # for var + fi + # Last step: remove runtime libs from dependency_libs + # (they stay in deplibs) + tmp_libs= + for i in $dependency_libs ; do + case " $predeps $postdeps $compiler_lib_search_path " in + *" $i "*) + i="" + ;; + esac + if test -n "$i" ; then + tmp_libs="$tmp_libs $i" + fi + done + dependency_libs=$tmp_libs + done # for pass + if test "$linkmode" = prog; then + dlfiles="$newdlfiles" + dlprefiles="$newdlprefiles" + fi + + case $linkmode in + oldlib) + case " $deplibs" in + *\ -l* | *\ -L*) + $echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2 ;; + esac + + if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then + $echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2 + fi + + if test -n "$rpath"; then + $echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2 + fi + + if test -n "$xrpath"; then + $echo "$modename: warning: \`-R' is ignored for archives" 1>&2 + fi + + if test -n "$vinfo"; then + $echo "$modename: warning: \`-version-info/-version-number' is ignored for archives" 1>&2 + fi + + if test -n "$release"; then + $echo "$modename: warning: \`-release' is ignored for archives" 1>&2 + fi + + if test -n "$export_symbols" || test -n "$export_symbols_regex"; then + $echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2 + fi + + # Now set the variables for building old libraries. + build_libtool_libs=no + oldlibs="$output" + objs="$objs$old_deplibs" + ;; + + lib) + # Make sure we only generate libraries of the form `libNAME.la'. + case $outputname in + lib*) + name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'` + eval shared_ext=\"$shrext_cmds\" + eval libname=\"$libname_spec\" + ;; + *) + if test "$module" = no; then + $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + if test "$need_lib_prefix" != no; then + # Add the "lib" prefix for modules if required + name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'` + eval shared_ext=\"$shrext_cmds\" + eval libname=\"$libname_spec\" + else + libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'` + fi + ;; + esac + + if test -n "$objs"; then + if test "$deplibs_check_method" != pass_all; then + $echo "$modename: cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 2>&1 + exit $EXIT_FAILURE + else + $echo + $echo "*** Warning: Linking the shared library $output against the non-libtool" + $echo "*** objects $objs is not portable!" + libobjs="$libobjs $objs" + fi + fi + + if test "$dlself" != no; then + $echo "$modename: warning: \`-dlopen self' is ignored for libtool libraries" 1>&2 + fi + + set dummy $rpath + if test "$#" -gt 2; then + $echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2 + fi + install_libdir="$2" + + oldlibs= + if test -z "$rpath"; then + if test "$build_libtool_libs" = yes; then + # Building a libtool convenience library. + # Some compilers have problems with a `.al' extension so + # convenience libraries should have the same extension an + # archive normally would. + oldlibs="$output_objdir/$libname.$libext $oldlibs" + build_libtool_libs=convenience + build_old_libs=yes + fi + + if test -n "$vinfo"; then + $echo "$modename: warning: \`-version-info/-version-number' is ignored for convenience libraries" 1>&2 + fi + + if test -n "$release"; then + $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2 + fi + else + + # Parse the version information argument. + save_ifs="$IFS"; IFS=':' + set dummy $vinfo 0 0 0 + IFS="$save_ifs" + + if test -n "$8"; then + $echo "$modename: too many parameters to \`-version-info'" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + + # convert absolute version numbers to libtool ages + # this retains compatibility with .la files and attempts + # to make the code below a bit more comprehensible + + case $vinfo_number in + yes) + number_major="$2" + number_minor="$3" + number_revision="$4" + # + # There are really only two kinds -- those that + # use the current revision as the major version + # and those that subtract age and use age as + # a minor version. But, then there is irix + # which has an extra 1 added just for fun + # + case $version_type in + darwin|linux|osf|windows|none) + current=`expr $number_major + $number_minor` + age="$number_minor" + revision="$number_revision" + ;; + freebsd-aout|freebsd-elf|sunos) + current="$number_major" + revision="$number_minor" + age="0" + ;; + irix|nonstopux) + current=`expr $number_major + $number_minor` + age="$number_minor" + revision="$number_minor" + lt_irix_increment=no + ;; + esac + ;; + no) + current="$2" + revision="$3" + age="$4" + ;; + esac + + # Check that each of the things are valid numbers. + case $current in + 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; + *) + $echo "$modename: CURRENT \`$current' must be a nonnegative integer" 1>&2 + $echo "$modename: \`$vinfo' is not valid version information" 1>&2 + exit $EXIT_FAILURE + ;; + esac + + case $revision in + 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; + *) + $echo "$modename: REVISION \`$revision' must be a nonnegative integer" 1>&2 + $echo "$modename: \`$vinfo' is not valid version information" 1>&2 + exit $EXIT_FAILURE + ;; + esac + + case $age in + 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; + *) + $echo "$modename: AGE \`$age' must be a nonnegative integer" 1>&2 + $echo "$modename: \`$vinfo' is not valid version information" 1>&2 + exit $EXIT_FAILURE + ;; + esac + + if test "$age" -gt "$current"; then + $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2 + $echo "$modename: \`$vinfo' is not valid version information" 1>&2 + exit $EXIT_FAILURE + fi + + # Calculate the version variables. + major= + versuffix= + verstring= + case $version_type in + none) ;; + + darwin) + # Like Linux, but with the current version available in + # verstring for coding it into the library header + major=.`expr $current - $age` + versuffix="$major.$age.$revision" + # Darwin ld doesn't like 0 for these options... + minor_current=`expr $current + 1` + xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" + verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" + ;; + + freebsd-aout) + major=".$current" + versuffix=".$current.$revision"; + ;; + + freebsd-elf) + major=".$current" + versuffix=".$current"; + ;; + + irix | nonstopux) + if test "X$lt_irix_increment" = "Xno"; then + major=`expr $current - $age` + else + major=`expr $current - $age + 1` + fi + case $version_type in + nonstopux) verstring_prefix=nonstopux ;; + *) verstring_prefix=sgi ;; + esac + verstring="$verstring_prefix$major.$revision" + + # Add in all the interfaces that we are compatible with. + loop=$revision + while test "$loop" -ne 0; do + iface=`expr $revision - $loop` + loop=`expr $loop - 1` + verstring="$verstring_prefix$major.$iface:$verstring" + done + + # Before this point, $major must not contain `.'. + major=.$major + versuffix="$major.$revision" + ;; + + linux) + major=.`expr $current - $age` + versuffix="$major.$age.$revision" + ;; + + osf) + major=.`expr $current - $age` + versuffix=".$current.$age.$revision" + verstring="$current.$age.$revision" + + # Add in all the interfaces that we are compatible with. + loop=$age + while test "$loop" -ne 0; do + iface=`expr $current - $loop` + loop=`expr $loop - 1` + verstring="$verstring:${iface}.0" + done + + # Make executables depend on our current version. + verstring="$verstring:${current}.0" + ;; + + sunos) + major=".$current" + versuffix=".$current.$revision" + ;; + + windows) + # Use '-' rather than '.', since we only want one + # extension on DOS 8.3 filesystems. + major=`expr $current - $age` + versuffix="-$major" + ;; + + *) + $echo "$modename: unknown library version type \`$version_type'" 1>&2 + $echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 + exit $EXIT_FAILURE + ;; + esac + + # Clear the version info if we defaulted, and they specified a release. + if test -z "$vinfo" && test -n "$release"; then + major= + case $version_type in + darwin) + # we can't check for "0.0" in archive_cmds due to quoting + # problems, so we reset it completely + verstring= + ;; + *) + verstring="0.0" + ;; + esac + if test "$need_version" = no; then + versuffix= + else + versuffix=".0.0" + fi + fi + + # Remove version info from name if versioning should be avoided + if test "$avoid_version" = yes && test "$need_version" = no; then + major= + versuffix= + verstring="" + fi + + # Check to see if the archive will have undefined symbols. + if test "$allow_undefined" = yes; then + if test "$allow_undefined_flag" = unsupported; then + $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2 + build_libtool_libs=no + build_old_libs=yes + fi + else + # Don't allow undefined symbols. + allow_undefined_flag="$no_undefined_flag" + fi + fi + + if test "$mode" != relink; then + # Remove our outputs, but don't remove object files since they + # may have been created when compiling PIC objects. + removelist= + tempremovelist=`$echo "$output_objdir/*"` + for p in $tempremovelist; do + case $p in + *.$objext) + ;; + $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) + if test "X$precious_files_regex" != "X"; then + if echo $p | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 + then + continue + fi + fi + removelist="$removelist $p" + ;; + *) ;; + esac + done + if test -n "$removelist"; then + $show "${rm}r $removelist" + $run ${rm}r $removelist + fi + fi + + # Now set the variables for building old libraries. + if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then + oldlibs="$oldlibs $output_objdir/$libname.$libext" + + # Transform .lo files to .o files. + oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP` + fi + + # Eliminate all temporary directories. + #for path in $notinst_path; do + # lib_search_path=`$echo "$lib_search_path " | ${SED} -e "s% $path % %g"` + # deplibs=`$echo "$deplibs " | ${SED} -e "s% -L$path % %g"` + # dependency_libs=`$echo "$dependency_libs " | ${SED} -e "s% -L$path % %g"` + #done + + if test -n "$xrpath"; then + # If the user specified any rpath flags, then add them. + temp_xrpath= + for libdir in $xrpath; do + temp_xrpath="$temp_xrpath -R$libdir" + case "$finalize_rpath " in + *" $libdir "*) ;; + *) finalize_rpath="$finalize_rpath $libdir" ;; + esac + done + if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then + dependency_libs="$temp_xrpath $dependency_libs" + fi + fi + + # Make sure dlfiles contains only unique files that won't be dlpreopened + old_dlfiles="$dlfiles" + dlfiles= + for lib in $old_dlfiles; do + case " $dlprefiles $dlfiles " in + *" $lib "*) ;; + *) dlfiles="$dlfiles $lib" ;; + esac + done + + # Make sure dlprefiles contains only unique files + old_dlprefiles="$dlprefiles" + dlprefiles= + for lib in $old_dlprefiles; do + case "$dlprefiles " in + *" $lib "*) ;; + *) dlprefiles="$dlprefiles $lib" ;; + esac + done + + if test "$build_libtool_libs" = yes; then + if test -n "$rpath"; then + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*) + # these systems don't actually have a c library (as such)! + ;; + *-*-rhapsody* | *-*-darwin1.[012]) + # Rhapsody C library is in the System framework + deplibs="$deplibs -framework System" + ;; + *-*-netbsd*) + # Don't link with libc until the a.out ld.so is fixed. + ;; + *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) + # Do not include libc due to us having libc/libc_r. + ;; + *-*-sco3.2v5* | *-*-sco5v6*) + # Causes problems with __ctype + ;; + *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) + # Compiler inserts libc in the correct place for threads to work + ;; + *) + # Add libc to deplibs on all other systems if necessary. + if test "$build_libtool_need_lc" = "yes"; then + deplibs="$deplibs -lc" + fi + ;; + esac + fi + + # Transform deplibs into only deplibs that can be linked in shared. + name_save=$name + libname_save=$libname + release_save=$release + versuffix_save=$versuffix + major_save=$major + # I'm not sure if I'm treating the release correctly. I think + # release should show up in the -l (ie -lgmp5) so we don't want to + # add it in twice. Is that correct? + release="" + versuffix="" + major="" + newdeplibs= + droppeddeps=no + case $deplibs_check_method in + pass_all) + # Don't check for shared/static. Everything works. + # This might be a little naive. We might want to check + # whether the library exists or not. But this is on + # osf3 & osf4 and I'm not really sure... Just + # implementing what was already the behavior. + newdeplibs=$deplibs + ;; + test_compile) + # This code stresses the "libraries are programs" paradigm to its + # limits. Maybe even breaks it. We compile a program, linking it + # against the deplibs as a proxy for the library. Then we can check + # whether they linked in statically or dynamically with ldd. + $rm conftest.c + cat > conftest.c <<EOF + int main() { return 0; } +EOF + $rm conftest + if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then + ldd_output=`ldd conftest` + for i in $deplibs; do + name=`expr $i : '-l\(.*\)'` + # If $name is empty we are operating on a -L argument. + if test "$name" != "" && test "$name" != "0"; then + if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then + case " $predeps $postdeps " in + *" $i "*) + newdeplibs="$newdeplibs $i" + i="" + ;; + esac + fi + if test -n "$i" ; then + libname=`eval \\$echo \"$libname_spec\"` + deplib_matches=`eval \\$echo \"$library_names_spec\"` + set dummy $deplib_matches + deplib_match=$2 + if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then + newdeplibs="$newdeplibs $i" + else + droppeddeps=yes + $echo + $echo "*** Warning: dynamic linker does not accept needed library $i." + $echo "*** I have the capability to make that library automatically link in when" + $echo "*** you link to this library. But I can only do this if you have a" + $echo "*** shared version of the library, which I believe you do not have" + $echo "*** because a test_compile did reveal that the linker did not use it for" + $echo "*** its dynamic dependency list that programs get resolved with at runtime." + fi + fi + else + newdeplibs="$newdeplibs $i" + fi + done + else + # Error occurred in the first compile. Let's try to salvage + # the situation: Compile a separate program for each library. + for i in $deplibs; do + name=`expr $i : '-l\(.*\)'` + # If $name is empty we are operating on a -L argument. + if test "$name" != "" && test "$name" != "0"; then + $rm conftest + if $LTCC $LTCFLAGS -o conftest conftest.c $i; then + ldd_output=`ldd conftest` + if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then + case " $predeps $postdeps " in + *" $i "*) + newdeplibs="$newdeplibs $i" + i="" + ;; + esac + fi + if test -n "$i" ; then + libname=`eval \\$echo \"$libname_spec\"` + deplib_matches=`eval \\$echo \"$library_names_spec\"` + set dummy $deplib_matches + deplib_match=$2 + if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then + newdeplibs="$newdeplibs $i" + else + droppeddeps=yes + $echo + $echo "*** Warning: dynamic linker does not accept needed library $i." + $echo "*** I have the capability to make that library automatically link in when" + $echo "*** you link to this library. But I can only do this if you have a" + $echo "*** shared version of the library, which you do not appear to have" + $echo "*** because a test_compile did reveal that the linker did not use this one" + $echo "*** as a dynamic dependency that programs can get resolved with at runtime." + fi + fi + else + droppeddeps=yes + $echo + $echo "*** Warning! Library $i is needed by this library but I was not able to" + $echo "*** make it link in! You will probably need to install it or some" + $echo "*** library that it depends on before this library will be fully" + $echo "*** functional. Installing it before continuing would be even better." + fi + else + newdeplibs="$newdeplibs $i" + fi + done + fi + ;; + file_magic*) + set dummy $deplibs_check_method + file_magic_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"` + for a_deplib in $deplibs; do + name=`expr $a_deplib : '-l\(.*\)'` + # If $name is empty we are operating on a -L argument. + if test "$name" != "" && test "$name" != "0"; then + if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then + case " $predeps $postdeps " in + *" $a_deplib "*) + newdeplibs="$newdeplibs $a_deplib" + a_deplib="" + ;; + esac + fi + if test -n "$a_deplib" ; then + libname=`eval \\$echo \"$libname_spec\"` + for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do + potential_libs=`ls $i/$libname[.-]* 2>/dev/null` + for potent_lib in $potential_libs; do + # Follow soft links. + if ls -lLd "$potent_lib" 2>/dev/null \ + | grep " -> " >/dev/null; then + continue + fi + # The statement above tries to avoid entering an + # endless loop below, in case of cyclic links. + # We might still enter an endless loop, since a link + # loop can be closed while we follow links, + # but so what? + potlib="$potent_lib" + while test -h "$potlib" 2>/dev/null; do + potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` + case $potliblink in + [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; + *) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";; + esac + done + if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \ + | ${SED} 10q \ + | $EGREP "$file_magic_regex" > /dev/null; then + newdeplibs="$newdeplibs $a_deplib" + a_deplib="" + break 2 + fi + done + done + fi + if test -n "$a_deplib" ; then + droppeddeps=yes + $echo + $echo "*** Warning: linker path does not have real file for library $a_deplib." + $echo "*** I have the capability to make that library automatically link in when" + $echo "*** you link to this library. But I can only do this if you have a" + $echo "*** shared version of the library, which you do not appear to have" + $echo "*** because I did check the linker path looking for a file starting" + if test -z "$potlib" ; then + $echo "*** with $libname but no candidates were found. (...for file magic test)" + else + $echo "*** with $libname and none of the candidates passed a file format test" + $echo "*** using a file magic. Last file checked: $potlib" + fi + fi + else + # Add a -L argument. + newdeplibs="$newdeplibs $a_deplib" + fi + done # Gone through all deplibs. + ;; + match_pattern*) + set dummy $deplibs_check_method + match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"` + for a_deplib in $deplibs; do + name=`expr $a_deplib : '-l\(.*\)'` + # If $name is empty we are operating on a -L argument. + if test -n "$name" && test "$name" != "0"; then + if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then + case " $predeps $postdeps " in + *" $a_deplib "*) + newdeplibs="$newdeplibs $a_deplib" + a_deplib="" + ;; + esac + fi + if test -n "$a_deplib" ; then + libname=`eval \\$echo \"$libname_spec\"` + for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do + potential_libs=`ls $i/$libname[.-]* 2>/dev/null` + for potent_lib in $potential_libs; do + potlib="$potent_lib" # see symlink-check above in file_magic test + if eval $echo \"$potent_lib\" 2>/dev/null \ + | ${SED} 10q \ + | $EGREP "$match_pattern_regex" > /dev/null; then + newdeplibs="$newdeplibs $a_deplib" + a_deplib="" + break 2 + fi + done + done + fi + if test -n "$a_deplib" ; then + droppeddeps=yes + $echo + $echo "*** Warning: linker path does not have real file for library $a_deplib." + $echo "*** I have the capability to make that library automatically link in when" + $echo "*** you link to this library. But I can only do this if you have a" + $echo "*** shared version of the library, which you do not appear to have" + $echo "*** because I did check the linker path looking for a file starting" + if test -z "$potlib" ; then + $echo "*** with $libname but no candidates were found. (...for regex pattern test)" + else + $echo "*** with $libname and none of the candidates passed a file format test" + $echo "*** using a regex pattern. Last file checked: $potlib" + fi + fi + else + # Add a -L argument. + newdeplibs="$newdeplibs $a_deplib" + fi + done # Gone through all deplibs. + ;; + none | unknown | *) + newdeplibs="" + tmp_deplibs=`$echo "X $deplibs" | $Xsed -e 's/ -lc$//' \ + -e 's/ -[LR][^ ]*//g'` + if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then + for i in $predeps $postdeps ; do + # can't use Xsed below, because $i might contain '/' + tmp_deplibs=`$echo "X $tmp_deplibs" | ${SED} -e "1s,^X,," -e "s,$i,,"` + done + fi + if $echo "X $tmp_deplibs" | $Xsed -e 's/[ ]//g' \ + | grep . >/dev/null; then + $echo + if test "X$deplibs_check_method" = "Xnone"; then + $echo "*** Warning: inter-library dependencies are not supported in this platform." + else + $echo "*** Warning: inter-library dependencies are not known to be supported." + fi + $echo "*** All declared inter-library dependencies are being dropped." + droppeddeps=yes + fi + ;; + esac + versuffix=$versuffix_save + major=$major_save + release=$release_save + libname=$libname_save + name=$name_save + + case $host in + *-*-rhapsody* | *-*-darwin1.[012]) + # On Rhapsody replace the C library is the System framework + newdeplibs=`$echo "X $newdeplibs" | $Xsed -e 's/ -lc / -framework System /'` + ;; + esac + + if test "$droppeddeps" = yes; then + if test "$module" = yes; then + $echo + $echo "*** Warning: libtool could not satisfy all declared inter-library" + $echo "*** dependencies of module $libname. Therefore, libtool will create" + $echo "*** a static module, that should work as long as the dlopening" + $echo "*** application is linked with the -dlopen flag." + if test -z "$global_symbol_pipe"; then + $echo + $echo "*** However, this would only work if libtool was able to extract symbol" + $echo "*** lists from a program, using \`nm' or equivalent, but libtool could" + $echo "*** not find such a program. So, this module is probably useless." + $echo "*** \`nm' from GNU binutils and a full rebuild may help." + fi + if test "$build_old_libs" = no; then + oldlibs="$output_objdir/$libname.$libext" + build_libtool_libs=module + build_old_libs=yes + else + build_libtool_libs=no + fi + else + $echo "*** The inter-library dependencies that have been dropped here will be" + $echo "*** automatically added whenever a program is linked with this library" + $echo "*** or is declared to -dlopen it." + + if test "$allow_undefined" = no; then + $echo + $echo "*** Since this library must not contain undefined symbols," + $echo "*** because either the platform does not support them or" + $echo "*** it was explicitly requested with -no-undefined," + $echo "*** libtool will only create a static version of it." + if test "$build_old_libs" = no; then + oldlibs="$output_objdir/$libname.$libext" + build_libtool_libs=module + build_old_libs=yes + else + build_libtool_libs=no + fi + fi + fi + fi + # Done checking deplibs! + deplibs=$newdeplibs + fi + + + # move library search paths that coincide with paths to not yet + # installed libraries to the beginning of the library search list + new_libs= + for path in $notinst_path; do + case " $new_libs " in + *" -L$path/$objdir "*) ;; + *) + case " $deplibs " in + *" -L$path/$objdir "*) + new_libs="$new_libs -L$path/$objdir" ;; + esac + ;; + esac + done + for deplib in $deplibs; do + case $deplib in + -L*) + case " $new_libs " in + *" $deplib "*) ;; + *) new_libs="$new_libs $deplib" ;; + esac + ;; + *) new_libs="$new_libs $deplib" ;; + esac + done + deplibs="$new_libs" + + + # All the library-specific variables (install_libdir is set above). + library_names= + old_library= + dlname= + + # Test again, we may have decided not to build it any more + if test "$build_libtool_libs" = yes; then + if test "$hardcode_into_libs" = yes; then + # Hardcode the library paths + hardcode_libdirs= + dep_rpath= + rpath="$finalize_rpath" + test "$mode" != relink && rpath="$compile_rpath$rpath" + for libdir in $rpath; do + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then + hardcode_libdirs="$libdir" + else + # Just accumulate the unique libdirs. + case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in + *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) + ;; + *) + hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" + ;; + esac + fi + else + eval flag=\"$hardcode_libdir_flag_spec\" + dep_rpath="$dep_rpath $flag" + fi + elif test -n "$runpath_var"; then + case "$perm_rpath " in + *" $libdir "*) ;; + *) perm_rpath="$perm_rpath $libdir" ;; + esac + fi + done + # Substitute the hardcoded libdirs into the rpath. + if test -n "$hardcode_libdir_separator" && + test -n "$hardcode_libdirs"; then + libdir="$hardcode_libdirs" + if test -n "$hardcode_libdir_flag_spec_ld"; then + case $archive_cmds in + *\$LD*) eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\" ;; + *) eval dep_rpath=\"$hardcode_libdir_flag_spec\" ;; + esac + else + eval dep_rpath=\"$hardcode_libdir_flag_spec\" + fi + fi + if test -n "$runpath_var" && test -n "$perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $perm_rpath; do + rpath="$rpath$dir:" + done + eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" + fi + test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" + fi + + shlibpath="$finalize_shlibpath" + test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath" + if test -n "$shlibpath"; then + eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" + fi + + # Get the real and link names of the library. + eval shared_ext=\"$shrext_cmds\" + eval library_names=\"$library_names_spec\" + set dummy $library_names + realname="$2" + shift; shift + + if test -n "$soname_spec"; then + eval soname=\"$soname_spec\" + else + soname="$realname" + fi + if test -z "$dlname"; then + dlname=$soname + fi + + lib="$output_objdir/$realname" + linknames= + for link + do + linknames="$linknames $link" + done + + # Use standard objects if they are pic + test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + + # Prepare the list of exported symbols + if test -z "$export_symbols"; then + if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then + $show "generating symbol list for \`$libname.la'" + export_symbols="$output_objdir/$libname.exp" + $run $rm $export_symbols + cmds=$export_symbols_cmds + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + if len=`expr "X$cmd" : ".*"` && + test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then + $show "$cmd" + $run eval "$cmd" || exit $? + skipped_export=false + else + # The command line is too long to execute in one step. + $show "using reloadable object file for export list..." + skipped_export=: + # Break out early, otherwise skipped_export may be + # set to false by a later but shorter cmd. + break + fi + done + IFS="$save_ifs" + if test -n "$export_symbols_regex"; then + $show "$EGREP -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\"" + $run eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' + $show "$mv \"${export_symbols}T\" \"$export_symbols\"" + $run eval '$mv "${export_symbols}T" "$export_symbols"' + fi + fi + fi + + if test -n "$export_symbols" && test -n "$include_expsyms"; then + $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"' + fi + + tmp_deplibs= + for test_deplib in $deplibs; do + case " $convenience " in + *" $test_deplib "*) ;; + *) + tmp_deplibs="$tmp_deplibs $test_deplib" + ;; + esac + done + deplibs="$tmp_deplibs" + + if test -n "$convenience"; then + if test -n "$whole_archive_flag_spec"; then + save_libobjs=$libobjs + eval libobjs=\"\$libobjs $whole_archive_flag_spec\" + else + gentop="$output_objdir/${outputname}x" + generated="$generated $gentop" + + func_extract_archives $gentop $convenience + libobjs="$libobjs $func_extract_archives_result" + fi + fi + + if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then + eval flag=\"$thread_safe_flag_spec\" + linker_flags="$linker_flags $flag" + fi + + # Make a backup of the uninstalled library when relinking + if test "$mode" = relink; then + $run eval '(cd $output_objdir && $rm ${realname}U && $mv $realname ${realname}U)' || exit $? + fi + + # Do each of the archive commands. + if test "$module" = yes && test -n "$module_cmds" ; then + if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then + eval test_cmds=\"$module_expsym_cmds\" + cmds=$module_expsym_cmds + else + eval test_cmds=\"$module_cmds\" + cmds=$module_cmds + fi + else + if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then + eval test_cmds=\"$archive_expsym_cmds\" + cmds=$archive_expsym_cmds + else + eval test_cmds=\"$archive_cmds\" + cmds=$archive_cmds + fi + fi + + if test "X$skipped_export" != "X:" && + len=`expr "X$test_cmds" : ".*" 2>/dev/null` && + test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then + : + else + # The command line is too long to link in one step, link piecewise. + $echo "creating reloadable object files..." + + # Save the value of $output and $libobjs because we want to + # use them later. If we have whole_archive_flag_spec, we + # want to use save_libobjs as it was before + # whole_archive_flag_spec was expanded, because we can't + # assume the linker understands whole_archive_flag_spec. + # This may have to be revisited, in case too many + # convenience libraries get linked in and end up exceeding + # the spec. + if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then + save_libobjs=$libobjs + fi + save_output=$output + output_la=`$echo "X$output" | $Xsed -e "$basename"` + + # Clear the reloadable object creation command queue and + # initialize k to one. + test_cmds= + concat_cmds= + objlist= + delfiles= + last_robj= + k=1 + output=$output_objdir/$output_la-${k}.$objext + # Loop over the list of objects to be linked. + for obj in $save_libobjs + do + eval test_cmds=\"$reload_cmds $objlist $last_robj\" + if test "X$objlist" = X || + { len=`expr "X$test_cmds" : ".*" 2>/dev/null` && + test "$len" -le "$max_cmd_len"; }; then + objlist="$objlist $obj" + else + # The command $test_cmds is almost too long, add a + # command to the queue. + if test "$k" -eq 1 ; then + # The first file doesn't have a previous command to add. + eval concat_cmds=\"$reload_cmds $objlist $last_robj\" + else + # All subsequent reloadable object files will link in + # the last one created. + eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj\" + fi + last_robj=$output_objdir/$output_la-${k}.$objext + k=`expr $k + 1` + output=$output_objdir/$output_la-${k}.$objext + objlist=$obj + len=1 + fi + done + # Handle the remaining objects by creating one last + # reloadable object file. All subsequent reloadable object + # files will link in the last one created. + test -z "$concat_cmds" || concat_cmds=$concat_cmds~ + eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\" + + if ${skipped_export-false}; then + $show "generating symbol list for \`$libname.la'" + export_symbols="$output_objdir/$libname.exp" + $run $rm $export_symbols + libobjs=$output + # Append the command to create the export file. + eval concat_cmds=\"\$concat_cmds~$export_symbols_cmds\" + fi + + # Set up a command to remove the reloadable object files + # after they are used. + i=0 + while test "$i" -lt "$k" + do + i=`expr $i + 1` + delfiles="$delfiles $output_objdir/$output_la-${i}.$objext" + done + + $echo "creating a temporary reloadable object file: $output" + + # Loop through the commands generated above and execute them. + save_ifs="$IFS"; IFS='~' + for cmd in $concat_cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + + libobjs=$output + # Restore the value of output. + output=$save_output + + if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then + eval libobjs=\"\$libobjs $whole_archive_flag_spec\" + fi + # Expand the library linking commands again to reset the + # value of $libobjs for piecewise linking. + + # Do each of the archive commands. + if test "$module" = yes && test -n "$module_cmds" ; then + if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then + cmds=$module_expsym_cmds + else + cmds=$module_cmds + fi + else + if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then + cmds=$archive_expsym_cmds + else + cmds=$archive_cmds + fi + fi + + # Append the command to remove the reloadable object files + # to the just-reset $cmds. + eval cmds=\"\$cmds~\$rm $delfiles\" + fi + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" || { + lt_exit=$? + + # Restore the uninstalled library and exit + if test "$mode" = relink; then + $run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)' + fi + + exit $lt_exit + } + done + IFS="$save_ifs" + + # Restore the uninstalled library and exit + if test "$mode" = relink; then + $run eval '(cd $output_objdir && $rm ${realname}T && $mv $realname ${realname}T && $mv "$realname"U $realname)' || exit $? + + if test -n "$convenience"; then + if test -z "$whole_archive_flag_spec"; then + $show "${rm}r $gentop" + $run ${rm}r "$gentop" + fi + fi + + exit $EXIT_SUCCESS + fi + + # Create links to the real library. + for linkname in $linknames; do + if test "$realname" != "$linkname"; then + $show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)" + $run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $? + fi + done + + # If -module or -export-dynamic was specified, set the dlname. + if test "$module" = yes || test "$export_dynamic" = yes; then + # On all known operating systems, these are identical. + dlname="$soname" + fi + fi + ;; + + obj) + case " $deplibs" in + *\ -l* | *\ -L*) + $echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2 ;; + esac + + if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then + $echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2 + fi + + if test -n "$rpath"; then + $echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2 + fi + + if test -n "$xrpath"; then + $echo "$modename: warning: \`-R' is ignored for objects" 1>&2 + fi + + if test -n "$vinfo"; then + $echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2 + fi + + if test -n "$release"; then + $echo "$modename: warning: \`-release' is ignored for objects" 1>&2 + fi + + case $output in + *.lo) + if test -n "$objs$old_deplibs"; then + $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2 + exit $EXIT_FAILURE + fi + libobj="$output" + obj=`$echo "X$output" | $Xsed -e "$lo2o"` + ;; + *) + libobj= + obj="$output" + ;; + esac + + # Delete the old objects. + $run $rm $obj $libobj + + # Objects from convenience libraries. This assumes + # single-version convenience libraries. Whenever we create + # different ones for PIC/non-PIC, this we'll have to duplicate + # the extraction. + reload_conv_objs= + gentop= + # reload_cmds runs $LD directly, so let us get rid of + # -Wl from whole_archive_flag_spec and hope we can get by with + # turning comma into space.. + wl= + + if test -n "$convenience"; then + if test -n "$whole_archive_flag_spec"; then + eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" + reload_conv_objs=$reload_objs\ `$echo "X$tmp_whole_archive_flags" | $Xsed -e 's|,| |g'` + else + gentop="$output_objdir/${obj}x" + generated="$generated $gentop" + + func_extract_archives $gentop $convenience + reload_conv_objs="$reload_objs $func_extract_archives_result" + fi + fi + + # Create the old-style object. + reload_objs="$objs$old_deplibs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test + + output="$obj" + cmds=$reload_cmds + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + + # Exit if we aren't doing a library object file. + if test -z "$libobj"; then + if test -n "$gentop"; then + $show "${rm}r $gentop" + $run ${rm}r $gentop + fi + + exit $EXIT_SUCCESS + fi + + if test "$build_libtool_libs" != yes; then + if test -n "$gentop"; then + $show "${rm}r $gentop" + $run ${rm}r $gentop + fi + + # Create an invalid libtool object if no PIC, so that we don't + # accidentally link it into a program. + # $show "echo timestamp > $libobj" + # $run eval "echo timestamp > $libobj" || exit $? + exit $EXIT_SUCCESS + fi + + if test -n "$pic_flag" || test "$pic_mode" != default; then + # Only do commands if we really have different PIC objects. + reload_objs="$libobjs $reload_conv_objs" + output="$libobj" + cmds=$reload_cmds + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + fi + + if test -n "$gentop"; then + $show "${rm}r $gentop" + $run ${rm}r $gentop + fi + + exit $EXIT_SUCCESS + ;; + + prog) + case $host in + *cygwin*) output=`$echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;; + esac + if test -n "$vinfo"; then + $echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2 + fi + + if test -n "$release"; then + $echo "$modename: warning: \`-release' is ignored for programs" 1>&2 + fi + + if test "$preload" = yes; then + if test "$dlopen_support" = unknown && test "$dlopen_self" = unknown && + test "$dlopen_self_static" = unknown; then + $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support." + fi + fi + + case $host in + *-*-rhapsody* | *-*-darwin1.[012]) + # On Rhapsody replace the C library is the System framework + compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / -framework System /'` + finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / -framework System /'` + ;; + esac + + case $host in + *darwin*) + # Don't allow lazy linking, it breaks C++ global constructors + if test "$tagname" = CXX ; then + compile_command="$compile_command ${wl}-bind_at_load" + finalize_command="$finalize_command ${wl}-bind_at_load" + fi + ;; + esac + + + # move library search paths that coincide with paths to not yet + # installed libraries to the beginning of the library search list + new_libs= + for path in $notinst_path; do + case " $new_libs " in + *" -L$path/$objdir "*) ;; + *) + case " $compile_deplibs " in + *" -L$path/$objdir "*) + new_libs="$new_libs -L$path/$objdir" ;; + esac + ;; + esac + done + for deplib in $compile_deplibs; do + case $deplib in + -L*) + case " $new_libs " in + *" $deplib "*) ;; + *) new_libs="$new_libs $deplib" ;; + esac + ;; + *) new_libs="$new_libs $deplib" ;; + esac + done + compile_deplibs="$new_libs" + + + compile_command="$compile_command $compile_deplibs" + finalize_command="$finalize_command $finalize_deplibs" + + if test -n "$rpath$xrpath"; then + # If the user specified any rpath flags, then add them. + for libdir in $rpath $xrpath; do + # This is the magic to use -rpath. + case "$finalize_rpath " in + *" $libdir "*) ;; + *) finalize_rpath="$finalize_rpath $libdir" ;; + esac + done + fi + + # Now hardcode the library paths + rpath= + hardcode_libdirs= + for libdir in $compile_rpath $finalize_rpath; do + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then + hardcode_libdirs="$libdir" + else + # Just accumulate the unique libdirs. + case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in + *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) + ;; + *) + hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" + ;; + esac + fi + else + eval flag=\"$hardcode_libdir_flag_spec\" + rpath="$rpath $flag" + fi + elif test -n "$runpath_var"; then + case "$perm_rpath " in + *" $libdir "*) ;; + *) perm_rpath="$perm_rpath $libdir" ;; + esac + fi + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) + testbindir=`$echo "X$libdir" | $Xsed -e 's*/lib$*/bin*'` + case :$dllsearchpath: in + *":$libdir:"*) ;; + *) dllsearchpath="$dllsearchpath:$libdir";; + esac + case :$dllsearchpath: in + *":$testbindir:"*) ;; + *) dllsearchpath="$dllsearchpath:$testbindir";; + esac + ;; + esac + done + # Substitute the hardcoded libdirs into the rpath. + if test -n "$hardcode_libdir_separator" && + test -n "$hardcode_libdirs"; then + libdir="$hardcode_libdirs" + eval rpath=\" $hardcode_libdir_flag_spec\" + fi + compile_rpath="$rpath" + + rpath= + hardcode_libdirs= + for libdir in $finalize_rpath; do + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then + hardcode_libdirs="$libdir" + else + # Just accumulate the unique libdirs. + case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in + *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) + ;; + *) + hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" + ;; + esac + fi + else + eval flag=\"$hardcode_libdir_flag_spec\" + rpath="$rpath $flag" + fi + elif test -n "$runpath_var"; then + case "$finalize_perm_rpath " in + *" $libdir "*) ;; + *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;; + esac + fi + done + # Substitute the hardcoded libdirs into the rpath. + if test -n "$hardcode_libdir_separator" && + test -n "$hardcode_libdirs"; then + libdir="$hardcode_libdirs" + eval rpath=\" $hardcode_libdir_flag_spec\" + fi + finalize_rpath="$rpath" + + if test -n "$libobjs" && test "$build_old_libs" = yes; then + # Transform all the library objects into standard objects. + compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + fi + + dlsyms= + if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then + if test -n "$NM" && test -n "$global_symbol_pipe"; then + dlsyms="${outputname}S.c" + else + $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2 + fi + fi + + if test -n "$dlsyms"; then + case $dlsyms in + "") ;; + *.c) + # Discover the nlist of each of the dlfiles. + nlist="$output_objdir/${outputname}.nm" + + $show "$rm $nlist ${nlist}S ${nlist}T" + $run $rm "$nlist" "${nlist}S" "${nlist}T" + + # Parse the name list into a source file. + $show "creating $output_objdir/$dlsyms" + + test -z "$run" && $echo > "$output_objdir/$dlsyms" "\ +/* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */ +/* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */ + +#ifdef __cplusplus +extern \"C\" { +#endif + +/* Prevent the only kind of declaration conflicts we can make. */ +#define lt_preloaded_symbols some_other_symbol + +/* External symbol declarations for the compiler. */\ +" + + if test "$dlself" = yes; then + $show "generating symbol list for \`$output'" + + test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist" + + # Add our own program objects to the symbol list. + progfiles=`$echo "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + for arg in $progfiles; do + $show "extracting global C symbols from \`$arg'" + $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'" + done + + if test -n "$exclude_expsyms"; then + $run eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' + $run eval '$mv "$nlist"T "$nlist"' + fi + + if test -n "$export_symbols_regex"; then + $run eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' + $run eval '$mv "$nlist"T "$nlist"' + fi + + # Prepare the list of exported symbols + if test -z "$export_symbols"; then + export_symbols="$output_objdir/$outputname.exp" + $run $rm $export_symbols + $run eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' + case $host in + *cygwin* | *mingw* ) + $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' + $run eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' + ;; + esac + else + $run eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' + $run eval 'grep -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' + $run eval 'mv "$nlist"T "$nlist"' + case $host in + *cygwin* | *mingw* ) + $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' + $run eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' + ;; + esac + fi + fi + + for arg in $dlprefiles; do + $show "extracting global C symbols from \`$arg'" + name=`$echo "$arg" | ${SED} -e 's%^.*/%%'` + $run eval '$echo ": $name " >> "$nlist"' + $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'" + done + + if test -z "$run"; then + # Make sure we have at least an empty file. + test -f "$nlist" || : > "$nlist" + + if test -n "$exclude_expsyms"; then + $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T + $mv "$nlist"T "$nlist" + fi + + # Try sorting and uniquifying the output. + if grep -v "^: " < "$nlist" | + if sort -k 3 </dev/null >/dev/null 2>&1; then + sort -k 3 + else + sort +2 + fi | + uniq > "$nlist"S; then + : + else + grep -v "^: " < "$nlist" > "$nlist"S + fi + + if test -f "$nlist"S; then + eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"' + else + $echo '/* NONE */' >> "$output_objdir/$dlsyms" + fi + + $echo >> "$output_objdir/$dlsyms" "\ + +#undef lt_preloaded_symbols + +#if defined (__STDC__) && __STDC__ +# define lt_ptr void * +#else +# define lt_ptr char * +# define const +#endif + +/* The mapping between symbol names and symbols. */ +" + + case $host in + *cygwin* | *mingw* ) + $echo >> "$output_objdir/$dlsyms" "\ +/* DATA imports from DLLs on WIN32 can't be const, because + runtime relocations are performed -- see ld's documentation + on pseudo-relocs */ +struct { +" + ;; + * ) + $echo >> "$output_objdir/$dlsyms" "\ +const struct { +" + ;; + esac + + + $echo >> "$output_objdir/$dlsyms" "\ + const char *name; + lt_ptr address; +} +lt_preloaded_symbols[] = +{\ +" + + eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$dlsyms" + + $echo >> "$output_objdir/$dlsyms" "\ + {0, (lt_ptr) 0} +}; + +/* This works around a problem in FreeBSD linker */ +#ifdef FREEBSD_WORKAROUND +static const void *lt_preloaded_setup() { + return lt_preloaded_symbols; +} +#endif + +#ifdef __cplusplus +} +#endif\ +" + fi + + pic_flag_for_symtable= + case $host in + # compiling the symbol table file with pic_flag works around + # a FreeBSD bug that causes programs to crash when -lm is + # linked before any other PIC object. But we must not use + # pic_flag when linking with -static. The problem exists in + # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. + *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) + case "$compile_command " in + *" -static "*) ;; + *) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND";; + esac;; + *-*-hpux*) + case "$compile_command " in + *" -static "*) ;; + *) pic_flag_for_symtable=" $pic_flag";; + esac + esac + + # Now compile the dynamic symbol file. + $show "(cd $output_objdir && $LTCC $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")" + $run eval '(cd $output_objdir && $LTCC $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $? + + # Clean up the generated files. + $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T" + $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T" + + # Transform the symbol file into the correct name. + case $host in + *cygwin* | *mingw* ) + if test -f "$output_objdir/${outputname}.def" ; then + compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%" | $NL2SP` + finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%" | $NL2SP` + else + compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP` + finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP` + fi + ;; + * ) + compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP` + finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP` + ;; + esac + ;; + *) + $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2 + exit $EXIT_FAILURE + ;; + esac + else + # We keep going just in case the user didn't refer to + # lt_preloaded_symbols. The linker will fail if global_symbol_pipe + # really was required. + + # Nullify the symbol file. + compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s% @SYMFILE@%%" | $NL2SP` + finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s% @SYMFILE@%%" | $NL2SP` + fi + + if test "$need_relink" = no || test "$build_libtool_libs" != yes; then + # Replace the output file specification. + compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e 's%@OUTPUT@%'"$output"'%g' | $NL2SP` + link_command="$compile_command$compile_rpath" + + # We have no uninstalled library dependencies, so finalize right now. + $show "$link_command" + $run eval "$link_command" + exit_status=$? + + # Delete the generated files. + if test -n "$dlsyms"; then + $show "$rm $output_objdir/${outputname}S.${objext}" + $run $rm "$output_objdir/${outputname}S.${objext}" + fi + + exit $exit_status + fi + + if test -n "$shlibpath_var"; then + # We should set the shlibpath_var + rpath= + for dir in $temp_rpath; do + case $dir in + [\\/]* | [A-Za-z]:[\\/]*) + # Absolute path. + rpath="$rpath$dir:" + ;; + *) + # Relative path: add a thisdir entry. + rpath="$rpath\$thisdir/$dir:" + ;; + esac + done + temp_rpath="$rpath" + fi + + if test -n "$compile_shlibpath$finalize_shlibpath"; then + compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" + fi + if test -n "$finalize_shlibpath"; then + finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" + fi + + compile_var= + finalize_var= + if test -n "$runpath_var"; then + if test -n "$perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $perm_rpath; do + rpath="$rpath$dir:" + done + compile_var="$runpath_var=\"$rpath\$$runpath_var\" " + fi + if test -n "$finalize_perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $finalize_perm_rpath; do + rpath="$rpath$dir:" + done + finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " + fi + fi + + if test "$no_install" = yes; then + # We don't need to create a wrapper script. + link_command="$compile_var$compile_command$compile_rpath" + # Replace the output file specification. + link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` + # Delete the old output file. + $run $rm $output + # Link the executable and exit + $show "$link_command" + $run eval "$link_command" || exit $? + exit $EXIT_SUCCESS + fi + + if test "$hardcode_action" = relink; then + # Fast installation is not supported + link_command="$compile_var$compile_command$compile_rpath" + relink_command="$finalize_var$finalize_command$finalize_rpath" + + $echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2 + $echo "$modename: \`$output' will be relinked during installation" 1>&2 + else + if test "$fast_install" != no; then + link_command="$finalize_var$compile_command$finalize_rpath" + if test "$fast_install" = yes; then + relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $SP2NL | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g' | $NL2SP` + else + # fast_install is set to needless + relink_command= + fi + else + link_command="$compile_var$compile_command$compile_rpath" + relink_command="$finalize_var$finalize_command$finalize_rpath" + fi + fi + + # Replace the output file specification. + link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` + + # Delete the old output files. + $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname + + $show "$link_command" + $run eval "$link_command" || exit $? + + # Now create the wrapper script. + $show "creating $output" + + # Quote the relink command for shipping. + if test -n "$relink_command"; then + # Preserve any variables that may affect compiler behavior + for var in $variables_saved_for_relink; do + if eval test -z \"\${$var+set}\"; then + relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command" + elif eval var_value=\$$var; test -z "$var_value"; then + relink_command="$var=; export $var; $relink_command" + else + var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"` + relink_command="$var=\"$var_value\"; export $var; $relink_command" + fi + done + relink_command="(cd `pwd`; $relink_command)" + relink_command=`$echo "X$relink_command" | $SP2NL | $Xsed -e "$sed_quote_subst" | $NL2SP` + fi + + # Quote $echo for shipping. + if test "X$echo" = "X$SHELL $progpath --fallback-echo"; then + case $progpath in + [\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";; + *) qecho="$SHELL `pwd`/$progpath --fallback-echo";; + esac + qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"` + else + qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"` + fi + + # Only actually do things if our run command is non-null. + if test -z "$run"; then + # win32 will think the script is a binary if it has + # a .exe suffix, so we strip it off here. + case $output in + *.exe) output=`$echo $output|${SED} 's,.exe$,,'` ;; + esac + # test for cygwin because mv fails w/o .exe extensions + case $host in + *cygwin*) + exeext=.exe + outputname=`$echo $outputname|${SED} 's,.exe$,,'` ;; + *) exeext= ;; + esac + case $host in + *cygwin* | *mingw* ) + output_name=`basename $output` + output_path=`dirname $output` + cwrappersource="$output_path/$objdir/lt-$output_name.c" + cwrapper="$output_path/$output_name.exe" + $rm $cwrappersource $cwrapper + trap "$rm $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 + + cat > $cwrappersource <<EOF + +/* $cwrappersource - temporary wrapper executable for $objdir/$outputname + Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP + + The $output program cannot be directly executed until all the libtool + libraries that it depends on are installed. + + This wrapper executable should never be moved out of the build directory. + If it is, it will not operate correctly. + + Currently, it simply execs the wrapper *script* "/bin/sh $output", + but could eventually absorb all of the scripts functionality and + exec $objdir/$outputname directly. +*/ +EOF + cat >> $cwrappersource<<"EOF" +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <malloc.h> +#include <stdarg.h> +#include <assert.h> +#include <string.h> +#include <ctype.h> +#include <sys/stat.h> + +#if defined(PATH_MAX) +# define LT_PATHMAX PATH_MAX +#elif defined(MAXPATHLEN) +# define LT_PATHMAX MAXPATHLEN +#else +# define LT_PATHMAX 1024 +#endif + +#ifndef DIR_SEPARATOR +# define DIR_SEPARATOR '/' +# define PATH_SEPARATOR ':' +#endif + +#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ + defined (__OS2__) +# define HAVE_DOS_BASED_FILE_SYSTEM +# ifndef DIR_SEPARATOR_2 +# define DIR_SEPARATOR_2 '\\' +# endif +# ifndef PATH_SEPARATOR_2 +# define PATH_SEPARATOR_2 ';' +# endif +#endif + +#ifndef DIR_SEPARATOR_2 +# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) +#else /* DIR_SEPARATOR_2 */ +# define IS_DIR_SEPARATOR(ch) \ + (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) +#endif /* DIR_SEPARATOR_2 */ + +#ifndef PATH_SEPARATOR_2 +# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) +#else /* PATH_SEPARATOR_2 */ +# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) +#endif /* PATH_SEPARATOR_2 */ + +#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) +#define XFREE(stale) do { \ + if (stale) { free ((void *) stale); stale = 0; } \ +} while (0) + +/* -DDEBUG is fairly common in CFLAGS. */ +#undef DEBUG +#if defined DEBUGWRAPPER +# define DEBUG(format, ...) fprintf(stderr, format, __VA_ARGS__) +#else +# define DEBUG(format, ...) +#endif + +const char *program_name = NULL; + +void * xmalloc (size_t num); +char * xstrdup (const char *string); +const char * base_name (const char *name); +char * find_executable(const char *wrapper); +int check_executable(const char *path); +char * strendzap(char *str, const char *pat); +void lt_fatal (const char *message, ...); + +int +main (int argc, char *argv[]) +{ + char **newargz; + int i; + + program_name = (char *) xstrdup (base_name (argv[0])); + DEBUG("(main) argv[0] : %s\n",argv[0]); + DEBUG("(main) program_name : %s\n",program_name); + newargz = XMALLOC(char *, argc+2); +EOF + + cat >> $cwrappersource <<EOF + newargz[0] = (char *) xstrdup("$SHELL"); +EOF + + cat >> $cwrappersource <<"EOF" + newargz[1] = find_executable(argv[0]); + if (newargz[1] == NULL) + lt_fatal("Couldn't find %s", argv[0]); + DEBUG("(main) found exe at : %s\n",newargz[1]); + /* we know the script has the same name, without the .exe */ + /* so make sure newargz[1] doesn't end in .exe */ + strendzap(newargz[1],".exe"); + for (i = 1; i < argc; i++) + newargz[i+1] = xstrdup(argv[i]); + newargz[argc+1] = NULL; + + for (i=0; i<argc+1; i++) + { + DEBUG("(main) newargz[%d] : %s\n",i,newargz[i]); + ; + } + +EOF + + case $host_os in + mingw*) + cat >> $cwrappersource <<EOF + execv("$SHELL",(char const **)newargz); +EOF + ;; + *) + cat >> $cwrappersource <<EOF + execv("$SHELL",newargz); +EOF + ;; + esac + + cat >> $cwrappersource <<"EOF" + return 127; +} + +void * +xmalloc (size_t num) +{ + void * p = (void *) malloc (num); + if (!p) + lt_fatal ("Memory exhausted"); + + return p; +} + +char * +xstrdup (const char *string) +{ + return string ? strcpy ((char *) xmalloc (strlen (string) + 1), string) : NULL +; +} + +const char * +base_name (const char *name) +{ + const char *base; + +#if defined (HAVE_DOS_BASED_FILE_SYSTEM) + /* Skip over the disk name in MSDOS pathnames. */ + if (isalpha ((unsigned char)name[0]) && name[1] == ':') + name += 2; +#endif + + for (base = name; *name; name++) + if (IS_DIR_SEPARATOR (*name)) + base = name + 1; + return base; +} + +int +check_executable(const char * path) +{ + struct stat st; + + DEBUG("(check_executable) : %s\n", path ? (*path ? path : "EMPTY!") : "NULL!"); + if ((!path) || (!*path)) + return 0; + + if ((stat (path, &st) >= 0) && + ( + /* MinGW & native WIN32 do not support S_IXOTH or S_IXGRP */ +#if defined (S_IXOTH) + ((st.st_mode & S_IXOTH) == S_IXOTH) || +#endif +#if defined (S_IXGRP) + ((st.st_mode & S_IXGRP) == S_IXGRP) || +#endif + ((st.st_mode & S_IXUSR) == S_IXUSR)) + ) + return 1; + else + return 0; +} + +/* Searches for the full path of the wrapper. Returns + newly allocated full path name if found, NULL otherwise */ +char * +find_executable (const char* wrapper) +{ + int has_slash = 0; + const char* p; + const char* p_next; + /* static buffer for getcwd */ + char tmp[LT_PATHMAX + 1]; + int tmp_len; + char* concat_name; + + DEBUG("(find_executable) : %s\n", wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!"); + + if ((wrapper == NULL) || (*wrapper == '\0')) + return NULL; + + /* Absolute path? */ +#if defined (HAVE_DOS_BASED_FILE_SYSTEM) + if (isalpha ((unsigned char)wrapper[0]) && wrapper[1] == ':') + { + concat_name = xstrdup (wrapper); + if (check_executable(concat_name)) + return concat_name; + XFREE(concat_name); + } + else + { +#endif + if (IS_DIR_SEPARATOR (wrapper[0])) + { + concat_name = xstrdup (wrapper); + if (check_executable(concat_name)) + return concat_name; + XFREE(concat_name); + } +#if defined (HAVE_DOS_BASED_FILE_SYSTEM) + } +#endif + + for (p = wrapper; *p; p++) + if (*p == '/') + { + has_slash = 1; + break; + } + if (!has_slash) + { + /* no slashes; search PATH */ + const char* path = getenv ("PATH"); + if (path != NULL) + { + for (p = path; *p; p = p_next) + { + const char* q; + size_t p_len; + for (q = p; *q; q++) + if (IS_PATH_SEPARATOR(*q)) + break; + p_len = q - p; + p_next = (*q == '\0' ? q : q + 1); + if (p_len == 0) + { + /* empty path: current directory */ + if (getcwd (tmp, LT_PATHMAX) == NULL) + lt_fatal ("getcwd failed"); + tmp_len = strlen(tmp); + concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1); + memcpy (concat_name, tmp, tmp_len); + concat_name[tmp_len] = '/'; + strcpy (concat_name + tmp_len + 1, wrapper); + } + else + { + concat_name = XMALLOC(char, p_len + 1 + strlen(wrapper) + 1); + memcpy (concat_name, p, p_len); + concat_name[p_len] = '/'; + strcpy (concat_name + p_len + 1, wrapper); + } + if (check_executable(concat_name)) + return concat_name; + XFREE(concat_name); + } + } + /* not found in PATH; assume curdir */ + } + /* Relative path | not found in path: prepend cwd */ + if (getcwd (tmp, LT_PATHMAX) == NULL) + lt_fatal ("getcwd failed"); + tmp_len = strlen(tmp); + concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1); + memcpy (concat_name, tmp, tmp_len); + concat_name[tmp_len] = '/'; + strcpy (concat_name + tmp_len + 1, wrapper); + + if (check_executable(concat_name)) + return concat_name; + XFREE(concat_name); + return NULL; +} + +char * +strendzap(char *str, const char *pat) +{ + size_t len, patlen; + + assert(str != NULL); + assert(pat != NULL); + + len = strlen(str); + patlen = strlen(pat); + + if (patlen <= len) + { + str += len - patlen; + if (strcmp(str, pat) == 0) + *str = '\0'; + } + return str; +} + +static void +lt_error_core (int exit_status, const char * mode, + const char * message, va_list ap) +{ + fprintf (stderr, "%s: %s: ", program_name, mode); + vfprintf (stderr, message, ap); + fprintf (stderr, ".\n"); + + if (exit_status >= 0) + exit (exit_status); +} + +void +lt_fatal (const char *message, ...) +{ + va_list ap; + va_start (ap, message); + lt_error_core (EXIT_FAILURE, "FATAL", message, ap); + va_end (ap); +} +EOF + # we should really use a build-platform specific compiler + # here, but OTOH, the wrappers (shell script and this C one) + # are only useful if you want to execute the "real" binary. + # Since the "real" binary is built for $host, then this + # wrapper might as well be built for $host, too. + $run $LTCC $LTCFLAGS -s -o $cwrapper $cwrappersource + ;; + esac + $rm $output + trap "$rm $output; exit $EXIT_FAILURE" 1 2 15 + + $echo > $output "\ +#! $SHELL + +# $output - temporary wrapper script for $objdir/$outputname +# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP +# +# The $output program cannot be directly executed until all the libtool +# libraries that it depends on are installed. +# +# This wrapper script should never be moved out of the build directory. +# If it is, it will not operate correctly. + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed='${SED} -e 1s/^X//' +sed_quote_subst='$sed_quote_subst' + +# Be Bourne compatible (taken from Autoconf:_AS_BOURNE_COMPATIBLE). +if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which + # is contrary to our usage. Disable this feature. + alias -g '\${1+\"\$@\"}'='\"\$@\"' + setopt NO_GLOB_SUBST +else + case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac +fi +BIN_SH=xpg4; export BIN_SH # for Tru64 +DUALCASE=1; export DUALCASE # for MKS sh + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +relink_command=\"$relink_command\" + +# This environment variable determines our operation mode. +if test \"\$libtool_install_magic\" = \"$magic\"; then + # install mode needs the following variable: + notinst_deplibs='$notinst_deplibs' +else + # When we are sourced in execute mode, \$file and \$echo are already set. + if test \"\$libtool_execute_magic\" != \"$magic\"; then + echo=\"$qecho\" + file=\"\$0\" + # Make sure echo works. + if test \"X\$1\" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift + elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then + # Yippee, \$echo works! + : + else + # Restart under the correct shell, and then maybe \$echo will work. + exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"} + fi + fi\ +" + $echo >> $output "\ + + # Find the directory that this script lives in. + thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\` + test \"x\$thisdir\" = \"x\$file\" && thisdir=. + + # Follow symbolic links until we get to the real thisdir. + file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\` + while test -n \"\$file\"; do + destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\` + + # If there was a directory component, then change thisdir. + if test \"x\$destdir\" != \"x\$file\"; then + case \"\$destdir\" in + [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; + *) thisdir=\"\$thisdir/\$destdir\" ;; + esac + fi + + file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\` + file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\` + done + + # Try to get the absolute directory name. + absdir=\`cd \"\$thisdir\" && pwd\` + test -n \"\$absdir\" && thisdir=\"\$absdir\" +" + + if test "$fast_install" = yes; then + $echo >> $output "\ + program=lt-'$outputname'$exeext + progdir=\"\$thisdir/$objdir\" + + if test ! -f \"\$progdir/\$program\" || \\ + { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ + test \"X\$file\" != \"X\$progdir/\$program\"; }; then + + file=\"\$\$-\$program\" + + if test ! -d \"\$progdir\"; then + $mkdir \"\$progdir\" + else + $rm \"\$progdir/\$file\" + fi" + + $echo >> $output "\ + + # relink executable if necessary + if test -n \"\$relink_command\"; then + if relink_command_output=\`eval \$relink_command 2>&1\`; then : + else + $echo \"\$relink_command_output\" >&2 + $rm \"\$progdir/\$file\" + exit $EXIT_FAILURE + fi + fi + + $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || + { $rm \"\$progdir/\$program\"; + $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; } + $rm \"\$progdir/\$file\" + fi" + else + $echo >> $output "\ + program='$outputname' + progdir=\"\$thisdir/$objdir\" +" + fi + + $echo >> $output "\ + + if test -f \"\$progdir/\$program\"; then" + + # Export our shlibpath_var if we have one. + if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then + $echo >> $output "\ + # Add our own library path to $shlibpath_var + $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" + + # Some systems cannot cope with colon-terminated $shlibpath_var + # The second colon is a workaround for a bug in BeOS R4 sed + $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\` + + export $shlibpath_var +" + fi + + # fixup the dll searchpath if we need to. + if test -n "$dllsearchpath"; then + $echo >> $output "\ + # Add the dll search path components to the executable PATH + PATH=$dllsearchpath:\$PATH +" + fi + + $echo >> $output "\ + if test \"\$libtool_execute_magic\" != \"$magic\"; then + # Run the actual program with our arguments. +" + case $host in + # Backslashes separate directories on plain windows + *-*-mingw | *-*-os2*) + $echo >> $output "\ + exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} +" + ;; + + *) + $echo >> $output "\ + exec \"\$progdir/\$program\" \${1+\"\$@\"} +" + ;; + esac + $echo >> $output "\ + \$echo \"\$0: cannot exec \$program \$*\" + exit $EXIT_FAILURE + fi + else + # The program doesn't exist. + \$echo \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 + \$echo \"This script is just a wrapper for \$program.\" 1>&2 + $echo \"See the $PACKAGE documentation for more information.\" 1>&2 + exit $EXIT_FAILURE + fi +fi\ +" + chmod +x $output + fi + exit $EXIT_SUCCESS + ;; + esac + + # See if we need to build an old-fashioned archive. + for oldlib in $oldlibs; do + + if test "$build_libtool_libs" = convenience; then + oldobjs="$libobjs_save" + addlibs="$convenience" + build_libtool_libs=no + else + if test "$build_libtool_libs" = module; then + oldobjs="$libobjs_save" + build_libtool_libs=no + else + oldobjs="$old_deplibs $non_pic_objects" + fi + addlibs="$old_convenience" + fi + + if test -n "$addlibs"; then + gentop="$output_objdir/${outputname}x" + generated="$generated $gentop" + + func_extract_archives $gentop $addlibs + oldobjs="$oldobjs $func_extract_archives_result" + fi + + # Do each command in the archive commands. + if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then + cmds=$old_archive_from_new_cmds + else + # POSIX demands no paths to be encoded in archives. We have + # to avoid creating archives with duplicate basenames if we + # might have to extract them afterwards, e.g., when creating a + # static archive out of a convenience library, or when linking + # the entirety of a libtool archive into another (currently + # not supported by libtool). + if (for obj in $oldobjs + do + $echo "X$obj" | $Xsed -e 's%^.*/%%' + done | sort | sort -uc >/dev/null 2>&1); then + : + else + $echo "copying selected object files to avoid basename conflicts..." + + if test -z "$gentop"; then + gentop="$output_objdir/${outputname}x" + generated="$generated $gentop" + + $show "${rm}r $gentop" + $run ${rm}r "$gentop" + $show "$mkdir $gentop" + $run $mkdir "$gentop" + exit_status=$? + if test "$exit_status" -ne 0 && test ! -d "$gentop"; then + exit $exit_status + fi + fi + + save_oldobjs=$oldobjs + oldobjs= + counter=1 + for obj in $save_oldobjs + do + objbase=`$echo "X$obj" | $Xsed -e 's%^.*/%%'` + case " $oldobjs " in + " ") oldobjs=$obj ;; + *[\ /]"$objbase "*) + while :; do + # Make sure we don't pick an alternate name that also + # overlaps. + newobj=lt$counter-$objbase + counter=`expr $counter + 1` + case " $oldobjs " in + *[\ /]"$newobj "*) ;; + *) if test ! -f "$gentop/$newobj"; then break; fi ;; + esac + done + $show "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" + $run ln "$obj" "$gentop/$newobj" || + $run cp "$obj" "$gentop/$newobj" + oldobjs="$oldobjs $gentop/$newobj" + ;; + *) oldobjs="$oldobjs $obj" ;; + esac + done + fi + + eval cmds=\"$old_archive_cmds\" + + if len=`expr "X$cmds" : ".*"` && + test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then + cmds=$old_archive_cmds + else + # the command line is too long to link in one step, link in parts + $echo "using piecewise archive linking..." + save_RANLIB=$RANLIB + RANLIB=: + objlist= + concat_cmds= + save_oldobjs=$oldobjs + + # Is there a better way of finding the last object in the list? + for obj in $save_oldobjs + do + last_oldobj=$obj + done + for obj in $save_oldobjs + do + oldobjs="$objlist $obj" + objlist="$objlist $obj" + eval test_cmds=\"$old_archive_cmds\" + if len=`expr "X$test_cmds" : ".*" 2>/dev/null` && + test "$len" -le "$max_cmd_len"; then + : + else + # the above command should be used before it gets too long + oldobjs=$objlist + if test "$obj" = "$last_oldobj" ; then + RANLIB=$save_RANLIB + fi + test -z "$concat_cmds" || concat_cmds=$concat_cmds~ + eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" + objlist= + fi + done + RANLIB=$save_RANLIB + oldobjs=$objlist + if test "X$oldobjs" = "X" ; then + eval cmds=\"\$concat_cmds\" + else + eval cmds=\"\$concat_cmds~\$old_archive_cmds\" + fi + fi + fi + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + eval cmd=\"$cmd\" + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + done + + if test -n "$generated"; then + $show "${rm}r$generated" + $run ${rm}r$generated + fi + + # Now create the libtool archive. + case $output in + *.la) + old_library= + test "$build_old_libs" = yes && old_library="$libname.$libext" + $show "creating $output" + + # Preserve any variables that may affect compiler behavior + for var in $variables_saved_for_relink; do + if eval test -z \"\${$var+set}\"; then + relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command" + elif eval var_value=\$$var; test -z "$var_value"; then + relink_command="$var=; export $var; $relink_command" + else + var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"` + relink_command="$var=\"$var_value\"; export $var; $relink_command" + fi + done + # Quote the link command for shipping. + relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" + relink_command=`$echo "X$relink_command" | $SP2NL | $Xsed -e "$sed_quote_subst" | $NL2SP` + if test "$hardcode_automatic" = yes ; then + relink_command= + fi + + + # Only create the output if not a dry run. + if test -z "$run"; then + for installed in no yes; do + if test "$installed" = yes; then + if test -z "$install_libdir"; then + break + fi + output="$output_objdir/$outputname"i + # Replace all uninstalled libtool libraries with the installed ones + newdependency_libs= + for deplib in $dependency_libs; do + case $deplib in + *.la) + name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'` + eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` + if test -z "$libdir"; then + $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2 + exit $EXIT_FAILURE + fi + newdependency_libs="$newdependency_libs $libdir/$name" + ;; + *) newdependency_libs="$newdependency_libs $deplib" ;; + esac + done + dependency_libs="$newdependency_libs" + newdlfiles= + for lib in $dlfiles; do + name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` + eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` + if test -z "$libdir"; then + $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 + exit $EXIT_FAILURE + fi + newdlfiles="$newdlfiles $libdir/$name" + done + dlfiles="$newdlfiles" + newdlprefiles= + for lib in $dlprefiles; do + name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` + eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` + if test -z "$libdir"; then + $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 + exit $EXIT_FAILURE + fi + newdlprefiles="$newdlprefiles $libdir/$name" + done + dlprefiles="$newdlprefiles" + else + newdlfiles= + for lib in $dlfiles; do + case $lib in + [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; + *) abs=`pwd`"/$lib" ;; + esac + newdlfiles="$newdlfiles $abs" + done + dlfiles="$newdlfiles" + newdlprefiles= + for lib in $dlprefiles; do + case $lib in + [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; + *) abs=`pwd`"/$lib" ;; + esac + newdlprefiles="$newdlprefiles $abs" + done + dlprefiles="$newdlprefiles" + fi + $rm $output + # place dlname in correct position for cygwin + tdlname=$dlname + case $host,$output,$installed,$module,$dlname in + *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;; + esac + $echo > $output "\ +# $outputname - a libtool library file +# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# The name that we can dlopen(3). +dlname='$tdlname' + +# Names of this library. +library_names='$library_names' + +# The name of the static archive. +old_library='$old_library' + +# Libraries that this one depends upon. +dependency_libs='$dependency_libs' + +# Version information for $libname. +current=$current +age=$age +revision=$revision + +# Is this an already installed library? +installed=$installed + +# Should we warn about portability when linking against -modules? +shouldnotlink=$module + +# Files to dlopen/dlpreopen +dlopen='$dlfiles' +dlpreopen='$dlprefiles' + +# Directory that this library needs to be installed in: +libdir='$install_libdir'" + if test "$installed" = no && test "$need_relink" = yes; then + $echo >> $output "\ +relink_command=\"$relink_command\"" + fi + done + fi + + # Do a symbolic link so that the libtool archive can be found in + # LD_LIBRARY_PATH before the program is installed. + $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)" + $run eval '(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)' || exit $? + ;; + esac + exit $EXIT_SUCCESS + ;; + + # libtool install mode + install) + modename="$modename: install" + + # There may be an optional sh(1) argument at the beginning of + # install_prog (especially on Windows NT). + if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || + # Allow the use of GNU shtool's install command. + $echo "X$nonopt" | grep shtool > /dev/null; then + # Aesthetically quote it. + arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"` + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + arg="\"$arg\"" + ;; + esac + install_prog="$arg " + arg="$1" + shift + else + install_prog= + arg=$nonopt + fi + + # The real first argument should be the name of the installation program. + # Aesthetically quote it. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + arg="\"$arg\"" + ;; + esac + install_prog="$install_prog$arg" + + # We need to accept at least all the BSD install flags. + dest= + files= + opts= + prev= + install_type= + isdir=no + stripme= + for arg + do + if test -n "$dest"; then + files="$files $dest" + dest=$arg + continue + fi + + case $arg in + -d) isdir=yes ;; + -f) + case " $install_prog " in + *[\\\ /]cp\ *) ;; + *) prev=$arg ;; + esac + ;; + -g | -m | -o) prev=$arg ;; + -s) + stripme=" -s" + continue + ;; + -*) + ;; + *) + # If the previous option needed an argument, then skip it. + if test -n "$prev"; then + prev= + else + dest=$arg + continue + fi + ;; + esac + + # Aesthetically quote the argument. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + arg="\"$arg\"" + ;; + esac + install_prog="$install_prog $arg" + done + + if test -z "$install_prog"; then + $echo "$modename: you must specify an install program" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + + if test -n "$prev"; then + $echo "$modename: the \`$prev' option requires an argument" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + + if test -z "$files"; then + if test -z "$dest"; then + $echo "$modename: no file or destination specified" 1>&2 + else + $echo "$modename: you must specify a destination" 1>&2 + fi + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + + # Strip any trailing slash from the destination. + dest=`$echo "X$dest" | $Xsed -e 's%/$%%'` + + # Check to see that the destination is a directory. + test -d "$dest" && isdir=yes + if test "$isdir" = yes; then + destdir="$dest" + destname= + else + destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'` + test "X$destdir" = "X$dest" && destdir=. + destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'` + + # Not a directory, so check to see that there is only one file specified. + set dummy $files + if test "$#" -gt 2; then + $echo "$modename: \`$dest' is not a directory" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + fi + case $destdir in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + for file in $files; do + case $file in + *.lo) ;; + *) + $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + ;; + esac + done + ;; + esac + + # This variable tells wrapper scripts just to set variables rather + # than running their programs. + libtool_install_magic="$magic" + + staticlibs= + future_libdirs= + current_libdirs= + for file in $files; do + + # Do each installation. + case $file in + *.$libext) + # Do the static libraries later. + staticlibs="$staticlibs $file" + ;; + + *.la) + # Check to see that this really is a libtool archive. + if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : + else + $echo "$modename: \`$file' is not a valid libtool archive" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + + library_names= + old_library= + relink_command= + # If there is no directory component, then add one. + case $file in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + # Add the libdir to current_libdirs if it is the destination. + if test "X$destdir" = "X$libdir"; then + case "$current_libdirs " in + *" $libdir "*) ;; + *) current_libdirs="$current_libdirs $libdir" ;; + esac + else + # Note the libdir as a future libdir. + case "$future_libdirs " in + *" $libdir "*) ;; + *) future_libdirs="$future_libdirs $libdir" ;; + esac + fi + + dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/ + test "X$dir" = "X$file/" && dir= + dir="$dir$objdir" + + if test -n "$relink_command"; then + # Determine the prefix the user has applied to our future dir. + inst_prefix_dir=`$echo "$destdir" | $SED "s%$libdir\$%%"` + + # Don't allow the user to place us outside of our expected + # location b/c this prevents finding dependent libraries that + # are installed to the same prefix. + # At present, this check doesn't affect windows .dll's that + # are installed into $libdir/../bin (currently, that works fine) + # but it's something to keep an eye on. + if test "$inst_prefix_dir" = "$destdir"; then + $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2 + exit $EXIT_FAILURE + fi + + if test -n "$inst_prefix_dir"; then + # Stick the inst_prefix_dir data into the link command. + relink_command=`$echo "$relink_command" | $SP2NL | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%" | $NL2SP` + else + relink_command=`$echo "$relink_command" | $SP2NL | $SED "s%@inst_prefix_dir@%%" | $NL2SP` + fi + + $echo "$modename: warning: relinking \`$file'" 1>&2 + $show "$relink_command" + if $run eval "$relink_command"; then : + else + $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2 + exit $EXIT_FAILURE + fi + fi + + # See the names of the shared library. + set dummy $library_names + if test -n "$2"; then + realname="$2" + shift + shift + + srcname="$realname" + test -n "$relink_command" && srcname="$realname"T + + # Install the shared library and build the symlinks. + $show "$install_prog $dir/$srcname $destdir/$realname" + $run eval "$install_prog $dir/$srcname $destdir/$realname" || exit $? + if test -n "$stripme" && test -n "$striplib"; then + $show "$striplib $destdir/$realname" + $run eval "$striplib $destdir/$realname" || exit $? + fi + + if test "$#" -gt 0; then + # Delete the old symlinks, and create new ones. + # Try `ln -sf' first, because the `ln' binary might depend on + # the symlink we replace! Solaris /bin/ln does not understand -f, + # so we also need to try rm && ln -s. + for linkname + do + if test "$linkname" != "$realname"; then + $show "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })" + $run eval "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })" + fi + done + fi + + # Do each command in the postinstall commands. + lib="$destdir/$realname" + cmds=$postinstall_cmds + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" || { + lt_exit=$? + + # Restore the uninstalled library and exit + if test "$mode" = relink; then + $run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)' + fi + + exit $lt_exit + } + done + IFS="$save_ifs" + fi + + # Install the pseudo-library for information purposes. + name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + instname="$dir/$name"i + $show "$install_prog $instname $destdir/$name" + $run eval "$install_prog $instname $destdir/$name" || exit $? + + # Maybe install the static library, too. + test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library" + ;; + + *.lo) + # Install (i.e. copy) a libtool object. + + # Figure out destination file name, if it wasn't already specified. + if test -n "$destname"; then + destfile="$destdir/$destname" + else + destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + destfile="$destdir/$destfile" + fi + + # Deduce the name of the destination old-style object file. + case $destfile in + *.lo) + staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"` + ;; + *.$objext) + staticdest="$destfile" + destfile= + ;; + *) + $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + ;; + esac + + # Install the libtool object if requested. + if test -n "$destfile"; then + $show "$install_prog $file $destfile" + $run eval "$install_prog $file $destfile" || exit $? + fi + + # Install the old object if enabled. + if test "$build_old_libs" = yes; then + # Deduce the name of the old-style object file. + staticobj=`$echo "X$file" | $Xsed -e "$lo2o"` + + $show "$install_prog $staticobj $staticdest" + $run eval "$install_prog \$staticobj \$staticdest" || exit $? + fi + exit $EXIT_SUCCESS + ;; + + *) + # Figure out destination file name, if it wasn't already specified. + if test -n "$destname"; then + destfile="$destdir/$destname" + else + destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + destfile="$destdir/$destfile" + fi + + # If the file is missing, and there is a .exe on the end, strip it + # because it is most likely a libtool script we actually want to + # install + stripped_ext="" + case $file in + *.exe) + if test ! -f "$file"; then + file=`$echo $file|${SED} 's,.exe$,,'` + stripped_ext=".exe" + fi + ;; + esac + + # Do a test to see if this is really a libtool program. + case $host in + *cygwin*|*mingw*) + wrapper=`$echo $file | ${SED} -e 's,.exe$,,'` + ;; + *) + wrapper=$file + ;; + esac + if (${SED} -e '4q' $wrapper | grep "^# Generated by .*$PACKAGE")>/dev/null 2>&1; then + notinst_deplibs= + relink_command= + + # Note that it is not necessary on cygwin/mingw to append a dot to + # foo even if both foo and FILE.exe exist: automatic-append-.exe + # behavior happens only for exec(3), not for open(2)! Also, sourcing + # `FILE.' does not work on cygwin managed mounts. + # + # If there is no directory component, then add one. + case $wrapper in + */* | *\\*) . ${wrapper} ;; + *) . ./${wrapper} ;; + esac + + # Check the variables that should have been set. + if test -z "$notinst_deplibs"; then + $echo "$modename: invalid libtool wrapper script \`$wrapper'" 1>&2 + exit $EXIT_FAILURE + fi + + finalize=yes + for lib in $notinst_deplibs; do + # Check to see that each library is installed. + libdir= + if test -f "$lib"; then + # If there is no directory component, then add one. + case $lib in + */* | *\\*) . $lib ;; + *) . ./$lib ;; + esac + fi + libfile="$libdir/"`$echo "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test + if test -n "$libdir" && test ! -f "$libfile"; then + $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2 + finalize=no + fi + done + + relink_command= + # Note that it is not necessary on cygwin/mingw to append a dot to + # foo even if both foo and FILE.exe exist: automatic-append-.exe + # behavior happens only for exec(3), not for open(2)! Also, sourcing + # `FILE.' does not work on cygwin managed mounts. + # + # If there is no directory component, then add one. + case $wrapper in + */* | *\\*) . ${wrapper} ;; + *) . ./${wrapper} ;; + esac + + outputname= + if test "$fast_install" = no && test -n "$relink_command"; then + if test "$finalize" = yes && test -z "$run"; then + tmpdir=`func_mktempdir` + file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'` + outputname="$tmpdir/$file" + # Replace the output file specification. + relink_command=`$echo "X$relink_command" | $SP2NL | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g' | $NL2SP` + + $show "$relink_command" + if $run eval "$relink_command"; then : + else + $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2 + ${rm}r "$tmpdir" + continue + fi + file="$outputname" + else + $echo "$modename: warning: cannot relink \`$file'" 1>&2 + fi + else + # Install the binary that we compiled earlier. + file=`$echo "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"` + fi + fi + + # remove .exe since cygwin /usr/bin/install will append another + # one anyway + case $install_prog,$host in + */usr/bin/install*,*cygwin*) + case $file:$destfile in + *.exe:*.exe) + # this is ok + ;; + *.exe:*) + destfile=$destfile.exe + ;; + *:*.exe) + destfile=`$echo $destfile | ${SED} -e 's,.exe$,,'` + ;; + esac + ;; + esac + $show "$install_prog$stripme $file $destfile" + $run eval "$install_prog\$stripme \$file \$destfile" || exit $? + test -n "$outputname" && ${rm}r "$tmpdir" + ;; + esac + done + + for file in $staticlibs; do + name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + + # Set up the ranlib parameters. + oldlib="$destdir/$name" + + $show "$install_prog $file $oldlib" + $run eval "$install_prog \$file \$oldlib" || exit $? + + if test -n "$stripme" && test -n "$old_striplib"; then + $show "$old_striplib $oldlib" + $run eval "$old_striplib $oldlib" || exit $? + fi + + # Do each command in the postinstall commands. + cmds=$old_postinstall_cmds + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + done + + if test -n "$future_libdirs"; then + $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2 + fi + + if test -n "$current_libdirs"; then + # Maybe just do a dry run. + test -n "$run" && current_libdirs=" -n$current_libdirs" + exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' + else + exit $EXIT_SUCCESS + fi + ;; + + # libtool finish mode + finish) + modename="$modename: finish" + libdirs="$nonopt" + admincmds= + + if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then + for dir + do + libdirs="$libdirs $dir" + done + + for libdir in $libdirs; do + if test -n "$finish_cmds"; then + # Do each command in the finish commands. + cmds=$finish_cmds + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" || admincmds="$admincmds + $cmd" + done + IFS="$save_ifs" + fi + if test -n "$finish_eval"; then + # Do the single finish_eval. + eval cmds=\"$finish_eval\" + $run eval "$cmds" || admincmds="$admincmds + $cmds" + fi + done + fi + + # Exit here if they wanted silent mode. + test "$show" = : && exit $EXIT_SUCCESS + + $echo "X----------------------------------------------------------------------" | $Xsed + $echo "Libraries have been installed in:" + for libdir in $libdirs; do + $echo " $libdir" + done + $echo + $echo "If you ever happen to want to link against installed libraries" + $echo "in a given directory, LIBDIR, you must either use libtool, and" + $echo "specify the full pathname of the library, or use the \`-LLIBDIR'" + $echo "flag during linking and do at least one of the following:" + if test -n "$shlibpath_var"; then + $echo " - add LIBDIR to the \`$shlibpath_var' environment variable" + $echo " during execution" + fi + if test -n "$runpath_var"; then + $echo " - add LIBDIR to the \`$runpath_var' environment variable" + $echo " during linking" + fi + if test -n "$hardcode_libdir_flag_spec"; then + libdir=LIBDIR + eval flag=\"$hardcode_libdir_flag_spec\" + + $echo " - use the \`$flag' linker flag" + fi + if test -n "$admincmds"; then + $echo " - have your system administrator run these commands:$admincmds" + fi + if test -f /etc/ld.so.conf; then + $echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" + fi + $echo + $echo "See any operating system documentation about shared libraries for" + $echo "more information, such as the ld(1) and ld.so(8) manual pages." + $echo "X----------------------------------------------------------------------" | $Xsed + exit $EXIT_SUCCESS + ;; + + # libtool execute mode + execute) + modename="$modename: execute" + + # The first argument is the command name. + cmd="$nonopt" + if test -z "$cmd"; then + $echo "$modename: you must specify a COMMAND" 1>&2 + $echo "$help" + exit $EXIT_FAILURE + fi + + # Handle -dlopen flags immediately. + for file in $execute_dlfiles; do + if test ! -f "$file"; then + $echo "$modename: \`$file' is not a file" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + + dir= + case $file in + *.la) + # Check to see that this really is a libtool archive. + if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : + else + $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + + # Read the libtool library. + dlname= + library_names= + + # If there is no directory component, then add one. + case $file in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + # Skip this library if it cannot be dlopened. + if test -z "$dlname"; then + # Warn if it was a shared library. + test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'" + continue + fi + + dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + test "X$dir" = "X$file" && dir=. + + if test -f "$dir/$objdir/$dlname"; then + dir="$dir/$objdir" + else + if test ! -f "$dir/$dlname"; then + $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2 + exit $EXIT_FAILURE + fi + fi + ;; + + *.lo) + # Just add the directory containing the .lo file. + dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + test "X$dir" = "X$file" && dir=. + ;; + + *) + $echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2 + continue + ;; + esac + + # Get the absolute pathname. + absdir=`cd "$dir" && pwd` + test -n "$absdir" && dir="$absdir" + + # Now add the directory to shlibpath_var. + if eval "test -z \"\$$shlibpath_var\""; then + eval "$shlibpath_var=\"\$dir\"" + else + eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" + fi + done + + # This variable tells wrapper scripts just to set shlibpath_var + # rather than running their programs. + libtool_execute_magic="$magic" + + # Check if any of the arguments is a wrapper script. + args= + for file + do + case $file in + -*) ;; + *) + # Do a test to see if this is really a libtool program. + if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + # If there is no directory component, then add one. + case $file in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + # Transform arg to wrapped name. + file="$progdir/$program" + fi + ;; + esac + # Quote arguments (to preserve shell metacharacters). + file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"` + args="$args \"$file\"" + done + + if test -z "$run"; then + if test -n "$shlibpath_var"; then + # Export the shlibpath_var. + eval "export $shlibpath_var" + fi + + # Restore saved environment variables + for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES + do + eval "if test \"\${save_$lt_var+set}\" = set; then + $lt_var=\$save_$lt_var; export $lt_var + fi" + done + + # Now prepare to actually exec the command. + exec_cmd="\$cmd$args" + else + # Display what would be done. + if test -n "$shlibpath_var"; then + eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\"" + $echo "export $shlibpath_var" + fi + $echo "$cmd$args" + exit $EXIT_SUCCESS + fi + ;; + + # libtool clean and uninstall mode + clean | uninstall) + modename="$modename: $mode" + rm="$nonopt" + files= + rmforce= + exit_status=0 + + # This variable tells wrapper scripts just to set variables rather + # than running their programs. + libtool_install_magic="$magic" + + for arg + do + case $arg in + -f) rm="$rm $arg"; rmforce=yes ;; + -*) rm="$rm $arg" ;; + *) files="$files $arg" ;; + esac + done + + if test -z "$rm"; then + $echo "$modename: you must specify an RM program" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + + rmdirs= + + origobjdir="$objdir" + for file in $files; do + dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + if test "X$dir" = "X$file"; then + dir=. + objdir="$origobjdir" + else + objdir="$dir/$origobjdir" + fi + name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + test "$mode" = uninstall && objdir="$dir" + + # Remember objdir for removal later, being careful to avoid duplicates + if test "$mode" = clean; then + case " $rmdirs " in + *" $objdir "*) ;; + *) rmdirs="$rmdirs $objdir" ;; + esac + fi + + # Don't error if the file doesn't exist and rm -f was used. + if (test -L "$file") >/dev/null 2>&1 \ + || (test -h "$file") >/dev/null 2>&1 \ + || test -f "$file"; then + : + elif test -d "$file"; then + exit_status=1 + continue + elif test "$rmforce" = yes; then + continue + fi + + rmfiles="$file" + + case $name in + *.la) + # Possibly a libtool archive, so verify it. + if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + . $dir/$name + + # Delete the libtool libraries and symlinks. + for n in $library_names; do + rmfiles="$rmfiles $objdir/$n" + done + test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library" + + case "$mode" in + clean) + case " $library_names " in + # " " in the beginning catches empty $dlname + *" $dlname "*) ;; + *) rmfiles="$rmfiles $objdir/$dlname" ;; + esac + test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i" + ;; + uninstall) + if test -n "$library_names"; then + # Do each command in the postuninstall commands. + cmds=$postuninstall_cmds + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" + if test "$?" -ne 0 && test "$rmforce" != yes; then + exit_status=1 + fi + done + IFS="$save_ifs" + fi + + if test -n "$old_library"; then + # Do each command in the old_postuninstall commands. + cmds=$old_postuninstall_cmds + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" + if test "$?" -ne 0 && test "$rmforce" != yes; then + exit_status=1 + fi + done + IFS="$save_ifs" + fi + # FIXME: should reinstall the best remaining shared library. + ;; + esac + fi + ;; + + *.lo) + # Possibly a libtool object, so verify it. + if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + + # Read the .lo file + . $dir/$name + + # Add PIC object to the list of files to remove. + if test -n "$pic_object" \ + && test "$pic_object" != none; then + rmfiles="$rmfiles $dir/$pic_object" + fi + + # Add non-PIC object to the list of files to remove. + if test -n "$non_pic_object" \ + && test "$non_pic_object" != none; then + rmfiles="$rmfiles $dir/$non_pic_object" + fi + fi + ;; + + *) + if test "$mode" = clean ; then + noexename=$name + case $file in + *.exe) + file=`$echo $file|${SED} 's,.exe$,,'` + noexename=`$echo $name|${SED} 's,.exe$,,'` + # $file with .exe has already been added to rmfiles, + # add $file without .exe + rmfiles="$rmfiles $file" + ;; + esac + # Do a test to see if this is a libtool program. + if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + relink_command= + . $dir/$noexename + + # note $name still contains .exe if it was in $file originally + # as does the version of $file that was added into $rmfiles + rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}" + if test "$fast_install" = yes && test -n "$relink_command"; then + rmfiles="$rmfiles $objdir/lt-$name" + fi + if test "X$noexename" != "X$name" ; then + rmfiles="$rmfiles $objdir/lt-${noexename}.c" + fi + fi + fi + ;; + esac + $show "$rm $rmfiles" + $run $rm $rmfiles || exit_status=1 + done + objdir="$origobjdir" + + # Try to remove the ${objdir}s in the directories where we deleted files + for dir in $rmdirs; do + if test -d "$dir"; then + $show "rmdir $dir" + $run rmdir $dir >/dev/null 2>&1 + fi + done + + exit $exit_status + ;; + + "") + $echo "$modename: you must specify a MODE" 1>&2 + $echo "$generic_help" 1>&2 + exit $EXIT_FAILURE + ;; + esac + + if test -z "$exec_cmd"; then + $echo "$modename: invalid operation mode \`$mode'" 1>&2 + $echo "$generic_help" 1>&2 + exit $EXIT_FAILURE + fi +fi # test -z "$show_help" + +if test -n "$exec_cmd"; then + eval exec $exec_cmd + exit $EXIT_FAILURE +fi + +# We need to display help for each of the modes. +case $mode in +"") $echo \ +"Usage: $modename [OPTION]... [MODE-ARG]... + +Provide generalized library-building support services. + + --config show all configuration variables + --debug enable verbose shell tracing +-n, --dry-run display commands without modifying any files + --features display basic configuration information and exit + --finish same as \`--mode=finish' + --help display this help message and exit + --mode=MODE use operation mode MODE [default=inferred from MODE-ARGS] + --quiet same as \`--silent' + --silent don't print informational messages + --tag=TAG use configuration variables from tag TAG + --version print version information + +MODE must be one of the following: + + clean remove files from the build directory + compile compile a source file into a libtool object + execute automatically set library path, then run a program + finish complete the installation of libtool libraries + install install libraries or executables + link create a library or an executable + uninstall remove libraries from an installed directory + +MODE-ARGS vary depending on the MODE. Try \`$modename --help --mode=MODE' for +a more detailed description of MODE. + +Report bugs to <bug-libtool@gnu.org>." + exit $EXIT_SUCCESS + ;; + +clean) + $echo \ +"Usage: $modename [OPTION]... --mode=clean RM [RM-OPTION]... FILE... + +Remove files from the build directory. + +RM is the name of the program to use to delete files associated with each FILE +(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed +to RM. + +If FILE is a libtool library, object or program, all the files associated +with it are deleted. Otherwise, only FILE itself is deleted using RM." + ;; + +compile) + $echo \ +"Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE + +Compile a source file into a libtool library object. + +This mode accepts the following additional options: + + -o OUTPUT-FILE set the output file name to OUTPUT-FILE + -prefer-pic try to building PIC objects only + -prefer-non-pic try to building non-PIC objects only + -static always build a \`.o' file suitable for static linking + +COMPILE-COMMAND is a command to be used in creating a \`standard' object file +from the given SOURCEFILE. + +The output file name is determined by removing the directory component from +SOURCEFILE, then substituting the C source code suffix \`.c' with the +library object suffix, \`.lo'." + ;; + +execute) + $echo \ +"Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]... + +Automatically set library path, then run a program. + +This mode accepts the following additional options: + + -dlopen FILE add the directory containing FILE to the library path + +This mode sets the library path environment variable according to \`-dlopen' +flags. + +If any of the ARGS are libtool executable wrappers, then they are translated +into their corresponding uninstalled binary, and any of their required library +directories are added to the library path. + +Then, COMMAND is executed, with ARGS as arguments." + ;; + +finish) + $echo \ +"Usage: $modename [OPTION]... --mode=finish [LIBDIR]... + +Complete the installation of libtool libraries. + +Each LIBDIR is a directory that contains libtool libraries. + +The commands that this mode executes may require superuser privileges. Use +the \`--dry-run' option if you just want to see what would be executed." + ;; + +install) + $echo \ +"Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND... + +Install executables or libraries. + +INSTALL-COMMAND is the installation command. The first component should be +either the \`install' or \`cp' program. + +The rest of the components are interpreted as arguments to that command (only +BSD-compatible install options are recognized)." + ;; + +link) + $echo \ +"Usage: $modename [OPTION]... --mode=link LINK-COMMAND... + +Link object files or libraries together to form another library, or to +create an executable program. + +LINK-COMMAND is a command using the C compiler that you would use to create +a program from several object files. + +The following components of LINK-COMMAND are treated specially: + + -all-static do not do any dynamic linking at all + -avoid-version do not add a version suffix if possible + -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime + -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols + -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) + -export-symbols SYMFILE + try to export only the symbols listed in SYMFILE + -export-symbols-regex REGEX + try to export only the symbols matching REGEX + -LLIBDIR search LIBDIR for required installed libraries + -lNAME OUTPUT-FILE requires the installed library libNAME + -module build a library that can dlopened + -no-fast-install disable the fast-install mode + -no-install link a not-installable executable + -no-undefined declare that a library does not refer to external symbols + -o OUTPUT-FILE create OUTPUT-FILE from the specified objects + -objectlist FILE Use a list of object files found in FILE to specify objects + -precious-files-regex REGEX + don't remove output files matching REGEX + -release RELEASE specify package release information + -rpath LIBDIR the created library will eventually be installed in LIBDIR + -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries + -static do not do any dynamic linking of uninstalled libtool libraries + -static-libtool-libs + do not do any dynamic linking of libtool libraries + -version-info CURRENT[:REVISION[:AGE]] + specify library version info [each variable defaults to 0] + +All other options (arguments beginning with \`-') are ignored. + +Every other argument is treated as a filename. Files ending in \`.la' are +treated as uninstalled libtool libraries, other files are standard or library +object files. + +If the OUTPUT-FILE ends in \`.la', then a libtool library is created, +only library objects (\`.lo' files) may be specified, and \`-rpath' is +required, except when creating a convenience library. + +If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created +using \`ar' and \`ranlib', or on Windows using \`lib'. + +If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file +is created, otherwise an executable program is created." + ;; + +uninstall) + $echo \ +"Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... + +Remove libraries from an installation directory. + +RM is the name of the program to use to delete files associated with each FILE +(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed +to RM. + +If FILE is a libtool library, all the files associated with it are deleted. +Otherwise, only FILE itself is deleted using RM." + ;; + +*) + $echo "$modename: invalid operation mode \`$mode'" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + ;; +esac + +$echo +$echo "Try \`$modename --help' for more information about other modes." + +exit $? + +# The TAGs below are defined such that we never get into a situation +# in which we disable both kinds of libraries. Given conflicting +# choices, we go for a static library, that is the most portable, +# since we can't tell whether shared libraries were disabled because +# the user asked for that or because the platform doesn't support +# them. This is particularly important on AIX, because we don't +# support having both static and shared libraries enabled at the same +# time on that platform, so we default to a shared-only configuration. +# If a disable-shared tag is given, we'll fallback to a static-only +# configuration. But we'll never go from static-only to shared-only. + +# ### BEGIN LIBTOOL TAG CONFIG: disable-shared +disable_libs=shared +# ### END LIBTOOL TAG CONFIG: disable-shared + +# ### BEGIN LIBTOOL TAG CONFIG: disable-static +disable_libs=static +# ### END LIBTOOL TAG CONFIG: disable-static + +# Local Variables: +# mode:shell-script +# sh-indentation:2 +# End: diff --git a/autoaux/missing b/autoaux/missing new file mode 100644 index 0000000..894e786 --- /dev/null +++ b/autoaux/missing @@ -0,0 +1,360 @@ +#! /bin/sh +# Common stub for a few missing GNU programs while installing. + +scriptversion=2005-06-08.21 + +# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005 +# Free Software Foundation, Inc. +# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +if test $# -eq 0; then + echo 1>&2 "Try \`$0 --help' for more information" + exit 1 +fi + +run=: + +# In the cases where this matters, `missing' is being run in the +# srcdir already. +if test -f configure.ac; then + configure_ac=configure.ac +else + configure_ac=configure.in +fi + +msg="missing on your system" + +case "$1" in +--run) + # Try to run requested program, and just exit if it succeeds. + run= + shift + "$@" && exit 0 + # Exit code 63 means version mismatch. This often happens + # when the user try to use an ancient version of a tool on + # a file that requires a minimum version. In this case we + # we should proceed has if the program had been absent, or + # if --run hadn't been passed. + if test $? = 63; then + run=: + msg="probably too old" + fi + ;; + + -h|--h|--he|--hel|--help) + echo "\ +$0 [OPTION]... PROGRAM [ARGUMENT]... + +Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an +error status if there is no known handling for PROGRAM. + +Options: + -h, --help display this help and exit + -v, --version output version information and exit + --run try to run the given command, and emulate it if it fails + +Supported PROGRAM values: + aclocal touch file \`aclocal.m4' + autoconf touch file \`configure' + autoheader touch file \`config.h.in' + automake touch all \`Makefile.in' files + bison create \`y.tab.[ch]', if possible, from existing .[ch] + flex create \`lex.yy.c', if possible, from existing .c + help2man touch the output file + lex create \`lex.yy.c', if possible, from existing .c + makeinfo touch the output file + tar try tar, gnutar, gtar, then tar without non-portable flags + yacc create \`y.tab.[ch]', if possible, from existing .[ch] + +Send bug reports to <bug-automake@gnu.org>." + exit $? + ;; + + -v|--v|--ve|--ver|--vers|--versi|--versio|--version) + echo "missing $scriptversion (GNU Automake)" + exit $? + ;; + + -*) + echo 1>&2 "$0: Unknown \`$1' option" + echo 1>&2 "Try \`$0 --help' for more information" + exit 1 + ;; + +esac + +# Now exit if we have it, but it failed. Also exit now if we +# don't have it and --version was passed (most likely to detect +# the program). +case "$1" in + lex|yacc) + # Not GNU programs, they don't have --version. + ;; + + tar) + if test -n "$run"; then + echo 1>&2 "ERROR: \`tar' requires --run" + exit 1 + elif test "x$2" = "x--version" || test "x$2" = "x--help"; then + exit 1 + fi + ;; + + *) + if test -z "$run" && ($1 --version) > /dev/null 2>&1; then + # We have it, but it failed. + exit 1 + elif test "x$2" = "x--version" || test "x$2" = "x--help"; then + # Could not run --version or --help. This is probably someone + # running `$TOOL --version' or `$TOOL --help' to check whether + # $TOOL exists and not knowing $TOOL uses missing. + exit 1 + fi + ;; +esac + +# If it does not exist, or fails to run (possibly an outdated version), +# try to emulate it. +case "$1" in + aclocal*) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`acinclude.m4' or \`${configure_ac}'. You might want + to install the \`Automake' and \`Perl' packages. Grab them from + any GNU archive site." + touch aclocal.m4 + ;; + + autoconf) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`${configure_ac}'. You might want to install the + \`Autoconf' and \`GNU m4' packages. Grab them from any GNU + archive site." + touch configure + ;; + + autoheader) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`acconfig.h' or \`${configure_ac}'. You might want + to install the \`Autoconf' and \`GNU m4' packages. Grab them + from any GNU archive site." + files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` + test -z "$files" && files="config.h" + touch_files= + for f in $files; do + case "$f" in + *:*) touch_files="$touch_files "`echo "$f" | + sed -e 's/^[^:]*://' -e 's/:.*//'`;; + *) touch_files="$touch_files $f.in";; + esac + done + touch $touch_files + ;; + + automake*) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. + You might want to install the \`Automake' and \`Perl' packages. + Grab them from any GNU archive site." + find . -type f -name Makefile.am -print | + sed 's/\.am$/.in/' | + while read f; do touch "$f"; done + ;; + + autom4te) + echo 1>&2 "\ +WARNING: \`$1' is needed, but is $msg. + You might have modified some files without having the + proper tools for further handling them. + You can get \`$1' as part of \`Autoconf' from any GNU + archive site." + + file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'` + test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'` + if test -f "$file"; then + touch $file + else + test -z "$file" || exec >$file + echo "#! /bin/sh" + echo "# Created by GNU Automake missing as a replacement of" + echo "# $ $@" + echo "exit 0" + chmod +x $file + exit 1 + fi + ;; + + bison|yacc) + echo 1>&2 "\ +WARNING: \`$1' $msg. You should only need it if + you modified a \`.y' file. You may need the \`Bison' package + in order for those modifications to take effect. You can get + \`Bison' from any GNU archive site." + rm -f y.tab.c y.tab.h + if [ $# -ne 1 ]; then + eval LASTARG="\${$#}" + case "$LASTARG" in + *.y) + SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` + if [ -f "$SRCFILE" ]; then + cp "$SRCFILE" y.tab.c + fi + SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` + if [ -f "$SRCFILE" ]; then + cp "$SRCFILE" y.tab.h + fi + ;; + esac + fi + if [ ! -f y.tab.h ]; then + echo >y.tab.h + fi + if [ ! -f y.tab.c ]; then + echo 'main() { return 0; }' >y.tab.c + fi + ;; + + lex|flex) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified a \`.l' file. You may need the \`Flex' package + in order for those modifications to take effect. You can get + \`Flex' from any GNU archive site." + rm -f lex.yy.c + if [ $# -ne 1 ]; then + eval LASTARG="\${$#}" + case "$LASTARG" in + *.l) + SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` + if [ -f "$SRCFILE" ]; then + cp "$SRCFILE" lex.yy.c + fi + ;; + esac + fi + if [ ! -f lex.yy.c ]; then + echo 'main() { return 0; }' >lex.yy.c + fi + ;; + + help2man) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified a dependency of a manual page. You may need the + \`Help2man' package in order for those modifications to take + effect. You can get \`Help2man' from any GNU archive site." + + file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` + if test -z "$file"; then + file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'` + fi + if [ -f "$file" ]; then + touch $file + else + test -z "$file" || exec >$file + echo ".ab help2man is required to generate this page" + exit 1 + fi + ;; + + makeinfo) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified a \`.texi' or \`.texinfo' file, or any other file + indirectly affecting the aspect of the manual. The spurious + call might also be the consequence of using a buggy \`make' (AIX, + DU, IRIX). You might want to install the \`Texinfo' package or + the \`GNU make' package. Grab either from any GNU archive site." + # The file to touch is that specified with -o ... + file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` + if test -z "$file"; then + # ... or it is the one specified with @setfilename ... + infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` + file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $infile` + # ... or it is derived from the source name (dir/f.texi becomes f.info) + test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info + fi + # If the file does not exist, the user really needs makeinfo; + # let's fail without touching anything. + test -f $file || exit 1 + touch $file + ;; + + tar) + shift + + # We have already tried tar in the generic part. + # Look for gnutar/gtar before invocation to avoid ugly error + # messages. + if (gnutar --version > /dev/null 2>&1); then + gnutar "$@" && exit 0 + fi + if (gtar --version > /dev/null 2>&1); then + gtar "$@" && exit 0 + fi + firstarg="$1" + if shift; then + case "$firstarg" in + *o*) + firstarg=`echo "$firstarg" | sed s/o//` + tar "$firstarg" "$@" && exit 0 + ;; + esac + case "$firstarg" in + *h*) + firstarg=`echo "$firstarg" | sed s/h//` + tar "$firstarg" "$@" && exit 0 + ;; + esac + fi + + echo 1>&2 "\ +WARNING: I can't seem to be able to run \`tar' with the given arguments. + You may want to install GNU tar or Free paxutils, or check the + command line arguments." + exit 1 + ;; + + *) + echo 1>&2 "\ +WARNING: \`$1' is needed, and is $msg. + You might have modified some files without having the + proper tools for further handling them. Check the \`README' file, + it often tells you about the needed prerequisites for installing + this package. You may also peek at any GNU archive site, in case + some other package would contain this missing \`$1' program." + exit 1 + ;; +esac + +exit 0 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-end: "$" +# End: diff --git a/configure b/configure new file mode 100755 index 0000000..2aac99c --- /dev/null +++ b/configure @@ -0,0 +1,15990 @@ +#! /bin/sh +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.63 for MP4v2 1.9.1. +# +# Report bugs to <eddyg@myreflection.org>. +# +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, +# 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + + + +# PATH needs CR +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + +# Support unset when possible. +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + { (exit 1); exit 1; } +fi + +# Work around bugs in pre-3.0 UWIN ksh. +for as_var in ENV MAIL MAILPATH +do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# Required to use basename. +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + + +# Name of the executable. +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# CDPATH. +$as_unset CDPATH + + +if test "x$CONFIG_SHELL" = x; then + if (eval ":") 2>/dev/null; then + as_have_required=yes +else + as_have_required=no +fi + + if test $as_have_required = yes && (eval ": +(as_func_return () { + (exit \$1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} + +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi + +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = \"\$1\" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test \$exitcode = 0) || { (exit 1); exit 1; } + +( + as_lineno_1=\$LINENO + as_lineno_2=\$LINENO + test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" && + test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; } +") 2> /dev/null; then + : +else + as_candidate_shells= + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + case $as_dir in + /*) + for as_base in sh bash ksh sh5; do + as_candidate_shells="$as_candidate_shells $as_dir/$as_base" + done;; + esac +done +IFS=$as_save_IFS + + + for as_shell in $as_candidate_shells $SHELL; do + # Try only shells that exist, to save several forks. + if { test -f "$as_shell" || test -f "$as_shell.exe"; } && + { ("$as_shell") 2> /dev/null <<\_ASEOF +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + +: +_ASEOF +}; then + CONFIG_SHELL=$as_shell + as_have_required=yes + if { "$as_shell" 2> /dev/null <<\_ASEOF +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + +: +(as_func_return () { + (exit $1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} + +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi + +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = "$1" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test $exitcode = 0) || { (exit 1); exit 1; } + +( + as_lineno_1=$LINENO + as_lineno_2=$LINENO + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; } + +_ASEOF +}; then + break +fi + +fi + + done + + if test "x$CONFIG_SHELL" != x; then + for as_var in BASH_ENV ENV + do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var + done + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} +fi + + + if test $as_have_required = no; then + echo This script requires a shell more modern than all the + echo shells that I found on your system. Please install a + echo modern shell, or manually run the script under such a + echo shell if you do have one. + { (exit 1); exit 1; } +fi + + +fi + +fi + + + +(eval "as_func_return () { + (exit \$1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} + +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi + +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = \"\$1\" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test \$exitcode = 0") || { + echo No shell found that supports shell functions. + echo Please tell bug-autoconf@gnu.org about your system, + echo including any error possibly output before this message. + echo This can help us improve future autoconf versions. + echo Configuration will now proceed without shell functions. +} + + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line after each line using $LINENO; the second 'sed' + # does the real work. The second script uses 'N' to pair each + # line-number line with the line containing $LINENO, and appends + # trailing '-' during substitution so that $LINENO is not a special + # case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # scripts with optimization help from Paolo Bonzini. Blame Lee + # E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | + sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno + N + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ + t loop + s/-\n.*// + ' >$as_me.lineno && + chmod +x "$as_me.lineno" || + { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 + { (exit 1); exit 1; }; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" + # Exit status is that of the last command. + exit +} + + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in +-n*) + case `echo 'x\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + *) ECHO_C='\c';; + esac;; +*) + ECHO_N='-n';; +esac +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -p' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -p' + fi +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + + + +# Check that we are running under the correct shell. +SHELL=${CONFIG_SHELL-/bin/sh} + +case X$ECHO in +X*--fallback-echo) + # Remove one level of quotation (which was required for Make). + ECHO=`echo "$ECHO" | sed 's,\\\\\$\\$0,'$0','` + ;; +esac + +echo=${ECHO-echo} +if test "X$1" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift +elif test "X$1" = X--fallback-echo; then + # Avoid inline document here, it may be left over + : +elif test "X`($echo '\t') 2>/dev/null`" = 'X\t' ; then + # Yippee, $echo works! + : +else + # Restart under the correct shell. + exec $SHELL "$0" --no-reexec ${1+"$@"} +fi + +if test "X$1" = X--fallback-echo; then + # used as fallback echo + shift + cat <<EOF +$* +EOF + exit 0 +fi + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +if test -z "$ECHO"; then +if test "X${echo_test_string+set}" != Xset; then +# find a string as large as possible, as long as the shell can cope with it + for cmd in 'sed 50q "$0"' 'sed 20q "$0"' 'sed 10q "$0"' 'sed 2q "$0"' 'echo test'; do + # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ... + if (echo_test_string=`eval $cmd`) 2>/dev/null && + echo_test_string=`eval $cmd` && + (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null + then + break + fi + done +fi + +if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + : +else + # The Solaris, AIX, and Digital Unix default echo programs unquote + # backslashes. This makes it impossible to quote backslashes using + # echo "$something" | sed 's/\\/\\\\/g' + # + # So, first we look for a working echo in the user's PATH. + + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for dir in $PATH /usr/ucb; do + IFS="$lt_save_ifs" + if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && + test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + echo="$dir/echo" + break + fi + done + IFS="$lt_save_ifs" + + if test "X$echo" = Xecho; then + # We didn't find a better echo, so look for alternatives. + if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`(print -r "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + # This shell has a builtin print -r that does the trick. + echo='print -r' + elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) && + test "X$CONFIG_SHELL" != X/bin/ksh; then + # If we have ksh, try running configure again with it. + ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} + export ORIGINAL_CONFIG_SHELL + CONFIG_SHELL=/bin/ksh + export CONFIG_SHELL + exec $CONFIG_SHELL "$0" --no-reexec ${1+"$@"} + else + # Try using printf. + echo='printf %s\n' + if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + # Cool, printf works + : + elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` && + test "X$echo_testing_string" = 'X\t' && + echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL + export CONFIG_SHELL + SHELL="$CONFIG_SHELL" + export SHELL + echo="$CONFIG_SHELL $0 --fallback-echo" + elif echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` && + test "X$echo_testing_string" = 'X\t' && + echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + echo="$CONFIG_SHELL $0 --fallback-echo" + else + # maybe with a smaller string... + prev=: + + for cmd in 'echo test' 'sed 2q "$0"' 'sed 10q "$0"' 'sed 20q "$0"' 'sed 50q "$0"'; do + if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null + then + break + fi + prev="$cmd" + done + + if test "$prev" != 'sed 50q "$0"'; then + echo_test_string=`eval $prev` + export echo_test_string + exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "$0" ${1+"$@"} + else + # Oops. We lost completely, so just stick with echo. + echo=echo + fi + fi + fi + fi +fi +fi + +# Copy echo and quote the copy suitably for passing to libtool from +# the Makefile, instead of quoting the original, which is used later. +ECHO=$echo +if test "X$ECHO" = "X$CONFIG_SHELL $0 --fallback-echo"; then + ECHO="$CONFIG_SHELL \\\$\$0 --fallback-echo" +fi + + + + +tagnames=${tagnames+${tagnames},}CXX + +exec 7<&0 </dev/null 6>&1 + +# Name of the host. +# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, +# so uname gets run too. +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +# +# Initializations. +# +ac_default_prefix=/usr/local +ac_clean_files= +ac_config_libobj_dir=. +LIBOBJS= +cross_compiling=no +subdirs= +MFLAGS= +MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} + +# Identity of this package. +PACKAGE_NAME='MP4v2' +PACKAGE_TARNAME='mp4v2' +PACKAGE_VERSION='1.9.1' +PACKAGE_STRING='MP4v2 1.9.1' +PACKAGE_BUGREPORT='eddyg@myreflection.org' + +ac_unique_file="src/mp4.cpp" +# Factoring default headers for most tests. +ac_includes_default="\ +#include <stdio.h> +#ifdef HAVE_SYS_TYPES_H +# include <sys/types.h> +#endif +#ifdef HAVE_SYS_STAT_H +# include <sys/stat.h> +#endif +#ifdef STDC_HEADERS +# include <stdlib.h> +# include <stddef.h> +#else +# ifdef HAVE_STDLIB_H +# include <stdlib.h> +# endif +#endif +#ifdef HAVE_STRING_H +# if !defined STDC_HEADERS && defined HAVE_MEMORY_H +# include <memory.h> +# endif +# include <string.h> +#endif +#ifdef HAVE_STRINGS_H +# include <strings.h> +#endif +#ifdef HAVE_INTTYPES_H +# include <inttypes.h> +#endif +#ifdef HAVE_STDINT_H +# include <stdint.h> +#endif +#ifdef HAVE_UNISTD_H +# include <unistd.h> +#endif" + +ac_subst_vars='LTLIBOBJS +LIBOBJS +X_MINGW_LIBS +X_CXX_I +X_CXX_D +X_CXX_W +X_CXX_ARCH +ADD_MANS_FALSE +ADD_MANS_TRUE +ADD_UTIL_FALSE +ADD_UTIL_TRUE +ADD_PLATFORM_WIN32_FALSE +ADD_PLATFORM_WIN32_TRUE +ADD_PLATFORM_POSIX_FALSE +ADD_PLATFORM_POSIX_TRUE +X_GCH_SHARED_FLAGS +X_GCH_SHARED +X_GCH_STATIC_FLAGS +X_GCH_STATIC +X_GCH_FLAGS +X_GCH +X_libmp4v2_la_LDFLAGS +PROJECT_build +PROJECT_repo_type +PROJECT_repo_date +PROJECT_repo_rev +PROJECT_repo_uuid +PROJECT_repo_root +PROJECT_repo_url +PROJECT_version_point +PROJECT_version_minor +PROJECT_version_major +PROJECT_version_hex +PROJECT_version +PROJECT_bugreport +PROJECT_irc +PROJECT_url_discussion +PROJECT_url_downloads +PROJECT_url_website +PROJECT_name_formal +PROJECT_name_upper +PROJECT_name_lower +PROJECT_name +FOUND_HELP2MAN +LIBTOOL +CXXCPP +CPP +NMEDIT +DSYMUTIL +RANLIB +AR +ECHO +LN_S +EGREP +GREP +SED +am__fastdepCC_FALSE +am__fastdepCC_TRUE +CCDEPMODE +ac_ct_CC +CFLAGS +CC +am__fastdepCXX_FALSE +am__fastdepCXX_TRUE +CXXDEPMODE +AMDEPBACKSLASH +AMDEP_FALSE +AMDEP_TRUE +am__quote +am__include +DEPDIR +OBJEXT +EXEEXT +ac_ct_CXX +CPPFLAGS +LDFLAGS +CXXFLAGS +CXX +host_os +host_vendor +host_cpu +host +build_os +build_vendor +build_cpu +build +am__untar +am__tar +AMTAR +am__leading_dot +SET_MAKE +AWK +mkdir_p +INSTALL_STRIP_PROGRAM +STRIP +install_sh +MAKEINFO +AUTOHEADER +AUTOMAKE +AUTOCONF +ACLOCAL +VERSION +PACKAGE +CYGPATH_W +INSTALL_DATA +INSTALL_SCRIPT +INSTALL_PROGRAM +target_alias +host_alias +build_alias +LIBS +ECHO_T +ECHO_N +ECHO_C +DEFS +mandir +localedir +libdir +psdir +pdfdir +dvidir +htmldir +infodir +docdir +oldincludedir +includedir +localstatedir +sharedstatedir +sysconfdir +datadir +datarootdir +libexecdir +sbindir +bindir +program_transform_name +prefix +exec_prefix +PACKAGE_BUGREPORT +PACKAGE_STRING +PACKAGE_VERSION +PACKAGE_TARNAME +PACKAGE_NAME +PATH_SEPARATOR +SHELL' +ac_subst_files='' +ac_user_opts=' +enable_option_checking +enable_debug +enable_optimize +enable_fvisibility +enable_gch +enable_largefile +enable_util +enable_bi +enable_ub +enable_cygwin_win32 +enable_mingw_mt +enable_dependency_tracking +enable_shared +enable_static +enable_fast_install +with_gnu_ld +enable_libtool_lock +with_pic +with_tags +' + ac_precious_vars='build_alias +host_alias +target_alias +CXX +CXXFLAGS +LDFLAGS +LIBS +CPPFLAGS +CCC +CC +CFLAGS +CPP +CXXCPP' + + +# Initialize some variables set by options. +ac_init_help= +ac_init_version=false +ac_unrecognized_opts= +ac_unrecognized_sep= +# The variables have the same names as the options, with +# dashes changed to underlines. +cache_file=/dev/null +exec_prefix=NONE +no_create= +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +verbose= +x_includes=NONE +x_libraries=NONE + +# Installation directory options. +# These are left unexpanded so users can "make install exec_prefix=/foo" +# and all the variables that are supposed to be based on exec_prefix +# by default will actually change. +# Use braces instead of parens because sh, perl, etc. also accept them. +# (The list follows the same order as the GNU Coding Standards.) +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datarootdir='${prefix}/share' +datadir='${datarootdir}' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +includedir='${prefix}/include' +oldincludedir='/usr/include' +docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' +infodir='${datarootdir}/info' +htmldir='${docdir}' +dvidir='${docdir}' +pdfdir='${docdir}' +psdir='${docdir}' +libdir='${exec_prefix}/lib' +localedir='${datarootdir}/locale' +mandir='${datarootdir}/man' + +ac_prev= +ac_dashdash= +for ac_option +do + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval $ac_prev=\$ac_option + ac_prev= + continue + fi + + case $ac_option in + *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *) ac_optarg=yes ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case $ac_dashdash$ac_option in + --) + ac_dashdash=yes ;; + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir=$ac_optarg ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build_alias ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build_alias=$ac_optarg ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file=$ac_optarg ;; + + --config-cache | -C) + cache_file=config.cache ;; + + -datadir | --datadir | --datadi | --datad) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=*) + datadir=$ac_optarg ;; + + -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ + | --dataroo | --dataro | --datar) + ac_prev=datarootdir ;; + -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ + | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) + datarootdir=$ac_optarg ;; + + -disable-* | --disable-*) + ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + { $as_echo "$as_me: error: invalid feature name: $ac_useropt" >&2 + { (exit 1); exit 1; }; } + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=no ;; + + -docdir | --docdir | --docdi | --doc | --do) + ac_prev=docdir ;; + -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) + docdir=$ac_optarg ;; + + -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) + ac_prev=dvidir ;; + -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) + dvidir=$ac_optarg ;; + + -enable-* | --enable-*) + ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + { $as_echo "$as_me: error: invalid feature name: $ac_useropt" >&2 + { (exit 1); exit 1; }; } + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=\$ac_optarg ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix=$ac_optarg ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he | -h) + ac_init_help=long ;; + -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) + ac_init_help=recursive ;; + -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) + ac_init_help=short ;; + + -host | --host | --hos | --ho) + ac_prev=host_alias ;; + -host=* | --host=* | --hos=* | --ho=*) + host_alias=$ac_optarg ;; + + -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) + ac_prev=htmldir ;; + -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ + | --ht=*) + htmldir=$ac_optarg ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir=$ac_optarg ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir=$ac_optarg ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir=$ac_optarg ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir=$ac_optarg ;; + + -localedir | --localedir | --localedi | --localed | --locale) + ac_prev=localedir ;; + -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) + localedir=$ac_optarg ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst | --locals) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) + localstatedir=$ac_optarg ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir=$ac_optarg ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c | -n) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir=$ac_optarg ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix=$ac_optarg ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix=$ac_optarg ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix=$ac_optarg ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name=$ac_optarg ;; + + -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) + ac_prev=pdfdir ;; + -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) + pdfdir=$ac_optarg ;; + + -psdir | --psdir | --psdi | --psd | --ps) + ac_prev=psdir ;; + -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) + psdir=$ac_optarg ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir=$ac_optarg ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir=$ac_optarg ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site=$ac_optarg ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir=$ac_optarg ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir=$ac_optarg ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target_alias ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target_alias=$ac_optarg ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers | -V) + ac_init_version=: ;; + + -with-* | --with-*) + ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + { $as_echo "$as_me: error: invalid package name: $ac_useropt" >&2 + { (exit 1); exit 1; }; } + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=\$ac_optarg ;; + + -without-* | --without-*) + ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + { $as_echo "$as_me: error: invalid package name: $ac_useropt" >&2 + { (exit 1); exit 1; }; } + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=no ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes=$ac_optarg ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries=$ac_optarg ;; + + -*) { $as_echo "$as_me: error: unrecognized option: $ac_option +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; } + ;; + + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && + { $as_echo "$as_me: error: invalid variable name: $ac_envvar" >&2 + { (exit 1); exit 1; }; } + eval $ac_envvar=\$ac_optarg + export $ac_envvar ;; + + *) + # FIXME: should be removed in autoconf 3.0. + $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} + ;; + + esac +done + +if test -n "$ac_prev"; then + ac_option=--`echo $ac_prev | sed 's/_/-/g'` + { $as_echo "$as_me: error: missing argument to $ac_option" >&2 + { (exit 1); exit 1; }; } +fi + +if test -n "$ac_unrecognized_opts"; then + case $enable_option_checking in + no) ;; + fatal) { $as_echo "$as_me: error: unrecognized options: $ac_unrecognized_opts" >&2 + { (exit 1); exit 1; }; } ;; + *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; + esac +fi + +# Check all directory arguments for consistency. +for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ + datadir sysconfdir sharedstatedir localstatedir includedir \ + oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ + libdir localedir mandir +do + eval ac_val=\$$ac_var + # Remove trailing slashes. + case $ac_val in + */ ) + ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` + eval $ac_var=\$ac_val;; + esac + # Be sure to have absolute directory names. + case $ac_val in + [\\/$]* | ?:[\\/]* ) continue;; + NONE | '' ) case $ac_var in *prefix ) continue;; esac;; + esac + { $as_echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; } +done + +# There might be people who depend on the old broken behavior: `$host' +# used to hold the argument of --host etc. +# FIXME: To remove some day. +build=$build_alias +host=$host_alias +target=$target_alias + +# FIXME: To remove some day. +if test "x$host_alias" != x; then + if test "x$build_alias" = x; then + cross_compiling=maybe + $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. + If a cross compiler is detected then cross compile mode will be used." >&2 + elif test "x$build_alias" != "x$host_alias"; then + cross_compiling=yes + fi +fi + +ac_tool_prefix= +test -n "$host_alias" && ac_tool_prefix=$host_alias- + +test "$silent" = yes && exec 6>/dev/null + + +ac_pwd=`pwd` && test -n "$ac_pwd" && +ac_ls_di=`ls -di .` && +ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || + { $as_echo "$as_me: error: working directory cannot be determined" >&2 + { (exit 1); exit 1; }; } +test "X$ac_ls_di" = "X$ac_pwd_ls_di" || + { $as_echo "$as_me: error: pwd does not report name of working directory" >&2 + { (exit 1); exit 1; }; } + + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then the parent directory. + ac_confdir=`$as_dirname -- "$as_myself" || +$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_myself" : 'X\(//\)[^/]' \| \ + X"$as_myself" : 'X\(//\)$' \| \ + X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_myself" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + srcdir=$ac_confdir + if test ! -r "$srcdir/$ac_unique_file"; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r "$srcdir/$ac_unique_file"; then + test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." + { $as_echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 + { (exit 1); exit 1; }; } +fi +ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" +ac_abs_confdir=`( + cd "$srcdir" && test -r "./$ac_unique_file" || { $as_echo "$as_me: error: $ac_msg" >&2 + { (exit 1); exit 1; }; } + pwd)` +# When building in place, set srcdir=. +if test "$ac_abs_confdir" = "$ac_pwd"; then + srcdir=. +fi +# Remove unnecessary trailing slashes from srcdir. +# Double slashes in file names in object file debugging info +# mess up M-x gdb in Emacs. +case $srcdir in +*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; +esac +for ac_var in $ac_precious_vars; do + eval ac_env_${ac_var}_set=\${${ac_var}+set} + eval ac_env_${ac_var}_value=\$${ac_var} + eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} + eval ac_cv_env_${ac_var}_value=\$${ac_var} +done + +# +# Report the --help message. +# +if test "$ac_init_help" = "long"; then + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat <<_ACEOF +\`configure' configures MP4v2 1.9.1 to adapt to many kinds of systems. + +Usage: $0 [OPTION]... [VAR=VALUE]... + +To assign environment variables (e.g., CC, CFLAGS...), specify them as +VAR=VALUE. See below for descriptions of some of the useful variables. + +Defaults for the options are specified in brackets. + +Configuration: + -h, --help display this help and exit + --help=short display options specific to this package + --help=recursive display the short help of all the included packages + -V, --version display version information and exit + -q, --quiet, --silent do not print \`checking...' messages + --cache-file=FILE cache test results in FILE [disabled] + -C, --config-cache alias for \`--cache-file=config.cache' + -n, --no-create do not create output files + --srcdir=DIR find the sources in DIR [configure dir or \`..'] + +Installation directories: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [PREFIX] + +By default, \`make install' will install all the files in +\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify +an installation prefix other than \`$ac_default_prefix' using \`--prefix', +for instance \`--prefix=\$HOME'. + +For better control, use the options below. + +Fine tuning of the installation directories: + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] + --datadir=DIR read-only architecture-independent data [DATAROOTDIR] + --infodir=DIR info documentation [DATAROOTDIR/info] + --localedir=DIR locale-dependent data [DATAROOTDIR/locale] + --mandir=DIR man documentation [DATAROOTDIR/man] + --docdir=DIR documentation root [DATAROOTDIR/doc/mp4v2] + --htmldir=DIR html documentation [DOCDIR] + --dvidir=DIR dvi documentation [DOCDIR] + --pdfdir=DIR pdf documentation [DOCDIR] + --psdir=DIR ps documentation [DOCDIR] +_ACEOF + + cat <<\_ACEOF + +Program names: + --program-prefix=PREFIX prepend PREFIX to installed program names + --program-suffix=SUFFIX append SUFFIX to installed program names + --program-transform-name=PROGRAM run sed PROGRAM on installed program names + +System types: + --build=BUILD configure for building on BUILD [guessed] + --host=HOST cross-compile to build programs to run on HOST [BUILD] +_ACEOF +fi + +if test -n "$ac_init_help"; then + case $ac_init_help in + short | recursive ) echo "Configuration of MP4v2 1.9.1:";; + esac + cat <<\_ACEOF + +Optional Features: + --disable-option-checking ignore unrecognized --enable/--with options + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --disable-debug disable debugging compilation + --disable-optimize disable optimizing compilation + --disable-fvisibility disable use of -fvisibility + --disable-gch disable GCC precompiled-headers + --disable-largefile disable LFS (large file support) + --disable-util disable build of command-line utilities + --enable-bi=ARCH enable -mARCH for bi-arch compilation + --enable-ub[=ARCHS] enable -arch ARCH for universal-binaries (OSX only) + --enable-cygwin-win32 when building with Cygwin use -mwin32 + --enable-mingw-threads when building with MinGW use -mthreads + --disable-dependency-tracking speeds up one-time build + --enable-dependency-tracking do not reject slow dependency extractors + --enable-shared[=PKGS] build shared libraries [default=yes] + --enable-static[=PKGS] build static libraries [default=yes] + --enable-fast-install[=PKGS] + optimize for fast installation [default=yes] + --disable-libtool-lock avoid locking (might break parallel builds) + +Optional Packages: + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --with-gnu-ld assume the C compiler uses GNU ld [default=no] + --with-pic try to use only PIC/non-PIC objects [default=use + both] + --with-tags[=TAGS] include additional configurations [automatic] + +Some influential environment variables: + CXX C++ compiler command + CXXFLAGS C++ compiler flags + LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a + nonstandard directory <lib dir> + LIBS libraries to pass to the linker, e.g. -l<library> + CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I<include dir> if + you have headers in a nonstandard directory <include dir> + CC C compiler command + CFLAGS C compiler flags + CPP C preprocessor + CXXCPP C++ preprocessor + +Use these variables to override the choices made by `configure' or to help +it to find libraries and programs with nonstandard names/locations. + +Report bugs to <eddyg@myreflection.org>. +_ACEOF +ac_status=$? +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue + test -d "$ac_dir" || + { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || + continue + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + cd "$ac_dir" || { ac_status=$?; continue; } + # Check for guested configure. + if test -f "$ac_srcdir/configure.gnu"; then + echo && + $SHELL "$ac_srcdir/configure.gnu" --help=recursive + elif test -f "$ac_srcdir/configure"; then + echo && + $SHELL "$ac_srcdir/configure" --help=recursive + else + $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi || ac_status=$? + cd "$ac_pwd" || { ac_status=$?; break; } + done +fi + +test -n "$ac_init_help" && exit $ac_status +if $ac_init_version; then + cat <<\_ACEOF +MP4v2 configure 1.9.1 +generated by GNU Autoconf 2.63 + +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, +2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +This configure script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it. +_ACEOF + exit +fi +cat >config.log <<_ACEOF +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by MP4v2 $as_me 1.9.1, which was +generated by GNU Autoconf 2.63. Invocation command line was + + $ $0 $@ + +_ACEOF +exec 5>>config.log +{ +cat <<_ASUNAME +## --------- ## +## Platform. ## +## --------- ## + +hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` + +/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` +/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` +/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` +/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` + +_ASUNAME + +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + $as_echo "PATH: $as_dir" +done +IFS=$as_save_IFS + +} >&5 + +cat >&5 <<_ACEOF + + +## ----------- ## +## Core tests. ## +## ----------- ## + +_ACEOF + + +# Keep a trace of the command line. +# Strip out --no-create and --no-recursion so they do not pile up. +# Strip out --silent because we don't want to record it for future runs. +# Also quote any args containing shell meta-characters. +# Make two passes to allow for proper duplicate-argument suppression. +ac_configure_args= +ac_configure_args0= +ac_configure_args1= +ac_must_keep_next=false +for ac_pass in 1 2 +do + for ac_arg + do + case $ac_arg in + -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + continue ;; + *\'*) + ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + case $ac_pass in + 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; + 2) + ac_configure_args1="$ac_configure_args1 '$ac_arg'" + if test $ac_must_keep_next = true; then + ac_must_keep_next=false # Got value, back to normal. + else + case $ac_arg in + *=* | --config-cache | -C | -disable-* | --disable-* \ + | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ + | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ + | -with-* | --with-* | -without-* | --without-* | --x) + case "$ac_configure_args0 " in + "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; + esac + ;; + -* ) ac_must_keep_next=true ;; + esac + fi + ac_configure_args="$ac_configure_args '$ac_arg'" + ;; + esac + done +done +$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } +$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; } + +# When interrupted or exit'd, cleanup temporary files, and complete +# config.log. We remove comments because anyway the quotes in there +# would cause problems or look ugly. +# WARNING: Use '\'' to represent an apostrophe within the trap. +# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. +trap 'exit_status=$? + # Save into config.log some information that might help in debugging. + { + echo + + cat <<\_ASBOX +## ---------------- ## +## Cache variables. ## +## ---------------- ## +_ASBOX + echo + # The following way of writing the cache mishandles newlines in values, +( + for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:$LINENO: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) $as_unset $ac_var ;; + esac ;; + esac + done + (set) 2>&1 | + case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + sed -n \ + "s/'\''/'\''\\\\'\'''\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" + ;; #( + *) + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) + echo + + cat <<\_ASBOX +## ----------------- ## +## Output variables. ## +## ----------------- ## +_ASBOX + echo + for ac_var in $ac_subst_vars + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" + done | sort + echo + + if test -n "$ac_subst_files"; then + cat <<\_ASBOX +## ------------------- ## +## File substitutions. ## +## ------------------- ## +_ASBOX + echo + for ac_var in $ac_subst_files + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" + done | sort + echo + fi + + if test -s confdefs.h; then + cat <<\_ASBOX +## ----------- ## +## confdefs.h. ## +## ----------- ## +_ASBOX + echo + cat confdefs.h + echo + fi + test "$ac_signal" != 0 && + $as_echo "$as_me: caught signal $ac_signal" + $as_echo "$as_me: exit $exit_status" + } >&5 + rm -f core *.core core.conftest.* && + rm -f -r conftest* confdefs* conf$$* $ac_clean_files && + exit $exit_status +' 0 +for ac_signal in 1 2 13 15; do + trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal +done +ac_signal=0 + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -f -r conftest* confdefs.h + +# Predefined preprocessor variables. + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_NAME "$PACKAGE_NAME" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_TARNAME "$PACKAGE_TARNAME" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_VERSION "$PACKAGE_VERSION" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_STRING "$PACKAGE_STRING" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" +_ACEOF + + +# Let the site file select an alternate cache file if it wants to. +# Prefer an explicitly selected file to automatically selected ones. +ac_site_file1=NONE +ac_site_file2=NONE +if test -n "$CONFIG_SITE"; then + ac_site_file1=$CONFIG_SITE +elif test "x$prefix" != xNONE; then + ac_site_file1=$prefix/share/config.site + ac_site_file2=$prefix/etc/config.site +else + ac_site_file1=$ac_default_prefix/share/config.site + ac_site_file2=$ac_default_prefix/etc/config.site +fi +for ac_site_file in "$ac_site_file1" "$ac_site_file2" +do + test "x$ac_site_file" = xNONE && continue + if test -r "$ac_site_file"; then + { $as_echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 +$as_echo "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 + . "$ac_site_file" + fi +done + +if test -r "$cache_file"; then + # Some versions of bash will fail to source /dev/null (special + # files actually), so we avoid doing that. + if test -f "$cache_file"; then + { $as_echo "$as_me:$LINENO: loading cache $cache_file" >&5 +$as_echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . "$cache_file";; + *) . "./$cache_file";; + esac + fi +else + { $as_echo "$as_me:$LINENO: creating cache $cache_file" >&5 +$as_echo "$as_me: creating cache $cache_file" >&6;} + >$cache_file +fi + +# Check that the precious variables saved in the cache have kept the same +# value. +ac_cache_corrupted=false +for ac_var in $ac_precious_vars; do + eval ac_old_set=\$ac_cv_env_${ac_var}_set + eval ac_new_set=\$ac_env_${ac_var}_set + eval ac_old_val=\$ac_cv_env_${ac_var}_value + eval ac_new_val=\$ac_env_${ac_var}_value + case $ac_old_set,$ac_new_set in + set,) + { $as_echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { $as_echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,);; + *) + if test "x$ac_old_val" != "x$ac_new_val"; then + # differences in whitespace do not lead to failure. + ac_old_val_w=`echo x $ac_old_val` + ac_new_val_w=`echo x $ac_new_val` + if test "$ac_old_val_w" != "$ac_new_val_w"; then + { $as_echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 +$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + ac_cache_corrupted=: + else + { $as_echo "$as_me:$LINENO: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 +$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} + eval $ac_var=\$ac_old_val + fi + { $as_echo "$as_me:$LINENO: former value: \`$ac_old_val'" >&5 +$as_echo "$as_me: former value: \`$ac_old_val'" >&2;} + { $as_echo "$as_me:$LINENO: current value: \`$ac_new_val'" >&5 +$as_echo "$as_me: current value: \`$ac_new_val'" >&2;} + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *) ac_arg=$ac_var=$ac_new_val ;; + esac + case " $ac_configure_args " in + *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. + *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; + esac + fi +done +if $ac_cache_corrupted; then + { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} + { $as_echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 +$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} + { { $as_echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 +$as_echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} + { (exit 1); exit 1; }; } +fi + + + + + + + + + + + + + + + + + + + + + + + + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + +{ $as_echo "$as_me:$LINENO: + --> + --> Configuring MP4v2 1.9.1 + -->" >&5 +$as_echo "$as_me: + --> + --> Configuring MP4v2 1.9.1 + -->" >&6;} + +ac_aux_dir= +for ac_dir in autoaux "$srcdir"/autoaux; do + if test -f "$ac_dir/install-sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f "$ac_dir/install.sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + elif test -f "$ac_dir/shtool"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/shtool install -c" + break + fi +done +if test -z "$ac_aux_dir"; then + { { $as_echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in autoaux \"$srcdir\"/autoaux" >&5 +$as_echo "$as_me: error: cannot find install-sh or install.sh in autoaux \"$srcdir\"/autoaux" >&2;} + { (exit 1); exit 1; }; } +fi + +# These three variables are undocumented and unsupported, +# and are intended to be withdrawn in a future Autoconf release. +# They can cause serious problems if a builder's source tree is in a directory +# whose full name contains unusual characters. +ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. +ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. +ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. + + +am__api_version="1.9" +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AmigaOS /C/install, which installs bootblocks on floppy discs +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# OS/2's system install, which has a completely different semantic +# ./install, which can be erroneously created by make from ./install.sh. +# Reject install programs that cannot install multiple files. +{ $as_echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 +$as_echo_n "checking for a BSD-compatible install... " >&6; } +if test -z "$INSTALL"; then +if test "${ac_cv_path_install+set}" = set; then + $as_echo_n "(cached) " >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in + ./ | .// | /cC/* | \ + /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ + ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ + /usr/ucb/* ) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then + if test $ac_prog = install && + grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + rm -rf conftest.one conftest.two conftest.dir + echo one > conftest.one + echo two > conftest.two + mkdir conftest.dir + if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && + test -s conftest.one && test -s conftest.two && + test -s conftest.dir/conftest.one && + test -s conftest.dir/conftest.two + then + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi + fi + fi + done + done + ;; +esac + +done +IFS=$as_save_IFS + +rm -rf conftest.one conftest.two conftest.dir + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL=$ac_cv_path_install + else + # As a last resort, use the slow shell script. Don't cache a + # value for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the value is a relative name. + INSTALL=$ac_install_sh + fi +fi +{ $as_echo "$as_me:$LINENO: result: $INSTALL" >&5 +$as_echo "$INSTALL" >&6; } + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +{ $as_echo "$as_me:$LINENO: checking whether build environment is sane" >&5 +$as_echo_n "checking whether build environment is sane... " >&6; } +# Just in case +sleep 1 +echo timestamp > conftest.file +# Do `set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null` + if test "$*" = "X"; then + # -L didn't work. + set X `ls -t $srcdir/configure conftest.file` + fi + rm -f conftest.file + if test "$*" != "X $srcdir/configure conftest.file" \ + && test "$*" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + { { $as_echo "$as_me:$LINENO: error: ls -t appears to fail. Make sure there is not a broken +alias in your environment" >&5 +$as_echo "$as_me: error: ls -t appears to fail. Make sure there is not a broken +alias in your environment" >&2;} + { (exit 1); exit 1; }; } + fi + + test "$2" = conftest.file + ) +then + # Ok. + : +else + { { $as_echo "$as_me:$LINENO: error: newly created file is older than distributed files! +Check your system clock" >&5 +$as_echo "$as_me: error: newly created file is older than distributed files! +Check your system clock" >&2;} + { (exit 1); exit 1; }; } +fi +{ $as_echo "$as_me:$LINENO: result: yes" >&5 +$as_echo "yes" >&6; } +test "$program_prefix" != NONE && + program_transform_name="s&^&$program_prefix&;$program_transform_name" +# Use a double $ so make ignores it. +test "$program_suffix" != NONE && + program_transform_name="s&\$&$program_suffix&;$program_transform_name" +# Double any \ or $. +# By default was `s,x,x', remove it if useless. +ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' +program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` + +# expand $ac_aux_dir to an absolute path +am_aux_dir=`cd $ac_aux_dir && pwd` + +test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" +# Use eval to expand $SHELL +if eval "$MISSING --run true"; then + am_missing_run="$MISSING --run " +else + am_missing_run= + { $as_echo "$as_me:$LINENO: WARNING: \`missing' script is too old or missing" >&5 +$as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} +fi + +if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then + # We used to keeping the `.' as first argument, in order to + # allow $(mkdir_p) to be used without argument. As in + # $(mkdir_p) $(somedir) + # where $(somedir) is conditionally defined. However this is wrong + # for two reasons: + # 1. if the package is installed by a user who cannot write `.' + # make install will fail, + # 2. the above comment should most certainly read + # $(mkdir_p) $(DESTDIR)$(somedir) + # so it does not work when $(somedir) is undefined and + # $(DESTDIR) is not. + # To support the latter case, we have to write + # test -z "$(somedir)" || $(mkdir_p) $(DESTDIR)$(somedir), + # so the `.' trick is pointless. + mkdir_p='mkdir -p --' +else + # On NextStep and OpenStep, the `mkdir' command does not + # recognize any option. It will interpret all options as + # directories to create, and then abort because `.' already + # exists. + for d in ./-p ./--version; + do + test -d $d && rmdir $d + done + # $(mkinstalldirs) is defined by Automake if mkinstalldirs exists. + if test -f "$ac_aux_dir/mkinstalldirs"; then + mkdir_p='$(mkinstalldirs)' + else + mkdir_p='$(install_sh) -d' + fi +fi + +for ac_prog in gawk mawk nawk awk +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_AWK+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$AWK"; then + ac_cv_prog_AWK="$AWK" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_AWK="$ac_prog" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +AWK=$ac_cv_prog_AWK +if test -n "$AWK"; then + { $as_echo "$as_me:$LINENO: result: $AWK" >&5 +$as_echo "$AWK" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$AWK" && break +done + +{ $as_echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 +$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } +set x ${MAKE-make} +ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` +if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.make <<\_ACEOF +SHELL = /bin/sh +all: + @echo '@@@%%%=$(MAKE)=@@@%%%' +_ACEOF +# GNU make sometimes prints "make[1]: Entering...", which would confuse us. +case `${MAKE-make} -f conftest.make 2>/dev/null` in + *@@@%%%=?*=@@@%%%*) + eval ac_cv_prog_make_${ac_make}_set=yes;; + *) + eval ac_cv_prog_make_${ac_make}_set=no;; +esac +rm -f conftest.make +fi +if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then + { $as_echo "$as_me:$LINENO: result: yes" >&5 +$as_echo "yes" >&6; } + SET_MAKE= +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } + SET_MAKE="MAKE=${MAKE-make}" +fi + +rm -rf .tst 2>/dev/null +mkdir .tst 2>/dev/null +if test -d .tst; then + am__leading_dot=. +else + am__leading_dot=_ +fi +rmdir .tst 2>/dev/null + +# test to see if srcdir already configured +if test "`cd $srcdir && pwd`" != "`pwd`" && + test -f $srcdir/config.status; then + { { $as_echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5 +$as_echo "$as_me: error: source directory already configured; run \"make distclean\" there first" >&2;} + { (exit 1); exit 1; }; } +fi + +# test whether we have cygpath +if test -z "$CYGPATH_W"; then + if (cygpath --version) >/dev/null 2>/dev/null; then + CYGPATH_W='cygpath -w' + else + CYGPATH_W=echo + fi +fi + + +# Define the identity of the package. + PACKAGE='mp4v2' + VERSION='1.9.1' + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE "$PACKAGE" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define VERSION "$VERSION" +_ACEOF + +# Some tools Automake needs. + +ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} + + +AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} + + +AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} + + +AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} + + +MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} + +install_sh=${install_sh-"$am_aux_dir/install-sh"} + +# Installed binaries are usually stripped using `strip' when the user +# run `make install-strip'. However `strip' might not be the right +# tool to use in cross-compilation environments, therefore Automake +# will honor the `STRIP' environment variable to overrule this program. +if test "$cross_compiling" != no; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. +set dummy ${ac_tool_prefix}strip; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_STRIP+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$STRIP"; then + ac_cv_prog_STRIP="$STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_STRIP="${ac_tool_prefix}strip" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +STRIP=$ac_cv_prog_STRIP +if test -n "$STRIP"; then + { $as_echo "$as_me:$LINENO: result: $STRIP" >&5 +$as_echo "$STRIP" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_STRIP"; then + ac_ct_STRIP=$STRIP + # Extract the first word of "strip", so it can be a program name with args. +set dummy strip; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_STRIP"; then + ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_STRIP="strip" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP +if test -n "$ac_ct_STRIP"; then + { $as_echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5 +$as_echo "$ac_ct_STRIP" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_STRIP" = x; then + STRIP=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + STRIP=$ac_ct_STRIP + fi +else + STRIP="$ac_cv_prog_STRIP" +fi + +fi +INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s" + +# We need awk for the "check" target. The system "awk" is bad on +# some platforms. +# Always define AMTAR for backward compatibility. + +AMTAR=${AMTAR-"${am_missing_run}tar"} + +am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -' + + + + + + + + +# disable unused langs (improves config speed, reduces configure file size) + + + + +# Make sure we can run config.sub. +$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || + { { $as_echo "$as_me:$LINENO: error: cannot run $SHELL $ac_aux_dir/config.sub" >&5 +$as_echo "$as_me: error: cannot run $SHELL $ac_aux_dir/config.sub" >&2;} + { (exit 1); exit 1; }; } + +{ $as_echo "$as_me:$LINENO: checking build system type" >&5 +$as_echo_n "checking build system type... " >&6; } +if test "${ac_cv_build+set}" = set; then + $as_echo_n "(cached) " >&6 +else + ac_build_alias=$build_alias +test "x$ac_build_alias" = x && + ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` +test "x$ac_build_alias" = x && + { { $as_echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5 +$as_echo "$as_me: error: cannot guess build type; you must specify one" >&2;} + { (exit 1); exit 1; }; } +ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || + { { $as_echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&5 +$as_echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&2;} + { (exit 1); exit 1; }; } + +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_build" >&5 +$as_echo "$ac_cv_build" >&6; } +case $ac_cv_build in +*-*-*) ;; +*) { { $as_echo "$as_me:$LINENO: error: invalid value of canonical build" >&5 +$as_echo "$as_me: error: invalid value of canonical build" >&2;} + { (exit 1); exit 1; }; };; +esac +build=$ac_cv_build +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_build +shift +build_cpu=$1 +build_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +build_os=$* +IFS=$ac_save_IFS +case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac + + +{ $as_echo "$as_me:$LINENO: checking host system type" >&5 +$as_echo_n "checking host system type... " >&6; } +if test "${ac_cv_host+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test "x$host_alias" = x; then + ac_cv_host=$ac_cv_build +else + ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || + { { $as_echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&5 +$as_echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&2;} + { (exit 1); exit 1; }; } +fi + +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_host" >&5 +$as_echo "$ac_cv_host" >&6; } +case $ac_cv_host in +*-*-*) ;; +*) { { $as_echo "$as_me:$LINENO: error: invalid value of canonical host" >&5 +$as_echo "$as_me: error: invalid value of canonical host" >&2;} + { (exit 1); exit 1; }; };; +esac +host=$ac_cv_host +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_host +shift +host_cpu=$1 +host_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +host_os=$* +IFS=$ac_save_IFS +case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac + + + +############################################################################### +# add configure options +############################################################################### + +if test -z "$enable_dependency_tracking"; then + enable_dependency_tracking=no +fi + +# Check whether --enable-debug was given. +if test "${enable_debug+set}" = set; then + enableval=$enable_debug; +fi + +# Check whether --enable-optimize was given. +if test "${enable_optimize+set}" = set; then + enableval=$enable_optimize; +fi + +# Check whether --enable-fvisibility was given. +if test "${enable_fvisibility+set}" = set; then + enableval=$enable_fvisibility; +fi + +# Check whether --enable-gch was given. +if test "${enable_gch+set}" = set; then + enableval=$enable_gch; +fi + +# Check whether --enable-largefile was given. +if test "${enable_largefile+set}" = set; then + enableval=$enable_largefile; +fi + +# Check whether --enable-util was given. +if test "${enable_util+set}" = set; then + enableval=$enable_util; +fi + +# Check whether --enable-bi was given. +if test "${enable_bi+set}" = set; then + enableval=$enable_bi; +fi + +# Check whether --enable-ub was given. +if test "${enable_ub+set}" = set; then + enableval=$enable_ub; +fi + +# Check whether --enable-cygwin_win32 was given. +if test "${enable_cygwin_win32+set}" = set; then + enableval=$enable_cygwin_win32; +fi + +# Check whether --enable-mingw_mt was given. +if test "${enable_mingw_mt+set}" = set; then + enableval=$enable_mingw_mt; +fi + + +############################################################################### +# checks for programs +############################################################################### + +ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu +if test -z "$CXX"; then + if test -n "$CCC"; then + CXX=$CCC + else + if test -n "$ac_tool_prefix"; then + for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_CXX+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$CXX"; then + ac_cv_prog_CXX="$CXX" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +CXX=$ac_cv_prog_CXX +if test -n "$CXX"; then + { $as_echo "$as_me:$LINENO: result: $CXX" >&5 +$as_echo "$CXX" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$CXX" && break + done +fi +if test -z "$CXX"; then + ac_ct_CXX=$CXX + for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CXX"; then + ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CXX="$ac_prog" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_CXX=$ac_cv_prog_ac_ct_CXX +if test -n "$ac_ct_CXX"; then + { $as_echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5 +$as_echo "$ac_ct_CXX" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_CXX" && break +done + + if test "x$ac_ct_CXX" = x; then + CXX="g++" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CXX=$ac_ct_CXX + fi +fi + + fi +fi +# Provide some information about the compiler. +$as_echo "$as_me:$LINENO: checking for C++ compiler version" >&5 +set X $ac_compile +ac_compiler=$2 +{ (ac_try="$ac_compiler --version >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compiler --version >&5") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (ac_try="$ac_compiler -v >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compiler -v >&5") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (ac_try="$ac_compiler -V >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compiler -V >&5") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" +# Try to create an executable without -o first, disregard a.out. +# It will help us diagnose broken compilers, and finding out an intuition +# of exeext. +{ $as_echo "$as_me:$LINENO: checking for C++ compiler default output file name" >&5 +$as_echo_n "checking for C++ compiler default output file name... " >&6; } +ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` + +# The possible output files: +ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" + +ac_rmfiles= +for ac_file in $ac_files +do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + * ) ac_rmfiles="$ac_rmfiles $ac_file";; + esac +done +rm -f $ac_rmfiles + +if { (ac_try="$ac_link_default" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link_default") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. +# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' +# in a Makefile. We should not override ac_cv_exeext if it was cached, +# so that the user can short-circuit this test for compilers unknown to +# Autoconf. +for ac_file in $ac_files '' +do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) + ;; + [ab].out ) + # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) + if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; + then :; else + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + fi + # We set ac_cv_exeext here because the later test for it is not + # safe: cross compilers may not add the suffix if given an `-o' + # argument, so we may need to know it at that point already. + # Even if this section looks crufty: it has the advantage of + # actually working. + break;; + * ) + break;; + esac +done +test "$ac_cv_exeext" = no && ac_cv_exeext= + +else + ac_file='' +fi + +{ $as_echo "$as_me:$LINENO: result: $ac_file" >&5 +$as_echo "$ac_file" >&6; } +if test -z "$ac_file"; then + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ { $as_echo "$as_me:$LINENO: error: C++ compiler cannot create executables +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: C++ compiler cannot create executables +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; }; } +fi + +ac_exeext=$ac_cv_exeext + +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ $as_echo "$as_me:$LINENO: checking whether the C++ compiler works" >&5 +$as_echo_n "checking whether the C++ compiler works... " >&6; } +# FIXME: These cross compiler hacks should be removed for Autoconf 3.0 +# If not cross compiling, check that we can run a simple program. +if test "$cross_compiling" != yes; then + if { ac_try='./$ac_file' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ { $as_echo "$as_me:$LINENO: error: cannot run C++ compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: cannot run C++ compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; }; } + fi + fi +fi +{ $as_echo "$as_me:$LINENO: result: yes" >&5 +$as_echo "yes" >&6; } + +rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out +ac_clean_files=$ac_clean_files_save +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ $as_echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 +$as_echo_n "checking whether we are cross compiling... " >&6; } +{ $as_echo "$as_me:$LINENO: result: $cross_compiling" >&5 +$as_echo "$cross_compiling" >&6; } + +{ $as_echo "$as_me:$LINENO: checking for suffix of executables" >&5 +$as_echo_n "checking for suffix of executables... " >&6; } +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # If both `conftest.exe' and `conftest' are `present' (well, observable) +# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will +# work properly (i.e., refer to `conftest.exe'), while it won't with +# `rm'. +for ac_file in conftest.exe conftest conftest.*; do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + break;; + * ) break;; + esac +done +else + { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ { $as_echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; }; } +fi + +rm -f conftest$ac_cv_exeext +{ $as_echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 +$as_echo "$ac_cv_exeext" >&6; } + +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +{ $as_echo "$as_me:$LINENO: checking for suffix of object files" >&5 +$as_echo_n "checking for suffix of object files... " >&6; } +if test "${ac_cv_objext+set}" = set; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + for ac_file in conftest.o conftest.obj conftest.*; do + test -f "$ac_file" || continue; + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ { $as_echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; }; } +fi + +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 +$as_echo "$ac_cv_objext" >&6; } +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +{ $as_echo "$as_me:$LINENO: checking whether we are using the GNU C++ compiler" >&5 +$as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } +if test "${ac_cv_cxx_compiler_gnu+set}" = set; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_compiler_gnu=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_compiler_gnu=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_cxx_compiler_gnu=$ac_compiler_gnu + +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_cxx_compiler_gnu" >&5 +$as_echo "$ac_cv_cxx_compiler_gnu" >&6; } +if test $ac_compiler_gnu = yes; then + GXX=yes +else + GXX= +fi +ac_test_CXXFLAGS=${CXXFLAGS+set} +ac_save_CXXFLAGS=$CXXFLAGS +{ $as_echo "$as_me:$LINENO: checking whether $CXX accepts -g" >&5 +$as_echo_n "checking whether $CXX accepts -g... " >&6; } +if test "${ac_cv_prog_cxx_g+set}" = set; then + $as_echo_n "(cached) " >&6 +else + ac_save_cxx_werror_flag=$ac_cxx_werror_flag + ac_cxx_werror_flag=yes + ac_cv_prog_cxx_g=no + CXXFLAGS="-g" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cxx_g=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + CXXFLAGS="" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + : +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cxx_werror_flag=$ac_save_cxx_werror_flag + CXXFLAGS="-g" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cxx_g=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_cxx_werror_flag=$ac_save_cxx_werror_flag +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cxx_g" >&5 +$as_echo "$ac_cv_prog_cxx_g" >&6; } +if test "$ac_test_CXXFLAGS" = set; then + CXXFLAGS=$ac_save_CXXFLAGS +elif test $ac_cv_prog_cxx_g = yes; then + if test "$GXX" = yes; then + CXXFLAGS="-g -O2" + else + CXXFLAGS="-g" + fi +else + if test "$GXX" = yes; then + CXXFLAGS="-O2" + else + CXXFLAGS= + fi +fi +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +DEPDIR="${am__leading_dot}deps" + +ac_config_commands="$ac_config_commands depfiles" + + +am_make=${MAKE-make} +cat > confinc << 'END' +am__doit: + @echo done +.PHONY: am__doit +END +# If we don't find an include directive, just comment out the code. +{ $as_echo "$as_me:$LINENO: checking for style of include used by $am_make" >&5 +$as_echo_n "checking for style of include used by $am_make... " >&6; } +am__include="#" +am__quote= +_am_result=none +# First try GNU make style include. +echo "include confinc" > confmf +# We grep out `Entering directory' and `Leaving directory' +# messages which can occur if `w' ends up in MAKEFLAGS. +# In particular we don't look at `^make:' because GNU make might +# be invoked under some other name (usually "gmake"), in which +# case it prints its new name instead of `make'. +if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then + am__include=include + am__quote= + _am_result=GNU +fi +# Now try BSD make style include. +if test "$am__include" = "#"; then + echo '.include "confinc"' > confmf + if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then + am__include=.include + am__quote="\"" + _am_result=BSD + fi +fi + + +{ $as_echo "$as_me:$LINENO: result: $_am_result" >&5 +$as_echo "$_am_result" >&6; } +rm -f confinc confmf + +# Check whether --enable-dependency-tracking was given. +if test "${enable_dependency_tracking+set}" = set; then + enableval=$enable_dependency_tracking; +fi + +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' +fi + + +if test "x$enable_dependency_tracking" != xno; then + AMDEP_TRUE= + AMDEP_FALSE='#' +else + AMDEP_TRUE='#' + AMDEP_FALSE= +fi + + + + +depcc="$CXX" am_compiler_list= + +{ $as_echo "$as_me:$LINENO: checking dependency style of $depcc" >&5 +$as_echo_n "checking dependency style of $depcc... " >&6; } +if test "${am_cv_CXX_dependencies_compiler_type+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_CXX_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` + fi + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with + # Solaris 8's {/usr,}/bin/sh. + touch sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + case $depmode in + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + none) break ;; + esac + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. + if depmode=$depmode \ + source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_CXX_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_CXX_dependencies_compiler_type=none +fi + +fi +{ $as_echo "$as_me:$LINENO: result: $am_cv_CXX_dependencies_compiler_type" >&5 +$as_echo "$am_cv_CXX_dependencies_compiler_type" >&6; } +CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type + + + +if + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then + am__fastdepCXX_TRUE= + am__fastdepCXX_FALSE='#' +else + am__fastdepCXX_TRUE='#' + am__fastdepCXX_FALSE= +fi + + +# Check whether --enable-shared was given. +if test "${enable_shared+set}" = set; then + enableval=$enable_shared; p=${PACKAGE-default} + case $enableval in + yes) enable_shared=yes ;; + no) enable_shared=no ;; + *) + enable_shared=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_shared=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac +else + enable_shared=yes +fi + + +# Check whether --enable-static was given. +if test "${enable_static+set}" = set; then + enableval=$enable_static; p=${PACKAGE-default} + case $enableval in + yes) enable_static=yes ;; + no) enable_static=no ;; + *) + enable_static=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_static=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac +else + enable_static=yes +fi + + +# Check whether --enable-fast-install was given. +if test "${enable_fast_install+set}" = set; then + enableval=$enable_fast_install; p=${PACKAGE-default} + case $enableval in + yes) enable_fast_install=yes ;; + no) enable_fast_install=no ;; + *) + enable_fast_install=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_fast_install=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac +else + enable_fast_install=yes +fi + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:$LINENO: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CC="gcc" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:$LINENO: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + + fi +fi +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# != 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:$LINENO: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl.exe + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:$LINENO: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl.exe +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CC="$ac_prog" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_CC" && break +done + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +fi + +fi + + +test -z "$CC" && { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ { $as_echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; }; } + +# Provide some information about the compiler. +$as_echo "$as_me:$LINENO: checking for C compiler version" >&5 +set X $ac_compile +ac_compiler=$2 +{ (ac_try="$ac_compiler --version >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compiler --version >&5") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (ac_try="$ac_compiler -v >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compiler -v >&5") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (ac_try="$ac_compiler -V >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compiler -V >&5") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + +{ $as_echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 +$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } +if test "${ac_cv_c_compiler_gnu+set}" = set; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_compiler_gnu=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_compiler_gnu=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 +$as_echo "$ac_cv_c_compiler_gnu" >&6; } +if test $ac_compiler_gnu = yes; then + GCC=yes +else + GCC= +fi +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +{ $as_echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 +$as_echo_n "checking whether $CC accepts -g... " >&6; } +if test "${ac_cv_prog_cc_g+set}" = set; then + $as_echo_n "(cached) " >&6 +else + ac_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + ac_cv_prog_cc_g=no + CFLAGS="-g" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cc_g=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + CFLAGS="" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + : +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS="-g" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cc_g=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag=$ac_save_c_werror_flag +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 +$as_echo "$ac_cv_prog_cc_g" >&6; } +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +{ $as_echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5 +$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } +if test "${ac_cv_prog_cc_c89+set}" = set; then + $as_echo_n "(cached) " >&6 +else + ac_cv_prog_cc_c89=no +ac_save_CC=$CC +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <stdarg.h> +#include <stdio.h> +#include <sys/types.h> +#include <sys/stat.h> +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) 'x' +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cc_c89=$ac_arg +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC + +fi +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c89" in + x) + { $as_echo "$as_me:$LINENO: result: none needed" >&5 +$as_echo "none needed" >&6; } ;; + xno) + { $as_echo "$as_me:$LINENO: result: unsupported" >&5 +$as_echo "unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c89" + { $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5 +$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; +esac + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +depcc="$CC" am_compiler_list= + +{ $as_echo "$as_me:$LINENO: checking dependency style of $depcc" >&5 +$as_echo_n "checking dependency style of $depcc... " >&6; } +if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_CC_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` + fi + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with + # Solaris 8's {/usr,}/bin/sh. + touch sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + case $depmode in + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + none) break ;; + esac + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. + if depmode=$depmode \ + source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_CC_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_CC_dependencies_compiler_type=none +fi + +fi +{ $as_echo "$as_me:$LINENO: result: $am_cv_CC_dependencies_compiler_type" >&5 +$as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } +CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type + + + +if + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then + am__fastdepCC_TRUE= + am__fastdepCC_FALSE='#' +else + am__fastdepCC_TRUE='#' + am__fastdepCC_FALSE= +fi + + +{ $as_echo "$as_me:$LINENO: checking for a sed that does not truncate output" >&5 +$as_echo_n "checking for a sed that does not truncate output... " >&6; } +if test "${lt_cv_path_SED+set}" = set; then + $as_echo_n "(cached) " >&6 +else + # Loop through the user's path and test for sed and gsed. +# Then use that list of sed's as ones to test for truncation. +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for lt_ac_prog in sed gsed; do + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$lt_ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$lt_ac_prog$ac_exec_ext"; }; then + lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" + fi + done + done +done +IFS=$as_save_IFS +lt_ac_max=0 +lt_ac_count=0 +# Add /usr/xpg4/bin/sed as it is typically found on Solaris +# along with /bin/sed that truncates output. +for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do + test ! -f $lt_ac_sed && continue + cat /dev/null > conftest.in + lt_ac_count=0 + echo $ECHO_N "0123456789$ECHO_C" >conftest.in + # Check for GNU sed and select it if it is found. + if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then + lt_cv_path_SED=$lt_ac_sed + break + fi + while true; do + cat conftest.in conftest.in >conftest.tmp + mv conftest.tmp conftest.in + cp conftest.in conftest.nl + echo >>conftest.nl + $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break + cmp -s conftest.out conftest.nl || break + # 10000 chars as input seems more than enough + test $lt_ac_count -gt 10 && break + lt_ac_count=`expr $lt_ac_count + 1` + if test $lt_ac_count -gt $lt_ac_max; then + lt_ac_max=$lt_ac_count + lt_cv_path_SED=$lt_ac_sed + fi + done +done + +fi + +SED=$lt_cv_path_SED + +{ $as_echo "$as_me:$LINENO: result: $SED" >&5 +$as_echo "$SED" >&6; } + +{ $as_echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5 +$as_echo_n "checking for grep that handles long lines and -e... " >&6; } +if test "${ac_cv_path_GREP+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -z "$GREP"; then + ac_path_GREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in grep ggrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue +# Check for GNU ac_path_GREP and select it if it is found. + # Check for GNU $ac_path_GREP +case `"$ac_path_GREP" --version 2>&1` in +*GNU*) + ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'GREP' >> "conftest.nl" + "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + ac_count=`expr $ac_count + 1` + if test $ac_count -gt ${ac_path_GREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_GREP="$ac_path_GREP" + ac_path_GREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_GREP_found && break 3 + done + done +done +IFS=$as_save_IFS + if test -z "$ac_cv_path_GREP"; then + { { $as_echo "$as_me:$LINENO: error: no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 +$as_echo "$as_me: error: no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} + { (exit 1); exit 1; }; } + fi +else + ac_cv_path_GREP=$GREP +fi + +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5 +$as_echo "$ac_cv_path_GREP" >&6; } + GREP="$ac_cv_path_GREP" + + +{ $as_echo "$as_me:$LINENO: checking for egrep" >&5 +$as_echo_n "checking for egrep... " >&6; } +if test "${ac_cv_path_EGREP+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 + then ac_cv_path_EGREP="$GREP -E" + else + if test -z "$EGREP"; then + ac_path_EGREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in egrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue +# Check for GNU ac_path_EGREP and select it if it is found. + # Check for GNU $ac_path_EGREP +case `"$ac_path_EGREP" --version 2>&1` in +*GNU*) + ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'EGREP' >> "conftest.nl" + "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + ac_count=`expr $ac_count + 1` + if test $ac_count -gt ${ac_path_EGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_EGREP="$ac_path_EGREP" + ac_path_EGREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_EGREP_found && break 3 + done + done +done +IFS=$as_save_IFS + if test -z "$ac_cv_path_EGREP"; then + { { $as_echo "$as_me:$LINENO: error: no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 +$as_echo "$as_me: error: no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} + { (exit 1); exit 1; }; } + fi +else + ac_cv_path_EGREP=$EGREP +fi + + fi +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5 +$as_echo "$ac_cv_path_EGREP" >&6; } + EGREP="$ac_cv_path_EGREP" + + + +# Check whether --with-gnu-ld was given. +if test "${with_gnu_ld+set}" = set; then + withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes +else + with_gnu_ld=no +fi + +ac_prog=ld +if test "$GCC" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + { $as_echo "$as_me:$LINENO: checking for ld used by $CC" >&5 +$as_echo_n "checking for ld used by $CC... " >&6; } + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return which upsets mingw + ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $ac_prog in + # Accept absolute paths. + [\\/]* | ?:[\\/]*) + re_direlt='/[^/][^/]*/\.\./' + # Canonicalize the pathname of ld + ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'` + while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do + ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test "$with_gnu_ld" = yes; then + { $as_echo "$as_me:$LINENO: checking for GNU ld" >&5 +$as_echo_n "checking for GNU ld... " >&6; } +else + { $as_echo "$as_me:$LINENO: checking for non-GNU ld" >&5 +$as_echo_n "checking for non-GNU ld... " >&6; } +fi +if test "${lt_cv_path_LD+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -z "$LD"; then + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + lt_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some variants of GNU ld only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in + *GNU* | *'with BFD'*) + test "$with_gnu_ld" != no && break + ;; + *) + test "$with_gnu_ld" != yes && break + ;; + esac + fi + done + IFS="$lt_save_ifs" +else + lt_cv_path_LD="$LD" # Let the user override the test with a path. +fi +fi + +LD="$lt_cv_path_LD" +if test -n "$LD"; then + { $as_echo "$as_me:$LINENO: result: $LD" >&5 +$as_echo "$LD" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi +test -z "$LD" && { { $as_echo "$as_me:$LINENO: error: no acceptable ld found in \$PATH" >&5 +$as_echo "$as_me: error: no acceptable ld found in \$PATH" >&2;} + { (exit 1); exit 1; }; } +{ $as_echo "$as_me:$LINENO: checking if the linker ($LD) is GNU ld" >&5 +$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } +if test "${lt_cv_prog_gnu_ld+set}" = set; then + $as_echo_n "(cached) " >&6 +else + # I'd rather use --version here, but apparently some GNU lds only accept -v. +case `$LD -v 2>&1 </dev/null` in +*GNU* | *'with BFD'*) + lt_cv_prog_gnu_ld=yes + ;; +*) + lt_cv_prog_gnu_ld=no + ;; +esac +fi +{ $as_echo "$as_me:$LINENO: result: $lt_cv_prog_gnu_ld" >&5 +$as_echo "$lt_cv_prog_gnu_ld" >&6; } +with_gnu_ld=$lt_cv_prog_gnu_ld + + +{ $as_echo "$as_me:$LINENO: checking for $LD option to reload object files" >&5 +$as_echo_n "checking for $LD option to reload object files... " >&6; } +if test "${lt_cv_ld_reload_flag+set}" = set; then + $as_echo_n "(cached) " >&6 +else + lt_cv_ld_reload_flag='-r' +fi +{ $as_echo "$as_me:$LINENO: result: $lt_cv_ld_reload_flag" >&5 +$as_echo "$lt_cv_ld_reload_flag" >&6; } +reload_flag=$lt_cv_ld_reload_flag +case $reload_flag in +"" | " "*) ;; +*) reload_flag=" $reload_flag" ;; +esac +reload_cmds='$LD$reload_flag -o $output$reload_objs' +case $host_os in + darwin*) + if test "$GCC" = yes; then + reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs' + else + reload_cmds='$LD$reload_flag -o $output$reload_objs' + fi + ;; +esac + +{ $as_echo "$as_me:$LINENO: checking for BSD-compatible nm" >&5 +$as_echo_n "checking for BSD-compatible nm... " >&6; } +if test "${lt_cv_path_NM+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$NM"; then + # Let the user override the test. + lt_cv_path_NM="$NM" +else + lt_nm_to_check="${ac_tool_prefix}nm" + if test -n "$ac_tool_prefix" && test "$build" = "$host"; then + lt_nm_to_check="$lt_nm_to_check nm" + fi + for lt_tmp_nm in $lt_nm_to_check; do + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + tmp_nm="$ac_dir/$lt_tmp_nm" + if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then + # Check to see if the nm accepts a BSD-compat flag. + # Adding the `sed 1q' prevents false positives on HP-UX, which says: + # nm: unknown option "B" ignored + # Tru64's nm complains that /dev/null is an invalid object file + case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in + */dev/null* | *'Invalid file or object type'*) + lt_cv_path_NM="$tmp_nm -B" + break + ;; + *) + case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in + */dev/null*) + lt_cv_path_NM="$tmp_nm -p" + break + ;; + *) + lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but + continue # so that we can try to find one that supports BSD flags + ;; + esac + ;; + esac + fi + done + IFS="$lt_save_ifs" + done + test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm +fi +fi +{ $as_echo "$as_me:$LINENO: result: $lt_cv_path_NM" >&5 +$as_echo "$lt_cv_path_NM" >&6; } +NM="$lt_cv_path_NM" + +{ $as_echo "$as_me:$LINENO: checking whether ln -s works" >&5 +$as_echo_n "checking whether ln -s works... " >&6; } +LN_S=$as_ln_s +if test "$LN_S" = "ln -s"; then + { $as_echo "$as_me:$LINENO: result: yes" >&5 +$as_echo "yes" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no, using $LN_S" >&5 +$as_echo "no, using $LN_S" >&6; } +fi + +{ $as_echo "$as_me:$LINENO: checking how to recognize dependent libraries" >&5 +$as_echo_n "checking how to recognize dependent libraries... " >&6; } +if test "${lt_cv_deplibs_check_method+set}" = set; then + $as_echo_n "(cached) " >&6 +else + lt_cv_file_magic_cmd='$MAGIC_CMD' +lt_cv_file_magic_test_file= +lt_cv_deplibs_check_method='unknown' +# Need to set the preceding variable on all platforms that support +# interlibrary dependencies. +# 'none' -- dependencies not supported. +# `unknown' -- same as none, but documents that we really don't know. +# 'pass_all' -- all dependencies passed with no checks. +# 'test_compile' -- check by making test program. +# 'file_magic [[regex]]' -- check by looking for files in library path +# which responds to the $file_magic_cmd with a given extended regex. +# If you have `file' or equivalent on your system and you're not sure +# whether `pass_all' will *always* work, you probably want this one. + +case $host_os in +aix[4-9]*) + lt_cv_deplibs_check_method=pass_all + ;; + +beos*) + lt_cv_deplibs_check_method=pass_all + ;; + +bsdi[45]*) + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' + lt_cv_file_magic_cmd='/usr/bin/file -L' + lt_cv_file_magic_test_file=/shlib/libc.so + ;; + +cygwin*) + # func_win32_libid is a shell function defined in ltmain.sh + lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' + lt_cv_file_magic_cmd='func_win32_libid' + ;; + +mingw* | pw32*) + # Base MSYS/MinGW do not provide the 'file' command needed by + # func_win32_libid shell function, so use a weaker test based on 'objdump', + # unless we find 'file', for example because we are cross-compiling. + if ( file / ) >/dev/null 2>&1; then + lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' + lt_cv_file_magic_cmd='func_win32_libid' + else + lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?' + lt_cv_file_magic_cmd='$OBJDUMP -f' + fi + ;; + +darwin* | rhapsody*) + lt_cv_deplibs_check_method=pass_all + ;; + +freebsd* | dragonfly*) + if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then + case $host_cpu in + i*86 ) + # Not sure whether the presence of OpenBSD here was a mistake. + # Let's accept both of them until this is cleared up. + lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` + ;; + esac + else + lt_cv_deplibs_check_method=pass_all + fi + ;; + +gnu*) + lt_cv_deplibs_check_method=pass_all + ;; + +hpux10.20* | hpux11*) + lt_cv_file_magic_cmd=/usr/bin/file + case $host_cpu in + ia64*) + lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64' + lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so + ;; + hppa*64*) + lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]' + lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl + ;; + *) + lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library' + lt_cv_file_magic_test_file=/usr/lib/libc.sl + ;; + esac + ;; + +interix[3-9]*) + # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$' + ;; + +irix5* | irix6* | nonstopux*) + case $LD in + *-32|*"-32 ") libmagic=32-bit;; + *-n32|*"-n32 ") libmagic=N32;; + *-64|*"-64 ") libmagic=64-bit;; + *) libmagic=never-match;; + esac + lt_cv_deplibs_check_method=pass_all + ;; + +# This must be Linux ELF. +linux* | k*bsd*-gnu) + lt_cv_deplibs_check_method=pass_all + ;; + +netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' + else + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$' + fi + ;; + +newos6*) + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=/usr/lib/libnls.so + ;; + +nto-qnx*) + lt_cv_deplibs_check_method=unknown + ;; + +openbsd*) + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$' + else + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' + fi + ;; + +osf3* | osf4* | osf5*) + lt_cv_deplibs_check_method=pass_all + ;; + +rdos*) + lt_cv_deplibs_check_method=pass_all + ;; + +solaris*) + lt_cv_deplibs_check_method=pass_all + ;; + +sysv4 | sysv4.3*) + case $host_vendor in + motorola) + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]' + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` + ;; + ncr) + lt_cv_deplibs_check_method=pass_all + ;; + sequent) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' + ;; + sni) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib" + lt_cv_file_magic_test_file=/lib/libc.so + ;; + siemens) + lt_cv_deplibs_check_method=pass_all + ;; + pc) + lt_cv_deplibs_check_method=pass_all + ;; + esac + ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + lt_cv_deplibs_check_method=pass_all + ;; +esac + +fi +{ $as_echo "$as_me:$LINENO: result: $lt_cv_deplibs_check_method" >&5 +$as_echo "$lt_cv_deplibs_check_method" >&6; } +file_magic_cmd=$lt_cv_file_magic_cmd +deplibs_check_method=$lt_cv_deplibs_check_method +test -z "$deplibs_check_method" && deplibs_check_method=unknown + + + + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# If no C compiler flags were specified, use CFLAGS. +LTCFLAGS=${LTCFLAGS-"$CFLAGS"} + +# Allow CC to be a program name with arguments. +compiler=$CC + + +# Check whether --enable-libtool-lock was given. +if test "${enable_libtool_lock+set}" = set; then + enableval=$enable_libtool_lock; +fi + +test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes + +# Some flags need to be propagated to the compiler or linker for good +# libtool support. +case $host in +ia64-*-hpux*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + case `/usr/bin/file conftest.$ac_objext` in + *ELF-32*) + HPUX_IA64_MODE="32" + ;; + *ELF-64*) + HPUX_IA64_MODE="64" + ;; + esac + fi + rm -rf conftest* + ;; +*-*-irix6*) + # Find out which ABI we are using. + echo '#line 5008 "configure"' > conftest.$ac_ext + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + if test "$lt_cv_prog_gnu_ld" = yes; then + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -melf32bsmip" + ;; + *N32*) + LD="${LD-ld} -melf32bmipn32" + ;; + *64-bit*) + LD="${LD-ld} -melf64bmip" + ;; + esac + else + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -32" + ;; + *N32*) + LD="${LD-ld} -n32" + ;; + *64-bit*) + LD="${LD-ld} -64" + ;; + esac + fi + fi + rm -rf conftest* + ;; + +x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \ +s390*-*linux*|sparc*-*linux*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + case `/usr/bin/file conftest.o` in + *32-bit*) + case $host in + x86_64-*kfreebsd*-gnu) + LD="${LD-ld} -m elf_i386_fbsd" + ;; + x86_64-*linux*) + LD="${LD-ld} -m elf_i386" + ;; + ppc64-*linux*|powerpc64-*linux*) + LD="${LD-ld} -m elf32ppclinux" + ;; + s390x-*linux*) + LD="${LD-ld} -m elf_s390" + ;; + sparc64-*linux*) + LD="${LD-ld} -m elf32_sparc" + ;; + esac + ;; + *64-bit*) + case $host in + x86_64-*kfreebsd*-gnu) + LD="${LD-ld} -m elf_x86_64_fbsd" + ;; + x86_64-*linux*) + LD="${LD-ld} -m elf_x86_64" + ;; + ppc*-*linux*|powerpc*-*linux*) + LD="${LD-ld} -m elf64ppc" + ;; + s390*-*linux*) + LD="${LD-ld} -m elf64_s390" + ;; + sparc*-*linux*) + LD="${LD-ld} -m elf64_sparc" + ;; + esac + ;; + esac + fi + rm -rf conftest* + ;; + +*-*-sco3.2v5*) + # On SCO OpenServer 5, we need -belf to get full-featured binaries. + SAVE_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -belf" + { $as_echo "$as_me:$LINENO: checking whether the C compiler needs -belf" >&5 +$as_echo_n "checking whether the C compiler needs -belf... " >&6; } +if test "${lt_cv_cc_needs_belf+set}" = set; then + $as_echo_n "(cached) " >&6 +else + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then + lt_cv_cc_needs_belf=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + lt_cv_cc_needs_belf=no +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +fi +{ $as_echo "$as_me:$LINENO: result: $lt_cv_cc_needs_belf" >&5 +$as_echo "$lt_cv_cc_needs_belf" >&6; } + if test x"$lt_cv_cc_needs_belf" != x"yes"; then + # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf + CFLAGS="$SAVE_CFLAGS" + fi + ;; +sparc*-*solaris*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + case `/usr/bin/file conftest.o` in + *64-bit*) + case $lt_cv_prog_gnu_ld in + yes*) LD="${LD-ld} -m elf64_sparc" ;; + *) + if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then + LD="${LD-ld} -64" + fi + ;; + esac + ;; + esac + fi + rm -rf conftest* + ;; + + +esac + +need_locks="$enable_libtool_lock" + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ $as_echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 +$as_echo_n "checking how to run the C preprocessor... " >&6; } +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if test "${ac_cv_prog_CPP+set}" = set; then + $as_echo_n "(cached) " >&6 +else + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + # <limits.h> exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#endif + Syntax error +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + : +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi + +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <ac_nonexistent.h> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + # Broken: success on invalid input. +continue +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi + +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +{ $as_echo "$as_me:$LINENO: result: $CPP" >&5 +$as_echo "$CPP" >&6; } +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + # <limits.h> exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#endif + Syntax error +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + : +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi + +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <ac_nonexistent.h> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + # Broken: success on invalid input. +continue +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi + +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + : +else + { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ { $as_echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; }; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +{ $as_echo "$as_me:$LINENO: checking for ANSI C header files" >&5 +$as_echo_n "checking for ANSI C header files... " >&6; } +if test "${ac_cv_header_stdc+set}" = set; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <stdlib.h> +#include <stdarg.h> +#include <string.h> +#include <float.h> + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_header_stdc=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_header_stdc=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <string.h> + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then + : +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <stdlib.h> + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then + : +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then + : +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <ctype.h> +#include <stdlib.h> +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + return 2; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + $as_echo "$as_me: program exited with status $ac_status" >&5 +$as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_header_stdc=no +fi +rm -rf conftest.dSYM +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + +fi +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 +$as_echo "$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then + +cat >>confdefs.h <<\_ACEOF +#define STDC_HEADERS 1 +_ACEOF + +fi + +# On IRIX 5.3, sys/types and inttypes.h are conflicting. + + + + + + + + + +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do +as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + eval "$as_ac_Header=yes" +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_Header=no" +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +as_val=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + +for ac_header in dlfcn.h +do +as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 +$as_echo_n "checking $ac_header usability... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 +$as_echo_n "checking $ac_header presence... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + ( cat <<\_ASBOX +## ------------------------------------- ## +## Report this to eddyg@myreflection.org ## +## ------------------------------------- ## +_ASBOX + ) | sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + +fi +as_val=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + +if test -n "$CXX" && ( test "X$CXX" != "Xno" && + ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || + (test "X$CXX" != "Xg++"))) ; then + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu +{ $as_echo "$as_me:$LINENO: checking how to run the C++ preprocessor" >&5 +$as_echo_n "checking how to run the C++ preprocessor... " >&6; } +if test -z "$CXXCPP"; then + if test "${ac_cv_prog_CXXCPP+set}" = set; then + $as_echo_n "(cached) " >&6 +else + # Double quotes because CXXCPP needs to be expanded + for CXXCPP in "$CXX -E" "/lib/cpp" + do + ac_preproc_ok=false +for ac_cxx_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + # <limits.h> exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#endif + Syntax error +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" || + test ! -s conftest.err + }; then + : +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi + +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <ac_nonexistent.h> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" || + test ! -s conftest.err + }; then + # Broken: success on invalid input. +continue +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi + +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + break +fi + + done + ac_cv_prog_CXXCPP=$CXXCPP + +fi + CXXCPP=$ac_cv_prog_CXXCPP +else + ac_cv_prog_CXXCPP=$CXXCPP +fi +{ $as_echo "$as_me:$LINENO: result: $CXXCPP" >&5 +$as_echo "$CXXCPP" >&6; } +ac_preproc_ok=false +for ac_cxx_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + # <limits.h> exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#endif + Syntax error +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" || + test ! -s conftest.err + }; then + : +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi + +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <ac_nonexistent.h> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" || + test ! -s conftest.err + }; then + # Broken: success on invalid input. +continue +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi + +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + : +else + { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ { $as_echo "$as_me:$LINENO: error: C++ preprocessor \"$CXXCPP\" fails sanity check +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: C++ preprocessor \"$CXXCPP\" fails sanity check +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; }; } +fi + +ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + +fi + + + +# Autoconf 2.13's AC_OBJEXT and AC_EXEEXT macros only works for C compilers! +# find the maximum length of command line arguments +{ $as_echo "$as_me:$LINENO: checking the maximum length of command line arguments" >&5 +$as_echo_n "checking the maximum length of command line arguments... " >&6; } +if test "${lt_cv_sys_max_cmd_len+set}" = set; then + $as_echo_n "(cached) " >&6 +else + i=0 + teststring="ABCD" + + case $build_os in + msdosdjgpp*) + # On DJGPP, this test can blow up pretty badly due to problems in libc + # (any single argument exceeding 2000 bytes causes a buffer overrun + # during glob expansion). Even if it were fixed, the result of this + # check would be larger than it should be. + lt_cv_sys_max_cmd_len=12288; # 12K is about right + ;; + + gnu*) + # Under GNU Hurd, this test is not required because there is + # no limit to the length of command line arguments. + # Libtool will interpret -1 as no limit whatsoever + lt_cv_sys_max_cmd_len=-1; + ;; + + cygwin* | mingw*) + # On Win9x/ME, this test blows up -- it succeeds, but takes + # about 5 minutes as the teststring grows exponentially. + # Worse, since 9x/ME are not pre-emptively multitasking, + # you end up with a "frozen" computer, even though with patience + # the test eventually succeeds (with a max line length of 256k). + # Instead, let's just punt: use the minimum linelength reported by + # all of the supported platforms: 8192 (on NT/2K/XP). + lt_cv_sys_max_cmd_len=8192; + ;; + + amigaos*) + # On AmigaOS with pdksh, this test takes hours, literally. + # So we just punt and use a minimum line length of 8192. + lt_cv_sys_max_cmd_len=8192; + ;; + + netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) + # This has been around since 386BSD, at least. Likely further. + if test -x /sbin/sysctl; then + lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` + elif test -x /usr/sbin/sysctl; then + lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` + else + lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs + fi + # And add a safety zone + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` + ;; + + interix*) + # We know the value 262144 and hardcode it with a safety zone (like BSD) + lt_cv_sys_max_cmd_len=196608 + ;; + + osf*) + # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure + # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not + # nice to cause kernel panics so lets avoid the loop below. + # First set a reasonable default. + lt_cv_sys_max_cmd_len=16384 + # + if test -x /sbin/sysconfig; then + case `/sbin/sysconfig -q proc exec_disable_arg_limit` in + *1*) lt_cv_sys_max_cmd_len=-1 ;; + esac + fi + ;; + sco3.2v5*) + lt_cv_sys_max_cmd_len=102400 + ;; + sysv5* | sco5v6* | sysv4.2uw2*) + kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` + if test -n "$kargmax"; then + lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[ ]//'` + else + lt_cv_sys_max_cmd_len=32768 + fi + ;; + *) + lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` + if test -n "$lt_cv_sys_max_cmd_len"; then + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` + else + SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} + while (test "X"`$SHELL $0 --fallback-echo "X$teststring" 2>/dev/null` \ + = "XX$teststring") >/dev/null 2>&1 && + new_result=`expr "X$teststring" : ".*" 2>&1` && + lt_cv_sys_max_cmd_len=$new_result && + test $i != 17 # 1/2 MB should be enough + do + i=`expr $i + 1` + teststring=$teststring$teststring + done + teststring= + # Add a significant safety factor because C++ compilers can tack on massive + # amounts of additional arguments before passing them to the linker. + # It appears as though 1/2 is a usable value. + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` + fi + ;; + esac + +fi + +if test -n $lt_cv_sys_max_cmd_len ; then + { $as_echo "$as_me:$LINENO: result: $lt_cv_sys_max_cmd_len" >&5 +$as_echo "$lt_cv_sys_max_cmd_len" >&6; } +else + { $as_echo "$as_me:$LINENO: result: none" >&5 +$as_echo "none" >&6; } +fi + + + + + +# Check for command to grab the raw symbol name followed by C symbol from nm. +{ $as_echo "$as_me:$LINENO: checking command to parse $NM output from $compiler object" >&5 +$as_echo_n "checking command to parse $NM output from $compiler object... " >&6; } +if test "${lt_cv_sys_global_symbol_pipe+set}" = set; then + $as_echo_n "(cached) " >&6 +else + +# These are sane defaults that work on at least a few old systems. +# [They come from Ultrix. What could be older than Ultrix?!! ;)] + +# Character class describing NM global symbol codes. +symcode='[BCDEGRST]' + +# Regexp to match symbols that can be accessed directly from C. +sympat='\([_A-Za-z][_A-Za-z0-9]*\)' + +# Transform an extracted symbol line into a proper C declaration +lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern int \1;/p'" + +# Transform an extracted symbol line into symbol name and symbol address +lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode \([^ ]*\) \([^ ]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" + +# Define system-specific variables. +case $host_os in +aix*) + symcode='[BCDT]' + ;; +cygwin* | mingw* | pw32*) + symcode='[ABCDGISTW]' + ;; +hpux*) # Its linker distinguishes data from code symbols + if test "$host_cpu" = ia64; then + symcode='[ABCDEGRST]' + fi + lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" + lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" + ;; +linux* | k*bsd*-gnu) + if test "$host_cpu" = ia64; then + symcode='[ABCDGIRSTW]' + lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" + lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" + fi + ;; +irix* | nonstopux*) + symcode='[BCDEGRST]' + ;; +osf*) + symcode='[BCDEGQRST]' + ;; +solaris*) + symcode='[BDRT]' + ;; +sco3.2v5*) + symcode='[DT]' + ;; +sysv4.2uw2*) + symcode='[DT]' + ;; +sysv5* | sco5v6* | unixware* | OpenUNIX*) + symcode='[ABDT]' + ;; +sysv4) + symcode='[DFNSTU]' + ;; +esac + +# Handle CRLF in mingw tool chain +opt_cr= +case $build_os in +mingw*) + opt_cr=`echo 'x\{0,1\}' | tr x '\015'` # option cr in regexp + ;; +esac + +# If we're using GNU nm, then use its standard symbol codes. +case `$NM -V 2>&1` in +*GNU* | *'with BFD'*) + symcode='[ABCDGIRSTW]' ;; +esac + +# Try without a prefix undercore, then with it. +for ac_symprfx in "" "_"; do + + # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. + symxfrm="\\1 $ac_symprfx\\2 \\2" + + # Write the raw and C identifiers. + lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" + + # Check to see that the pipe works correctly. + pipe_works=no + + rm -f conftest* + cat > conftest.$ac_ext <<EOF +#ifdef __cplusplus +extern "C" { +#endif +char nm_test_var; +void nm_test_func(){} +#ifdef __cplusplus +} +#endif +int main(){nm_test_var='a';nm_test_func();return(0);} +EOF + + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # Now try to grab the symbols. + nlist=conftest.nm + if { (eval echo "$as_me:$LINENO: \"$NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist\"") >&5 + (eval $NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && test -s "$nlist"; then + # Try sorting and uniquifying the output. + if sort "$nlist" | uniq > "$nlist"T; then + mv -f "$nlist"T "$nlist" + else + rm -f "$nlist"T + fi + + # Make sure that we snagged all the symbols we need. + if grep ' nm_test_var$' "$nlist" >/dev/null; then + if grep ' nm_test_func$' "$nlist" >/dev/null; then + cat <<EOF > conftest.$ac_ext +#ifdef __cplusplus +extern "C" { +#endif + +EOF + # Now generate the symbol file. + eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | grep -v main >> conftest.$ac_ext' + + cat <<EOF >> conftest.$ac_ext +#if defined (__STDC__) && __STDC__ +# define lt_ptr_t void * +#else +# define lt_ptr_t char * +# define const +#endif + +/* The mapping between symbol names and symbols. */ +const struct { + const char *name; + lt_ptr_t address; +} +lt_preloaded_symbols[] = +{ +EOF + $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (lt_ptr_t) \&\2},/" < "$nlist" | grep -v main >> conftest.$ac_ext + cat <<\EOF >> conftest.$ac_ext + {0, (lt_ptr_t) 0} +}; + +#ifdef __cplusplus +} +#endif +EOF + # Now try linking the two files. + mv conftest.$ac_objext conftstm.$ac_objext + lt_save_LIBS="$LIBS" + lt_save_CFLAGS="$CFLAGS" + LIBS="conftstm.$ac_objext" + CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag" + if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && test -s conftest${ac_exeext}; then + pipe_works=yes + fi + LIBS="$lt_save_LIBS" + CFLAGS="$lt_save_CFLAGS" + else + echo "cannot find nm_test_func in $nlist" >&5 + fi + else + echo "cannot find nm_test_var in $nlist" >&5 + fi + else + echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5 + fi + else + echo "$progname: failed program was:" >&5 + cat conftest.$ac_ext >&5 + fi + rm -rf conftest* conftst* + + # Do not use the global_symbol_pipe unless it works. + if test "$pipe_works" = yes; then + break + else + lt_cv_sys_global_symbol_pipe= + fi +done + +fi + +if test -z "$lt_cv_sys_global_symbol_pipe"; then + lt_cv_sys_global_symbol_to_cdecl= +fi +if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then + { $as_echo "$as_me:$LINENO: result: failed" >&5 +$as_echo "failed" >&6; } +else + { $as_echo "$as_me:$LINENO: result: ok" >&5 +$as_echo "ok" >&6; } +fi + +{ $as_echo "$as_me:$LINENO: checking for objdir" >&5 +$as_echo_n "checking for objdir... " >&6; } +if test "${lt_cv_objdir+set}" = set; then + $as_echo_n "(cached) " >&6 +else + rm -f .libs 2>/dev/null +mkdir .libs 2>/dev/null +if test -d .libs; then + lt_cv_objdir=.libs +else + # MS-DOS does not allow filenames that begin with a dot. + lt_cv_objdir=_libs +fi +rmdir .libs 2>/dev/null +fi +{ $as_echo "$as_me:$LINENO: result: $lt_cv_objdir" >&5 +$as_echo "$lt_cv_objdir" >&6; } +objdir=$lt_cv_objdir + + + + + +case $host_os in +aix3*) + # AIX sometimes has problems with the GCC collect2 program. For some + # reason, if we set the COLLECT_NAMES environment variable, the problems + # vanish in a puff of smoke. + if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES + fi + ;; +esac + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed='sed -e 1s/^X//' +sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g' + +# Same as above, but do not quote variable references. +double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g' + +# Sed substitution to delay expansion of an escaped shell variable in a +# double_quote_subst'ed string. +delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' + +# Sed substitution to avoid accidental globbing in evaled expressions +no_glob_subst='s/\*/\\\*/g' + +# Constants: +rm="rm -f" + +# Global variables: +default_ofile=libtool +can_build_shared=yes + +# All known linkers require a `.a' archive for static linking (except MSVC, +# which needs '.lib'). +libext=a +ltmain="$ac_aux_dir/ltmain.sh" +ofile="$default_ofile" +with_gnu_ld="$lt_cv_prog_gnu_ld" + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args. +set dummy ${ac_tool_prefix}ar; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_AR+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$AR"; then + ac_cv_prog_AR="$AR" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_AR="${ac_tool_prefix}ar" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +AR=$ac_cv_prog_AR +if test -n "$AR"; then + { $as_echo "$as_me:$LINENO: result: $AR" >&5 +$as_echo "$AR" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_AR"; then + ac_ct_AR=$AR + # Extract the first word of "ar", so it can be a program name with args. +set dummy ar; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_AR+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_AR"; then + ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_AR="ar" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_AR=$ac_cv_prog_ac_ct_AR +if test -n "$ac_ct_AR"; then + { $as_echo "$as_me:$LINENO: result: $ac_ct_AR" >&5 +$as_echo "$ac_ct_AR" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_AR" = x; then + AR="false" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + AR=$ac_ct_AR + fi +else + AR="$ac_cv_prog_AR" +fi + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. +set dummy ${ac_tool_prefix}ranlib; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_RANLIB+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +RANLIB=$ac_cv_prog_RANLIB +if test -n "$RANLIB"; then + { $as_echo "$as_me:$LINENO: result: $RANLIB" >&5 +$as_echo "$RANLIB" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_RANLIB"; then + ac_ct_RANLIB=$RANLIB + # Extract the first word of "ranlib", so it can be a program name with args. +set dummy ranlib; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_RANLIB"; then + ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_RANLIB="ranlib" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB +if test -n "$ac_ct_RANLIB"; then + { $as_echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5 +$as_echo "$ac_ct_RANLIB" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_RANLIB" = x; then + RANLIB=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + RANLIB=$ac_ct_RANLIB + fi +else + RANLIB="$ac_cv_prog_RANLIB" +fi + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. +set dummy ${ac_tool_prefix}strip; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_STRIP+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$STRIP"; then + ac_cv_prog_STRIP="$STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_STRIP="${ac_tool_prefix}strip" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +STRIP=$ac_cv_prog_STRIP +if test -n "$STRIP"; then + { $as_echo "$as_me:$LINENO: result: $STRIP" >&5 +$as_echo "$STRIP" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_STRIP"; then + ac_ct_STRIP=$STRIP + # Extract the first word of "strip", so it can be a program name with args. +set dummy strip; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_STRIP"; then + ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_STRIP="strip" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP +if test -n "$ac_ct_STRIP"; then + { $as_echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5 +$as_echo "$ac_ct_STRIP" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_STRIP" = x; then + STRIP=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + STRIP=$ac_ct_STRIP + fi +else + STRIP="$ac_cv_prog_STRIP" +fi + + +old_CC="$CC" +old_CFLAGS="$CFLAGS" + +# Set sane defaults for various variables +test -z "$AR" && AR=ar +test -z "$AR_FLAGS" && AR_FLAGS=cru +test -z "$AS" && AS=as +test -z "$CC" && CC=cc +test -z "$LTCC" && LTCC=$CC +test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS +test -z "$DLLTOOL" && DLLTOOL=dlltool +test -z "$LD" && LD=ld +test -z "$LN_S" && LN_S="ln -s" +test -z "$MAGIC_CMD" && MAGIC_CMD=file +test -z "$NM" && NM=nm +test -z "$SED" && SED=sed +test -z "$OBJDUMP" && OBJDUMP=objdump +test -z "$RANLIB" && RANLIB=: +test -z "$STRIP" && STRIP=: +test -z "$ac_objext" && ac_objext=o + +# Determine commands to create old-style static archives. +old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' +old_postinstall_cmds='chmod 644 $oldlib' +old_postuninstall_cmds= + +if test -n "$RANLIB"; then + case $host_os in + openbsd*) + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib" + ;; + *) + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib" + ;; + esac + old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" +fi + +for cc_temp in $compiler""; do + case $cc_temp in + compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; + distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; + \-*) ;; + *) break;; + esac +done +cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` + + +# Only perform the check for file, if the check method requires it +case $deplibs_check_method in +file_magic*) + if test "$file_magic_cmd" = '$MAGIC_CMD'; then + { $as_echo "$as_me:$LINENO: checking for ${ac_tool_prefix}file" >&5 +$as_echo_n "checking for ${ac_tool_prefix}file... " >&6; } +if test "${lt_cv_path_MAGIC_CMD+set}" = set; then + $as_echo_n "(cached) " >&6 +else + case $MAGIC_CMD in +[\\/*] | ?:[\\/]*) + lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. + ;; +*) + lt_save_MAGIC_CMD="$MAGIC_CMD" + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" + for ac_dir in $ac_dummy; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/${ac_tool_prefix}file; then + lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file" + if test -n "$file_magic_test_file"; then + case $deplibs_check_method in + "file_magic "*) + file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` + MAGIC_CMD="$lt_cv_path_MAGIC_CMD" + if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | + $EGREP "$file_magic_regex" > /dev/null; then + : + else + cat <<EOF 1>&2 + +*** Warning: the command libtool uses to detect shared libraries, +*** $file_magic_cmd, produces output that libtool cannot recognize. +*** The result is that libtool may fail to recognize shared libraries +*** as such. This will affect the creation of libtool libraries that +*** depend on shared libraries, but programs linked with such libtool +*** libraries will work regardless of this problem. Nevertheless, you +*** may want to report the problem to your system manager and/or to +*** bug-libtool@gnu.org + +EOF + fi ;; + esac + fi + break + fi + done + IFS="$lt_save_ifs" + MAGIC_CMD="$lt_save_MAGIC_CMD" + ;; +esac +fi + +MAGIC_CMD="$lt_cv_path_MAGIC_CMD" +if test -n "$MAGIC_CMD"; then + { $as_echo "$as_me:$LINENO: result: $MAGIC_CMD" >&5 +$as_echo "$MAGIC_CMD" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + +if test -z "$lt_cv_path_MAGIC_CMD"; then + if test -n "$ac_tool_prefix"; then + { $as_echo "$as_me:$LINENO: checking for file" >&5 +$as_echo_n "checking for file... " >&6; } +if test "${lt_cv_path_MAGIC_CMD+set}" = set; then + $as_echo_n "(cached) " >&6 +else + case $MAGIC_CMD in +[\\/*] | ?:[\\/]*) + lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. + ;; +*) + lt_save_MAGIC_CMD="$MAGIC_CMD" + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" + for ac_dir in $ac_dummy; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/file; then + lt_cv_path_MAGIC_CMD="$ac_dir/file" + if test -n "$file_magic_test_file"; then + case $deplibs_check_method in + "file_magic "*) + file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` + MAGIC_CMD="$lt_cv_path_MAGIC_CMD" + if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | + $EGREP "$file_magic_regex" > /dev/null; then + : + else + cat <<EOF 1>&2 + +*** Warning: the command libtool uses to detect shared libraries, +*** $file_magic_cmd, produces output that libtool cannot recognize. +*** The result is that libtool may fail to recognize shared libraries +*** as such. This will affect the creation of libtool libraries that +*** depend on shared libraries, but programs linked with such libtool +*** libraries will work regardless of this problem. Nevertheless, you +*** may want to report the problem to your system manager and/or to +*** bug-libtool@gnu.org + +EOF + fi ;; + esac + fi + break + fi + done + IFS="$lt_save_ifs" + MAGIC_CMD="$lt_save_MAGIC_CMD" + ;; +esac +fi + +MAGIC_CMD="$lt_cv_path_MAGIC_CMD" +if test -n "$MAGIC_CMD"; then + { $as_echo "$as_me:$LINENO: result: $MAGIC_CMD" >&5 +$as_echo "$MAGIC_CMD" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + else + MAGIC_CMD=: + fi +fi + + fi + ;; +esac + + + case $host_os in + rhapsody* | darwin*) + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args. +set dummy ${ac_tool_prefix}dsymutil; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_DSYMUTIL+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$DSYMUTIL"; then + ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +DSYMUTIL=$ac_cv_prog_DSYMUTIL +if test -n "$DSYMUTIL"; then + { $as_echo "$as_me:$LINENO: result: $DSYMUTIL" >&5 +$as_echo "$DSYMUTIL" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_DSYMUTIL"; then + ac_ct_DSYMUTIL=$DSYMUTIL + # Extract the first word of "dsymutil", so it can be a program name with args. +set dummy dsymutil; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_DSYMUTIL+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_DSYMUTIL"; then + ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_DSYMUTIL="dsymutil" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL +if test -n "$ac_ct_DSYMUTIL"; then + { $as_echo "$as_me:$LINENO: result: $ac_ct_DSYMUTIL" >&5 +$as_echo "$ac_ct_DSYMUTIL" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_DSYMUTIL" = x; then + DSYMUTIL=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + DSYMUTIL=$ac_ct_DSYMUTIL + fi +else + DSYMUTIL="$ac_cv_prog_DSYMUTIL" +fi + + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args. +set dummy ${ac_tool_prefix}nmedit; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_NMEDIT+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$NMEDIT"; then + ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +NMEDIT=$ac_cv_prog_NMEDIT +if test -n "$NMEDIT"; then + { $as_echo "$as_me:$LINENO: result: $NMEDIT" >&5 +$as_echo "$NMEDIT" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_NMEDIT"; then + ac_ct_NMEDIT=$NMEDIT + # Extract the first word of "nmedit", so it can be a program name with args. +set dummy nmedit; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_NMEDIT+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_NMEDIT"; then + ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_NMEDIT="nmedit" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT +if test -n "$ac_ct_NMEDIT"; then + { $as_echo "$as_me:$LINENO: result: $ac_ct_NMEDIT" >&5 +$as_echo "$ac_ct_NMEDIT" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_NMEDIT" = x; then + NMEDIT=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + NMEDIT=$ac_ct_NMEDIT + fi +else + NMEDIT="$ac_cv_prog_NMEDIT" +fi + + + { $as_echo "$as_me:$LINENO: checking for -single_module linker flag" >&5 +$as_echo_n "checking for -single_module linker flag... " >&6; } +if test "${lt_cv_apple_cc_single_mod+set}" = set; then + $as_echo_n "(cached) " >&6 +else + lt_cv_apple_cc_single_mod=no + if test -z "${LT_MULTI_MODULE}"; then + # By default we will add the -single_module flag. You can override + # by either setting the environment variable LT_MULTI_MODULE + # non-empty at configure time, or by adding -multi_module to the + # link flags. + echo "int foo(void){return 1;}" > conftest.c + $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ + -dynamiclib ${wl}-single_module conftest.c + if test -f libconftest.dylib; then + lt_cv_apple_cc_single_mod=yes + rm -rf libconftest.dylib* + fi + rm conftest.c + fi +fi +{ $as_echo "$as_me:$LINENO: result: $lt_cv_apple_cc_single_mod" >&5 +$as_echo "$lt_cv_apple_cc_single_mod" >&6; } + { $as_echo "$as_me:$LINENO: checking for -exported_symbols_list linker flag" >&5 +$as_echo_n "checking for -exported_symbols_list linker flag... " >&6; } +if test "${lt_cv_ld_exported_symbols_list+set}" = set; then + $as_echo_n "(cached) " >&6 +else + lt_cv_ld_exported_symbols_list=no + save_LDFLAGS=$LDFLAGS + echo "_main" > conftest.sym + LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then + lt_cv_ld_exported_symbols_list=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + lt_cv_ld_exported_symbols_list=no +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext + LDFLAGS="$save_LDFLAGS" + +fi +{ $as_echo "$as_me:$LINENO: result: $lt_cv_ld_exported_symbols_list" >&5 +$as_echo "$lt_cv_ld_exported_symbols_list" >&6; } + case $host_os in + rhapsody* | darwin1.[0123]) + _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; + darwin1.*) + _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; + darwin*) + # if running on 10.5 or later, the deployment target defaults + # to the OS version, if on x86, and 10.4, the deployment + # target defaults to 10.4. Don't you love it? + case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in + 10.0,*86*-darwin8*|10.0,*-darwin[91]*) + _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; + 10.[012]*) + _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; + 10.*) + _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; + esac + ;; + esac + if test "$lt_cv_apple_cc_single_mod" = "yes"; then + _lt_dar_single_mod='$single_module' + fi + if test "$lt_cv_ld_exported_symbols_list" = "yes"; then + _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' + else + _lt_dar_export_syms="~$NMEDIT -s \$output_objdir/\${libname}-symbols.expsym \${lib}" + fi + if test "$DSYMUTIL" != ":"; then + _lt_dsymutil="~$DSYMUTIL \$lib || :" + else + _lt_dsymutil= + fi + ;; + esac + + +enable_dlopen=no +enable_win32_dll=no + +# Check whether --enable-libtool-lock was given. +if test "${enable_libtool_lock+set}" = set; then + enableval=$enable_libtool_lock; +fi + +test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes + + +# Check whether --with-pic was given. +if test "${with_pic+set}" = set; then + withval=$with_pic; pic_mode="$withval" +else + pic_mode=default +fi + +test -z "$pic_mode" && pic_mode=default + +# Use C for the default configuration in the libtool script +tagname= +lt_save_CC="$CC" +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +# Source file extension for C test sources. +ac_ext=c + +# Object file extension for compiled C test sources. +objext=o +objext=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="int some_variable = 0;" + +# Code to be used in simple link tests +lt_simple_link_test_code='int main(){return(0);}' + + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# If no C compiler flags were specified, use CFLAGS. +LTCFLAGS=${LTCFLAGS-"$CFLAGS"} + +# Allow CC to be a program name with arguments. +compiler=$CC + + +# save warnings/boilerplate of simple test code +ac_outfile=conftest.$ac_objext +echo "$lt_simple_compile_test_code" >conftest.$ac_ext +eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_compiler_boilerplate=`cat conftest.err` +$rm conftest* + +ac_outfile=conftest.$ac_objext +echo "$lt_simple_link_test_code" >conftest.$ac_ext +eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_linker_boilerplate=`cat conftest.err` +$rm -r conftest* + + + +lt_prog_compiler_no_builtin_flag= + +if test "$GCC" = yes; then + lt_prog_compiler_no_builtin_flag=' -fno-builtin' + + +{ $as_echo "$as_me:$LINENO: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 +$as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; } +if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then + $as_echo_n "(cached) " >&6 +else + lt_cv_prog_compiler_rtti_exceptions=no + ac_outfile=conftest.$ac_objext + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="-fno-rtti -fno-exceptions" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:7346: $lt_compile\"" >&5) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&5 + echo "$as_me:7350: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings other than the usual output. + $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then + lt_cv_prog_compiler_rtti_exceptions=yes + fi + fi + $rm conftest* + +fi +{ $as_echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 +$as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; } + +if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then + lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions" +else + : +fi + +fi + +lt_prog_compiler_wl= +lt_prog_compiler_pic= +lt_prog_compiler_static= + +{ $as_echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5 +$as_echo_n "checking for $compiler option to produce PIC... " >&6; } + + if test "$GCC" = yes; then + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_static='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static='-Bstatic' + fi + ;; + + amigaos*) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the `-m68020' flag to GCC prevents building anything better, + # like `-m68040'. + lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4' + ;; + + beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + + mingw* | cygwin* | pw32* | os2*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + # Although the cygwin gcc ignores -fPIC, still need this for old-style + # (--disable-auto-import) libraries + lt_prog_compiler_pic='-DDLL_EXPORT' + ;; + + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + lt_prog_compiler_pic='-fno-common' + ;; + + interix[3-9]*) + # Interix 3.x gcc -fpic/-fPIC options generate broken code. + # Instead, we relocate shared libraries at runtime. + ;; + + msdosdjgpp*) + # Just because we use GCC doesn't mean we suddenly get shared libraries + # on systems that don't support them. + lt_prog_compiler_can_build_shared=no + enable_shared=no + ;; + + sysv4*MP*) + if test -d /usr/nec; then + lt_prog_compiler_pic=-Kconform_pic + fi + ;; + + hpux*) + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + lt_prog_compiler_pic='-fPIC' + ;; + esac + ;; + + *) + lt_prog_compiler_pic='-fPIC' + ;; + esac + else + # PORTME Check for flag to pass linker flags through the system compiler. + case $host_os in + aix*) + lt_prog_compiler_wl='-Wl,' + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static='-Bstatic' + else + lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp' + fi + ;; + darwin*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + case $cc_basename in + xlc*) + lt_prog_compiler_pic='-qnocommon' + lt_prog_compiler_wl='-Wl,' + ;; + esac + ;; + + mingw* | cygwin* | pw32* | os2*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + lt_prog_compiler_pic='-DDLL_EXPORT' + ;; + + hpux9* | hpux10* | hpux11*) + lt_prog_compiler_wl='-Wl,' + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + lt_prog_compiler_pic='+Z' + ;; + esac + # Is there a better lt_prog_compiler_static that works with the bundled CC? + lt_prog_compiler_static='${wl}-a ${wl}archive' + ;; + + irix5* | irix6* | nonstopux*) + lt_prog_compiler_wl='-Wl,' + # PIC (with -KPIC) is the default. + lt_prog_compiler_static='-non_shared' + ;; + + newsos6) + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + ;; + + linux* | k*bsd*-gnu) + case $cc_basename in + icc* | ecc*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-static' + ;; + pgcc* | pgf77* | pgf90* | pgf95*) + # Portland Group compilers (*not* the Pentium gcc compiler, + # which looks to be a dead project) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-fpic' + lt_prog_compiler_static='-Bstatic' + ;; + ccc*) + lt_prog_compiler_wl='-Wl,' + # All Alpha code is PIC. + lt_prog_compiler_static='-non_shared' + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + # Sun C 5.9 + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + lt_prog_compiler_wl='-Wl,' + ;; + *Sun\ F*) + # Sun Fortran 8.3 passes all unrecognized flags to the linker + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + lt_prog_compiler_wl='' + ;; + esac + ;; + esac + ;; + + osf3* | osf4* | osf5*) + lt_prog_compiler_wl='-Wl,' + # All OSF/1 code is PIC. + lt_prog_compiler_static='-non_shared' + ;; + + rdos*) + lt_prog_compiler_static='-non_shared' + ;; + + solaris*) + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + case $cc_basename in + f77* | f90* | f95*) + lt_prog_compiler_wl='-Qoption ld ';; + *) + lt_prog_compiler_wl='-Wl,';; + esac + ;; + + sunos4*) + lt_prog_compiler_wl='-Qoption ld ' + lt_prog_compiler_pic='-PIC' + lt_prog_compiler_static='-Bstatic' + ;; + + sysv4 | sysv4.2uw2* | sysv4.3*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + ;; + + sysv4*MP*) + if test -d /usr/nec ;then + lt_prog_compiler_pic='-Kconform_pic' + lt_prog_compiler_static='-Bstatic' + fi + ;; + + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + ;; + + unicos*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_can_build_shared=no + ;; + + uts4*) + lt_prog_compiler_pic='-pic' + lt_prog_compiler_static='-Bstatic' + ;; + + *) + lt_prog_compiler_can_build_shared=no + ;; + esac + fi + +{ $as_echo "$as_me:$LINENO: result: $lt_prog_compiler_pic" >&5 +$as_echo "$lt_prog_compiler_pic" >&6; } + +# +# Check to make sure the PIC flag actually works. +# +if test -n "$lt_prog_compiler_pic"; then + +{ $as_echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5 +$as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; } +if test "${lt_cv_prog_compiler_pic_works+set}" = set; then + $as_echo_n "(cached) " >&6 +else + lt_cv_prog_compiler_pic_works=no + ac_outfile=conftest.$ac_objext + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="$lt_prog_compiler_pic -DPIC" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:7636: $lt_compile\"" >&5) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&5 + echo "$as_me:7640: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings other than the usual output. + $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then + lt_cv_prog_compiler_pic_works=yes + fi + fi + $rm conftest* + +fi +{ $as_echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_pic_works" >&5 +$as_echo "$lt_cv_prog_compiler_pic_works" >&6; } + +if test x"$lt_cv_prog_compiler_pic_works" = xyes; then + case $lt_prog_compiler_pic in + "" | " "*) ;; + *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;; + esac +else + lt_prog_compiler_pic= + lt_prog_compiler_can_build_shared=no +fi + +fi +case $host_os in + # For platforms which do not support PIC, -DPIC is meaningless: + *djgpp*) + lt_prog_compiler_pic= + ;; + *) + lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC" + ;; +esac + +# +# Check to make sure the static flag actually works. +# +wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\" +{ $as_echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5 +$as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } +if test "${lt_cv_prog_compiler_static_works+set}" = set; then + $as_echo_n "(cached) " >&6 +else + lt_cv_prog_compiler_static_works=no + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS $lt_tmp_static_flag" + echo "$lt_simple_link_test_code" > conftest.$ac_ext + if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then + # The linker can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + # Append any errors to the config.log. + cat conftest.err 1>&5 + $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if diff conftest.exp conftest.er2 >/dev/null; then + lt_cv_prog_compiler_static_works=yes + fi + else + lt_cv_prog_compiler_static_works=yes + fi + fi + $rm -r conftest* + LDFLAGS="$save_LDFLAGS" + +fi +{ $as_echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_static_works" >&5 +$as_echo "$lt_cv_prog_compiler_static_works" >&6; } + +if test x"$lt_cv_prog_compiler_static_works" = xyes; then + : +else + lt_prog_compiler_static= +fi + + +{ $as_echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5 +$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } +if test "${lt_cv_prog_compiler_c_o+set}" = set; then + $as_echo_n "(cached) " >&6 +else + lt_cv_prog_compiler_c_o=no + $rm -r conftest 2>/dev/null + mkdir conftest + cd conftest + mkdir out + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + lt_compiler_flag="-o out/conftest2.$ac_objext" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:7740: $lt_compile\"" >&5) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&5 + echo "$as_me:7744: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp + $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 + if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then + lt_cv_prog_compiler_c_o=yes + fi + fi + chmod u+w . 2>&5 + $rm conftest* + # SGI C++ compiler will create directory out/ii_files/ for + # template instantiation + test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files + $rm out/* && rmdir out + cd .. + rmdir conftest + $rm conftest* + +fi +{ $as_echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o" >&5 +$as_echo "$lt_cv_prog_compiler_c_o" >&6; } + + +hard_links="nottested" +if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then + # do not overwrite the value of need_locks provided by the user + { $as_echo "$as_me:$LINENO: checking if we can lock with hard links" >&5 +$as_echo_n "checking if we can lock with hard links... " >&6; } + hard_links=yes + $rm conftest* + ln conftest.a conftest.b 2>/dev/null && hard_links=no + touch conftest.a + ln conftest.a conftest.b 2>&5 || hard_links=no + ln conftest.a conftest.b 2>/dev/null && hard_links=no + { $as_echo "$as_me:$LINENO: result: $hard_links" >&5 +$as_echo "$hard_links" >&6; } + if test "$hard_links" = no; then + { $as_echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 +$as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} + need_locks=warn + fi +else + need_locks=no +fi + +{ $as_echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5 +$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } + + runpath_var= + allow_undefined_flag= + enable_shared_with_static_runtimes=no + archive_cmds= + archive_expsym_cmds= + old_archive_From_new_cmds= + old_archive_from_expsyms_cmds= + export_dynamic_flag_spec= + whole_archive_flag_spec= + thread_safe_flag_spec= + hardcode_libdir_flag_spec= + hardcode_libdir_flag_spec_ld= + hardcode_libdir_separator= + hardcode_direct=no + hardcode_minus_L=no + hardcode_shlibpath_var=unsupported + link_all_deplibs=unknown + hardcode_automatic=no + module_cmds= + module_expsym_cmds= + always_export_symbols=no + export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + # include_expsyms should be a list of space-separated symbols to be *always* + # included in the symbol list + include_expsyms= + # exclude_expsyms can be an extended regexp of symbols to exclude + # it will be wrapped by ` (' and `)$', so one must not match beginning or + # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', + # as well as any symbol that contains `d'. + exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*' + # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out + # platforms (ab)use it in PIC code, but their linkers get confused if + # the symbol is explicitly referenced. Since portable code cannot + # rely on this symbol name, it's probably fine to never include it in + # preloaded symbol tables. + # Exclude shared library initialization/finalization symbols. + extract_expsyms_cmds= + # Just being paranoid about ensuring that cc_basename is set. + for cc_temp in $compiler""; do + case $cc_temp in + compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; + distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; + \-*) ;; + *) break;; + esac +done +cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` + + case $host_os in + cygwin* | mingw* | pw32*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + if test "$GCC" != yes; then + with_gnu_ld=no + fi + ;; + interix*) + # we just hope/assume this is gcc and not c89 (= MSVC++) + with_gnu_ld=yes + ;; + openbsd*) + with_gnu_ld=no + ;; + esac + + ld_shlibs=yes + if test "$with_gnu_ld" = yes; then + # If archive_cmds runs LD, not CC, wlarc should be empty + wlarc='${wl}' + + # Set some defaults for GNU ld with shared library support. These + # are reset later if shared libraries are not supported. Putting them + # here allows them to be overridden if necessary. + runpath_var=LD_RUN_PATH + hardcode_libdir_flag_spec='${wl}--rpath ${wl}$libdir' + export_dynamic_flag_spec='${wl}--export-dynamic' + # ancient GNU ld didn't support --whole-archive et. al. + if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then + whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + whole_archive_flag_spec= + fi + supports_anon_versioning=no + case `$LD -v 2>/dev/null` in + *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 + *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... + *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... + *\ 2.11.*) ;; # other 2.11 versions + *) supports_anon_versioning=yes ;; + esac + + # See if GNU ld supports shared libraries. + case $host_os in + aix[3-9]*) + # On AIX/PPC, the GNU linker is very broken + if test "$host_cpu" != ia64; then + ld_shlibs=no + cat <<EOF 1>&2 + +*** Warning: the GNU linker, at least up to release 2.9.1, is reported +*** to be unable to reliably create shared libraries on AIX. +*** Therefore, libtool is disabling shared libraries support. If you +*** really care for shared libraries, you may want to modify your PATH +*** so that a non-GNU linker is found, and then restart. + +EOF + fi + ;; + + amigaos*) + archive_cmds='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + + # Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports + # that the semantics of dynamic libraries on AmigaOS, at least up + # to version 4, is to share data among multiple programs linked + # with the same dynamic library. Since this doesn't match the + # behavior of shared libraries on other platforms, we can't use + # them. + ld_shlibs=no + ;; + + beos*) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + allow_undefined_flag=unsupported + # Joseph Beckenbach <jrb3@best.com> says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + else + ld_shlibs=no + fi + ;; + + cygwin* | mingw* | pw32*) + # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless, + # as there is no search path for DLLs. + hardcode_libdir_flag_spec='-L$libdir' + allow_undefined_flag=unsupported + always_export_symbols=no + enable_shared_with_static_runtimes=yes + export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/'\'' -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols' + + if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + # If the export-symbols file already is a .def file (1st line + # is EXPORTS), use it as is; otherwise, prepend... + archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + else + ld_shlibs=no + fi + ;; + + interix[3-9]*) + hardcode_direct=no + hardcode_shlibpath_var=no + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + export_dynamic_flag_spec='${wl}-E' + # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. + # Instead, shared libraries are loaded at an image base (0x10000000 by + # default) and relocated if they conflict, which is a slow very memory + # consuming and fragmenting process. To avoid this, we pick a random, + # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link + # time. Moving up from 0x10000000 also allows more sbrk(2) space. + archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + ;; + + gnu* | linux* | k*bsd*-gnu) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + tmp_addflag= + case $cc_basename,$host_cpu in + pgcc*) # Portland Group C compiler + whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' + tmp_addflag=' $pic_flag' + ;; + pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers + whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' + tmp_addflag=' $pic_flag -Mnomain' ;; + ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 + tmp_addflag=' -i_dynamic' ;; + efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 + tmp_addflag=' -i_dynamic -nofor_main' ;; + ifc* | ifort*) # Intel Fortran compiler + tmp_addflag=' -nofor_main' ;; + esac + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) # Sun C 5.9 + whole_archive_flag_spec='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' + tmp_sharedflag='-G' ;; + *Sun\ F*) # Sun Fortran 8.3 + tmp_sharedflag='-G' ;; + *) + tmp_sharedflag='-shared' ;; + esac + archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + + if test $supports_anon_versioning = yes; then + archive_expsym_cmds='$echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + $echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' + fi + else + ld_shlibs=no + fi + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' + wlarc= + else + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + fi + ;; + + solaris*) + if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then + ld_shlibs=no + cat <<EOF 1>&2 + +*** Warning: The releases 2.8.* of the GNU linker cannot reliably +*** create shared libraries on Solaris systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.9.1 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +EOF + elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs=no + fi + ;; + + sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) + case `$LD -v 2>&1` in + *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) + ld_shlibs=no + cat <<_LT_EOF 1>&2 + +*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not +*** reliably create shared libraries on SCO systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.16.91.0.3 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +_LT_EOF + ;; + *) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`' + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname,-retain-symbols-file,$export_symbols -o $lib' + else + ld_shlibs=no + fi + ;; + esac + ;; + + sunos4*) + archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' + wlarc= + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + *) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs=no + fi + ;; + esac + + if test "$ld_shlibs" = no; then + runpath_var= + hardcode_libdir_flag_spec= + export_dynamic_flag_spec= + whole_archive_flag_spec= + fi + else + # PORTME fill in a description of your system's linker (not GNU ld) + case $host_os in + aix3*) + allow_undefined_flag=unsupported + always_export_symbols=yes + archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + hardcode_minus_L=yes + if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + hardcode_direct=unsupported + fi + ;; + + aix[4-9]*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag="" + else + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to AIX nm, but means don't demangle with GNU nm + if $NM -V 2>&1 | grep 'GNU' > /dev/null; then + export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' + else + export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' + fi + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) + for ld_flag in $LDFLAGS; do + if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then + aix_use_runtimelinking=yes + break + fi + done + ;; + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + archive_cmds='' + hardcode_direct=yes + hardcode_libdir_separator=':' + link_all_deplibs=yes + + if test "$GCC" = yes; then + case $host_os in aix4.[012]|aix4.[012].*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && \ + strings "$collect2name" | grep resolve_lib_name >/dev/null + then + # We have reworked collect2 + : + else + # We have old collect2 + hardcode_direct=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + hardcode_minus_L=yes + hardcode_libdir_flag_spec='-L$libdir' + hardcode_libdir_separator= + fi + ;; + esac + shared_flag='-shared' + if test "$aix_use_runtimelinking" = yes; then + shared_flag="$shared_flag "'${wl}-G' + fi + else + # not using gcc + if test "$host_cpu" = ia64; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test "$aix_use_runtimelinking" = yes; then + shared_flag='${wl}-G' + else + shared_flag='${wl}-bM:SRE' + fi + fi + fi + + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to export. + always_export_symbols=yes + if test "$aix_use_runtimelinking" = yes; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + allow_undefined_flag='-berok' + # Determine the default libpath from the value encoded in an empty executable. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then + +lt_aix_libpath_sed=' + /Import File Strings/,/^$/ { + /^0/ { + s/^0 *\(.*\)$/\1/ + p + } + }' +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then + aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` +fi +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi + + hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" + archive_expsym_cmds="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" + else + if test "$host_cpu" = ia64; then + hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' + allow_undefined_flag="-z nodefs" + archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an empty executable. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then + +lt_aix_libpath_sed=' + /Import File Strings/,/^$/ { + /^0/ { + s/^0 *\(.*\)$/\1/ + p + } + }' +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then + aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` +fi +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi + + hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + no_undefined_flag=' ${wl}-bernotok' + allow_undefined_flag=' ${wl}-berok' + # Exported symbols can be pulled into shared objects from archives + whole_archive_flag_spec='$convenience' + archive_cmds_need_lc=yes + # This is similar to how AIX traditionally builds its shared libraries. + archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' + fi + fi + ;; + + amigaos*) + archive_cmds='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + # see comment about different semantics on the GNU ld section + ld_shlibs=no + ;; + + bsdi[45]*) + export_dynamic_flag_spec=-rdynamic + ;; + + cygwin* | mingw* | pw32*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + hardcode_libdir_flag_spec=' ' + allow_undefined_flag=unsupported + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=".dll" + # FIXME: Setting linknames here is a bad hack. + archive_cmds='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames=' + # The linker will automatically build a .lib file if we build a DLL. + old_archive_From_new_cmds='true' + # FIXME: Should let the user specify the lib program. + old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs' + fix_srcfile_path='`cygpath -w "$srcfile"`' + enable_shared_with_static_runtimes=yes + ;; + + darwin* | rhapsody*) + allow_undefined_flag="$_lt_dar_allow_undefined" + archive_cmds_need_lc=no + hardcode_direct=no + hardcode_automatic=yes + hardcode_shlibpath_var=unsupported + whole_archive_flag_spec='' + link_all_deplibs=yes + if test "$GCC" = yes ; then + output_verbose_link_cmd='echo' + archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" + module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" + archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" + module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" + else + case $cc_basename in + xlc*) + output_verbose_link_cmd='echo' + archive_cmds='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $xlcverstring' + module_cmds='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' + # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds + archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $xlcverstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + module_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + ;; + *) + ld_shlibs=no + ;; + esac + fi + ;; + + dgux*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_shlibpath_var=no + ;; + + freebsd1*) + ld_shlibs=no + ;; + + # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor + # support. Future versions do this automatically, but an explicit c++rt0.o + # does not break anything, and helps significantly (at the cost of a little + # extra space). + freebsd2.2*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + # Unfortunately, older versions of FreeBSD 2 do not have this feature. + freebsd2*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=yes + hardcode_minus_L=yes + hardcode_shlibpath_var=no + ;; + + # FreeBSD 3 and greater uses gcc -shared to do shared libraries. + freebsd* | dragonfly*) + archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + hpux9*) + if test "$GCC" = yes; then + archive_cmds='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + else + archive_cmds='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + fi + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_direct=yes + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + export_dynamic_flag_spec='${wl}-E' + ;; + + hpux10*) + if test "$GCC" = yes -a "$with_gnu_ld" = no; then + archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' + fi + if test "$with_gnu_ld" = no; then + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + + hardcode_direct=yes + export_dynamic_flag_spec='${wl}-E' + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + fi + ;; + + hpux11*) + if test "$GCC" = yes -a "$with_gnu_ld" = no; then + case $host_cpu in + hppa*64*) + archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + archive_cmds='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + else + case $host_cpu in + hppa*64*) + archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + fi + if test "$with_gnu_ld" = no; then + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + + case $host_cpu in + hppa*64*|ia64*) + hardcode_libdir_flag_spec_ld='+b $libdir' + hardcode_direct=no + hardcode_shlibpath_var=no + ;; + *) + hardcode_direct=yes + export_dynamic_flag_spec='${wl}-E' + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + ;; + esac + fi + ;; + + irix5* | irix6* | nonstopux*) + if test "$GCC" = yes; then + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + hardcode_libdir_flag_spec_ld='-rpath $libdir' + fi + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + link_all_deplibs=yes + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out + else + archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF + fi + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + newsos6) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=yes + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_shlibpath_var=no + ;; + + openbsd*) + if test -f /usr/libexec/ld.so; then + hardcode_direct=yes + hardcode_shlibpath_var=no + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + export_dynamic_flag_spec='${wl}-E' + else + case $host_os in + openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec='-R$libdir' + ;; + *) + archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + ;; + esac + fi + else + ld_shlibs=no + fi + ;; + + os2*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + allow_undefined_flag=unsupported + archive_cmds='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' + old_archive_From_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' + ;; + + osf3*) + if test "$GCC" = yes; then + allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + allow_undefined_flag=' -expect_unresolved \*' + archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + fi + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + + osf4* | osf5*) # as osf3* with the addition of -msym flag + if test "$GCC" = yes; then + allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + else + allow_undefined_flag=' -expect_unresolved \*' + archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~ + $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp' + + # Both c and cxx compiler support -rpath directly + hardcode_libdir_flag_spec='-rpath $libdir' + fi + hardcode_libdir_separator=: + ;; + + solaris*) + no_undefined_flag=' -z text' + if test "$GCC" = yes; then + wlarc='${wl}' + archive_cmds='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp' + else + wlarc='' + archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' + archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' + fi + hardcode_libdir_flag_spec='-R$libdir' + hardcode_shlibpath_var=no + case $host_os in + solaris2.[0-5] | solaris2.[0-5].*) ;; + *) + # The compiler driver will combine and reorder linker options, + # but understands `-z linker_flag'. GCC discards it without `$wl', + # but is careful enough not to reorder. + # Supported since Solaris 2.6 (maybe 2.5.1?) + if test "$GCC" = yes; then + whole_archive_flag_spec='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' + else + whole_archive_flag_spec='-z allextract$convenience -z defaultextract' + fi + ;; + esac + link_all_deplibs=yes + ;; + + sunos4*) + if test "x$host_vendor" = xsequent; then + # Use $CC to link under sequent, because it throws in some extra .o + # files that make .init and .fini sections work. + archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' + fi + hardcode_libdir_flag_spec='-L$libdir' + hardcode_direct=yes + hardcode_minus_L=yes + hardcode_shlibpath_var=no + ;; + + sysv4) + case $host_vendor in + sni) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=yes # is this really true??? + ;; + siemens) + ## LD is ld it makes a PLAMLIB + ## CC just makes a GrossModule. + archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' + reload_cmds='$CC -r -o $output$reload_objs' + hardcode_direct=no + ;; + motorola) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=no #Motorola manual says yes, but my tests say they lie + ;; + esac + runpath_var='LD_RUN_PATH' + hardcode_shlibpath_var=no + ;; + + sysv4.3*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var=no + export_dynamic_flag_spec='-Bexport' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var=no + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + ld_shlibs=yes + fi + ;; + + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) + no_undefined_flag='${wl}-z,text' + archive_cmds_need_lc=no + hardcode_shlibpath_var=no + runpath_var='LD_RUN_PATH' + + if test "$GCC" = yes; then + archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + sysv5* | sco3.2v5* | sco5v6*) + # Note: We can NOT use -z defs as we might desire, because we do not + # link with -lc, and that would cause any symbols used from libc to + # always be unresolved, which means just about no library would + # ever link correctly. If we're not using GNU ld we use -z text + # though, which does catch some bad symbols but isn't as heavy-handed + # as -z defs. + no_undefined_flag='${wl}-z,text' + allow_undefined_flag='${wl}-z,nodefs' + archive_cmds_need_lc=no + hardcode_shlibpath_var=no + hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`' + hardcode_libdir_separator=':' + link_all_deplibs=yes + export_dynamic_flag_spec='${wl}-Bexport' + runpath_var='LD_RUN_PATH' + + if test "$GCC" = yes; then + archive_cmds='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + uts4*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_shlibpath_var=no + ;; + + *) + ld_shlibs=no + ;; + esac + fi + +{ $as_echo "$as_me:$LINENO: result: $ld_shlibs" >&5 +$as_echo "$ld_shlibs" >&6; } +test "$ld_shlibs" = no && can_build_shared=no + +# +# Do we need to explicitly link libc? +# +case "x$archive_cmds_need_lc" in +x|xyes) + # Assume -lc should be added + archive_cmds_need_lc=yes + + if test "$enable_shared" = yes && test "$GCC" = yes; then + case $archive_cmds in + *'~'*) + # FIXME: we may have to deal with multi-command sequences. + ;; + '$CC '*) + # Test whether the compiler implicitly links with -lc since on some + # systems, -lgcc has to come before -lc. If gcc already passes -lc + # to ld, don't add -lc before -lgcc. + { $as_echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5 +$as_echo_n "checking whether -lc should be explicitly linked in... " >&6; } + $rm conftest* + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } 2>conftest.err; then + soname=conftest + lib=conftest + libobjs=conftest.$ac_objext + deplibs= + wl=$lt_prog_compiler_wl + pic_flag=$lt_prog_compiler_pic + compiler_flags=-v + linker_flags=-v + verstring= + output_objdir=. + libname=conftest + lt_save_allow_undefined_flag=$allow_undefined_flag + allow_undefined_flag= + if { (eval echo "$as_me:$LINENO: \"$archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5 + (eval $archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + then + archive_cmds_need_lc=no + else + archive_cmds_need_lc=yes + fi + allow_undefined_flag=$lt_save_allow_undefined_flag + else + cat conftest.err 1>&5 + fi + $rm conftest* + { $as_echo "$as_me:$LINENO: result: $archive_cmds_need_lc" >&5 +$as_echo "$archive_cmds_need_lc" >&6; } + ;; + esac + fi + ;; +esac + +{ $as_echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5 +$as_echo_n "checking dynamic linker characteristics... " >&6; } +library_names_spec= +libname_spec='lib$name' +soname_spec= +shrext_cmds=".so" +postinstall_cmds= +postuninstall_cmds= +finish_cmds= +finish_eval= +shlibpath_var= +shlibpath_overrides_runpath=unknown +version_type=none +dynamic_linker="$host_os ld.so" +sys_lib_dlsearch_path_spec="/lib /usr/lib" + +if test "$GCC" = yes; then + case $host_os in + darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; + *) lt_awk_arg="/^libraries:/" ;; + esac + lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if echo "$lt_search_path_spec" | grep ';' >/dev/null ; then + # if the path contains ";" then we assume it to be the separator + # otherwise default to the standard path separator (i.e. ":") - it is + # assumed that no part of a normal pathname contains ";" but that should + # okay in the real world where ";" in dirpaths is itself problematic. + lt_search_path_spec=`echo "$lt_search_path_spec" | $SED -e 's/;/ /g'` + else + lt_search_path_spec=`echo "$lt_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + # Ok, now we have the path, separated by spaces, we can step through it + # and add multilib dir if necessary. + lt_tmp_lt_search_path_spec= + lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` + for lt_sys_path in $lt_search_path_spec; do + if test -d "$lt_sys_path/$lt_multi_os_dir"; then + lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" + else + test -d "$lt_sys_path" && \ + lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" + fi + done + lt_search_path_spec=`echo $lt_tmp_lt_search_path_spec | awk ' +BEGIN {RS=" "; FS="/|\n";} { + lt_foo=""; + lt_count=0; + for (lt_i = NF; lt_i > 0; lt_i--) { + if ($lt_i != "" && $lt_i != ".") { + if ($lt_i == "..") { + lt_count++; + } else { + if (lt_count == 0) { + lt_foo="/" $lt_i lt_foo; + } else { + lt_count--; + } + } + } + } + if (lt_foo != "") { lt_freq[lt_foo]++; } + if (lt_freq[lt_foo] == 1) { print lt_foo; } +}'` + sys_lib_search_path_spec=`echo $lt_search_path_spec` +else + sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" +fi +need_lib_prefix=unknown +hardcode_into_libs=no + +# when you set need_version to no, make sure it does not cause -set_version +# flags to be left without arguments +need_version=unknown + +case $host_os in +aix3*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' + shlibpath_var=LIBPATH + + # AIX 3 has no versioning support, so we append a major version to the name. + soname_spec='${libname}${release}${shared_ext}$major' + ;; + +aix[4-9]*) + version_type=linux + need_lib_prefix=no + need_version=no + hardcode_into_libs=yes + if test "$host_cpu" = ia64; then + # AIX 5 supports IA64 + library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + else + # With GCC up to 2.95.x, collect2 would create an import file + # for dependence libraries. The import file would start with + # the line `#! .'. This would cause the generated library to + # depend on `.', always an invalid library. This was fixed in + # development snapshots of GCC prior to 3.0. + case $host_os in + aix4 | aix4.[01] | aix4.[01].*) + if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' + echo ' yes ' + echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then + : + else + can_build_shared=no + fi + ;; + esac + # AIX (on Power*) has no versioning support, so currently we can not hardcode correct + # soname into executable. Probably we can add versioning support to + # collect2, so additional links can be useful in future. + if test "$aix_use_runtimelinking" = yes; then + # If using run time linking (on AIX 4.2 or later) use lib<name>.so + # instead of lib<name>.a to let people know that these are not + # typical AIX shared libraries. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + else + # We preserve .a as extension for shared libraries through AIX4.2 + # and later when we are not doing run time linking. + library_names_spec='${libname}${release}.a $libname.a' + soname_spec='${libname}${release}${shared_ext}$major' + fi + shlibpath_var=LIBPATH + fi + ;; + +amigaos*) + library_names_spec='$libname.ixlibrary $libname.a' + # Create ${libname}_ixlibrary.a entries in /sys/libs. + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' + ;; + +beos*) + library_names_spec='${libname}${shared_ext}' + dynamic_linker="$host_os ld.so" + shlibpath_var=LIBRARY_PATH + ;; + +bsdi[45]*) + version_type=linux + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" + sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" + # the default ld.so.conf also contains /usr/contrib/lib and + # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow + # libtool to hard-code these into programs + ;; + +cygwin* | mingw* | pw32*) + version_type=windows + shrext_cmds=".dll" + need_version=no + need_lib_prefix=no + + case $GCC,$host_os in + yes,cygwin* | yes,mingw* | yes,pw32*) + library_names_spec='$libname.dll.a' + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \${file}`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname~ + chmod a+x \$dldir/$dlname' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $rm \$dlpath' + shlibpath_overrides_runpath=yes + + case $host_os in + cygwin*) + # Cygwin DLLs use 'cyg' prefix rather than 'lib' + soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" + ;; + mingw*) + # MinGW DLLs use traditional 'lib' prefix + soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then + # It is most probably a Windows format PATH printed by + # mingw gcc, but we are running on Cygwin. Gcc prints its search + # path with ; separators, and with drive letters. We can handle the + # drive letters (cygwin fileutils understands them), so leave them, + # especially as we might pass files found there to a mingw objdump, + # which wouldn't understand a cygwinified path. Ahh. + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + ;; + pw32*) + # pw32 DLLs use 'pw' prefix rather than 'lib' + library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + ;; + esac + ;; + + *) + library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' + ;; + esac + dynamic_linker='Win32 ld.exe' + # FIXME: first we should search . and the directory the executable is in + shlibpath_var=PATH + ;; + +darwin* | rhapsody*) + dynamic_linker="$host_os dyld" + version_type=darwin + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext' + soname_spec='${libname}${release}${major}$shared_ext' + shlibpath_overrides_runpath=yes + shlibpath_var=DYLD_LIBRARY_PATH + shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' + + sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib" + sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' + ;; + +dgux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +freebsd1*) + dynamic_linker=no + ;; + +freebsd* | dragonfly*) + # DragonFly does not have aout. When/if they implement a new + # versioning mechanism, adjust this. + if test -x /usr/bin/objformat; then + objformat=`/usr/bin/objformat` + else + case $host_os in + freebsd[123]*) objformat=aout ;; + *) objformat=elf ;; + esac + fi + version_type=freebsd-$objformat + case $version_type in + freebsd-elf*) + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + need_version=no + need_lib_prefix=no + ;; + freebsd-*) + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' + need_version=yes + ;; + esac + shlibpath_var=LD_LIBRARY_PATH + case $host_os in + freebsd2*) + shlibpath_overrides_runpath=yes + ;; + freebsd3.[01]* | freebsdelf3.[01]*) + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ + freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + *) # from 4.6 on, and DragonFly + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + esac + ;; + +gnu*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + hardcode_into_libs=yes + ;; + +hpux9* | hpux10* | hpux11*) + # Give a soname corresponding to the major version so that dld.sl refuses to + # link against other versions. + version_type=sunos + need_lib_prefix=no + need_version=no + case $host_cpu in + ia64*) + shrext_cmds='.so' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.so" + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + if test "X$HPUX_IA64_MODE" = X32; then + sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" + else + sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" + fi + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + hppa*64*) + shrext_cmds='.sl' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.sl" + shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + *) + shrext_cmds='.sl' + dynamic_linker="$host_os dld.sl" + shlibpath_var=SHLIB_PATH + shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + ;; + esac + # HP-UX runs *really* slowly unless shared libraries are mode 555. + postinstall_cmds='chmod 555 $lib' + ;; + +interix[3-9]*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + +irix5* | irix6* | nonstopux*) + case $host_os in + nonstopux*) version_type=nonstopux ;; + *) + if test "$lt_cv_prog_gnu_ld" = yes; then + version_type=linux + else + version_type=irix + fi ;; + esac + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' + case $host_os in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in # libtool.m4 will add one of these switches to LD + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") + libsuff= shlibsuff= libmagic=32-bit;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") + libsuff=32 shlibsuff=N32 libmagic=N32;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") + libsuff=64 shlibsuff=64 libmagic=64-bit;; + *) libsuff= shlibsuff= libmagic=never-match;; + esac + ;; + esac + shlibpath_var=LD_LIBRARY${shlibsuff}_PATH + shlibpath_overrides_runpath=no + sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" + sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" + hardcode_into_libs=yes + ;; + +# No shared lib support for Linux oldld, aout, or coff. +linux*oldld* | linux*aout* | linux*coff*) + dynamic_linker=no + ;; + +# This must be Linux ELF. +linux* | k*bsd*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + # Append ld.so.conf contents to the search path + if test -f /etc/ld.so.conf; then + lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` + sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" + fi + + # We used to test for /lib/ld.so.1 and disable shared libraries on + # powerpc, because MkLinux only supported shared libraries with the + # GNU dynamic linker. Since this was broken with cross compilers, + # most powerpc-linux boxes support dynamic linking these days and + # people can always --disable-shared, the test was removed, and we + # assume the GNU/Linux dynamic linker is in use. + dynamic_linker='GNU/Linux ld.so' + ;; + +netbsd*) + version_type=sunos + need_lib_prefix=no + need_version=no + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + dynamic_linker='NetBSD (a.out) ld.so' + else + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='NetBSD ld.elf_so' + fi + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + +newsos6) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +nto-qnx*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +openbsd*) + version_type=sunos + sys_lib_dlsearch_path_spec="/usr/lib" + need_lib_prefix=no + # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. + case $host_os in + openbsd3.3 | openbsd3.3.*) need_version=yes ;; + *) need_version=no ;; + esac + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + shlibpath_var=LD_LIBRARY_PATH + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + case $host_os in + openbsd2.[89] | openbsd2.[89].*) + shlibpath_overrides_runpath=no + ;; + *) + shlibpath_overrides_runpath=yes + ;; + esac + else + shlibpath_overrides_runpath=yes + fi + ;; + +os2*) + libname_spec='$name' + shrext_cmds=".dll" + need_lib_prefix=no + library_names_spec='$libname${shared_ext} $libname.a' + dynamic_linker='OS/2 ld.exe' + shlibpath_var=LIBPATH + ;; + +osf3* | osf4* | osf5*) + version_type=osf + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" + sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" + ;; + +rdos*) + dynamic_linker=no + ;; + +solaris*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + # ldd complains unless libraries are executable + postinstall_cmds='chmod +x $lib' + ;; + +sunos4*) + version_type=sunos + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + if test "$with_gnu_ld" = yes; then + need_lib_prefix=no + fi + need_version=yes + ;; + +sysv4 | sysv4.3*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + case $host_vendor in + sni) + shlibpath_overrides_runpath=no + need_lib_prefix=no + export_dynamic_flag_spec='${wl}-Blargedynsym' + runpath_var=LD_RUN_PATH + ;; + siemens) + need_lib_prefix=no + ;; + motorola) + need_lib_prefix=no + need_version=no + shlibpath_overrides_runpath=no + sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' + ;; + esac + ;; + +sysv4*MP*) + if test -d /usr/nec ;then + version_type=linux + library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' + soname_spec='$libname${shared_ext}.$major' + shlibpath_var=LD_LIBRARY_PATH + fi + ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + version_type=freebsd-elf + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + hardcode_into_libs=yes + if test "$with_gnu_ld" = yes; then + sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' + shlibpath_overrides_runpath=no + else + sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' + shlibpath_overrides_runpath=yes + case $host_os in + sco3.2v5*) + sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" + ;; + esac + fi + sys_lib_dlsearch_path_spec='/usr/lib' + ;; + +uts4*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +*) + dynamic_linker=no + ;; +esac +{ $as_echo "$as_me:$LINENO: result: $dynamic_linker" >&5 +$as_echo "$dynamic_linker" >&6; } +test "$dynamic_linker" = no && can_build_shared=no + +if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then + $as_echo_n "(cached) " >&6 +else + lt_cv_sys_lib_search_path_spec="$sys_lib_search_path_spec" +fi + +sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" +if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then + $as_echo_n "(cached) " >&6 +else + lt_cv_sys_lib_dlsearch_path_spec="$sys_lib_dlsearch_path_spec" +fi + +sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" + +variables_saved_for_relink="PATH $shlibpath_var $runpath_var" +if test "$GCC" = yes; then + variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" +fi + +{ $as_echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5 +$as_echo_n "checking how to hardcode library paths into programs... " >&6; } +hardcode_action= +if test -n "$hardcode_libdir_flag_spec" || \ + test -n "$runpath_var" || \ + test "X$hardcode_automatic" = "Xyes" ; then + + # We can hardcode non-existant directories. + if test "$hardcode_direct" != no && + # If the only mechanism to avoid hardcoding is shlibpath_var, we + # have to relink, otherwise we might link with an installed library + # when we should be linking with a yet-to-be-installed one + ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, )" != no && + test "$hardcode_minus_L" != no; then + # Linking always hardcodes the temporary library directory. + hardcode_action=relink + else + # We can link without hardcoding, and we can hardcode nonexisting dirs. + hardcode_action=immediate + fi +else + # We cannot hardcode anything, or else we can only hardcode existing + # directories. + hardcode_action=unsupported +fi +{ $as_echo "$as_me:$LINENO: result: $hardcode_action" >&5 +$as_echo "$hardcode_action" >&6; } + +if test "$hardcode_action" = relink; then + # Fast installation is not supported + enable_fast_install=no +elif test "$shlibpath_overrides_runpath" = yes || + test "$enable_shared" = no; then + # Fast installation is not necessary + enable_fast_install=needless +fi + +striplib= +old_striplib= +{ $as_echo "$as_me:$LINENO: checking whether stripping libraries is possible" >&5 +$as_echo_n "checking whether stripping libraries is possible... " >&6; } +if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then + test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" + test -z "$striplib" && striplib="$STRIP --strip-unneeded" + { $as_echo "$as_me:$LINENO: result: yes" >&5 +$as_echo "yes" >&6; } +else +# FIXME - insert some real tests, host_os isn't really good enough + case $host_os in + darwin*) + if test -n "$STRIP" ; then + striplib="$STRIP -x" + old_striplib="$STRIP -S" + { $as_echo "$as_me:$LINENO: result: yes" >&5 +$as_echo "yes" >&6; } + else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + ;; + *) + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } + ;; + esac +fi + +if test "x$enable_dlopen" != xyes; then + enable_dlopen=unknown + enable_dlopen_self=unknown + enable_dlopen_self_static=unknown +else + lt_cv_dlopen=no + lt_cv_dlopen_libs= + + case $host_os in + beos*) + lt_cv_dlopen="load_add_on" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ;; + + mingw* | pw32*) + lt_cv_dlopen="LoadLibrary" + lt_cv_dlopen_libs= + ;; + + cygwin*) + lt_cv_dlopen="dlopen" + lt_cv_dlopen_libs= + ;; + + darwin*) + # if libdl is installed we need to link against it + { $as_echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5 +$as_echo_n "checking for dlopen in -ldl... " >&6; } +if test "${ac_cv_lib_dl_dlopen+set}" = set; then + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldl $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char dlopen (); +int +main () +{ +return dlopen (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then + ac_cv_lib_dl_dlopen=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_dl_dlopen=no +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5 +$as_echo "$ac_cv_lib_dl_dlopen" >&6; } +if test "x$ac_cv_lib_dl_dlopen" = x""yes; then + lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" +else + + lt_cv_dlopen="dyld" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + +fi + + ;; + + *) + { $as_echo "$as_me:$LINENO: checking for shl_load" >&5 +$as_echo_n "checking for shl_load... " >&6; } +if test "${ac_cv_func_shl_load+set}" = set; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define shl_load to an innocuous variant, in case <limits.h> declares shl_load. + For example, HP-UX 11i <limits.h> declares gettimeofday. */ +#define shl_load innocuous_shl_load + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char shl_load (); below. + Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + <limits.h> exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#endif + +#undef shl_load + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char shl_load (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_shl_load || defined __stub___shl_load +choke me +#endif + +int +main () +{ +return shl_load (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then + ac_cv_func_shl_load=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_func_shl_load=no +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_func_shl_load" >&5 +$as_echo "$ac_cv_func_shl_load" >&6; } +if test "x$ac_cv_func_shl_load" = x""yes; then + lt_cv_dlopen="shl_load" +else + { $as_echo "$as_me:$LINENO: checking for shl_load in -ldld" >&5 +$as_echo_n "checking for shl_load in -ldld... " >&6; } +if test "${ac_cv_lib_dld_shl_load+set}" = set; then + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldld $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char shl_load (); +int +main () +{ +return shl_load (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then + ac_cv_lib_dld_shl_load=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_dld_shl_load=no +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_dld_shl_load" >&5 +$as_echo "$ac_cv_lib_dld_shl_load" >&6; } +if test "x$ac_cv_lib_dld_shl_load" = x""yes; then + lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld" +else + { $as_echo "$as_me:$LINENO: checking for dlopen" >&5 +$as_echo_n "checking for dlopen... " >&6; } +if test "${ac_cv_func_dlopen+set}" = set; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define dlopen to an innocuous variant, in case <limits.h> declares dlopen. + For example, HP-UX 11i <limits.h> declares gettimeofday. */ +#define dlopen innocuous_dlopen + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char dlopen (); below. + Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + <limits.h> exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#endif + +#undef dlopen + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char dlopen (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_dlopen || defined __stub___dlopen +choke me +#endif + +int +main () +{ +return dlopen (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then + ac_cv_func_dlopen=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_func_dlopen=no +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_func_dlopen" >&5 +$as_echo "$ac_cv_func_dlopen" >&6; } +if test "x$ac_cv_func_dlopen" = x""yes; then + lt_cv_dlopen="dlopen" +else + { $as_echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5 +$as_echo_n "checking for dlopen in -ldl... " >&6; } +if test "${ac_cv_lib_dl_dlopen+set}" = set; then + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldl $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char dlopen (); +int +main () +{ +return dlopen (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then + ac_cv_lib_dl_dlopen=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_dl_dlopen=no +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5 +$as_echo "$ac_cv_lib_dl_dlopen" >&6; } +if test "x$ac_cv_lib_dl_dlopen" = x""yes; then + lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" +else + { $as_echo "$as_me:$LINENO: checking for dlopen in -lsvld" >&5 +$as_echo_n "checking for dlopen in -lsvld... " >&6; } +if test "${ac_cv_lib_svld_dlopen+set}" = set; then + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lsvld $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char dlopen (); +int +main () +{ +return dlopen (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then + ac_cv_lib_svld_dlopen=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_svld_dlopen=no +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_svld_dlopen" >&5 +$as_echo "$ac_cv_lib_svld_dlopen" >&6; } +if test "x$ac_cv_lib_svld_dlopen" = x""yes; then + lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld" +else + { $as_echo "$as_me:$LINENO: checking for dld_link in -ldld" >&5 +$as_echo_n "checking for dld_link in -ldld... " >&6; } +if test "${ac_cv_lib_dld_dld_link+set}" = set; then + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldld $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char dld_link (); +int +main () +{ +return dld_link (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then + ac_cv_lib_dld_dld_link=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_dld_dld_link=no +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_dld_dld_link" >&5 +$as_echo "$ac_cv_lib_dld_dld_link" >&6; } +if test "x$ac_cv_lib_dld_dld_link" = x""yes; then + lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld" +fi + + +fi + + +fi + + +fi + + +fi + + +fi + + ;; + esac + + if test "x$lt_cv_dlopen" != xno; then + enable_dlopen=yes + else + enable_dlopen=no + fi + + case $lt_cv_dlopen in + dlopen) + save_CPPFLAGS="$CPPFLAGS" + test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" + + save_LDFLAGS="$LDFLAGS" + wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" + + save_LIBS="$LIBS" + LIBS="$lt_cv_dlopen_libs $LIBS" + + { $as_echo "$as_me:$LINENO: checking whether a program can dlopen itself" >&5 +$as_echo_n "checking whether a program can dlopen itself... " >&6; } +if test "${lt_cv_dlopen_self+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + lt_cv_dlopen_self=cross +else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext <<EOF +#line 10122 "configure" +#include "confdefs.h" + +#if HAVE_DLFCN_H +#include <dlfcn.h> +#endif + +#include <stdio.h> + +#ifdef RTLD_GLOBAL +# define LT_DLGLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LT_DLGLOBAL DL_GLOBAL +# else +# define LT_DLGLOBAL 0 +# endif +#endif + +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LT_DLLAZY_OR_NOW +# ifdef RTLD_LAZY +# define LT_DLLAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LT_DLLAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LT_DLLAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LT_DLLAZY_OR_NOW DL_NOW +# else +# define LT_DLLAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +#ifdef __cplusplus +extern "C" void exit (int); +#endif + +void fnord() { int i=42;} +int main () +{ + void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); + int status = $lt_dlunknown; + + if (self) + { + if (dlsym (self,"fnord")) status = $lt_dlno_uscore; + else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + /* dlclose (self); */ + } + else + puts (dlerror ()); + + exit (status); +} +EOF + if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then + (./conftest; exit; ) >&5 2>/dev/null + lt_status=$? + case x$lt_status in + x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; + x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; + x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;; + esac + else : + # compilation failed + lt_cv_dlopen_self=no + fi +fi +rm -fr conftest* + + +fi +{ $as_echo "$as_me:$LINENO: result: $lt_cv_dlopen_self" >&5 +$as_echo "$lt_cv_dlopen_self" >&6; } + + if test "x$lt_cv_dlopen_self" = xyes; then + wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" + { $as_echo "$as_me:$LINENO: checking whether a statically linked program can dlopen itself" >&5 +$as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; } +if test "${lt_cv_dlopen_self_static+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + lt_cv_dlopen_self_static=cross +else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext <<EOF +#line 10222 "configure" +#include "confdefs.h" + +#if HAVE_DLFCN_H +#include <dlfcn.h> +#endif + +#include <stdio.h> + +#ifdef RTLD_GLOBAL +# define LT_DLGLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LT_DLGLOBAL DL_GLOBAL +# else +# define LT_DLGLOBAL 0 +# endif +#endif + +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LT_DLLAZY_OR_NOW +# ifdef RTLD_LAZY +# define LT_DLLAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LT_DLLAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LT_DLLAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LT_DLLAZY_OR_NOW DL_NOW +# else +# define LT_DLLAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +#ifdef __cplusplus +extern "C" void exit (int); +#endif + +void fnord() { int i=42;} +int main () +{ + void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); + int status = $lt_dlunknown; + + if (self) + { + if (dlsym (self,"fnord")) status = $lt_dlno_uscore; + else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + /* dlclose (self); */ + } + else + puts (dlerror ()); + + exit (status); +} +EOF + if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then + (./conftest; exit; ) >&5 2>/dev/null + lt_status=$? + case x$lt_status in + x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; + x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; + x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;; + esac + else : + # compilation failed + lt_cv_dlopen_self_static=no + fi +fi +rm -fr conftest* + + +fi +{ $as_echo "$as_me:$LINENO: result: $lt_cv_dlopen_self_static" >&5 +$as_echo "$lt_cv_dlopen_self_static" >&6; } + fi + + CPPFLAGS="$save_CPPFLAGS" + LDFLAGS="$save_LDFLAGS" + LIBS="$save_LIBS" + ;; + esac + + case $lt_cv_dlopen_self in + yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; + *) enable_dlopen_self=unknown ;; + esac + + case $lt_cv_dlopen_self_static in + yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; + *) enable_dlopen_self_static=unknown ;; + esac +fi + + +# Report which library types will actually be built +{ $as_echo "$as_me:$LINENO: checking if libtool supports shared libraries" >&5 +$as_echo_n "checking if libtool supports shared libraries... " >&6; } +{ $as_echo "$as_me:$LINENO: result: $can_build_shared" >&5 +$as_echo "$can_build_shared" >&6; } + +{ $as_echo "$as_me:$LINENO: checking whether to build shared libraries" >&5 +$as_echo_n "checking whether to build shared libraries... " >&6; } +test "$can_build_shared" = "no" && enable_shared=no + +# On AIX, shared libraries and static libraries use the same namespace, and +# are all built from PIC. +case $host_os in +aix3*) + test "$enable_shared" = yes && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + +aix[4-9]*) + if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then + test "$enable_shared" = yes && enable_static=no + fi + ;; +esac +{ $as_echo "$as_me:$LINENO: result: $enable_shared" >&5 +$as_echo "$enable_shared" >&6; } + +{ $as_echo "$as_me:$LINENO: checking whether to build static libraries" >&5 +$as_echo_n "checking whether to build static libraries... " >&6; } +# Make sure either enable_shared or enable_static is yes. +test "$enable_shared" = yes || enable_static=yes +{ $as_echo "$as_me:$LINENO: result: $enable_static" >&5 +$as_echo "$enable_static" >&6; } + +# The else clause should only fire when bootstrapping the +# libtool distribution, otherwise you forgot to ship ltmain.sh +# with your package, and you will get complaints that there are +# no rules to generate ltmain.sh. +if test -f "$ltmain"; then + # See if we are running on zsh, and set the options which allow our commands through + # without removal of \ escapes. + if test -n "${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST + fi + # Now quote all the things that may contain metacharacters while being + # careful not to overquote the AC_SUBSTed values. We take copies of the + # variables and quote the copies for generation of the libtool script. + for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \ + SED SHELL STRIP \ + libname_spec library_names_spec soname_spec extract_expsyms_cmds \ + old_striplib striplib file_magic_cmd finish_cmds finish_eval \ + deplibs_check_method reload_flag reload_cmds need_locks \ + lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \ + lt_cv_sys_global_symbol_to_c_name_address \ + sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ + old_postinstall_cmds old_postuninstall_cmds \ + compiler \ + CC \ + LD \ + lt_prog_compiler_wl \ + lt_prog_compiler_pic \ + lt_prog_compiler_static \ + lt_prog_compiler_no_builtin_flag \ + export_dynamic_flag_spec \ + thread_safe_flag_spec \ + whole_archive_flag_spec \ + enable_shared_with_static_runtimes \ + old_archive_cmds \ + old_archive_from_new_cmds \ + predep_objects \ + postdep_objects \ + predeps \ + postdeps \ + compiler_lib_search_path \ + compiler_lib_search_dirs \ + archive_cmds \ + archive_expsym_cmds \ + postinstall_cmds \ + postuninstall_cmds \ + old_archive_from_expsyms_cmds \ + allow_undefined_flag \ + no_undefined_flag \ + export_symbols_cmds \ + hardcode_libdir_flag_spec \ + hardcode_libdir_flag_spec_ld \ + hardcode_libdir_separator \ + hardcode_automatic \ + module_cmds \ + module_expsym_cmds \ + lt_cv_prog_compiler_c_o \ + fix_srcfile_path \ + exclude_expsyms \ + include_expsyms; do + + case $var in + old_archive_cmds | \ + old_archive_from_new_cmds | \ + archive_cmds | \ + archive_expsym_cmds | \ + module_cmds | \ + module_expsym_cmds | \ + old_archive_from_expsyms_cmds | \ + export_symbols_cmds | \ + extract_expsyms_cmds | reload_cmds | finish_cmds | \ + postinstall_cmds | postuninstall_cmds | \ + old_postinstall_cmds | old_postuninstall_cmds | \ + sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) + # Double-quote double-evaled strings. + eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" + ;; + *) + eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" + ;; + esac + done + + case $lt_echo in + *'\$0 --fallback-echo"') + lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'` + ;; + esac + +cfgfile="${ofile}T" + trap "$rm \"$cfgfile\"; exit 1" 1 2 15 + $rm -f "$cfgfile" + { $as_echo "$as_me:$LINENO: creating $ofile" >&5 +$as_echo "$as_me: creating $ofile" >&6;} + + cat <<__EOF__ >> "$cfgfile" +#! $SHELL + +# `$echo "$cfgfile" | sed 's%^.*/%%'` - Provide generalized library-building support services. +# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP) +# NOTE: Changes made to this file will be lost: look at ltmain.sh. +# +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 +# Free Software Foundation, Inc. +# +# This file is part of GNU Libtool: +# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# A sed program that does not truncate output. +SED=$lt_SED + +# Sed that helps us avoid accidentally triggering echo(1) options like -n. +Xsed="$SED -e 1s/^X//" + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +# The names of the tagged configurations supported by this script. +available_tags= + +# ### BEGIN LIBTOOL CONFIG + +# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: + +# Shell to use when invoking shell scripts. +SHELL=$lt_SHELL + +# Whether or not to build shared libraries. +build_libtool_libs=$enable_shared + +# Whether or not to build static libraries. +build_old_libs=$enable_static + +# Whether or not to add -lc for building shared libraries. +build_libtool_need_lc=$archive_cmds_need_lc + +# Whether or not to disallow shared libs when runtime libs are static +allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes + +# Whether or not to optimize for fast installation. +fast_install=$enable_fast_install + +# The host system. +host_alias=$host_alias +host=$host +host_os=$host_os + +# The build system. +build_alias=$build_alias +build=$build +build_os=$build_os + +# An echo program that does not interpret backslashes. +echo=$lt_echo + +# The archiver. +AR=$lt_AR +AR_FLAGS=$lt_AR_FLAGS + +# A C compiler. +LTCC=$lt_LTCC + +# LTCC compiler flags. +LTCFLAGS=$lt_LTCFLAGS + +# A language-specific compiler. +CC=$lt_compiler + +# Is the compiler the GNU C compiler? +with_gcc=$GCC + +# An ERE matcher. +EGREP=$lt_EGREP + +# The linker used to build libraries. +LD=$lt_LD + +# Whether we need hard or soft links. +LN_S=$lt_LN_S + +# A BSD-compatible nm program. +NM=$lt_NM + +# A symbol stripping program +STRIP=$lt_STRIP + +# Used to examine libraries when file_magic_cmd begins "file" +MAGIC_CMD=$MAGIC_CMD + +# Used on cygwin: DLL creation program. +DLLTOOL="$DLLTOOL" + +# Used on cygwin: object dumper. +OBJDUMP="$OBJDUMP" + +# Used on cygwin: assembler. +AS="$AS" + +# The name of the directory that contains temporary libtool files. +objdir=$objdir + +# How to create reloadable object files. +reload_flag=$lt_reload_flag +reload_cmds=$lt_reload_cmds + +# How to pass a linker flag through the compiler. +wl=$lt_lt_prog_compiler_wl + +# Object file suffix (normally "o"). +objext="$ac_objext" + +# Old archive suffix (normally "a"). +libext="$libext" + +# Shared library suffix (normally ".so"). +shrext_cmds='$shrext_cmds' + +# Executable file suffix (normally ""). +exeext="$exeext" + +# Additional compiler flags for building library objects. +pic_flag=$lt_lt_prog_compiler_pic +pic_mode=$pic_mode + +# What is the maximum length of a command? +max_cmd_len=$lt_cv_sys_max_cmd_len + +# Does compiler simultaneously support -c and -o options? +compiler_c_o=$lt_lt_cv_prog_compiler_c_o + +# Must we lock files when doing compilation? +need_locks=$lt_need_locks + +# Do we need the lib prefix for modules? +need_lib_prefix=$need_lib_prefix + +# Do we need a version for libraries? +need_version=$need_version + +# Whether dlopen is supported. +dlopen_support=$enable_dlopen + +# Whether dlopen of programs is supported. +dlopen_self=$enable_dlopen_self + +# Whether dlopen of statically linked programs is supported. +dlopen_self_static=$enable_dlopen_self_static + +# Compiler flag to prevent dynamic linking. +link_static_flag=$lt_lt_prog_compiler_static + +# Compiler flag to turn off builtin functions. +no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag + +# Compiler flag to allow reflexive dlopens. +export_dynamic_flag_spec=$lt_export_dynamic_flag_spec + +# Compiler flag to generate shared objects directly from archives. +whole_archive_flag_spec=$lt_whole_archive_flag_spec + +# Compiler flag to generate thread-safe objects. +thread_safe_flag_spec=$lt_thread_safe_flag_spec + +# Library versioning type. +version_type=$version_type + +# Format of library name prefix. +libname_spec=$lt_libname_spec + +# List of archive names. First name is the real one, the rest are links. +# The last name is the one that the linker finds with -lNAME. +library_names_spec=$lt_library_names_spec + +# The coded name of the library, if different from the real name. +soname_spec=$lt_soname_spec + +# Commands used to build and install an old-style archive. +RANLIB=$lt_RANLIB +old_archive_cmds=$lt_old_archive_cmds +old_postinstall_cmds=$lt_old_postinstall_cmds +old_postuninstall_cmds=$lt_old_postuninstall_cmds + +# Create an old-style archive from a shared archive. +old_archive_from_new_cmds=$lt_old_archive_from_new_cmds + +# Create a temporary old-style archive to link instead of a shared archive. +old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds + +# Commands used to build and install a shared archive. +archive_cmds=$lt_archive_cmds +archive_expsym_cmds=$lt_archive_expsym_cmds +postinstall_cmds=$lt_postinstall_cmds +postuninstall_cmds=$lt_postuninstall_cmds + +# Commands used to build a loadable module (assumed same as above if empty) +module_cmds=$lt_module_cmds +module_expsym_cmds=$lt_module_expsym_cmds + +# Commands to strip libraries. +old_striplib=$lt_old_striplib +striplib=$lt_striplib + +# Dependencies to place before the objects being linked to create a +# shared library. +predep_objects=$lt_predep_objects + +# Dependencies to place after the objects being linked to create a +# shared library. +postdep_objects=$lt_postdep_objects + +# Dependencies to place before the objects being linked to create a +# shared library. +predeps=$lt_predeps + +# Dependencies to place after the objects being linked to create a +# shared library. +postdeps=$lt_postdeps + +# The directories searched by this compiler when creating a shared +# library +compiler_lib_search_dirs=$lt_compiler_lib_search_dirs + +# The library search path used internally by the compiler when linking +# a shared library. +compiler_lib_search_path=$lt_compiler_lib_search_path + +# Method to check whether dependent libraries are shared objects. +deplibs_check_method=$lt_deplibs_check_method + +# Command to use when deplibs_check_method == file_magic. +file_magic_cmd=$lt_file_magic_cmd + +# Flag that allows shared libraries with undefined symbols to be built. +allow_undefined_flag=$lt_allow_undefined_flag + +# Flag that forces no undefined symbols. +no_undefined_flag=$lt_no_undefined_flag + +# Commands used to finish a libtool library installation in a directory. +finish_cmds=$lt_finish_cmds + +# Same as above, but a single script fragment to be evaled but not shown. +finish_eval=$lt_finish_eval + +# Take the output of nm and produce a listing of raw symbols and C names. +global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe + +# Transform the output of nm in a proper C declaration +global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl + +# Transform the output of nm in a C name address pair +global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address + +# This is the shared library runtime path variable. +runpath_var=$runpath_var + +# This is the shared library path variable. +shlibpath_var=$shlibpath_var + +# Is shlibpath searched before the hard-coded library search path? +shlibpath_overrides_runpath=$shlibpath_overrides_runpath + +# How to hardcode a shared library path into an executable. +hardcode_action=$hardcode_action + +# Whether we should hardcode library paths into libraries. +hardcode_into_libs=$hardcode_into_libs + +# Flag to hardcode \$libdir into a binary during linking. +# This must work even if \$libdir does not exist. +hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec + +# If ld is used when linking, flag to hardcode \$libdir into +# a binary during linking. This must work even if \$libdir does +# not exist. +hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld + +# Whether we need a single -rpath flag with a separated argument. +hardcode_libdir_separator=$lt_hardcode_libdir_separator + +# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the +# resulting binary. +hardcode_direct=$hardcode_direct + +# Set to yes if using the -LDIR flag during linking hardcodes DIR into the +# resulting binary. +hardcode_minus_L=$hardcode_minus_L + +# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into +# the resulting binary. +hardcode_shlibpath_var=$hardcode_shlibpath_var + +# Set to yes if building a shared library automatically hardcodes DIR into the library +# and all subsequent libraries and executables linked against it. +hardcode_automatic=$hardcode_automatic + +# Variables whose values should be saved in libtool wrapper scripts and +# restored at relink time. +variables_saved_for_relink="$variables_saved_for_relink" + +# Whether libtool must link a program against all its dependency libraries. +link_all_deplibs=$link_all_deplibs + +# Compile-time system search path for libraries +sys_lib_search_path_spec=$lt_sys_lib_search_path_spec + +# Run-time system search path for libraries +sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec + +# Fix the shell variable \$srcfile for the compiler. +fix_srcfile_path=$lt_fix_srcfile_path + +# Set to yes if exported symbols are required. +always_export_symbols=$always_export_symbols + +# The commands to list exported symbols. +export_symbols_cmds=$lt_export_symbols_cmds + +# The commands to extract the exported symbol list from a shared archive. +extract_expsyms_cmds=$lt_extract_expsyms_cmds + +# Symbols that should not be listed in the preloaded symbols. +exclude_expsyms=$lt_exclude_expsyms + +# Symbols that must always be exported. +include_expsyms=$lt_include_expsyms + +# ### END LIBTOOL CONFIG + +__EOF__ + + + case $host_os in + aix3*) + cat <<\EOF >> "$cfgfile" + +# AIX sometimes has problems with the GCC collect2 program. For some +# reason, if we set the COLLECT_NAMES environment variable, the problems +# vanish in a puff of smoke. +if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES +fi +EOF + ;; + esac + + # We use sed instead of cat because bash on DJGPP gets confused if + # if finds mixed CR/LF and LF-only lines. Since sed operates in + # text mode, it properly converts lines to CR/LF. This bash problem + # is reportedly fixed, but why not run on old versions too? + sed '$q' "$ltmain" >> "$cfgfile" || (rm -f "$cfgfile"; exit 1) + + mv -f "$cfgfile" "$ofile" || \ + (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") + chmod +x "$ofile" + +else + # If there is no Makefile yet, we rely on a make rule to execute + # `config.status --recheck' to rerun these tests and create the + # libtool script then. + ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'` + if test -f "$ltmain_in"; then + test -f Makefile && make "$ltmain" + fi +fi + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +CC="$lt_save_CC" + + +# Check whether --with-tags was given. +if test "${with_tags+set}" = set; then + withval=$with_tags; tagnames="$withval" +fi + + +if test -f "$ltmain" && test -n "$tagnames"; then + if test ! -f "${ofile}"; then + { $as_echo "$as_me:$LINENO: WARNING: output file \`$ofile' does not exist" >&5 +$as_echo "$as_me: WARNING: output file \`$ofile' does not exist" >&2;} + fi + + if test -z "$LTCC"; then + eval "`$SHELL ${ofile} --config | grep '^LTCC='`" + if test -z "$LTCC"; then + { $as_echo "$as_me:$LINENO: WARNING: output file \`$ofile' does not look like a libtool script" >&5 +$as_echo "$as_me: WARNING: output file \`$ofile' does not look like a libtool script" >&2;} + else + { $as_echo "$as_me:$LINENO: WARNING: using \`LTCC=$LTCC', extracted from \`$ofile'" >&5 +$as_echo "$as_me: WARNING: using \`LTCC=$LTCC', extracted from \`$ofile'" >&2;} + fi + fi + if test -z "$LTCFLAGS"; then + eval "`$SHELL ${ofile} --config | grep '^LTCFLAGS='`" + fi + + # Extract list of available tagged configurations in $ofile. + # Note that this assumes the entire list is on one line. + available_tags=`grep "^available_tags=" "${ofile}" | $SED -e 's/available_tags=\(.*$\)/\1/' -e 's/\"//g'` + + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for tagname in $tagnames; do + IFS="$lt_save_ifs" + # Check whether tagname contains only valid characters + case `$echo "X$tagname" | $Xsed -e 's:[-_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,/]::g'` in + "") ;; + *) { { $as_echo "$as_me:$LINENO: error: invalid tag name: $tagname" >&5 +$as_echo "$as_me: error: invalid tag name: $tagname" >&2;} + { (exit 1); exit 1; }; } + ;; + esac + + if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "${ofile}" > /dev/null + then + { { $as_echo "$as_me:$LINENO: error: tag name \"$tagname\" already exists" >&5 +$as_echo "$as_me: error: tag name \"$tagname\" already exists" >&2;} + { (exit 1); exit 1; }; } + fi + + # Update the list of available tags. + if test -n "$tagname"; then + echo appending configuration tag \"$tagname\" to $ofile + + case $tagname in + CXX) + if test -n "$CXX" && ( test "X$CXX" != "Xno" && + ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || + (test "X$CXX" != "Xg++"))) ; then + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + + + +archive_cmds_need_lc_CXX=no +allow_undefined_flag_CXX= +always_export_symbols_CXX=no +archive_expsym_cmds_CXX= +export_dynamic_flag_spec_CXX= +hardcode_direct_CXX=no +hardcode_libdir_flag_spec_CXX= +hardcode_libdir_flag_spec_ld_CXX= +hardcode_libdir_separator_CXX= +hardcode_minus_L_CXX=no +hardcode_shlibpath_var_CXX=unsupported +hardcode_automatic_CXX=no +module_cmds_CXX= +module_expsym_cmds_CXX= +link_all_deplibs_CXX=unknown +old_archive_cmds_CXX=$old_archive_cmds +no_undefined_flag_CXX= +whole_archive_flag_spec_CXX= +enable_shared_with_static_runtimes_CXX=no + +# Dependencies to place before and after the object being linked: +predep_objects_CXX= +postdep_objects_CXX= +predeps_CXX= +postdeps_CXX= +compiler_lib_search_path_CXX= +compiler_lib_search_dirs_CXX= + +# Source file extension for C++ test sources. +ac_ext=cpp + +# Object file extension for compiled C++ test sources. +objext=o +objext_CXX=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="int some_variable = 0;" + +# Code to be used in simple link tests +lt_simple_link_test_code='int main(int, char *[]) { return(0); }' + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# If no C compiler flags were specified, use CFLAGS. +LTCFLAGS=${LTCFLAGS-"$CFLAGS"} + +# Allow CC to be a program name with arguments. +compiler=$CC + + +# save warnings/boilerplate of simple test code +ac_outfile=conftest.$ac_objext +echo "$lt_simple_compile_test_code" >conftest.$ac_ext +eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_compiler_boilerplate=`cat conftest.err` +$rm conftest* + +ac_outfile=conftest.$ac_objext +echo "$lt_simple_link_test_code" >conftest.$ac_ext +eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_linker_boilerplate=`cat conftest.err` +$rm -r conftest* + + +# Allow CC to be a program name with arguments. +lt_save_CC=$CC +lt_save_LD=$LD +lt_save_GCC=$GCC +GCC=$GXX +lt_save_with_gnu_ld=$with_gnu_ld +lt_save_path_LD=$lt_cv_path_LD +if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then + lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx +else + $as_unset lt_cv_prog_gnu_ld +fi +if test -n "${lt_cv_path_LDCXX+set}"; then + lt_cv_path_LD=$lt_cv_path_LDCXX +else + $as_unset lt_cv_path_LD +fi +test -z "${LDCXX+set}" || LD=$LDCXX +CC=${CXX-"c++"} +compiler=$CC +compiler_CXX=$CC +for cc_temp in $compiler""; do + case $cc_temp in + compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; + distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; + \-*) ;; + *) break;; + esac +done +cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` + + +# We don't want -fno-exception wen compiling C++ code, so set the +# no_builtin_flag separately +if test "$GXX" = yes; then + lt_prog_compiler_no_builtin_flag_CXX=' -fno-builtin' +else + lt_prog_compiler_no_builtin_flag_CXX= +fi + +if test "$GXX" = yes; then + # Set up default GNU C++ configuration + + +# Check whether --with-gnu-ld was given. +if test "${with_gnu_ld+set}" = set; then + withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes +else + with_gnu_ld=no +fi + +ac_prog=ld +if test "$GCC" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + { $as_echo "$as_me:$LINENO: checking for ld used by $CC" >&5 +$as_echo_n "checking for ld used by $CC... " >&6; } + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return which upsets mingw + ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $ac_prog in + # Accept absolute paths. + [\\/]* | ?:[\\/]*) + re_direlt='/[^/][^/]*/\.\./' + # Canonicalize the pathname of ld + ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'` + while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do + ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test "$with_gnu_ld" = yes; then + { $as_echo "$as_me:$LINENO: checking for GNU ld" >&5 +$as_echo_n "checking for GNU ld... " >&6; } +else + { $as_echo "$as_me:$LINENO: checking for non-GNU ld" >&5 +$as_echo_n "checking for non-GNU ld... " >&6; } +fi +if test "${lt_cv_path_LD+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -z "$LD"; then + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + lt_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some variants of GNU ld only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in + *GNU* | *'with BFD'*) + test "$with_gnu_ld" != no && break + ;; + *) + test "$with_gnu_ld" != yes && break + ;; + esac + fi + done + IFS="$lt_save_ifs" +else + lt_cv_path_LD="$LD" # Let the user override the test with a path. +fi +fi + +LD="$lt_cv_path_LD" +if test -n "$LD"; then + { $as_echo "$as_me:$LINENO: result: $LD" >&5 +$as_echo "$LD" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi +test -z "$LD" && { { $as_echo "$as_me:$LINENO: error: no acceptable ld found in \$PATH" >&5 +$as_echo "$as_me: error: no acceptable ld found in \$PATH" >&2;} + { (exit 1); exit 1; }; } +{ $as_echo "$as_me:$LINENO: checking if the linker ($LD) is GNU ld" >&5 +$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } +if test "${lt_cv_prog_gnu_ld+set}" = set; then + $as_echo_n "(cached) " >&6 +else + # I'd rather use --version here, but apparently some GNU lds only accept -v. +case `$LD -v 2>&1 </dev/null` in +*GNU* | *'with BFD'*) + lt_cv_prog_gnu_ld=yes + ;; +*) + lt_cv_prog_gnu_ld=no + ;; +esac +fi +{ $as_echo "$as_me:$LINENO: result: $lt_cv_prog_gnu_ld" >&5 +$as_echo "$lt_cv_prog_gnu_ld" >&6; } +with_gnu_ld=$lt_cv_prog_gnu_ld + + + + # Check if GNU C++ uses GNU ld as the underlying linker, since the + # archiving commands below assume that GNU ld is being used. + if test "$with_gnu_ld" = yes; then + archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + + hardcode_libdir_flag_spec_CXX='${wl}--rpath ${wl}$libdir' + export_dynamic_flag_spec_CXX='${wl}--export-dynamic' + + # If archive_cmds runs LD, not CC, wlarc should be empty + # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to + # investigate it a little bit more. (MM) + wlarc='${wl}' + + # ancient GNU ld didn't support --whole-archive et. al. + if eval "`$CC -print-prog-name=ld` --help 2>&1" | \ + grep 'no-whole-archive' > /dev/null; then + whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + whole_archive_flag_spec_CXX= + fi + else + with_gnu_ld=no + wlarc= + + # A generic and very simple default shared library creation + # command for GNU C++ for the case where it uses the native + # linker, instead of GNU ld. If possible, this setting should + # overridden to take advantage of the native linker features on + # the platform it is being used on. + archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' + fi + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"' + +else + GXX=no + with_gnu_ld=no + wlarc= +fi + +# PORTME: fill in a description of your system's C++ link characteristics +{ $as_echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5 +$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } +ld_shlibs_CXX=yes +case $host_os in + aix3*) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + aix[4-9]*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag="" + else + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) + for ld_flag in $LDFLAGS; do + case $ld_flag in + *-brtl*) + aix_use_runtimelinking=yes + break + ;; + esac + done + ;; + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + archive_cmds_CXX='' + hardcode_direct_CXX=yes + hardcode_libdir_separator_CXX=':' + link_all_deplibs_CXX=yes + + if test "$GXX" = yes; then + case $host_os in aix4.[012]|aix4.[012].*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && \ + strings "$collect2name" | grep resolve_lib_name >/dev/null + then + # We have reworked collect2 + : + else + # We have old collect2 + hardcode_direct_CXX=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + hardcode_minus_L_CXX=yes + hardcode_libdir_flag_spec_CXX='-L$libdir' + hardcode_libdir_separator_CXX= + fi + ;; + esac + shared_flag='-shared' + if test "$aix_use_runtimelinking" = yes; then + shared_flag="$shared_flag "'${wl}-G' + fi + else + # not using gcc + if test "$host_cpu" = ia64; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test "$aix_use_runtimelinking" = yes; then + shared_flag='${wl}-G' + else + shared_flag='${wl}-bM:SRE' + fi + fi + fi + + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to export. + always_export_symbols_CXX=yes + if test "$aix_use_runtimelinking" = yes; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + allow_undefined_flag_CXX='-berok' + # Determine the default libpath from the value encoded in an empty executable. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then + +lt_aix_libpath_sed=' + /Import File Strings/,/^$/ { + /^0/ { + s/^0 *\(.*\)$/\1/ + p + } + }' +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then + aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` +fi +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi + + hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath" + + archive_expsym_cmds_CXX="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" + else + if test "$host_cpu" = ia64; then + hardcode_libdir_flag_spec_CXX='${wl}-R $libdir:/usr/lib:/lib' + allow_undefined_flag_CXX="-z nodefs" + archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an empty executable. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then + +lt_aix_libpath_sed=' + /Import File Strings/,/^$/ { + /^0/ { + s/^0 *\(.*\)$/\1/ + p + } + }' +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then + aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` +fi +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi + + hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + no_undefined_flag_CXX=' ${wl}-bernotok' + allow_undefined_flag_CXX=' ${wl}-berok' + # Exported symbols can be pulled into shared objects from archives + whole_archive_flag_spec_CXX='$convenience' + archive_cmds_need_lc_CXX=yes + # This is similar to how AIX traditionally builds its shared libraries. + archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' + fi + fi + ;; + + beos*) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + allow_undefined_flag_CXX=unsupported + # Joseph Beckenbach <jrb3@best.com> says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + archive_cmds_CXX='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + else + ld_shlibs_CXX=no + fi + ;; + + chorus*) + case $cc_basename in + *) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + esac + ;; + + cygwin* | mingw* | pw32*) + # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, CXX) is actually meaningless, + # as there is no search path for DLLs. + hardcode_libdir_flag_spec_CXX='-L$libdir' + allow_undefined_flag_CXX=unsupported + always_export_symbols_CXX=no + enable_shared_with_static_runtimes_CXX=yes + + if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then + archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + # If the export-symbols file already is a .def file (1st line + # is EXPORTS), use it as is; otherwise, prepend... + archive_expsym_cmds_CXX='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + else + ld_shlibs_CXX=no + fi + ;; + darwin* | rhapsody*) + archive_cmds_need_lc_CXX=no + hardcode_direct_CXX=no + hardcode_automatic_CXX=yes + hardcode_shlibpath_var_CXX=unsupported + whole_archive_flag_spec_CXX='' + link_all_deplibs_CXX=yes + allow_undefined_flag_CXX="$_lt_dar_allow_undefined" + if test "$GXX" = yes ; then + output_verbose_link_cmd='echo' + archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" + module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" + archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" + module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" + if test "$lt_cv_apple_cc_single_mod" != "yes"; then + archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}" + archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}" + fi + else + case $cc_basename in + xlc*) + output_verbose_link_cmd='echo' + archive_cmds_CXX='$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $xlcverstring' + module_cmds_CXX='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' + # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds + archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $xlcverstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + module_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + ;; + *) + ld_shlibs_CXX=no + ;; + esac + fi + ;; + + dgux*) + case $cc_basename in + ec++*) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + ghcx*) + # Green Hills C++ Compiler + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + *) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + esac + ;; + freebsd[12]*) + # C++ shared libraries reported to be fairly broken before switch to ELF + ld_shlibs_CXX=no + ;; + freebsd-elf*) + archive_cmds_need_lc_CXX=no + ;; + freebsd* | dragonfly*) + # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF + # conventions + ld_shlibs_CXX=yes + ;; + gnu*) + ;; + hpux9*) + hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir' + hardcode_libdir_separator_CXX=: + export_dynamic_flag_spec_CXX='${wl}-E' + hardcode_direct_CXX=yes + hardcode_minus_L_CXX=yes # Not in the search PATH, + # but as the default + # location of the library. + + case $cc_basename in + CC*) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + aCC*) + archive_cmds_CXX='$rm $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "[-]L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + ;; + *) + if test "$GXX" = yes; then + archive_cmds_CXX='$rm $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + else + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + fi + ;; + esac + ;; + hpux10*|hpux11*) + if test $with_gnu_ld = no; then + hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir' + hardcode_libdir_separator_CXX=: + + case $host_cpu in + hppa*64*|ia64*) ;; + *) + export_dynamic_flag_spec_CXX='${wl}-E' + ;; + esac + fi + case $host_cpu in + hppa*64*|ia64*) + hardcode_direct_CXX=no + hardcode_shlibpath_var_CXX=no + ;; + *) + hardcode_direct_CXX=yes + hardcode_minus_L_CXX=yes # Not in the search PATH, + # but as the default + # location of the library. + ;; + esac + + case $cc_basename in + CC*) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + aCC*) + case $host_cpu in + hppa*64*) + archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + ia64*) + archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + *) + archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + esac + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + ;; + *) + if test "$GXX" = yes; then + if test $with_gnu_ld = no; then + case $host_cpu in + hppa*64*) + archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + ia64*) + archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + *) + archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + esac + fi + else + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + fi + ;; + esac + ;; + interix[3-9]*) + hardcode_direct_CXX=no + hardcode_shlibpath_var_CXX=no + hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' + export_dynamic_flag_spec_CXX='${wl}-E' + # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. + # Instead, shared libraries are loaded at an image base (0x10000000 by + # default) and relocated if they conflict, which is a slow very memory + # consuming and fragmenting process. To avoid this, we pick a random, + # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link + # time. Moving up from 0x10000000 also allows more sbrk(2) space. + archive_cmds_CXX='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + archive_expsym_cmds_CXX='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + ;; + irix5* | irix6*) + case $cc_basename in + CC*) + # SGI C++ + archive_cmds_CXX='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + + # Archives containing C++ object files must be created using + # "CC -ar", where "CC" is the IRIX C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + old_archive_cmds_CXX='$CC -ar -WR,-u -o $oldlib $oldobjs' + ;; + *) + if test "$GXX" = yes; then + if test "$with_gnu_ld" = no; then + archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` -o $lib' + fi + fi + link_all_deplibs_CXX=yes + ;; + esac + hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator_CXX=: + ;; + linux* | k*bsd*-gnu) + case $cc_basename in + KCC*) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + archive_expsym_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | grep "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + + hardcode_libdir_flag_spec_CXX='${wl}--rpath,$libdir' + export_dynamic_flag_spec_CXX='${wl}--export-dynamic' + + # Archives containing C++ object files must be created using + # "CC -Bstatic", where "CC" is the KAI C++ compiler. + old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs' + ;; + icpc*) + # Intel C++ + with_gnu_ld=yes + # version 8.0 and above of icpc choke on multiply defined symbols + # if we add $predep_objects and $postdep_objects, however 7.1 and + # earlier do not add the objects themselves. + case `$CC -V 2>&1` in + *"Version 7."*) + archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + ;; + *) # Version 8.0 or newer + tmp_idyn= + case $host_cpu in + ia64*) tmp_idyn=' -i_dynamic';; + esac + archive_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + ;; + esac + archive_cmds_need_lc_CXX=no + hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' + export_dynamic_flag_spec_CXX='${wl}--export-dynamic' + whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive' + ;; + pgCC* | pgcpp*) + # Portland Group C++ compiler + archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' + archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' + + hardcode_libdir_flag_spec_CXX='${wl}--rpath ${wl}$libdir' + export_dynamic_flag_spec_CXX='${wl}--export-dynamic' + whole_archive_flag_spec_CXX='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' + ;; + cxx*) + # Compaq C++ + archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' + + runpath_var=LD_RUN_PATH + hardcode_libdir_flag_spec_CXX='-rpath $libdir' + hardcode_libdir_separator_CXX=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + # Sun C++ 5.9 + no_undefined_flag_CXX=' -zdefs' + archive_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + archive_expsym_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols' + hardcode_libdir_flag_spec_CXX='-R$libdir' + whole_archive_flag_spec_CXX='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' + + # Not sure whether something based on + # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 + # would be better. + output_verbose_link_cmd='echo' + + # Archives containing C++ object files must be created using + # "CC -xar", where "CC" is the Sun C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs' + ;; + esac + ;; + esac + ;; + lynxos*) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + m88k*) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + mvs*) + case $cc_basename in + cxx*) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + *) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + esac + ;; + netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + archive_cmds_CXX='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' + wlarc= + hardcode_libdir_flag_spec_CXX='-R$libdir' + hardcode_direct_CXX=yes + hardcode_shlibpath_var_CXX=no + fi + # Workaround some broken pre-1.5 toolchains + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' + ;; + openbsd2*) + # C++ shared libraries are fairly broken + ld_shlibs_CXX=no + ;; + openbsd*) + if test -f /usr/libexec/ld.so; then + hardcode_direct_CXX=yes + hardcode_shlibpath_var_CXX=no + archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' + hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib' + export_dynamic_flag_spec_CXX='${wl}-E' + whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + fi + output_verbose_link_cmd='echo' + else + ld_shlibs_CXX=no + fi + ;; + osf3*) + case $cc_basename in + KCC*) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + + hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' + hardcode_libdir_separator_CXX=: + + # Archives containing C++ object files must be created using + # "CC -Bstatic", where "CC" is the KAI C++ compiler. + old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs' + + ;; + RCC*) + # Rational C++ 2.4.1 + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + cxx*) + allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + + hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator_CXX=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + ;; + *) + if test "$GXX" = yes && test "$with_gnu_ld" = no; then + allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + + hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator_CXX=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"' + + else + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + fi + ;; + esac + ;; + osf4* | osf5*) + case $cc_basename in + KCC*) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + + hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' + hardcode_libdir_separator_CXX=: + + # Archives containing C++ object files must be created using + # the KAI C++ compiler. + old_archive_cmds_CXX='$CC -o $oldlib $oldobjs' + ;; + RCC*) + # Rational C++ 2.4.1 + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + cxx*) + allow_undefined_flag_CXX=' -expect_unresolved \*' + archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + archive_expsym_cmds_CXX='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ + echo "-hidden">> $lib.exp~ + $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname -Wl,-input -Wl,$lib.exp `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~ + $rm $lib.exp' + + hardcode_libdir_flag_spec_CXX='-rpath $libdir' + hardcode_libdir_separator_CXX=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + ;; + *) + if test "$GXX" = yes && test "$with_gnu_ld" = no; then + allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + + hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator_CXX=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"' + + else + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + fi + ;; + esac + ;; + psos*) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + sunos4*) + case $cc_basename in + CC*) + # Sun C++ 4.x + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + lcc*) + # Lucid + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + *) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + esac + ;; + solaris*) + case $cc_basename in + CC*) + # Sun C++ 4.2, 5.x and Centerline C++ + archive_cmds_need_lc_CXX=yes + no_undefined_flag_CXX=' -zdefs' + archive_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + archive_expsym_cmds_CXX='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' + + hardcode_libdir_flag_spec_CXX='-R$libdir' + hardcode_shlibpath_var_CXX=no + case $host_os in + solaris2.[0-5] | solaris2.[0-5].*) ;; + *) + # The compiler driver will combine and reorder linker options, + # but understands `-z linker_flag'. + # Supported since Solaris 2.6 (maybe 2.5.1?) + whole_archive_flag_spec_CXX='-z allextract$convenience -z defaultextract' + ;; + esac + link_all_deplibs_CXX=yes + + output_verbose_link_cmd='echo' + + # Archives containing C++ object files must be created using + # "CC -xar", where "CC" is the Sun C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs' + ;; + gcx*) + # Green Hills C++ Compiler + archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + + # The C++ compiler must be used to create the archive. + old_archive_cmds_CXX='$CC $LDFLAGS -archive -o $oldlib $oldobjs' + ;; + *) + # GNU C++ compiler with Solaris linker + if test "$GXX" = yes && test "$with_gnu_ld" = no; then + no_undefined_flag_CXX=' ${wl}-z ${wl}defs' + if $CC --version | grep -v '^2\.7' > /dev/null; then + archive_cmds_CXX='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + archive_expsym_cmds_CXX='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd="$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\"" + else + # g++ 2.7 appears to require `-G' NOT `-shared' on this + # platform. + archive_cmds_CXX='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + archive_expsym_cmds_CXX='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd="$CC -G $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\"" + fi + + hardcode_libdir_flag_spec_CXX='${wl}-R $wl$libdir' + case $host_os in + solaris2.[0-5] | solaris2.[0-5].*) ;; + *) + whole_archive_flag_spec_CXX='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' + ;; + esac + fi + ;; + esac + ;; + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) + no_undefined_flag_CXX='${wl}-z,text' + archive_cmds_need_lc_CXX=no + hardcode_shlibpath_var_CXX=no + runpath_var='LD_RUN_PATH' + + case $cc_basename in + CC*) + archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + ;; + sysv5* | sco3.2v5* | sco5v6*) + # Note: We can NOT use -z defs as we might desire, because we do not + # link with -lc, and that would cause any symbols used from libc to + # always be unresolved, which means just about no library would + # ever link correctly. If we're not using GNU ld we use -z text + # though, which does catch some bad symbols but isn't as heavy-handed + # as -z defs. + # For security reasons, it is highly recommended that you always + # use absolute paths for naming shared libraries, and exclude the + # DT_RUNPATH tag from executables and libraries. But doing so + # requires that you compile everything twice, which is a pain. + # So that behaviour is only enabled if SCOABSPATH is set to a + # non-empty value in the environment. Most likely only useful for + # creating official distributions of packages. + # This is a hack until libtool officially supports absolute path + # names for shared libraries. + no_undefined_flag_CXX='${wl}-z,text' + allow_undefined_flag_CXX='${wl}-z,nodefs' + archive_cmds_need_lc_CXX=no + hardcode_shlibpath_var_CXX=no + hardcode_libdir_flag_spec_CXX='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`' + hardcode_libdir_separator_CXX=':' + link_all_deplibs_CXX=yes + export_dynamic_flag_spec_CXX='${wl}-Bexport' + runpath_var='LD_RUN_PATH' + + case $cc_basename in + CC*) + archive_cmds_CXX='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + archive_cmds_CXX='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + ;; + tandem*) + case $cc_basename in + NCC*) + # NonStop-UX NCC 3.20 + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + *) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + esac + ;; + vxworks*) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + *) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; +esac +{ $as_echo "$as_me:$LINENO: result: $ld_shlibs_CXX" >&5 +$as_echo "$ld_shlibs_CXX" >&6; } +test "$ld_shlibs_CXX" = no && can_build_shared=no + +GCC_CXX="$GXX" +LD_CXX="$LD" + +cat > conftest.$ac_ext <<EOF +class Foo +{ +public: + Foo (void) { a = 0; } +private: + int a; +}; +EOF + +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # Parse the compiler output and extract the necessary + # objects, libraries and library flags. + + # Sentinel used to keep track of whether or not we are before + # the conftest object file. + pre_test_object_deps_done=no + + # The `*' in the case matches for architectures that use `case' in + # $output_verbose_cmd can trigger glob expansion during the loop + # eval without this substitution. + output_verbose_link_cmd=`$echo "X$output_verbose_link_cmd" | $Xsed -e "$no_glob_subst"` + + for p in `eval $output_verbose_link_cmd`; do + case $p in + + -L* | -R* | -l*) + # Some compilers place space between "-{L,R}" and the path. + # Remove the space. + if test $p = "-L" \ + || test $p = "-R"; then + prev=$p + continue + else + prev= + fi + + if test "$pre_test_object_deps_done" = no; then + case $p in + -L* | -R*) + # Internal compiler library paths should come after those + # provided the user. The postdeps already come after the + # user supplied libs so there is no need to process them. + if test -z "$compiler_lib_search_path_CXX"; then + compiler_lib_search_path_CXX="${prev}${p}" + else + compiler_lib_search_path_CXX="${compiler_lib_search_path_CXX} ${prev}${p}" + fi + ;; + # The "-l" case would never come before the object being + # linked, so don't bother handling this case. + esac + else + if test -z "$postdeps_CXX"; then + postdeps_CXX="${prev}${p}" + else + postdeps_CXX="${postdeps_CXX} ${prev}${p}" + fi + fi + ;; + + *.$objext) + # This assumes that the test object file only shows up + # once in the compiler output. + if test "$p" = "conftest.$objext"; then + pre_test_object_deps_done=yes + continue + fi + + if test "$pre_test_object_deps_done" = no; then + if test -z "$predep_objects_CXX"; then + predep_objects_CXX="$p" + else + predep_objects_CXX="$predep_objects_CXX $p" + fi + else + if test -z "$postdep_objects_CXX"; then + postdep_objects_CXX="$p" + else + postdep_objects_CXX="$postdep_objects_CXX $p" + fi + fi + ;; + + *) ;; # Ignore the rest. + + esac + done + + # Clean up. + rm -f a.out a.exe +else + echo "libtool.m4: error: problem compiling CXX test program" +fi + +$rm -f confest.$objext + +compiler_lib_search_dirs_CXX= +if test -n "$compiler_lib_search_path_CXX"; then + compiler_lib_search_dirs_CXX=`echo " ${compiler_lib_search_path_CXX}" | ${SED} -e 's! -L! !g' -e 's!^ !!'` +fi + +# PORTME: override above test on systems where it is broken +case $host_os in +interix[3-9]*) + # Interix 3.5 installs completely hosed .la files for C++, so rather than + # hack all around it, let's just trust "g++" to DTRT. + predep_objects_CXX= + postdep_objects_CXX= + postdeps_CXX= + ;; + +linux*) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + # Sun C++ 5.9 + # + # The more standards-conforming stlport4 library is + # incompatible with the Cstd library. Avoid specifying + # it if it's in CXXFLAGS. Ignore libCrun as + # -library=stlport4 depends on it. + case " $CXX $CXXFLAGS " in + *" -library=stlport4 "*) + solaris_use_stlport4=yes + ;; + esac + if test "$solaris_use_stlport4" != yes; then + postdeps_CXX='-library=Cstd -library=Crun' + fi + ;; + esac + ;; + +solaris*) + case $cc_basename in + CC*) + # The more standards-conforming stlport4 library is + # incompatible with the Cstd library. Avoid specifying + # it if it's in CXXFLAGS. Ignore libCrun as + # -library=stlport4 depends on it. + case " $CXX $CXXFLAGS " in + *" -library=stlport4 "*) + solaris_use_stlport4=yes + ;; + esac + + # Adding this requires a known-good setup of shared libraries for + # Sun compiler versions before 5.6, else PIC objects from an old + # archive will be linked into the output, leading to subtle bugs. + if test "$solaris_use_stlport4" != yes; then + postdeps_CXX='-library=Cstd -library=Crun' + fi + ;; + esac + ;; +esac + +case " $postdeps_CXX " in +*" -lc "*) archive_cmds_need_lc_CXX=no ;; +esac + +lt_prog_compiler_wl_CXX= +lt_prog_compiler_pic_CXX= +lt_prog_compiler_static_CXX= + +{ $as_echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5 +$as_echo_n "checking for $compiler option to produce PIC... " >&6; } + + # C++ specific cases for pic, static, wl, etc. + if test "$GXX" = yes; then + lt_prog_compiler_wl_CXX='-Wl,' + lt_prog_compiler_static_CXX='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static_CXX='-Bstatic' + fi + ;; + amigaos*) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the `-m68020' flag to GCC prevents building anything better, + # like `-m68040'. + lt_prog_compiler_pic_CXX='-m68020 -resident32 -malways-restore-a4' + ;; + beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + mingw* | cygwin* | os2* | pw32*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + # Although the cygwin gcc ignores -fPIC, still need this for old-style + # (--disable-auto-import) libraries + lt_prog_compiler_pic_CXX='-DDLL_EXPORT' + ;; + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + lt_prog_compiler_pic_CXX='-fno-common' + ;; + *djgpp*) + # DJGPP does not support shared libraries at all + lt_prog_compiler_pic_CXX= + ;; + interix[3-9]*) + # Interix 3.x gcc -fpic/-fPIC options generate broken code. + # Instead, we relocate shared libraries at runtime. + ;; + sysv4*MP*) + if test -d /usr/nec; then + lt_prog_compiler_pic_CXX=-Kconform_pic + fi + ;; + hpux*) + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case $host_cpu in + hppa*64*|ia64*) + ;; + *) + lt_prog_compiler_pic_CXX='-fPIC' + ;; + esac + ;; + *) + lt_prog_compiler_pic_CXX='-fPIC' + ;; + esac + else + case $host_os in + aix[4-9]*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static_CXX='-Bstatic' + else + lt_prog_compiler_static_CXX='-bnso -bI:/lib/syscalls.exp' + fi + ;; + chorus*) + case $cc_basename in + cxch68*) + # Green Hills C++ Compiler + # _LT_AC_TAGVAR(lt_prog_compiler_static, CXX)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" + ;; + esac + ;; + darwin*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + case $cc_basename in + xlc*) + lt_prog_compiler_pic_CXX='-qnocommon' + lt_prog_compiler_wl_CXX='-Wl,' + ;; + esac + ;; + dgux*) + case $cc_basename in + ec++*) + lt_prog_compiler_pic_CXX='-KPIC' + ;; + ghcx*) + # Green Hills C++ Compiler + lt_prog_compiler_pic_CXX='-pic' + ;; + *) + ;; + esac + ;; + freebsd* | dragonfly*) + # FreeBSD uses GNU C++ + ;; + hpux9* | hpux10* | hpux11*) + case $cc_basename in + CC*) + lt_prog_compiler_wl_CXX='-Wl,' + lt_prog_compiler_static_CXX='${wl}-a ${wl}archive' + if test "$host_cpu" != ia64; then + lt_prog_compiler_pic_CXX='+Z' + fi + ;; + aCC*) + lt_prog_compiler_wl_CXX='-Wl,' + lt_prog_compiler_static_CXX='${wl}-a ${wl}archive' + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + lt_prog_compiler_pic_CXX='+Z' + ;; + esac + ;; + *) + ;; + esac + ;; + interix*) + # This is c89, which is MS Visual C++ (no shared libs) + # Anyone wants to do a port? + ;; + irix5* | irix6* | nonstopux*) + case $cc_basename in + CC*) + lt_prog_compiler_wl_CXX='-Wl,' + lt_prog_compiler_static_CXX='-non_shared' + # CC pic flag -KPIC is the default. + ;; + *) + ;; + esac + ;; + linux* | k*bsd*-gnu) + case $cc_basename in + KCC*) + # KAI C++ Compiler + lt_prog_compiler_wl_CXX='--backend -Wl,' + lt_prog_compiler_pic_CXX='-fPIC' + ;; + icpc* | ecpc*) + # Intel C++ + lt_prog_compiler_wl_CXX='-Wl,' + lt_prog_compiler_pic_CXX='-KPIC' + lt_prog_compiler_static_CXX='-static' + ;; + pgCC* | pgcpp*) + # Portland Group C++ compiler. + lt_prog_compiler_wl_CXX='-Wl,' + lt_prog_compiler_pic_CXX='-fpic' + lt_prog_compiler_static_CXX='-Bstatic' + ;; + cxx*) + # Compaq C++ + # Make sure the PIC flag is empty. It appears that all Alpha + # Linux and Compaq Tru64 Unix objects are PIC. + lt_prog_compiler_pic_CXX= + lt_prog_compiler_static_CXX='-non_shared' + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + # Sun C++ 5.9 + lt_prog_compiler_pic_CXX='-KPIC' + lt_prog_compiler_static_CXX='-Bstatic' + lt_prog_compiler_wl_CXX='-Qoption ld ' + ;; + esac + ;; + esac + ;; + lynxos*) + ;; + m88k*) + ;; + mvs*) + case $cc_basename in + cxx*) + lt_prog_compiler_pic_CXX='-W c,exportall' + ;; + *) + ;; + esac + ;; + netbsd*) + ;; + osf3* | osf4* | osf5*) + case $cc_basename in + KCC*) + lt_prog_compiler_wl_CXX='--backend -Wl,' + ;; + RCC*) + # Rational C++ 2.4.1 + lt_prog_compiler_pic_CXX='-pic' + ;; + cxx*) + # Digital/Compaq C++ + lt_prog_compiler_wl_CXX='-Wl,' + # Make sure the PIC flag is empty. It appears that all Alpha + # Linux and Compaq Tru64 Unix objects are PIC. + lt_prog_compiler_pic_CXX= + lt_prog_compiler_static_CXX='-non_shared' + ;; + *) + ;; + esac + ;; + psos*) + ;; + solaris*) + case $cc_basename in + CC*) + # Sun C++ 4.2, 5.x and Centerline C++ + lt_prog_compiler_pic_CXX='-KPIC' + lt_prog_compiler_static_CXX='-Bstatic' + lt_prog_compiler_wl_CXX='-Qoption ld ' + ;; + gcx*) + # Green Hills C++ Compiler + lt_prog_compiler_pic_CXX='-PIC' + ;; + *) + ;; + esac + ;; + sunos4*) + case $cc_basename in + CC*) + # Sun C++ 4.x + lt_prog_compiler_pic_CXX='-pic' + lt_prog_compiler_static_CXX='-Bstatic' + ;; + lcc*) + # Lucid + lt_prog_compiler_pic_CXX='-pic' + ;; + *) + ;; + esac + ;; + tandem*) + case $cc_basename in + NCC*) + # NonStop-UX NCC 3.20 + lt_prog_compiler_pic_CXX='-KPIC' + ;; + *) + ;; + esac + ;; + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + case $cc_basename in + CC*) + lt_prog_compiler_wl_CXX='-Wl,' + lt_prog_compiler_pic_CXX='-KPIC' + lt_prog_compiler_static_CXX='-Bstatic' + ;; + esac + ;; + vxworks*) + ;; + *) + lt_prog_compiler_can_build_shared_CXX=no + ;; + esac + fi + +{ $as_echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_CXX" >&5 +$as_echo "$lt_prog_compiler_pic_CXX" >&6; } + +# +# Check to make sure the PIC flag actually works. +# +if test -n "$lt_prog_compiler_pic_CXX"; then + +{ $as_echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works" >&5 +$as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works... " >&6; } +if test "${lt_cv_prog_compiler_pic_works_CXX+set}" = set; then + $as_echo_n "(cached) " >&6 +else + lt_cv_prog_compiler_pic_works_CXX=no + ac_outfile=conftest.$ac_objext + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="$lt_prog_compiler_pic_CXX -DPIC" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:12631: $lt_compile\"" >&5) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&5 + echo "$as_me:12635: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings other than the usual output. + $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then + lt_cv_prog_compiler_pic_works_CXX=yes + fi + fi + $rm conftest* + +fi +{ $as_echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_pic_works_CXX" >&5 +$as_echo "$lt_cv_prog_compiler_pic_works_CXX" >&6; } + +if test x"$lt_cv_prog_compiler_pic_works_CXX" = xyes; then + case $lt_prog_compiler_pic_CXX in + "" | " "*) ;; + *) lt_prog_compiler_pic_CXX=" $lt_prog_compiler_pic_CXX" ;; + esac +else + lt_prog_compiler_pic_CXX= + lt_prog_compiler_can_build_shared_CXX=no +fi + +fi +case $host_os in + # For platforms which do not support PIC, -DPIC is meaningless: + *djgpp*) + lt_prog_compiler_pic_CXX= + ;; + *) + lt_prog_compiler_pic_CXX="$lt_prog_compiler_pic_CXX -DPIC" + ;; +esac + +# +# Check to make sure the static flag actually works. +# +wl=$lt_prog_compiler_wl_CXX eval lt_tmp_static_flag=\"$lt_prog_compiler_static_CXX\" +{ $as_echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5 +$as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } +if test "${lt_cv_prog_compiler_static_works_CXX+set}" = set; then + $as_echo_n "(cached) " >&6 +else + lt_cv_prog_compiler_static_works_CXX=no + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS $lt_tmp_static_flag" + echo "$lt_simple_link_test_code" > conftest.$ac_ext + if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then + # The linker can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + # Append any errors to the config.log. + cat conftest.err 1>&5 + $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if diff conftest.exp conftest.er2 >/dev/null; then + lt_cv_prog_compiler_static_works_CXX=yes + fi + else + lt_cv_prog_compiler_static_works_CXX=yes + fi + fi + $rm -r conftest* + LDFLAGS="$save_LDFLAGS" + +fi +{ $as_echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_static_works_CXX" >&5 +$as_echo "$lt_cv_prog_compiler_static_works_CXX" >&6; } + +if test x"$lt_cv_prog_compiler_static_works_CXX" = xyes; then + : +else + lt_prog_compiler_static_CXX= +fi + + +{ $as_echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5 +$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } +if test "${lt_cv_prog_compiler_c_o_CXX+set}" = set; then + $as_echo_n "(cached) " >&6 +else + lt_cv_prog_compiler_c_o_CXX=no + $rm -r conftest 2>/dev/null + mkdir conftest + cd conftest + mkdir out + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + lt_compiler_flag="-o out/conftest2.$ac_objext" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:12735: $lt_compile\"" >&5) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&5 + echo "$as_me:12739: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp + $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 + if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then + lt_cv_prog_compiler_c_o_CXX=yes + fi + fi + chmod u+w . 2>&5 + $rm conftest* + # SGI C++ compiler will create directory out/ii_files/ for + # template instantiation + test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files + $rm out/* && rmdir out + cd .. + rmdir conftest + $rm conftest* + +fi +{ $as_echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_CXX" >&5 +$as_echo "$lt_cv_prog_compiler_c_o_CXX" >&6; } + + +hard_links="nottested" +if test "$lt_cv_prog_compiler_c_o_CXX" = no && test "$need_locks" != no; then + # do not overwrite the value of need_locks provided by the user + { $as_echo "$as_me:$LINENO: checking if we can lock with hard links" >&5 +$as_echo_n "checking if we can lock with hard links... " >&6; } + hard_links=yes + $rm conftest* + ln conftest.a conftest.b 2>/dev/null && hard_links=no + touch conftest.a + ln conftest.a conftest.b 2>&5 || hard_links=no + ln conftest.a conftest.b 2>/dev/null && hard_links=no + { $as_echo "$as_me:$LINENO: result: $hard_links" >&5 +$as_echo "$hard_links" >&6; } + if test "$hard_links" = no; then + { $as_echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 +$as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} + need_locks=warn + fi +else + need_locks=no +fi + +{ $as_echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5 +$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } + + export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + case $host_os in + aix[4-9]*) + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to AIX nm, but means don't demangle with GNU nm + if $NM -V 2>&1 | grep 'GNU' > /dev/null; then + export_symbols_cmds_CXX='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' + else + export_symbols_cmds_CXX='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' + fi + ;; + pw32*) + export_symbols_cmds_CXX="$ltdll_cmds" + ;; + cygwin* | mingw*) + export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;/^.*[ ]__nm__/s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols' + ;; + *) + export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + ;; + esac + exclude_expsyms_CXX='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*' + +{ $as_echo "$as_me:$LINENO: result: $ld_shlibs_CXX" >&5 +$as_echo "$ld_shlibs_CXX" >&6; } +test "$ld_shlibs_CXX" = no && can_build_shared=no + +# +# Do we need to explicitly link libc? +# +case "x$archive_cmds_need_lc_CXX" in +x|xyes) + # Assume -lc should be added + archive_cmds_need_lc_CXX=yes + + if test "$enable_shared" = yes && test "$GCC" = yes; then + case $archive_cmds_CXX in + *'~'*) + # FIXME: we may have to deal with multi-command sequences. + ;; + '$CC '*) + # Test whether the compiler implicitly links with -lc since on some + # systems, -lgcc has to come before -lc. If gcc already passes -lc + # to ld, don't add -lc before -lgcc. + { $as_echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5 +$as_echo_n "checking whether -lc should be explicitly linked in... " >&6; } + $rm conftest* + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } 2>conftest.err; then + soname=conftest + lib=conftest + libobjs=conftest.$ac_objext + deplibs= + wl=$lt_prog_compiler_wl_CXX + pic_flag=$lt_prog_compiler_pic_CXX + compiler_flags=-v + linker_flags=-v + verstring= + output_objdir=. + libname=conftest + lt_save_allow_undefined_flag=$allow_undefined_flag_CXX + allow_undefined_flag_CXX= + if { (eval echo "$as_me:$LINENO: \"$archive_cmds_CXX 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5 + (eval $archive_cmds_CXX 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + then + archive_cmds_need_lc_CXX=no + else + archive_cmds_need_lc_CXX=yes + fi + allow_undefined_flag_CXX=$lt_save_allow_undefined_flag + else + cat conftest.err 1>&5 + fi + $rm conftest* + { $as_echo "$as_me:$LINENO: result: $archive_cmds_need_lc_CXX" >&5 +$as_echo "$archive_cmds_need_lc_CXX" >&6; } + ;; + esac + fi + ;; +esac + +{ $as_echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5 +$as_echo_n "checking dynamic linker characteristics... " >&6; } +library_names_spec= +libname_spec='lib$name' +soname_spec= +shrext_cmds=".so" +postinstall_cmds= +postuninstall_cmds= +finish_cmds= +finish_eval= +shlibpath_var= +shlibpath_overrides_runpath=unknown +version_type=none +dynamic_linker="$host_os ld.so" +sys_lib_dlsearch_path_spec="/lib /usr/lib" + +need_lib_prefix=unknown +hardcode_into_libs=no + +# when you set need_version to no, make sure it does not cause -set_version +# flags to be left without arguments +need_version=unknown + +case $host_os in +aix3*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' + shlibpath_var=LIBPATH + + # AIX 3 has no versioning support, so we append a major version to the name. + soname_spec='${libname}${release}${shared_ext}$major' + ;; + +aix[4-9]*) + version_type=linux + need_lib_prefix=no + need_version=no + hardcode_into_libs=yes + if test "$host_cpu" = ia64; then + # AIX 5 supports IA64 + library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + else + # With GCC up to 2.95.x, collect2 would create an import file + # for dependence libraries. The import file would start with + # the line `#! .'. This would cause the generated library to + # depend on `.', always an invalid library. This was fixed in + # development snapshots of GCC prior to 3.0. + case $host_os in + aix4 | aix4.[01] | aix4.[01].*) + if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' + echo ' yes ' + echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then + : + else + can_build_shared=no + fi + ;; + esac + # AIX (on Power*) has no versioning support, so currently we can not hardcode correct + # soname into executable. Probably we can add versioning support to + # collect2, so additional links can be useful in future. + if test "$aix_use_runtimelinking" = yes; then + # If using run time linking (on AIX 4.2 or later) use lib<name>.so + # instead of lib<name>.a to let people know that these are not + # typical AIX shared libraries. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + else + # We preserve .a as extension for shared libraries through AIX4.2 + # and later when we are not doing run time linking. + library_names_spec='${libname}${release}.a $libname.a' + soname_spec='${libname}${release}${shared_ext}$major' + fi + shlibpath_var=LIBPATH + fi + ;; + +amigaos*) + library_names_spec='$libname.ixlibrary $libname.a' + # Create ${libname}_ixlibrary.a entries in /sys/libs. + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' + ;; + +beos*) + library_names_spec='${libname}${shared_ext}' + dynamic_linker="$host_os ld.so" + shlibpath_var=LIBRARY_PATH + ;; + +bsdi[45]*) + version_type=linux + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" + sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" + # the default ld.so.conf also contains /usr/contrib/lib and + # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow + # libtool to hard-code these into programs + ;; + +cygwin* | mingw* | pw32*) + version_type=windows + shrext_cmds=".dll" + need_version=no + need_lib_prefix=no + + case $GCC,$host_os in + yes,cygwin* | yes,mingw* | yes,pw32*) + library_names_spec='$libname.dll.a' + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \${file}`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname~ + chmod a+x \$dldir/$dlname' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $rm \$dlpath' + shlibpath_overrides_runpath=yes + + case $host_os in + cygwin*) + # Cygwin DLLs use 'cyg' prefix rather than 'lib' + soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" + ;; + mingw*) + # MinGW DLLs use traditional 'lib' prefix + soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then + # It is most probably a Windows format PATH printed by + # mingw gcc, but we are running on Cygwin. Gcc prints its search + # path with ; separators, and with drive letters. We can handle the + # drive letters (cygwin fileutils understands them), so leave them, + # especially as we might pass files found there to a mingw objdump, + # which wouldn't understand a cygwinified path. Ahh. + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + ;; + pw32*) + # pw32 DLLs use 'pw' prefix rather than 'lib' + library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + ;; + esac + ;; + + *) + library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' + ;; + esac + dynamic_linker='Win32 ld.exe' + # FIXME: first we should search . and the directory the executable is in + shlibpath_var=PATH + ;; + +darwin* | rhapsody*) + dynamic_linker="$host_os dyld" + version_type=darwin + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext' + soname_spec='${libname}${release}${major}$shared_ext' + shlibpath_overrides_runpath=yes + shlibpath_var=DYLD_LIBRARY_PATH + shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' + + sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' + ;; + +dgux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +freebsd1*) + dynamic_linker=no + ;; + +freebsd* | dragonfly*) + # DragonFly does not have aout. When/if they implement a new + # versioning mechanism, adjust this. + if test -x /usr/bin/objformat; then + objformat=`/usr/bin/objformat` + else + case $host_os in + freebsd[123]*) objformat=aout ;; + *) objformat=elf ;; + esac + fi + version_type=freebsd-$objformat + case $version_type in + freebsd-elf*) + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + need_version=no + need_lib_prefix=no + ;; + freebsd-*) + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' + need_version=yes + ;; + esac + shlibpath_var=LD_LIBRARY_PATH + case $host_os in + freebsd2*) + shlibpath_overrides_runpath=yes + ;; + freebsd3.[01]* | freebsdelf3.[01]*) + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ + freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + *) # from 4.6 on, and DragonFly + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + esac + ;; + +gnu*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + hardcode_into_libs=yes + ;; + +hpux9* | hpux10* | hpux11*) + # Give a soname corresponding to the major version so that dld.sl refuses to + # link against other versions. + version_type=sunos + need_lib_prefix=no + need_version=no + case $host_cpu in + ia64*) + shrext_cmds='.so' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.so" + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + if test "X$HPUX_IA64_MODE" = X32; then + sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" + else + sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" + fi + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + hppa*64*) + shrext_cmds='.sl' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.sl" + shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + *) + shrext_cmds='.sl' + dynamic_linker="$host_os dld.sl" + shlibpath_var=SHLIB_PATH + shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + ;; + esac + # HP-UX runs *really* slowly unless shared libraries are mode 555. + postinstall_cmds='chmod 555 $lib' + ;; + +interix[3-9]*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + +irix5* | irix6* | nonstopux*) + case $host_os in + nonstopux*) version_type=nonstopux ;; + *) + if test "$lt_cv_prog_gnu_ld" = yes; then + version_type=linux + else + version_type=irix + fi ;; + esac + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' + case $host_os in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in # libtool.m4 will add one of these switches to LD + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") + libsuff= shlibsuff= libmagic=32-bit;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") + libsuff=32 shlibsuff=N32 libmagic=N32;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") + libsuff=64 shlibsuff=64 libmagic=64-bit;; + *) libsuff= shlibsuff= libmagic=never-match;; + esac + ;; + esac + shlibpath_var=LD_LIBRARY${shlibsuff}_PATH + shlibpath_overrides_runpath=no + sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" + sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" + hardcode_into_libs=yes + ;; + +# No shared lib support for Linux oldld, aout, or coff. +linux*oldld* | linux*aout* | linux*coff*) + dynamic_linker=no + ;; + +# This must be Linux ELF. +linux* | k*bsd*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + # Append ld.so.conf contents to the search path + if test -f /etc/ld.so.conf; then + lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` + sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" + fi + + # We used to test for /lib/ld.so.1 and disable shared libraries on + # powerpc, because MkLinux only supported shared libraries with the + # GNU dynamic linker. Since this was broken with cross compilers, + # most powerpc-linux boxes support dynamic linking these days and + # people can always --disable-shared, the test was removed, and we + # assume the GNU/Linux dynamic linker is in use. + dynamic_linker='GNU/Linux ld.so' + ;; + +netbsd*) + version_type=sunos + need_lib_prefix=no + need_version=no + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + dynamic_linker='NetBSD (a.out) ld.so' + else + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='NetBSD ld.elf_so' + fi + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + +newsos6) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +nto-qnx*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +openbsd*) + version_type=sunos + sys_lib_dlsearch_path_spec="/usr/lib" + need_lib_prefix=no + # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. + case $host_os in + openbsd3.3 | openbsd3.3.*) need_version=yes ;; + *) need_version=no ;; + esac + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + shlibpath_var=LD_LIBRARY_PATH + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + case $host_os in + openbsd2.[89] | openbsd2.[89].*) + shlibpath_overrides_runpath=no + ;; + *) + shlibpath_overrides_runpath=yes + ;; + esac + else + shlibpath_overrides_runpath=yes + fi + ;; + +os2*) + libname_spec='$name' + shrext_cmds=".dll" + need_lib_prefix=no + library_names_spec='$libname${shared_ext} $libname.a' + dynamic_linker='OS/2 ld.exe' + shlibpath_var=LIBPATH + ;; + +osf3* | osf4* | osf5*) + version_type=osf + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" + sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" + ;; + +rdos*) + dynamic_linker=no + ;; + +solaris*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + # ldd complains unless libraries are executable + postinstall_cmds='chmod +x $lib' + ;; + +sunos4*) + version_type=sunos + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + if test "$with_gnu_ld" = yes; then + need_lib_prefix=no + fi + need_version=yes + ;; + +sysv4 | sysv4.3*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + case $host_vendor in + sni) + shlibpath_overrides_runpath=no + need_lib_prefix=no + export_dynamic_flag_spec='${wl}-Blargedynsym' + runpath_var=LD_RUN_PATH + ;; + siemens) + need_lib_prefix=no + ;; + motorola) + need_lib_prefix=no + need_version=no + shlibpath_overrides_runpath=no + sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' + ;; + esac + ;; + +sysv4*MP*) + if test -d /usr/nec ;then + version_type=linux + library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' + soname_spec='$libname${shared_ext}.$major' + shlibpath_var=LD_LIBRARY_PATH + fi + ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + version_type=freebsd-elf + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + hardcode_into_libs=yes + if test "$with_gnu_ld" = yes; then + sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' + shlibpath_overrides_runpath=no + else + sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' + shlibpath_overrides_runpath=yes + case $host_os in + sco3.2v5*) + sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" + ;; + esac + fi + sys_lib_dlsearch_path_spec='/usr/lib' + ;; + +uts4*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +*) + dynamic_linker=no + ;; +esac +{ $as_echo "$as_me:$LINENO: result: $dynamic_linker" >&5 +$as_echo "$dynamic_linker" >&6; } +test "$dynamic_linker" = no && can_build_shared=no + +if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then + $as_echo_n "(cached) " >&6 +else + lt_cv_sys_lib_search_path_spec="$sys_lib_search_path_spec" +fi + +sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" +if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then + $as_echo_n "(cached) " >&6 +else + lt_cv_sys_lib_dlsearch_path_spec="$sys_lib_dlsearch_path_spec" +fi + +sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" + +variables_saved_for_relink="PATH $shlibpath_var $runpath_var" +if test "$GCC" = yes; then + variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" +fi + +{ $as_echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5 +$as_echo_n "checking how to hardcode library paths into programs... " >&6; } +hardcode_action_CXX= +if test -n "$hardcode_libdir_flag_spec_CXX" || \ + test -n "$runpath_var_CXX" || \ + test "X$hardcode_automatic_CXX" = "Xyes" ; then + + # We can hardcode non-existant directories. + if test "$hardcode_direct_CXX" != no && + # If the only mechanism to avoid hardcoding is shlibpath_var, we + # have to relink, otherwise we might link with an installed library + # when we should be linking with a yet-to-be-installed one + ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, CXX)" != no && + test "$hardcode_minus_L_CXX" != no; then + # Linking always hardcodes the temporary library directory. + hardcode_action_CXX=relink + else + # We can link without hardcoding, and we can hardcode nonexisting dirs. + hardcode_action_CXX=immediate + fi +else + # We cannot hardcode anything, or else we can only hardcode existing + # directories. + hardcode_action_CXX=unsupported +fi +{ $as_echo "$as_me:$LINENO: result: $hardcode_action_CXX" >&5 +$as_echo "$hardcode_action_CXX" >&6; } + +if test "$hardcode_action_CXX" = relink; then + # Fast installation is not supported + enable_fast_install=no +elif test "$shlibpath_overrides_runpath" = yes || + test "$enable_shared" = no; then + # Fast installation is not necessary + enable_fast_install=needless +fi + + +# The else clause should only fire when bootstrapping the +# libtool distribution, otherwise you forgot to ship ltmain.sh +# with your package, and you will get complaints that there are +# no rules to generate ltmain.sh. +if test -f "$ltmain"; then + # See if we are running on zsh, and set the options which allow our commands through + # without removal of \ escapes. + if test -n "${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST + fi + # Now quote all the things that may contain metacharacters while being + # careful not to overquote the AC_SUBSTed values. We take copies of the + # variables and quote the copies for generation of the libtool script. + for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \ + SED SHELL STRIP \ + libname_spec library_names_spec soname_spec extract_expsyms_cmds \ + old_striplib striplib file_magic_cmd finish_cmds finish_eval \ + deplibs_check_method reload_flag reload_cmds need_locks \ + lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \ + lt_cv_sys_global_symbol_to_c_name_address \ + sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ + old_postinstall_cmds old_postuninstall_cmds \ + compiler_CXX \ + CC_CXX \ + LD_CXX \ + lt_prog_compiler_wl_CXX \ + lt_prog_compiler_pic_CXX \ + lt_prog_compiler_static_CXX \ + lt_prog_compiler_no_builtin_flag_CXX \ + export_dynamic_flag_spec_CXX \ + thread_safe_flag_spec_CXX \ + whole_archive_flag_spec_CXX \ + enable_shared_with_static_runtimes_CXX \ + old_archive_cmds_CXX \ + old_archive_from_new_cmds_CXX \ + predep_objects_CXX \ + postdep_objects_CXX \ + predeps_CXX \ + postdeps_CXX \ + compiler_lib_search_path_CXX \ + compiler_lib_search_dirs_CXX \ + archive_cmds_CXX \ + archive_expsym_cmds_CXX \ + postinstall_cmds_CXX \ + postuninstall_cmds_CXX \ + old_archive_from_expsyms_cmds_CXX \ + allow_undefined_flag_CXX \ + no_undefined_flag_CXX \ + export_symbols_cmds_CXX \ + hardcode_libdir_flag_spec_CXX \ + hardcode_libdir_flag_spec_ld_CXX \ + hardcode_libdir_separator_CXX \ + hardcode_automatic_CXX \ + module_cmds_CXX \ + module_expsym_cmds_CXX \ + lt_cv_prog_compiler_c_o_CXX \ + fix_srcfile_path_CXX \ + exclude_expsyms_CXX \ + include_expsyms_CXX; do + + case $var in + old_archive_cmds_CXX | \ + old_archive_from_new_cmds_CXX | \ + archive_cmds_CXX | \ + archive_expsym_cmds_CXX | \ + module_cmds_CXX | \ + module_expsym_cmds_CXX | \ + old_archive_from_expsyms_cmds_CXX | \ + export_symbols_cmds_CXX | \ + extract_expsyms_cmds | reload_cmds | finish_cmds | \ + postinstall_cmds | postuninstall_cmds | \ + old_postinstall_cmds | old_postuninstall_cmds | \ + sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) + # Double-quote double-evaled strings. + eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" + ;; + *) + eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" + ;; + esac + done + + case $lt_echo in + *'\$0 --fallback-echo"') + lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'` + ;; + esac + +cfgfile="$ofile" + + cat <<__EOF__ >> "$cfgfile" +# ### BEGIN LIBTOOL TAG CONFIG: $tagname + +# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: + +# Shell to use when invoking shell scripts. +SHELL=$lt_SHELL + +# Whether or not to build shared libraries. +build_libtool_libs=$enable_shared + +# Whether or not to build static libraries. +build_old_libs=$enable_static + +# Whether or not to add -lc for building shared libraries. +build_libtool_need_lc=$archive_cmds_need_lc_CXX + +# Whether or not to disallow shared libs when runtime libs are static +allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_CXX + +# Whether or not to optimize for fast installation. +fast_install=$enable_fast_install + +# The host system. +host_alias=$host_alias +host=$host +host_os=$host_os + +# The build system. +build_alias=$build_alias +build=$build +build_os=$build_os + +# An echo program that does not interpret backslashes. +echo=$lt_echo + +# The archiver. +AR=$lt_AR +AR_FLAGS=$lt_AR_FLAGS + +# A C compiler. +LTCC=$lt_LTCC + +# LTCC compiler flags. +LTCFLAGS=$lt_LTCFLAGS + +# A language-specific compiler. +CC=$lt_compiler_CXX + +# Is the compiler the GNU C compiler? +with_gcc=$GCC_CXX + +# An ERE matcher. +EGREP=$lt_EGREP + +# The linker used to build libraries. +LD=$lt_LD_CXX + +# Whether we need hard or soft links. +LN_S=$lt_LN_S + +# A BSD-compatible nm program. +NM=$lt_NM + +# A symbol stripping program +STRIP=$lt_STRIP + +# Used to examine libraries when file_magic_cmd begins "file" +MAGIC_CMD=$MAGIC_CMD + +# Used on cygwin: DLL creation program. +DLLTOOL="$DLLTOOL" + +# Used on cygwin: object dumper. +OBJDUMP="$OBJDUMP" + +# Used on cygwin: assembler. +AS="$AS" + +# The name of the directory that contains temporary libtool files. +objdir=$objdir + +# How to create reloadable object files. +reload_flag=$lt_reload_flag +reload_cmds=$lt_reload_cmds + +# How to pass a linker flag through the compiler. +wl=$lt_lt_prog_compiler_wl_CXX + +# Object file suffix (normally "o"). +objext="$ac_objext" + +# Old archive suffix (normally "a"). +libext="$libext" + +# Shared library suffix (normally ".so"). +shrext_cmds='$shrext_cmds' + +# Executable file suffix (normally ""). +exeext="$exeext" + +# Additional compiler flags for building library objects. +pic_flag=$lt_lt_prog_compiler_pic_CXX +pic_mode=$pic_mode + +# What is the maximum length of a command? +max_cmd_len=$lt_cv_sys_max_cmd_len + +# Does compiler simultaneously support -c and -o options? +compiler_c_o=$lt_lt_cv_prog_compiler_c_o_CXX + +# Must we lock files when doing compilation? +need_locks=$lt_need_locks + +# Do we need the lib prefix for modules? +need_lib_prefix=$need_lib_prefix + +# Do we need a version for libraries? +need_version=$need_version + +# Whether dlopen is supported. +dlopen_support=$enable_dlopen + +# Whether dlopen of programs is supported. +dlopen_self=$enable_dlopen_self + +# Whether dlopen of statically linked programs is supported. +dlopen_self_static=$enable_dlopen_self_static + +# Compiler flag to prevent dynamic linking. +link_static_flag=$lt_lt_prog_compiler_static_CXX + +# Compiler flag to turn off builtin functions. +no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_CXX + +# Compiler flag to allow reflexive dlopens. +export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_CXX + +# Compiler flag to generate shared objects directly from archives. +whole_archive_flag_spec=$lt_whole_archive_flag_spec_CXX + +# Compiler flag to generate thread-safe objects. +thread_safe_flag_spec=$lt_thread_safe_flag_spec_CXX + +# Library versioning type. +version_type=$version_type + +# Format of library name prefix. +libname_spec=$lt_libname_spec + +# List of archive names. First name is the real one, the rest are links. +# The last name is the one that the linker finds with -lNAME. +library_names_spec=$lt_library_names_spec + +# The coded name of the library, if different from the real name. +soname_spec=$lt_soname_spec + +# Commands used to build and install an old-style archive. +RANLIB=$lt_RANLIB +old_archive_cmds=$lt_old_archive_cmds_CXX +old_postinstall_cmds=$lt_old_postinstall_cmds +old_postuninstall_cmds=$lt_old_postuninstall_cmds + +# Create an old-style archive from a shared archive. +old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_CXX + +# Create a temporary old-style archive to link instead of a shared archive. +old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_CXX + +# Commands used to build and install a shared archive. +archive_cmds=$lt_archive_cmds_CXX +archive_expsym_cmds=$lt_archive_expsym_cmds_CXX +postinstall_cmds=$lt_postinstall_cmds +postuninstall_cmds=$lt_postuninstall_cmds + +# Commands used to build a loadable module (assumed same as above if empty) +module_cmds=$lt_module_cmds_CXX +module_expsym_cmds=$lt_module_expsym_cmds_CXX + +# Commands to strip libraries. +old_striplib=$lt_old_striplib +striplib=$lt_striplib + +# Dependencies to place before the objects being linked to create a +# shared library. +predep_objects=$lt_predep_objects_CXX + +# Dependencies to place after the objects being linked to create a +# shared library. +postdep_objects=$lt_postdep_objects_CXX + +# Dependencies to place before the objects being linked to create a +# shared library. +predeps=$lt_predeps_CXX + +# Dependencies to place after the objects being linked to create a +# shared library. +postdeps=$lt_postdeps_CXX + +# The directories searched by this compiler when creating a shared +# library +compiler_lib_search_dirs=$lt_compiler_lib_search_dirs_CXX + +# The library search path used internally by the compiler when linking +# a shared library. +compiler_lib_search_path=$lt_compiler_lib_search_path_CXX + +# Method to check whether dependent libraries are shared objects. +deplibs_check_method=$lt_deplibs_check_method + +# Command to use when deplibs_check_method == file_magic. +file_magic_cmd=$lt_file_magic_cmd + +# Flag that allows shared libraries with undefined symbols to be built. +allow_undefined_flag=$lt_allow_undefined_flag_CXX + +# Flag that forces no undefined symbols. +no_undefined_flag=$lt_no_undefined_flag_CXX + +# Commands used to finish a libtool library installation in a directory. +finish_cmds=$lt_finish_cmds + +# Same as above, but a single script fragment to be evaled but not shown. +finish_eval=$lt_finish_eval + +# Take the output of nm and produce a listing of raw symbols and C names. +global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe + +# Transform the output of nm in a proper C declaration +global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl + +# Transform the output of nm in a C name address pair +global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address + +# This is the shared library runtime path variable. +runpath_var=$runpath_var + +# This is the shared library path variable. +shlibpath_var=$shlibpath_var + +# Is shlibpath searched before the hard-coded library search path? +shlibpath_overrides_runpath=$shlibpath_overrides_runpath + +# How to hardcode a shared library path into an executable. +hardcode_action=$hardcode_action_CXX + +# Whether we should hardcode library paths into libraries. +hardcode_into_libs=$hardcode_into_libs + +# Flag to hardcode \$libdir into a binary during linking. +# This must work even if \$libdir does not exist. +hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_CXX + +# If ld is used when linking, flag to hardcode \$libdir into +# a binary during linking. This must work even if \$libdir does +# not exist. +hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_CXX + +# Whether we need a single -rpath flag with a separated argument. +hardcode_libdir_separator=$lt_hardcode_libdir_separator_CXX + +# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the +# resulting binary. +hardcode_direct=$hardcode_direct_CXX + +# Set to yes if using the -LDIR flag during linking hardcodes DIR into the +# resulting binary. +hardcode_minus_L=$hardcode_minus_L_CXX + +# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into +# the resulting binary. +hardcode_shlibpath_var=$hardcode_shlibpath_var_CXX + +# Set to yes if building a shared library automatically hardcodes DIR into the library +# and all subsequent libraries and executables linked against it. +hardcode_automatic=$hardcode_automatic_CXX + +# Variables whose values should be saved in libtool wrapper scripts and +# restored at relink time. +variables_saved_for_relink="$variables_saved_for_relink" + +# Whether libtool must link a program against all its dependency libraries. +link_all_deplibs=$link_all_deplibs_CXX + +# Compile-time system search path for libraries +sys_lib_search_path_spec=$lt_sys_lib_search_path_spec + +# Run-time system search path for libraries +sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec + +# Fix the shell variable \$srcfile for the compiler. +fix_srcfile_path=$lt_fix_srcfile_path + +# Set to yes if exported symbols are required. +always_export_symbols=$always_export_symbols_CXX + +# The commands to list exported symbols. +export_symbols_cmds=$lt_export_symbols_cmds_CXX + +# The commands to extract the exported symbol list from a shared archive. +extract_expsyms_cmds=$lt_extract_expsyms_cmds + +# Symbols that should not be listed in the preloaded symbols. +exclude_expsyms=$lt_exclude_expsyms_CXX + +# Symbols that must always be exported. +include_expsyms=$lt_include_expsyms_CXX + +# ### END LIBTOOL TAG CONFIG: $tagname + +__EOF__ + + +else + # If there is no Makefile yet, we rely on a make rule to execute + # `config.status --recheck' to rerun these tests and create the + # libtool script then. + ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'` + if test -f "$ltmain_in"; then + test -f Makefile && make "$ltmain" + fi +fi + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +CC=$lt_save_CC +LDCXX=$LD +LD=$lt_save_LD +GCC=$lt_save_GCC +with_gnu_ldcxx=$with_gnu_ld +with_gnu_ld=$lt_save_with_gnu_ld +lt_cv_path_LDCXX=$lt_cv_path_LD +lt_cv_path_LD=$lt_save_path_LD +lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld +lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld + + else + tagname="" + fi + ;; + + F77) + if test -n "$F77" && test "X$F77" != "Xno"; then + : + else + tagname="" + fi + ;; + + GCJ) + if test -n "$GCJ" && test "X$GCJ" != "Xno"; then + : + else + tagname="" + fi + ;; + + RC) + : + ;; + + *) + { { $as_echo "$as_me:$LINENO: error: Unsupported tag name: $tagname" >&5 +$as_echo "$as_me: error: Unsupported tag name: $tagname" >&2;} + { (exit 1); exit 1; }; } + ;; + esac + + # Append the new tag name to the list of available tags. + if test -n "$tagname" ; then + available_tags="$available_tags $tagname" + fi + fi + done + IFS="$lt_save_ifs" + + # Now substitute the updated list of available tags. + if eval "sed -e 's/^available_tags=.*\$/available_tags=\"$available_tags\"/' \"$ofile\" > \"${ofile}T\""; then + mv "${ofile}T" "$ofile" + chmod +x "$ofile" + else + rm -f "${ofile}T" + { { $as_echo "$as_me:$LINENO: error: unable to update list of available tagged configurations." >&5 +$as_echo "$as_me: error: unable to update list of available tagged configurations." >&2;} + { (exit 1); exit 1; }; } + fi +fi + + + +# This can be used to rebuild libtool when needed +LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh" + +# Always use our own libtool. +LIBTOOL='$(SHELL) $(top_builddir)/libtool' + +# Prevent multiple expansion + + + + + + + + + + + + + + + + +# Extract the first word of "help2man", so it can be a program name with args. +set dummy help2man; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_FOUND_HELP2MAN+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$FOUND_HELP2MAN"; then + ac_cv_prog_FOUND_HELP2MAN="$FOUND_HELP2MAN" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_FOUND_HELP2MAN="yes" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + + test -z "$ac_cv_prog_FOUND_HELP2MAN" && ac_cv_prog_FOUND_HELP2MAN="no" +fi +fi +FOUND_HELP2MAN=$ac_cv_prog_FOUND_HELP2MAN +if test -n "$FOUND_HELP2MAN"; then + { $as_echo "$as_me:$LINENO: result: $FOUND_HELP2MAN" >&5 +$as_echo "$FOUND_HELP2MAN" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + + +############################################################################### +# top-level platform check +############################################################################### + +{ $as_echo "$as_me:$LINENO: checking $PACKAGE_NAME platform portability" >&5 +$as_echo_n "checking $PACKAGE_NAME platform portability... " >&6; } +X_PLATFORM=posix +case ${host} in +*-*-cygwin) + # do not support shared + enable_shared=no + X_CXX_W="$X_CXX_W -Wno-format" + if test "$enable_cygwin_win32" = "yes"; then + X_PLATFORM=win32 + X_CXX_ARCH="$X_CXX_ARCH -mwin32" + fi + ;; +*-*-mingw*) + # do not support shared + enable_shared=no + X_PLATFORM=win32 + X_MINGW_LIBS="$X_MINGW_LIBS" + X_CXX_W="$X_CXX_W -Wno-format" + if test "$enable_mingw_threads" = "yes"; then + X_CXX_ARCH="$X_CXX_ARCH -mthreads" + fi + ;; +esac +{ $as_echo "$as_me:$LINENO: result: $X_PLATFORM" >&5 +$as_echo "$X_PLATFORM" >&6; } + +############################################################################### +# prepare project metadata +############################################################################### + +PROJECT_name="MP4v2" +PROJECT_name_lower="mp4v2" +PROJECT_name_upper="MP4V2" +PROJECT_name_formal="MP4v2 1.9.1" +PROJECT_url_website="http://code.google.com/p/mp4v2" +PROJECT_url_downloads="http://code.google.com/p/mp4v2/downloads/list" +PROJECT_url_discussion="http://groups.google.com/group/mp4v2" +PROJECT_irc="irc://irc.freenode.net/mp4v2" +PROJECT_bugreport="<eddyg@myreflection.org>" + +PROJECT_version="1.9.1" +PROJECT_version_hex="0x00010901" +PROJECT_version_major="1" +PROJECT_version_minor="9" +PROJECT_version_point="1" +PROJECT_repo_url="https://mp4v2.googlecode.com/svn/releases/1.9.1" +PROJECT_repo_root="https://mp4v2.googlecode.com/svn" +PROJECT_repo_uuid="6e6572fa-98a6-11dd-ad9f-f77439c74b79" +PROJECT_repo_rev="368" +PROJECT_repo_date="2009-07-14 11:25:03 +1200 (Tue, 14 Jul 2009)" +PROJECT_repo_type="stable" +PROJECT_build="`date`" + +test -z "$PROJECT_version_hex" && PROJECT_version_hex="0x0000000000000000LL" +test -z "$PROJECT_version_major" && PROJECT_version_major="0" +test -z "$PROJECT_version_minor" && PROJECT_version_minor="0" +test -z "$PROJECT_version_point" && PROJECT_version_point="0" +test -z "$PROJECT_repo_url" && PROJECT_repo_url="svn://nowhere.com/project/unknown" +test -z "$PROJECT_repo_root" && PROJECT_repo_root="svn://nowhere.com/project" +test -z "$PROJECT_repo_uuid" && PROJECT_repo_uuid="00000000-0000-0000-0000-000000000000" +test -z "$PROJECT_repo_rev" && PROJECT_repo_rev="0" +test -z "$PROJECT_repo_date" && PROJECT_repo_date="unknown" +test -z "$PROJECT_repo_type" && PROJECT_repo_type="unknown" +test -z "$PROJECT_build" && PROJECT_build="unknown" + + + + + + + + + + + + + + + + + + + + + + + +############################################################################### +# checks for libraries +############################################################################### + +############################################################################### +# checks for header files +############################################################################### + +############################################################################### +# checks for typedefs, structures, and compiler characteristics +############################################################################### + +############################################################################### +# replace -ggdb3 with -ggdb2 to avoid GNU 'as' from failing +# See http://code.google.com/p/mp4v2/issues/detail?id=27 +############################################################################### +if test "$GXX" = "yes"; then + CXXFLAGS_GGDB3=`echo "$CXXFLAGS" | sed -e 's/-ggdb3/-ggdb2/'` + CXXFLAGS="$CXXFLAGS_GGDB3" +fi + +############################################################################### +# additional ldflags +############################################################################### + +case ${host} in + *-*-darwin*) + X_libmp4v2_la_LDFLAGS='-Wl,-current_version,$(PROJECT_version_major).$(PROJECT_version_minor).$(PROJECT_version_point) -Wl,-compatibility_version,$(PROJECT_version_major).0.0' + ;; + *) + X_libmp4v2_la_LDFLAGS= + ;; +esac + + + +############################################################################### +# check for --disable-fvisibility +############################################################################### + +if test "$enable_fvisibility" != "no" -a "$GXX" = "yes"; then + case ${host} in + *-*-cygwin) + ;; + *-*-mingw*) + ;; + *) + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + { $as_echo "$as_me:$LINENO: checking if $CXX supports -fvisibility" >&5 +$as_echo_n "checking if $CXX supports -fvisibility... " >&6; } +if test "${x_cv_fvisibility+set}" = set; then + $as_echo_n "(cached) " >&6 +else + + x_save="$CXXFLAGS" + CXXFLAGS="$CXXFLAGS -fvisibility=hidden" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + x_cv_fvisibility=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + x_cv_fvisibility=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + if test "$x_cv_fvisibility" != "yes"; then + CXXFLAGS="$x_save" + fi + x_save= + +fi +{ $as_echo "$as_me:$LINENO: result: $x_cv_fvisibility" >&5 +$as_echo "$x_cv_fvisibility" >&6; } + ;; + esac +fi + +############################################################################### +# check for --disable-gch +############################################################################### + +{ $as_echo "$as_me:$LINENO: checking if GCC precompiled-headers should be created" >&5 +$as_echo_n "checking if GCC precompiled-headers should be created... " >&6; } + +X_GCH=0 +X_GCH_FLAGS= +X_GCH_STATIC=0 +X_GCH_STATIC_FLAGS="$lt_prog_compiler_static_CXX" +X_GCH_SHARED=0 +X_GCH_SHARED_FLAGS="$lt_prog_compiler_pic_CXX" + +if test "$enable_gch" = "yes"; then + X_GCH=1 +elif test "$enable_gch" != "no"; then + if test "$GXX" = "yes"; then + case ${host_os} in + cygwin*|darwin*|freebsd*|linux*|mingw*|solaris*) + X_GCH=1 + ;; + esac + fi +fi + +if test "$X_GCH" -eq 1; then + x_gch_result="yes" + if test "$enable_static" = "yes"; then + X_GCH_STATIC=1 + fi + if test "$enable_shared" = "yes"; then + X_GCH_SHARED=1 + fi +else + x_gch_result="no" +fi + +{ $as_echo "$as_me:$LINENO: result: $x_gch_result" >&5 +$as_echo "$x_gch_result" >&6; } + + + + + + + + +############################################################################### +# check for --disable-largefile +############################################################################### + +if test "$enable_largefile" != "no" -a "$ac_cv_header_unistd_h" = "yes"; then + case ${host_cpu} in + i?86|ppc) + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + { $as_echo "$as_me:$LINENO: checking if LFS (large file support) is required" >&5 +$as_echo_n "checking if LFS (large file support) is required... " >&6; } +if test "${x_cv_largefile+set}" = set; then + $as_echo_n "(cached) " >&6 +else + + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +#include <unistd.h> +#ifndef _LFS_LARGEFILE + error: not LFS conformant +#endif + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + x_cv_largefile=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + x_cv_largefile=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:$LINENO: result: $x_cv_largefile" >&5 +$as_echo "$x_cv_largefile" >&6; } + if test "$x_cv_largefile" = "yes"; then + +cat >>confdefs.h <<\_ACEOF +#define NEED_LFS_ACTIVATION 1 +_ACEOF + + fi + ;; + esac +fi + +############################################################################### +# set arch flags +############################################################################### + +if test "$GXX" = "yes"; then + { $as_echo "$as_me:$LINENO: checking arch flags" >&5 +$as_echo_n "checking arch flags... " >&6; } + x_flags= + x_save_IFS=$IFS; IFS=, + for arch in ${enable_ub}; do + case "$arch" in + ""|no) + ;; + yes) + case ${host} in + *-*-darwin*) + x_flags="$xflags -arch i386 -arch x86_64 -arch ppc -arch ppc64" + ;; + esac + ;; + *) + x_flags="$x_flags -arch $arch" + ;; + esac + done + IFS=$x_save_IFS + + case "$enable_bi" in + ""|no|yes) + ;; + *) + x_flags="$x_flags -m${enable_bi}" + ;; + esac + + if test -n "$x_flags"; then + { $as_echo "$as_me:$LINENO: result: $x_flags" >&5 +$as_echo "$x_flags" >&6; } + X_CXX_ARCH="$X_CXX_ARCH $x_flags" + else + { $as_echo "$as_me:$LINENO: result: none" >&5 +$as_echo "none" >&6; } + fi + + x_flags= +fi + +############################################################################### +# disable debugging +############################################################################### + +if test "$enable_debug" = "no"; then + if test "$GCC" = "yes"; then + CFLAGS=`echo "$CFLAGS" | sed -e 's/-g[^ ]*[ ]*//' -e 's/^ //' -e 's/ $//'` + fi + if test "$GXX" = "yes"; then + CXXFLAGS=`echo "$CXXFLAGS" | sed -e 's/-g[^ ]*[ ]*//' -e 's/^ //' -e 's/ $//'` + fi + fi + +############################################################################### +# disable optimizing +############################################################################### + +if test "$enable_optimize" = "no"; then + if test "$GCC" = "yes"; then + CFLAGS=`echo "$CFLAGS" | sed -e 's/-O[^ ]*[ ]*//' -e 's/^ //' -e 's/ $//'` + fi + if test "$GXX" = "yes"; then + CXXFLAGS=`echo "$CXXFLAGS" | sed -e 's/-O[^ ]*[ ]*//' -e 's/^ //' -e 's/ $//'` + fi + fi + +############################################################################### +# checks for library functions +############################################################################### + +############################################################################### +# conditional compilation +############################################################################### + + + +if test "$X_PLATFORM" = "posix"; then + ADD_PLATFORM_POSIX_TRUE= + ADD_PLATFORM_POSIX_FALSE='#' +else + ADD_PLATFORM_POSIX_TRUE='#' + ADD_PLATFORM_POSIX_FALSE= +fi + + + +if test "$X_PLATFORM" = "win32"; then + ADD_PLATFORM_WIN32_TRUE= + ADD_PLATFORM_WIN32_FALSE='#' +else + ADD_PLATFORM_WIN32_TRUE='#' + ADD_PLATFORM_WIN32_FALSE= +fi + + + + +if test "$enable_util" != "no"; then + ADD_UTIL_TRUE= + ADD_UTIL_FALSE='#' +else + ADD_UTIL_TRUE='#' + ADD_UTIL_FALSE= +fi + + + +if test "$X_PLATFORM" != "win32"; then + ADD_MANS_TRUE= + ADD_MANS_FALSE='#' +else + ADD_MANS_TRUE='#' + ADD_MANS_FALSE= +fi + + +############################################################################### +# declare common substitutions +############################################################################### + + + + + + + +############################################################################### +# output files +############################################################################### + +ac_config_headers="$ac_config_headers libplatform/config.h" + + +ac_config_files="$ac_config_files GNUmakefile" + +ac_config_files="$ac_config_files include/mp4v2/project.h" + +ac_config_files="$ac_config_files project/project.m4" + + +cat >confcache <<\_ACEOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. +# +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. +# +# `ac_cv_env_foo' variables (set or unset) will be overridden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +_ACEOF + +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, we kill variables containing newlines. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +( + for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:$LINENO: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) $as_unset $ac_var ;; + esac ;; + esac + done + + (set) 2>&1 | + case $as_nl`(ac_space=' '; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + ;; #( + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) | + sed ' + /^ac_cv_env_/b end + t clear + :clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + :end' >>confcache +if diff "$cache_file" confcache >/dev/null 2>&1; then :; else + if test -w "$cache_file"; then + test "x$cache_file" != "x/dev/null" && + { $as_echo "$as_me:$LINENO: updating cache $cache_file" >&5 +$as_echo "$as_me: updating cache $cache_file" >&6;} + cat confcache >$cache_file + else + { $as_echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5 +$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} + fi +fi +rm -f confcache + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +DEFS=-DHAVE_CONFIG_H + +ac_libobjs= +ac_ltlibobjs= +for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue + # 1. Remove the extension, and $U if already installed. + ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' + ac_i=`$as_echo "$ac_i" | sed "$ac_script"` + # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR + # will be set to the directory where LIBOBJS objects are built. + ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext" + ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo' +done +LIBOBJS=$ac_libobjs + +LTLIBOBJS=$ac_ltlibobjs + + +if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then + { { $as_echo "$as_me:$LINENO: error: conditional \"AMDEP\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +$as_echo "$as_me: error: conditional \"AMDEP\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then + { { $as_echo "$as_me:$LINENO: error: conditional \"am__fastdepCXX\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +$as_echo "$as_me: error: conditional \"am__fastdepCXX\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then + { { $as_echo "$as_me:$LINENO: error: conditional \"am__fastdepCC\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +$as_echo "$as_me: error: conditional \"am__fastdepCC\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${ADD_PLATFORM_POSIX_TRUE}" && test -z "${ADD_PLATFORM_POSIX_FALSE}"; then + { { $as_echo "$as_me:$LINENO: error: conditional \"ADD_PLATFORM_POSIX\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +$as_echo "$as_me: error: conditional \"ADD_PLATFORM_POSIX\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${ADD_PLATFORM_WIN32_TRUE}" && test -z "${ADD_PLATFORM_WIN32_FALSE}"; then + { { $as_echo "$as_me:$LINENO: error: conditional \"ADD_PLATFORM_WIN32\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +$as_echo "$as_me: error: conditional \"ADD_PLATFORM_WIN32\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${ADD_UTIL_TRUE}" && test -z "${ADD_UTIL_FALSE}"; then + { { $as_echo "$as_me:$LINENO: error: conditional \"ADD_UTIL\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +$as_echo "$as_me: error: conditional \"ADD_UTIL\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${ADD_MANS_TRUE}" && test -z "${ADD_MANS_FALSE}"; then + { { $as_echo "$as_me:$LINENO: error: conditional \"ADD_MANS\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +$as_echo "$as_me: error: conditional \"ADD_MANS\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi + +: ${CONFIG_STATUS=./config.status} +ac_write_fail=0 +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ $as_echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 +$as_echo "$as_me: creating $CONFIG_STATUS" >&6;} +cat >$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +#! $SHELL +# Generated by $as_me. +# Run this file to recreate the current configuration. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +ac_cs_recheck=false +ac_cs_silent=false +SHELL=\${CONFIG_SHELL-$SHELL} +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + + + +# PATH needs CR +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + +# Support unset when possible. +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + { (exit 1); exit 1; } +fi + +# Work around bugs in pre-3.0 UWIN ksh. +for as_var in ENV MAIL MAILPATH +do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# Required to use basename. +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + + +# Name of the executable. +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# CDPATH. +$as_unset CDPATH + + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line after each line using $LINENO; the second 'sed' + # does the real work. The second script uses 'N' to pair each + # line-number line with the line containing $LINENO, and appends + # trailing '-' during substitution so that $LINENO is not a special + # case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # scripts with optimization help from Paolo Bonzini. Blame Lee + # E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | + sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno + N + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ + t loop + s/-\n.*// + ' >$as_me.lineno && + chmod +x "$as_me.lineno" || + { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 + { (exit 1); exit 1; }; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" + # Exit status is that of the last command. + exit +} + + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in +-n*) + case `echo 'x\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + *) ECHO_C='\c';; + esac;; +*) + ECHO_N='-n';; +esac +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -p' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -p' + fi +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +exec 6>&1 + +# Save the log message, to keep $[0] and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. +ac_log=" +This file was extended by MP4v2 $as_me 1.9.1, which was +generated by GNU Autoconf 2.63. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +on `(hostname || uname -n) 2>/dev/null | sed 1q` +" + +_ACEOF + +case $ac_config_files in *" +"*) set x $ac_config_files; shift; ac_config_files=$*;; +esac + +case $ac_config_headers in *" +"*) set x $ac_config_headers; shift; ac_config_headers=$*;; +esac + + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +# Files that config.status was made for. +config_files="$ac_config_files" +config_headers="$ac_config_headers" +config_commands="$ac_config_commands" + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +ac_cs_usage="\ +\`$as_me' instantiates files from templates according to the +current configuration. + +Usage: $0 [OPTION]... [FILE]... + + -h, --help print this help, then exit + -V, --version print version number and configuration settings, then exit + -q, --quiet, --silent + do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + --header=FILE[:TEMPLATE] + instantiate the configuration header FILE + +Configuration files: +$config_files + +Configuration headers: +$config_headers + +Configuration commands: +$config_commands + +Report bugs to <bug-autoconf@gnu.org>." + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_cs_version="\\ +MP4v2 config.status 1.9.1 +configured by $0, generated by GNU Autoconf 2.63, + with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" + +Copyright (C) 2008 Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." + +ac_pwd='$ac_pwd' +srcdir='$srcdir' +INSTALL='$INSTALL' +AWK='$AWK' +test -n "\$AWK" || AWK=awk +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# The default lists apply if the user does not specify any file. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=*) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` + ac_shift=: + ;; + *) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + esac + + case $ac_option in + # Handling of the options. + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) + $as_echo "$ac_cs_version"; exit ;; + --debug | --debu | --deb | --de | --d | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + CONFIG_FILES="$CONFIG_FILES '$ac_optarg'" + ac_need_defaults=false;; + --header | --heade | --head | --hea ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + CONFIG_HEADERS="$CONFIG_HEADERS '$ac_optarg'" + ac_need_defaults=false;; + --he | --h) + # Conflict between --help and --header + { $as_echo "$as_me: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; };; + --help | --hel | -h ) + $as_echo "$ac_cs_usage"; exit ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) { $as_echo "$as_me: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; } ;; + + *) ac_config_targets="$ac_config_targets $1" + ac_need_defaults=false ;; + + esac + shift +done + +ac_configure_extra_args= + +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +if \$ac_cs_recheck; then + set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + shift + \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 + CONFIG_SHELL='$SHELL' + export CONFIG_SHELL + exec "\$@" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX + $as_echo "$ac_log" +} >&5 + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +# +# INIT-COMMANDS +# +AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + +# Handling of arguments. +for ac_config_target in $ac_config_targets +do + case $ac_config_target in + "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; + "libplatform/config.h") CONFIG_HEADERS="$CONFIG_HEADERS libplatform/config.h" ;; + "GNUmakefile") CONFIG_FILES="$CONFIG_FILES GNUmakefile" ;; + "include/mp4v2/project.h") CONFIG_FILES="$CONFIG_FILES include/mp4v2/project.h" ;; + "project/project.m4") CONFIG_FILES="$CONFIG_FILES project/project.m4" ;; + + *) { { $as_echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 +$as_echo "$as_me: error: invalid argument: $ac_config_target" >&2;} + { (exit 1); exit 1; }; };; + esac +done + + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files + test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers + test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason against having it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Hook for its removal unless debugging. +# Note that there is a small window in which the directory will not be cleaned: +# after its creation but before its name has been assigned to `$tmp'. +$debug || +{ + tmp= + trap 'exit_status=$? + { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status +' 0 + trap '{ (exit 1); exit 1; }' 1 2 13 15 +} +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && + test -n "$tmp" && test -d "$tmp" +} || +{ + tmp=./conf$$-$RANDOM + (umask 077 && mkdir "$tmp") +} || +{ + $as_echo "$as_me: cannot create a temporary directory in ." >&2 + { (exit 1); exit 1; } +} + +# Set up the scripts for CONFIG_FILES section. +# No need to generate them if there are no CONFIG_FILES. +# This happens for instance with `./config.status config.h'. +if test -n "$CONFIG_FILES"; then + + +ac_cr='
' +ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null` +if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then + ac_cs_awk_cr='\\r' +else + ac_cs_awk_cr=$ac_cr +fi + +echo 'BEGIN {' >"$tmp/subs1.awk" && +_ACEOF + + +{ + echo "cat >conf$$subs.awk <<_ACEOF" && + echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && + echo "_ACEOF" +} >conf$$subs.sh || + { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 +$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} + { (exit 1); exit 1; }; } +ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'` +ac_delim='%!_!# ' +for ac_last_try in false false false false false :; do + . ./conf$$subs.sh || + { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 +$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} + { (exit 1); exit 1; }; } + + ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` + if test $ac_delim_n = $ac_delim_num; then + break + elif $ac_last_try; then + { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 +$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} + { (exit 1); exit 1; }; } + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done +rm -f conf$$subs.sh + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +cat >>"\$tmp/subs1.awk" <<\\_ACAWK && +_ACEOF +sed -n ' +h +s/^/S["/; s/!.*/"]=/ +p +g +s/^[^!]*!// +:repl +t repl +s/'"$ac_delim"'$// +t delim +:nl +h +s/\(.\{148\}\).*/\1/ +t more1 +s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ +p +n +b repl +:more1 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t nl +:delim +h +s/\(.\{148\}\).*/\1/ +t more2 +s/["\\]/\\&/g; s/^/"/; s/$/"/ +p +b +:more2 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t delim +' <conf$$subs.awk | sed ' +/^[^""]/{ + N + s/\n// +} +' >>$CONFIG_STATUS || ac_write_fail=1 +rm -f conf$$subs.awk +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +_ACAWK +cat >>"\$tmp/subs1.awk" <<_ACAWK && + for (key in S) S_is_set[key] = 1 + FS = "" + +} +{ + line = $ 0 + nfields = split(line, field, "@") + substed = 0 + len = length(field[1]) + for (i = 2; i < nfields; i++) { + key = field[i] + keylen = length(key) + if (S_is_set[key]) { + value = S[key] + line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) + len += length(value) + length(field[++i]) + substed = 1 + } else + len += 1 + keylen + } + + print line +} + +_ACAWK +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then + sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" +else + cat +fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ + || { { $as_echo "$as_me:$LINENO: error: could not setup config files machinery" >&5 +$as_echo "$as_me: error: could not setup config files machinery" >&2;} + { (exit 1); exit 1; }; } +_ACEOF + +# VPATH may cause trouble with some makes, so we remove $(srcdir), +# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=/{ +s/:*\$(srcdir):*/:/ +s/:*\${srcdir}:*/:/ +s/:*@srcdir@:*/:/ +s/^\([^=]*=[ ]*\):*/\1/ +s/:*$// +s/^[^=]*=[ ]*$// +}' +fi + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +fi # test -n "$CONFIG_FILES" + +# Set up the scripts for CONFIG_HEADERS section. +# No need to generate them if there are no CONFIG_HEADERS. +# This happens for instance with `./config.status Makefile'. +if test -n "$CONFIG_HEADERS"; then +cat >"$tmp/defines.awk" <<\_ACAWK || +BEGIN { +_ACEOF + +# Transform confdefs.h into an awk script `defines.awk', embedded as +# here-document in config.status, that substitutes the proper values into +# config.h.in to produce config.h. + +# Create a delimiter string that does not exist in confdefs.h, to ease +# handling of long lines. +ac_delim='%!_!# ' +for ac_last_try in false false :; do + ac_t=`sed -n "/$ac_delim/p" confdefs.h` + if test -z "$ac_t"; then + break + elif $ac_last_try; then + { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_HEADERS" >&5 +$as_echo "$as_me: error: could not make $CONFIG_HEADERS" >&2;} + { (exit 1); exit 1; }; } + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done + +# For the awk script, D is an array of macro values keyed by name, +# likewise P contains macro parameters if any. Preserve backslash +# newline sequences. + +ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* +sed -n ' +s/.\{148\}/&'"$ac_delim"'/g +t rset +:rset +s/^[ ]*#[ ]*define[ ][ ]*/ / +t def +d +:def +s/\\$// +t bsnl +s/["\\]/\\&/g +s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ +D["\1"]=" \3"/p +s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p +d +:bsnl +s/["\\]/\\&/g +s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ +D["\1"]=" \3\\\\\\n"\\/p +t cont +s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p +t cont +d +:cont +n +s/.\{148\}/&'"$ac_delim"'/g +t clear +:clear +s/\\$// +t bsnlc +s/["\\]/\\&/g; s/^/"/; s/$/"/p +d +:bsnlc +s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p +b cont +' <confdefs.h | sed ' +s/'"$ac_delim"'/"\\\ +"/g' >>$CONFIG_STATUS || ac_write_fail=1 + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + for (key in D) D_is_set[key] = 1 + FS = "" +} +/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { + line = \$ 0 + split(line, arg, " ") + if (arg[1] == "#") { + defundef = arg[2] + mac1 = arg[3] + } else { + defundef = substr(arg[1], 2) + mac1 = arg[2] + } + split(mac1, mac2, "(") #) + macro = mac2[1] + prefix = substr(line, 1, index(line, defundef) - 1) + if (D_is_set[macro]) { + # Preserve the white space surrounding the "#". + print prefix "define", macro P[macro] D[macro] + next + } else { + # Replace #undef with comments. This is necessary, for example, + # in the case of _POSIX_SOURCE, which is predefined and required + # on some systems where configure will not decide to define it. + if (defundef == "undef") { + print "/*", prefix defundef, macro, "*/" + next + } + } +} +{ print } +_ACAWK +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + { { $as_echo "$as_me:$LINENO: error: could not setup config headers machinery" >&5 +$as_echo "$as_me: error: could not setup config headers machinery" >&2;} + { (exit 1); exit 1; }; } +fi # test -n "$CONFIG_HEADERS" + + +eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS" +shift +for ac_tag +do + case $ac_tag in + :[FHLC]) ac_mode=$ac_tag; continue;; + esac + case $ac_mode$ac_tag in + :[FHL]*:*);; + :L* | :C*:*) { { $as_echo "$as_me:$LINENO: error: invalid tag $ac_tag" >&5 +$as_echo "$as_me: error: invalid tag $ac_tag" >&2;} + { (exit 1); exit 1; }; };; + :[FH]-) ac_tag=-:-;; + :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; + esac + ac_save_IFS=$IFS + IFS=: + set x $ac_tag + IFS=$ac_save_IFS + shift + ac_file=$1 + shift + + case $ac_mode in + :L) ac_source=$1;; + :[FH]) + ac_file_inputs= + for ac_f + do + case $ac_f in + -) ac_f="$tmp/stdin";; + *) # Look for the file first in the build tree, then in the source tree + # (if the path is not absolute). The absolute path cannot be DOS-style, + # because $ac_f cannot contain `:'. + test -f "$ac_f" || + case $ac_f in + [\\/$]*) false;; + *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; + esac || + { { $as_echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5 +$as_echo "$as_me: error: cannot find input file: $ac_f" >&2;} + { (exit 1); exit 1; }; };; + esac + case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac + ac_file_inputs="$ac_file_inputs '$ac_f'" + done + + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + configure_input='Generated from '` + $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' + `' by configure.' + if test x"$ac_file" != x-; then + configure_input="$ac_file. $configure_input" + { $as_echo "$as_me:$LINENO: creating $ac_file" >&5 +$as_echo "$as_me: creating $ac_file" >&6;} + fi + # Neutralize special characters interpreted by sed in replacement strings. + case $configure_input in #( + *\&* | *\|* | *\\* ) + ac_sed_conf_input=`$as_echo "$configure_input" | + sed 's/[\\\\&|]/\\\\&/g'`;; #( + *) ac_sed_conf_input=$configure_input;; + esac + + case $ac_tag in + *:-:* | *:-) cat >"$tmp/stdin" \ + || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 +$as_echo "$as_me: error: could not create $ac_file" >&2;} + { (exit 1); exit 1; }; } ;; + esac + ;; + esac + + ac_dir=`$as_dirname -- "$ac_file" || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + { as_dir="$ac_dir" + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || { { $as_echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 +$as_echo "$as_me: error: cannot create directory $as_dir" >&2;} + { (exit 1); exit 1; }; }; } + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + + case $ac_mode in + :F) + # + # CONFIG_FILE + # + + case $INSTALL in + [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; + *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; + esac +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# If the template does not know about datarootdir, expand it. +# FIXME: This hack should be removed a few years after 2.60. +ac_datarootdir_hack=; ac_datarootdir_seen= + +ac_sed_dataroot=' +/datarootdir/ { + p + q +} +/@datadir@/p +/@docdir@/p +/@infodir@/p +/@localedir@/p +/@mandir@/p +' +case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in +*datarootdir*) ac_datarootdir_seen=yes;; +*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) + { $as_echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 +$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + ac_datarootdir_hack=' + s&@datadir@&$datadir&g + s&@docdir@&$docdir&g + s&@infodir@&$infodir&g + s&@localedir@&$localedir&g + s&@mandir@&$mandir&g + s&\\\${datarootdir}&$datarootdir&g' ;; +esac +_ACEOF + +# Neutralize VPATH when `$srcdir' = `.'. +# Shell code in configure.ac might set extrasub. +# FIXME: do we really want to maintain this feature? +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_sed_extra="$ac_vpsub +$extrasub +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s|@configure_input@|$ac_sed_conf_input|;t t +s&@top_builddir@&$ac_top_builddir_sub&;t t +s&@top_build_prefix@&$ac_top_build_prefix&;t t +s&@srcdir@&$ac_srcdir&;t t +s&@abs_srcdir@&$ac_abs_srcdir&;t t +s&@top_srcdir@&$ac_top_srcdir&;t t +s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t +s&@builddir@&$ac_builddir&;t t +s&@abs_builddir@&$ac_abs_builddir&;t t +s&@abs_top_builddir@&$ac_abs_top_builddir&;t t +s&@INSTALL@&$ac_INSTALL&;t t +$ac_datarootdir_hack +" +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \ + || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 +$as_echo "$as_me: error: could not create $ac_file" >&2;} + { (exit 1); exit 1; }; } + +test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && + { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && + { $as_echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined." >&5 +$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined." >&2;} + + rm -f "$tmp/stdin" + case $ac_file in + -) cat "$tmp/out" && rm -f "$tmp/out";; + *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; + esac \ + || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 +$as_echo "$as_me: error: could not create $ac_file" >&2;} + { (exit 1); exit 1; }; } + ;; + :H) + # + # CONFIG_HEADER + # + if test x"$ac_file" != x-; then + { + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" + } >"$tmp/config.h" \ + || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 +$as_echo "$as_me: error: could not create $ac_file" >&2;} + { (exit 1); exit 1; }; } + if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then + { $as_echo "$as_me:$LINENO: $ac_file is unchanged" >&5 +$as_echo "$as_me: $ac_file is unchanged" >&6;} + else + rm -f "$ac_file" + mv "$tmp/config.h" "$ac_file" \ + || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 +$as_echo "$as_me: error: could not create $ac_file" >&2;} + { (exit 1); exit 1; }; } + fi + else + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \ + || { { $as_echo "$as_me:$LINENO: error: could not create -" >&5 +$as_echo "$as_me: error: could not create -" >&2;} + { (exit 1); exit 1; }; } + fi +# Compute "$ac_file"'s index in $config_headers. +_am_stamp_count=1 +for _am_header in $config_headers :; do + case $_am_header in + "$ac_file" | "$ac_file":* ) + break ;; + * ) + _am_stamp_count=`expr $_am_stamp_count + 1` ;; + esac +done +echo "timestamp for "$ac_file"" >`$as_dirname -- "$ac_file" || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'`/stamp-h$_am_stamp_count + ;; + + :C) { $as_echo "$as_me:$LINENO: executing $ac_file commands" >&5 +$as_echo "$as_me: executing $ac_file commands" >&6;} + ;; + esac + + + case $ac_file$ac_mode in + "depfiles":C) test x"$AMDEP_TRUE" != x"" || for mf in $CONFIG_FILES; do + # Strip MF so we end up with the name of the file. + mf=`echo "$mf" | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile or not. + # We used to match only the files named `Makefile.in', but + # some people rename them; so instead we look at the file content. + # Grep'ing the first line is not enough: some people post-process + # each Makefile.in and add a new line on top of each file to say so. + # So let's grep whole file. + if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then + dirpart=`$as_dirname -- "$mf" || +$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$mf" : 'X\(//\)[^/]' \| \ + X"$mf" : 'X\(//\)$' \| \ + X"$mf" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$mf" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + else + continue + fi + # Extract the definition of DEPDIR, am__include, and am__quote + # from the Makefile without running `make'. + DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` + test -z "$DEPDIR" && continue + am__include=`sed -n 's/^am__include = //p' < "$mf"` + test -z "am__include" && continue + am__quote=`sed -n 's/^am__quote = //p' < "$mf"` + # When using ansi2knr, U may be empty or an underscore; expand it + U=`sed -n 's/^U = //p' < "$mf"` + # Find all dependency output files, they are included files with + # $(DEPDIR) in their names. We invoke sed twice because it is the + # simplest approach to changing $(DEPDIR) to its actual value in the + # expansion. + for file in `sed -n " + s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ + sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do + # Make sure the directory exists. + test -f "$dirpart/$file" && continue + fdir=`$as_dirname -- "$file" || +$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$file" : 'X\(//\)[^/]' \| \ + X"$file" : 'X\(//\)$' \| \ + X"$file" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + { as_dir=$dirpart/$fdir + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || { { $as_echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 +$as_echo "$as_me: error: cannot create directory $as_dir" >&2;} + { (exit 1); exit 1; }; }; } + # echo "creating $dirpart/$file" + echo '# dummy' > "$dirpart/$file" + done +done + ;; + + esac +done # for ac_tag + + +{ (exit 0); exit 0; } +_ACEOF +chmod +x $CONFIG_STATUS +ac_clean_files=$ac_clean_files_save + +test $ac_write_fail = 0 || + { { $as_echo "$as_me:$LINENO: error: write failure creating $CONFIG_STATUS" >&5 +$as_echo "$as_me: error: write failure creating $CONFIG_STATUS" >&2;} + { (exit 1); exit 1; }; } + + +# configure is writing to config.log, and then calls config.status. +# config.status does its own redirection, appending to config.log. +# Unfortunately, on DOS this fails, as config.log is still kept open +# by configure, so config.status won't be able to write to it; its +# output is simply discarded. So we exec the FD to /dev/null, +# effectively closing config.log, so it can be properly (re)opened and +# appended to by config.status. When coming back to configure, we +# need to make the FD available again. +if test "$no_create" != yes; then + ac_cs_success=: + ac_config_status_args= + test "$silent" = yes && + ac_config_status_args="$ac_config_status_args --quiet" + exec 5>/dev/null + $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false + exec 5>>config.log + # Use ||, not &&, to avoid exiting from the if with $? = 1, which + # would make configure fail if this is the last instruction. + $ac_cs_success || { (exit 1); exit 1; } +fi +if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then + { $as_echo "$as_me:$LINENO: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 +$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} +fi + diff --git a/configure.ac b/configure.ac new file mode 100755 index 0000000..2daad20 --- /dev/null +++ b/configure.ac @@ -0,0 +1,418 @@ +############################################################################### +# prelude +############################################################################### + +m4_include([project/project.m4sugar]) + +m4_define([SVNINFO],m4_esyscmd([svn info 2>/dev/null])) + +m4_define([PRJ_repo_url],m4_bregexp(SVNINFO,[^URL: *\(.+\)],[\1])) +m4_define([PRJ_repo_root],m4_bregexp(SVNINFO,[^Repository Root: *\(.+\)],[\1])) +m4_define([PRJ_repo_uuid],m4_bregexp(SVNINFO,[^Repository UUID: *\(.+\)],[\1])) +m4_define([PRJ_repo_rev],m4_bregexp(SVNINFO,[^Last Changed Rev: *\(.+\)],[\1])) +m4_define([PRJ_repo_date],m4_bregexp(SVNINFO,[^Last Changed Date: *\(.+\)],[\1])) +m4_define([PRJ_repo_type],ifelse(m4_bregexp(PRJ_repo_url,[/releases/]),[-1],[developer],[stable])) + +m4_define([PRJ_version_hex],m4_format([0x%04x%02x%02x],PRJ_version_major,PRJ_version_minor,PRJ_version_point)) + +m4_define([PRJ_snapshot], + m4_bregexp(m4_esyscmd([(test "$SNAPSHOT" = "1" && date +%Y%m%d) 2>/dev/null]),[\([0-9]+\)],[\1])) +m4_define([PRJ_repo_type],ifelse(m4_len(PRJ_snapshot),8,[snapshot],PRJ_repo_type)) + +m4_define([PRJ_version],ifelse( + PRJ_repo_type,[stable],m4_format([%d.%d.%d],PRJ_version_major,PRJ_version_minor,PRJ_version_point), + PRJ_repo_type,[snapshot],m4_format([%d.%d-%s],PRJ_version_major,PRJ_version_minor,PRJ_snapshot), + PRJ_repo_type,[developer],m4_format([%d.%d-r%d],PRJ_version_major,PRJ_version_minor,PRJ_repo_rev), + m4_format([%d.%d-r%d],PRJ_version_major,PRJ_version_minor,PRJ_repo_rev))) + +############################################################################### +# initialization +############################################################################### + +AC_PREREQ([2.61]) +AC_INIT(PRJ_name,PRJ_version,PRJ_bugreport) + +AC_MSG_NOTICE([ + --> + --> Configuring ]AC_PACKAGE_STRING[ + -->]) + +AC_CONFIG_AUX_DIR([autoaux]) +AM_INIT_AUTOMAKE([1.9.6 foreign -Wall -Wno-portability -Werror subdir-objects nostdinc no-dist-gzip dist-bzip2 dist-zip dejagnu]) + +AC_CONFIG_SRCDIR([src/mp4.cpp]) + +# disable unused langs (improves config speed, reduces configure file size) +AC_DEFUN([_LT_AC_LANG_F77_CONFIG], [:]) +AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG], [:]) +AC_DEFUN([_LT_AC_LANG_RC_CONFIG], [:]) + +AC_CANONICAL_HOST + +############################################################################### +# add configure options +############################################################################### + +if test -z "$enable_dependency_tracking"; then + enable_dependency_tracking=no +fi + +AC_ARG_ENABLE([debug], + [AS_HELP_STRING([--disable-debug],[disable debugging compilation])]) +AC_ARG_ENABLE([optimize], + [AS_HELP_STRING([--disable-optimize],[disable optimizing compilation])]) +AC_ARG_ENABLE([fvisibility], + [AS_HELP_STRING([--disable-fvisibility],[disable use of -fvisibility])]) +AC_ARG_ENABLE([gch], + [AS_HELP_STRING([--disable-gch],[disable GCC precompiled-headers])]) +AC_ARG_ENABLE([largefile], + [AS_HELP_STRING([--disable-largefile],[disable LFS (large file support)])]) +AC_ARG_ENABLE([util], + [AS_HELP_STRING([--disable-util],[disable build of command-line utilities])]) +AC_ARG_ENABLE([bi], + [AS_HELP_STRING([--enable-bi=ARCH],[enable -mARCH for bi-arch compilation])]) +AC_ARG_ENABLE([ub], + [AS_HELP_STRING([--enable-ub@<:@=ARCHS@:>@],[enable -arch ARCH for universal-binaries (OSX only)])]) +AC_ARG_ENABLE([cygwin_win32], + [AS_HELP_STRING([--enable-cygwin-win32],[when building with Cygwin use -mwin32])]) +AC_ARG_ENABLE([mingw_mt], + [AS_HELP_STRING([--enable-mingw-threads],[when building with MinGW use -mthreads])]) + +############################################################################### +# checks for programs +############################################################################### + +AC_PROG_CXX +AC_PROG_LIBTOOL + +AC_CHECK_PROG([FOUND_HELP2MAN],[help2man],[yes],[no]) + +############################################################################### +# top-level platform check +############################################################################### + +AC_MSG_CHECKING([$PACKAGE_NAME platform portability]) +X_PLATFORM=posix +case ${host} in +*-*-cygwin) + # do not support shared + enable_shared=no + X_CXX_W="$X_CXX_W -Wno-format" + if test "$enable_cygwin_win32" = "yes"; then + X_PLATFORM=win32 + X_CXX_ARCH="$X_CXX_ARCH -mwin32" + fi + ;; +*-*-mingw*) + # do not support shared + enable_shared=no + X_PLATFORM=win32 + X_MINGW_LIBS="$X_MINGW_LIBS" + X_CXX_W="$X_CXX_W -Wno-format" + if test "$enable_mingw_threads" = "yes"; then + X_CXX_ARCH="$X_CXX_ARCH -mthreads" + fi + ;; +esac +AC_MSG_RESULT([$X_PLATFORM]) + +############################################################################### +# prepare project metadata +############################################################################### + +PROJECT_name="PRJ_name" +PROJECT_name_lower="PRJ_name_lower" +PROJECT_name_upper="PRJ_name_upper" +PROJECT_name_formal="PRJ_name PRJ_version" +PROJECT_url_website="PRJ_url_website" +PROJECT_url_downloads="PRJ_url_downloads" +PROJECT_url_discussion="PRJ_url_discussion" +PROJECT_irc="PRJ_irc" +PROJECT_bugreport="<PRJ_bugreport>" + +PROJECT_version="PRJ_version" +PROJECT_version_hex="PRJ_version_hex" +PROJECT_version_major="PRJ_version_major" +PROJECT_version_minor="PRJ_version_minor" +PROJECT_version_point="PRJ_version_point" +PROJECT_repo_url="PRJ_repo_url" +PROJECT_repo_root="PRJ_repo_root" +PROJECT_repo_uuid="PRJ_repo_uuid" +PROJECT_repo_rev="PRJ_repo_rev" +PROJECT_repo_date="PRJ_repo_date" +PROJECT_repo_type="PRJ_repo_type" +PROJECT_build="`date`" + +test -z "$PROJECT_version_hex" && PROJECT_version_hex="0x0000000000000000LL" +test -z "$PROJECT_version_major" && PROJECT_version_major="0" +test -z "$PROJECT_version_minor" && PROJECT_version_minor="0" +test -z "$PROJECT_version_point" && PROJECT_version_point="0" +test -z "$PROJECT_repo_url" && PROJECT_repo_url="svn://nowhere.com/project/unknown" +test -z "$PROJECT_repo_root" && PROJECT_repo_root="svn://nowhere.com/project" +test -z "$PROJECT_repo_uuid" && PROJECT_repo_uuid="00000000-0000-0000-0000-000000000000" +test -z "$PROJECT_repo_rev" && PROJECT_repo_rev="0" +test -z "$PROJECT_repo_date" && PROJECT_repo_date="unknown" +test -z "$PROJECT_repo_type" && PROJECT_repo_type="unknown" +test -z "$PROJECT_build" && PROJECT_build="unknown" + +AC_SUBST([PROJECT_name]) +AC_SUBST([PROJECT_name_lower]) +AC_SUBST([PROJECT_name_upper]) +AC_SUBST([PROJECT_name_formal]) +AC_SUBST([PROJECT_url_website]) +AC_SUBST([PROJECT_url_downloads]) +AC_SUBST([PROJECT_url_discussion]) +AC_SUBST([PROJECT_irc]) +AC_SUBST([PROJECT_bugreport]) +AC_SUBST([PROJECT_version]) +AC_SUBST([PROJECT_version_hex]) +AC_SUBST([PROJECT_version_major]) +AC_SUBST([PROJECT_version_minor]) +AC_SUBST([PROJECT_version_point]) +AC_SUBST([PROJECT_repo_url]) +AC_SUBST([PROJECT_repo_root]) +AC_SUBST([PROJECT_repo_uuid]) +AC_SUBST([PROJECT_repo_rev]) +AC_SUBST([PROJECT_repo_date]) +AC_SUBST([PROJECT_repo_type]) +AC_SUBST([PROJECT_build]) + +############################################################################### +# checks for libraries +############################################################################### + +############################################################################### +# checks for header files +############################################################################### + +############################################################################### +# checks for typedefs, structures, and compiler characteristics +############################################################################### + +############################################################################### +# replace -ggdb3 with -ggdb2 to avoid GNU 'as' from failing +# See http://code.google.com/p/mp4v2/issues/detail?id=27 +############################################################################### +if test "$GXX" = "yes"; then + CXXFLAGS_GGDB3=`echo "$CXXFLAGS" | sed -e 's/-ggdb3/-ggdb2/'` + CXXFLAGS="$CXXFLAGS_GGDB3" +fi + +############################################################################### +# additional ldflags +############################################################################### + +case ${host} in + *-*-darwin*) + X_libmp4v2_la_LDFLAGS='-Wl,-current_version,$(PROJECT_version_major).$(PROJECT_version_minor).$(PROJECT_version_point) -Wl,-compatibility_version,$(PROJECT_version_major).0.0' + ;; + *) + X_libmp4v2_la_LDFLAGS= + ;; +esac + +AC_SUBST([X_libmp4v2_la_LDFLAGS]) + +############################################################################### +# check for --disable-fvisibility +############################################################################### + +if test "$enable_fvisibility" != "no" -a "$GXX" = "yes"; then + case ${host} in + *-*-cygwin) + ;; + *-*-mingw*) + ;; + *) + AC_LANG(C++) + AC_CACHE_CHECK([if $CXX supports -fvisibility],[x_cv_fvisibility],[ + x_save="$CXXFLAGS" + CXXFLAGS="$CXXFLAGS -fvisibility=hidden" + AC_TRY_COMPILE([],[],[x_cv_fvisibility=yes],[x_cv_fvisibility=no]) + if test "$x_cv_fvisibility" != "yes"; then + CXXFLAGS="$x_save" + fi + x_save= + ]) + ;; + esac +fi + +############################################################################### +# check for --disable-gch +############################################################################### + +AC_MSG_CHECKING([if GCC precompiled-headers should be created]) + +X_GCH=0 +X_GCH_FLAGS= +X_GCH_STATIC=0 +X_GCH_STATIC_FLAGS="$lt_prog_compiler_static_CXX" +X_GCH_SHARED=0 +X_GCH_SHARED_FLAGS="$lt_prog_compiler_pic_CXX" + +if test "$enable_gch" = "yes"; then + X_GCH=1 +elif test "$enable_gch" != "no"; then + if test "$GXX" = "yes"; then + case ${host_os} in + cygwin*|darwin*|freebsd*|linux*|mingw*|solaris*) + X_GCH=1 + ;; + esac + fi +fi + +if test "$X_GCH" -eq 1; then + x_gch_result="yes" + if test "$enable_static" = "yes"; then + X_GCH_STATIC=1 + fi + if test "$enable_shared" = "yes"; then + X_GCH_SHARED=1 + fi +else + x_gch_result="no" +fi + +AC_MSG_RESULT([$x_gch_result]) + +AC_SUBST([X_GCH]) +AC_SUBST([X_GCH_FLAGS]) +AC_SUBST([X_GCH_STATIC]) +AC_SUBST([X_GCH_STATIC_FLAGS]) +AC_SUBST([X_GCH_SHARED]) +AC_SUBST([X_GCH_SHARED_FLAGS]) + +############################################################################### +# check for --disable-largefile +############################################################################### + +if test "$enable_largefile" != "no" -a "$ac_cv_header_unistd_h" = "yes"; then + case ${host_cpu} in + i?86|ppc) + AC_LANG(C++) + AC_CACHE_CHECK([if LFS (large file support) is required],[x_cv_largefile],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include <unistd.h> +#ifndef _LFS_LARGEFILE + error: not LFS conformant +#endif + ]])],[x_cv_largefile=yes],[x_cv_largefile=no]) + ]) + if test "$x_cv_largefile" = "yes"; then + AC_DEFINE([NEED_LFS_ACTIVATION],[1],[Define to 1 if LFS should be activated]) + fi + ;; + esac +fi + +############################################################################### +# set arch flags +############################################################################### + +if test "$GXX" = "yes"; then + AC_MSG_CHECKING([arch flags]) + x_flags= + x_save_IFS=$IFS; IFS=, + for arch in ${enable_ub}; do + case "$arch" in + ""|no) + ;; + yes) + case ${host} in + *-*-darwin*) + x_flags="$xflags -arch i386 -arch x86_64 -arch ppc -arch ppc64" + ;; + esac + ;; + *) + x_flags="$x_flags -arch $arch" + ;; + esac + done + IFS=$x_save_IFS + + case "$enable_bi" in + ""|no|yes) + ;; + *) + x_flags="$x_flags -m${enable_bi}" + ;; + esac + + if test -n "$x_flags"; then + AC_MSG_RESULT([$x_flags]) + X_CXX_ARCH="$X_CXX_ARCH $x_flags" + else + AC_MSG_RESULT([none]) + fi + + x_flags= +fi + +############################################################################### +# disable debugging +############################################################################### + +if test "$enable_debug" = "no"; then + changequote(<<,>>)dnl + if test "$GCC" = "yes"; then + CFLAGS=`echo "$CFLAGS" | sed -e 's/-g[^ ]*[ ]*//' -e 's/^ //' -e 's/ $//'` + fi + if test "$GXX" = "yes"; then + CXXFLAGS=`echo "$CXXFLAGS" | sed -e 's/-g[^ ]*[ ]*//' -e 's/^ //' -e 's/ $//'` + fi + changequote([,])dnl +fi + +############################################################################### +# disable optimizing +############################################################################### + +if test "$enable_optimize" = "no"; then + changequote(<<,>>)dnl + if test "$GCC" = "yes"; then + CFLAGS=`echo "$CFLAGS" | sed -e 's/-O[^ ]*[ ]*//' -e 's/^ //' -e 's/ $//'` + fi + if test "$GXX" = "yes"; then + CXXFLAGS=`echo "$CXXFLAGS" | sed -e 's/-O[^ ]*[ ]*//' -e 's/^ //' -e 's/ $//'` + fi + changequote([,])dnl +fi + +############################################################################### +# checks for library functions +############################################################################### + +############################################################################### +# conditional compilation +############################################################################### + +AM_CONDITIONAL([ADD_PLATFORM_POSIX],[test "$X_PLATFORM" = "posix"]) +AM_CONDITIONAL([ADD_PLATFORM_WIN32],[test "$X_PLATFORM" = "win32"]) + +AM_CONDITIONAL([ADD_UTIL],[test "$enable_util" != "no"]) +AM_CONDITIONAL([ADD_MANS],[test "$X_PLATFORM" != "win32"]) + +############################################################################### +# declare common substitutions +############################################################################### + +AC_SUBST([X_CXX_ARCH]) +AC_SUBST([X_CXX_W]) +AC_SUBST([X_CXX_D]) +AC_SUBST([X_CXX_I]) +AC_SUBST([X_MINGW_LIBS]) + +############################################################################### +# output files +############################################################################### + +AC_CONFIG_HEADERS([libplatform/config.h]) + +AC_CONFIG_FILES([GNUmakefile]) +AC_CONFIG_FILES([include/mp4v2/project.h]) +AC_CONFIG_FILES([project/project.m4]) + +AC_OUTPUT diff --git a/doc/Authors.txt b/doc/Authors.txt new file mode 100644 index 0000000..c0a29be --- /dev/null +++ b/doc/Authors.txt @@ -0,0 +1,22 @@ +MP4v2 1.9.1 Authors +******************* + +This document lists significant contributors to MP4v2. 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. + + Edward Groenendaal egroenen@cisco.com + Jonathon Rubin jb.rubin@gmail.com + Kona Blend kona8lend@gmail.com + Rouven Wessling mp4v2@rouvenwessling.de + +Authors from original MPEG4IP/libmp4v2 +====================================== + + Dave Mackie dmackie@cisco.com + Alix Marchandise-Franquet alix@cisco.com + Bill May wmay@cisco.com + Ximpo Group Ltd. mp4v2@ximpo.com + Danijel Kopcinovic danijel.kopcinovic@adnecto.net + diff --git a/doc/BuildRepository.txt b/doc/BuildRepository.txt new file mode 100644 index 0000000..8ba9a73 --- /dev/null +++ b/doc/BuildRepository.txt @@ -0,0 +1,720 @@ +MP4v2 1.9.1 Building the Repository +*********************************** + +Table of Contents +***************** + +1 Overview +2 Introduction +3 Quickstart +4 Build Process + 4.1 Checkout Sources + 4.2 Boostrap (Autotools) + 4.3 Configure + 4.4 Build + 4.5 Install + 4.6 Create Distribution + 4.7 Build Documentation + 4.8 Post Site and API Documentation to project website. +5 Platform Notes + 5.1 Mac OS X + 5.1.1 Default Binaries + 5.1.2 Release Binaries + 5.1.3 Developer Binaries + 5.1.4 Universal Binaries - all architectures + 5.1.5 Universal Binaries - selected architectures + 5.2 Linux + 5.2.1 Default Binaries + 5.2.2 Release Binaries + 5.2.3 Developer Binaries + 5.2.4 Bi-arch compilation + 5.3 FreeBSD + 5.3.1 Default Binaries + 5.3.2 Release Binaries + 5.3.3 Developer Binaries + 5.3.4 Bi-arch compilation + 5.4 Solaris + 5.4.1 Default Binaries + 5.4.2 Release Binaries + 5.4.3 Developer Binaries + 5.4.4 Bi-arch compilation + 5.5 Cygwin + 5.5.1 Default Binaries + 5.5.2 Release Binaries + 5.5.3 Developer Binaries + 5.6 Windows + + +1 Overview +********** + +The documented and supported method to build MP4v2 uses the GNU build +system (also known as the Autotools). You must first obtain the sources +by either downloading and extracting the source-distribution bundle or +working directly MP4v2's Subversion repository. We have build documents +for both methods, but unless you are a member of the MP4v2 project, you +are strongly encouraged to use the source-distribution method. + +On other supported platforms which lack Autotools we provide an +alternative method for building the software. Please see the +appropriate platform section. + +2 Introduction +************** + +This document describes the recommended process to build MP4v2 from the +repository. This process is a superset of the process to build from a +source-distribution bundle. If you are interested in building from a +source-distribution bundle then this document is not for you. + +3 Quickstart +************ + +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 *note Build Process::. + + svn checkout https://mp4v2.googlecode.com/svn/releases/1.9.1 mp4v2 + cd mp4v2 + autoreconf -fiv + rm -fr build/ + mkdir build/ + cd build/ + ../configure + make + make install + make install-man + make dist + +4 Build Process +*************** + +4.1 Checkout Sources +==================== + +Checkout sources from the project's Subversion repository. + +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. + +If you are a project member, then you may add the appropriate +login/password information as needed. + + svn checkout https://mp4v2.googlecode.com/svn/releases/1.9.1 mp4v2 + cd mp4v2 + +It is recommended to use Subversion 1.5.0 or higher. Lower versions +might work. + +4.2 Boostrap (Autotools) +======================== + +The following command causes forces Autotools to regenerate all files +and install helper scripts needed at configure-time and to regenerate +all files. + + autoreconf -fiv + +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: + + * GNU autoconf 2.61 or higher (lower versions might work) + + * GNU automake 1.10 or higher (lower versions might work) + + * GNU libtool 1.5.26 or higher (lower versions might work) + +4.3 Configure +============= + +The following command configures the project for a build. It is highly +recommended that you invoke configure from an empty directory. + + rm -fr build/ + mkdir build/ + cd build/ + ../configure + +Please see `INSTALL' for details on configure usage, and standard +options. Additionally, the following custom options have been added to +`configure': + +`--disable-debug' + 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. + +`--disable-optimize' + Do not optimize. Do not direct compiler to optimize code. By + default compiler optimization is enabled if the platform supports + it. + +`--disable-fvisibility' + 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. + +`--disable-gch' + 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 `make + clean' may be required when headers are changed. Use this option + to disable GCC precompiled headers. + +`--disable-largefile' + 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. + +`--disable-util' + 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. + +`--enable-bi=ARCH' + On bi-arch capable platforms it is possible to generate 32 or 64 + bit code. This is supported by adding arguments `-m32' or `-m64', + respectively, when compiling or linking. Use this option to + override the platform-specific default. + +`--enable-ub[=ARCHS]' + On OSX systems it is possible to generate universal binaries. This + is supported by adding one or more argument patterns `-arch ARCH' + when compiling or linking. Use this option to either target an + architecture different from the platform default, or to produce + universal binaries. + +`--enable-dependency-tracking' + Enable automatic dependency tracking for include-files. By default + this feature is disabled. + + +4.4 Build +========= + +The following command will build MP4v2. + + make + +On some platforms `make' refers to a BSD-flavor of make which is not +compatible with this project. Check if `gmake' is installed, and if it +is, substitute `gmake' wherever you may see `make' in this document. +Otherwise you will need to install GNU make package version 3.81 or +higher. Lower versions might work. + +4.5 Install +=========== + +The following command will install MP4v2. + + make install + make install-man + +4.6 Create Distribution +======================= + +The following command will create a MP4v2 source distribution. It is +during this step that shipped documentation is generated. + + make dist + +This step in the build process introduces additional requirements to +the host system. While most of the following utilities are generally +available, `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. + + * GNU help2man 1.36 or higher (lower versions should work) + + * GNU tar 1.15.1 or higher (lower versions should work) + + * GNU gzip 1.3.10 or higher (lower versions should work) + + * bzip2 1.0.4 or higher (lower versions should work) + + * Info-ZIP zip 2.32 or higher (lower versions should work) + +4.7 Build Documentation +======================= + +This step in the build process introduces some significant requirements +to the host system: + + * GNU texinfo 4.8 or higher (lower versions should work) + + * Doxygen 1.5.7 or higher (lower versions should work) + +Documentation that is shipped with source-distribution is generated as +part of the *note Build Process:: step. This section documents builds +all of the supported methods to build documentation. There are three +kinds of documentation in this project; man-pages, articles and API. +Documentation must be build from the repository. + +Man-pages are automatically generated for command-line utilities by +using `html2man' which invokes standard options `--help' and +`--version' and gleans the information, generating a man-page in nroff +script. Note that the utilities will first be built as they are +depdendencies of man-page generation. + +Artcles are usually hand-written and authored in Texinfo format which +permits macro-expansions, simple formatting and conversion to several +popular formats using the GNU `makeinfo'. A Texinfo manual +(http://www.gnu.org/software/texinfo) is available. + +API is documented inline to C and C++ source files, usually headers +using Doxygen comment-formatting. Doxygen is then used to post-process +these files and generate documentation in various formats. A Doxygen +manual is available at it's main site (http://www.doxygen.org) . + +The project's goal is to document as thoroughly as possible the public +API in MP4v2. Since we never have enough time to document everything, +we try to set some priorities in this regard. Generally the public API +is the highest priority to document. Next most important is probably +underlying utility code which is shared by many developers; for example +libplatform. + +If you need examples of how to document C-compatible source see +`include/mp4v2/mp4v2.h' and for C++-only source see +`libplatform/io/File.h' . + +The following table describes the various make targets available for +building docs. Note you must first have completed the *note Configure:: +step. + +`make man' + Generate man-pages for command-line utilities. + +`make html' + Generate articles in HTML format from `texi' files. + +`make txt' + Generate articles in plaintext format from `texi' files. + +`make wiki' + Generate articles in Google Code Wiki format from `texi' files. + +`make xml' + Generate articles in (Texinfo) XML format from `texi' files. + +`make api' + Generate API in HTML format from header files. + +`make articles' + Convenience; the equivalent of `make html txt wiki xml' . + +`make doc' + Convenience; the equivalent of `make man articles api' . + + +And finally all of the document targets have a corresponding clean +target which cleans up generated files. Simply prefix as follows: + + make manclean + make htmlclean + make txtclean + make wikiclean + make xmlclean + make apiclean + make articlesclean + make docclean + +4.8 Post Site and API Documentation to project website. +======================================================= + +This step is for project maintainers and can be used to update Site and +API documentation. The following components are updated: + + * Featured Wiki article: BuildRepository + + * Featured Wiki article: BuildSource + + * MP4v2 (trunk) docs (includes Release Notes and other articles, and + API docs). + +This procedure may only be run from a *nix platform and has only been +tested on Mac OS X. + +`make google.clean' + Clean any local working copy of google changeset. + +`make google.post' + Generate required docs, sparse-checkout google tree, remove files + which are no longer generated, add new files which are generated, + and update existing files. + +`svn ci -m "-refreshed GoogleCode site+api docs." google/.' + Check-in changes. This might take several minutes, especially if + your upstream bandwidth is limited. + + +5 Platform Notes +**************** + +MP4v2 builds on many unix-style platforms, also commonly referred to as +posix-style systems. Building on Mac OS X, Linux, FreeBSD, Solaris, +Cygwin, Windows are known to work. + +Similar platforms should also work. Please see the following platform +specific notes for instructions on commonly used options for various +platforms. + +5.1 Mac OS X +============ + +Building on Mac OS X 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: + + * Mac Intel hardware + + * Mac OS X 10.5.7 + + * Xcode-3.1.2 + + * gcc 4.0.1 (Apple Inc. build 5493) + + * gcc 4.2.1 (Apple Inc. build 5570) + + Note: 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. + +5.1.1 Default Binaries +---------------------- + +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. + + ../configure + +5.1.2 Release Binaries +---------------------- + +The preferred method to produce binaries suitable for releases, (ie. +which does not contain debug information) is to pass the following to +configure: + + ../configure --disable-debug + +5.1.3 Developer Binaries +------------------------ + +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. + + ../configure --disable-optimize --disable-static + +5.1.4 Universal Binaries - all architectures +-------------------------------------------- + +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. + + ../configure --enable-ub + +5.1.5 Universal Binaries - selected architectures +------------------------------------------------- + +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 }. + + ../configure --enable-ub=i386,x86_64 + +5.2 Linux +========= + +Building on 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: + + * Intel 32-bit or 64-bit hardware + + * Fedora 10, gcc 4.3.2 + + * gcc 3.4.0 or higher is reported to work + + Note: 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. + +5.2.1 Default Binaries +---------------------- + +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. + + ../configure + +5.2.2 Release Binaries +---------------------- + +The preferred method to produce binaries suitable for releases, (ie. +which does not contain debug information) is to pass the following to +configure: + + ../configure --disable-debug + +5.2.3 Developer Binaries +------------------------ + +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. + + ../configure --disable-optimize --disable-static + +5.2.4 Bi-arch compilation +------------------------- + +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. + + ../configure --enable-bi=32 + + Warning: Currently bi-arch cross-compilation is not supported due + to a bug with libtool which fails miserably during linking. + +5.3 FreeBSD +=========== + +Building on FreeBSD is supported. The following are the recommended +specifications for this platform; but is not necessarily the only +configuration that is possible: + + * Intel 32-bit or 64-bit hardware + + * FreeBSD 7.0 Release, gcc 4.2.1 + + * gcc 3.4.0 or higher is reported to work + + Note: 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. + +5.3.1 Default Binaries +---------------------- + +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. + + ../configure + +5.3.2 Release Binaries +---------------------- + +The preferred method to produce binaries suitable for releases, (ie. +which does not contain debug information) is to pass the following to +configure: + + ../configure --disable-debug + +5.3.3 Developer Binaries +------------------------ + +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. + + ../configure --disable-optimize --disable-static + +5.3.4 Bi-arch compilation +------------------------- + +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. + + ../configure --enable-bi=32 + + Warning: Currently bi-arch cross-compilation is not supported due + to a bug with libtool which fails miserably during linking. + +5.4 Solaris +=========== + +Building on Solaris is supported. The following are the recommended +specifications for this platform; but is not necessarily the only +configuration that is possible: + + * Intel 32-bit or 64-bit hardware + + * Solaris 10u6, gcc 3.4.3 + + * gcc 3.4.0 or higher is reported to work + + Note: 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. + + Note: 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 `/usr/sfw/bin'. + +5.4.1 Default Binaries +---------------------- + +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. + + ../configure + +5.4.2 Release Binaries +---------------------- + +The preferred method to produce binaries suitable for releases, (ie. +which does not contain debug information) is to pass the following to +configure: + + ../configure --disable-debug + +5.4.3 Developer Binaries +------------------------ + +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. + + ../configure --disable-optimize --disable-static + +5.4.4 Bi-arch compilation +------------------------- + +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. + + ../configure --enable-bi=32 + + Warning: Currently bi-arch cross-compilation is not supported due + to a bug with libtool which fails miserably during linking. + +5.5 Cygwin +========== + +Building on Cygwin is supported. The following are the recommended +specifications for this platform; but is not necessarily the only +configuration that is possible: + + * Intel 32-bit or 64-bit hardware + + * Cygwin, gcc 4.3.2 + + * gcc 3.4.0 or higher is reported to work + + Note: As of this writing, Cygwin has available to it several + versions of gcc; only one of which may be found and used in the + path as `gcc' and `g++'. Configure will thus find what is probably + the older more stable version of gcc in a typical Cygwin + environment. If you desire to build with the newer gcc, it is + found in the path as `gcc-4' and `g++-4' respectively and you must + indicate to configure the desired versions. Defining the following + variables beforing running configure should do the trick: + + setenv CC gcc-4 + setenv CXX gcc-4 + ../configure + +5.5.1 Default Binaries +---------------------- + +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. + + ../configure + +5.5.2 Release Binaries +---------------------- + +The preferred method to produce binaries suitable for releases, (ie. +which does not contain debug information) is to pass the following to +configure: + + ../configure --disable-debug + +5.5.3 Developer Binaries +------------------------ + +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. + + ../configure --disable-optimize --disable-static + +5.6 Windows +=========== + +Native builds on 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: + + * Intel 32-bit or 64-bit hardware + + * Windows 2000 or higher, Visual Studio 9.0 (aka. Visual Studio 2008) + + * Visual Studio 9.0 Express is reported to work + +Only 32-bit binaries are targeted, and win32-API is set to Windows 2000 +or higher. Older versions of Windows, or win32-API are not supported. + +MP4v2 has directory `vstudio9.0/' 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. + + Warning: Project meta-data is stored in header `project.h'. A + proper source distribution is built using autotools and generates + `TOP/include/mp4v2/project.h' correctly, which is then bundled + with our source distribution. This is adequate for building on the + Windows platform. + + However, if you are building from the repository, be warned that + there is no method to automatically generate `project.h' on + Windows. Instead, we periodically checkin a copy of this file + (generated using autotools) as + `vstudio9.0/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 `project.h' from + there. + diff --git a/doc/BuildSource.txt b/doc/BuildSource.txt new file mode 100644 index 0000000..3b510ff --- /dev/null +++ b/doc/BuildSource.txt @@ -0,0 +1,561 @@ +MP4v2 1.9.1 Building the Source +******************************* + +Table of Contents +***************** + +1 Overview +2 Introduction +3 Quickstart +4 Build Process + 4.1 Extract + 4.2 Configure + 4.3 Build + 4.4 Install +5 Platform Notes + 5.1 Mac OS X + 5.1.1 Default Binaries + 5.1.2 Release Binaries + 5.1.3 Developer Binaries + 5.1.4 Universal Binaries - all architectures + 5.1.5 Universal Binaries - selected architectures + 5.2 Linux + 5.2.1 Default Binaries + 5.2.2 Release Binaries + 5.2.3 Developer Binaries + 5.2.4 Bi-arch compilation + 5.3 FreeBSD + 5.3.1 Default Binaries + 5.3.2 Release Binaries + 5.3.3 Developer Binaries + 5.3.4 Bi-arch compilation + 5.4 Solaris + 5.4.1 Default Binaries + 5.4.2 Release Binaries + 5.4.3 Developer Binaries + 5.4.4 Bi-arch compilation + 5.5 Cygwin + 5.5.1 Default Binaries + 5.5.2 Release Binaries + 5.5.3 Developer Binaries + 5.6 Windows + + +1 Overview +********** + +The documented and supported method to build MP4v2 uses the GNU build +system (also known as the Autotools). You must first obtain the sources +by either downloading and extracting the source-distribution bundle or +working directly MP4v2's Subversion repository. We have build documents +for both methods, but unless you are a member of the MP4v2 project, you +are strongly encouraged to use the source-distribution method. + +On other supported platforms which lack Autotools we provide an +alternative method for building the software. Please see the +appropriate platform section. + +2 Introduction +************** + +This document describes the recommended process to build MP4v2 from a +source-distribution bundle. This process is a 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. + +3 Quickstart +************ + +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 *note Build Process::. + + tar xf mp4v2-1.9.1.tar.bz2 + cd mp4v2-1.9.1/ + rm -fr build/ + mkdir build/ + cd build/ + ../configure + make + make install + make install-man + +4 Build Process +*************** + +4.1 Extract +=========== + +Extract sources from a source-distribution bundle. Releases are +available from `http://code.google.com/p/mp4v2' in the downloads +(http://code.google.com/p/mp4v2/downloads/list) section. + + tar xf mp4v2-1.9.1.tar.bz2 + cd mp4v2-1.9.1/ + +Older versions of `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 `bz2' file: + + tar xjf mp4v2-1.9.1.tar.bz2 + bunzip2 -c mp4v2-1.9.1.tar.bz2 | tar xf - + bzcat mp4v2-1.9.1.tar.bz2 | tar xf - + +And for a `gz' file: + + tar xzf mp4v2-1.9.1.tar.gz + gunzip -c mp4v2-1.9.1.tar.gz | tar xf - + gzcat mp4v2-1.9.1.tar.gz | tar xf - + +4.2 Configure +============= + +The following command configures the project for a build. It is highly +recommended that you invoke configure from an empty directory. + + rm -fr build/ + mkdir build/ + cd build/ + ../configure + +Please see `INSTALL' for details on configure usage, and standard +options. Additionally, the following custom options have been added to +`configure': + +`--disable-debug' + 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. + +`--disable-optimize' + Do not optimize. Do not direct compiler to optimize code. By + default compiler optimization is enabled if the platform supports + it. + +`--disable-fvisibility' + 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. + +`--disable-gch' + 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 `make + clean' may be required when headers are changed. Use this option + to disable GCC precompiled headers. + +`--disable-largefile' + 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. + +`--disable-util' + 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. + +`--enable-bi=ARCH' + On bi-arch capable platforms it is possible to generate 32 or 64 + bit code. This is supported by adding arguments `-m32' or `-m64', + respectively, when compiling or linking. Use this option to + override the platform-specific default. + +`--enable-ub[=ARCHS]' + On OSX systems it is possible to generate universal binaries. This + is supported by adding one or more argument patterns `-arch ARCH' + when compiling or linking. Use this option to either target an + architecture different from the platform default, or to produce + universal binaries. + +`--enable-dependency-tracking' + Enable automatic dependency tracking for include-files. By default + this feature is disabled. + + +4.3 Build +========= + +The following command will build MP4v2. + + make + +On some platforms `make' refers to a BSD-flavor of make which is not +compatible with this project. Check if `gmake' is installed, and if it +is, substitute `gmake' wherever you may see `make' in this document. +Otherwise you will need to install GNU make package version 3.81 or +higher. Lower versions might work. + +4.4 Install +=========== + +The following command will install MP4v2. + + make install + make install-man + +5 Platform Notes +**************** + +MP4v2 builds on many unix-style platforms, also commonly referred to as +posix-style systems. Building on Mac OS X, Linux, FreeBSD, Solaris, +Cygwin, Windows are known to work. + +Similar platforms should also work. Please see the following platform +specific notes for instructions on commonly used options for various +platforms. + +5.1 Mac OS X +============ + +Building on Mac OS X 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: + + * Mac Intel hardware + + * Mac OS X 10.5.7 + + * Xcode-3.1.2 + + * gcc 4.0.1 (Apple Inc. build 5493) + + * gcc 4.2.1 (Apple Inc. build 5570) + + Note: 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. + +5.1.1 Default Binaries +---------------------- + +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. + + ../configure + +5.1.2 Release Binaries +---------------------- + +The preferred method to produce binaries suitable for releases, (ie. +which does not contain debug information) is to pass the following to +configure: + + ../configure --disable-debug + +5.1.3 Developer Binaries +------------------------ + +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. + + ../configure --disable-optimize --disable-static + +5.1.4 Universal Binaries - all architectures +-------------------------------------------- + +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. + + ../configure --enable-ub + +5.1.5 Universal Binaries - selected architectures +------------------------------------------------- + +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 }. + + ../configure --enable-ub=i386,x86_64 + +5.2 Linux +========= + +Building on 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: + + * Intel 32-bit or 64-bit hardware + + * Fedora 10, gcc 4.3.2 + + * gcc 3.4.0 or higher is reported to work + + Note: 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. + +5.2.1 Default Binaries +---------------------- + +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. + + ../configure + +5.2.2 Release Binaries +---------------------- + +The preferred method to produce binaries suitable for releases, (ie. +which does not contain debug information) is to pass the following to +configure: + + ../configure --disable-debug + +5.2.3 Developer Binaries +------------------------ + +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. + + ../configure --disable-optimize --disable-static + +5.2.4 Bi-arch compilation +------------------------- + +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. + + ../configure --enable-bi=32 + + Warning: Currently bi-arch cross-compilation is not supported due + to a bug with libtool which fails miserably during linking. + +5.3 FreeBSD +=========== + +Building on FreeBSD is supported. The following are the recommended +specifications for this platform; but is not necessarily the only +configuration that is possible: + + * Intel 32-bit or 64-bit hardware + + * FreeBSD 7.0 Release, gcc 4.2.1 + + * gcc 3.4.0 or higher is reported to work + + Note: 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. + +5.3.1 Default Binaries +---------------------- + +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. + + ../configure + +5.3.2 Release Binaries +---------------------- + +The preferred method to produce binaries suitable for releases, (ie. +which does not contain debug information) is to pass the following to +configure: + + ../configure --disable-debug + +5.3.3 Developer Binaries +------------------------ + +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. + + ../configure --disable-optimize --disable-static + +5.3.4 Bi-arch compilation +------------------------- + +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. + + ../configure --enable-bi=32 + + Warning: Currently bi-arch cross-compilation is not supported due + to a bug with libtool which fails miserably during linking. + +5.4 Solaris +=========== + +Building on Solaris is supported. The following are the recommended +specifications for this platform; but is not necessarily the only +configuration that is possible: + + * Intel 32-bit or 64-bit hardware + + * Solaris 10u6, gcc 3.4.3 + + * gcc 3.4.0 or higher is reported to work + + Note: 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. + + Note: 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 `/usr/sfw/bin'. + +5.4.1 Default Binaries +---------------------- + +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. + + ../configure + +5.4.2 Release Binaries +---------------------- + +The preferred method to produce binaries suitable for releases, (ie. +which does not contain debug information) is to pass the following to +configure: + + ../configure --disable-debug + +5.4.3 Developer Binaries +------------------------ + +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. + + ../configure --disable-optimize --disable-static + +5.4.4 Bi-arch compilation +------------------------- + +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. + + ../configure --enable-bi=32 + + Warning: Currently bi-arch cross-compilation is not supported due + to a bug with libtool which fails miserably during linking. + +5.5 Cygwin +========== + +Building on Cygwin is supported. The following are the recommended +specifications for this platform; but is not necessarily the only +configuration that is possible: + + * Intel 32-bit or 64-bit hardware + + * Cygwin, gcc 4.3.2 + + * gcc 3.4.0 or higher is reported to work + + Note: As of this writing, Cygwin has available to it several + versions of gcc; only one of which may be found and used in the + path as `gcc' and `g++'. Configure will thus find what is probably + the older more stable version of gcc in a typical Cygwin + environment. If you desire to build with the newer gcc, it is + found in the path as `gcc-4' and `g++-4' respectively and you must + indicate to configure the desired versions. Defining the following + variables beforing running configure should do the trick: + + setenv CC gcc-4 + setenv CXX gcc-4 + ../configure + +5.5.1 Default Binaries +---------------------- + +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. + + ../configure + +5.5.2 Release Binaries +---------------------- + +The preferred method to produce binaries suitable for releases, (ie. +which does not contain debug information) is to pass the following to +configure: + + ../configure --disable-debug + +5.5.3 Developer Binaries +------------------------ + +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. + + ../configure --disable-optimize --disable-static + +5.6 Windows +=========== + +Native builds on 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: + + * Intel 32-bit or 64-bit hardware + + * Windows 2000 or higher, Visual Studio 9.0 (aka. Visual Studio 2008) + + * Visual Studio 9.0 Express is reported to work + +Only 32-bit binaries are targeted, and win32-API is set to Windows 2000 +or higher. Older versions of Windows, or win32-API are not supported. + +MP4v2 has directory `vstudio9.0/' 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. + + Warning: Project meta-data is stored in header `project.h'. A + proper source distribution is built using autotools and generates + `TOP/include/mp4v2/project.h' correctly, which is then bundled + with our source distribution. This is adequate for building on the + Windows platform. + + However, if you are building from the repository, be warned that + there is no method to automatically generate `project.h' on + Windows. Instead, we periodically checkin a copy of this file + (generated using autotools) as + `vstudio9.0/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 `project.h' from + there. + diff --git a/doc/Documentation.txt b/doc/Documentation.txt new file mode 100644 index 0000000..658c92a --- /dev/null +++ b/doc/Documentation.txt @@ -0,0 +1,33 @@ +MP4v2 1.9.1 Documentation +************************* + +Introduction +============ + +Project MP4v2 consists of a C-library and various command-line +utilities which permit creation and modification of MP4 files as +defined by as defined by `ISO base media file format', document number +`ISO/IEC 14496-12:2005(E)'. + +Official website +================ + +The official website (http://code.google.com/p/mp4v2) makes various +downloads (http://code.google.com/p/mp4v2/downloads/list) available and +archives online browesable documentation for releases, including API +Reference. Questions, bug-reports and general feedback may be submitted +to the discussion (http://groups.google.com/group/mp4v2) group. + +Articles +******** + +See Release Notes (`doc/ReleaseNotes.txt') +See Building the Source (`doc/BuildSource.txt') +See Building the Repository (`doc/BuildRepository.txt') +See Authors (`doc/Authors.txt') + +Guides +****** + +See Command-line Tools Guide (`doc/ToolGuide.txt') + diff --git a/doc/GNUmakefile.mk b/doc/GNUmakefile.mk new file mode 100644 index 0000000..e3af64a --- /dev/null +++ b/doc/GNUmakefile.mk @@ -0,0 +1,387 @@ +############################################################################### +## +## makefile for documentation creation +## +## INTPUT FILES (SOURCE/doc) +## doc/ +## dox/ <-- generated API docs support files +## doxygen/ <-- generated API docs support files +## texi/ <-- hand-written project articles +## +## OUTPUT FILES (BUILD/doc) +## doc/ +## doc/ +## api/ +## html/ <-- API in html format +## xml/ <-- API in xml format +## articles/ +## html/ <-- articles in html format +## txt/ <-- articles in txt format +## wiki/ <-- articles in Google Code Wiki format +## xml/ <-- articles in xml-texinfo format +## man/ +## man1/ <-- man-pages for utilities +## +############################################################################### + +# Conventional VPATH directive breaks too many things so we use vpath and its +# pattern-spec feature. If new files or extensions are introduced they may need +# to be added here. + +VPATH = + +vpath COPYING $(top_srcdir) +vpath INSTALL $(top_srcdir) +vpath README $(top_srcdir) +vpath autoaux/% $(top_srcdir) +vpath %.1 $(top_srcdir) +vpath %.cpp $(top_srcdir) +vpath %.h $(top_srcdir) +vpath %.m4 $(top_srcdir) +vpath %.tcc $(top_srcdir) + +############################################################################### + +SOURCE/ = $(top_srcdir)/ +BUILD/ = $(top_builddir)/ + +DOC.in/ = $(SOURCE/)doc/ +DOC.out/ = $(BUILD/)doc/ + +DOC.out.api/ = $(DOC.out/)api/ +DOC.out.articles/ = $(DOC.out/)articles/ +DOC.out.site/ = $(DOC.out/)site/ + +############################################################################### + +M4 = m4 +M4.flags = -I$(BUILD/)project +M4.cmd = $(M4) $(M4.flags) $(1) > $(2) +M4.deps = $(BUILD/)project/project.m4 + +ifeq ($(FOUND_HELP2MAN),yes) +HELP2MAN = help2man +HELP2MAN.flags = -m "$(PROJECT_name) Utilities" -N +HELP2MAN.cmd = $(HELP2MAN) $(HELP2MAN.flags) ./$(1) -o $(2) +else +HELP2MAN.cmd = touch $(2) +endif + +MAKEINFO.flags = -I$(DOC.in/)texi -I$(DOC.out/)texi +MAKEINFO.flags.html = --html --no-headers --no-split +MAKEINFO.flags.txt = --plaintext --no-headers +MAKEINFO.flags.xml = --xml --output-indent=4 +MAKEINFO.cmd = makeinfo $(MAKEINFO.flags) $(MAKEINFO.flags.$(1)) $(2) -o $(3) + +HTMLCOMBINE = $(SOURCE/)project/htmlcombine.py +HTMLCOMBINE.cmd = $(HTMLCOMBINE) --header $(1) --footer $(2) --body $(3) > $(4) +HTMLCOMBINE.deps = $(HTMLCOMBINE) + +XML2WIKI = $(SOURCE/)project/xml2wiki.py +XML2WIKI.flags = --date --toc +XML2WIKI.cmd = $(XML2WIKI) $(XML2WIKI.flags) $(1) > $(2) +XML2WIKI.deps = $(XML2WIKI) + +DOXYGEN = doxygen +DOXYGEN.cmd = $(DOXYGEN) $(1) + +############################################################################### + +DOC.m4.out = \ + doc/texi/base/project.texi \ + doc/doxygen/Doxyfile \ + doc/doxygen/header.html \ + doc/doxygen/footer.html \ + doc/html/header.html \ + doc/html/footer.html + +DOC.man.utils = mp4art mp4file mp4subtitle mp4track +DOC.man.out = $(DOC.man.utils:%=$(DOC.out/)man/man1/%.1) + +DOC.texi.articles = $(wildcard $(DOC.in/)texi/*.texi $(DOC.out/)texi/*.texi) + +DOC.texi.includes = \ + doc/texi/base/project.texi \ + $(wildcard $(DOC.in/)texi/*/*.texi $(DOC.out/)texi/*/*.texi) + +DOC.texi2html.out = $(DOC.texi.articles:$(DOC.in/)texi/%.texi=$(DOC.out.articles/)html/%.html) +DOC.texi2txt.out = $(DOC.texi.articles:$(DOC.in/)texi/%.texi=$(DOC.out.articles/)txt/%.txt) +DOC.texi2xml.out = $(DOC.texi.articles:$(DOC.in/)texi/%.texi=$(DOC.out.articles/)xml/%.xml) + +DOC.xml2wiki.out = $(DOC.texi2xml.out:$(DOC.out.articles/)xml/%.xml=$(DOC.out.articles/)wiki/%.wiki) + +DOC.api.out = $(DOC.out.api/).stamp + +DOC.site.out = $(DOC.out.site/).stamp +DOC.site.out.copy = $(patsubst $(DOC.in/)html/%,$(DOC.out.site/)%, \ + $(filter-out %.in,$(wildcard $(DOC.in/)html/*))) +DOC.site.out.index = $(DOC.out.site/)index.html +DOC.site.out.html = $(patsubst $(DOC.out.articles/)html/%,$(DOC.out.site/)%, \ + $(filter-out %/Documentation.html,$(DOC.texi2html.out))) + +############################################################################### + +MKDIRS += $(dir $(DOC.m4.out)) +MKDIRS += $(DOC.out/)man/man1/ +MKDIRS += $(foreach n,html man texi txt wiki xml,$(DOC.out.articles/)$n) +MKDIRS += $(DOC.out.api/) +MKDIRS += $(DOC.out.site/) + +############################################################################### + +EXTRA_DIST += \ + $(SOURCE/)vstudio9.0/include/mp4v2/project.h \ + $(SOURCE/)vstudio9.0/mp4v2.sln \ + $(wildcard $(SOURCE/)vstudio9.0/*/*.vcproj) + +############################################################################### + +dist-hook: $(DOC.texi2txt.out) $(DOC.man.out) + rm -fr $(distdir)/doc + $(mkdir_p) $(distdir)/doc + $(INSTALL_DATA) $(DOC.in/)GNUmakefile.mk $(distdir)/doc/. +ifneq (,$(DOC.texi2txt.out)) + $(INSTALL_DATA) $(DOC.texi2txt.out) $(distdir)/doc/. +endif +ifneq (,$(DOC.man.out)) + $(mkdir_p) $(distdir)/doc/man/man1 + $(INSTALL_DATA) $(DOC.man.out) $(distdir)/doc/man/man1 +endif + +distclean-local: docclean + +############################################################################### + +$(DOC.m4.out): %: %.m4 $(M4.deps) | $(dir $(DOC.m4.out)) + $(call M4.cmd,$<,$@) + +############################################################################### + +.PHONY: articles doc +articles: html txt xml wiki +doc: man articles api site + +.PHONY: articlesclean apiclean docclean +articlesclean: htmlclean txtclean xmlclean wikiclean +docclean: manclean articlesclean apiclean siteclean + +.PHONY: man html txt xml wiki api +man: $(DOC.man.out) +html: $(DOC.texi2html.out) +txt: $(DOC.texi2txt.out) +xml: $(DOC.texi2xml.out) +wiki: $(DOC.xml2wiki.out) +api: $(DOC.api.out) +site: $(DOC.site.out) + +.PHONY: manclean htmlclean txtclean xmlclean wikiclean apiclean +manclean: + rm -f $(DOC.man.out) + +htmlclean: + rm -f $(DOC.texi2html.out) + +txtclean: + rm -f $(DOC.texi2txt.out) + +xmlclean: + rm -f $(DOC.texi2xml.out) + +wikiclean: + rm -f $(DOC.xml2wiki.out) + +apiclean: + rm -f $(DOC.api.out) + rm -fr $(DOC.out.api/)html/ $(DOC.out.api/)xml/ + +siteclean: + rm -fr $(DOC.out.site/) + +############################################################################### + +$(DOC.man.out): | $(dir $(DOC.man.out)) +$(DOC.man.out): $(DOC.out/)man/man1/%.1: $(BUILD/)% + $(call HELP2MAN.cmd,$<,$@) + +$(DOC.texi2html.out): $(DOC.texi.includes) | $(dir $(DOC.texi2html.out)) +$(DOC.texi2html.out): $(DOC.out.articles/)html/%.html: $(DOC.in/)texi/%.texi + $(call MAKEINFO.cmd,html,$<,$@) + +$(DOC.texi2txt.out): $(DOC.texi.includes) | $(dir $(DOC.texi2txt.out)) +$(DOC.texi2txt.out): $(DOC.out.articles/)txt/%.txt: $(DOC.in/)texi/%.texi + $(call MAKEINFO.cmd,txt,$<,$@) + +$(DOC.texi2xml.out): $(DOC.texi.includes) | $(dir $(DOC.texi2xml.out)) +$(DOC.texi2xml.out): $(DOC.out.articles/)xml/%.xml: $(DOC.in/)texi/%.texi + $(call MAKEINFO.cmd,xml,$<,$@) + +$(DOC.xml2wiki.out): $(XML2WIKI.deps) | $(dir $(DOC.xml2wiki.out)) +$(DOC.xml2wiki.out): $(DOC.out.articles/)wiki/%.wiki: $(DOC.out.articles/)xml/%.xml + $(call XML2WIKI.cmd,$<,$@) + +$(DOC.api.out): | $(dir $(DOC.api.out)) +$(DOC.api.out): $(DOC.in/)doxygen/banner.png +$(DOC.api.out): $(DOC.in/)doxygen/project.css +$(DOC.api.out): $(DOC.out/)doxygen/header.html +$(DOC.api.out): $(DOC.out/)doxygen/footer.html +$(DOC.api.out): $(DOC.out/)doxygen/Doxyfile + $(call DOXYGEN.cmd,$<) + $(INSTALL_DATA) $(DOC.in/)doxygen/banner.png $(DOC.out.api/)html/ + touch $@ + +############################################################################### + +$(DOC.site.out): | $(DOC.out.site/)articles +$(DOC.site.out): | $(DOC.out.site/)api +$(DOC.site.out): $(DOC.site.out.copy) +$(DOC.site.out): $(DOC.site.out.index) +$(DOC.site.out): $(DOC.site.out.html) + +$(DOC.out.site/)articles: | html $(DOC.out.site/) + rm -f $@ + ln -s ../articles/html $@ + +$(DOC.out.site/)api: | api $(DOC.out.site/) + rm -f $@ + ln -s ../api/html $@ + +$(DOC.site.out.copy): $(DOC.out.site/)%: $(DOC.in/)html/% + $(INSTALL_DATA) $^ $(@D)/. + +$(DOC.site.out.index): $(DOC.out/)html/header.html $(DOC.out/)html/footer.html +$(DOC.site.out.index): $(HTMLCOMBINE.deps) +$(DOC.site.out.index): $(DOC.out.articles/)html/Documentation.html + $(call HTMLCOMBINE.cmd,$(word 2,$^),$(word 3,$^),$<,$@) + +$(DOC.site.out.html): $(DOC.out/)html/header.html $(DOC.out/)html/footer.html +$(DOC.site.out.html): $(HTMLCOMBINE.deps) +$(DOC.site.out.html): $(DOC.out.site/)%: $(DOC.out.articles/)html/% + $(call HTMLCOMBINE.cmd,$(word 2,$^),$(word 3,$^),$<,$@) + +############################################################################### + +GOOGLE.out/ = $(top_builddir)/google/ +GOOGLE.repo.doc = $(if $(filter stable,$(PROJECT_repo_type)),$(PROJECT_version),trunk) + +google.clean: + rm -fr $(GOOGLE.out/) + +google.post: site wiki +google.post: | $(GOOGLE.out/) +google.post: google.rsync google.rm google.add google.propset + +$(GOOGLE.out/): + svn co --depth immediates $(PROJECT_repo_root) $(GOOGLE.out/) + svn update --set-depth immediates google/wiki + svn update --set-depth infinity google/doc/$(GOOGLE.repo.doc) + +google.rsync: + rsync -vrptPL --delete \ + --exclude=".svn/*" --exclude=".svn" \ + --exclude="*/.svn/*" --exclude="*/.svn" \ + --exclude=".stamp" --exclude="*/.stamp" \ + --exclude="*.m4" --exclude="*/*.m4" \ + $(DOC.out.site/). $(GOOGLE.out/)doc/$(GOOGLE.repo.doc)/. + $(INSTALL_DATA) $(DOC.out.articles/)wiki/BuildRepository.wiki $(GOOGLE.out/)wiki/. + $(INSTALL_DATA) $(DOC.out.articles/)wiki/BuildSource.wiki $(GOOGLE.out/)wiki/. + +google.rm: + @files=`svn status $(GOOGLE.out/) | grep '^!' | awk '{ print $$2 }'`; \ + if [ -n "$$files" ]; then \ + svn rm $$files; \ + fi + +google.add: + @files=`svn status $(GOOGLE.out/) | grep '^?' | awk '{ print $$2 }'`; \ + if [ -n "$$files" ]; then \ + svn add $$files; \ + fi + +google.propset: + find $(GOOGLE.out/)doc/$(GOOGLE.repo.doc) -type f -a \( -name "*.html" -o -name "*.css" \) -print0 \ + | xargs -0 svn propset svn:eol-style native + find $(GOOGLE.out/)doc/$(GOOGLE.repo.doc) -type f -a -name "*.html" -print0 \ + | xargs -0 svn propset svn:mime-type "text/html" + +############################################################################### + +dist-hb: distdir=lib$(PACKAGE) +dist-hb: distdir + tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >lib$(PACKAGE)-$(VERSION).tar.gz + $(am__remove_distdir) + +############################################################################### + +## Precompiled header support is tricky given libtool's complexity and its +## historical aversion to supporting it. +## +## What we do is add rules to precompile. Unfortunately, we cannot +## automatically determine what flags libtool adds for compilation variants; +## ie: PIC or non-PIC compilation. So instead we will hardcode the flags +## to match. The reason for this is the precompiled-header will not be used if +## (relevent) compilation flags differ. + +CXX.gch.static.flags = $(X_GCH_STATIC_FLAGS) +CXX.gch.static.in = libplatform/impl.h src/impl.h libutil/impl.h +CXX.gch.static.out = $(CXX.gch.static.in:%=$(BUILD/)%.gch/static) + +CXX.gch.shared.flags = $(X_GCH_SHARED_FLAGS) +CXX.gch.shared.in = libplatform/impl.h src/impl.h libutil/impl.h +CXX.gch.shared.out = $(CXX.gch.shared.in:%=$(BUILD/)%.gch/shared) + +CXX.gch.exe.flags = $(X_GCH_FLAGS) +CXX.gch.exe.in = util/impl.h +CXX.gch.exe.out = $(CXX.gch.exe.in:%=$(BUILD/)%.gch/exe) + +CXX.gch.static.dependents = $(libmp4v2_la_OBJECTS) +CXX.gch.shared.dependents = $(libmp4v2_la_OBJECTS) + +CXX.gch.exe.dependents = \ + $(mp4art_OBJECTS) \ + $(mp4chaps_OBJECTS) \ + $(mp4extract_OBJECTS) \ + $(mp4file_OBJECTS) \ + $(mp4info_OBJECTS) \ + $(mp4subtitle_OBJECTS) \ + $(mp4syncfiles_OBJECTS) \ + $(mp4tags_OBJECTS) \ + $(mp4track_OBJECTS) \ + $(mp4trackdump_OBJECTS) + +ifeq ($(X_GCH_STATIC),1) +$(CXX.gch.static.dependents): $(CXX.gch.static.out) +endif + +ifeq ($(X_GCH_SHARED),1) +$(CXX.gch.shared.dependents): $(CXX.gch.shared.out) +endif + +ifeq ($(X_GCH),1) +$(CXX.gch.exe.dependents): $(CXX.gch.exe.out) +endif + +$(CXX.gch.static.out): | $(sort $(dir $(CXX.gch.static.out))) +$(CXX.gch.static.out): $(BUILD/)%.gch/static: % + $(CXXCOMPILE) $(CXX.gch.static.flags) -c $< -o $@ + +$(CXX.gch.shared.out): | $(sort $(dir $(CXX.gch.shared.out))) +$(CXX.gch.shared.out): $(BUILD/)%.gch/shared: % + $(CXXCOMPILE) $(CXX.gch.shared.flags) -c $< -o $@ + +$(CXX.gch.exe.out): | $(sort $(dir $(CXX.gch.exe.out))) +$(CXX.gch.exe.out): $(BUILD/)%.gch/exe: % + $(CXXCOMPILE) $(CXX.gch.exe.flags) -c $< -o $@ + +MKDIRS += $(dir $(CXX.gch.static.out)) +MKDIRS += $(dir $(CXX.gch.shared.out)) +MKDIRS += $(dir $(CXX.gch.exe.out)) + +clean-local: + rm -f $(CXX.gch.static.out) + rm -f $(CXX.gch.shared.out) + rm -f $(CXX.gch.exe.out) + +############################################################################### + +$(sort $(MKDIRS)): + $(mkdir_p) $@ diff --git a/doc/ReleaseNotes.txt b/doc/ReleaseNotes.txt new file mode 100644 index 0000000..9c5f73a --- /dev/null +++ b/doc/ReleaseNotes.txt @@ -0,0 +1,128 @@ +MP4v2 1.9.1 Release Notes +************************* + +Table of Contents +***************** + +1 What's New? +2 Breaking Changes + 2.1 Top-level header file + 2.2 Command-line utilities +Appendix A Changelog + A.1 Version 1.9 + A.2 Version 1.6 +Appendix B SCM repository details + + +1 What's New? +************* + +Welcome! This is the inaugural release of MP4v2. + +This project's goal is to continue development of a C-library named +`libmp4v2' which was once a part of the (now defunct) MPEG4IP project. +That library, and some related command-line utilities were branched +from MPEG4IP version 1.6.1 to seed this project, MP4v2. + +2 Breaking Changes +****************** + +2.1 Top-level header file +========================= + +This release is nearly 100% API compatible with MPEG4IP, however there +are some differences. Dependents of this library must now include the +top-level public header file as follows. This is the only supported +mechanism to include the library. We do not support attempts to include +any sub-level header files; such files are private implementation +details and their naming must not be relied upon. + + #include <mp4v2/mp4v2.h> + +2.2 Command-line utilities +========================== + +The command-line utilities have been totally rewritten and enhanced. +Help usage has been made more consistent and enhanced, please invoke +the appropriate utility in this fashion for more details: + + command --help + +Appendix A Changelog +******************** + +A.1 Version 1.9 +=============== + + 1. Renamed public API top-level header to `<mp4v2/mp4v2.h>' 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. + + 2. Added initial AC3 support. + + 3. Added native Windows port. The port targets `WINVER 0x0500' which + is Windows 2000 or higher. + + 4. Added QuickTime and Nero chapter support. See `mp4chaps' + command-line utility. + Contributed by Ullrich Pollähne <u.pollaehne@gmail.com>. + + 5. Enhanced `mp4art' to support multiple cover-art atoms. + + 6. Dropped `mp4dump' and replaced with `mp4file' which supports + general file operations. + + 7. Added `mp4track' with colr-box and pasp-box support. + + 8. Fixed corruption of udta.name atom during read-in. + + 9. Enhanced `mp4file --dump' to show hexdump-style canonical + hex+ASCII data. + + 10. Enhanced `mp4file --dump' to show human-readble value for tag + typeCode values. + + 11. Enhanced `mp4file --dump' to show human-readble value for + ISO-639-2/T language codes. + + 12. Added new public-API: MP4GetTrackLanguage(). + + 13. Added new public-API: MP4SetTrackLanguage(). + + 14. Added support for GCC precompiled-headers on various *nix + platforms to speed up builds as we are using quite a few C++ + headers. + + 15. Enhanced `mp4track' to facilitate modification of { enabled, + inmovie, inpreview, altgroup, volume, width, height, language, + hdlrname, udtaname } properties. + + 16. Added new public-API: MP4GetTrackDurationPerChunk(). + + 17. Added new public-API: MP4SetTrackDurationPerChunk() to override + default per-track chunk duration. + + 18. Added new public-API: MP4WriteSampleDependency(). + + 19. Replaced (undocumented) public-API: MP4CreateEx() with + MP4CreateProvider(). + + 20. Added new public-API for iTMF Generic functionality. + +A.2 Version 1.6 +=============== + + 1. Branched libmp4v2 module from mpeg4ip project version 1.6.1. + +Appendix B SCM repository details +********************************* + + url: https://mp4v2.googlecode.com/svn/releases/1.9.1 + root: https://mp4v2.googlecode.com/svn + uuid: 6e6572fa-98a6-11dd-ad9f-f77439c74b79 + rev: 368 + date: 2009-07-14 11:25:03 +1200 (Tue, 14 Jul 2009) + type: stable + diff --git a/doc/ToolGuide.txt b/doc/ToolGuide.txt new file mode 100644 index 0000000..d73cd6a --- /dev/null +++ b/doc/ToolGuide.txt @@ -0,0 +1,415 @@ +MP4v2 1.9.1 Command-line Tools Guide +************************************ + +Table of Contents +***************** + +1 Overview +2 Introduction +3 Common Options +4 mp4file +5 mp4track +6 mp4art + + +1 Overview +********** + +MP4v2 bundles several command-line tools which, in general, allow some +basic manipulation of mp4 files which have been created by other means. +They are not meant to be a complete solution to management of mp4 file +structure. + +The following is a brief summary of the tools available and the +functionality offered. Other tools may be packaged with the +distribution but are not yet stable enough to even document. User +beware. + +`mp4file' + Operates on the entire file with actions such as list (summary + information), optimization and ASCII dumps. + +`mp4track' + Operates on individual tracks with actions such as colr-box and + pasp-box manipulation. + +`mp4art' + Operates on iTunes Metadata Cover-art Boxes with actions such as + list, add, replace, remove and extraction of Cover-art images. + +2 Introduction +************** + +The tools are invoked by their command-name, followed by one or more +options, actions, parameters for actions, and finally one or more files +on which the tool will operate. Options are specified in one of two +ways; in short or long syntax. A short-syntax option is prefixed with +exactly one dash while a long-syntax option is prefixed with exactly +two dashes. Depending on the option, it may or may not expect an +argument. Specifying an option which expects an argument usually +follows either of the following patterns: + + toolname --something value ... + toolname --something=value ... + +The rest of this guide will use the equals sign method. + +3 Common Options +**************** + +Many of the tools share a common set of options which. These common +options usually have identically behaving short or long syntax. In some +cases short-syntax differs from long-syntax in that it may not require +an argument. This style is used sparingly and only when truly +convenient. Even though it is common practice in many unix-style tools +to permit optional arguments, the tools used in this project will tend +to avoid that because it can create a great deal of confusion. + +The following is a list of common options available: + +`-y, --dryrun' + do not actually create or modify any files. In situations where + the command will create new or modify existing files, specifying + this option will cause the tool to do as much as possible stopping + short of performing any actual writes. This is useful to guard + against user mistakes or unexpected behavior. + +`-k, --keepgoing' + continue batch processing even after errors. When actions involve + multiple files or operations, the default behavior is to stop and + exit on the first error encountered. Specify this option if it is + desirable to record the error but continue processing. + +`-o, --overwrite' + overwrite existing files when creating. In situations where a new + file will be created, the default behavior is to not overwrite a + file if it already exists. Use this option to allow overwriting. + +`-f, --force' + force overwrite even if file is read-only. If overwriting is + enabled, file permissions may prevent writes. Specify this option + to try and overwrite the file anyways. This usually involves + deleting the file, then creating a new one. + +`-q, --quiet' + equivalent to -verbose 0. Default behavior is to print a low + amount of informative information, usually one line of text per + action/file. Specify this option to omit normal messages. Errors + will still be reported. + +`-d, --debug NUM' + increase debug or long-option to set NUM. File I/O with mp4 file + structures have special debug options available to users + interested in all the fine details. Default is level 1 . The + short-syntax is accumulative and takes no argument, while + long-syntax takes an argument. For exmaple, the following are + equivalent and would set level 3: `-dd' or `-d -d' or `--debug=3'. + The following levels are available: + 0. supressed + + 1. add warnings and errors (default) + + 2. add table details + + 3. add implicits + + 4. everything + +`-v, --verbose NUM' + increase verbosity or long-option to set NUM. Tool activity by + default will generally print one informative message per + action/file. Specify this option to change the default behavior. + The short-syntax is accumulative and takes no argument, while + long-syntax takes an argument. + 0. warnings and errors + + 1. normal informative messages (default) + + 2. more informative messages + + 3. everything + +`-h, --help' + print brief help or long-option for extended help. The + short-syntax will produce brief help. Specify the long-option for + more extensive help. + +`--version' + print version information and exit. Extended version information + used for SCM purposes is not listed in help, but is available by + specifying `--verionx'. + +4 mp4file +********* + +`--list' + list (summary information). This will produce brief report when + summarizing each mp4 file. BRAND shows the file's main brand + identifier. COMPAT shows additional brands for which the file + purports to be comaptible with. SIZING displays if the file has + 64-bit extensions of any kind, otherwise 32-bit. Example output: + BRAND COMPAT SIZING FILE + ---------------------------------------------------------------------- + M4A M4A,isom,mp42 32-bit Song.m4a + mp42 isom,mp42 32-bit Movie1.m4v + mp42 isom,mp42 32-bit Movie2.m4v + +`--optimize' + optimize mp4 structure. This will rewrite the entire mp4 file + which, if needed, will clean up any unused (free) sections, and + re-order the atoms in a manner somewhat consistent with the + best-practices described in the ISO base media file specification. + +`--dump' + dump mp4 structure in human-readable format. An ASCII dump of mp4 + atoms is printed to stdout. This action is heavily influenced by + `--debug' option. + + Example, list some files: + mp4file --list *.mp4 *.m4a *.m4v + + Example, dump a file with more than usual debugging information: + mp4file -dd --dump movie.m4v + +5 mp4track +********** + +This tool is used to manage various aspects of individual tracks in an +mp4 file. Some of the actions are mp4 (generic) while others may +support standards based on mp4 files such as `.m4a' or `.m4v' files. +Each action has an appropriate scope upon which it acts. See individual +actions for details. The following parameters are used to set scopes +for actions: + +`--track-any' + act on any/all tracks. + +`--track-index IDX' + act on a single track specified by index value. A track index is + 0-based and counts upwards for each track available. + +`--track-id ID' + act on a single track specified by id value. A track id is a + unique value assigned to each track and never changes. + +The list action will produce a brief report of each track for each mp4 +file. Many (but not all) of the values shown may be modified by +actions documented later in this article. This will produce a brief +report of each track for each mp4 file. + +`--list' + list all tracks in mp4. Example output: + track[0] id=1 + type = video + enabled = true + inMovie = false + inPreview = false + layer = 0 + alternateGroup = 0 + volume = 0.0000 + width = 850.96295166 + height = 360.00000000 + language = UNDEFINED(0) + handlerName = + userDataName = <absent> + +The following group of actions are used to modify the values shown by +-list action. The modification of these values should be done with +great care on any files, and as always you are cautioned to backup your +media files before modification. + +`--enabled BOOL' + set trak.tkhd.flags (enabled bit). When true indicates the track + is enabled. + +`--inmovie BOOL' + set trak.tkhd.flags (inMovie bit). When true indicates the track + is used in the movie. + +`--inpreview BOOL' + set trak.tkhd.flags (inPreview bit). When true indicates the + track is used in the movie's preview. + +`--layer NUM' + set trak.tkhd.layer. Specifies the front-to-back ordering of + video tracks; tracks with lower numbers are closer to the viewer. + 0 is the normal value, and -1 would be in front of track 0, and so + on. + +`--altgroup NUM' + set trak.tkhd.alternate_group. An integer that specifies a group + or collection of tracks. If this field is 0 there is no + information on possible relations to other tracks. If this field + is not 0, it should be the same for tracks that contain alternate + data for one another and different for tracks belonging to + different such groups. Only one track within an alternate group + should be played or streamed at any one time, and must be + distinguishable from other tracks in the group via attributes such + as bitrate, codec, language, packet size etc. A group may have + only one member. + +`--volume FLOAT' + set trak.tkhd.volume. Specifies the track's relative audio + volume. Full volume is 1.0 and is the normal value. + +`--width FLOAT' + set trak.tkhd.width. Specifies the track's visual presentation + width. By default this is the same as the pixel width of the + images. All images in the sequence are scaled to this size before + any overall transformation by the matrix. + +`--height FLOAT' + set trak.tkhd.height. Specifies the track's visual presentation + height. By default this is the same as the pixel width of the + images. All images in the sequence are scaled to this size before + any overall transformation by the matrix. + +`--language CODE' + set trak.mdia.mdhd.language. Specifies the ISO-639-2/T langauge + code of the track. For example, `eng' for English, `fra' for + French. + +`--hdlrname STR' + set trak.mdia.hdlr.name. Specifies a human-readable track type + (for debugging and inspection purposes). + +`--udtaname STR' + set trak.udta.name.value. Specifies an arbitrary track-name. This + value is optional (may be absent). + +`--udtaname-remove' + remove trak.udta.name atom. This action will remove the optional + atom. + + +The colr related actions manage Color Parameter boxes which are used by +QuickTime to map numerical values of pixels in a file to a common +representation of color for video tracks. They may or may not be +suitable for other Apple media players. Community feedback on +compatibility is welcome. + +`--colr-list' + list all colr-boxes in mp4. + +`--colr-add' + add colr-box to a video track. An individual track must be + specified. + +`--colr-set' + set colr-box parms. An individual track must be specified. + +`--colr-remove' + remove colr-box from track. By default all colr-boxes will be + removed unless an individual track is specified. + +`--colr-parms CSV' + where CSV is IDX1,IDX2,IDX3 . Specify the exact parameters of an + NCLC Color Parameter box as specified in the QuickTime + specification. IDX1 correlates to the 16-bit primaries index. + IDX2 correlates to the 16-bit transferFunction index. IDX3 + correlates to the 16-bit matrixIndex index. Effects actions + -colr-add, -colr-set. + +`--colr-parm-hd' + equivalent to -colr-parms=1,1,1 . This is a convenience setting + generally suitable for HD content. Effects actions -colr-add, + -colr-set. + +`--colr-parm-sd' + equivalent to -colr-parms=6,1,6 . This is a convenience setting + generally suitable for SD content. Effects actions -colr-add, + -colr-set. + + Example, add a colr-box tuned for HD content: + mp4track --track-id=1 --colr-add --colr-parm-hd mymovie.m4v + + Example, add a colr-box with arbitrary index parameters: + mp4track --track-id=1 --colr-add --colr-parms=2,3,4 mymovie.m4v + + +The pasp related actions manage Picture Aspect Ratio boxes which are +used by QuickTime to specify height-to-width ratio of pixels for video +tracks. They may or may not be suitable for other Apple media players. +Community feedback on compatibility is welcome. + +`--pasp-list' + list all pasp-boxes in mp4. + +`--pasp-add' + add pasp-box to a video track. An individual track must be + specified. + +`--pasp-set' + set pasp-box parms. An individual track must be specified. + +`--pasp-remove' + remove pasp-box from track By default all pasp-boxes will be + removed unless an individual track is specified. + +`--pasp-parms CSV' + where CSV is hSPACING,vSPACING. Specify the exact parameters of + Picture Aspect Ratio box as specified in the QuickTime + specification. Effects actions -pasp-add, -pasp-set. + + Example, add a pasp-box with default (1,1) parameters for square + pixels: + mp4track --track-id=1 --pasp-add --pasp-parms=1,1 mymovie.m4v + + Example, add a pasp-box for 16:9 digital 525 (NTSC): + mp4track --track-id=1 --pasp-add --pasp-parms=40,33 mymovie.m4v + + Example, add a pasp-box for 16:9 digital 625 (PAL): + mp4track --track-id=1 --pasp-add --pasp-parms=118,81 mymovie.m4v + + +6 mp4art +******** + +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 `.m4a', `.m4v' and `.mov' files. + +`--art-any' + act on all covr-boxes (default). Specifies the scope of the + action to operate on all, if applicable, covr-boxes. + +`--art-index IDX' + act on covr-box index IDX. Specifies the scope of the action to + operate on single covr-box INDEX. + +`--list' + list all covr-boxes. + IDX BYTES CRC32 TYPE FILE + ---------------------------------------------------------------------- + 0 173613 710a3ec9 JPEG 01 Life In Technicolor.m4a + 0 173613 710a3ec9 JPEG 02 Cemeteries Of London.m4a + 0 173613 710a3ec9 JPEG 03 Lost!.m4a + 0 173613 710a3ec9 JPEG 04 42.m4a + 0 173613 710a3ec9 JPEG 05 Lovers In Japan _ Reign Of Love.m4a + 0 173613 710a3ec9 JPEG 06 Yes.m4a + 0 173613 710a3ec9 JPEG 07 Viva La Vida.m4a + 0 173613 710a3ec9 JPEG 08 Violet Hill.m4a + 0 173613 710a3ec9 JPEG 09 Strawberry Swing.m4a + 0 173613 710a3ec9 JPEG 10 Death And All His Friends.m4a + +`--add IMG' + add covr-box from IMG file. + +`--replace IMG' + replace covr-box with IMG file. + +`--remove' + remove covr-box. + +`--extract' + extract covr-box. This will extract all covr-box data to image + files in the format of `BASENAME.art[INDEX].TYPE' . + + Example, add PNG image file: + mp4art --add ACDC.png mysong.m4a + + Example, extract image files from file: + mp4art --extract mysong.m4a + + diff --git a/doc/man/man1/mp4art.1 b/doc/man/man1/mp4art.1 new file mode 100644 index 0000000..292bad8 --- /dev/null +++ b/doc/man/man1/mp4art.1 @@ -0,0 +1,98 @@ +.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.29. +.TH MP4ART "1" "July 2009" "mp4art - MP4v2 1.9.1" "MP4v2 Utilities" +.SH NAME +mp4art \- manual page for mp4art - MP4v2 1.9.1 +.SH SYNOPSIS +.B mp4art +[\fIOPTION\fR]... \fIACTION file\fR... +.SH DESCRIPTION +For each mp4 (m4a) file specified, perform the specified ACTION. An action +must be specified. Some options are not applicable for some actions. +.PP +ACTIONS +.TP +\fB\-\-list\fR +list all covr-boxes +.TP +\fB\-\-add\fR IMG +add covr-box from IMG file +.TP +\fB\-\-replace\fR IMG +replace covr-box with IMG file +.TP +\fB\-\-remove\fR +remove covr-box +.TP +\fB\-\-extract\fR +extract covr-box +.PP +ACTION PARAMETERS +.TP +\fB\-\-art\-any\fR +act on all covr-boxes (default) +.TP +\fB\-\-art\-index\fR IDX +act on covr-box index IDX +.PP +OPTIONS +.TP +\fB\-z\fR, \fB\-\-optimize\fR +optimize mp4 file after modification +.TP +\fB\-y\fR, \fB\-\-dryrun\fR +do not actually create or modify any files +.TP +\fB\-k\fR, \fB\-\-keepgoing\fR +continue batch processing even after errors +.TP +\fB\-o\fR, \fB\-\-overwrite\fR +overwrite existing files when creating +.TP +\fB\-f\fR, \fB\-\-force\fR +force overwrite even if file is read-only +.TP +\fB\-q\fR, \fB\-\-quiet\fR +equivalent to \fB\-\-verbose\fR 0 +.TP +\fB\-d\fR, \fB\-\-debug\fR NUM +increase debug or long-option to set NUM +.TP +\fB\-v\fR, \fB\-\-verbose\fR NUM +increase verbosity or long-option to set NUM +.TP +\fB\-h\fR, \fB\-\-help\fR +print brief help or long-option for extended help +.TP +\fB\-\-version\fR +print version information and exit +.PP +DEBUG LEVELS (for raw mp4 file I/O) +.TP +0 +supressed +.TP +1 +add warnings and errors (default) +.TP +2 +add table details +.TP +3 +add implicits +.TP +4 +everything +.PP +VERBOSE LEVELS +.TP +0 +warnings and errors +.TP +1 +normal informative messages (default) +.TP +2 +more informative messages +.TP +3 +everything diff --git a/doc/man/man1/mp4file.1 b/doc/man/man1/mp4file.1 new file mode 100644 index 0000000..9cb99a6 --- /dev/null +++ b/doc/man/man1/mp4file.1 @@ -0,0 +1,75 @@ +.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.29. +.TH MP4FILE "1" "July 2009" "mp4file - MP4v2 1.9.1" "MP4v2 Utilities" +.SH NAME +mp4file \- manual page for mp4file - MP4v2 1.9.1 +.SH SYNOPSIS +.B mp4file +[\fIOPTION\fR]... \fIACTION file\fR... +.SH DESCRIPTION +For each mp4 file specified, perform the specified ACTION. An action must be +specified. Some options are not applicable to some actions. +.PP +ACTIONS +.TP +\fB\-\-list\fR +list (summary information) +.TP +\fB\-\-optimize\fR +optimize mp4 structure +.TP +\fB\-\-dump\fR +dump mp4 structure in human-readable format +.PP +OPTIONS +.TP +\fB\-y\fR, \fB\-\-dryrun\fR +do not actually create or modify any files +.TP +\fB\-k\fR, \fB\-\-keepgoing\fR +continue batch processing even after errors +.TP +\fB\-q\fR, \fB\-\-quiet\fR +equivalent to \fB\-\-verbose\fR 0 +.TP +\fB\-d\fR, \fB\-\-debug\fR NUM +increase debug or long-option to set NUM +.TP +\fB\-v\fR, \fB\-\-verbose\fR NUM +increase verbosity or long-option to set NUM +.TP +\fB\-h\fR, \fB\-\-help\fR +print brief help or long-option for extended help +.TP +\fB\-\-version\fR +print version information and exit +.PP +DEBUG LEVELS (for raw mp4 file I/O) +.TP +0 +supressed +.TP +1 +add warnings and errors (default) +.TP +2 +add table details +.TP +3 +add implicits +.TP +4 +everything +.PP +VERBOSE LEVELS +.TP +0 +warnings and errors +.TP +1 +normal informative messages (default) +.TP +2 +more informative messages +.TP +3 +everything diff --git a/doc/man/man1/mp4subtitle.1 b/doc/man/man1/mp4subtitle.1 new file mode 100644 index 0000000..ae7272e --- /dev/null +++ b/doc/man/man1/mp4subtitle.1 @@ -0,0 +1,87 @@ +.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.29. +.TH MP4SUBTITLE "1" "July 2009" "mp4subtitle - MP4v2 1.9.1" "MP4v2 Utilities" +.SH NAME +mp4subtitle \- manual page for mp4subtitle - MP4v2 1.9.1 +.SH SYNOPSIS +.B mp4subtitle +[\fIOPTION\fR]... \fIACTION file\fR... +.SH DESCRIPTION +For each mp4 file specified, perform the specified ACTION. An action must be +specified. Some options are not applicable to some actions. +.PP +ACTIONS +.TP +\fB\-\-list\fR +list available subtitles +.TP +\fB\-\-export\fR TXT +export subtitles to TXT +.TP +\fB\-\-import\fR TXT +import subtitles from TXT +.TP +\fB\-\-remove\fR +remove all subtitles +.PP +OPTIONS +.TP +\fB\-z\fR, \fB\-\-optimize\fR +optimize mp4 file after modification +.TP +\fB\-y\fR, \fB\-\-dryrun\fR +do not actually create or modify any files +.TP +\fB\-k\fR, \fB\-\-keepgoing\fR +continue batch processing even after errors +.TP +\fB\-o\fR, \fB\-\-overwrite\fR +overwrite existing files when creating +.TP +\fB\-f\fR, \fB\-\-force\fR +force overwrite even if file is read-only +.TP +\fB\-q\fR, \fB\-\-quiet\fR +equivalent to \fB\-\-verbose\fR 0 +.TP +\fB\-d\fR, \fB\-\-debug\fR NUM +increase debug or long-option to set NUM +.TP +\fB\-v\fR, \fB\-\-verbose\fR NUM +increase verbosity or long-option to set NUM +.TP +\fB\-h\fR, \fB\-\-help\fR +print brief help or long-option for extended help +.TP +\fB\-\-version\fR +print version information and exit +.PP +DEBUG LEVELS (for raw mp4 file I/O) +.TP +0 +supressed +.TP +1 +add warnings and errors (default) +.TP +2 +add table details +.TP +3 +add implicits +.TP +4 +everything +.PP +VERBOSE LEVELS +.TP +0 +warnings and errors +.TP +1 +normal informative messages (default) +.TP +2 +more informative messages +.TP +3 +everything diff --git a/doc/man/man1/mp4track.1 b/doc/man/man1/mp4track.1 new file mode 100644 index 0000000..c182ce8 --- /dev/null +++ b/doc/man/man1/mp4track.1 @@ -0,0 +1,161 @@ +.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.29. +.TH MP4TRACK "1" "July 2009" "mp4track - MP4v2 1.9.1" "MP4v2 Utilities" +.SH NAME +mp4track \- manual page for mp4track - MP4v2 1.9.1 +.SH SYNOPSIS +.B mp4track +[\fIOPTION\fR]... [\fIPARAMETERS\fR]... \fIACTION file\fR... +.SH DESCRIPTION +For each mp4 file specified, perform the specified ACTION. An action must be +specified. Some options are not applicable to some actions. +.PP +ACTIONS +.TP +\fB\-\-list\fR +list all tracks in mp4 +.TP +\fB\-\-enabled\fR BOOL +set trak.tkhd.flags (enabled bit) +.TP +\fB\-\-inmovie\fR BOOL +set trak.tkhd.flags (inMovie bit) +.TP +\fB\-\-inpreview\fR BOOL +set trak.tkhd.flags (inPreview bit) +.TP +\fB\-\-layer\fR NUM +set trak.tkhd.layer +.TP +\fB\-\-altgroup\fR NUM +set trak.tkhd.alternate_group +.TP +\fB\-\-volume\fR FLOAT +set trak.tkhd.volume +.TP +\fB\-\-width\fR FLOAT +set trak.tkhd.width +.TP +\fB\-\-height\fR FLOAT +set trak.tkhd.height +.TP +\fB\-\-language\fR CODE +set trak.mdia.mdhd.language +.TP +\fB\-\-hdlrname\fR STR +set trak.mdia.hdlr.name +.TP +\fB\-\-udtaname\fR STR +set trak.udta.name.value +.TP +\fB\-\-udtaname\-remove\fR +remove trak.udta.name atom +.TP +\fB\-\-colr\-list\fR +list all colr-boxes in mp4 +.TP +\fB\-\-colr\-add\fR +add colr-box to a video track +.TP +\fB\-\-colr\-set\fR +set colr-box parms +.TP +\fB\-\-colr\-remove\fR +remove colr-box from track +.TP +\fB\-\-pasp\-list\fR +list all pasp-boxes in mp4 +.TP +\fB\-\-pasp\-add\fR +add pasp-box to a video track +.TP +\fB\-\-pasp\-set\fR +set pasp-box parms +.TP +\fB\-\-pasp\-remove\fR +remove pasp-box from track +.PP +PARAMETERS +.TP +\fB\-\-track\-any\fR +act on any/all tracks +.TP +\fB\-\-track\-index\fR IDX +act on track index IDX +.TP +\fB\-\-track\-id\fR ID +act on track id ID +.TP +\fB\-\-colr\-parms\fR CSV +where CSV is IDX1,IDX2,IDX3 +.TP +\fB\-\-colr\-parm\-hd\fR +equivalent to \fB\-\-colr\-parms\fR=\fI1\fR,1,1 +.TP +\fB\-\-colr\-parm\-sd\fR +equivalent to \fB\-\-colr\-parms\fR=\fI6\fR,1,6 +.TP +\fB\-\-pasp\-parms\fR CSV +where CSV is hSPACING,vSPACING +.PP +OPTIONS +.TP +\fB\-z\fR, \fB\-\-optimize\fR +optimize mp4 file after modification +.TP +\fB\-y\fR, \fB\-\-dryrun\fR +do not actually create or modify any files +.TP +\fB\-k\fR, \fB\-\-keepgoing\fR +continue batch processing even after errors +.TP +\fB\-o\fR, \fB\-\-overwrite\fR +overwrite existing files when creating +.TP +\fB\-f\fR, \fB\-\-force\fR +force overwrite even if file is read-only +.TP +\fB\-q\fR, \fB\-\-quiet\fR +equivalent to \fB\-\-verbose\fR 0 +.TP +\fB\-d\fR, \fB\-\-debug\fR NUM +increase debug or long-option to set NUM +.TP +\fB\-v\fR, \fB\-\-verbose\fR NUM +increase verbosity or long-option to set NUM +.TP +\fB\-h\fR, \fB\-\-help\fR +print brief help or long-option for extended help +.TP +\fB\-\-version\fR +print version information and exit +.PP +DEBUG LEVELS (for raw mp4 file I/O) +.TP +0 +supressed +.TP +1 +add warnings and errors (default) +.TP +2 +add table details +.TP +3 +add implicits +.TP +4 +everything +.PP +VERBOSE LEVELS +.TP +0 +warnings and errors +.TP +1 +normal informative messages (default) +.TP +2 +more informative messages +.TP +3 +everything diff --git a/include/mp4v2/chapter.h b/include/mp4v2/chapter.h new file mode 100644 index 0000000..5b493a5 --- /dev/null +++ b/include/mp4v2/chapter.h @@ -0,0 +1,176 @@ +#ifndef MP4V2_CHAPTER_H +#define MP4V2_CHAPTER_H + +/**************************************************************************//** + * + * @defgroup mp4_chapter MP4v2 Chapter + * @{ + * + *****************************************************************************/ + +/** The maximum length of a QuickTime chapter title (in 8-bit chars) + */ +#define MP4V2_CHAPTER_TITLE_MAX 1023 + +/** Chapter item. + * This item defines various attributes for a chapter. + * @ingroup mp4_chapter + */ +typedef struct MP4Chapter_s { + MP4Duration duration; /**< duration of chapter in milliseconds */ + char title[MP4V2_CHAPTER_TITLE_MAX+1]; /**< title of chapter */ +} MP4Chapter_t; + +/** Known chapter types. + * @ingroup mp4_chapter + */ +typedef enum { + MP4ChapterTypeNone = 0, /**< no chapters found return value */ + MP4ChapterTypeAny = 1, /**< any or all known chapter types */ + MP4ChapterTypeQt = 2, /**< QuickTime chapter type */ + MP4ChapterTypeNero = 4 /**< Nero chapter type */ +} MP4ChapterType; + +/** Add a QuickTime chapter. + * + * This function adds a QuickTime chapter to file <b>hFile</b>. + * + * @param hFile handle of file to add chapter. + * @param chapterTrackId ID of chapter track or #MP4_INVALID_TRACK_ID + * if unknown. + * @param chapterDuration duration (in the timescale of the chapter track). + * @param chapterTitle title text for the chapter or NULL to use default + * title format ("Chapter %03d", n) where n is the chapter number. + */ +MP4V2_EXPORT +void MP4AddChapter( + MP4FileHandle hFile, + MP4TrackId chapterTrackId, + MP4Duration chapterDuration, + const char* chapterTitle DEFAULT(0)); + +/** Add a QuickTime chapter track. + * + * This function adds a chapter (text) track to file <b>hFile</b>. + * The optional parameter <b>timescale</b> may be supplied to give the new + * chapter a specific timescale. Otherwise the chapter track will have + * the same timescale as the reference track defined in parameter refTrackId. + * + * @param hFile handle of file to add chapter track. + * @param refTrackId ID of the track that will reference the chapter track. + * @param timescale the timescale of the chapter track or 0 to use the + * timescale of track specified by <b>refTrackId</b>. + * + * @return ID of the created chapter track. + */ +MP4V2_EXPORT +MP4TrackId MP4AddChapterTextTrack( + MP4FileHandle hFile, + MP4TrackId refTrackId, + uint32_t timescale DEFAULT(0) ); + +/** Add a Nero chapter. + * + * This function adds a Nero chapter to file <b>hFile</b>. + * + * @param hFile handle of file to add chapter. + * @param chapterStart the start time of the chapter in 100 nanosecond units + * @param chapterTitle title text for the chapter or NULL to use default + * title format ("Chapter %03d", n) where n is the chapter number. + */ +MP4V2_EXPORT +void MP4AddNeroChapter( + MP4FileHandle hFile, + MP4Timestamp chapterStart, + const char* chapterTitle DEFAULT(0)); + +/** Convert chapters to another type. + * + * This function converts existing chapters in file <b>hFile</b> + * from one type to another type. + * Conversion from Nero to QuickTime or QuickTime to Nero is supported. + * + * @param hFile handle of file to convert. + * @param toChapterType the chapter type to convert to: + * @li #MP4ChapterTypeQt (convert from Nero to Qt) + * @li #MP4ChapterTypeNero (convert from Qt to Nero) + * + * @return the chapter type before conversion or #MP4ChapterTypeNone + * if the source chapters do not exist + * or invalid <b>toChapterType</b> was specified. + */ +MP4V2_EXPORT +MP4ChapterType MP4ConvertChapters( + MP4FileHandle hFile, + MP4ChapterType toChapterType DEFAULT(MP4ChapterTypeQt)); + +/** Delete chapters. + * + * This function deletes existing chapters in file <b>hFile</b>. + * + * @param hFile handle of file to delete chapters. + * @param chapterType the type of chapters to delete: + * @li #MP4ChapterTypeAny (delete all known chapter types) + * @li #MP4ChapterTypeQt + * @li #MP4ChapterTypeNero + * @param chapterTrackId ID of the chapter track if known, + * or #MP4_INVALID_TRACK_ID. + * Only applies when <b>chapterType</b>=#MP4ChapterTypeQt. + * + * @return the type of deleted chapters + */ +MP4V2_EXPORT +MP4ChapterType MP4DeleteChapters( + MP4FileHandle hFile, + MP4ChapterType chapterType DEFAULT(MP4ChapterTypeQt), + MP4TrackId chapterTrackId DEFAULT(MP4_INVALID_TRACK_ID) ); + +/** Get list of chapters. + * + * This function gets a chpter list from file <b>hFile</b>. + * + * @param hFile handle of file to read. + * @param chapterList address receiving array of chapter items. + * If a non-NULL is received the caller is responsible for freeing the + * memory with MP4Free(). + * @param chapterCount address receiving count of items in array. + * @param chapterType the type of chapters to read: + * @li #MP4ChapterTypeAny (any chapters, searched in order of Qt, Nero) + * @li #MP4ChapterTypeQt + * @li #MP4ChapterTypeNero + * + * @result the first type of chapters found. + */ +MP4V2_EXPORT +MP4ChapterType MP4GetChapters( + MP4FileHandle hFile, + MP4Chapter_t** chapterList, + uint32_t* chapterCount, + MP4ChapterType chapterType DEFAULT(MP4ChapterTypeQt)); + +/** Set list of chapters OKOK. + * + * This functions sets the complete chapter list in file <b>hFile</b>. + * If any chapters of the same type already exist they will first + * be deleted. + * + * @param hFile handle of file to modify. + * @param chapterList array of chapters items. + * @param chapterCount count of items in array. + * @param chapterType type of chapters to write: + * @li #MP4ChapterTypeAny (chapters of all types are written) + * @li #MP4ChapterTypeQt + * @li #MP4ChapterTypeNero + * + * @return the type of chapters written. + */ +MP4V2_EXPORT +MP4ChapterType MP4SetChapters( + MP4FileHandle hFile, + MP4Chapter_t* chapterList, + uint32_t chapterCount, + MP4ChapterType chapterType DEFAULT(MP4ChapterTypeQt)); + +/** @} ***********************************************************************/ + +#endif /* MP4V2_CHAPTER_H */ diff --git a/include/mp4v2/file.h b/include/mp4v2/file.h new file mode 100644 index 0000000..1e662e2 --- /dev/null +++ b/include/mp4v2/file.h @@ -0,0 +1,403 @@ +#ifndef MP4V2_FILE_H +#define MP4V2_FILE_H + +/**************************************************************************//** + * + * @defgroup mp4_file MP4v2 File I/O + * @{ + * + *****************************************************************************/ + +#define MP4_DETAILS_ALL 0xFFFFFFFF /**< Verbosity bitmask: all possible details. */ +#define MP4_DETAILS_ERROR 0x00000001 /**< Verbosity bit: reasons for errors. */ +#define MP4_DETAILS_WARNING 0x00000002 /**< Verbosity bit: warnings. */ +#define MP4_DETAILS_READ 0x00000004 /**< Verbosity bit: read operations. */ +#define MP4_DETAILS_WRITE 0x00000008 /**< Verbosity bit: write operations. */ +#define MP4_DETAILS_FIND 0x00000010 /**< Verbosity bit: find property operations. */ +#define MP4_DETAILS_TABLE 0x00000020 /**< Verbosity bit: per table entry details. */ +#define MP4_DETAILS_SAMPLE 0x00000040 /**< Verbosity bit: per sample details. */ +#define MP4_DETAILS_HINT 0x00000080 /**< Verbosity bit: per RTP hint details. */ +#define MP4_DETAILS_ISMA 0x00000100 /**< Verbosity bit: ISMA details. */ +#define MP4_DETAILS_EDIT 0x00000200 /**< Verbosity bit: edit details. */ + +/** Bit: enable 64-bit data-atoms. */ +#define MP4_CREATE_64BIT_DATA 0x01 +/** Bit: enable 64-bit time-atoms. + * @note Incompatible with QuickTime. + */ +#define MP4_CREATE_64BIT_TIME 0x02 +/** Bitmask: convenience for both data and time atoms. + * @deprecated scheduled for removal + */ +#define MP4_CREATE_64BIT (MP4_CREATE_64BIT_DATA | MP4_CREATE_64BIT_TIME) +/** Not used. + * @deprecated scheduled for removal + */ +#define MP4_CREATE_EXTENSIBLE_FORMAT 0x04 + +/** Enumeration of file modes for custom file provider. */ +typedef enum MP4FileMode_e +{ + FILEMODE_UNDEFINED, /**< undefined */ + FILEMODE_READ, /**< file may be read */ + FILEMODE_MODIFY, /**< file may be read/written */ + FILEMODE_CREATE, /**< file will be created/truncated for read/write */ +} MP4FileMode; + +/** Structure of functions implementing custom file provider. + * + * Except for <b>open</b>, al the functions must return a true value + * to indicate failure or false on success. The open function must return + * a pointer or handle which represents the open file, otherwise NULL. + * + * maxChunkSize is a hint suggesting what the max size of data should be read + * as in underlying read/write operations. A value of 0 indicates there is no hint. + */ +typedef struct MP4FileProvider_s +{ + void* ( *open )( const char* name, MP4FileMode mode ); + int ( *seek )( void* handle, int64_t pos ); + int ( *read )( void* handle, void* buffer, int64_t size, int64_t* nin, int64_t maxChunkSize ); + int ( *write )( void* handle, const void* buffer, int64_t size, int64_t* nout, int64_t maxChunkSize ); + int ( *close )( void* handle ); +} MP4FileProvider; + +/** Get verbosity level for diagnostic information. + * + * @param hFile handle of file for operation. + * + * @return bitmask of flags of diagnostic information. + * + * @see MP4SetVerbosity() for further details. + */ +MP4V2_EXPORT +uint32_t MP4GetVerbosity( MP4FileHandle hFile ); + +/** Set verbosity level for diagnostic information. + * + * MP4SetVerbosity allows control over the level of diagnostic information + * printed out by the library. It can be called at any time. Since much is + * done by the library when opening an mp4 file, functions such as + * MP4Create(), MP4Modify(), and MP4Read() include a parameter for the. + * + * @param hFile handle of file for operation. + * @param verbosity bitmask of the following bits or <b>0</b> for none: + * @li #MP4_DETAILS_ALL + * @li #MP4_DETAILS_ERROR + * @li #MP4_DETAILS_WARNING + * @li #MP4_DETAILS_READ + * @li #MP4_DETAILS_WRITE + * @li #MP4_DETAILS_FIND + * @li #MP4_DETAILS_TABLE + * @li #MP4_DETAILS_SAMPLE + * @li #MP4_DETAILS_HINT + * @li #MP4_DETAILS_ISMA + * @li #MP4_DETAILS_EDIT + * + * @see MP4GetVerbosity(). + */ +MP4V2_EXPORT +void MP4SetVerbosity( MP4FileHandle hFile, uint32_t verbosity ); + +/** Close an mp4 file. + * MP4Close closes a previously opened mp4 file. If the file was opened + * writable with MP4Create() or MP4Modify(), then MP4Close() will write + * out all pending information to disk. + * + * @param hFile handle of file to close. + */ +MP4V2_EXPORT +void MP4Close( + MP4FileHandle hFile ); + +/** Create a new mp4 file. + * + * MP4Create is the first call that should be used when you want to create + * a new, empty mp4 file. It is equivalent to opening a file for writing, + * but also involved with creation of necessary mp4 framework structures. + * ie. invoking MP4Create() followed by MP4Close() will result in a file + * with a non-zero size. + * + * @param fileName pathname of the file to be created. + * @param verbosity bitmask of diagnostic details the library + * should print to stdout during its functioning. + * @param flags bitmask that allows the user to set 64-bit values for + * data or time atoms. Valid bits may be any combination of: + * @li #MP4_CREATE_64BIT_DATA + * @li #MP4_CREATE_64BIT_TIME + * + * @return On success a handle of the newly created file for use in + * subsequent calls to the library. + * On error, #MP4_INVALID_FILE_HANDLE. + * + * @see MP4SetVerbosity() for <b>verbosity</b> values. + */ +MP4V2_EXPORT +MP4FileHandle MP4Create( + const char* fileName, + uint32_t verbosity DEFAULT(0), + uint32_t flags DEFAULT(0) ); + +/** Create a new mp4 file with extended options. + * + * MP4CreateEx is an extended version of MP4Create(). + * + * @param fileName pathname of the file to be created. + * @param verbosity bitmask of diagnostic details the library + * should print to stdout during its functioning. + * @param flags bitmask that allows the user to set 64-bit values for + * data or time atoms. Valid bits may be any combination of: + * @li #MP4_CREATE_64BIT_DATA + * @li #MP4_CREATE_64BIT_TIME + * @param add_ftyp if true an <b>ftyp</b> atom is automatically created. + * @param add_iods if true an <b>iods</b> atom is automatically created. + * @param majorBrand <b>ftyp</b> brand identifier. + * @param minorVersion <b>ftyp</b> informative integer for the minor version + * of the major brand. + * @param compatibleBrands <b>ftyp</b> list of compatible brands. + * @param compatibleBrandsCount is the count of items specified in + * compatibleBrands. + * + * @return On success a handle of the newly created file for use in + * subsequent calls to the library. + * On error, #MP4_INVALID_FILE_HANDLE. + * + * @see MP4SetVerbosity() for <b>verbosity</b> values. + */ +MP4V2_EXPORT +MP4FileHandle MP4CreateEx( + const char* fileName, + uint32_t verbosity DEFAULT(0), + uint32_t flags DEFAULT(0), + int add_ftyp DEFAULT(1), + int add_iods DEFAULT(1), + char* majorBrand DEFAULT(0), + uint32_t minorVersion DEFAULT(0), + char** compatibleBrands DEFAULT(0), + uint32_t compatibleBrandsCount DEFAULT(0) ); + +/** Dump mp4 file contents as ASCII. + * + * Dump is an invaluable debugging tool in that in can reveal all the details + * of the mp4 control structures. However, the output will not make much sense + * until you familiarize yourself with the mp4 specification (or the Quicktime + * File Format specification). + * + * Note that MP4Dump() will not print the individual values of control tables, + * such as the size of each sample, unless the current verbosity value + * includes the flag #MP4_DETAILS_TABLE. + * See MP4SetVerbosity() for how to set this flag. + * + * @param hFile handle of file to dump. + * @param pDumpFile dump destination. If NULL stdout will be used. + * @param dumpImplicits prints properties which would not actually be + * written to the mp4 file, but still exist in mp4 control structures. + * ie. they are implicit given the current values of other controlling + * properties. + * + * @return <b>true</b> on success, <b>false</b> on failure. + * + * @see MP4SetVerbosity(). + */ +MP4V2_EXPORT +bool MP4Dump( + MP4FileHandle hFile, + FILE* pDumpFile DEFAULT(NULL), + bool dumpImplicits DEFAULT(0) ); + +/** Return a textual summary of an mp4 file. + * + * MP4FileInfo provides a string that contains a textual summary of the + * contents of an mp4 file. This includes the track id's, the track type, + * and track specific information. For example, for a video track, media + * encoding, image size, frame rate, and bitrate are summarized. + * + * Note that the returned string is malloc'ed, so it is the caller's + * responsibility to free() the string. Also note that the returned string + * contains newlines and tabs which may or may not be desirable. + * + * The following is an example of the output of MP4Info(): +@verbatim +Track Type Info +1 video MPEG−4 Simple @ L3, 119.625 secs, 1008 kbps, 352x288 @ 24.00 fps +2 audio MPEG−4, 119.327 secs, 128 kbps, 44100 Hz +3 hint Payload MP4V−ES for track 1 +4 hint Payload mpeg4−generic for track 2 +5 od Object Descriptors +6 scene BIFS +@endverbatim + * + * @param fileName pathname to mp4 file to summarize. + * @param trackId specifies track to summarize. If the value is + * #MP4_INVALID_TRACK_ID, the summary info is created for all + * tracks in the file. + * + * @return On success a malloc'd string containing summary information. + * On failure, <b>NULL</b>. + * + * @see MP4Info(). + */ +MP4V2_EXPORT +char* MP4FileInfo( + const char* fileName, + MP4TrackId trackId DEFAULT(MP4_INVALID_TRACK_ID) ); + +/** Return a textual summary of an mp4 file. + * + * MP4FileInfo provides a string that contains a textual summary of the + * contents of an mp4 file. This includes the track id's, the track type, + * and track specific information. For example, for a video track, media + * encoding, image size, frame rate, and bitrate are summarized. + * + * Note that the returned string is malloc'ed, so it is the caller's + * responsibility to free() the string. Also note that the returned string + * contains newlines and tabs which may or may not be desirable. + * + * The following is an example of the output of MP4Info(): +@verbatim +Track Type Info +1 video MPEG−4 Simple @ L3, 119.625 secs, 1008 kbps, 352x288 @ 24.00 fps +2 audio MPEG−4, 119.327 secs, 128 kbps, 44100 Hz +3 hint Payload MP4V−ES for track 1 +4 hint Payload mpeg4−generic for track 2 +5 od Object Descriptors +6 scene BIFS +@endverbatim + * + * @param hFile handle of file to summarize. + * @param trackId specifies track to summarize. If the value is + * #MP4_INVALID_TRACK_ID, the summary info is created for all + * tracks in the file. + * + * @return On success a malloc'd string containing summary information. + * On failure, <b>NULL</b>. + * + * @see MP4FileInfo(). + */ +MP4V2_EXPORT +char* MP4Info( + MP4FileHandle hFile, + MP4TrackId trackId DEFAULT(MP4_INVALID_TRACK_ID) ); + +/** Modify an existing mp4 file. + * + * MP4Modify is the first call that should be used when you want to modify + * an existing mp4 file. It is roughly equivalent to opening a file in + * read/write mode. + * + * Since modifications to an existing mp4 file can result in a sub−optimal + * file layout, you may want to use MP4Optimize() after you have modified + * and closed the mp4 file. + * + * @param fileName pathname of the file to be modified. + * @param verbosity bitmask of diagnostic details the library + * should print to stdout during its functioning. + * @param flags currently ignored. + * + * @return On success a handle of the target file for use in subsequent calls + * to the library. + * On error, #MP4_INVALID_FILE_HANDLE. + * + * @see MP4SetVerbosity() for <b>verbosity</b> values. + */ +MP4V2_EXPORT +MP4FileHandle MP4Modify( + const char* fileName, + uint32_t verbosity DEFAULT(0), + uint32_t flags DEFAULT(0) ); + +/** Optimize the layout of an mp4 file. + * + * MP4Optimize reads an existing mp4 file and writes a new version of the + * file with the two important changes: + * + * First, the mp4 control information is moved to the beginning of the file. + * (Frequenty it is at the end of the file due to it being constantly + * modified as track samples are added to an mp4 file). This optimization + * is useful in that in allows the mp4 file to be HTTP streamed. + * + * Second, the track samples are interleaved so that the samples for a + * particular instant in time are colocated within the file. This + * eliminates disk seeks during playback of the file which results in + * better performance. + * + * There are also two important side effects of MP4Optimize(): + * + * First, any free blocks within the mp4 file are eliminated. + * + * Second, as a side effect of the sample interleaving process any media + * data chunks that are not actually referenced by the mp4 control + * structures are deleted. This is useful if you have called MP4DeleteTrack() + * which only deletes the control information for a track, and not the + * actual media data. + * + * @param fileName pathname of (existing) file to be optimized. + * @param newFileName pathname of the new optimized file. + * If NULL a temporary file will be used and <b>fileName</b> + * will be over-written upon successful completion. + * @param verbosity bitmask of diagnostic details the library + * should print to stdout during its functioning. + * + * @return <b>true</b> on success, <b>false</b> on failure. + * + * @see MP4SetVerbosity() for <b>verbosity</b> values. + */ +MP4V2_EXPORT +bool MP4Optimize( + const char* fileName, + const char* newFileName DEFAULT(NULL), + uint32_t verbosity DEFAULT(0) ); + +/** Read an existing mp4 file. + * + * MP4Read is the first call that should be used when you want to just + * read an existing mp4 file. It is equivalent to opening a file for + * reading, but in addition the mp4 file is parsed and the control + * information is loaded into memory. Note that actual track samples are not + * read into memory until MP4ReadSample() is called. + * + * @param fileName pathname of the file to be read. + * @param verbosity bitmask of diagnostic details the library + * should print to stdout during its functioning. + * + * @return On success a handle of the file for use in subsequent calls to + * the library. + * On error, #MP4_INVALID_FILE_HANDLE. + * + * @see MP4SetVerbosity() for <b>verbosity</b> values. + */ +MP4V2_EXPORT +MP4FileHandle MP4Read( + const char* fileName, + uint32_t verbosity DEFAULT(0) ); + +/** Read an existing mp4 file. + * + * MP4ReadProvider is the first call that should be used when you want to just + * read an existing mp4 file. It is equivalent to opening a file for + * reading, but in addition the mp4 file is parsed and the control + * information is loaded into memory. Note that actual track samples are not + * read into memory until MP4ReadSample() is called. + * + * @param fileName pathname of the file to be read. + * @param verbosity bitmask of diagnostic details the library + * should print to stdout during its functioning. + * @param fileProvider custom implementation of file I/O operations. + * All functions in structure must be implemented. + * The structure is immediately copied internally. + * + * @return On success a handle of the file for use in subsequent calls to + * the library. + * On error, #MP4_INVALID_FILE_HANDLE. + * + * @see MP4SetVerbosity() for <b>verbosity</b> values. + */ +MP4V2_EXPORT +MP4FileHandle MP4ReadProvider( + const char* fileName, + uint32_t verbosity DEFAULT(0), + const MP4FileProvider* fileProvider DEFAULT(NULL) ); + +/** @} ***********************************************************************/ + +#endif /* MP4V2_FILE_H */ diff --git a/include/mp4v2/file_prop.h b/include/mp4v2/file_prop.h new file mode 100644 index 0000000..15435e8 --- /dev/null +++ b/include/mp4v2/file_prop.h @@ -0,0 +1,148 @@ +#ifndef MP4V2_FILE_PROP_H +#define MP4V2_FILE_PROP_H + +/**************************************************************************//** + * + * @defgroup mp4_file_prop MP4v2 File Property + * @{ + * + *****************************************************************************/ + +/* generic props */ + +MP4V2_EXPORT +bool MP4HaveAtom( + MP4FileHandle hFile, + const char* atomName ); + +MP4V2_EXPORT +bool MP4GetIntegerProperty( + MP4FileHandle hFile, + const char* propName, + uint64_t* retval ); + +MP4V2_EXPORT +bool MP4GetFloatProperty( + MP4FileHandle hFile, + const char* propName, + float* retvalue ); + +MP4V2_EXPORT +bool MP4GetStringProperty( + MP4FileHandle hFile, + const char* propName, + const char** retvalue ); + +MP4V2_EXPORT +bool MP4GetBytesProperty( + MP4FileHandle hFile, + const char* propName, + uint8_t** ppValue, + uint32_t* pValueSize ); + +MP4V2_EXPORT +bool MP4SetIntegerProperty( + MP4FileHandle hFile, + const char* propName, + int64_t value ); + +MP4V2_EXPORT +bool MP4SetFloatProperty( + MP4FileHandle hFile, + const char* propName, + float value ); + +MP4V2_EXPORT +bool MP4SetStringProperty( + MP4FileHandle hFile, + const char* propName, + const char* value ); + +MP4V2_EXPORT +bool MP4SetBytesProperty( + MP4FileHandle hFile, + const char* propName, + const uint8_t* pValue, + uint32_t valueSize ); + +/* specific props */ + +MP4V2_EXPORT +MP4Duration MP4GetDuration( MP4FileHandle hFile ); + +/** Get the time scale of the movie (file). + * + * MP4GetTimeScale returns the time scale in units of ticks per second for + * the mp4 file. Caveat: tracks may use the same time scale as the movie + * or may use their own time scale. + * + * @param hFile handle of file for operation. + * + * @return timescale (ticks per second) of the mp4 file. + */ +MP4V2_EXPORT +uint32_t MP4GetTimeScale( MP4FileHandle hFile ); + +/** Set the time scale of the movie (file). + * + * MP4SetTimeScale sets the time scale of the mp4 file. The time scale is + * in the number of clock ticks per second. Caveat: tracks may use the + * same time scale as the movie or may use their own time scale. + * + * @param hFile handle of file for operation. + * @param value desired timescale for the movie. + * + * @return On success, true. On failure, false. + */ +MP4V2_EXPORT +bool MP4SetTimeScale( MP4FileHandle hFile, uint32_t value ); + +/** Change the general timescale of file hFile. + * + * This function changes the general timescale of the file <b>hFile</b> + * to the new timescale <b>value</b> by recalculating all values that depend + * on the timescale in "moov.mvhd". + * + * If the timescale is already equal to value nothing is done. + * + * @param hFile handle of file to change. + * @param value the new timescale. + */ +MP4V2_EXPORT +void MP4ChangeMovieTimeScale( MP4FileHandle hFile, uint32_t value ); + +MP4V2_EXPORT +uint8_t MP4GetODProfileLevel( MP4FileHandle hFile ); + +MP4V2_EXPORT +bool MP4SetODProfileLevel( MP4FileHandle hFile, uint8_t value ); + +MP4V2_EXPORT +uint8_t MP4GetSceneProfileLevel( MP4FileHandle hFile ); + +MP4V2_EXPORT +bool MP4SetSceneProfileLevel( MP4FileHandle hFile, uint8_t value ); + +MP4V2_EXPORT +uint8_t MP4GetVideoProfileLevel( + MP4FileHandle hFile, + MP4TrackId trackId DEFAULT(MP4_INVALID_TRACK_ID) ); + +MP4V2_EXPORT +void MP4SetVideoProfileLevel( MP4FileHandle hFile, uint8_t value ); + +MP4V2_EXPORT +uint8_t MP4GetAudioProfileLevel( MP4FileHandle hFile ); + +MP4V2_EXPORT +void MP4SetAudioProfileLevel( MP4FileHandle hFile, uint8_t value ); + +MP4V2_EXPORT +uint8_t MP4GetGraphicsProfileLevel( MP4FileHandle hFile ); + +MP4V2_EXPORT +bool MP4SetGraphicsProfileLevel( MP4FileHandle hFile, uint8_t value ); + +/** @} ***********************************************************************/ + +#endif /* MP4V2_FILE_PROP_H */ diff --git a/include/mp4v2/general.h b/include/mp4v2/general.h new file mode 100644 index 0000000..62ebde7 --- /dev/null +++ b/include/mp4v2/general.h @@ -0,0 +1,475 @@ +#ifndef MP4V2_GENERAL_H +#define MP4V2_GENERAL_H + +/**************************************************************************//** + * + * @defgroup mp4_general MP4v2 General + * @{ + * + *****************************************************************************/ + +/* MP4 API types */ +typedef void* MP4FileHandle; +typedef uint32_t MP4TrackId; +typedef uint32_t MP4SampleId; +typedef uint64_t MP4Timestamp; +typedef uint64_t MP4Duration; +typedef uint32_t MP4EditId; + +/*****************************************************************************/ + +typedef void (*error_msg_func_t)( + int loglevel, + const char* lib, + const char* fmt, + va_list ap ); + +typedef void (*lib_message_func_t)( + int loglevel, + const char* lib, + const char* fmt, + ... ); + +/*****************************************************************************/ + +/** Encryption function pointer. + * + * @see MP4EncAndCopySample(). + * @see MP4EncAndCopyTrack(). + */ +typedef uint32_t (*encryptFunc_t)( uint32_t, uint32_t, uint8_t*, uint32_t*, uint8_t** ); + +/*****************************************************************************/ + +#define MP4_INVALID_FILE_HANDLE ((MP4FileHandle)NULL) /**< Constant: invalid MP4FileHandle. */ +#define MP4_INVALID_TRACK_ID ((MP4TrackId)0) /**< Constant: invalid MP4TrackId. */ +#define MP4_INVALID_SAMPLE_ID ((MP4SampleId)0) /**< Constant: invalid MP4SampleId. */ +#define MP4_INVALID_TIMESTAMP ((MP4Timestamp)-1) /**< Constant: invalid MP4Timestamp. */ +#define MP4_INVALID_DURATION ((MP4Duration)-1) /**< Constant: invalid MP4Duration. */ +#define MP4_INVALID_EDIT_ID ((MP4EditId)0) /**< Constant: invalid MP4EditId. */ + +/* Macros to test for API type validity */ +#define MP4_IS_VALID_FILE_HANDLE(x) ((x) != MP4_INVALID_FILE_HANDLE) +#define MP4_IS_VALID_TRACK_ID(x) ((x) != MP4_INVALID_TRACK_ID) +#define MP4_IS_VALID_SAMPLE_ID(x) ((x) != MP4_INVALID_SAMPLE_ID) +#define MP4_IS_VALID_TIMESTAMP(x) ((x) != MP4_INVALID_TIMESTAMP) +#define MP4_IS_VALID_DURATION(x) ((x) != MP4_INVALID_DURATION) +#define MP4_IS_VALID_EDIT_ID(x) ((x) != MP4_INVALID_EDIT_ID) + +#define MP4_DETAILS_READ_ALL \ + (MP4_DETAILS_READ | MP4_DETAILS_TABLE | MP4_DETAILS_SAMPLE) +#define MP4_DETAILS_WRITE_ALL \ + (MP4_DETAILS_WRITE | MP4_DETAILS_TABLE | MP4_DETAILS_SAMPLE) + +/* + * MP4 Known track type names - e.g. MP4GetNumberOfTracks(type) + * + * Note this first group of track types should be created + * via the MP4Add<Type>Track() functions, and not MP4AddTrack(type) + */ +#define MP4_OD_TRACK_TYPE "odsm" /**< Constant: OD track. */ +#define MP4_SCENE_TRACK_TYPE "sdsm" /**< Constant: scene track. */ +#define MP4_AUDIO_TRACK_TYPE "soun" /**< Constant: audio track. */ +#define MP4_VIDEO_TRACK_TYPE "vide" /**< Constant: video track. */ +#define MP4_HINT_TRACK_TYPE "hint" /**< Constant: hint track. */ +#define MP4_CNTL_TRACK_TYPE "cntl" /**< Constant: control track. */ +#define MP4_TEXT_TRACK_TYPE "text" /**< Constant: text track. */ +#define MP4_SUBTITLE_TRACK_TYPE "sbtl" /**< Constant: subtitle track. */ +/* + * This second set of track types should be created + * via MP4AddSystemsTrack(type) + */ +#define MP4_CLOCK_TRACK_TYPE "crsm" /**< Constant: clock track. */ +#define MP4_MPEG7_TRACK_TYPE "m7sm" /**< Constant: mpeg7 track. */ +#define MP4_OCI_TRACK_TYPE "ocsm" /**< Constant: OCI track. */ +#define MP4_IPMP_TRACK_TYPE "ipsm" /**< Constant: IPMP track. */ +#define MP4_MPEGJ_TRACK_TYPE "mjsm" /**< Constant: MPEGJ track. */ + +#define MP4_IS_VIDEO_TRACK_TYPE(type) \ + (!strcasecmp(type, MP4_VIDEO_TRACK_TYPE)) + +#define MP4_IS_AUDIO_TRACK_TYPE(type) \ + (!strcasecmp(type, MP4_AUDIO_TRACK_TYPE)) + +#define MP4_IS_CNTL_TRACK_TYPE(type) \ + (!strcasecmp(type, MP4_CNTL_TRACK_TYPE)) + +#define MP4_IS_OD_TRACK_TYPE(type) \ + (!strcasecmp(type, MP4_OD_TRACK_TYPE)) + +#define MP4_IS_SCENE_TRACK_TYPE(type) \ + (!strcasecmp(type, MP4_SCENE_TRACK_TYPE)) + +#define MP4_IS_HINT_TRACK_TYPE(type) \ + (!strcasecmp(type, MP4_HINT_TRACK_TYPE)) + +#define MP4_IS_SYSTEMS_TRACK_TYPE(type) \ + (!strcasecmp(type, MP4_CLOCK_TRACK_TYPE) \ + || !strcasecmp(type, MP4_MPEG7_TRACK_TYPE) \ + || !strcasecmp(type, MP4_OCI_TRACK_TYPE) \ + || !strcasecmp(type, MP4_IPMP_TRACK_TYPE) \ + || !strcasecmp(type, MP4_MPEGJ_TRACK_TYPE)) + +/* MP4 Audio track types - see MP4AddAudioTrack()*/ +#define MP4_INVALID_AUDIO_TYPE 0x00 +#define MP4_MPEG1_AUDIO_TYPE 0x6B +#define MP4_MPEG2_AUDIO_TYPE 0x69 +#define MP4_MP3_AUDIO_TYPE MP4_MPEG2_AUDIO_TYPE +#define MP4_MPEG2_AAC_MAIN_AUDIO_TYPE 0x66 +#define MP4_MPEG2_AAC_LC_AUDIO_TYPE 0x67 +#define MP4_MPEG2_AAC_SSR_AUDIO_TYPE 0x68 +#define MP4_MPEG2_AAC_AUDIO_TYPE MP4_MPEG2_AAC_MAIN_AUDIO_TYPE +#define MP4_MPEG4_AUDIO_TYPE 0x40 +#define MP4_PRIVATE_AUDIO_TYPE 0xC0 +#define MP4_PCM16_LITTLE_ENDIAN_AUDIO_TYPE 0xE0 /* a private definition */ +#define MP4_VORBIS_AUDIO_TYPE 0xE1 /* a private definition */ +#define MP4_AC3_AUDIO_TYPE 0xE2 /* a private definition */ +#define MP4_ALAW_AUDIO_TYPE 0xE3 /* a private definition */ +#define MP4_ULAW_AUDIO_TYPE 0xE4 /* a private definition */ +#define MP4_G723_AUDIO_TYPE 0xE5 /* a private definition */ +#define MP4_PCM16_BIG_ENDIAN_AUDIO_TYPE 0xE6 /* a private definition */ + +/* MP4 MPEG-4 Audio types from 14496-3 Table 1.5.1 */ +#define MP4_MPEG4_INVALID_AUDIO_TYPE 0 +#define MP4_MPEG4_AAC_MAIN_AUDIO_TYPE 1 +#define MP4_MPEG4_AAC_LC_AUDIO_TYPE 2 +#define MP4_MPEG4_AAC_SSR_AUDIO_TYPE 3 +#define MP4_MPEG4_AAC_LTP_AUDIO_TYPE 4 +#define MP4_MPEG4_AAC_HE_AUDIO_TYPE 5 +#define MP4_MPEG4_AAC_SCALABLE_AUDIO_TYPE 6 +#define MP4_MPEG4_CELP_AUDIO_TYPE 8 +#define MP4_MPEG4_HVXC_AUDIO_TYPE 9 +#define MP4_MPEG4_TTSI_AUDIO_TYPE 12 +#define MP4_MPEG4_MAIN_SYNTHETIC_AUDIO_TYPE 13 +#define MP4_MPEG4_WAVETABLE_AUDIO_TYPE 14 +#define MP4_MPEG4_MIDI_AUDIO_TYPE 15 +#define MP4_MPEG4_ALGORITHMIC_FX_AUDIO_TYPE 16 +#define MP4_MPEG4_ALS_AUDIO_TYPE 31 +#define MP4_MPEG4_LAYER1_AUDIO_TYPE 32 +#define MP4_MPEG4_LAYER2_AUDIO_TYPE 33 +#define MP4_MPEG4_LAYER3_AUDIO_TYPE 34 +#define MP4_MPEG4_SLS_AUDIO_TYPE 35 + +/* MP4 Audio type utilities following common usage */ +#define MP4_IS_MP3_AUDIO_TYPE(type) \ + ((type) == MP4_MPEG1_AUDIO_TYPE || (type) == MP4_MPEG2_AUDIO_TYPE) + +#define MP4_IS_MPEG2_AAC_AUDIO_TYPE(type) \ + (((type) >= MP4_MPEG2_AAC_MAIN_AUDIO_TYPE \ + && (type) <= MP4_MPEG2_AAC_SSR_AUDIO_TYPE)) + +#define MP4_IS_MPEG4_AAC_AUDIO_TYPE(mpeg4Type) \ + (((mpeg4Type) >= MP4_MPEG4_AAC_MAIN_AUDIO_TYPE \ + && (mpeg4Type) <= MP4_MPEG4_AAC_HE_AUDIO_TYPE) \ + || (mpeg4Type) == MP4_MPEG4_AAC_SCALABLE_AUDIO_TYPE \ + || (mpeg4Type) == 17) + +#define MP4_IS_AAC_AUDIO_TYPE(type) \ + (MP4_IS_MPEG2_AAC_AUDIO_TYPE(type) \ + || (type) == MP4_MPEG4_AUDIO_TYPE) + +/* MP4 Video track types - see MP4AddVideoTrack() */ +#define MP4_INVALID_VIDEO_TYPE 0x00 +#define MP4_MPEG1_VIDEO_TYPE 0x6A +#define MP4_MPEG2_SIMPLE_VIDEO_TYPE 0x60 +#define MP4_MPEG2_MAIN_VIDEO_TYPE 0x61 +#define MP4_MPEG2_SNR_VIDEO_TYPE 0x62 +#define MP4_MPEG2_SPATIAL_VIDEO_TYPE 0x63 +#define MP4_MPEG2_HIGH_VIDEO_TYPE 0x64 +#define MP4_MPEG2_442_VIDEO_TYPE 0x65 +#define MP4_MPEG2_VIDEO_TYPE MP4_MPEG2_MAIN_VIDEO_TYPE +#define MP4_MPEG4_VIDEO_TYPE 0x20 +#define MP4_JPEG_VIDEO_TYPE 0x6C +#define MP4_PRIVATE_VIDEO_TYPE 0xD0 +#define MP4_YUV12_VIDEO_TYPE 0xF0 /* a private definition */ +#define MP4_H263_VIDEO_TYPE 0xF2 /* a private definition */ +#define MP4_H261_VIDEO_TYPE 0xF3 /* a private definition */ + +/* MP4 Video type utilities */ +#define MP4_IS_MPEG1_VIDEO_TYPE(type) \ + ((type) == MP4_MPEG1_VIDEO_TYPE) + +#define MP4_IS_MPEG2_VIDEO_TYPE(type) \ + (((type) >= MP4_MPEG2_SIMPLE_VIDEO_TYPE \ + && (type) <= MP4_MPEG2_442_VIDEO_TYPE) \ + || MP4_IS_MPEG1_VIDEO_TYPE(type)) + +#define MP4_IS_MPEG4_VIDEO_TYPE(type) \ + ((type) == MP4_MPEG4_VIDEO_TYPE) + +/* Mpeg4 Visual Profile Defines - ISO/IEC 14496-2:2001/Amd.2:2002(E) */ +#define MPEG4_SP_L1 (0x1) +#define MPEG4_SP_L2 (0x2) +#define MPEG4_SP_L3 (0x3) +#define MPEG4_SP_L0 (0x8) +#define MPEG4_SSP_L1 (0x11) +#define MPEG4_SSP_L2 (0x12) +#define MPEG4_CP_L1 (0x21) +#define MPEG4_CP_L2 (0x22) +#define MPEG4_MP_L2 (0x32) +#define MPEG4_MP_L3 (0x33) +#define MPEG4_MP_L4 (0x34) +#define MPEG4_NBP_L2 (0x42) +#define MPEG4_STP_L1 (0x51) +#define MPEG4_SFAP_L1 (0x61) +#define MPEG4_SFAP_L2 (0x62) +#define MPEG4_SFBAP_L1 (0x63) +#define MPEG4_SFBAP_L2 (0x64) +#define MPEG4_BATP_L1 (0x71) +#define MPEG4_BATP_L2 (0x72) +#define MPEG4_HP_L1 (0x81) +#define MPEG4_HP_L2 (0x82) +#define MPEG4_ARTSP_L1 (0x91) +#define MPEG4_ARTSP_L2 (0x92) +#define MPEG4_ARTSP_L3 (0x93) +#define MPEG4_ARTSP_L4 (0x94) +#define MPEG4_CSP_L1 (0xa1) +#define MPEG4_CSP_L2 (0xa2) +#define MPEG4_CSP_L3 (0xa3) +#define MPEG4_ACEP_L1 (0xb1) +#define MPEG4_ACEP_L2 (0xb2) +#define MPEG4_ACEP_L3 (0xb3) +#define MPEG4_ACEP_L4 (0xb4) +#define MPEG4_ACP_L1 (0xc1) +#define MPEG4_ACP_L2 (0xc2) +#define MPEG4_AST_L1 (0xd1) +#define MPEG4_AST_L2 (0xd2) +#define MPEG4_AST_L3 (0xd3) +#define MPEG4_S_STUDIO_P_L1 (0xe1) +#define MPEG4_S_STUDIO_P_L2 (0xe2) +#define MPEG4_S_STUDIO_P_L3 (0xe3) +#define MPEG4_S_STUDIO_P_L4 (0xe4) +#define MPEG4_C_STUDIO_P_L1 (0xe5) +#define MPEG4_C_STUDIO_P_L2 (0xe6) +#define MPEG4_C_STUDIO_P_L3 (0xe7) +#define MPEG4_C_STUDIO_P_L4 (0xe8) +#define MPEG4_ASP_L0 (0xF0) +#define MPEG4_ASP_L1 (0xF1) +#define MPEG4_ASP_L2 (0xF2) +#define MPEG4_ASP_L3 (0xF3) +#define MPEG4_ASP_L4 (0xF4) +#define MPEG4_ASP_L5 (0xF5) +#define MPEG4_ASP_L3B (0xF7) +#define MPEG4_FGSP_L0 (0xf8) +#define MPEG4_FGSP_L1 (0xf9) +#define MPEG4_FGSP_L2 (0xfa) +#define MPEG4_FGSP_L3 (0xfb) +#define MPEG4_FGSP_L4 (0xfc) +#define MPEG4_FGSP_L5 (0xfd) + +/*****************************************************************************/ + +/* 3GP specific utilities */ + +MP4V2_EXPORT +bool MP4Make3GPCompliant( + const char* fileName, + uint32_t verbosity DEFAULT(0), + char* majorBrand DEFAULT(0), + uint32_t minorVersion DEFAULT(0), + char** supportedBrands DEFAULT(NULL), + uint32_t supportedBrandsCount DEFAULT(0), + bool deleteIodsAtom DEFAULT(true) ); + +/* NOTE this section of functionality has not yet been fully tested */ + +MP4V2_EXPORT +MP4EditId MP4AddTrackEdit( + MP4FileHandle hFile, + MP4TrackId trackId, + MP4EditId editId DEFAULT(MP4_INVALID_EDIT_ID), + MP4Timestamp startTime DEFAULT(0), + MP4Duration duration DEFAULT(0), + bool dwell DEFAULT(false) ); + +MP4V2_EXPORT +bool MP4DeleteTrackEdit( + MP4FileHandle hFile, + MP4TrackId trackId, + MP4EditId editId ); + +MP4V2_EXPORT +uint32_t MP4GetTrackNumberOfEdits( + MP4FileHandle hFile, + MP4TrackId trackId ); + +MP4V2_EXPORT +MP4Timestamp MP4GetTrackEditStart( + MP4FileHandle hFile, + MP4TrackId trackId, + MP4EditId editId ); + +MP4V2_EXPORT +MP4Duration MP4GetTrackEditTotalDuration( + MP4FileHandle hFile, + MP4TrackId trackId, + MP4EditId editId DEFAULT(MP4_INVALID_EDIT_ID) ); + +MP4V2_EXPORT +MP4Timestamp MP4GetTrackEditMediaStart( + MP4FileHandle hFile, + MP4TrackId trackId, + MP4EditId editId ); + +MP4V2_EXPORT +bool MP4SetTrackEditMediaStart( + MP4FileHandle hFile, + MP4TrackId trackId, + MP4EditId editId, + MP4Timestamp startTime ); + +MP4V2_EXPORT +MP4Duration MP4GetTrackEditDuration( + MP4FileHandle hFile, + MP4TrackId trackId, + MP4EditId editId ); + +MP4V2_EXPORT +bool MP4SetTrackEditDuration( + MP4FileHandle hFile, + MP4TrackId trackId, + MP4EditId editId, + MP4Duration duration ); + +MP4V2_EXPORT +int8_t MP4GetTrackEditDwell( + MP4FileHandle hFile, + MP4TrackId trackId, + MP4EditId editId ); + +MP4V2_EXPORT +bool MP4SetTrackEditDwell( + MP4FileHandle hFile, + MP4TrackId trackId, + MP4EditId editId, + bool dwell ); + +MP4V2_EXPORT +bool MP4ReadSampleFromEditTime( + /* input parameters */ + MP4FileHandle hFile, + MP4TrackId trackId, + MP4Timestamp when, + /* input/output parameters */ + uint8_t** ppBytes, + uint32_t* pNumBytes, + /* output parameters */ + MP4Timestamp* pStartTime DEFAULT(NULL), + MP4Duration* pDuration DEFAULT(NULL), + MP4Duration* pRenderingOffset DEFAULT(NULL), + bool* pIsSyncSample DEFAULT(NULL) ); + +MP4V2_EXPORT +MP4SampleId MP4GetSampleIdFromEditTime( + MP4FileHandle hFile, + MP4TrackId trackId, + MP4Timestamp when, + MP4Timestamp* pStartTime DEFAULT(NULL), + MP4Duration* pDuration DEFAULT(NULL) ); + +/* time conversion utilties */ + +/* predefined values for timeScale parameter below */ +#define MP4_SECONDS_TIME_SCALE 1 +#define MP4_MILLISECONDS_TIME_SCALE 1000 +#define MP4_MICROSECONDS_TIME_SCALE 1000000 +#define MP4_NANOSECONDS_TIME_SCALE 1000000000 + +#define MP4_SECS_TIME_SCALE MP4_SECONDS_TIME_SCALE +#define MP4_MSECS_TIME_SCALE MP4_MILLISECONDS_TIME_SCALE +#define MP4_USECS_TIME_SCALE MP4_MICROSECONDS_TIME_SCALE +#define MP4_NSECS_TIME_SCALE MP4_NANOSECONDS_TIME_SCALE + +MP4V2_EXPORT +uint64_t MP4ConvertFromMovieDuration( + MP4FileHandle hFile, + MP4Duration duration, + uint32_t timeScale ); + +MP4V2_EXPORT +uint64_t MP4ConvertFromTrackTimestamp( + MP4FileHandle hFile, + MP4TrackId trackId, + MP4Timestamp timeStamp, + uint32_t timeScale ); + +MP4V2_EXPORT +MP4Timestamp MP4ConvertToTrackTimestamp( + MP4FileHandle hFile, + MP4TrackId trackId, + uint64_t timeStamp, + uint32_t timeScale ); + +/** Convert duration from track time scale to an arbitrary time scale. + * + * MP4ConvertFromTrackDuration converts a duration such as a sample duration + * from the track time scale to another time scale. This can be used by a + * player application to map all track samples to a common time scale. + * + * @param hFile handle of file for operation. + * @param trackId id of track for operation. + * @param duration value to be converted. + * @param timeScale time scale in ticks per second. + * + * @return On success, the duration in arbitrary time scale units. + * On error, <b>0</b>. + * + * @see MP4GetSampleDuration(). + * @see MP4ConvertToTrackDuration(). + */ +MP4V2_EXPORT +uint64_t MP4ConvertFromTrackDuration( + MP4FileHandle hFile, + MP4TrackId trackId, + MP4Duration duration, + uint32_t timeScale ); + +/** Convert duration from arbitrary time scale to track time scale. + * + * MP4ConvertToTrackDuration converts a duration such as a sample duration + * from the specified time scale to the track time scale. + * + * @param hFile handle of file for operation. + * @param trackId id of track for operation. + * @param duration value to be converted. + * @param timeScale time scale in ticks per second. + * + * @return On success, the duration in track time scale units. + * On error, #MP4_INVALID_DURATION. + * + * @see MP4ConvertFromTrackDuration(). + */ +MP4V2_EXPORT +MP4Duration MP4ConvertToTrackDuration( + MP4FileHandle hFile, + MP4TrackId trackId, + uint64_t duration, + uint32_t timeScale ); + +MP4V2_EXPORT +char* MP4BinaryToBase16( + const uint8_t* pData, + uint32_t dataSize ); + +MP4V2_EXPORT +char* MP4BinaryToBase64( + const uint8_t* pData, + uint32_t dataSize ); + +MP4V2_EXPORT +uint8_t* Base64ToBinary( + const char* pData, + uint32_t decodeSize, + uint32_t* pDataSize ); + +MP4V2_EXPORT +void MP4Free( + void* p ); + +MP4V2_EXPORT +void MP4SetLibFunc( + lib_message_func_t libfunc ); + +/** @} ***********************************************************************/ + +#endif /* MP4V2_GENERAL_H */ diff --git a/include/mp4v2/isma.h b/include/mp4v2/isma.h new file mode 100644 index 0000000..1764bec --- /dev/null +++ b/include/mp4v2/isma.h @@ -0,0 +1,98 @@ +#ifndef MP4V2_ISMA_H +#define MP4V2_ISMA_H + +/**************************************************************************//** + * + * @defgroup mp4_isma MP4v2 ISMA (Internet Streaming Media Alliance) + * @{ + * + *****************************************************************************/ + +/** something */ +typedef struct mp4v2_ismacryp_session_params { + uint32_t scheme_type; + uint16_t scheme_version; + uint8_t key_ind_len; + uint8_t iv_len; + uint8_t selective_enc; + const char* kms_uri; +} mp4v2_ismacrypParams; + +/* + * API to initialize ismacryp properties to sensible defaults + * if input param is null then mallocs a params struct + */ + +MP4V2_EXPORT +mp4v2_ismacrypParams* MP4DefaultISMACrypParams( mp4v2_ismacrypParams* ptr ); + +MP4V2_EXPORT +MP4TrackId MP4AddEncAudioTrack( + MP4FileHandle hFile, + uint32_t timeScale, + MP4Duration sampleDuration, + mp4v2_ismacrypParams* icPp, + uint8_t audioType DEFAULT(MP4_MPEG4_AUDIO_TYPE) ); + +MP4V2_EXPORT +MP4TrackId MP4AddEncVideoTrack( + MP4FileHandle hFile, + uint32_t timeScale, + MP4Duration sampleDuration, + uint16_t width, + uint16_t height, + mp4v2_ismacrypParams* icPp, + uint8_t videoType DEFAULT(MP4_MPEG4_VIDEO_TYPE), + const char* oFormat DEFAULT(NULL) ); + +MP4V2_EXPORT +MP4TrackId MP4AddEncH264VideoTrack( + MP4FileHandle dstFile, + uint32_t timeScale, + MP4Duration sampleDuration, + uint16_t width, + uint16_t height, + MP4FileHandle srcFile, + MP4TrackId srcTrackId, + mp4v2_ismacrypParams* icPp ); + +MP4V2_EXPORT +MP4TrackId MP4EncAndCloneTrack( + MP4FileHandle srcFile, + MP4TrackId srcTrackId, + mp4v2_ismacrypParams* icPp, + MP4FileHandle dstFile DEFAULT(MP4_INVALID_FILE_HANDLE), + MP4TrackId dstHintTrackReferenceTrack DEFAULT(MP4_INVALID_TRACK_ID) ); + +MP4V2_EXPORT +MP4TrackId MP4EncAndCopyTrack( + MP4FileHandle srcFile, + MP4TrackId srcTrackId, + mp4v2_ismacrypParams* icPp, + encryptFunc_t encfcnp, + uint32_t encfcnparam1, + MP4FileHandle dstFile DEFAULT(MP4_INVALID_FILE_HANDLE), + bool applyEdits DEFAULT(false), + MP4TrackId dstHintTrackReferenceTrack DEFAULT(MP4_INVALID_TRACK_ID) ); + +MP4V2_EXPORT +bool MP4MakeIsmaCompliant( + const char* fileName, + uint32_t verbosity DEFAULT(0), + bool addIsmaComplianceSdp DEFAULT(true) ); + +MP4V2_EXPORT +char* MP4MakeIsmaSdpIod( + uint8_t videoProfile, + uint32_t videoBitrate, + uint8_t* videoConfig, + uint32_t videoConfigLength, + uint8_t audioProfile, + uint32_t audioBitrate, + uint8_t* audioConfig, + uint32_t audioConfigLength, + uint32_t verbosity DEFAULT(0) ); + +/** @} ***********************************************************************/ + +#endif /* MP4V2_ISMA_H */ diff --git a/include/mp4v2/itmf_generic.h b/include/mp4v2/itmf_generic.h new file mode 100644 index 0000000..c72b2a3 --- /dev/null +++ b/include/mp4v2/itmf_generic.h @@ -0,0 +1,147 @@ +#ifndef MP4V2_ITMF_GENERIC_H +#define MP4V2_ITMF_GENERIC_H + +/**************************************************************************//** + * + * @defgroup mp4_itmf_generic MP4v2 iTMF (iTunes Metadata Format) Generic + * @{ + * + *****************************************************************************/ + +/** Basic types of value data as enumerated in spec. */ +typedef enum MP4ItmfBasicType_e +{ + MP4_ITMF_BT_IMPLICIT = 0, /**< for use with tags for which no type needs to be indicated */ + MP4_ITMF_BT_UTF8 = 1, /**< without any count or null terminator */ + MP4_ITMF_BT_UTF16 = 2, /**< also known as UTF-16BE */ + MP4_ITMF_BT_SJIS = 3, /**< deprecated unless it is needed for special Japanese characters */ + MP4_ITMF_BT_HTML = 6, /**< the HTML file header specifies which HTML version */ + MP4_ITMF_BT_XML = 7, /**< the XML header must identify the DTD or schemas */ + MP4_ITMF_BT_UUID = 8, /**< also known as GUID; stored as 16 bytes in binary (valid as an ID) */ + MP4_ITMF_BT_ISRC = 9, /**< stored as UTF-8 text (valid as an ID) */ + MP4_ITMF_BT_MI3P = 10, /**< stored as UTF-8 text (valid as an ID) */ + MP4_ITMF_BT_GIF = 12, /**< (deprecated) a GIF image */ + MP4_ITMF_BT_JPEG = 13, /**< a JPEG image */ + MP4_ITMF_BT_PNG = 14, /**< a PNG image */ + MP4_ITMF_BT_URL = 15, /**< absolute, in UTF-8 characters */ + MP4_ITMF_BT_DURATION = 16, /**< in milliseconds, 32-bit integer */ + MP4_ITMF_BT_DATETIME = 17, /**< in UTC, counting seconds since midnight, January 1, 1904; 32 or 64-bits */ + MP4_ITMF_BT_GENRES = 18, /**< a list of enumerated values */ + MP4_ITMF_BT_INTEGER = 21, /**< a signed big-endian integer with length one of { 1,2,3,4,8 } bytes */ + MP4_ITMF_BT_RIAA_PA = 24, /**< RIAA parental advisory; { -1=no, 1=yes, 0=unspecified }, 8-bit ingteger */ + MP4_ITMF_BT_UPC = 25, /**< Universal Product Code, in text UTF-8 format (valid as an ID) */ + MP4_ITMF_BT_BMP = 27, /**< Windows bitmap image */ + + MP4_ITMF_BT_UNDEFINED = 255 /**< undefined */ +} MP4ItmfBasicType; + +/** Data structure. + * Models an iTMF data atom contained in an iTMF metadata item atom. + */ +typedef struct MP4ItmfData_s +{ + uint8_t typeSetIdentifier; /**< always zero. */ + MP4ItmfBasicType typeCode; /**< iTMF basic type. */ + uint32_t locale; /**< always zero. */ + uint8_t* value; /**< may be NULL. */ + uint32_t valueSize; /**< value size in bytes. */ +} MP4ItmfData; + +/** List of data. */ +typedef struct MP4ItmfDataList_s +{ + MP4ItmfData* elements; /**< flat array. NULL when size is zero. */ + uint32_t size; /**< number of elements. */ +} MP4ItmfDataList; + +/** Item structure. + * Models an iTMF metadata item atom contained in an ilst atom. + */ +typedef struct MP4ItmfItem_s +{ + int32_t index; /**< 0-based index of item in ilst container. -1 if undefined. */ + char* code; /**< four-char code identifing atom type. NULL-terminated. */ + char* mean; /**< may be NULL. UTF-8 meaning. NULL-terminated. */ + char* name; /**< may be NULL. UTF-8 name. NULL-terminated. */ + MP4ItmfDataList dataList; /**< list of data. size is always >= 1. */ +} MP4ItmfItem; + +/** List of items. */ +typedef struct MP4ItmfItemList_s +{ + MP4ItmfItem* elements; /**< flat array. NULL when size is zero. */ + uint32_t size; /**< number of elements. */ +} MP4ItmfItemList; + +/** Allocate an item on the heap. + * @param code four-char code identifying atom type. NULL-terminated. + * @param numData number of data elements to allocate. Must be >= 1. + * @return newly allocated item. + */ +MP4V2_EXPORT MP4ItmfItem* +MP4ItmfItemAlloc( const char* code, uint32_t numData ); + +/** Free an item (deep free). + * @param item to be free'd. + */ +MP4V2_EXPORT void +MP4ItmfItemFree( MP4ItmfItem* item ); + +/** Free an item list (deep free). + * @param itemList to be free'd. + */ +MP4V2_EXPORT void +MP4ItmfItemListFree( MP4ItmfItemList* itemList ); + +/** Get list of all items from file. + * @param hFile handle of file to operate on. + * @return On succes, list of items, which must be free'd. On failure, NULL. + */ +MP4V2_EXPORT MP4ItmfItemList* +MP4ItmfGetItems( MP4FileHandle hFile ); + +/** Get list of items by code from file. + * @param hFile handle of file to operate on. + * @param code four-char code identifying atom type. NULL-terminated. + * @return On succes, list of items, which must be free'd. On failure, NULL. + */ +MP4V2_EXPORT MP4ItmfItemList* +MP4ItmfGetItemsByCode( MP4FileHandle hFile, const char* code ); + +/** Get list of items by meaning from file. + * Implicitly only returns atoms of code @b{----}. + * @param hFile handle of file to operate on. + * @param meaning UTF-8 meaning. NULL-terminated. + * @param name may be NULL. UTF-8 name. NULL-terminated. + * @return On succes, list of items, which must be free'd. On failure, NULL. + */ +MP4V2_EXPORT MP4ItmfItemList* +MP4ItmfGetItemsByMeaning( MP4FileHandle hFile, const char* meaning, const char* name ); + +/** Add an item to file. + * @param hFile handle of file to operate on. + * @param item object to add. + * @return <b>true</b> on success, <b>false</b> on failure. + */ +MP4V2_EXPORT bool +MP4ItmfAddItem( MP4FileHandle hFile, const MP4ItmfItem* item ); + +/** Overwrite an existing item in file. + * @param hFile handle of file to operate on. + * @param item object to overwrite. Must have a valid index obtained from prior get. + * @return <b>true</b> on success, <b>false</b> on failure. + */ +MP4V2_EXPORT bool +MP4ItmfSetItem( MP4FileHandle hFile, const MP4ItmfItem* item ); + +/** Remove an existing item from file. + * @param hFile handle of file to operate on. + * @param item object to remove. Must have a valid index obtained from prior get. + * @return <b>true</b> on success, <b>false</b> on failure. + */ +MP4V2_EXPORT bool +MP4ItmfRemoveItem( MP4FileHandle hFile, const MP4ItmfItem* item ); + +/** @} ***********************************************************************/ + +#endif /* MP4V2_ITMF_GENERIC_H */ diff --git a/include/mp4v2/itmf_tags.h b/include/mp4v2/itmf_tags.h new file mode 100644 index 0000000..9bc186c --- /dev/null +++ b/include/mp4v2/itmf_tags.h @@ -0,0 +1,219 @@ +#ifndef MP4V2_ITMF_TAGS_H +#define MP4V2_ITMF_TAGS_H + +/**************************************************************************//** + * + * @defgroup mp4_itmf_tags MP4v2 iTMF (iTunes Metadata Format) Tags + * @{ + * + *****************************************************************************/ + +/** Enumeration of possible MP4TagArtwork::type values. */ +typedef enum MP4TagArtworkType_e +{ + MP4_ART_UNDEFINED = 0, + MP4_ART_BMP = 1, + MP4_ART_GIF = 2, + MP4_ART_JPEG = 3, + MP4_ART_PNG = 4, +} MP4TagArtworkType; + +/** Data object representing a single piece of artwork. */ +typedef struct MP4TagArtwork_s +{ + const void* data; /**< raw picture data */ + uint32_t size; /**< data size in bytes */ + MP4TagArtworkType type; /**< data type */ +} MP4TagArtwork; + +typedef struct MP4TagTrack_s +{ + uint16_t index; + uint16_t total; +} MP4TagTrack; + +typedef struct MP4TagDisk_s +{ + uint16_t index; + uint16_t total; +} MP4TagDisk; + +/** Tags <b>convenience</b> structure. + * + * This structure is used in the tags convenience API which allows for + * simplified retrieval and modification of the majority of known tags. + * + * This is a read-only structure and each tag is present if and only if the + * pointer is a <b>non-NULL</b> value. The actual data is backed by a hidden + * data cache which is only updated when the appropriate metadata <b>set</b> + * function is used, or if MP4TagsFetch() is invoked. Thus, if other API + * is used to manipulate relevent atom structure of the MP4 file, the user + * is responsible for re-fetching the data in this structure. + */ +typedef struct MP4Tags_s +{ + void* __handle; /* internal use only */ + + const char* name; + const char* artist; + const char* albumArtist; + const char* album; + const char* grouping; + const char* composer; + const char* comments; + const char* genre; + const uint16_t* genreType; + const char* releaseDate; + const MP4TagTrack* track; + const MP4TagDisk* disk; + const uint16_t* tempo; + const uint8_t* compilation; + + const char* tvShow; + const char* tvNetwork; + const char* tvEpisodeID; + const uint32_t* tvSeason; + const uint32_t* tvEpisode; + + const char* description; + const char* longDescription; + const char* lyrics; + + const char* sortName; + const char* sortArtist; + const char* sortAlbumArtist; + const char* sortAlbum; + const char* sortComposer; + const char* sortTVShow; + + const MP4TagArtwork* artwork; + uint32_t artworkCount; + + const char* copyright; + const char* encodingTool; + const char* encodedBy; + const char* purchaseDate; + + const uint8_t* podcast; + const char* keywords; /* TODO: Needs testing */ + const char* category; + + const uint8_t* hdVideo; + const uint8_t* mediaType; + const uint8_t* contentRating; + const uint8_t* gapless; + + const char* iTunesAccount; + const uint8_t* iTunesAccountType; + const uint32_t* iTunesCountry; + const uint32_t* cnID; + const uint32_t* atID; + const uint64_t* plID; + const uint32_t* geID; +} MP4Tags; + +/** Allocate tags convenience structure for reading and settings tags. + * + * This function allocates a new structure which represents a snapshot + * of all the tags therein, tracking if the tag is missing, + * or present and with value. It is the caller's responsibility to free + * the structure with MP4TagsFree(). + * + * @return structure with all tags missing. + */ +MP4V2_EXPORT +const MP4Tags* MP4TagsAlloc(); + +/** Fetch data from mp4 file and populate structure. + * + * The tags structure and its hidden data-cache is updated to + * reflect the actual tags values found in the <b>hFile</b>. + * + * @param tags structure to fetch (write) into. + * @param hFile handle of file to fetch data from. + */ +MP4V2_EXPORT +void MP4TagsFetch( const MP4Tags* tags, MP4FileHandle hFile ); + +/** Store data to mp4 file from structure. + * + * The tags structure is pushed out to the mp4 file, + * adding tags if needed, removing tags if needed, and updating + * the values to modified tags. + * + * @param tags structure to store (read) from. + * @param hFile handle of file to store data to. + */ +MP4V2_EXPORT +void MP4TagsStore( const MP4Tags* tags, MP4FileHandle hFile ); + +/** Free tags convenience structure. + * + * This function frees memory associated with the structure. + * + * @param tags structure to destroy. + */ +MP4V2_EXPORT +void MP4TagsFree( const MP4Tags* tags ); + +MP4V2_EXPORT void MP4TagsSetName ( const MP4Tags*, const char* ); +MP4V2_EXPORT void MP4TagsSetArtist ( const MP4Tags*, const char* ); +MP4V2_EXPORT void MP4TagsSetAlbumArtist ( const MP4Tags*, const char* ); +MP4V2_EXPORT void MP4TagsSetAlbum ( const MP4Tags*, const char* ); +MP4V2_EXPORT void MP4TagsSetGrouping ( const MP4Tags*, const char* ); +MP4V2_EXPORT void MP4TagsSetComposer ( const MP4Tags*, const char* ); +MP4V2_EXPORT void MP4TagsSetComments ( const MP4Tags*, const char* ); +MP4V2_EXPORT void MP4TagsSetGenre ( const MP4Tags*, const char* ); +MP4V2_EXPORT void MP4TagsSetGenreType ( const MP4Tags*, const uint16_t* ); +MP4V2_EXPORT void MP4TagsSetReleaseDate ( const MP4Tags*, const char* ); +MP4V2_EXPORT void MP4TagsSetTrack ( const MP4Tags*, const MP4TagTrack* ); +MP4V2_EXPORT void MP4TagsSetDisk ( const MP4Tags*, const MP4TagDisk* ); +MP4V2_EXPORT void MP4TagsSetTempo ( const MP4Tags*, const uint16_t* ); +MP4V2_EXPORT void MP4TagsSetCompilation ( const MP4Tags*, const uint8_t* ); + +MP4V2_EXPORT void MP4TagsSetTVShow ( const MP4Tags*, const char* ); +MP4V2_EXPORT void MP4TagsSetTVNetwork ( const MP4Tags*, const char* ); +MP4V2_EXPORT void MP4TagsSetTVEpisodeID ( const MP4Tags*, const char* ); +MP4V2_EXPORT void MP4TagsSetTVSeason ( const MP4Tags*, const uint32_t* ); +MP4V2_EXPORT void MP4TagsSetTVEpisode ( const MP4Tags*, const uint32_t* ); + +MP4V2_EXPORT void MP4TagsSetDescription ( const MP4Tags*, const char* ); +MP4V2_EXPORT void MP4TagsSetLongDescription ( const MP4Tags*, const char* ); +MP4V2_EXPORT void MP4TagsSetLyrics ( const MP4Tags*, const char* ); + +MP4V2_EXPORT void MP4TagsSetSortName ( const MP4Tags*, const char* ); +MP4V2_EXPORT void MP4TagsSetSortArtist ( const MP4Tags*, const char* ); +MP4V2_EXPORT void MP4TagsSetSortAlbumArtist ( const MP4Tags*, const char* ); +MP4V2_EXPORT void MP4TagsSetSortAlbum ( const MP4Tags*, const char* ); +MP4V2_EXPORT void MP4TagsSetSortComposer ( const MP4Tags*, const char* ); +MP4V2_EXPORT void MP4TagsSetSortTVShow ( const MP4Tags*, const char* ); + +MP4V2_EXPORT void MP4TagsAddArtwork ( const MP4Tags*, MP4TagArtwork* ); +MP4V2_EXPORT void MP4TagsSetArtwork ( const MP4Tags*, uint32_t, MP4TagArtwork* ); +MP4V2_EXPORT void MP4TagsRemoveArtwork ( const MP4Tags*, uint32_t ); + +MP4V2_EXPORT void MP4TagsSetCopyright ( const MP4Tags*, const char* ); +MP4V2_EXPORT void MP4TagsSetEncodingTool ( const MP4Tags*, const char* ); +MP4V2_EXPORT void MP4TagsSetEncodedBy ( const MP4Tags*, const char* ); +MP4V2_EXPORT void MP4TagsSetPurchaseDate ( const MP4Tags*, const char* ); + +MP4V2_EXPORT void MP4TagsSetPodcast ( const MP4Tags*, const uint8_t* ); +MP4V2_EXPORT void MP4TagsSetKeywords ( const MP4Tags*, const char* ); +MP4V2_EXPORT void MP4TagsSetCategory ( const MP4Tags*, const char* ); + +MP4V2_EXPORT void MP4TagsSetHDVideo ( const MP4Tags*, const uint8_t* ); +MP4V2_EXPORT void MP4TagsSetMediaType ( const MP4Tags*, const uint8_t* ); +MP4V2_EXPORT void MP4TagsSetContentRating ( const MP4Tags*, const uint8_t* ); +MP4V2_EXPORT void MP4TagsSetGapless ( const MP4Tags*, const uint8_t* ); + +MP4V2_EXPORT void MP4TagsSetITunesAccount ( const MP4Tags*, const char* ); +MP4V2_EXPORT void MP4TagsSetITunesAccountType ( const MP4Tags*, const uint8_t* ); +MP4V2_EXPORT void MP4TagsSetITunesCountry ( const MP4Tags*, const uint32_t* ); +MP4V2_EXPORT void MP4TagsSetCNID ( const MP4Tags*, const uint32_t* ); +MP4V2_EXPORT void MP4TagsSetATID ( const MP4Tags*, const uint32_t* ); +MP4V2_EXPORT void MP4TagsSetPLID ( const MP4Tags*, const uint64_t* ); +MP4V2_EXPORT void MP4TagsSetGEID ( const MP4Tags*, const uint32_t* ); + +/** @} ***********************************************************************/ + +#endif /* MP4V2_ITMF_TAGS_H */ diff --git a/include/mp4v2/meta.h b/include/mp4v2/meta.h new file mode 100644 index 0000000..9d39c79 --- /dev/null +++ b/include/mp4v2/meta.h @@ -0,0 +1,489 @@ +#ifndef MP4V2_META_H +#define MP4V2_META_H + +/**************************************************************************//** + * + * @defgroup mp4_meta MP4v2 Metadata (deprecated) + * @{ + * + *****************************************************************************/ + +/** + * @deprecated Deprecated, scheduled for removal. Please use the iTMF generic API. + */ +MP4V2_EXPORT +bool MP4MetadataDelete( + MP4FileHandle hFile ); + +/** + * @deprecated Deprecated, scheduled for removal. Please use the iTMF generic API. + */ +MP4V2_EXPORT +bool MP4GetMetadataByIndex( + MP4FileHandle hFile, + uint32_t index, + char** ppName, /* need to free memory */ + uint8_t** ppValue, /* need to free */ + uint32_t* pValueSize ); + +/** + * @deprecated Deprecated, scheduled for removal. Please use the tags convenience API. + */ +MP4V2_DEPRECATED +MP4V2_EXPORT +bool MP4SetMetadataName( + MP4FileHandle hFile, + const char* value ); + +/** + * @deprecated Deprecated, scheduled for removal. Please use the tags convenience API. + */ +MP4V2_DEPRECATED +MP4V2_EXPORT +bool MP4GetMetadataName( + MP4FileHandle hFile, + char** value ); + +/** + * @deprecated Deprecated, scheduled for removal. Please use the tags convenience API. + */ +MP4V2_DEPRECATED +MP4V2_EXPORT +bool MP4DeleteMetadataName( + MP4FileHandle hFile ); + +/** + * @deprecated Deprecated, scheduled for removal. Please use the tags convenience API. + */ +MP4V2_DEPRECATED +MP4V2_EXPORT +bool MP4SetMetadataArtist( + MP4FileHandle hFile, + const char* value ); + +/** + * @deprecated Deprecated, scheduled for removal. Please use the tags convenience API. + */ +MP4V2_DEPRECATED +MP4V2_EXPORT +bool MP4GetMetadataArtist( + MP4FileHandle hFile, + char** value ); + +/** + * @deprecated Deprecated, scheduled for removal. Please use the tags convenience API. + */ +MP4V2_DEPRECATED +MP4V2_EXPORT +bool MP4DeleteMetadataArtist( + MP4FileHandle hFile ); + +/** + * @deprecated Deprecated, scheduled for removal. Please use the tags convenience API. + */ +MP4V2_DEPRECATED +MP4V2_EXPORT +bool MP4SetMetadataWriter( + MP4FileHandle hFile, + const char* value ); + +/** + * @deprecated Deprecated, scheduled for removal. Please use the tags convenience API. + */ +MP4V2_DEPRECATED +MP4V2_EXPORT +bool MP4GetMetadataWriter( + MP4FileHandle hFile, + char** value ); + +/** + * @deprecated Deprecated, scheduled for removal. Please use the tags convenience API. + */ +MP4V2_DEPRECATED +MP4V2_EXPORT +bool MP4DeleteMetadataWriter( + MP4FileHandle hFile ); + +/** + * @deprecated Deprecated, scheduled for removal. Please use the tags convenience API. + */ +MP4V2_DEPRECATED +MP4V2_EXPORT +bool MP4SetMetadataComment( + MP4FileHandle hFile, + const char* value ); + +/** + * @deprecated Deprecated, scheduled for removal. Please use the tags convenience API. + */ +MP4V2_DEPRECATED +MP4V2_EXPORT +bool MP4GetMetadataComment( + MP4FileHandle hFile, + char** value ); + +/** + * @deprecated Deprecated, scheduled for removal. Please use the tags convenience API. + */ +MP4V2_DEPRECATED +MP4V2_EXPORT +bool MP4DeleteMetadataComment( + MP4FileHandle hFile ); + +/** + * @deprecated Deprecated, scheduled for removal. Please use the tags convenience API. + */ +MP4V2_DEPRECATED +MP4V2_EXPORT +bool MP4SetMetadataTool( + MP4FileHandle hFile, + const char* value ); + +/** + * @deprecated Deprecated, scheduled for removal. Please use the tags convenience API. + */ +MP4V2_DEPRECATED +MP4V2_EXPORT +bool MP4GetMetadataTool( + MP4FileHandle hFile, + char** value ); + +/** + * @deprecated Deprecated, scheduled for removal. Please use the tags convenience API. + */ +MP4V2_DEPRECATED +MP4V2_EXPORT +bool MP4DeleteMetadataTool( + MP4FileHandle hFile ); + +/** + * @deprecated Deprecated, scheduled for removal. Please use the tags convenience API. + */ +MP4V2_DEPRECATED +MP4V2_EXPORT +bool MP4SetMetadataYear( + MP4FileHandle hFile, + const char* value ); + +/** + * @deprecated Deprecated, scheduled for removal. Please use the tags convenience API. + */ +MP4V2_DEPRECATED +MP4V2_EXPORT +bool MP4GetMetadataYear( + MP4FileHandle hFile, + char** value ); + +/** + * @deprecated Deprecated, scheduled for removal. Please use the tags convenience API. + */ +MP4V2_DEPRECATED +MP4V2_EXPORT +bool MP4DeleteMetadataYear( + MP4FileHandle hFile ); + +/** + * @deprecated Deprecated, scheduled for removal. Please use the tags convenience API. + */ +MP4V2_DEPRECATED +MP4V2_EXPORT +bool MP4SetMetadataAlbum( + MP4FileHandle hFile, + const char* value ); + +/** + * @deprecated Deprecated, scheduled for removal. Please use the tags convenience API. + */ +MP4V2_DEPRECATED +MP4V2_EXPORT +bool MP4GetMetadataAlbum( + MP4FileHandle hFile, + char** value ); + +/** + * @deprecated Deprecated, scheduled for removal. Please use the tags convenience API. + */ +MP4V2_DEPRECATED +MP4V2_EXPORT +bool MP4DeleteMetadataAlbum( + MP4FileHandle hFile ); + +/** + * @deprecated Deprecated, scheduled for removal. Please use the tags convenience API. + */ +MP4V2_EXPORT +bool MP4SetMetadataTrack( + MP4FileHandle hFile, + uint16_t track, + uint16_t totalTracks ); + +/** + * @deprecated Deprecated, scheduled for removal. Please use the tags convenience API. + */ +MP4V2_DEPRECATED +MP4V2_EXPORT +bool MP4GetMetadataTrack( + MP4FileHandle hFile, + uint16_t* track, + uint16_t* totalTracks ); + +/** + * @deprecated Deprecated, scheduled for removal. Please use the tags convenience API. + */ +MP4V2_EXPORT +bool MP4DeleteMetadataTrack( + MP4FileHandle hFile ); + +/** + * @deprecated Deprecated, scheduled for removal. Please use the tags convenience API. + */ +MP4V2_EXPORT +bool MP4SetMetadataDisk( + MP4FileHandle hFile, + uint16_t disk, + uint16_t totalDisks ); + +/** + * @deprecated Deprecated, scheduled for removal. Please use the tags convenience API. + */ +MP4V2_DEPRECATED +MP4V2_EXPORT +bool MP4GetMetadataDisk( + MP4FileHandle hFile, + uint16_t* disk, + uint16_t* totalDisks ); + +/** + * @deprecated Deprecated, scheduled for removal. Please use the tags convenience API. + */ +MP4V2_EXPORT +bool MP4DeleteMetadataDisk( + MP4FileHandle hFile ); + +/** + * @deprecated Deprecated, scheduled for removal. Please use the tags convenience API. + */ +MP4V2_DEPRECATED +MP4V2_EXPORT +bool MP4SetMetadataGenre( + MP4FileHandle hFile, + const char* genre ); + +/** + * @deprecated Deprecated, scheduled for removal. Please use the tags convenience API. + */ +MP4V2_DEPRECATED +MP4V2_EXPORT +bool MP4GetMetadataGenre( + MP4FileHandle hFile, + char** genre ); + +/** + * @deprecated Deprecated, scheduled for removal. Please use the tags convenience API. + */ +MP4V2_DEPRECATED +MP4V2_EXPORT +bool MP4DeleteMetadataGenre( + MP4FileHandle hFile ); + +/** + * @deprecated Deprecated, scheduled for removal. Please use the tags convenience API. + */ +MP4V2_DEPRECATED +MP4V2_EXPORT +bool MP4SetMetadataGrouping( + MP4FileHandle hFile, + const char* grouping ); + +/** + * @deprecated Deprecated, scheduled for removal. Please use the tags convenience API. + */ +MP4V2_DEPRECATED +MP4V2_EXPORT +bool MP4GetMetadataGrouping( + MP4FileHandle hFile, + char** grouping ); + +/** + * @deprecated Deprecated, scheduled for removal. Please use the tags convenience API. + */ +MP4V2_DEPRECATED +MP4V2_EXPORT +bool MP4DeleteMetadataGrouping( + MP4FileHandle hFile ); + +/** + * @deprecated Deprecated, scheduled for removal. Please use the tags convenience API. + */ +MP4V2_DEPRECATED +MP4V2_EXPORT +bool MP4SetMetadataTempo( + MP4FileHandle hFile, + uint16_t tempo ); + +/** + * @deprecated Deprecated, scheduled for removal. Please use the tags convenience API. + */ +MP4V2_DEPRECATED +MP4V2_EXPORT +bool MP4GetMetadataTempo( + MP4FileHandle hFile, + uint16_t* tempo ); + +/** + * @deprecated Deprecated, scheduled for removal. Please use the tags convenience API. + */ +MP4V2_DEPRECATED +MP4V2_EXPORT +bool MP4DeleteMetadataTempo( + MP4FileHandle hFile ); + +/** + * @deprecated Deprecated, scheduled for removal. Please use the tags convenience API. + */ +MP4V2_DEPRECATED +MP4V2_EXPORT +bool MP4SetMetadataCompilation( + MP4FileHandle hFile, + uint8_t cpl ); + +/** + * @deprecated Deprecated, scheduled for removal. Please use the tags convenience API. + */ +MP4V2_DEPRECATED +MP4V2_EXPORT +bool MP4GetMetadataCompilation( + MP4FileHandle hFile, + uint8_t* cpl ); + +/** + * @deprecated Deprecated, scheduled for removal. Please use the tags convenience API. + */ +MP4V2_DEPRECATED +MP4V2_EXPORT +bool MP4DeleteMetadataCompilation( + MP4FileHandle hFile ); + +/** + * @deprecated Deprecated, scheduled for removal. Please use the tags convenience API. + */ +MP4V2_DEPRECATED +MP4V2_EXPORT +bool MP4SetMetadataPartOfGaplessAlbum( + MP4FileHandle hFile, + uint8_t pgap ); + +/** + * @deprecated Deprecated, scheduled for removal. Please use the tags convenience API. + */ +MP4V2_DEPRECATED +MP4V2_EXPORT +bool MP4GetMetadataPartOfGaplessAlbum( + MP4FileHandle hFile, + uint8_t* pgap ); + +/** + * @deprecated Deprecated, scheduled for removal. Please use the tags convenience API. + */ +MP4V2_DEPRECATED +MP4V2_EXPORT +bool MP4DeleteMetadataPartOfGaplessAlbum( + MP4FileHandle hFile ); + +/** + * @deprecated Deprecated, scheduled for removal. Please use the tags convenience API. + */ +MP4V2_DEPRECATED +MP4V2_EXPORT +bool MP4SetMetadataCoverArt( + MP4FileHandle hFile, + uint8_t* coverArt, + uint32_t size ); + +/** + * @deprecated Deprecated, scheduled for removal. Please use the tags convenience API. + */ +MP4V2_DEPRECATED +MP4V2_EXPORT +bool MP4GetMetadataCoverArt( + MP4FileHandle hFile, + uint8_t** coverArt, + uint32_t* size, + uint32_t index DEFAULT(0) ); + +/** + * @deprecated Deprecated, scheduled for removal. Please use the tags convenience API. + */ +MP4V2_DEPRECATED +MP4V2_EXPORT +uint32_t MP4GetMetadataCoverArtCount( + MP4FileHandle hFile ); + +/** + * @deprecated Deprecated, scheduled for removal. Please use the tags convenience API. + */ +MP4V2_DEPRECATED +MP4V2_EXPORT +bool MP4DeleteMetadataCoverArt( + MP4FileHandle hFile ); + +/** + * @deprecated Deprecated, scheduled for removal. Please use the tags convenience API. + */ +MP4V2_DEPRECATED +MP4V2_EXPORT +bool MP4SetMetadataAlbumArtist( + MP4FileHandle hFile, + const char* value ); + +/** + * @deprecated Deprecated, scheduled for removal. Please use the tags convenience API. + */ +MP4V2_DEPRECATED +MP4V2_EXPORT +bool MP4GetMetadataAlbumArtist( + MP4FileHandle hFile, + char** value ); + +/** + * @deprecated Deprecated, scheduled for removal. Please use the tags convenience API. + */ +MP4V2_DEPRECATED +MP4V2_EXPORT +bool MP4DeleteMetadataAlbumArtist( + MP4FileHandle hFile ); + +/** + * @deprecated Deprecated, scheduled for removal. Please use the iTMF generic API. + */ +MP4V2_EXPORT +bool MP4SetMetadataFreeForm( + MP4FileHandle hFile, + const char* name, + const uint8_t* pValue, + uint32_t valueSize, + const char* owner DEFAULT(NULL) ); + +/** + * @deprecated Deprecated, scheduled for removal. Please use the iTMF generic API. + */ +MP4V2_EXPORT +bool MP4GetMetadataFreeForm( + MP4FileHandle hFile, + const char* name, + uint8_t** pValue, + uint32_t* valueSize, + const char* owner DEFAULT(NULL) ); + +/** + * @deprecated Deprecated, scheduled for removal. Please use the iTMF generic API. + */ +MP4V2_EXPORT +bool MP4DeleteMetadataFreeForm( + MP4FileHandle hFile, + const char* name, + const char* owner DEFAULT(NULL) ); + +/** @} ***********************************************************************/ + +#endif /* MP4V2_META_H */ diff --git a/include/mp4v2/mp4v2.h b/include/mp4v2/mp4v2.h new file mode 100644 index 0000000..f934a0f --- /dev/null +++ b/include/mp4v2/mp4v2.h @@ -0,0 +1,84 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001 - 2005. All Rights Reserved. + * + * 3GPP features implementation is based on 3GPP's TS26.234-v5.60, + * and was contributed by Ximpo Group Ltd. + * + * Portions created by Ximpo Group Ltd. are + * Copyright (C) Ximpo Group Ltd. 2003, 2004. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + * Alix Marchandise-Franquet alix@cisco.com + * Ximpo Group Ltd. mp4v2@ximpo.com + * Bill May wmay@cisco.com + */ +#ifndef MP4V2_MP4V2_H +#define MP4V2_MP4V2_H + +/*****************************************************************************/ + +#include <mp4v2/platform.h> +#include <mp4v2/project.h> + +/*****************************************************************************/ + +/* exploit C++ ability of default values for function parameters */ +#if defined( DEFAULT ) +# define __MP4V2_SAVE_DEFAULT DEFAULT +#endif +#undef DEFAULT +#if defined( __cplusplus ) +# define DEFAULT(x) =x +#else +# define DEFAULT(x) +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/*****************************************************************************/ + +#include <mp4v2/general.h> +#include <mp4v2/file.h> +#include <mp4v2/file_prop.h> +#include <mp4v2/track.h> +#include <mp4v2/track_prop.h> +#include <mp4v2/sample.h> +#include <mp4v2/chapter.h> +#include <mp4v2/itmf_generic.h> +#include <mp4v2/itmf_tags.h> +#include <mp4v2/meta.h> +#include <mp4v2/streaming.h> +#include <mp4v2/isma.h> + +/*****************************************************************************/ + +/* restore macro DEFAULT to state prior to mp4v2 headers */ +#undef DEFAULT +#if defined( __MP4V2_SAVE_DEFAULT ) +# define DEFAULT __MP4V2_SAVE_DEFAULT +#endif + +#ifdef __cplusplus +} // extern "C" +#endif + +/*****************************************************************************/ + +#endif /* MP4V2_MP4V2_H */ diff --git a/include/mp4v2/platform.h b/include/mp4v2/platform.h new file mode 100644 index 0000000..bc9413a --- /dev/null +++ b/include/mp4v2/platform.h @@ -0,0 +1,98 @@ +#ifndef MP4V2_PLATFORM_H +#define MP4V2_PLATFORM_H + +/*****************************************************************************/ + +#include <stddef.h> +#include <stdio.h> +#include <stdarg.h> + +#if defined( _WIN32 ) && !defined( __MINGW32__ ) + typedef char int8_t; + typedef short int16_t; + typedef int int32_t; + typedef long long int64_t; + + typedef unsigned char uint8_t; + typedef unsigned short uint16_t; + typedef unsigned int uint32_t; + typedef unsigned long long uint64_t; +#else +# include <stdint.h> +#endif + +#if defined( _WIN32 ) || defined( __MINGW32__ ) +# if defined( _WINDLL ) || defined( DLL_EXPORT ) +# define MP4V2_EXPORT __declspec(dllexport) +# elif defined( _DLL ) || defined( DLL_IMPORT ) +# define MP4V2_EXPORT __declspec(dllimport) +# else +# define MP4V2_EXPORT +# endif +#else +# define MP4V2_EXPORT __attribute__((visibility("default"))) +#endif + +// Music Manager custom change +// We're using the DLL CRT, which sets _WINDLL, but not compiling this library as a DLL. +#if defined ( _WIN32 ) && defined ( MP4V2_EXPORT ) +#undef MP4V2_EXPORT +#define MP4V2_EXPORT +#endif +// End Music Manager custom change + +#if defined( __GNUC__ ) +# define MP4V2_DEPRECATED __attribute__((deprecated)) +#else +# define MP4V2_DEPRECATED +#endif + +/****************************************************************************** + * + * TODO-KB: cleanup -- absolutely no need for a C-API to fuss with reserved + * C++ keywords. This will involve changing the public interface and current + * plan of action: + * + * typdef enum { + * mp4_false, + * mp4_true, + * } mp4_bool_t; + * + * followed by updating all public signatures and implementation. + */ + +#ifndef FALSE +#define FALSE 0 +#endif + +#ifndef TRUE +#define TRUE 1 +#endif + +#if !defined( __cplusplus ) +#ifndef bool +#if SIZEOF_BOOL == 8 +typedef uint64_t bool; +#else +#if SIZEOF_BOOL == 4 +typedef uint32_t bool; +#else +#if SIZEOF_BOOL == 2 +typedef uint16_t bool; +#else +typedef unsigned char bool; +#endif +#endif +#endif +#ifndef false +#define false FALSE +#endif +#ifndef true +#define true TRUE +#endif +#endif +#endif + +/*****************************************************************************/ + +#endif /* MP4V2_PLATFORM_H */ diff --git a/include/mp4v2/project.h b/include/mp4v2/project.h new file mode 100644 index 0000000..b69b0b8 --- /dev/null +++ b/include/mp4v2/project.h @@ -0,0 +1,30 @@ +#ifndef MP4V2_PROJECT_H +#define MP4V2_PROJECT_H + +/*****************************************************************************/ + +#define MP4V2_PROJECT_name "MP4v2" +#define MP4V2_PROJECT_name_lower "mp4v2" +#define MP4V2_PROJECT_name_upper "MP4V2" +#define MP4V2_PROJECT_name_formal "MP4v2 1.9.1" +#define MP4V2_PROJECT_url_website "http://code.google.com/p/mp4v2" +#define MP4V2_PROJECT_url_downloads "http://code.google.com/p/mp4v2/downloads/list" +#define MP4V2_PROJECT_url_discussion "http://groups.google.com/group/mp4v2" +#define MP4V2_PROJECT_irc "irc://irc.freenode.net/mp4v2" +#define MP4V2_PROJECT_bugreport "<eddyg@myreflection.org>" +#define MP4V2_PROJECT_version "1.9.1" +#define MP4V2_PROJECT_version_hex 0x00010901 +#define MP4V2_PROJECT_version_major 1 +#define MP4V2_PROJECT_version_minor 9 +#define MP4V2_PROJECT_version_point 1 +#define MP4V2_PROJECT_repo_url "https://mp4v2.googlecode.com/svn/releases/1.9.1" +#define MP4V2_PROJECT_repo_root "https://mp4v2.googlecode.com/svn" +#define MP4V2_PROJECT_repo_uuid "6e6572fa-98a6-11dd-ad9f-f77439c74b79" +#define MP4V2_PROJECT_repo_rev 368 +#define MP4V2_PROJECT_repo_date "2009-07-14 11:25:03 +1200 (Tue, 14 Jul 2009)" +#define MP4V2_PROJECT_repo_type "stable" +#define MP4V2_PROJECT_build "Wed May 19 14:32:21 PDT 2010" + +/*****************************************************************************/ + +#endif /* MP4V2_PROJECT_H */ diff --git a/include/mp4v2/project.h.in b/include/mp4v2/project.h.in new file mode 100644 index 0000000..2baced9 --- /dev/null +++ b/include/mp4v2/project.h.in @@ -0,0 +1,30 @@ +#ifndef MP4V2_PROJECT_H +#define MP4V2_PROJECT_H + +/*****************************************************************************/ + +#define MP4V2_PROJECT_name "@PROJECT_name@" +#define MP4V2_PROJECT_name_lower "@PROJECT_name_lower@" +#define MP4V2_PROJECT_name_upper "@PROJECT_name_upper@" +#define MP4V2_PROJECT_name_formal "@PROJECT_name_formal@" +#define MP4V2_PROJECT_url_website "@PROJECT_url_website@" +#define MP4V2_PROJECT_url_downloads "@PROJECT_url_downloads@" +#define MP4V2_PROJECT_url_discussion "@PROJECT_url_discussion@" +#define MP4V2_PROJECT_irc "@PROJECT_irc@" +#define MP4V2_PROJECT_bugreport "@PROJECT_bugreport@" +#define MP4V2_PROJECT_version "@PROJECT_version@" +#define MP4V2_PROJECT_version_hex @PROJECT_version_hex@ +#define MP4V2_PROJECT_version_major @PROJECT_version_major@ +#define MP4V2_PROJECT_version_minor @PROJECT_version_minor@ +#define MP4V2_PROJECT_version_point @PROJECT_version_point@ +#define MP4V2_PROJECT_repo_url "@PROJECT_repo_url@" +#define MP4V2_PROJECT_repo_root "@PROJECT_repo_root@" +#define MP4V2_PROJECT_repo_uuid "@PROJECT_repo_uuid@" +#define MP4V2_PROJECT_repo_rev @PROJECT_repo_rev@ +#define MP4V2_PROJECT_repo_date "@PROJECT_repo_date@" +#define MP4V2_PROJECT_repo_type "@PROJECT_repo_type@" +#define MP4V2_PROJECT_build "@PROJECT_build@" + +/*****************************************************************************/ + +#endif /* MP4V2_PROJECT_H */ diff --git a/include/mp4v2/sample.h b/include/mp4v2/sample.h new file mode 100644 index 0000000..5ee589a --- /dev/null +++ b/include/mp4v2/sample.h @@ -0,0 +1,557 @@ +#ifndef MP4V2_SAMPLE_H +#define MP4V2_SAMPLE_H + +/**************************************************************************//** + * + * @defgroup mp4_sample MP4v2 Sample + * @{ + * + *****************************************************************************/ + +/** Sample dependency types. + * + * Bit combinations 0x03, 0x30, 0xc0 are reserved. + */ +typedef enum MP4SampleDependencyType_e { + MP4_SDT_UNKNOWN = 0x00, /**< unknown */ + MP4_SDT_HAS_REDUNDANT_CODING = 0x01, /**< contains redundant coding */ + MP4_SDT_HAS_NO_REDUNDANT_CODING = 0x02, /**< does not contain redundant coding */ + MP4_SDT_HAS_DEPENDENTS = 0x04, /**< referenced by other samples */ + MP4_SDT_HAS_NO_DEPENDENTS = 0x08, /**< not referenced by other samples */ + MP4_SDT_IS_DEPENDENT = 0x10, /**< references other samples */ + MP4_SDT_IS_INDEPENDENT = 0x20, /**< does not reference other samples */ + MP4_SDT_EARLIER_DISPLAY_TIMES_ALLOWED = 0x40, /**< subequent samples in GOP may display earlier */ + _MP4_SDT_RESERVED = 0x80, /**< reserved */ +} MP4SampleDependencyType; + +/** Read a track sample. + * + * MP4ReadSample reads the specified sample from the specified track. + * Typically this sample is then decoded in a codec dependent fashion and + * rendered in an appropriate fashion. + * + * The argument <b>ppBytes</b> allows for two possible approaches for + * buffering: + * + * If the calling application wishes to handle its own buffering it can set + * *ppBytes to the buffer it wishes to use. The calling application is + * responsible for ensuring that the buffer is large enough to hold the + * sample. This can be done by using either MP4GetSampleSize() or + * MP4GetTrackMaxSampleSize() to determine before−hand how large the + * receiving buffer must be. + * + * If the value of *ppBytes is NULL, then an appropriately sized buffer is + * automatically malloc’ed for the sample data and *ppBytes set to this + * pointer. The calling application is responsible for free’ing this + * memory. + * + * The last four arguments are pointers to variables that can receive + * optional sample information. + * + * Typically for audio none of these are needed. MPEG audio such as MP3 or + * AAC has a fixed sample duration and every sample can be accessed at + * random. + * + * For video, all of these optional values could be needed. MPEG video can + * be encoded at a variable frame rate, with only occasional random access + * points, and with "B frames" which cause the rendering (display) order + * of the video frames to differ from the storage/decoding order. + * + * Other media types fall between these two extremes. + * + * @param hFile handle of file for operation. + * @param trackId id of track for operation. + * @param sampleId specifies which sample is to be read. + * Caveat: the first sample has id <b>1</b> not <b>0</b>. + * @param ppBytes pointer to the pointer to the sample data. + * @param pNumBytes pointer to variable that will be hold the size in bytes + * of the sample. + * @param pStartTime if non−NULL, pointer to variable that will receive the + * starting timestamp for this sample. Caveat: The timestamp is in + * <b>trackId</b>'s timescale. + * @param pDuration if non−NULL, pointer to variable that will receive the + * duration for this sample. Caveat: The duration is in + * <b>trackId</b>'s timescale. + * @param pRenderingOffset if non−NULL, pointer to variable that will + * receive the rendering offset for this sample. Currently the only + * media type that needs this feature is MPEG video. Caveat: The offset + * is in <b>trackId</b>'s timescale. + * @param pIsSyncSample if non−NULL, pointer to variable that will receive + * the state of the sync/random access flag for this sample. + * + * @return <b>true</b> on success, <b>false</b> on failure. + * + * @see MP4GetSampleSize(). + * @see MP4GetTrackMaxSampleSize(). + */ +MP4V2_EXPORT +bool MP4ReadSample( + /* input parameters */ + MP4FileHandle hFile, + MP4TrackId trackId, + MP4SampleId sampleId, + /* input/output parameters */ + uint8_t** ppBytes, + uint32_t* pNumBytes, + /* output parameters */ + MP4Timestamp* pStartTime DEFAULT(NULL), + MP4Duration* pDuration DEFAULT(NULL), + MP4Duration* pRenderingOffset DEFAULT(NULL), + bool* pIsSyncSample DEFAULT(NULL) ); + +/** Read a track sample based on a specified time. + * + * MP4ReadSampleFromTime is similar to MP4ReadSample() except the sample + * is specified by using a timestamp instead of sampleId. + * Typically this sample is then decoded in a codec dependent fashion and + * rendered in an appropriate fashion. + * + * The argument <b>ppBytes</b> allows for two possible approaches for + * buffering: + * + * If the calling application wishes to handle its own buffering it can set + * *ppBytes to the buffer it wishes to use. The calling application is + * responsible for ensuring that the buffer is large enough to hold the + * sample. This can be done by using either MP4GetSampleSize() or + * MP4GetTrackMaxSampleSize() to determine before−hand how large the + * receiving buffer must be. + * + * If the value of *ppBytes is NULL, then an appropriately sized buffer is + * automatically malloc’ed for the sample data and *ppBytes set to this + * pointer. The calling application is responsible for free’ing this + * memory. + * + * The last four arguments are pointers to variables that can receive + * optional sample information. + * + * Typically for audio none of these are needed. MPEG audio such as MP3 or + * AAC has a fixed sample duration and every sample can be accessed at + * random. + * + * For video, all of these optional values could be needed. MPEG video can + * be encoded at a variable frame rate, with only occasional random access + * points, and with "B frames" which cause the rendering (display) order + * of the video frames to differ from the storage/decoding order. + * + * Other media types fall between these two extremes. + * + * @param hFile handle of file for operation. + * @param trackId id of track for operation. + * @param when specifies which sample is to be read based on a time in the + * track timeline. See MP4GetSampleIdFromTime() for details. + * @param ppBytes pointer to the pointer to the sample data. + * @param pNumBytes pointer to variable that will be hold the size in bytes + * of the sample. + * @param pStartTime if non−NULL, pointer to variable that will receive the + * starting timestamp for this sample. Caveat: The timestamp is in + * <b>trackId</b>'s timescale. + * @param pDuration if non−NULL, pointer to variable that will receive the + * duration for this sample. Caveat: The duration is in + * <b>trackId</b>'s timescale. + * @param pRenderingOffset if non−NULL, pointer to variable that will + * receive the rendering offset for this sample. Currently the only + * media type that needs this feature is MPEG video. Caveat: The offset + * is in <b>trackId</b>'s timescale. + * @param pIsSyncSample if non−NULL, pointer to variable that will receive + * the state of the sync/random access flag for this sample. + * + * @return <b>true</b> on success, <b>false</b> on failure. + * + * @see MP4ReadSample(). + * @see MP4GetSampleIdFromTime(). + * @see MP4GetSampleSize(). + * @see MP4GetTrackMaxSampleSize(). + */ +MP4V2_EXPORT +bool MP4ReadSampleFromTime( + /* input parameters */ + MP4FileHandle hFile, + MP4TrackId trackId, + MP4Timestamp when, + /* input/output parameters */ + uint8_t** ppBytes, + uint32_t* pNumBytes, + /* output parameters */ + MP4Timestamp* pStartTime DEFAULT(NULL), + MP4Duration* pDuration DEFAULT(NULL), + MP4Duration* pRenderingOffset DEFAULT(NULL), + bool* pIsSyncSample DEFAULT(NULL) ); + +/** Write a track sample. + * + * MP4WriteSample writes the given sample at the end of the specified track. + * Currently the library does not support random insertion of samples into + * the track timeline. Note that with mp4 there cannot be any holes or + * overlapping samples in the track timeline. The last three arguments give + * optional sample information. + * + * The value of duration can be given as #MP4_INVALID_DURATION if all samples + * in the track have the same duration. This can be specified with + * MP4AddTrack() and related functions. + * + * Typically for audio none of the optional arguments are needed. MPEG audio + * such as MP3 or AAC has a fixed sample duration and every sample can be + * accessed at random. + * + * For video, all of the optional arguments could be needed. MPEG video + * can be encoded at a variable frame rate, with only occasional random + * access points, and with "B frames" which cause the rendering (display) + * order of the video frames to differ from the storage/decoding order. + * + * Other media types fall between these two extremes. + * + * @param hFile handle of file for operation. + * @param trackId id of track for operation. + * @param pBytes pointer to sample data. + * @param numBytes length of sample data in bytes. + * @param duration sample duration. Caveat: should be in track timescale. + * @param renderingOffset the rendering offset for this sample. + * Currently the only media type that needs this feature is MPEG + * video. Caveat: The offset should be in the track timescale. + * @param isSyncSample the sync/random access flag for this sample. + * + * @return <b>true</b> on success, <b>false</b> on failure. + * + * @see MP4AddTrack(). + */ +MP4V2_EXPORT +bool MP4WriteSample( + MP4FileHandle hFile, + MP4TrackId trackId, + const uint8_t* pBytes, + uint32_t numBytes, + MP4Duration duration DEFAULT(MP4_INVALID_DURATION), + MP4Duration renderingOffset DEFAULT(0), + bool isSyncSample DEFAULT(true) ); + +/** Write a track sample and supply dependency information. + * + * MP4WriteSampleDependency writes the given sample at the end of the specified track. + * Currently the library does not support random insertion of samples into + * the track timeline. Note that with mp4 there cannot be any holes or + * overlapping samples in the track timeline. The last three arguments give + * optional sample information. + * + * The value of duration can be given as #MP4_INVALID_DURATION if all samples + * in the track have the same duration. This can be specified with + * MP4AddTrack() and related functions. + * + * When this method is used instead of MP4WriteSample() it enables <b>sdtp</b> + * atom to be written out. This atom may be used by advanced players to + * optimize trick-operations such as fast-fwd, reverse or scrubbing. + * + * An <b>sdtp</b> atom will always be written out if this method is used. + * To avoid writing the atom, use MP4WriteSample() instead. + * + * Intermixing use of MP4WriteSampleDependency() and MP4WriteSample() on the + * same track is not permitted. + * + * @param hFile handle of file for operation. + * @param trackId id of track for operation. + * @param pBytes pointer to sample data. + * @param numBytes length of sample data in bytes. + * @param duration sample duration. Caveat: should be in track timescale. + * @param renderingOffset the rendering offset for this sample. + * Currently the only media type that needs this feature is MPEG + * video. Caveat: The offset should be in the track timescale. + * @param isSyncSample the sync/random access flag for this sample. + * @param dependencyFlags bitmask specifying sample dependency characteristics. + * See #MP4SampleDependencyType for bit constants. + * + * @return <b>true</b> on success, <b>false</b> on failure. + * + * @see MP4AddTrack(). + */ +MP4V2_EXPORT +bool MP4WriteSampleDependency( + MP4FileHandle hFile, + MP4TrackId trackId, + const uint8_t* pBytes, + uint32_t numBytes, + MP4Duration duration, + MP4Duration renderingOffset, + bool isSyncSample, + uint32_t dependencyFlags ); + +/** Make a copy of a sample. + * + * MP4CopySample creates a new sample based on an existing sample. Note that + * another copy of the media sample data is created in the file using this + * function. ie. this call is equivalent to MP4ReadSample() followed by + * MP4WriteSample(). + * + * Note that is the responsibility of the caller to ensure that the copied + * media sample makes sense in the destination track. eg. copying a video + * sample to an audio track is unlikely to result in anything good happening, + * even copying a sample from video track to another requires that the tracks + * use the same encoding and that issues such as image size are addressed. + * + * @param srcFile source sample file handle. + * @param srcTrackId source sample track id. + * @param srcSampleId source sample id. + * @param dstFile destination file handle for new (copied) sample. + * If the value is #MP4_INVALID_FILE_HANDLE, the copy is created in + * the same file as <b>srcFile</b>. + * @param dstTrackId destination track id for new sample. + * If the value is #MP4_INVALID_TRACK_ID, the the copy is created in + * the same track as the <b>srcTrackId</b>. + * @param dstSampleDuration duration in track timescale for new sample. + * If the value is #MP4_INVALID_DURATION, then the duration of + * the source sample is used. + * + * @return On success, thew id of the new sample. + * On error, #MP4_INVALID_SAMPLE_ID. + * + * @see MP4ReadSample(). + * @see MP4WriteSample(). + */ +MP4V2_EXPORT +bool MP4CopySample( + MP4FileHandle srcFile, + MP4TrackId srcTrackId, + MP4SampleId srcSampleId, + MP4FileHandle dstFile DEFAULT(MP4_INVALID_FILE_HANDLE), + MP4TrackId dstTrackId DEFAULT(MP4_INVALID_TRACK_ID), + MP4Duration dstSampleDuration DEFAULT(MP4_INVALID_DURATION) ); + +/** Make a copy of a sample. + * + * MP4EncAndCopySample is similar to MP4CopySample() except that it + * offers an encryption hook to the caller. + * + * @param srcFile source sample file handle. + * @param srcTrackId source sample track id. + * @param srcSampleId source sample id. + * @param encfcnp undocumented. + * @param encfcnparam1 undocumented. + * @param dstFile destination file handle for new (copied) sample. + * If the value is #MP4_INVALID_FILE_HANDLE, the copy is created in + * the same file as <b>srcFile</b>. + * @param dstTrackId destination track id for new sample. + * If the value is #MP4_INVALID_TRACK_ID, the the copy is created in + * the same track as the <b>srcTrackId</b>. + * @param dstSampleDuration duration in track timescale for new sample. + * If the value is #MP4_INVALID_DURATION, then the duration of + * the source sample is used. + * + * @return On success, thew id of the new sample. + * On error, #MP4_INVALID_SAMPLE_ID. + * + * @see MP4CopySample(). + */ +MP4V2_EXPORT +bool MP4EncAndCopySample( + MP4FileHandle srcFile, + MP4TrackId srcTrackId, + MP4SampleId srcSampleId, + encryptFunc_t encfcnp, + uint32_t encfcnparam1, + MP4FileHandle dstFile DEFAULT(MP4_INVALID_FILE_HANDLE), + MP4TrackId dstTrackId DEFAULT(MP4_INVALID_TRACK_ID), + MP4Duration dstSampleDuration DEFAULT(MP4_INVALID_DURATION) ); + +/** Not implemented. + */ +MP4V2_EXPORT +bool MP4ReferenceSample( + MP4FileHandle srcFile, + MP4TrackId srcTrackId, + MP4SampleId srcSampleId, + MP4FileHandle dstFile, + MP4TrackId dstTrackId, + MP4Duration dstSampleDuration DEFAULT(MP4_INVALID_DURATION) ); + +/** Get size of a track sample. + * + * MP4GetSampleSize returns the size in bytes of the specified sample from the + * the specified track. + * + * @param hFile handle of file for operation. + * @param trackId id of track for operation. + * @param sampleId id of sample for operation. Caveat: the first sample has + * id <b>1</b>, not <b>0</b>. + * + * @return On success the sample size in bytes. On error, <b>0</b>. + */ +MP4V2_EXPORT +uint32_t MP4GetSampleSize( + MP4FileHandle hFile, + MP4TrackId trackId, + MP4SampleId sampleId); + +/** Get the maximum sample size of a track. + * + * MP4GetTrackMaxSampleSize returns the maximum size in bytes of all the + * samples in the specified track. + * + * @param hFile handle of file for operation. + * @param trackId id of track for operation. + * + * @return On success, the maximum sample size in bytes. On error, <b>0</b>. + * + * @see MP4GetSampleSize(). + */ +MP4V2_EXPORT +uint32_t MP4GetTrackMaxSampleSize( + MP4FileHandle hFile, + MP4TrackId trackId ); + +/** Get sample id of a specified time. + * + * MP4GetSampleIdFromTime returns the sample id of the track sample in which + * the specified time occurs. + * + * The specified time should be in the track timescale. + * + * It is wise to use MP4GetSampleTime() with the returned sample id so one + * can adjust for any difference between the specified time and the actual + * start time of the sample. + * + * If the calling application needs a sample that can be accessed randomly + * then the <b>wantSyncSample</b> argument should be set to true. This could + * be the case for a player that is implementing a positioning function and + * needs to be able to start decoding a track from the returned sample id. + * + * @param hFile handle of file for operation. + * @param trackId id of track for operation. + * @param when time in track timescale. + * @param wantSyncSample specifies if the result sample id must correspond + * to a sample whose sync/random access flag is true. + * + * @return On success, the sample id that occurs at the specified time. + * On error, #MP4_INVALID_SAMPLE_ID. + * + * @see MP4ConvertToTrackTimestamp() for how to map a time value to this + * timescale. + */ +MP4V2_EXPORT +MP4SampleId MP4GetSampleIdFromTime( + MP4FileHandle hFile, + MP4TrackId trackId, + MP4Timestamp when, + bool wantSyncSample DEFAULT(false) ); + +/** Get start time of track sample. + * + * MP4GetSampleTime returns the start time of the specified sample from + * the specified track in the track timescale units. + * + * @param hFile handle of file for operation. + * @param trackId id of track for operation. + * @param sampleId id of sample for operation. Caveat: the first sample has + * id <b>1</b>, not <b>0</b>. + * + * @return On success, sample start time in track timescale units. + * On error, #MP4_INVALID_TIMESTAMP. + * + * @see MP4ConvertFromTrackTimestamp() for how to map this value to another + * timescale. + */ +MP4V2_EXPORT +MP4Timestamp MP4GetSampleTime( + MP4FileHandle hFile, + MP4TrackId trackId, + MP4SampleId sampleId ); + +/** Get the duration of a track sample. + * + * MP4GetSampleDuration returns the duration of the specified sample from + * the specified track in the track timescale units. + * + * @param hFile handle of file for operation. + * @param trackId id of track for operation. + * @param sampleId id of sample for operation. Caveat: the first sample has + * id <b>1</b>, not <b>0</b>. + * + * @return On success, the sample duration in track timescale units. + * On error, #MP4_INVALID_DURATION. + * + * @see MP4ConvertFromTrackDuration() for how to map this value to another + * timescale. + */ +MP4V2_EXPORT +MP4Duration MP4GetSampleDuration( + MP4FileHandle hFile, + MP4TrackId trackId, + MP4SampleId sampleId ); + +/** Get the rendering offset of a track sample. + * + * MP4GetSampleRenderingOffset returns the rendering offset of the specified + * sample from the specified track in the track timescale units. + * + * The sample rendering offset is typically zero for all media types other + * than video. For video, encodings such as those defined by MPEG have + * three types of frames: I, P, and B. To increase coding efficiency B + * frames can depend on I or P frames that should be rendered after the B + * frame. However to decode the B frame the I or P frame must already have + * been decoded. This situation is addressed by placing the frames in + * decoding order in the video track, and then setting the rendering offset + * property to indicate when the video frame should actually be rendered to + * the screen. Hence the start time of a sample indicates when it should be + * decoded, the start time plus the rendering offset indicates when it + * should be rendered. + * + * @param hFile handle of file for operation. + * @param trackId id of track for operation. + * @param sampleId id of sample for operation. Caveat: the first sample has + * id <b>1</b>, not <b>0</b>. + * + * @return On success, the rendering offset in track timescale units. + * On error, #MP4_INVALID_DURATION. + * + * @see MP4ConvertFromTrackDuration() for how to map this value to another + * timescale. + */ +MP4V2_EXPORT +MP4Duration MP4GetSampleRenderingOffset( + MP4FileHandle hFile, + MP4TrackId trackId, + MP4SampleId sampleId ); + +/** Set the rendering offset of a track sample. + * + * MP4SetSampleRenderingOffset sets the rendering offset of the specified + * sample from the specified track in the track timescale units. + * + * @param hFile handle of file for operation. + * @param trackId id of track for operation. + * @param sampleId id of sample for operation. Caveat: the first sample has + * id <b>1</b>, not <b>0</b>. + * @param renderingOffset new offset value in timescale units. + * + * @return <b>true</b> on success, <b>false</b> on failure. + * + * @see MP4ConvertToTrackDuration() for how to map this value from another + * timescale. + * @see MP4GetSampleRenderingOffset() for a description of this sample + * property. + */ +MP4V2_EXPORT +bool MP4SetSampleRenderingOffset( + MP4FileHandle hFile, + MP4TrackId trackId, + MP4SampleId sampleId, + MP4Duration renderingOffset ); + +/** Get sync/random access state of sample. + * + * MP4GetSampleSync returns the state of the sync/random access flag of + * the specified sample from the specified track. + * + * @param hFile handle of file for operation. + * @param trackId id of track for operation. + * @param sampleId id of sample for operation. Caveat: the first sample has + * id <b>1</b>, not <b>0</b>. + * + * @return <b>1</b> when true, <b>0</b> when false. On error, <b>-1</b>. + */ +MP4V2_EXPORT +int8_t MP4GetSampleSync( + MP4FileHandle hFile, + MP4TrackId trackId, + MP4SampleId sampleId ); + +/* @} ***********************************************************************/ + +#endif /* MP4V2_SAMPLE_H */ diff --git a/include/mp4v2/streaming.h b/include/mp4v2/streaming.h new file mode 100644 index 0000000..36389d6 --- /dev/null +++ b/include/mp4v2/streaming.h @@ -0,0 +1,163 @@ +#ifndef MP4V2_STREAMING_H +#define MP4V2_STREAMING_H + +/**************************************************************************//** + * + * @defgroup mp4_hint MP4v2 Streaming + * @{ + * + *****************************************************************************/ + +MP4V2_EXPORT +bool MP4GetHintTrackRtpPayload( + MP4FileHandle hFile, + MP4TrackId hintTrackId, + char** ppPayloadName DEFAULT(NULL), + uint8_t* pPayloadNumber DEFAULT(NULL), + uint16_t* pMaxPayloadSize DEFAULT(NULL), + char** ppEncodingParams DEFAULT(NULL) ); + +#define MP4_SET_DYNAMIC_PAYLOAD 0xff + +MP4V2_EXPORT +bool MP4SetHintTrackRtpPayload( + MP4FileHandle hFile, + MP4TrackId hintTrackId, + const char* pPayloadName, + uint8_t* pPayloadNumber, + uint16_t maxPayloadSize DEFAULT(0), + const char * encode_params DEFAULT(NULL), + bool include_rtp_map DEFAULT(true), + bool include_mpeg4_esid DEFAULT(true) ); + +MP4V2_EXPORT +const char* MP4GetSessionSdp( + MP4FileHandle hFile ); + +MP4V2_EXPORT +bool MP4SetSessionSdp( + MP4FileHandle hFile, + const char* sdpString ); + +MP4V2_EXPORT +bool MP4AppendSessionSdp( + MP4FileHandle hFile, + const char* sdpString ); + +MP4V2_EXPORT +const char* MP4GetHintTrackSdp( + MP4FileHandle hFile, + MP4TrackId hintTrackId ); + +MP4V2_EXPORT +bool MP4SetHintTrackSdp( + MP4FileHandle hFile, + MP4TrackId hintTrackId, + const char* sdpString ); + +MP4V2_EXPORT +bool MP4AppendHintTrackSdp( + MP4FileHandle hFile, + MP4TrackId hintTrackId, + const char* sdpString ); + +MP4V2_EXPORT +MP4TrackId MP4GetHintTrackReferenceTrackId( + MP4FileHandle hFile, + MP4TrackId hintTrackId ); + +MP4V2_EXPORT +bool MP4ReadRtpHint( + MP4FileHandle hFile, + MP4TrackId hintTrackId, + MP4SampleId hintSampleId, + uint16_t* pNumPackets DEFAULT(NULL) ); + +MP4V2_EXPORT +uint16_t MP4GetRtpHintNumberOfPackets( + MP4FileHandle hFile, + MP4TrackId hintTrackId ); + +MP4V2_EXPORT +int8_t MP4GetRtpPacketBFrame( + MP4FileHandle hFile, + MP4TrackId hintTrackId, + uint16_t packetIndex ); + +MP4V2_EXPORT +int32_t MP4GetRtpPacketTransmitOffset( + MP4FileHandle hFile, + MP4TrackId hintTrackId, + uint16_t packetIndex ); + +MP4V2_EXPORT +bool MP4ReadRtpPacket( + MP4FileHandle hFile, + MP4TrackId hintTrackId, + uint16_t packetIndex, + uint8_t** ppBytes, + uint32_t* pNumBytes, + uint32_t ssrc DEFAULT(0), + bool includeHeader DEFAULT(true), + bool includePayload DEFAULT(true) ); + +MP4V2_EXPORT +MP4Timestamp MP4GetRtpTimestampStart( + MP4FileHandle hFile, + MP4TrackId hintTrackId ); + +MP4V2_EXPORT +bool MP4SetRtpTimestampStart( + MP4FileHandle hFile, + MP4TrackId hintTrackId, + MP4Timestamp rtpStart ); + +MP4V2_EXPORT +bool MP4AddRtpHint( + MP4FileHandle hFile, + MP4TrackId hintTrackId ); + +MP4V2_EXPORT +bool MP4AddRtpVideoHint( + MP4FileHandle hFile, + MP4TrackId hintTrackId, + bool isBframe DEFAULT(false), + uint32_t timestampOffset DEFAULT(0) ); + +MP4V2_EXPORT +bool MP4AddRtpPacket( + MP4FileHandle hFile, + MP4TrackId hintTrackId, + bool setMbit DEFAULT(false), + int32_t transmitOffset DEFAULT(0) ); + +MP4V2_EXPORT +bool MP4AddRtpImmediateData( + MP4FileHandle hFile, + MP4TrackId hintTrackId, + const uint8_t* pBytes, + uint32_t numBytes ); + +MP4V2_EXPORT +bool MP4AddRtpSampleData( + MP4FileHandle hFile, + MP4TrackId hintTrackId, + MP4SampleId sampleId, + uint32_t dataOffset, + uint32_t dataLength ); + +MP4V2_EXPORT +bool MP4AddRtpESConfigurationPacket( + MP4FileHandle hFile, + MP4TrackId hintTrackId ); + +MP4V2_EXPORT +bool MP4WriteRtpHint( + MP4FileHandle hFile, + MP4TrackId hintTrackId, + MP4Duration duration, + bool isSyncSample DEFAULT(true) ); + +/** @} ***********************************************************************/ + +#endif /* MP4V2_STREAMING_H */ diff --git a/include/mp4v2/track.h b/include/mp4v2/track.h new file mode 100644 index 0000000..6e39e5a --- /dev/null +++ b/include/mp4v2/track.h @@ -0,0 +1,404 @@ +#ifndef MP4V2_TRACK_H +#define MP4V2_TRACK_H + +/**************************************************************************//** + * + * @defgroup mp4_track MP4v2 Track + * @{ + * + *****************************************************************************/ + +/** Add a user defined track. + * + * MP4AddTrack adds a user defined track to the mp4 file. Care should be + * taken to avoid any of the standardized track type names. A useful + * convention is use only uppercase characters for user defined track types. + * The string should be exactly four characters in length, e.g. "MINE". + * + * Note this should not be used to add any of the known track types defined + * in the MP4 standard (ISO/IEC 14496−1:2001). + * + * @param hFile handle of file for operation. + * @param type specifies the type of track to be added. + * + * @return On success, the track-id of new track. + * On failure, #MP4_INVALID_TRACK_ID. + */ +MP4V2_EXPORT +MP4TrackId MP4AddTrack( + MP4FileHandle hFile, + const char* type ); + +/** Add an MPEG−4 systems track. + * + * MP4AddSystemsTrack adds an MPEG−4 Systems track to the mp4 file. Note + * this should not be used to add OD or scene tracks, MP4AddODTrack() and + * MP4AddSceneTrack() should be used for those purposes. Other known + * MPEG−4 System track types are: + * @li #MP4_CLOCK_TRACK_TYPE + * @li #MP4_MPEG7_TRACK_TYPE + * @li #MP4_OCI_TRACK_TYPE + * @li #MP4_IPMP_TRACK_TYPE + * @li #MP4_MPEGJ_TRACK_TYPE + * + * @param hFile handle of file for operation. + * @param type specifies the type of track to be added. + * + * @return On success, the track-id of new track. + * On failure, #MP4_INVALID_TRACK_ID. + */ +MP4V2_EXPORT +MP4TrackId MP4AddSystemsTrack( + MP4FileHandle hFile, + const char* type ); + +/** Add a object descriptor (OD) track. + * + * MP4AddODTrack adds an object descriptor (aka OD) track to the mp4 file. + * MP4WriteSample() can then be used to add the desired OD commands to the + * track. The burden is currently on the calling application to understand + * OD. + * + * Those wishing to have a simple audio/video scene without understanding + * OD may wish to use MP4MakeIsmaCompliant() to create the minimal OD and + * BIFS information. + * + * @param hFile handle of file for operation. + * + * @return On success, the track-id of new track. + * On failure, #MP4_INVALID_TRACK_ID. + */ +MP4V2_EXPORT +MP4TrackId MP4AddODTrack( + MP4FileHandle hFile ); + +/** Add a scene (BIFS) track. + * + * MP4AddSceneTrack adds a scene (aka BIFS) track to the mp4 file. + * MP4WriteSample() can then be used to add the desired BIFS commands to + * the track. The burden is currently on the calling application to + * understand BIFS. + * + * Those wishing to have a simple audio/video scene without understanding + * BIFS may wish to use MP4MakeIsmaCompliant() to create the minimal OD + * and BIFS information. + * + * @param hFile handle of file for operation. + * + * @return On success, the track-id of new track. + * On failure, #MP4_INVALID_TRACK_ID. + */ +MP4V2_EXPORT +MP4TrackId MP4AddSceneTrack( + MP4FileHandle hFile ); + +/** Add audio track to mp4 file. + * + * MP4AddAudioTrack adds an audio track to the mp4 file. MP4WriteSample() + * can then be used to add the desired audio samples. + * + * It is recommended that the time scale be set to the sampling frequency + * (eg. 44100 Hz) of the audio so as to preserve the timing information + * accurately. + * + * If the audio encoding uses a fixed duration for each sample that should + * be specified here. If not then the value #MP4_INVALID_DURATION + * should be given for the sampleDuration argument. + * + * @param hFile handle of file for operation. + * @param timeScale the time scale in ticks per second of the track. + * @param sampleDuration the fixed duration for all track samples. + * Caveat: the value should be in track-timescale units. + * @param audioType the audio encoding type. + * See MP4GetTrackEsdsObjectTypeId() for known values. + * + * @return On success, the track-id of the new track. + * On error, #MP4_INVALID_TRACK_ID. + */ +MP4V2_EXPORT +MP4TrackId MP4AddAudioTrack( + MP4FileHandle hFile, + uint32_t timeScale, + MP4Duration sampleDuration, + uint8_t audioType DEFAULT(MP4_MPEG4_AUDIO_TYPE) ); + +MP4V2_EXPORT +MP4TrackId MP4AddAC3AudioTrack( + MP4FileHandle hFile, + uint32_t samplingRate, + uint8_t fscod, + uint8_t bsid, + uint8_t bsmod, + uint8_t acmod, + uint8_t lfeon, + uint8_t bit_rate_code ); + +MP4V2_EXPORT +MP4TrackId MP4AddAmrAudioTrack( + MP4FileHandle hFile, + uint32_t timeScale, + uint16_t modeSet, + uint8_t modeChangePeriod, + uint8_t framesPerSample, + bool isAmrWB ); + +MP4V2_EXPORT +void MP4SetAmrVendor( + MP4FileHandle hFile, + MP4TrackId trackId, + uint32_t vendor ); + +MP4V2_EXPORT +void MP4SetAmrDecoderVersion( + MP4FileHandle hFile, + MP4TrackId trackId, + uint8_t decoderVersion ); + +MP4V2_EXPORT +void MP4SetAmrModeSet( + MP4FileHandle hFile, + MP4TrackId trakId, + uint16_t modeSet ); + +MP4V2_EXPORT +uint16_t MP4GetAmrModeSet( + MP4FileHandle hFile, + MP4TrackId trackId ); + +MP4V2_EXPORT +MP4TrackId MP4AddHrefTrack( + MP4FileHandle hFile, + uint32_t timeScale, + MP4Duration sampleDuration, + const char* base_url DEFAULT(NULL) ); + +MP4V2_EXPORT +const char* MP4GetHrefTrackBaseUrl( + MP4FileHandle hFile, + MP4TrackId trackId ); + +/** Add a video track. + * + * MP4AddVideoTrack adds a video track to the mp4 file. MP4WriteSample() + * can then be used to add the desired video samples. + * + * It is recommended that the time scale be set to 90000 so as to preserve + * the timing information accurately for the range of video frame rates + * commonly in use. + * + * If the video frame rate is to be fixed then the sampleDuration argument + * should be give the appropriate fixed value. If the video frame rate is + * to be variable then the value #MP4_INVALID_DURATION should be + * given for the sampleDuration argument. + * + * @param hFile handle of file for operation. + * @param timeScale the timescale in ticks per second of the track. + * @param sampleDuration specifies fixed sample duration for all track + * samples. Caveat: the value should be in track timescale units. + * @param width specifies the video frame width in pixels. + * @param height specifies the video frame height in pixels. + * @param videoType specifies the video encoding type. + * See MP4GetTrackVideoType() for known values. + * + * @return On success, the track-id of the new track. + * On error, #MP4_INVALID_TRACK_ID. + */ +MP4V2_EXPORT +MP4TrackId MP4AddVideoTrack( + MP4FileHandle hFile, + uint32_t timeScale, + MP4Duration sampleDuration, + uint16_t width, + uint16_t height, + uint8_t videoType DEFAULT(MP4_MPEG4_VIDEO_TYPE) ); + +MP4V2_EXPORT +MP4TrackId MP4AddH264VideoTrack( + MP4FileHandle hFile, + uint32_t timeScale, + MP4Duration sampleDuration, + uint16_t width, + uint16_t height, + uint8_t AVCProfileIndication, + uint8_t profile_compat, + uint8_t AVCLevelIndication, + uint8_t sampleLenFieldSizeMinusOne ); + +MP4V2_EXPORT +void MP4AddH264SequenceParameterSet( + MP4FileHandle hFile, + MP4TrackId trackId, + const uint8_t* pSequence, + uint16_t sequenceLen ); + +MP4V2_EXPORT +void MP4AddH264PictureParameterSet( + MP4FileHandle hFile, + MP4TrackId trackId, + const uint8_t* pPict, + uint16_t pictLen ); + +MP4V2_EXPORT +void MP4SetH263Vendor( + MP4FileHandle hFile, + MP4TrackId trackId, + uint32_t vendor ); + +MP4V2_EXPORT +void MP4SetH263DecoderVersion( + MP4FileHandle hFile, + MP4TrackId trackId, + uint8_t decoderVersion ); + +MP4V2_EXPORT +void MP4SetH263Bitrates( + MP4FileHandle hFile, + MP4TrackId trackId, + uint32_t avgBitrate, + uint32_t maxBitrate ); + +MP4V2_EXPORT +MP4TrackId MP4AddH263VideoTrack( + MP4FileHandle hFile, + uint32_t timeScale, + MP4Duration sampleDuration, + uint16_t width, + uint16_t height, + uint8_t h263Level, + uint8_t h263Profile, + uint32_t avgBitrate, + uint32_t maxBitrate ); + +/** Add a hint track. + * + * MP4AddHintTrack adds a hint track to the mp4 file. A hint track is used + * to describe how to send the reference media track over a particular + * network transport. In the case of the IETF RTP protocol, the hint track + * describes how the media data should be placed into packets and any + * media specific protocol headers that should be added. + * + * Typically there is a one to one correspondence between reference media + * track samples and hint track samples. The start time, duration, and + * sync flags are typically the same, however provisions are made for + * deviations from this rule. + * + * The MP4 library provides extensive support for RTP hint tracks. This + * includes a easy to use API to create RTP hint tracks, and read out + * fully constructed RTP packets based on the hint track. + * + * @param hFile handle of file for operation. + * @param refTrackId specifies the reference media track for this hint track. + * + * @return On success, the track-id of the new track. + * On error, #MP4_INVALID_TRACK_ID. + */ +MP4V2_EXPORT +MP4TrackId MP4AddHintTrack( + MP4FileHandle hFile, + MP4TrackId refTrackId ); + +MP4V2_EXPORT +MP4TrackId MP4AddTextTrack( + MP4FileHandle hFile, + MP4TrackId refTrackId ); + +MP4V2_EXPORT +MP4TrackId MP4AddSubtitleTrack( + MP4FileHandle hFile, + uint32_t timescale, + uint16_t width, + uint16_t height ); + +MP4V2_EXPORT +MP4TrackId MP4AddPixelAspectRatio( + MP4FileHandle hFile, + MP4TrackId refTrackId, + uint32_t hSpacing, + uint32_t vSpacing ); + +MP4V2_EXPORT +MP4TrackId MP4AddColr( + MP4FileHandle hFile, + MP4TrackId refTrackId, + uint16_t primary, + uint16_t transfer, + uint16_t matrix ); + +MP4V2_EXPORT +MP4TrackId MP4CloneTrack( + MP4FileHandle srcFile, + MP4TrackId srcTrackId, + MP4FileHandle dstFile DEFAULT(MP4_INVALID_FILE_HANDLE), + MP4TrackId dstHintTrackReferenceTrack DEFAULT(MP4_INVALID_TRACK_ID) ); + +MP4V2_EXPORT +MP4TrackId MP4CopyTrack( + MP4FileHandle srcFile, + MP4TrackId srcTrackId, + MP4FileHandle dstFile DEFAULT(MP4_INVALID_FILE_HANDLE), + bool applyEdits DEFAULT(false), + MP4TrackId dstHintTrackReferenceTrack DEFAULT(MP4_INVALID_TRACK_ID) ); + +MP4V2_EXPORT +void MP4DeleteTrack( + MP4FileHandle hFile, + MP4TrackId trackId ); + +MP4V2_EXPORT +uint32_t MP4GetNumberOfTracks( + MP4FileHandle hFile, + const char* type DEFAULT(NULL), + uint8_t subType DEFAULT(0) ); + +MP4V2_EXPORT +MP4TrackId MP4FindTrackId( + MP4FileHandle hFile, + uint16_t index, + const char* type DEFAULT(NULL), + uint8_t subType DEFAULT(0) ); + +MP4V2_EXPORT +uint16_t MP4FindTrackIndex( + MP4FileHandle hFile, + MP4TrackId trackId ); + +/** Get maximum duration of chunk. + * + * MP4GetTrackDurationPerChunk gets the maximum duration for each chunk. + * + * @param hFile handle of file for operation. + * @param trackId id of track for operation. + * @param duration out value of duration in track timescale units. + * + * return <b>true</b> on success, <b>false</b> on failure. + */ +MP4V2_EXPORT +bool MP4GetTrackDurationPerChunk( + MP4FileHandle hFile, + MP4TrackId trackId, + MP4Duration* duration ); + +/** Set maximum duration of chunk. + * + * MP4SetTrackDurationPerChunk sets the maximum duration for each chunk. + * + * @param hFile handle of file for operation. + * @param trackId id of track for operation. + * @param duration in timescale units. + * + * return <b>true</b> on success, <b>false</b> on failure. + */ +MP4V2_EXPORT +bool MP4SetTrackDurationPerChunk( + MP4FileHandle hFile, + MP4TrackId trackId, + MP4Duration duration ); + +MP4V2_EXPORT +void MP4AddIPodUUID( + MP4FileHandle hFile, + MP4TrackId trackId ); + +/** @} ***********************************************************************/ + +#endif /* MP4V2_TRACK_H */ diff --git a/include/mp4v2/track_prop.h b/include/mp4v2/track_prop.h new file mode 100644 index 0000000..9a7c6fc --- /dev/null +++ b/include/mp4v2/track_prop.h @@ -0,0 +1,335 @@ +#ifndef MP4V2_TRACK_PROP_H +#define MP4V2_TRACK_PROP_H + +/**************************************************************************//** + * + * @defgroup mp4_track_prop MP4v2 Track Property + * @{ + * + *****************************************************************************/ + +/* specific track properties */ + +MP4V2_EXPORT +bool MP4HaveTrackAtom( + MP4FileHandle hFile, + MP4TrackId trackId, + const char* atomname ); + +/** Get the track type. + * + * MP4GetTrackType gets the type of the track with the specified track id. + * + * Note: the library does not provide a MP4SetTrackType function, the + * track type needs to be specified when the track is created, e.g. + * MP4AddSystemsTrack(MP4_OCI_TRACK_TYPE). + * + * Known track types are: + * @li #MP4_OD_TRACK_TYPE + * @li #MP4_SCENE_TRACK_TYPE + * @li #MP4_AUDIO_TRACK_TYPE + * @li #MP4_VIDEO_TRACK_TYPE + * @li #MP4_HINT_TRACK_TYPE + * @li #MP4_CNTL_TRACK_TYPE + * @li #MP4_TEXT_TRACK_TYPE + * @li #MP4_CLOCK_TRACK_TYPE + * @li #MP4_MPEG7_TRACK_TYPE + * @li #MP4_OCI_TRACK_TYPE + * @li #MP4_IPMP_TRACK_TYPE + * @li #MP4_MPEGJ_TRACK_TYPE + * + * @param hFile handle of file for operation. + * @param trackId id of track for operation. + * + * @return On success, a string indicating track type. On failure, NULL. + */ +MP4V2_EXPORT +const char* MP4GetTrackType( + MP4FileHandle hFile, + MP4TrackId trackId ); + +MP4V2_EXPORT +const char* MP4GetTrackMediaDataName( + MP4FileHandle hFile, + MP4TrackId trackId ); + +/* + * MP4GetTrackMediaDataOriginalFormat is to be used to get the original + * MediaDataName if a track has been encrypted. + */ + +MP4V2_EXPORT +bool MP4GetTrackMediaDataOriginalFormat( + MP4FileHandle hFile, + MP4TrackId trackId, + char* originalFormat, + uint32_t buflen ); + +MP4V2_EXPORT +MP4Duration MP4GetTrackDuration( + MP4FileHandle hFile, + MP4TrackId trackId ); + +/** Get the time scale of a track. + * + * MP4GetTrackTimeScale returns the time scale of the specified track in + * the mp4 file. The time scale determines the number of clock ticks per + * second for this track. + * + * @param hFile handle of file for operation. + * @param trackId id of track for operation. + * + * @return timescale (ticks per second) of the track in the mp4 file. + */ +MP4V2_EXPORT +uint32_t MP4GetTrackTimeScale( + MP4FileHandle hFile, + MP4TrackId trackId ); + +/** Set the time scale of a track. + * + * MP4SetTrackTimeScale sets the time scale of the specified track in the + * mp4 file. The time scale determines the number of clock ticks per + * second for this track. + * + * Typically this value is set once when the track is created. However + * this call can be used to modify the value if that is desired. Since + * track sample durations are expressed in units of the track time scale, + * any change to the time scale value will effect the real time duration + * of the samples. + * + * @param hFile handle of file for operation. + * @param trackId id of track for operation. + * @param timeScale desired time scale for the track. + */ +MP4V2_EXPORT +void MP4SetTrackTimeScale( + MP4FileHandle hFile, + MP4TrackId trackId, + uint32_t value ); + +/** Get ISO-639-2/T langauge code of a track. + * The language code is a 3-char alpha code consisting of lower-case letters. + * + * @param hFile handle of file for operation. + * @param trackId id of track for operation. + * @param code buffer to hold 3-char+null (4-bytes total). + * + * @return <b>true</b> on success, <b>false</b> on failure. + */ +MP4V2_EXPORT +bool MP4GetTrackLanguage( + MP4FileHandle hFile, + MP4TrackId trackId, + char* code ); + +/** Set ISO-639-2/T langauge code of a track. + * The language code is a 3-char alpha code consisting of lower-case letters. + * + * @param hFile handle of file for operation. + * @param trackId id of track for operation. + * @param code 3-char language code. + * + * @return <b>true</b> on success, <b>false</b> on failure. + */ +MP4V2_EXPORT +bool MP4SetTrackLanguage( + MP4FileHandle hFile, + MP4TrackId trackId, + const char* code ); + +/** Get track name. + * + * MP4GetTrackName gets the name of the track via udta.name property. + * + * @param hFile handle of file for operation. + * @param trackId id of track for operation. + * + * @return <b>true</b> on success, <b>false</b> on failure. + */ +MP4V2_EXPORT +bool MP4GetTrackName( + MP4FileHandle hFile, + MP4TrackId trackId, + char** name ); + +/** Set track name. + * + * MP4SetTrackName sets the name of the track via udta.name property. + * The udta atom is created if needed. + * + * @param hFile handle of file for operation. + * @param trackId id of track for operation. + * + * @return <b>true</b> on success, <b>false</b> on failure. + */ +MP4V2_EXPORT +bool MP4SetTrackName( + MP4FileHandle hFile, + MP4TrackId trackId, + const char* name ); + +MP4V2_EXPORT +uint8_t MP4GetTrackAudioMpeg4Type( + MP4FileHandle hFile, + MP4TrackId trackId ); + +MP4V2_EXPORT +uint8_t MP4GetTrackEsdsObjectTypeId( + MP4FileHandle hFile, + MP4TrackId trackId ); + +/* returns MP4_INVALID_DURATION if track samples do not have a fixed duration */ +MP4V2_EXPORT +MP4Duration MP4GetTrackFixedSampleDuration( + MP4FileHandle hFile, + MP4TrackId trackId ); + +MP4V2_EXPORT +uint32_t MP4GetTrackBitRate( + MP4FileHandle hFile, + MP4TrackId trackId ); + +MP4V2_EXPORT +bool MP4GetTrackVideoMetadata( + MP4FileHandle hFile, + MP4TrackId trackId, + uint8_t** ppConfig, + uint32_t* pConfigSize ); + +MP4V2_EXPORT +bool MP4GetTrackESConfiguration( + MP4FileHandle hFile, + MP4TrackId trackId, + uint8_t** ppConfig, + uint32_t* pConfigSize ); + +MP4V2_EXPORT +bool MP4SetTrackESConfiguration( + MP4FileHandle hFile, + MP4TrackId trackId, + const uint8_t* pConfig, + uint32_t configSize ); + +/* h264 information routines */ +MP4V2_EXPORT +bool MP4GetTrackH264ProfileLevel( + MP4FileHandle hFile, + MP4TrackId trackId, + uint8_t* pProfile, + uint8_t* pLevel ); + +MP4V2_EXPORT +void MP4GetTrackH264SeqPictHeaders( + MP4FileHandle hFile, + MP4TrackId trackId, + uint8_t*** pSeqHeaders, + uint32_t** pSeqHeaderSize, + uint8_t*** pPictHeader, + uint32_t** pPictHeaderSize ); + +MP4V2_EXPORT +bool MP4GetTrackH264LengthSize( + MP4FileHandle hFile, + MP4TrackId trackId, + uint32_t* pLength ); + +MP4V2_EXPORT +MP4SampleId MP4GetTrackNumberOfSamples( + MP4FileHandle hFile, + MP4TrackId trackId ); + +MP4V2_EXPORT +uint16_t MP4GetTrackVideoWidth( + MP4FileHandle hFile, + MP4TrackId trackId ); + +MP4V2_EXPORT +uint16_t MP4GetTrackVideoHeight( + MP4FileHandle hFile, + MP4TrackId trackId ); + +MP4V2_EXPORT +double MP4GetTrackVideoFrameRate( + MP4FileHandle hFile, + MP4TrackId trackId ); + +MP4V2_EXPORT +int MP4GetTrackAudioChannels( + MP4FileHandle hFile, + MP4TrackId trackId ); + +MP4V2_EXPORT +bool MP4IsIsmaCrypMediaTrack( + MP4FileHandle hFile, + MP4TrackId trackId ); + +/* generic track properties */ + +MP4V2_EXPORT +bool MP4HaveTrackAtom( + MP4FileHandle hFile, + MP4TrackId trackId, + const char* atomName ); + +MP4V2_EXPORT +bool MP4GetTrackIntegerProperty( + MP4FileHandle hFile, + MP4TrackId trackId, + const char* propName, + uint64_t* retvalue ); + +MP4V2_EXPORT +bool MP4GetTrackFloatProperty( + MP4FileHandle hFile, + MP4TrackId trackId, + const char* propName, + float* ret_value ); + +MP4V2_EXPORT +bool MP4GetTrackStringProperty( + MP4FileHandle hFile, + MP4TrackId trackId, + const char* propName, + const char** retvalue ); + +MP4V2_EXPORT +bool MP4GetTrackBytesProperty( + MP4FileHandle hFile, + MP4TrackId trackId, + const char* propName, + uint8_t** ppValue, + uint32_t* pValueSize ); + +MP4V2_EXPORT +bool MP4SetTrackIntegerProperty( + MP4FileHandle hFile, + MP4TrackId trackId, + const char* propName, + int64_t value ); + +MP4V2_EXPORT +bool MP4SetTrackFloatProperty( + MP4FileHandle hFile, + MP4TrackId trackId, + const char* propName, + float value ); + +MP4V2_EXPORT +bool MP4SetTrackStringProperty( + MP4FileHandle hFile, + MP4TrackId trackId, + const char* propName, + const char* value ); + +MP4V2_EXPORT +bool MP4SetTrackBytesProperty( + MP4FileHandle hFile, + MP4TrackId trackId, + const char* propName, + const uint8_t* pValue, + uint32_t valueSize); + +/** @} ***********************************************************************/ + +#endif /* MP4V2_TRACK_PROP_H */ diff --git a/libplatform/config.h b/libplatform/config.h new file mode 100644 index 0000000..b4c2d29 --- /dev/null +++ b/libplatform/config.h @@ -0,0 +1,59 @@ +/* libplatform/config.h. Generated from config.h.in by configure. */ +/* libplatform/config.h.in. Generated from configure.ac by autoheader. */ + +/* Define to 1 if you have the <dlfcn.h> header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if you have the <inttypes.h> header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the <memory.h> header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the <stdint.h> header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the <stdlib.h> header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the <strings.h> header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the <string.h> header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the <sys/stat.h> header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the <sys/types.h> header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the <unistd.h> header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if LFS should be activated */ +#define NEED_LFS_ACTIVATION 1 + +/* Name of package */ +#define PACKAGE "mp4v2" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "eddyg@myreflection.org" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "MP4v2" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "MP4v2 1.9.1" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "mp4v2" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "1.9.1" + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Version number of package */ +#define VERSION "1.9.1" diff --git a/libplatform/config.h.in b/libplatform/config.h.in new file mode 100755 index 0000000..956280c --- /dev/null +++ b/libplatform/config.h.in @@ -0,0 +1,58 @@ +/* libplatform/config.h.in. Generated from configure.ac by autoheader. */ + +/* Define to 1 if you have the <dlfcn.h> header file. */ +#undef HAVE_DLFCN_H + +/* Define to 1 if you have the <inttypes.h> header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if you have the <memory.h> header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the <stdint.h> header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the <stdlib.h> header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the <strings.h> header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the <string.h> header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the <sys/stat.h> header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the <sys/types.h> header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the <unistd.h> header file. */ +#undef HAVE_UNISTD_H + +/* Define to 1 if LFS should be activated */ +#undef NEED_LFS_ACTIVATION + +/* Name of package */ +#undef PACKAGE + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Version number of package */ +#undef VERSION diff --git a/libplatform/endian.h b/libplatform/endian.h new file mode 100644 index 0000000..83fe69e --- /dev/null +++ b/libplatform/endian.h @@ -0,0 +1,42 @@ +#ifndef MP4V2_PLATFORM_ENDIAN_H +#define MP4V2_PLATFORM_ENDIAN_H + +/////////////////////////////////////////////////////////////////////////////// + +#define MP4V2_BYTESWAP_16(x) \ + mp4v2::platform::uint16_t( ((mp4v2::platform::uint16_t(x) & 0xff00U) >> 8) \ + | ((mp4v2::platform::uint16_t(x) & 0x00ffU) << 8) ) + +#define MP4V2_BYTESWAP_32(x) \ + mp4v2::platform::uint32_t( ((mp4v2::platform::uint32_t(x) & 0xff000000U) >> 24) \ + | ((mp4v2::platform::uint32_t(x) & 0x00ff0000U) >> 8) \ + | ((mp4v2::platform::uint32_t(x) & 0x0000ff00U) << 8) \ + | ((mp4v2::platform::uint32_t(x) & 0x000000ffU) << 24) ) + +#define MP4V2_BYTESWAP_64(x) \ + mp4v2::platform::uint64_t( ((mp4v2::platform::uint64_t(x) & 0xff00000000000000ULL) >> 56) \ + | ((mp4v2::platform::uint64_t(x) & 0x00ff000000000000ULL) >> 40) \ + | ((mp4v2::platform::uint64_t(x) & 0x0000ff0000000000ULL) >> 24) \ + | ((mp4v2::platform::uint64_t(x) & 0x000000ff00000000ULL) >> 8) \ + | ((mp4v2::platform::uint64_t(x) & 0x00000000ff000000ULL) << 8) \ + | ((mp4v2::platform::uint64_t(x) & 0x0000000000ff0000ULL) << 24) \ + | ((mp4v2::platform::uint64_t(x) & 0x000000000000ff00ULL) << 40) \ + | ((mp4v2::platform::uint64_t(x) & 0x00000000000000ffULL) << 56) ) + +/////////////////////////////////////////////////////////////////////////////// + +#if defined( __BIG_ENDIAN__ ) +# define MP4V2_HTONS(x) (x) +# define MP4V2_HTONL(x) (x) +# define MP4V2_NTOHS(x) (x) +# define MP4V2_NTOHL(x) (x) +#else +# define MP4V2_HTONS(x) MP4V2_BYTESWAP_16(x) +# define MP4V2_HTONL(x) MP4V2_BYTESWAP_32(x) +# define MP4V2_NTOHS(x) MP4V2_BYTESWAP_16(x) +# define MP4V2_NTOHL(x) MP4V2_BYTESWAP_32(x) +#endif + +/////////////////////////////////////////////////////////////////////////////// + +#endif // MP4V2_PLATFORM_ENDIAN_H diff --git a/libplatform/impl.h b/libplatform/impl.h new file mode 100644 index 0000000..b20523d --- /dev/null +++ b/libplatform/impl.h @@ -0,0 +1,10 @@ +#ifndef MP4V2_PLATFORM_IMPL_H +#define MP4V2_PLATFORM_IMPL_H + +/////////////////////////////////////////////////////////////////////////////// + +#include "libplatform/platform.h" + +/////////////////////////////////////////////////////////////////////////////// + +#endif // MP4V2_PLATFORM_IMPL_H diff --git a/libplatform/io/File.cpp b/libplatform/io/File.cpp new file mode 100644 index 0000000..893f98c --- /dev/null +++ b/libplatform/io/File.cpp @@ -0,0 +1,185 @@ +#include "libplatform/impl.h" + +namespace mp4v2 { namespace platform { namespace io { + +/////////////////////////////////////////////////////////////////////////////// + +namespace { + const File::Size __maxChunkSize = 1024*1024; +} + +/////////////////////////////////////////////////////////////////////////////// + +File::File( std::string name_, Mode mode_, FileProvider* provider_ ) + : _name ( name_ ) + , _isOpen ( false ) + , _mode ( mode_ ) + , _size ( 0 ) + , _position ( 0 ) + , _provider ( provider_ ? *provider_ : standard() ) + , name ( _name ) + , isOpen ( _isOpen ) + , mode ( _mode ) + , size ( _size ) + , position ( _position ) +{ +} + +/////////////////////////////////////////////////////////////////////////////// + +File::~File() +{ + close(); + delete &_provider; +} + +/////////////////////////////////////////////////////////////////////////////// + +void +File::setMode( Mode mode_ ) +{ + _mode = mode_; +} + +void +File::setName( const std::string& name_ ) +{ + _name = name_; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +File::open( std::string name_, Mode mode_ ) +{ + if( _isOpen ) + return true; + + if( !name_.empty() ) + setName( name_ ); + if( mode_ != MODE_UNDEFINED ) + setMode( mode_ ); + + if( _provider.open( _name, _mode )) + return true; + + FileSystem::getFileSize( _name, _size ); + + _isOpen = true; + return false; +} + +bool +File::seek( Size pos ) +{ + if( !_isOpen ) + return true; + + if( _provider.seek( pos )) + return true; + _position = pos; + return false; +} + +bool +File::read( void* buffer, Size size, Size& nin, Size maxChunkSize ) +{ + nin = 0; + + if( !_isOpen ) + return true; + + if( _provider.read( buffer, size, nin, maxChunkSize )) + return true; + + _position += nin; + if( _position > _size ) + _size = _position; + + return false; +} + +bool +File::write( const void* buffer, Size size, Size& nout, Size maxChunkSize ) +{ + nout = 0; + + if( !_isOpen ) + return true; + + if( _provider.write( buffer, size, nout, maxChunkSize )) + return true; + + _position += nout; + if( _position > _size ) + _size = _position; + + return false; +} + +bool +File::close() +{ + if( !_isOpen ) + return false; + if( _provider.close() ) + return true; + + _isOpen = false; + return false; +} + +/////////////////////////////////////////////////////////////////////////////// + +CustomFileProvider::CustomFileProvider( const MP4FileProvider& provider ) + : _handle( NULL ) +{ + memcpy( &_call, &provider, sizeof(MP4FileProvider) ); +} + +bool +CustomFileProvider::open( std::string name, Mode mode ) +{ + MP4FileMode fm; + switch( mode ) { + case MODE_READ: fm = FILEMODE_READ; break; + case MODE_MODIFY: fm = FILEMODE_MODIFY; break; + case MODE_CREATE: fm = FILEMODE_CREATE; break; + + case MODE_UNDEFINED: + default: + fm = FILEMODE_UNDEFINED; + break; + } + + _handle = _call.open( name.c_str(), fm ); + return _handle == NULL; +} + +bool +CustomFileProvider::seek( Size pos ) +{ + return _call.seek( _handle, pos ); +} + +bool +CustomFileProvider::read( void* buffer, Size size, Size& nin, Size maxChunkSize ) +{ + return _call.read( _handle, buffer, size, &nin, maxChunkSize ); +} + +bool +CustomFileProvider::write( const void* buffer, Size size, Size& nout, Size maxChunkSize ) +{ + return _call.write( _handle, buffer, size, &nout, maxChunkSize ); +} + +bool +CustomFileProvider::close() +{ + return _call.close( _handle ); +} + +/////////////////////////////////////////////////////////////////////////////// + +}}} // namespace mp4v2::platform::io diff --git a/libplatform/io/File.h b/libplatform/io/File.h new file mode 100644 index 0000000..1cf7cf9 --- /dev/null +++ b/libplatform/io/File.h @@ -0,0 +1,198 @@ +#ifndef MP4V2_PLATFORM_IO_FILE_H +#define MP4V2_PLATFORM_IO_FILE_H + +namespace mp4v2 { namespace platform { namespace io { + +/////////////////////////////////////////////////////////////////////////////// + +class MP4V2_EXPORT FileProvider +{ +public: + static FileProvider& standard(); + +public: + //! file operation mode flags + enum Mode { + MODE_UNDEFINED, //!< undefined + MODE_READ, //!< file may be read + MODE_MODIFY, //!< file may be read/written + MODE_CREATE, //!< file will be created/truncated for read/write + }; + + //! type used to represent all file sizes and offsets + typedef int64_t Size; + +public: + virtual ~FileProvider() { } + + virtual bool open( std::string name, Mode mode ) = 0; + virtual bool seek( Size pos ) = 0; + virtual bool read( void* buffer, Size size, Size& nin, Size maxChunkSize ) = 0; + virtual bool write( const void* buffer, Size size, Size& nout, Size maxChunkSize ) = 0; + virtual bool close() = 0; + +protected: + FileProvider() { } +}; + +/////////////////////////////////////////////////////////////////////////////// +/// +/// File implementation. +/// +/// File objects model real filesystem files in a 1:1 releationship and always +/// treated as binary; there are no translations of text content performed. +/// +/// The interface represents all sizes with a signed 64-bit value, thus +/// the limit to this interface is 63-bits of size, roughly 9.22 million TB. +/// +/////////////////////////////////////////////////////////////////////////////// + +class MP4V2_EXPORT File : public FileProvider +{ +public: + /////////////////////////////////////////////////////////////////////////// + //! + //! Constructor. + //! + //! A new file object is constructed but not opened. + //! + //! @param name filename of file object, or empty-string. + //! @param mode bitmask specifying mode flags. + //! See #Mode for bit constants. + //! @param provider a fileprovider instance. If NULL a standard file + //! provider will be used otherwise the supplied provider must be + //! new-allocated and will be delete'd via ~File(). + //! + /////////////////////////////////////////////////////////////////////////// + + explicit File( std::string name = "", Mode mode = MODE_UNDEFINED, FileProvider* = NULL ); + + /////////////////////////////////////////////////////////////////////////// + //! + //! Destructor. + //! + //! File object is destroyed. If the file is opened it is closed prior + //! to destruction. + //! + /////////////////////////////////////////////////////////////////////////// + + ~File(); + + /////////////////////////////////////////////////////////////////////////// + //! + //! Open file. + //! + //! @param name filename of file object, or empty-string to use #name. + //! + /////////////////////////////////////////////////////////////////////////// + + bool open( std::string name = "", Mode mode = MODE_UNDEFINED ); + + /////////////////////////////////////////////////////////////////////////// + //! + //! Closes file. + //! + //! If the file has not been opened or is not considered the + //! owner of a filehandle, no action is taken. + //! + //! @return true on failure, false on success. + //! + /////////////////////////////////////////////////////////////////////////// + + bool close(); + + /////////////////////////////////////////////////////////////////////////// + //! + //! Set current file position in bytes. + //! + //! @param pos new file position in bytes. + //! + //! @return true on failure, false on success. + //! + /////////////////////////////////////////////////////////////////////////// + + bool seek( Size pos ); + + /////////////////////////////////////////////////////////////////////////// + //! + //! Binary stream read. + //! + //! The function reads up to a maximum <b>size</b> bytes from file, + //! storing them in <b>buffer</b>. The number of bytes actually read are + //! returned in <b>nin</b>. + //! + //! @param buffer storage for data read from file. + //! @param size maximum number of bytes to read from file. + //! @param nin output indicating number of bytes read from file. + //! @param maxChunkSize maximum chunk size for reads issued to operating + //! system or 0 for default. + //! + //! @return true on failure, false on success. + //! + /////////////////////////////////////////////////////////////////////////// + + bool read( void* buffer, Size size, Size& nin, Size maxChunkSize = 0 ); + + /////////////////////////////////////////////////////////////////////////// + //! + //! Binary stream write. + //! + //! The function writes up to a maximum <b>size</b> bytes from + //! <b>buffer</b> to file. The number of bytes actually written are + //! returned in <b>nout</b>. + //! + //! @param buffer data to be written out to file. + //! @param size maximum number of bytes to read from file. + //! @param nout output indicating number of bytes written to file. + //! @param maxChunkSize maximum chunk size for writes issued to operating + //! system or 0 for default. + //! + //! @return true on failure, false on success. + //! + /////////////////////////////////////////////////////////////////////////// + + bool write( const void* buffer, Size size, Size& nout, Size maxChunkSize = 0 ); + +private: + std::string _name; + bool _isOpen; + Mode _mode; + Size _size; + Size _position; + FileProvider& _provider; + +public: + const std::string& name; //!< read-only: file pathname or empty-string if not applicable + const bool& isOpen; //!< read-only: true if file is open + const Mode& mode; //!< read-only: file mode + const Size& size; //!< read-only: file size + const Size& position; //!< read-only: file position + +public: + void setName( const std::string& name ); + void setMode( Mode mode ); +}; + +/////////////////////////////////////////////////////////////////////////////// + +class CustomFileProvider : public FileProvider +{ +public: + CustomFileProvider( const MP4FileProvider& ); + + bool open( std::string name, Mode mode ); + bool seek( Size pos ); + bool read( void* buffer, Size size, Size& nin, Size maxChunkSize ); + bool write( const void* buffer, Size size, Size& nout, Size maxChunkSize ); + bool close(); + +private: + MP4FileProvider _call; + void* _handle; +}; + +/////////////////////////////////////////////////////////////////////////////// + +}}} // namespace mp4v2::platform::io + +#endif // MP4V2_PLATFORM_IO_FILE_H diff --git a/libplatform/io/FileSystem.cpp b/libplatform/io/FileSystem.cpp new file mode 100644 index 0000000..762511f --- /dev/null +++ b/libplatform/io/FileSystem.cpp @@ -0,0 +1,101 @@ +#include "libplatform/impl.h" + +namespace mp4v2 { namespace platform { namespace io { + +/////////////////////////////////////////////////////////////////////////////// + +void +FileSystem::pathnameCleanup( string& name ) +{ + string bad; + + // fold repeating directory separators + bad = DIR_SEPARATOR; + bad += DIR_SEPARATOR; + for( string::size_type pos = name.find( bad ); + pos != string::npos; + pos = name.find( bad, pos ) ) + { + name.replace( pos, bad.length(), DIR_SEPARATOR ); + } + + // replace occurances of /./ with / + bad = DIR_SEPARATOR; + bad += '.'; + bad += DIR_SEPARATOR; + for( string::size_type pos = name.find( bad ); + pos != string::npos; + pos = name.find( bad, pos ) ) + { + name.replace( pos, bad.length(), DIR_SEPARATOR ); + } +} + +/////////////////////////////////////////////////////////////////////////////// + +void +FileSystem::pathnameOnlyExtension( string& name ) +{ + // compute basename + string::size_type dot_pos = name.rfind( '.' ); + string::size_type slash_pos = name.rfind( DIR_SEPARATOR ); + + // dot_pos must be after slash_pos + if( slash_pos != string::npos && dot_pos < slash_pos ) + dot_pos = string::npos; + + // return empty-string if no dot + if( dot_pos == string::npos ) { + name.resize( 0 ); + return; + } + + name = name.substr( dot_pos + 1 ); + pathnameCleanup( name ); +} + +/////////////////////////////////////////////////////////////////////////////// + +void +FileSystem::pathnameStripExtension( string& name ) +{ + pathnameCleanup( name ); + + // compute basename + string::size_type dot_pos = name.rfind( '.' ); + string::size_type slash_pos = name.rfind( DIR_SEPARATOR ); + + // dot_pos must be after slash_pos + if( slash_pos != string::npos && dot_pos < slash_pos ) + dot_pos = string::npos; + + // chop extension + if( dot_pos != string::npos ) + name.resize( dot_pos ); +} + +/////////////////////////////////////////////////////////////////////////////// + +void +FileSystem::pathnameTemp( string& name, string dir, string prefix, string suffix ) +{ + ostringstream buf; + buf << dir; + + // add dir separator if needed + if( !dir.empty() ) { + buf << dir; + if( dir[dir.length()-1] != '/' ) + buf << '/'; + } + + buf << prefix; + buf << setfill('0') << setw(8) << number::random32(); + buf << suffix; + + name = buf.str(); +} + +/////////////////////////////////////////////////////////////////////////////// + +}}} // namespace mp4v2::platform::io diff --git a/libplatform/io/FileSystem.h b/libplatform/io/FileSystem.h new file mode 100644 index 0000000..5e95018 --- /dev/null +++ b/libplatform/io/FileSystem.h @@ -0,0 +1,191 @@ +#ifndef MP4V2_PLATFORM_IO_FILESYSTEM_H +#define MP4V2_PLATFORM_IO_FILESYSTEM_H + +namespace mp4v2 { namespace platform { namespace io { + +/////////////////////////////////////////////////////////////////////////////// +/// +/// General file-system abstraction. +/// +/// FileSystem abstracts operations on files and directories. +/// +/////////////////////////////////////////////////////////////////////////////// +class MP4V2_EXPORT FileSystem +{ +public: + static string DIR_SEPARATOR; //!< separator string used in file pathnames + static string PATH_SEPARATOR; //!< separator string used in search-paths + + /////////////////////////////////////////////////////////////////////////// + //! + //! Query file presence. + //! Check if <b>name</b> exists. + //! @param name filename to query. + //! @return true if present, false otherwise. + //! + /////////////////////////////////////////////////////////////////////////// + + static bool exists( std::string name ); + + /////////////////////////////////////////////////////////////////////////// + //! + //! Query directory type. + //! Check if <b>name</b> exists and is a directory. + //! @param name pathname to query. + //! @return true if directory, false otherwise. + //! + /////////////////////////////////////////////////////////////////////////// + + static bool isDirectory( std::string name ); + + /////////////////////////////////////////////////////////////////////////// + //! + //! Query file type. + //! Check if <b>name</b> exists and is a file. + //! @param name filename to query. + //! @return true if file, false otherwise. + //! + /////////////////////////////////////////////////////////////////////////// + + static bool isFile( std::string name ); + + /////////////////////////////////////////////////////////////////////////// + //! + //! Query file size. + //! Check if <b>name</b> exists and is a file. + //! @param name filename to query. + //! @param size output indicating file size in bytes. + //! @return true on failure, false on success. + //! + /////////////////////////////////////////////////////////////////////////// + + static bool getFileSize( std::string name, File::Size& size ); + + /////////////////////////////////////////////////////////////////////////// + //! + //! Rename file or directory. + //! + //! Rename <b>oldname</b> to <b>newname</b>. + //! If <b>newname</b> exists, it is first removed. + //! Both <b>oldname</b> and <b>newname</b> must be of the same type; + //! that is, both must be either files or directories and must reside on + //! the same filesystem. + //! + //! @param oldname existing pathname to rename. + //! @param newname new pathname. + //! + //! @return true on failure, false on success. + //! + /////////////////////////////////////////////////////////////////////////// + + static bool rename( std::string oldname, std::string newname ); + + /////////////////////////////////////////////////////////////////////////// + //! + //! Generate temporary pathname. + //! + //! @param name output containing generated pathname. + //! @param dir relative or absolute directory of pathname. + //! @param prefix text prepended to base pathname. + //! @param suffix text appended to base pathname. + //! + /////////////////////////////////////////////////////////////////////////// + + static void pathnameTemp( string& name, string dir = ".", string prefix = "tmp", string suffix = "" ); + + /////////////////////////////////////////////////////////////////////////// + //! + //! Cleanup pathname. + //! + //! Redundant (repeating) directory-separators are folded into a single + //! directory-separator. + //! + //! Redundant /./ are folded into a single directory-separator. + //! + //! @param name pathname to modify. + //! + /////////////////////////////////////////////////////////////////////////// + + static void pathnameCleanup( string& name ); + +#if 0 +TODO-KB: implement + /////////////////////////////////////////////////////////////////////////// + //! + //! Remove everything after the last directory component. + //! + //! A pathname cleanup is always performed. See pathnameCleanup(). + //! If no directory component is present then "." is assumed. + //! + //! @param name pathname to modify. + //! @param trailing when true all results are suffixed with exactly one + //! directory-separator, otherwise the result is guaranteed to not + //! end in a directory-separator. + //! + /////////////////////////////////////////////////////////////////////////// + static void pathnameOnlyDirectory( string& name, bool trailing = true ); + + /////////////////////////////////////////////////////////////////////////// + //! + //! Remove everything except the file component of pathname. + //! + //! A pathname cleanup is always performed. See pathnameCleanup(). + //! If no file component exists then an empty-string is output. + //! A file component may include an extension. + //! + //! @param name pathname to modify. + //! + /////////////////////////////////////////////////////////////////////////// + static void pathnameOnlyFile( string& name ); + + /////////////////////////////////////////////////////////////////////////// + //! + //! Remove everything except file basename. + //! + //! A pathname cleanup is always performed. See pathnameCleanup(). + //! A basename is considered to be everything before the last '.' + //! in the file component of a pathname. + //! If no file extension exists then an empty-string is output. + //! + //! @param name pathname to modify. + //! + /////////////////////////////////////////////////////////////////////////// + static void pathnameOnlyBasename( string& name ); +#endif + + /////////////////////////////////////////////////////////////////////////// + //! + //! Remove everything except file extension. + //! + //! A pathname cleanup is always performed. See pathnameCleanup(). + //! A file extension is considered to everything <b>after</b> + //! the last '.' in the file component of a pathname. + //! If no file extension exists then an empty-string is output. + //! + //! @param name pathname to modify. + //! + /////////////////////////////////////////////////////////////////////////// + + static void pathnameOnlyExtension( string& name ); + + /////////////////////////////////////////////////////////////////////////// + //! + //! Remove file extension from pathname. + //! + //! A pathname cleanup is always performed. See pathnameCleanup(). + //! A file extension is considered to everything <b>after</b> + //! the last '.' in the file component of a pathname. + //! The last '.' is also removed. + //! + //! @param name pathname to modify. + //! + /////////////////////////////////////////////////////////////////////////// + + static void pathnameStripExtension( string& name ); +}; + +/////////////////////////////////////////////////////////////////////////////// + +}}} // namespace mp4v2::platform::io + +#endif // MP4V2_PLATFORM_IO_FILESYSTEM_H diff --git a/libplatform/io/FileSystem_posix.cpp b/libplatform/io/FileSystem_posix.cpp new file mode 100644 index 0000000..46cf933 --- /dev/null +++ b/libplatform/io/FileSystem_posix.cpp @@ -0,0 +1,65 @@ +#include "libplatform/impl.h" +#include <sys/stat.h> + +namespace mp4v2 { namespace platform { namespace io { + +/////////////////////////////////////////////////////////////////////////////// + +bool +FileSystem::exists( string path_ ) +{ + struct stat buf; + return stat( path_.c_str(), &buf ) == 0; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +FileSystem::isDirectory( string path_ ) +{ + struct stat buf; + if( stat( path_.c_str(), &buf )) + return false; + return S_ISDIR( buf.st_mode ); +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +FileSystem::isFile( string path_ ) +{ + struct stat buf; + if( stat( path_.c_str(), &buf )) + return false; + return S_ISREG( buf.st_mode ); +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +FileSystem::getFileSize( string path_, File::Size& size_ ) +{ + size_ = 0; + struct stat buf; + if( stat( path_.c_str(), &buf )) + return true; + size_ = buf.st_size; + return false; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +FileSystem::rename( string from, string to ) +{ + return ::rename( from.c_str(), to.c_str() ) != 0; +} + +/////////////////////////////////////////////////////////////////////////////// + +string FileSystem::DIR_SEPARATOR = "/"; +string FileSystem::PATH_SEPARATOR = ":"; + +/////////////////////////////////////////////////////////////////////////////// + +}}} // namespace mp4v2::platform::io diff --git a/libplatform/io/FileSystem_win32.cpp b/libplatform/io/FileSystem_win32.cpp new file mode 100644 index 0000000..c223dfd --- /dev/null +++ b/libplatform/io/FileSystem_win32.cpp @@ -0,0 +1,85 @@ +#include "libplatform/impl.h" + +namespace mp4v2 { namespace platform { namespace io { + +/////////////////////////////////////////////////////////////////////////////// + +bool +FileSystem::exists( string path_ ) +{ + WIN32_FIND_DATAA buf; + HANDLE h = FindFirstFileA( path_.c_str(), &buf ); + if( h == INVALID_HANDLE_VALUE ) + return false; + FindClose( h ); + return true; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +FileSystem::isDirectory( string path_ ) +{ + WIN32_FIND_DATAA buf; + HANDLE h = FindFirstFileA( path_.c_str(), &buf ); + if( h == INVALID_HANDLE_VALUE ) + return false; + FindClose( h ); + return (buf.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +FileSystem::isFile( string path_ ) +{ + WIN32_FIND_DATAA buf; + HANDLE h = FindFirstFileA( path_.c_str(), &buf ); + if( h == INVALID_HANDLE_VALUE ) + return false; + FindClose( h ); + return (buf.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +FileSystem::getFileSize( string path_, File::Size& size_ ) +{ + size_ = 0; + WIN32_FILE_ATTRIBUTE_DATA data; + +#ifdef AMBIENT_CHAR_INSTEAD_OF_UTF8 + if( !GetFileAttributesExA( path_.c_str(), GetFileExInfoStandard, (LPVOID)&data )) + return true; +#else + wchar_t buffer[MAX_PATH + 1]; + MultiByteToWideChar(CP_UTF8, 0, path_.c_str(), -1, buffer, (int) MAX_PATH); + if( !GetFileAttributesExW(buffer, GetFileExInfoStandard, (LPVOID)&data )) + return true; +#endif + + size_ = ((File::Size)data.nFileSizeHigh << 32) | data.nFileSizeLow; + return false; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +FileSystem::rename( string from, string to ) +{ + if( exists( to )) { + if( ::remove( to.c_str() )) + return true; + } + return ::rename( from.c_str(), to.c_str() ) != 0; +} + +/////////////////////////////////////////////////////////////////////////////// + +string FileSystem::DIR_SEPARATOR = "\\"; +string FileSystem::PATH_SEPARATOR = ";"; + +/////////////////////////////////////////////////////////////////////////////// + +}}} // namespace mp4v2::platform::io diff --git a/libplatform/io/File_posix.cpp b/libplatform/io/File_posix.cpp new file mode 100644 index 0000000..b6fb214 --- /dev/null +++ b/libplatform/io/File_posix.cpp @@ -0,0 +1,109 @@ +#include "libplatform/impl.h" + +namespace mp4v2 { namespace platform { namespace io { + +/////////////////////////////////////////////////////////////////////////////// + +class StandardFileProvider : public FileProvider +{ +public: + StandardFileProvider(); + + bool open( std::string name, Mode mode ); + bool seek( Size pos ); + bool read( void* buffer, Size size, Size& nin, Size maxChunkSize ); + bool write( const void* buffer, Size size, Size& nout, Size maxChunkSize ); + bool close(); + +private: + bool _seekg; + bool _seekp; + std::fstream _fstream; +}; + +/////////////////////////////////////////////////////////////////////////////// + +StandardFileProvider::StandardFileProvider() + : _seekg ( false ) + , _seekp ( false ) +{ +} + +bool +StandardFileProvider::open( std::string name, Mode mode ) +{ + ios::openmode om = ios::binary; + switch( mode ) { + case MODE_UNDEFINED: + case MODE_READ: + default: + om |= ios::in; + _seekg = true; + _seekp = false; + break; + + case MODE_MODIFY: + om |= ios::in | ios::out; + _seekg = true; + _seekp = true; + break; + + case MODE_CREATE: + om |= ios::in | ios::out | ios::trunc; + _seekg = true; + _seekp = true; + break; + } + + _fstream.open( name.c_str(), om ); + return _fstream.fail(); +} + +bool +StandardFileProvider::seek( Size pos ) +{ + if( _seekg ) + _fstream.seekg( pos, ios::beg ); + if( _seekp ) + _fstream.seekp( pos, ios::beg ); + return _fstream.fail(); +} + +bool +StandardFileProvider::read( void* buffer, Size size, Size& nin, Size maxChunkSize ) +{ + _fstream.read( (char*)buffer, size ); + if( _fstream.fail() ) + return true; + nin = _fstream.gcount(); + return false; +} + +bool +StandardFileProvider::write( const void* buffer, Size size, Size& nout, Size maxChunkSize ) +{ + _fstream.write( (const char*)buffer, size ); + if( _fstream.fail() ) + return true; + nout = size; + return false; +} + +bool +StandardFileProvider::close() +{ + _fstream.close(); + return _fstream.fail(); +} + +/////////////////////////////////////////////////////////////////////////////// + +FileProvider& +FileProvider::standard() +{ + return *new StandardFileProvider(); +} + +/////////////////////////////////////////////////////////////////////////////// + +}}} // namespace mp4v2::platform::io diff --git a/libplatform/io/File_win32.cpp b/libplatform/io/File_win32.cpp new file mode 100644 index 0000000..7d63787 --- /dev/null +++ b/libplatform/io/File_win32.cpp @@ -0,0 +1,114 @@ +#include "libplatform/impl.h" + +namespace mp4v2 { namespace platform { namespace io { + +/////////////////////////////////////////////////////////////////////////////// + +class StandardFileProvider : public FileProvider +{ +public: + StandardFileProvider(); + + bool open( std::string name, Mode mode ); + bool seek( Size pos ); + bool read( void* buffer, Size size, Size& nin, Size maxChunkSize ); + bool write( const void* buffer, Size size, Size& nout, Size maxChunkSize ); + bool close(); + +private: + HANDLE _handle; +}; + +/////////////////////////////////////////////////////////////////////////////// + +StandardFileProvider::StandardFileProvider() + : _handle( INVALID_HANDLE_VALUE ) +{ +} + +bool +StandardFileProvider::open( std::string name, Mode mode ) +{ + DWORD access = 0; + DWORD share = 0; + DWORD crdisp = 0; + DWORD flags = FILE_ATTRIBUTE_NORMAL; + + switch( mode ) { + case MODE_UNDEFINED: + case MODE_READ: + default: + access |= GENERIC_READ; + share |= FILE_SHARE_READ; + crdisp |= OPEN_EXISTING; + break; + + case MODE_MODIFY: + access |= GENERIC_READ | GENERIC_WRITE; + share |= FILE_SHARE_READ; + crdisp |= OPEN_EXISTING; + break; + + case MODE_CREATE: + access |= GENERIC_READ | GENERIC_WRITE; + share |= FILE_SHARE_READ; + crdisp |= CREATE_ALWAYS; + break; + } + +#ifdef AMBIENT_CHAR_INSTEAD_OF_UTF8 + _handle = CreateFileA( name.c_str(), access, share, NULL, crdisp, flags, NULL ); +#else + wchar_t buffer[MAX_PATH + 1]; + MultiByteToWideChar(CP_UTF8, 0, name.c_str(), -1, buffer, (int) MAX_PATH); + _handle = CreateFileW( buffer, access, share, NULL, crdisp, flags, NULL ); +#endif + + return _handle == INVALID_HANDLE_VALUE; +} + +bool +StandardFileProvider::seek( Size pos ) +{ + LARGE_INTEGER n; + n.QuadPart = pos; + return SetFilePointerEx( _handle, n, NULL, FILE_BEGIN ) == 0; +} + +bool +StandardFileProvider::read( void* buffer, Size size, Size& nin, Size maxChunkSize ) +{ + DWORD nread = 0; + if( ReadFile( _handle, buffer, (DWORD)size, &nread, NULL ) == 0 ) + return true; + nin = nread; + return false; +} + +bool +StandardFileProvider::write( const void* buffer, Size size, Size& nout, Size maxChunkSize ) +{ + DWORD nwrote = 0; + if( WriteFile( _handle, buffer, (DWORD)size, &nwrote, NULL ) == 0 ) + return true; + nout = nwrote; + return false; +} + +bool +StandardFileProvider::close() +{ + return CloseHandle( _handle ) == 0; +} + +/////////////////////////////////////////////////////////////////////////////// + +FileProvider& +FileProvider::standard() +{ + return *new StandardFileProvider(); +} + +/////////////////////////////////////////////////////////////////////////////// + +}}} // namespace mp4v2::platform::io diff --git a/libplatform/number/random.h b/libplatform/number/random.h new file mode 100644 index 0000000..9d0f105 --- /dev/null +++ b/libplatform/number/random.h @@ -0,0 +1,18 @@ +#ifndef MP4V2_PLATFORM_NUMBER_RANDOM_H +#define MP4V2_PLATFORM_NUMBER_RANDOM_H + +namespace mp4v2 { namespace platform { namespace number { + +/////////////////////////////////////////////////////////////////////////////// + +/// Generate 32-bit pseudo-random number. +MP4V2_EXPORT uint32_t random32(); + +/// Seed pseudo-random number generator. +MP4V2_EXPORT void srandom( uint32_t ); + +/////////////////////////////////////////////////////////////////////////////// + +}}} // namespace mp4v2::platform::number + +#endif // MP4V2_PLATFORM_NUMBER_RANDOM_H diff --git a/libplatform/number/random_posix.cpp b/libplatform/number/random_posix.cpp new file mode 100644 index 0000000..0bdcd1d --- /dev/null +++ b/libplatform/number/random_posix.cpp @@ -0,0 +1,24 @@ +#include "libplatform/impl.h" +#include <stdlib.h> + +namespace mp4v2 { namespace platform { namespace number { + +/////////////////////////////////////////////////////////////////////////////// + +uint32_t +random32() +{ + return uint32_t( ::random() ); +} + +/////////////////////////////////////////////////////////////////////////////// + +void +srandom( uint32_t seed ) +{ + ::srandom( seed ); +} + +/////////////////////////////////////////////////////////////////////////////// + +}}} // namespace mp4v2::platform::time diff --git a/libplatform/number/random_win32.cpp b/libplatform/number/random_win32.cpp new file mode 100644 index 0000000..f884e5d --- /dev/null +++ b/libplatform/number/random_win32.cpp @@ -0,0 +1,24 @@ +#include "libplatform/impl.h" +#include <stdlib.h> + +namespace mp4v2 { namespace platform { namespace number { + +/////////////////////////////////////////////////////////////////////////////// + +uint32_t +random32() +{ + return uint32_t( ::rand() << 16 | ::rand() ); +} + +/////////////////////////////////////////////////////////////////////////////// + +void +srandom( uint32_t seed ) +{ + ::srand( seed ); +} + +/////////////////////////////////////////////////////////////////////////////// + +}}} // namespace mp4v2::platform::time diff --git a/libplatform/platform.h b/libplatform/platform.h new file mode 100644 index 0000000..2868f77 --- /dev/null +++ b/libplatform/platform.h @@ -0,0 +1,43 @@ +#ifndef MP4V2_PLATFORM_PLATFORM_H +#define MP4V2_PLATFORM_PLATFORM_H + +/// @namespace mp4v2::platform (private) Platform abstraction. +/// <b>WARNING: THIS IS A PRIVATE NAMESPACE. NOT FOR PUBLIC CONSUMPTION.</b> +/// +/// This namespace implements platform abstractions that are useful for +/// keeping the code base portable. + +/// @namespace mp4v2::platform::io (private) I/O. +/// <b>WARNING: THIS IS A PRIVATE NAMESPACE. NOT FOR PUBLIC CONSUMPTION.</b> + +/// @namespace mp4v2::platform::number (private) Number. +/// <b>WARNING: THIS IS A PRIVATE NAMESPACE. NOT FOR PUBLIC CONSUMPTION.</b> + +/// @namespace mp4v2::platform::sys (private) System. +/// <b>WARNING: THIS IS A PRIVATE NAMESPACE. NOT FOR PUBLIC CONSUMPTION.</b> + +/////////////////////////////////////////////////////////////////////////////// + +#if defined( _WIN32 ) +# include "libplatform/platform_win32.h" +#else +# include "libplatform/platform_posix.h" +#endif + +/////////////////////////////////////////////////////////////////////////////// + +#include "libplatform/warning.h" +#include "libplatform/endian.h" + +#include "libplatform/io/File.h" +#include "libplatform/io/FileSystem.h" + +#include "libplatform/number/random.h" +#include "libplatform/process/process.h" +#include "libplatform/prog/option.h" +#include "libplatform/sys/error.h" +#include "libplatform/time/time.h" + +/////////////////////////////////////////////////////////////////////////////// + +#endif // MP4V2_PLATFORM_PLATFORM_H diff --git a/libplatform/platform_base.h b/libplatform/platform_base.h new file mode 100644 index 0000000..5b6a263 --- /dev/null +++ b/libplatform/platform_base.h @@ -0,0 +1,34 @@ +#ifndef MP4V2_PLATFORM_BASE_H +#define MP4V2_PLATFORM_BASE_H + +/////////////////////////////////////////////////////////////////////////////// + +#include <fstream> +#include <iomanip> +#include <iostream> +#include <limits> +#include <list> +#include <locale> +#include <map> +#include <set> +#include <sstream> +#include <string> +#include <vector> + +#include <cassert> +#include <cctype> +#include <cerrno> +#include <climits> +#include <cmath> +#include <cstdarg> +#include <cstddef> +#include <cstdio> +#include <cstdlib> +#include <cstring> +#include <ctime> +#include <cwchar> +#include <cwctype> + +/////////////////////////////////////////////////////////////////////////////// + +#endif // MP4V2_PLATFORM_BASE_H diff --git a/libplatform/platform_posix.h b/libplatform/platform_posix.h new file mode 100644 index 0000000..b636e29 --- /dev/null +++ b/libplatform/platform_posix.h @@ -0,0 +1,81 @@ +#ifndef MP4V2_PLATFORM_POSIX_H +#define MP4V2_PLATFORM_POSIX_H + +/////////////////////////////////////////////////////////////////////////////// + +#include "libplatform/config.h" + +/////////////////////////////////////////////////////////////////////////////// + +// constant macros are not usually used with C++ so the standard mechanism to +// activate it is to define before stdint.h +#ifndef __STDC_CONSTANT_MACROS +# define __STDC_CONSTANT_MACROS +#endif + +// format macros are not usually used with C++ so the standard mechanism to +// activate it is to define before inttypes.h +#ifndef __STDC_FORMAT_MACROS +# define __STDC_FORMAT_MACROS +#endif + +#ifdef NEED_LFS_ACTIVATION +# ifndef _LARGEFILE_SOURCE +# define _LARGEFILE_SOURCE +# define _FILE_OFFSET_BITS 64 +# endif +#endif + +/////////////////////////////////////////////////////////////////////////////// + +#include "libplatform/platform_base.h" +#include <inttypes.h> +#include <stdint.h> +#include <fcntl.h> +#include <unistd.h> + +#include <mp4v2/mp4v2.h> + +/////////////////////////////////////////////////////////////////////////////// + +namespace mp4v2 { namespace platform { + using namespace std; + + using ::int8_t; + using ::int16_t; + using ::int32_t; + using ::int64_t; + + using ::uint8_t; + using ::uint16_t; + using ::uint32_t; + using ::uint64_t; +}} // namespace mp4v2::platform + +/////////////////////////////////////////////////////////////////////////////// + +#define MP4V2_PATH_MAX PATH_MAX + +/////////////////////////////////////////////////////////////////////////////// + +// win32 platform requires O_BINARY when using old open() calls so we add +// this harmless bit-flag for posix to avoid .cpp platform conditionals +#ifndef O_BINARY +# define O_BINARY 0 +#endif + +/////////////////////////////////////////////////////////////////////////////// + +// ARM seems to require integer instructions operands to have 4-byte alignment +// so we set this macro to for some int<->string code to manually copy string +// bytes into an int which aligns it. This is much easier than trying to +// align pertinent string data (constants) from in text sections. +#if defined( __arm__ ) +# define MP4V2_INTSTRING_ALIGNMENT 1 +#else +# undef MP4V2_INTSTRING_ALIGNMENT +#endif + +/////////////////////////////////////////////////////////////////////////////// + +#endif // MP4V2_PLATFORM_POSIX_H diff --git a/libplatform/platform_win32.h b/libplatform/platform_win32.h new file mode 100644 index 0000000..7cbd507 --- /dev/null +++ b/libplatform/platform_win32.h @@ -0,0 +1,101 @@ +#ifndef MP4V2_PLATFORM_WIN32_H +#define MP4V2_PLATFORM_WIN32_H + +/////////////////////////////////////////////////////////////////////////////// + +// mingw needs this to enable some newer 64-bit functions +#ifdef __MINGW32__ +# undef __MSVCRT_VERSION__ +# define __MSVCRT_VERSION__ 0x800 +#endif + +// set minimum win32 API requirement to Windows 2000 or higher +#ifndef _WIN32_WINNT +# define _WIN32_WINNT 0x0500 +#endif +#ifndef WINVER +# define WINVER 0x0500 +#endif + +/////////////////////////////////////////////////////////////////////////////// + +#include "libplatform/platform_base.h" +#include <windows.h> + +#include <mp4v2/mp4v2.h> + +/////////////////////////////////////////////////////////////////////////////// + +namespace mp4v2 { namespace platform { + using namespace std; + + using ::int8_t; + using ::int16_t; + using ::int32_t; + using ::int64_t; + + using ::uint8_t; + using ::uint16_t; + using ::uint32_t; + using ::uint64_t; +}} // namespace mp4v2::platform + +/////////////////////////////////////////////////////////////////////////////// + +#define MP4V2_PATH_MAX (_MAX_PATH + 1) + +/////////////////////////////////////////////////////////////////////////////// + +// fprintf macros for unsigned types - mingw32 is a good source if more needed +#define PRId8 "d" +#define PRId16 "d" +#define PRId32 "d" +#define PRId64 "I64d" + +#define PRIu8 "u" +#define PRIu16 "u" +#define PRIu32 "u" +#define PRIu64 "I64u" + +#define PRIx8 "x" +#define PRIx16 "x" +#define PRIx32 "x" +#define PRIx64 "I64x" + +/////////////////////////////////////////////////////////////////////////////// + +// some macros for constant expressions +#define INT8_C(x) x +#define INT16_C(x) x +#define INT32_C(x) x ## L +#define INT64_C(x) x ## LL + +#define UINT8_C(x) x +#define UINT16_C(x) x +#define UINT32_C(x) x ## UL +#define UINT64_C(x) x ## ULL + +/////////////////////////////////////////////////////////////////////////////// + +#ifdef min +# undef min +#endif + +#ifdef max +# undef max +#endif + +/////////////////////////////////////////////////////////////////////////////// + +#define snprintf(s,n,...) _snprintf(s,n,__VA_ARGS__) +#define strcasecmp(s1,s2) _stricmp(s1,s2) +#define strdup(s) _strdup(s) + +/////////////////////////////////////////////////////////////////////////////// + +// macro clashes with symbol +#undef LC_NONE + +/////////////////////////////////////////////////////////////////////////////// + +#endif // MP4V2_PLATFORM_WIN32_H diff --git a/libplatform/process/process.h b/libplatform/process/process.h new file mode 100644 index 0000000..446b100 --- /dev/null +++ b/libplatform/process/process.h @@ -0,0 +1,16 @@ +#ifndef MP4V2_PLATFORM_PROCESS_PROCESS_H +#define MP4V2_PLATFORM_PROCESS_PROCESS_H + +/// @namespace mp4v2::platform::process (private) Process. +/// <b>WARNING: THIS IS A PRIVATE NAMESPACE. NOT FOR PUBLIC CONSUMPTION.</b> +namespace mp4v2 { namespace platform { namespace process { + +/////////////////////////////////////////////////////////////////////////////// + +MP4V2_EXPORT int32_t getpid(); + +/////////////////////////////////////////////////////////////////////////////// + +}}} // namespace mp4v2::platform::process + +#endif // MP4V2_PLATFORM_PROCESS_PROCESS_H diff --git a/libplatform/process/process_posix.cpp b/libplatform/process/process_posix.cpp new file mode 100644 index 0000000..74b4e17 --- /dev/null +++ b/libplatform/process/process_posix.cpp @@ -0,0 +1,15 @@ +#include "libplatform/impl.h" + +namespace mp4v2 { namespace platform { namespace process { + +/////////////////////////////////////////////////////////////////////////////// + +int32_t +getpid() +{ + return ::getpid(); +} + +/////////////////////////////////////////////////////////////////////////////// + +}}} // namespace mp4v2::platform::process diff --git a/libplatform/process/process_win32.cpp b/libplatform/process/process_win32.cpp new file mode 100644 index 0000000..b784680 --- /dev/null +++ b/libplatform/process/process_win32.cpp @@ -0,0 +1,16 @@ +#include "libplatform/impl.h" +#include <process.h> + +namespace mp4v2 { namespace platform { namespace process { + +/////////////////////////////////////////////////////////////////////////////// + +int32_t +getpid() +{ + return ::_getpid(); +} + +/////////////////////////////////////////////////////////////////////////////// + +}}} // namespace mp4v2::platform::process diff --git a/libplatform/prog/option.cpp b/libplatform/prog/option.cpp new file mode 100644 index 0000000..645dccf --- /dev/null +++ b/libplatform/prog/option.cpp @@ -0,0 +1,637 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// branched from: +// FreeBSD 7.0-RELEASE +// $FreeBSD: src/lib/libc/stdlib/getopt_long.c,v 1.15 2006/09/23 14:48:31 ache Exp $ +// +/////////////////////////////////////////////////////////////////////////////// + +/* + * Copyright (c) 2002 Todd C. Miller <Todd.Miller@courtesan.com> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Sponsored in part by the Defense Advanced Research Projects + * Agency (DARPA) and Air Force Research Laboratory, Air Force + * Materiel Command, USAF, under agreement number F39502-99-1-0512. + */ +/*- + * Copyright (c) 2000 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Dieter Baron and Thomas Klausner. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "libplatform/impl.h" + +namespace mp4v2 { +namespace platform { +namespace prog { + +/////////////////////////////////////////////////////////////////////////////// + +#define GNU_COMPATIBLE +#define REPLACE_GETOPT + +namespace { + void warnx( const char* format, ... ) { + va_list ap; + va_start( ap, format ); + vfprintf( stderr, format, ap ); + va_end( ap ); + fprintf( stderr, "\n" ); + } +} + +/////////////////////////////////////////////////////////////////////////////// + +#ifdef REPLACE_GETOPT +int opterr = 1; /* if error message should be printed */ +int optind = 1; /* index into parent argv vector */ +int optopt = '?'; /* character checked for validity */ +int optreset; /* reset getopt */ +const char* optarg; /* argument associated with option */ +#endif + +#define PRINT_ERROR ((opterr) && (*options != ':')) + +#define FLAG_PERMUTE 0x01 // permute non-options to the end of argv +#define FLAG_ALLARGS 0x02 // treat non-options as args to option "-1" +#define FLAG_LONGONLY 0x04 // operate as getopt_long_only + +// return values +#define BADCH (int)'?' +#define BADARG ((*options == ':') ? (int)':' : (int)'?') +#define INORDER (int)1 + +#define EMSG "" + +#ifdef GNU_COMPATIBLE +#define NO_PREFIX (-1) +#define D_PREFIX 0 +#define DD_PREFIX 1 +#define W_PREFIX 2 +#endif + +static int getopt_internal(int, char * const *, const char *, const Option*, int*, int); +static int parse_long_options(char * const *, const char *, const Option*, int *, int, int); +static int gcd(int, int); +static void permute_args(int, int, int, char * const *); + +static const char *place = EMSG; /* option letter processing */ + +/* XXX: set optreset to 1 rather than these two */ +static int nonopt_start = -1; /* first non option argument (for permute) */ +static int nonopt_end = -1; /* first option after non options (for permute) */ + +/* Error messages */ +static const char recargchar[] = "option requires an argument -- %c"; +static const char illoptchar[] = "illegal option -- %c"; /* From P1003.2 */ +#ifdef GNU_COMPATIBLE +static int dash_prefix = NO_PREFIX; +static const char gnuoptchar[] = "invalid option -- %c"; + +static const char recargstring[] = "option `%s%s' requires an argument"; +static const char ambig[] = "option `%s%.*s' is ambiguous"; +static const char noarg[] = "option `%s%.*s' doesn't allow an argument"; +static const char illoptstring[] = "unrecognized option `%s%s'"; +#else +static const char recargstring[] = "option requires an argument -- %s"; +static const char ambig[] = "ambiguous option -- %.*s"; +static const char noarg[] = "option doesn't take an argument -- %.*s"; +static const char illoptstring[] = "unknown option -- %s"; +#endif + +/* + * Compute the greatest common divisor of a and b. + */ +static int +gcd(int a, int b) { + int c; + + c = a % b; + while (c != 0) { + a = b; + b = c; + c = a % b; + } + + return (b); +} + +/* + * Exchange the block from nonopt_start to nonopt_end with the block + * from nonopt_end to opt_end (keeping the same order of arguments + * in each block). + */ +static void +permute_args(int panonopt_start, int panonopt_end, int opt_end, + char * const *nargv) { + int cstart, cyclelen, i, j, ncycle, nnonopts, nopts, pos; + char *swap; + + /* + * compute lengths of blocks and number and size of cycles + */ + nnonopts = panonopt_end - panonopt_start; + nopts = opt_end - panonopt_end; + ncycle = gcd(nnonopts, nopts); + cyclelen = (opt_end - panonopt_start) / ncycle; + + for (i = 0; i < ncycle; i++) { + cstart = panonopt_end+i; + pos = cstart; + for (j = 0; j < cyclelen; j++) { + if (pos >= panonopt_end) + pos -= nnonopts; + else + pos += nopts; + swap = nargv[pos]; + /* LINTED const cast */ + ((char **) nargv)[pos] = nargv[cstart]; + /* LINTED const cast */ + ((char **)nargv)[cstart] = swap; + } + } +} + +/* + * parse_long_options -- + * Parse long options in argc/argv argument vector. + * Returns -1 if short_too is set and the option does not match long_options. + */ +static int +parse_long_options(char * const *nargv, const char *options, + const Option* long_options, int* idx, int short_too, int flags) { + const char *current_argv; + char *has_equal; +#ifdef GNU_COMPATIBLE + const char *current_dash; +#endif + size_t current_argv_len; + int i, match, exact_match, second_partial_match; + + current_argv = place; +#ifdef GNU_COMPATIBLE + switch (dash_prefix) { + case D_PREFIX: + current_dash = "-"; + break; + case DD_PREFIX: + current_dash = "--"; + break; + case W_PREFIX: + current_dash = "-W "; + break; + default: + current_dash = ""; + break; + } +#endif + match = -1; + exact_match = 0; + second_partial_match = 0; + + optind++; + + if ((has_equal = (char*)strchr(current_argv, '=')) != NULL) { + /* argument found (--option=arg) */ + current_argv_len = has_equal - current_argv; + has_equal++; + } + else + current_argv_len = strlen(current_argv); + + for (i = 0; long_options[i].name; i++) { + /* find matching long option */ + if (strncmp(current_argv, long_options[i].name, + current_argv_len)) + continue; + + if (strlen(long_options[i].name) == current_argv_len) { + /* exact match */ + match = i; + exact_match = 1; + break; + } + /* + * If this is a known short option, don't allow + * a partial match of a single character. + */ + if (short_too && current_argv_len == 1) + continue; + + if (match == -1) /* first partial match */ + match = i; + else if ((flags & FLAG_LONGONLY) || + long_options[i].type != + long_options[match].type || + long_options[i].flag != long_options[match].flag || + long_options[i].val != long_options[match].val) + second_partial_match = 1; + } + if (!exact_match && second_partial_match) { + /* ambiguous abbreviation */ + if (PRINT_ERROR) + warnx(ambig, +#ifdef GNU_COMPATIBLE + current_dash, +#endif + (int)current_argv_len, + current_argv); + optopt = 0; + return (BADCH); + } + if (match != -1) { /* option found */ + if (long_options[match].type == Option::NO_ARG + && has_equal) { + if (PRINT_ERROR) + warnx(noarg, +#ifdef GNU_COMPATIBLE + current_dash, +#endif + (int)current_argv_len, + current_argv); + /* + * XXX: GNU sets optopt to val regardless of flag + */ + if (long_options[match].flag == NULL) + optopt = long_options[match].val; + else + optopt = 0; +#ifdef GNU_COMPATIBLE + return (BADCH); +#else + return (BADARG); +#endif + } + if (long_options[match].type == Option::REQUIRED_ARG || + long_options[match].type == Option::OPTIONAL_ARG) { + if (has_equal) + optarg = has_equal; + else if (long_options[match].type == Option::REQUIRED_ARG) { + /* + * optional argument doesn't use next nargv + */ + optarg = nargv[optind++]; + } + } + if ((long_options[match].type == Option::REQUIRED_ARG) + && (optarg == NULL)) { + /* + * Missing argument; leading ':' indicates no error + * should be generated. + */ + if (PRINT_ERROR) + warnx(recargstring, +#ifdef GNU_COMPATIBLE + current_dash, +#endif + current_argv); + /* + * XXX: GNU sets optopt to val regardless of flag + */ + if (long_options[match].flag == NULL) + optopt = long_options[match].val; + else + optopt = 0; + --optind; + return (BADARG); + } + } + else { /* unknown option */ + if (short_too) { + --optind; + return (-1); + } + if (PRINT_ERROR) + warnx(illoptstring, +#ifdef GNU_COMPATIBLE + current_dash, +#endif + current_argv); + optopt = 0; + return (BADCH); + } + if (idx) + *idx = match; + if (long_options[match].flag) { + *long_options[match].flag = long_options[match].val; + return (0); + } + else + return (long_options[match].val); +} + +/* + * getopt_internal -- + * Parse argc/argv argument vector. Called by user level routines. + */ +static int +getopt_internal(int nargc, char * const *nargv, const char *options, + const Option* long_options, int* idx, int flags) { + const char *oli; /* option letter list index */ + int optchar, short_too; + int posixly_correct; /* no static, can be changed on the fly */ + + if (options == NULL) + return (-1); + + /* + * Disable GNU extensions if POSIXLY_CORRECT is set or options + * string begins with a '+'. + */ + posixly_correct = (getenv("POSIXLY_CORRECT") != NULL); +#ifdef GNU_COMPATIBLE + if (*options == '-') + flags |= FLAG_ALLARGS; + else if (posixly_correct || *options == '+') + flags &= ~FLAG_PERMUTE; +#else + if (posixly_correct || *options == '+') + flags &= ~FLAG_PERMUTE; + else if (*options == '-') + flags |= FLAG_ALLARGS; +#endif + if (*options == '+' || *options == '-') + options++; + + /* + * XXX Some GNU programs (like cvs) set optind to 0 instead of + * XXX using optreset. Work around this braindamage. + */ + if (optind == 0) + optind = optreset = 1; + + optarg = NULL; + if (optreset) + nonopt_start = nonopt_end = -1; +start: + if (optreset || !*place) { /* update scanning pointer */ + optreset = 0; + if (optind >= nargc) { /* end of argument vector */ + place = EMSG; + if (nonopt_end != -1) { + /* do permutation, if we have to */ + permute_args(nonopt_start, nonopt_end, + optind, nargv); + optind -= nonopt_end - nonopt_start; + } + else if (nonopt_start != -1) { + /* + * If we skipped non-options, set optind + * to the first of them. + */ + optind = nonopt_start; + } + nonopt_start = nonopt_end = -1; + return (-1); + } + if (*(place = nargv[optind]) != '-' || +#ifdef GNU_COMPATIBLE + place[1] == '\0') { +#else + (place[1] == '\0' && strchr(options, '-') == NULL)) { +#endif + place = EMSG; /* found non-option */ + if (flags & FLAG_ALLARGS) { + /* + * GNU extension: + * return non-option as argument to option 1 + */ + optarg = nargv[optind++]; + return (INORDER); + } + if (!(flags & FLAG_PERMUTE)) { + /* + * If no permutation wanted, stop parsing + * at first non-option. + */ + return (-1); + } + /* do permutation */ + if (nonopt_start == -1) + nonopt_start = optind; + else if (nonopt_end != -1) { + permute_args(nonopt_start, nonopt_end, + optind, nargv); + nonopt_start = optind - + (nonopt_end - nonopt_start); + nonopt_end = -1; + } + optind++; + /* process next argument */ + goto start; + } + if (nonopt_start != -1 && nonopt_end == -1) + nonopt_end = optind; + + /* + * If we have "-" do nothing, if "--" we are done. + */ + if (place[1] != '\0' && *++place == '-' && place[1] == '\0') { + optind++; + place = EMSG; + /* + * We found an option (--), so if we skipped + * non-options, we have to permute. + */ + if (nonopt_end != -1) { + permute_args(nonopt_start, nonopt_end, + optind, nargv); + optind -= nonopt_end - nonopt_start; + } + nonopt_start = nonopt_end = -1; + return (-1); + } + } + + /* + * Check long options if: + * 1) we were passed some + * 2) the arg is not just "-" + * 3) either the arg starts with -- we are getopt_long_only() + */ + if (long_options != NULL && place != nargv[optind] && + (*place == '-' || (flags & FLAG_LONGONLY))) { + short_too = 0; +#ifdef GNU_COMPATIBLE + dash_prefix = D_PREFIX; +#endif + if (*place == '-') { + place++; /* --foo long option */ +#ifdef GNU_COMPATIBLE + dash_prefix = DD_PREFIX; +#endif + } + else if (*place != ':' && strchr(options, *place) != NULL) + short_too = 1; /* could be short option too */ + + optchar = parse_long_options(nargv, options, long_options, + idx, short_too, flags); + if (optchar != -1) { + place = EMSG; + return (optchar); + } + } + + if ((optchar = (int)*place++) == (int)':' || + (optchar == (int)'-' && *place != '\0') || + (oli = (const char*)strchr(options, optchar)) == NULL) { + /* + * If the user specified "-" and '-' isn't listed in + * options, return -1 (non-option) as per POSIX. + * Otherwise, it is an unknown option character (or ':'). + */ + if (optchar == (int)'-' && *place == '\0') + return (-1); + if (!*place) + ++optind; +#ifdef GNU_COMPATIBLE + if (PRINT_ERROR) + warnx(posixly_correct ? illoptchar : gnuoptchar, + optchar); +#else + if (PRINT_ERROR) + warnx(illoptchar, optchar); +#endif + optopt = optchar; + return (BADCH); + } + if (long_options != NULL && optchar == 'W' && oli[1] == ';') { + /* -W long-option */ + if (*place) /* no space */ + /* NOTHING */; + else if (++optind >= nargc) { /* no arg */ + place = EMSG; + if (PRINT_ERROR) + warnx(recargchar, optchar); + optopt = optchar; + return (BADARG); + } + else /* white space */ + place = nargv[optind]; +#ifdef GNU_COMPATIBLE + dash_prefix = W_PREFIX; +#endif + optchar = parse_long_options(nargv, options, long_options, + idx, 0, flags); + place = EMSG; + return (optchar); + } + if (*++oli != ':') { /* doesn't take argument */ + if (!*place) + ++optind; + } + else { /* takes (optional) argument */ + optarg = NULL; + if (*place) /* no white space */ + optarg = place; + else if (oli[1] != ':') { /* arg not optional */ + if (++optind >= nargc) { /* no arg */ + place = EMSG; + if (PRINT_ERROR) + warnx(recargchar, optchar); + optopt = optchar; + return (BADARG); + } + else + optarg = nargv[optind]; + } + place = EMSG; + ++optind; + } + /* dump back option letter */ + return (optchar); +} + +#if 0 +#ifdef REPLACE_GETOPT +/* + * getopt -- + * Parse argc/argv argument vector. + * + * [eventually this will replace the BSD getopt] + */ +int +getopt(int nargc, char * const *nargv, const char *options) { + + /* + * We don't pass FLAG_PERMUTE to getopt_internal() since + * the BSD getopt(3) (unlike GNU) has never done this. + * + * Furthermore, since many privileged programs call getopt() + * before dropping privileges it makes sense to keep things + * as simple (and bug-free) as possible. + */ + return (getopt_internal(nargc, nargv, options, NULL, NULL, 0)); +} +#endif /* REPLACE_GETOPT */ +#endif + +/* + * getopt_long -- + * Parse argc/argv argument vector. + */ +int +getOption(int nargc, char * const *nargv, const char *options, + const Option* long_options, int* idx) { + + return (getopt_internal(nargc, nargv, options, long_options, idx, + FLAG_PERMUTE)); +} + +/* + * getopt_long_only -- + * Parse argc/argv argument vector. + */ +int +getOptionSingle(int nargc, char * const *nargv, const char *options, + const Option* long_options, int* idx) { + + return (getopt_internal(nargc, nargv, options, long_options, idx, + FLAG_PERMUTE|FLAG_LONGONLY)); +} + +/////////////////////////////////////////////////////////////////////////////// + +}}} // namespace mp4v2::platform::prog diff --git a/libplatform/prog/option.h b/libplatform/prog/option.h new file mode 100644 index 0000000..9f7a82a --- /dev/null +++ b/libplatform/prog/option.h @@ -0,0 +1,174 @@ +#ifndef MP4V2_PLATFORM_PROG_OPTION_H +#define MP4V2_PLATFORM_PROG_OPTION_H + +/////////////////////////////////////////////////////////////////////////////// +/// +/// @namespace mp4v2::platform::prog Command-line argument parsing. +/// <b>WARNING: THIS IS A PRIVATE NAMESPACE. NOT FOR PUBLIC CONSUMPTION.</b> +/// +/// This namespace provides a mechanism to parse command-line arguments and +/// options for executables. +/// It is identical in behavior to <b>getopt_long</b> functions available +/// with many popular posix-platforms such as Darwin, FreeBSD and Linux. +/// Virtually any OS which has getopt_long will adequately document this +/// functionality. However, to avoid symbol ambiguity with the popular +/// posix implementation, the following identifiers have been renamed: +/// @li getopt_long() -> getOption() +/// @li getopt_long_only() -> getOptionSingle() +/// @li option -> Option +/// @li option.has_arg -> Option.type +//! +/////////////////////////////////////////////////////////////////////////////// +namespace mp4v2 { namespace platform { namespace prog { + +//! On return from getOption() or getOptionSingle(), +//! points to an option argument, if it is anticipated. +MP4V2_EXPORT extern const char* optarg; + +//! On return from getOption() or getOptionSingle(), +//! contains the index to the next argv argument for a subsequent call to +//! getOption() or getOptionSingle(). +//! Initialized to 1 and must be set manually to 1 prior to invoking +//! getOption() or getOptionSingle() to evaluate multiple sets of arguments. +MP4V2_EXPORT extern int optind; + +//! On return from getOption() or getOptionSingle(), +//! saves the last known option character returned by +//! getOption() or getOptionSingle(). +//! On error, contains the character/code of option which caused error. +MP4V2_EXPORT extern int optopt; + +//! Initialized to 1 and may be set to 0 to disable error messages. +MP4V2_EXPORT extern int opterr; + +//! Must be set to 1 before evaluating the 2nd or each additional set +//! of arguments. +MP4V2_EXPORT extern int optreset; + +//! Structure describing a single option. +//! An instance of Option is required for each program option and is +//! initialized before use with getOption() or getOptionWord(). +struct MP4V2_EXPORT Option +{ + //! expectation-type indicating number of arguments expected + //! on the command-line following the option-argument itself + enum Type { + //! indicates exactly 0 arguments follow option + NO_ARG, + //! indicates exactly 1 argument follow option + REQUIRED_ARG, + //! indicates 0 or 1 arguments follow option + OPTIONAL_ARG, + }; + + //! contains the option name without leading double-dash + const char* name; + + //! option expectation-type + Type type; + + //! If not NULL, then the integer pointed to by it will be set to + //! the value in the val field. If the flag field is NULL, then the + //! <b>val</b> field will be returned. + int* flag; + + //! Constant value representing option. This is usually a single-char + //! ASCII value but in case of long-options without a corresponding + //! single-char value it can be a unique integer (beyond ASCII range) + //! which represents the long-option. + int val; +}; + +/////////////////////////////////////////////////////////////////////////////// +//! +//! Get option character from command line argument list. +//! +//! getOption() is similar to posix getopt() but it accepts options in two +//! forms: words and characters. The getOption() function provides a +//! superset of the functionality of getopt(). The getOption() function can +//! be used in two ways. In the first way, every long-option understood by +//! the program has a corresponding short-option, and the Option structure +//! is only used to translate from long-options to short-options. When used +//! in this fashion, getOption() behaves identically to getopt(). This is +//! a good way to add long-option processing to an esxisting program with +//! a minimum of rewriting. +//! +//! In the second mechanism, a long-option sets a flag in the Option +//! structure structure passed, or will store a pointer to the command line +//! argument in the Option structure passed to it for options that take +//! arguments. Additionally, the long-option's argument may be specified as +//! a single argument with an equal sign, eg: +//! @code myprogram --myoption=somevalue +//! @endcode +//! +//! When a long-option is processed, the call to getOption() will return 0. +//! For this reason, long-option processing without shortcuts is not +//! backwards compatible with getopt(). +//! +//! It is possible to combine these methods, providing for long-options +//! processing with short-option equivalents for some options. Less +//! frequently used options would be processed as long-options only. +//! +//! @param argc number of arguments. +//! @param argv argument array of strings. +//! @param optstr string containing the following elements: +//! individual characters, and characters followed by a colon to indicate +//! an option argument is to follow. For example, an option string "x" +//! recognizes an option "-x", and an option string "x:" recognizes an +//! option and argument "-x argument". +//! @param longopts array of Option entries. The last element must be filled +//! with zeroes to indicate end-of-array. +//! @param idx If not NULL, then the integer pointed to it will be set to +//! the index of the long-option relative to <b>longops</b>. +//! +//! @return If the <b>flag</b> field is NULL, <b>val</b> field is returned, +//! which is usually just the corresponding short-option. +//! If <b>flag</b> is not NULL, 0 is returned and <b>val</b> is +//! stored in the location pointed to by <b>flag</b> field. +//! A ':' will be returned if there was a missing option argument. +//! A '?' will be returned if an unknown or ambiguous option was used. +//! A -1 will be returned when the argument list has been exhausted. +//! +/////////////////////////////////////////////////////////////////////////////// +MP4V2_EXPORT +int getOption( int argc, char* const* argv, const char* optstr, const Option* longopts, int* idx ); + +/////////////////////////////////////////////////////////////////////////////// +//! +//! Get option character from command line argument list and allow +//! long-options with single-hyphens. +//! +//! Behaves identically to getOption() with the exception that long-options +//! may start with '-' in addition to '--'. +//! If an option starting with '-' does not match a long option but does match +//! a single-character option, the single-character option is returned. +//! +//! @param argc number of arguments. +//! @param argv argument array of strings. +//! @param optstr string containing the following elements: +//! individual characters, and characters followed by a colon to indicate +//! an option argument is to follow. For example, an option string "x" +//! recognizes an option "-x", and an option string "x:" recognizes an +//! option and argument "-x argument". +//! @param longopts array of Option entries. The last element must be filled +//! with zeroes to indicate end-of-array. +//! @param idx If not NULL, then the integer pointed to it will be set to +//! the index of the long-option relative to <b>longops</b>. +//! +//! @return If the <b>flag</b> field is NULL, <b>val</b> field is returned, +//! which is usually just the corresponding short-option. +//! If <b>flag</b> is not NULL, 0 is returned and <b>val</b> is +//! stored in the location pointed to by <b>flag</b> field. +//! A ':' will be returned if there was a missing option argument. +//! A '?' will be returned if an unknown or ambiguous option was used. +//! A -1 will be returned when the argument list has been exhausted. +//! +/////////////////////////////////////////////////////////////////////////////// +MP4V2_EXPORT +int getOptionSingle( int argc, char* const* argv, const char* optstr, const Option* longopts, int* idx ); + +/////////////////////////////////////////////////////////////////////////////// + +}}} // namespace mp4v2::platform::prog + +#endif // MP4V2_PLATFORM_PROG_OPTION_H diff --git a/libplatform/sys/error.cpp b/libplatform/sys/error.cpp new file mode 100644 index 0000000..094ace1 --- /dev/null +++ b/libplatform/sys/error.cpp @@ -0,0 +1,31 @@ +#include "libplatform/impl.h" + +namespace mp4v2 { namespace platform { namespace sys { + +/////////////////////////////////////////////////////////////////////////////// + +const char* +getErrorStr( int errno_ ) +{ + return std::strerror( errno_ ); +} + +/////////////////////////////////////////////////////////////////////////////// + +int +getLastError() +{ + return errno; +} + +/////////////////////////////////////////////////////////////////////////////// + +const char* +getLastErrorStr() +{ + return strerror( errno ); +} + +/////////////////////////////////////////////////////////////////////////////// + +}}} // namespace mp4v2::platform::sys diff --git a/libplatform/sys/error.h b/libplatform/sys/error.h new file mode 100644 index 0000000..8776458 --- /dev/null +++ b/libplatform/sys/error.h @@ -0,0 +1,16 @@ +#ifndef MP4V2_PLATFORM_SYS_ERROR_H +#define MP4V2_PLATFORM_SYS_ERROR_H + +namespace mp4v2 { namespace platform { namespace sys { + +/////////////////////////////////////////////////////////////////////////////// + +MP4V2_EXPORT int getLastError ( ); +MP4V2_EXPORT const char* getLastErrorStr ( ); +MP4V2_EXPORT const char* getErrorStr ( int ); + +/////////////////////////////////////////////////////////////////////////////// + +}}} // namespace mp4v2::platform::sys + +#endif // MP4V2_PLATFORM_SYS_ERROR_H diff --git a/libplatform/time/time.cpp b/libplatform/time/time.cpp new file mode 100644 index 0000000..5fe8867 --- /dev/null +++ b/libplatform/time/time.cpp @@ -0,0 +1,15 @@ +#include "libplatform/impl.h" + +namespace mp4v2 { namespace platform { namespace time { + +/////////////////////////////////////////////////////////////////////////////// + +seconds_t +getLocalTimeSeconds() +{ + return getLocalTimeMilliseconds() / 1000; +} + +/////////////////////////////////////////////////////////////////////////////// + +}}} // namespace mp4v2::platform::time diff --git a/libplatform/time/time.h b/libplatform/time/time.h new file mode 100644 index 0000000..d4d8e7a --- /dev/null +++ b/libplatform/time/time.h @@ -0,0 +1,48 @@ +#ifndef MP4V2_PLATFORM_TIME_TIME_H +#define MP4V2_PLATFORM_TIME_TIME_H + +/// @namespace mp4v2::platform::time (private) Time. +/// <b>WARNING: THIS IS A PRIVATE NAMESPACE. NOT FOR PUBLIC CONSUMPTION.</b> +namespace mp4v2 { namespace platform { namespace time { + +//! type used to represent milliseconds +typedef int64_t milliseconds_t; + +//! type used to represent seconds +typedef int64_t seconds_t; + +/////////////////////////////////////////////////////////////////////////////// +//! +//! Get local-time in milliseconds. +//! +//! getLocalTimeMilliseconds obtains the system's notion of current Greenwich +//! time, adjusted according to the current timezone of the host system. +//! The time is expressed as an absolute value since midnight (0 hour), +//! January 1, 1970. This is commonly referred to as the "epoch". +//! +//! @return local-time in milliseconds elapsed since the epoch. +//! +/////////////////////////////////////////////////////////////////////////////// +MP4V2_EXPORT milliseconds_t getLocalTimeMilliseconds(); + +/////////////////////////////////////////////////////////////////////////////// +//! +//! Get local-time in seconds. +//! +//! getLocalTimeMilliseconds obtains the system's notion of current Greenwich +//! time, adjusted according to the current timezone of the host system. +//! The time is expressed as an absolute value since midnight (0 hour), +//! January 1, 1970. This is commonly referred to as the "epoch". +//! +//! @return local-time in seconds elapsed since the epoch. +//! +/////////////////////////////////////////////////////////////////////////////// +MP4V2_EXPORT seconds_t getLocalTimeSeconds(); + +/////////////////////////////////////////////////////////////////////////////// +//! @} +/////////////////////////////////////////////////////////////////////////////// + +}}} // namespace mp4v2::platform::time + +#endif // MP4V2_PLATFORM_TIME_TIME_H diff --git a/libplatform/time/time_posix.cpp b/libplatform/time/time_posix.cpp new file mode 100644 index 0000000..e3c82f7 --- /dev/null +++ b/libplatform/time/time_posix.cpp @@ -0,0 +1,19 @@ +#include "libplatform/impl.h" +#include <sys/time.h> + +namespace mp4v2 { namespace platform { namespace time { + +/////////////////////////////////////////////////////////////////////////////// + +milliseconds_t +getLocalTimeMilliseconds() +{ + timeval buf; + if( gettimeofday( &buf, 0 )) + memset( &buf, 0, sizeof( buf )); + return milliseconds_t( buf.tv_sec ) * 1000 + buf.tv_usec / 1000; +} + +/////////////////////////////////////////////////////////////////////////////// + +}}} // namespace mp4v2::platform::time diff --git a/libplatform/time/time_win32.cpp b/libplatform/time/time_win32.cpp new file mode 100644 index 0000000..88a7ea5 --- /dev/null +++ b/libplatform/time/time_win32.cpp @@ -0,0 +1,18 @@ +#include "libplatform/impl.h" +#include <sys/timeb.h> + +namespace mp4v2 { namespace platform { namespace time { + +/////////////////////////////////////////////////////////////////////////////// + +milliseconds_t +getLocalTimeMilliseconds() +{ + __timeb64 buf; + _ftime64( &buf ); + return milliseconds_t( buf.time ) * 1000 + buf.millitm; +} + +/////////////////////////////////////////////////////////////////////////////// + +}}} // namespace mp4v2::platform::time diff --git a/libplatform/warning.h b/libplatform/warning.h new file mode 100644 index 0000000..2a236ab --- /dev/null +++ b/libplatform/warning.h @@ -0,0 +1,30 @@ +#ifndef MP4V2_PLATFORM_WARNING_H +#define MP4V2_PLATFORM_WARNING_H + +/////////////////////////////////////////////////////////////////////////////// + +// TODO-KB: clean code to avoid disabling warnings + +#if defined( __GNUC__ ) && ( __GNUC__ >= 4 ) && ( __GNUC_MINOR__ >= 2 ) +# pragma GCC diagnostic ignored "-Wwrite-strings" +#elif defined( _MSC_VER ) +# pragma warning( disable: 4244 ) +# pragma warning( disable: 4251 ) +# pragma warning( disable: 4800 ) +# pragma warning( disable: 4996 ) +#endif + +/////////////////////////////////////////////////////////////////////////////// + +// this macro is used to mark printf-style functions for GCC to examine +// the format string and arguments and issue warnings if needed + +#if defined( __GNUC__ ) +# define MP4V2_WFORMAT_PRINTF(i,j) __attribute__((format(__printf__,i,j))) +#else +# define MP4V2_WFORMAT_PRINTF(i,j) +#endif + +/////////////////////////////////////////////////////////////////////////////// + +#endif // MP4V2_PLATFORM_WARNING_H diff --git a/libutil/Database.cpp b/libutil/Database.cpp new file mode 100644 index 0000000..4b99b07 --- /dev/null +++ b/libutil/Database.cpp @@ -0,0 +1,225 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is MP4v2. +// +// The Initial Developer of the Original Code is Kona Blend. +// Portions created by Kona Blend are Copyright (C) 2008. +// All Rights Reserved. +// +// Contributors: +// Kona Blend, kona8lend@@gmail.com +// +/////////////////////////////////////////////////////////////////////////////// + +#include "libutil/impl.h" + +namespace mp4v2 { namespace util { + +/////////////////////////////////////////////////////////////////////////////// + +Database::Database( const string& filename, const string& key ) + : _filename ( filename ) + , _key ( key ) +{ +} + +/////////////////////////////////////////////////////////////////////////////// + +Database::~Database() +{ +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Database::close() +{ + _stream.close(); + _stream.clear(); +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +Database::open( bool write, string& fname ) +{ + _currentKeyValue.clear(); + + _stream.clear(); + _stream.open( fname.c_str(), write ? ios::out : ios::in ); + return _stream.rdstate(); +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Database::parseData( map<string,string>& data ) +{ + data.clear(); + + string name; + string value; + + if ( _currentKeyValue.length() ) { + data[ _key ] = _currentKeyValue; + _currentKeyValue.clear(); + } + + while ( !parsePair( name, value ) ) { + if ( name == _key ) { + _currentKeyValue = value; + break; + } + data[ name ] = value; + } +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +Database::parsePair( string& name, string& value ) +{ + enum Mode { LTRIM, COMMENT, NAME, DELIM, VALUE }; + Mode mode = LTRIM; + bool delimVisible = false; + + int visibleLength = 0; + + for ( char c; !_stream.get( c ).rdstate(); ) { + switch( mode ) { + case LTRIM: + switch( c ) { + case '\0': // NULL + case '\t': // TAB + case ' ': // SPACE + case '\n': // NEWLINE + case '\r': // CARRIAGE-RETURN + break; + + case '#': // COMMENT + mode = COMMENT; + break; + + default: + mode = NAME; + name = tolower( c ); + break; + } + break; + + case COMMENT: + switch( c ) { + case '\n': // NEWLINE + case '\r': // CARRIAGE-RETURN + mode = LTRIM; + name.clear(); + break; + + default: + break; + } + break; + + case NAME: + switch( c ) { + case '\0': // NULL + break; + + case '\n': // NEWLINE + case '\r': // CARRIAGE-RETURN + mode = LTRIM; + break; + + case '\t': // TAB + case ' ': // SPACE + case '=': // DELIMITER + mode = DELIM; + delimVisible = false; + break; + + default: + name += tolower( c ); + break; + } + break; + + case DELIM: + switch( c ) { + case '\n': // NEWLINE + case '\r': // CARRIAGE-RETURN + mode = LTRIM; + name.clear(); + break; + + case '\0': // NULL + case '\t': // TAB + case ' ': // SPACE + break; + + case '=': // DELIMITER + if( delimVisible ) { + mode = VALUE; + value = c; + visibleLength = value.length(); + } + delimVisible = true; + break; + + default: + mode = VALUE; + value = c; + visibleLength = value.length(); + break; + } + break; + + case VALUE: + switch (c) { + case '\0': // NULL + break; + + case '\n': // NEWLINE + case '\r': // CARRIAGE-RETURN + if( visibleLength ) + value.resize( visibleLength ); + return false; + + case '\t': // TAB + case ' ': // SPACE + value += ' '; + break; + + default: + value += c; + visibleLength = value.length(); + break; + } + break; + + default: + break; + } + } + + if( mode != VALUE ) + return true; + + if( visibleLength ) + value.resize( visibleLength ); + + return false; +} + +/////////////////////////////////////////////////////////////////////////////// + +}} // namespace mp4v2::util diff --git a/libutil/Database.h b/libutil/Database.h new file mode 100644 index 0000000..43831a6 --- /dev/null +++ b/libutil/Database.h @@ -0,0 +1,101 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is MP4v2. +// +// The Initial Developer of the Original Code is Kona Blend. +// Portions created by Kona Blend are Copyright (C) 2008. +// All Rights Reserved. +// +// Contributors: +// Kona Blend, kona8lend@@gmail.com +// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef MP4V2_UTIL_DATABASE_H +#define MP4V2_UTIL_DATABASE_H + +namespace mp4v2 { namespace util { + +/////////////////////////////////////////////////////////////////////////////// +/// +/// Database class is the base implementation for persistent databases. +/// +/// All databases use an ASCII file format: +/// @li leading/trailing spaces on any line are trimmed. +/// @li lines beginning with '#' are considered comments. +/// @li lines of { <NAME><DELIMITER><VALUE><EOL> } form NAME/VALUEs pairs. +/// @li <NAME> cannot contain any <DELIMITER> characters. +/// @li <DELIMITER> is any combination of { ' ', '=', '\t' }. +/// @li <VALUE> continues until <EOL>. +/// @li <EOL> is optional for last line. +/// @li <NAME> of value this._key marks the beginning of a new record. +/// @li <NAME> is case-insensitive. +/// @li subsequent lines of NAME/VALUE pairs are part of the same record. +/// +/////////////////////////////////////////////////////////////////////////////// +class Database { +public: + virtual ~Database(); + +protected: + /// Constructor. + /// + /// @param file specifies filename for IO operations. + /// @param key specifies the name of primary key. + /// + Database( const string& file, const string& key ); + + /// Close database file. + void close(); + + /// Open database file. + /// + /// @param write <b>true</b> to open file for writing, <b>false</b> for reading. + /// @param fname filename to open. + /// + /// @return <b>true</b> on error. + /// + bool open( bool write, string& fname ); + + /// Parse a record-data from open intput stream. + /// + /// @param data is populated with NAME/VALUE pairs if any. + /// + void parseData( map<string,string>& data ); + + /////////////////////////////////////////////////////////////////////////// + + const string _filename; // filename (basename only) used for database + const string _key; // name of key for record boundries + fstream _stream; // // IO object + +private: + /// parse a name/value pair from open input stream. + /// + /// @param name stores the parsed name. + /// @param value stores the parsed value. + /// + /// @return <b>true</b> on error (no name/value pair was parised). + /// + bool parsePair( string& name, string& value ); + + /*************************************************************************/ + + string _currentKeyValue; +}; + +/////////////////////////////////////////////////////////////////////////////// + +}} // namespace mp4v2::util + +#endif // MP4V2_UTIL_DATABASE_H diff --git a/libutil/Timecode.cpp b/libutil/Timecode.cpp new file mode 100644 index 0000000..195a009 --- /dev/null +++ b/libutil/Timecode.cpp @@ -0,0 +1,591 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is MP4v2. +// +// The Initial Developer of the Original Code is Kona Blend. +// Portions created by Kona Blend are Copyright (C) 2008. +// All Rights Reserved. +// +// Contributors: +// Kona Blend, kona8lend@@gmail.com +// +/////////////////////////////////////////////////////////////////////////////// + +#include "libutil/impl.h" + +namespace mp4v2 { namespace util { + +/////////////////////////////////////////////////////////////////////////////// + +Timecode::Timecode( const Timecode& obj ) + : _scale ( 1.0 ) + , _duration ( 0 ) + , _format ( FRAME ) + , _svalue ( "" ) + , _hours ( 0 ) + , _minutes ( 0 ) + , _seconds ( 0 ) + , _subseconds ( 0 ) + , scale ( _scale ) + , duration ( _duration ) + , format ( _format ) + , svalue ( _svalue ) + , hours ( _hours ) + , minutes ( _minutes ) + , seconds ( _seconds ) + , subseconds ( _subseconds ) +{ + operator=( obj ); +} + +/////////////////////////////////////////////////////////////////////////////// + +Timecode::Timecode( const string& time_, double scale_ ) + : _scale ( scale_ < 1.0 ? 1.0 : scale_ ) + , _duration ( 0 ) + , _format ( FRAME ) + , _svalue ( "" ) + , _hours ( 0 ) + , _minutes ( 0 ) + , _seconds ( 0 ) + , _subseconds ( 0 ) + , scale ( _scale ) + , duration ( _duration ) + , format ( _format ) + , svalue ( _svalue ) + , hours ( _hours ) + , minutes ( _minutes ) + , seconds ( _seconds ) + , subseconds ( _subseconds ) +{ + parse( time_ ); +} + +/////////////////////////////////////////////////////////////////////////////// + +Timecode::Timecode( uint64_t duration_, double scale_ ) + : _scale ( scale_ < 1.0 ? 1.0 : scale_ ) + , _duration ( 0 ) + , _format ( FRAME ) + , _svalue ( "" ) + , _hours ( 0 ) + , _minutes ( 0 ) + , _seconds ( 0 ) + , _subseconds ( 0 ) + , scale ( _scale ) + , duration ( _duration ) + , format ( _format ) + , svalue ( _svalue ) + , hours ( _hours ) + , minutes ( _minutes ) + , seconds ( _seconds ) + , subseconds ( _subseconds ) +{ + setDuration( duration_ ); +} + +/////////////////////////////////////////////////////////////////////////////// + +uint64_t +Timecode::convertDuration( const Timecode& obj ) const +{ + if( _scale == obj._scale ) + return obj._duration; + + return static_cast<uint64_t>( ( _scale / obj._scale ) * obj._duration ); +} + +/////////////////////////////////////////////////////////////////////////////// + +Timecode& +Timecode::operator=( const Timecode& rhs ) +{ + _scale = rhs._scale; + _duration = rhs._duration; + _format = FRAME; + _svalue = rhs._svalue; + + _hours = rhs._hours; + _minutes = rhs._minutes; + _seconds = rhs._seconds; + _subseconds = rhs._subseconds; + + return *this; +} + +/////////////////////////////////////////////////////////////////////////////// + +Timecode& +Timecode::operator+=( const Timecode& rhs ) +{ + uint64_t dur = _duration + convertDuration( rhs ); + // overflow check + if( dur < _duration ) + dur = numeric_limits<long long>::max(); + + setDuration( dur ); + return *this; +} + +/////////////////////////////////////////////////////////////////////////////// + +Timecode& +Timecode::operator-=( const Timecode& rhs ) +{ + uint64_t dur = _duration - convertDuration( rhs ); + // underflow check + if( dur > _duration ) + dur = 0; + + setDuration( dur ); + return *this; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +Timecode::operator<( const Timecode& obj ) const +{ + return _duration < convertDuration( obj ); +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +Timecode::operator<=( const Timecode& obj ) const +{ + return _duration <= convertDuration( obj ); +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +Timecode::operator>( const Timecode& obj ) const +{ + return _duration < convertDuration( obj ); +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +Timecode::operator>=( const Timecode& obj ) const +{ + return _duration < convertDuration( obj ); +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +Timecode::operator!=( const Timecode& obj ) const +{ + return _duration != convertDuration( obj ); +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +Timecode::operator==( const Timecode& obj ) const +{ + return _duration == convertDuration( obj ); +} + +/////////////////////////////////////////////////////////////////////////////// + +Timecode +Timecode::operator+( const Timecode& obj ) const +{ + Timecode t( *this ); + t += obj; + return t; +} + +/////////////////////////////////////////////////////////////////////////////// + +Timecode +Timecode::operator-( const Timecode& obj ) const +{ + Timecode t( *this ); + t -= obj; + return t; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +Timecode::parse( const string& time, string* outError ) +{ + string outErrorPlacebo; + string& error = outError ? *outError : outErrorPlacebo; + error.clear(); + + _format = FRAME; + _hours = 0; + _minutes = 0; + _seconds = 0; + _subseconds = 0; + + // bail if empty + if( time.empty() ) { + recompute(); + return false; + } + + // count number of ':' + int nsect = 0; + int nsemi = 0; + int ndot = 0; + + const string::size_type max = time.length(); + for( string::size_type i = 0; i < max; i++ ) { + switch( time[i] ) { + case ':': + nsect++; + break; + + case ';': + if( nsemi++ ) { + error = "too many semicolons"; + return true; + } + nsect++; + break; + + case '.': + if( ndot++ ) { + error = "too many periods"; + return true; + } + nsect++; + break; + + default: + break; + } + } + + // bail if impossible number of sections + if( nsect > 3 ) { + recompute(); + error = "too many sections"; + return true; + } + + enum Target { + HOURS, + MINUTES, + SECONDS, + SUBSECONDS, + }; + + // setup target before parsing + Target target; + uint64_t* tvalue; + switch( nsect ) { + default: + case 0: + target = SUBSECONDS; + tvalue = &_subseconds; + break; + + case 1: + target = SECONDS; + tvalue = &_seconds; + break; + + case 2: + target = MINUTES; + tvalue = &_minutes; + break; + + case 3: + target = HOURS; + tvalue = &_hours; + break; + } + + istringstream convert; + string tbuffer; + for( string::size_type i = 0; i < max; i++ ) { + const char c = time[i]; + switch( c ) { + case ':': + switch( target ) { + case HOURS: + convert.clear(); + convert.str( tbuffer ); + if( !tbuffer.empty() && !(convert >> *tvalue) ) { + error = "failed to convert integer"; + return true; + } + tbuffer.clear(); + target = MINUTES; + tvalue = &_minutes; + break; + + case MINUTES: + convert.clear(); + convert.str( tbuffer ); + if( !tbuffer.empty() && !(convert >> *tvalue) ) { + error = "failed to convert integer"; + return true; + } + tbuffer.clear(); + target = SECONDS; + tvalue = &_seconds; + break; + + case SECONDS: + convert.clear(); + convert.str( tbuffer ); + if( !tbuffer.empty() && !(convert >> *tvalue) ) { + error = "failed to convert integer"; + return true; + } + tbuffer.clear(); + target = SUBSECONDS; + tvalue = &_subseconds; + break; + + default: + case SUBSECONDS: + error = "unexpected char ':'"; + return true; + } + break; + + case '.': + { + if( target != SECONDS ) { + error = "unexpected char '.'"; + return true; + } + _format = DECIMAL; + convert.clear(); + convert.str( tbuffer ); + if( !tbuffer.empty() && !(convert >> *tvalue) ) { + error = "failed to convert integer"; + return true; + } + tbuffer.clear(); + target = SUBSECONDS; + tvalue = &_subseconds; + break; + } + + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + tbuffer += c; + if( tbuffer.length() > 16 ) { + error = "overflow"; + return true; + } + break; + + default: + error = "unexpected char '"; + error += c; + error += "'"; + return true; + } + } + + // apply final section + if( !tbuffer.empty() ) { + convert.clear(); + convert.str( tbuffer ); + if( !tbuffer.empty() && !(convert >> *tvalue) ) { + error = "failed to convert integer"; + return true; + } + } + + // special post processing + switch( _format ) { + case FRAME: + default: + break; + + case DECIMAL: + { + double div = std::pow( 10.0, static_cast<double>(tbuffer.length()) ); + if( div < 1.0 ) + div = 1.0; + *tvalue = static_cast<uint64_t>( static_cast<double>(*tvalue) / div * std::ceil( _scale )); + break; + } + } + + recompute(); + return false; +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Timecode::recompute() +{ + // case: 29.97 becomes 30.0 + // case: 30.0 becomes 30.0 + const uint64_t iscale = uint64_t( std::ceil( _scale )); + + if( _subseconds > iscale - 1 ) { + uint64_t n = _subseconds / iscale; + _seconds += n; + _subseconds -= n * iscale; + } + + if( _seconds > 59 ) { + uint64_t n = _seconds / 60; + _minutes += n; + _seconds -= n * 60; + } + + if( _minutes > 59 ) { + uint64_t n = _minutes / 60; + _hours += n; + _minutes -= n * 60; + } + + _duration = _subseconds + (iscale * _seconds) + (iscale * _minutes * 60) + (iscale * _hours * 3600); + + ostringstream oss; + oss << setfill('0') << right + << setw(2) << _hours + << ':' + << setw(2) << _minutes + << ':' + << setw(2) << _seconds; + + switch( _format ) { + case FRAME: + oss << ':' << setw(2) << setfill( '0' ) << _subseconds; + break; + + case DECIMAL: + { + oss << '.' << setw(3) << setfill( '0' ) << static_cast<uint64_t>(_subseconds / _scale * 1000.0 + 0.5); + break; + } + } + + _svalue = oss.str(); +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Timecode::reset() +{ + setDuration( 0 ); +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Timecode::setDuration( uint64_t duration_, double scale_ ) +{ + if( scale_ != 0.0 ) { + _scale = scale_; + if( _scale < 1.0 ) + _scale = 1.0; + } + + _duration = duration_; + + const uint64_t iscale = uint64_t( std::ceil( _scale )); + uint64_t i = _duration; + + _hours = i / (iscale * 3600); + i -= (iscale * 3600 * _hours); + + _minutes = i / (iscale * 60); + i -= (iscale * 60 * _minutes); + + _seconds = i / iscale; + i -= (iscale * _seconds); + + _subseconds = i; + + recompute(); +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Timecode::setFormat( Format format_ ) +{ + _format = format_; + recompute(); +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Timecode::setHours( uint64_t hours_ ) +{ + _hours = hours_; + recompute(); +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Timecode::setMinutes( uint64_t minutes_ ) +{ + _minutes = minutes_; + recompute(); +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Timecode::setScale( double scale_ ) +{ + const double oldscale = _scale; + _scale = scale_; + if( _scale < 1.0 ) + _scale = 1.0; + + _subseconds = static_cast<uint64_t>( (_scale / oldscale) * _subseconds ); + recompute(); +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Timecode::setSeconds( uint64_t seconds_ ) +{ + _seconds = seconds_; + recompute(); +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Timecode::setSubseconds( uint64_t subseconds_ ) +{ + _subseconds = subseconds_; + recompute(); +} + +/////////////////////////////////////////////////////////////////////////////// + +}} // namespace mp4v2::util diff --git a/libutil/Timecode.h b/libutil/Timecode.h new file mode 100644 index 0000000..dd164e6 --- /dev/null +++ b/libutil/Timecode.h @@ -0,0 +1,119 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is MP4v2. +// +// The Initial Developer of the Original Code is Kona Blend. +// Portions created by Kona Blend are Copyright (C) 2008. +// All Rights Reserved. +// +// Contributors: +// Kona Blend, kona8lend@@gmail.com +// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef MP4V2_UTIL_TIMECODE_H +#define MP4V2_UTIL_TIMECODE_H + +namespace mp4v2 { namespace util { + +/////////////////////////////////////////////////////////////////////////////// + +/// Class representing SMPTE timecode. +/// +/// Objects of this class represent a specific time or duration and can +/// be converted to/from string values, and various epochs. +/// +/// The standard pattern for string representation is as follows: +/// @li HH:MM:SS:FF +/// @li HH:MM:SS.DDD +/// +/// where: +/// @li <b>HH</b> specifies hours +/// @li <b>MM</b> specifies minutes +/// @li <b>SS</b> specifies seconds +/// @li <b>:</b> specifies normal timecode +/// @li <b>FF</b> specifies the frame number +/// @li <b>.</b> specifies decimal fractions of a second follow +/// @li <b>DDD</b> specifies decimal fractions of a second, rounded down to closest scale +/// +class MP4V2_EXPORT Timecode { +public: + enum Format { + FRAME, + DECIMAL, + }; + +private: + double _scale; + uint64_t _duration; + Format _format; + string _svalue; + + uint64_t _hours; + uint64_t _minutes; + uint64_t _seconds; + uint64_t _subseconds; + +public: + const double& scale; + const uint64_t& duration; + const Format& format; + const string& svalue; + + const uint64_t& hours; + const uint64_t& minutes; + const uint64_t& seconds; + const uint64_t& subseconds; + +public: + Timecode( const Timecode& ); + explicit Timecode( const string&, double = 1.0 ); + explicit Timecode( uint64_t = 0, double = 1.0 ); + + Timecode& operator= ( const Timecode& ); + Timecode& operator+= ( const Timecode& ); + Timecode& operator-= ( const Timecode& ); + + bool operator< ( const Timecode& ) const; + bool operator<= ( const Timecode& ) const; + bool operator> ( const Timecode& ) const; + bool operator>= ( const Timecode& ) const; + bool operator!= ( const Timecode& ) const; + bool operator== ( const Timecode& ) const; + + Timecode operator+ ( const Timecode& ) const; + Timecode operator- ( const Timecode& ) const; + + bool parse( const string&, string* = NULL ); + + void reset(); + + void setScale ( double ); + void setDuration ( uint64_t, double = 0.0 ); + void setFormat ( Format ); + + void setHours ( uint64_t ); + void setMinutes ( uint64_t ); + void setSeconds ( uint64_t ); + void setSubseconds ( uint64_t ); + +private: + uint64_t convertDuration( const Timecode& ) const; + void recompute(); +}; + +/////////////////////////////////////////////////////////////////////////////// + +}} // namespace mp4v2::util + +#endif // MP4V2_UTIL_TIMECODE_H diff --git a/libutil/TrackModifier.cpp b/libutil/TrackModifier.cpp new file mode 100644 index 0000000..6e3ccc4 --- /dev/null +++ b/libutil/TrackModifier.cpp @@ -0,0 +1,503 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is MP4v2. +// +// The Initial Developer of the Original Code is Kona Blend. +// Portions created by Kona Blend are Copyright (C) 2008. +// All Rights Reserved. +// +// Contributors: +// Kona Blend, kona8lend@@gmail.com +// +/////////////////////////////////////////////////////////////////////////////// + +#include "libutil/impl.h" + +namespace mp4v2 { namespace util { + +/////////////////////////////////////////////////////////////////////////////// + +TrackModifier::TrackModifier( MP4FileHandle file_, uint16_t trackIndex_ ) + : _track ( refTrackAtom( *static_cast<MP4File*>(file_), trackIndex_ )) + , _props ( *this ) // must come after _track is initialized + , _enabled ( false ) + , _inMovie ( false ) + , _inPreview ( false ) + , _layer ( 0 ) + , _alternateGroup ( 0 ) + , _volume ( 1.0f ) + , _width ( 0.0f ) + , _height ( 0.0f ) + , _language ( bmff::ILC_UND ) + , _handlerType ( "" ) + , _handlerName ( "" ) + , _userDataName ( "" ) + , file ( *static_cast<MP4File*>(file_) ) + , trackIndex ( trackIndex_ ) + , trackId ( MP4FindTrackId( file_, trackIndex_ )) + , enabled ( _enabled ) + , inMovie ( _inMovie ) + , inPreview ( _inPreview ) + , layer ( _layer ) + , alternateGroup ( _alternateGroup ) + , volume ( _volume ) + , width ( _width ) + , height ( _height ) + , language ( _language ) + , handlerType ( _handlerType ) + , handlerName ( _handlerName ) + , userDataName ( _userDataName ) +{ + fetch(); +} + +/////////////////////////////////////////////////////////////////////////////// + +TrackModifier::~TrackModifier() +{ +} + +/////////////////////////////////////////////////////////////////////////////// + +void +TrackModifier::dump( ostream& out, const string& xind ) +{ + const uint32_t w = 14; + const string eq = " = "; + const string ind = " "; + + out << left << xind << "track[" << trackIndex << "] id=" << trackId + << '\n' << xind << ind << setw( w ) << "type" << eq << toStringTrackType( handlerType ) + << '\n' << xind << ind << setw( w ) << "enabled" << eq << toString( enabled ) + << '\n' << xind << ind << setw( w ) << "inMovie" << eq << toString( inMovie ) + << '\n' << xind << ind << setw( w ) << "inPreview" << eq << toString( inPreview ) + << '\n' << xind << ind << setw( w ) << "layer" << eq << layer + << '\n' << xind << ind << setw( w ) << "alternateGroup" << eq << alternateGroup + << '\n' << xind << ind << setw( w ) << "volume" << eq << toString( volume, 8, 8 ) + << '\n' << xind << ind << setw( w ) << "width" << eq << toString( width, 16, 16 ) + << '\n' << xind << ind << setw( w ) << "height" << eq << toString( height, 16, 16 ) + << '\n' << xind << ind << setw( w ) << "language" << eq << bmff::enumLanguageCode.toString( language, true ) + << '\n' << xind << ind << setw( w ) << "handlerName" << eq << handlerName; + + out << '\n' << xind << ind << setw( w ) << "userDataName" << eq + << ( _props.userDataName ? userDataName : "<absent>" ); + + out << '\n'; +} + +/////////////////////////////////////////////////////////////////////////////// + +void +TrackModifier::fetch() +{ + _props.update(); + + const uint32_t flags = _props.flags.GetValue(); + _enabled = flags & 0x01; + _inMovie = flags & 0x02; + _inPreview = flags & 0x04; + + _layer = _props.layer.GetValue(); + _alternateGroup = _props.alternateGroup.GetValue(); + _volume = _props.volume.GetValue(); + _width = _props.width.GetValue(); + _height = _props.height.GetValue(); + + _language = _props.language.GetValue(); + _handlerType = _props.handlerType.GetValue(); + _handlerName = _props.handlerName.GetValue(); + + if( _props.userDataName ) { + uint8_t* buffer; + uint32_t size; + _props.userDataName->GetValue( &buffer, &size ); + _userDataName = string( reinterpret_cast<char*>(buffer), size ); + } + else { + _userDataName.clear(); + } +} + +/////////////////////////////////////////////////////////////////////////////// + +bool& +TrackModifier::fromString( const string& src, bool& dst ) +{ + if( src == "true" ) + dst = true; + else if ( src == "false" ) + dst = false; + else { + istringstream iss( src ); + iss >> dst; + if( iss.rdstate() != ios::eofbit ) { + ostringstream oss; + oss << "invalid value: " << src; + throw new MP4Exception( oss ); + } + } + + return dst; +} + +/////////////////////////////////////////////////////////////////////////////// + +float& +TrackModifier::fromString( const string& src, float& dst ) +{ + istringstream iss( src ); + iss >> dst; + if( iss.rdstate() != ios::eofbit ) { + ostringstream oss; + oss << "invalid value: " << src; + throw new MP4Exception( oss ); + } + + return dst; +} + +/////////////////////////////////////////////////////////////////////////////// + +uint16_t& +TrackModifier::fromString( const string& src, uint16_t& dst ) +{ + istringstream iss( src ); + iss >> dst; + if( iss.rdstate() != ios::eofbit ) { + ostringstream oss; + oss << "invalid value: " << src; + throw new MP4Exception( oss ); + } + + return dst; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +TrackModifier::hasUserDataName() const +{ + return _props.userDataName != NULL; +} + +/////////////////////////////////////////////////////////////////////////////// + +MP4Atom& +TrackModifier::refTrackAtom( MP4File& file, uint16_t index ) +{ + MP4Atom& root = *file.FindAtom( NULL ); + + ostringstream oss; + oss << "moov.trak[" << index << "]"; + MP4Atom* trak = root.FindAtom( oss.str().c_str() ); + if( !trak ) { + oss.str( "" ); + oss << "trackIndex " << index << " not found"; + throw new MP4Exception( oss ); + } + + return *trak; +} + +/////////////////////////////////////////////////////////////////////////////// + +void +TrackModifier::removeUserDataName() +{ + MP4Atom* name = _track.FindAtom( "trak.udta.name" ); + if( name ) + name->GetParentAtom()->DeleteChildAtom( name ); + + MP4Atom* udta = _track.FindAtom( "trak.udta" ); + if( udta && !udta->GetNumberOfChildAtoms() ) + udta->GetParentAtom()->DeleteChildAtom( udta ); +} + +/////////////////////////////////////////////////////////////////////////////// + +void +TrackModifier::setAlternateGroup( uint16_t value ) +{ + _props.alternateGroup.SetValue( value ); + fetch(); +} + +void +TrackModifier::setAlternateGroup( const string& value ) +{ + uint16_t tmp; + setAlternateGroup( fromString( value, tmp )); +} + +/////////////////////////////////////////////////////////////////////////////// + +void +TrackModifier::setEnabled( bool value ) +{ + _enabled = value; + _props.flags.SetValue( (_enabled ? 0x01 : 0) | (_inMovie ? 0x02 : 0) | (_inPreview ? 0x04 : 0) ); + fetch(); +} + +void +TrackModifier::setEnabled( const string& value ) +{ + bool tmp; + setEnabled( fromString( value, tmp )); +} + +/////////////////////////////////////////////////////////////////////////////// + +void +TrackModifier::setHandlerName( const string& value ) +{ + _props.handlerName.SetValue( value.c_str() ); + fetch(); +} +/////////////////////////////////////////////////////////////////////////////// + +void +TrackModifier::setHeight( float value ) +{ + _props.height.SetValue( value ); + fetch(); +} + +void +TrackModifier::setHeight( const string& value ) +{ + float tmp; + setHeight( fromString( value, tmp )); +} + +/////////////////////////////////////////////////////////////////////////////// + +void +TrackModifier::setInMovie( bool value ) +{ + _inMovie = value; + _props.flags.SetValue( (_enabled ? 0x01 : 0) | (_inMovie ? 0x02 : 0) | (_inPreview ? 0x04 : 0) ); + fetch(); +} + +void +TrackModifier::setInMovie( const string& value ) +{ + bool tmp; + setInMovie( fromString( value, tmp )); +} + +/////////////////////////////////////////////////////////////////////////////// + +void +TrackModifier::setInPreview( bool value ) +{ + _inPreview = value; + _props.flags.SetValue( (_enabled ? 0x01 : 0) | (_inMovie ? 0x02 : 0) | (_inPreview ? 0x04 : 0) ); + fetch(); +} + +void +TrackModifier::setInPreview( const string& value ) +{ + bool tmp; + setInPreview( fromString( value, tmp )); +} + +/////////////////////////////////////////////////////////////////////////////// + +void +TrackModifier::setLanguage( bmff::LanguageCode value ) +{ + _props.language.SetValue( value ); + fetch(); +} + +void +TrackModifier::setLanguage( const string& value ) +{ + setLanguage( bmff::enumLanguageCode.toType( value )); +} + +/////////////////////////////////////////////////////////////////////////////// + +void +TrackModifier::setLayer( uint16_t value ) +{ + _props.layer.SetValue( value ); + fetch(); +} + +void +TrackModifier::setLayer( const string& value ) +{ + uint16_t tmp; + setLayer( fromString( value, tmp )); +} + +/////////////////////////////////////////////////////////////////////////////// + +void +TrackModifier::setUserDataName( const string& value ) +{ + if( !_props.userDataName ) { + ostringstream oss; + oss << "moov.trak[" << trackIndex << "]"; + file.AddDescendantAtoms( oss.str().c_str(), "udta.name" ); + _props.update(); + } + + _props.userDataName->SetValue( reinterpret_cast<const uint8_t*>(value.c_str()), value.size() ); + fetch(); +} + +/////////////////////////////////////////////////////////////////////////////// + +void +TrackModifier::setVolume( float value ) +{ + _props.volume.SetValue( value ); + fetch(); +} + +void +TrackModifier::setVolume( const string& value ) +{ + float tmp; + setVolume( fromString( value, tmp )); +} + +/////////////////////////////////////////////////////////////////////////////// + +void +TrackModifier::setWidth( float value ) +{ + _props.width.SetValue( value ); + fetch(); +} + +void +TrackModifier::setWidth( const string& value ) +{ + float tmp; + setWidth( fromString( value, tmp )); +} + +/////////////////////////////////////////////////////////////////////////////// + +string +TrackModifier::toString( bool value ) +{ + ostringstream oss; + oss << (value ? "true" : "false"); + return oss.str(); +} + +/////////////////////////////////////////////////////////////////////////////// + +string +TrackModifier::toString( float value, uint8_t i, uint8_t f ) +{ + ostringstream oss; + oss << fixed << setprecision(f <= 8 ? 4 : 8) << value; + return oss.str(); +} + +/////////////////////////////////////////////////////////////////////////////// + +string +TrackModifier::toStringTrackType( const string& code ) +{ + if( !code.compare( "vide" )) // 14496-12 + return "video"; + if( !code.compare( "soun" )) // 14496-12 + return "audio"; + if( !code.compare( "hint" )) // 14496-12 + return "hint"; + + if( !code.compare( "text" )) // QTFF + return "text"; + if( !code.compare( "tmcd" )) // QTFF + return "timecode"; + + if( !code.compare( "subt" )) // QTFF + return "subtitle"; + + return string( "(" ) + code + ")"; +} + +/////////////////////////////////////////////////////////////////////////////// + +TrackModifier::Properties::Properties( TrackModifier& trackModifier_ ) + : _trackModifier ( trackModifier_ ) + , flags ( static_cast<MP4Integer24Property&> ( refProperty( "trak.tkhd.flags" ))) + , layer ( static_cast<MP4Integer16Property&> ( refProperty( "trak.tkhd.layer" ))) + , alternateGroup ( static_cast<MP4Integer16Property&> ( refProperty( "trak.tkhd.alternate_group" ))) + , volume ( static_cast<MP4Float32Property&> ( refProperty( "trak.tkhd.volume" ))) + , width ( static_cast<MP4Float32Property&> ( refProperty( "trak.tkhd.width" ))) + , height ( static_cast<MP4Float32Property&> ( refProperty( "trak.tkhd.height" ))) + , language ( static_cast<MP4LanguageCodeProperty&>( refProperty( "trak.mdia.mdhd.language" ))) + , handlerType ( static_cast<MP4StringProperty&> ( refProperty( "trak.mdia.hdlr.handlerType" ))) + , handlerName ( static_cast<MP4StringProperty&> ( refProperty( "trak.mdia.hdlr.name" ))) + , userDataName ( static_cast<MP4BytesProperty*> ( findProperty( "trak.udta.name.value" ))) +{ +} + +/////////////////////////////////////////////////////////////////////////////// + +MP4Property* +TrackModifier::Properties::findProperty( const char* name ) +{ + MP4Property* property; + if( !_trackModifier._track.FindProperty( name, &property )) + return NULL; + + return property; +} + +/////////////////////////////////////////////////////////////////////////////// + +MP4Property& +TrackModifier::Properties::refProperty( const char* name ) +{ + MP4Property* property; + if( !_trackModifier._track.FindProperty( name, &property )) { + ostringstream oss; + oss << "trackId " << _trackModifier.trackId << " property '" << name << "' not found"; + throw new MP4Exception( oss ); + } + + return *property; +} + +/////////////////////////////////////////////////////////////////////////////// + +void +TrackModifier::Properties::update() +{ + // update optional properties + updateProperty( "trak.udta.name.value", reinterpret_cast<MP4Property**>( &userDataName )); +} + +/////////////////////////////////////////////////////////////////////////////// + +void +TrackModifier::Properties::updateProperty( const char* name, MP4Property** pp ) +{ + *pp = NULL; + _trackModifier._track.FindProperty( name, pp ); +} + +/////////////////////////////////////////////////////////////////////////////// + +}} // namespace mp4v2::util diff --git a/libutil/TrackModifier.h b/libutil/TrackModifier.h new file mode 100644 index 0000000..798a061 --- /dev/null +++ b/libutil/TrackModifier.h @@ -0,0 +1,160 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is MP4v2. +// +// The Initial Developer of the Original Code is Kona Blend. +// Portions created by Kona Blend are Copyright (C) 2008. +// All Rights Reserved. +// +// Contributors: +// Kona Blend, kona8lend@@gmail.com +// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef MP4V2_UTIL_TRACKMODIFIER_H +#define MP4V2_UTIL_TRACKMODIFIER_H + +namespace mp4v2 { namespace util { + +/////////////////////////////////////////////////////////////////////////////// + +class MP4V2_EXPORT TrackModifier +{ +private: + class Properties + { + private: + TrackModifier& _trackModifier; + + public: + Properties( TrackModifier& ); + + void update(); + + MP4Integer24Property& flags; + MP4Integer16Property& layer; + MP4Integer16Property& alternateGroup; + MP4Float32Property& volume; + MP4Float32Property& width; + MP4Float32Property& height; + MP4LanguageCodeProperty& language; + MP4StringProperty& handlerType; + MP4StringProperty& handlerName; + MP4BytesProperty* userDataName; + + private: + MP4Property& refProperty( const char* ); + MP4Property* findProperty( const char* ); + void updateProperty( const char*, MP4Property** ); + }; + + friend class Properties; + +private: + static MP4Atom& refTrackAtom( MP4File&, uint16_t ); + +private: + MP4Atom& _track; + Properties _props; + + // Track Header + bool _enabled; + bool _inMovie; + bool _inPreview; + uint16_t _layer; + uint16_t _alternateGroup; + float _volume; + float _width; + float _height; + + // Media Header + bmff::LanguageCode _language; + + // Handler Reference + string _handlerType; + string _handlerName; + + // User Data name + string _userDataName; + +public: + MP4File& file; + const uint16_t trackIndex; + const MP4TrackId trackId; + + const bool& enabled; + const bool& inMovie; + const bool& inPreview; + const uint16_t& layer; + const uint16_t& alternateGroup; + const float& volume; + const float& width; + const float& height; + + const bmff::LanguageCode& language; + + const string& handlerType; + const string& handlerName; + + const string& userDataName; + +public: + TrackModifier( MP4FileHandle, uint16_t ); + ~TrackModifier(); + + void setEnabled ( bool ); + void setInMovie ( bool ); + void setInPreview ( bool ); + void setLayer ( uint16_t ); + void setAlternateGroup ( uint16_t ); + void setVolume ( float ); + void setWidth ( float ); + void setHeight ( float ); + void setLanguage ( bmff::LanguageCode ); + void setHandlerName ( const string& ); + void setUserDataName ( const string& ); + + // set by string + void setEnabled ( const string& ); + void setInMovie ( const string& ); + void setInPreview ( const string& ); + void setLayer ( const string& ); + void setAlternateGroup ( const string& ); + void setVolume ( const string& ); + void setWidth ( const string& ); + void setHeight ( const string& ); + void setLanguage ( const string& ); + + bool hasUserDataName() const; + void removeUserDataName(); + + void dump( ostream&, const string& ); + +private: + void fetch(); + + static string toString( bool ); + static string toString( float, uint8_t, uint8_t ); + + static bool& fromString( const string&, bool& ); + static float& fromString( const string&, float& ); + static uint16_t& fromString( const string&, uint16_t& ); + + static string toStringTrackType( const string& ); +}; + +/////////////////////////////////////////////////////////////////////////////// + +}} // namespace mp4v2::util + +#endif // MP4V2_UTIL_TRACKMODIFIER_H diff --git a/libutil/Utility.cpp b/libutil/Utility.cpp new file mode 100644 index 0000000..43712da --- /dev/null +++ b/libutil/Utility.cpp @@ -0,0 +1,764 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is MP4v2. +// +// The Initial Developer of the Original Code is Kona Blend. +// Portions created by Kona Blend are Copyright (C) 2008. +// All Rights Reserved. +// +// Contributors: +// Kona Blend, kona8lend@@gmail.com +// +/////////////////////////////////////////////////////////////////////////////// + +#include "libutil/impl.h" + +namespace mp4v2 { namespace util { + +/////////////////////////////////////////////////////////////////////////////// + +Utility::Utility( string name_, int argc_, char** argv_ ) + : _longOptions ( NULL ) + , _name ( name_ ) + , _argc ( argc_ ) + , _argv ( argv_ ) + , _optimize ( false ) + , _dryrun ( false ) + , _keepgoing ( false ) + , _overwrite ( false ) + , _force ( false ) + , _debug ( 0 ) + , _verbosity ( 1 ) + , _jobCount ( 0 ) + , _debugVerbosity ( 0 ) + , _debugImplicits ( false ) + , _group ( "OPTIONS" ) + +,STD_OPTIMIZE( 'z', false, "optimize", false, LC_NONE, "optimize mp4 file after modification" ) +,STD_DRYRUN( 'y', false, "dryrun", false, LC_NONE, "do not actually create or modify any files" ) +,STD_KEEPGOING( 'k', false, "keepgoing", false, LC_NONE, "continue batch processing even after errors" ) +,STD_OVERWRITE( 'o', false, "overwrite", false, LC_NONE, "overwrite existing files when creating" ) +,STD_FORCE( 'f', false, "force", false, LC_NONE, "force overwrite even if file is read-only" ) +,STD_QUIET( 'q', false, "quiet", false, LC_NONE, "equivalent to --verbose 0" ) +,STD_DEBUG( 'd', false, "debug", true, LC_DEBUG, "increase debug or long-option to set NUM", "NUM", + // 79-cols, inclusive, max desired width + // |----------------------------------------------------------------------------| + "\nDEBUG LEVELS (for raw mp4 file I/O)" + "\n 0 supressed" + "\n 1 add warnings and errors (default)" + "\n 2 add table details" + "\n 3 add implicits" + "\n 4 everything" ) +,STD_VERBOSE( 'v', false, "verbose", true, LC_VERBOSE, "increase verbosity or long-option to set NUM", "NUM", + // 79-cols, inclusive, max desired width + // |----------------------------------------------------------------------------| + "\nVERBOSE LEVELS" + "\n 0 warnings and errors" + "\n 1 normal informative messages (default)" + "\n 2 more informative messages" + "\n 3 everything" ) +,STD_HELP( 'h', false, "help", false, LC_HELP, "print brief help or long-option for extended help" ) +,STD_VERSION( 0, false, "version", false, LC_VERSION, "print version information and exit" ) +,STD_VERSIONX( 0, false, "versionx", false, LC_VERSIONX, "print extended version information", "ARG", "", true ) + +{ + debugUpdate( 1 ); + + _usage = "<UNDEFINED>"; + _description = "<UNDEFINED>"; + _groups.push_back( &_group ); +} + +/////////////////////////////////////////////////////////////////////////////// + +Utility::~Utility() +{ + delete[] _longOptions; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +Utility::batch( int argi ) +{ + _jobCount = 0; + _jobTotal = _argc - argi; + + // nothing to be done + if( !_jobTotal ) + return SUCCESS; + + bool batchResult = FAILURE; + for( int i = argi; i < _argc; i++ ) { + bool subResult = FAILURE; + try { + if( !job( _argv[i] )) { + batchResult = SUCCESS; + subResult = SUCCESS; + } + } + catch( mp4v2::impl::MP4Error* x ) { + x->Print( stderr ); + delete x; + } + catch( MP4Exception* x ) { + herrf( "%s\n", x->what.c_str() ); + delete x; + } + + if( !_keepgoing && subResult == FAILURE ) + return FAILURE; + } + + return batchResult; +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Utility::debugUpdate( uint32_t debug ) +{ + _debug = debug; + verbose2f( "debug level: %u\n", _debug ); + + switch( _debug ) { + case 0: + _debugVerbosity = 0; + _debugImplicits = false; + break; + + case 1: + _debugVerbosity = MP4_DETAILS_ERROR; + _debugImplicits = false; + break; + + case 2: + _debugVerbosity = MP4_DETAILS_ERROR | MP4_DETAILS_TABLE; + _debugImplicits = false; + break; + + case 3: + _debugVerbosity = MP4_DETAILS_ERROR | MP4_DETAILS_TABLE; + _debugImplicits = true; + break; + + case 4: + default: + _debugVerbosity = MP4_DETAILS_ALL; + _debugImplicits = true; + break; + } +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +Utility::dryrunAbort() +{ + if( !_dryrun ) + return false; + + verbose2f( "skipping: dry-run mode enabled\n" ); + return true; +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Utility::errf( const char* format, ... ) +{ + va_list ap; + va_start( ap, format ); + vfprintf( stderr, format, ap ); + va_end( ap ); +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Utility::formatGroups() +{ + // determine longest long-option [+space +argname] + int longMax = 0; + list<Group*>::reverse_iterator ie = _groups.rend(); + for( list<Group*>::reverse_iterator it = _groups.rbegin(); it != ie; it++ ) { + Group& group = **it; + const Group::List::const_iterator ieo = group.options.end(); + for( Group::List::const_iterator ito = group.options.begin(); ito != ieo; ito++ ) { + const Option& option = **ito; + if( option.hidden ) + continue; + + int len = option.lname.length(); + if( option.lhasarg ) + len += 1 + option.argname.length(); + if( len > longMax ) + longMax = len; + } + } + + // format help output (no line-wrapping yet) + ostringstream oss; + + int groupCount = 0; + int optionCount = 0; + ie = _groups.rend(); + for( list<Group*>::reverse_iterator it = _groups.rbegin(); it != ie; it++, groupCount++ ) { + if( groupCount ) + oss << '\n'; + Group& group = **it; + oss << '\n' << group.name; + const Group::List::const_iterator ieo = group.options.end(); + for( Group::List::const_iterator ito = group.options.begin(); ito != ieo; ito++, optionCount++ ) { + const Option& option = **ito; + if( option.hidden ) + continue; + + oss << "\n "; + + if( option.scode == 0 ) + oss << " --"; + else + oss << '-' << option.scode << ", --"; + + if( option.lhasarg ) { + oss << option.lname << ' ' << option.argname; + oss << setw( longMax - option.lname.length() - 1 - option.argname.length() ) << ""; + } + else { + oss << setw( longMax ) << left << option.lname; + } + + oss << " "; + + const string::size_type imax = option.descr.length(); + for( string::size_type i = 0; i < imax; i++ ) + oss << option.descr[i]; + } + } + + _help = oss.str(); + + // allocate and populate C-style options + delete[] _longOptions; + _longOptions = new prog::Option[optionCount + 1]; + + // fill EOL marker + _longOptions[optionCount].name = NULL; + _longOptions[optionCount].type = prog::Option::NO_ARG; + _longOptions[optionCount].flag = 0; + _longOptions[optionCount].val = 0; + + _shortOptions.clear(); + + int optionIndex = 0; + ie = _groups.rend(); + for( list<Group*>::reverse_iterator it = _groups.rbegin(); it != ie; it++ ) { + Group& group = **it; + const Group::List::const_iterator ieo = group.options.end(); + for( Group::List::const_iterator ito = group.options.begin(); ito != ieo; ito++, optionIndex++ ) { + const Option& a = **ito; + prog::Option& b = _longOptions[optionIndex]; + + b.name = const_cast<char*>(a.lname.c_str()); + b.type = a.lhasarg ? prog::Option::REQUIRED_ARG : prog::Option::NO_ARG; + b.flag = 0; + b.val = (a.lcode == LC_NONE) ? a.scode : a.lcode; + + if( a.scode != 0 ) { + _shortOptions += a.scode; + if( a.shasarg ) + _shortOptions += ':'; + } + } + } +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +Utility::job( string arg ) +{ + verbose2f( "job begin: %s\n", arg.c_str() ); + + // perform job + JobContext job( arg ); + bool result = FAILURE; + try { + result = utility_job( job ); + } + catch( mp4v2::impl::MP4Error* x ) { + x->Print( stderr ); + delete x; + } + catch( MP4Exception* x ) { + herrf( "%s\n", x->what.c_str() ); + delete x; + } + + // close file handle flagged with job + if( job.fileHandle != MP4_INVALID_FILE_HANDLE ) { + verbose2f( "closing %s\n", job.file.c_str() ); + MP4Close( job.fileHandle ); + + // invoke optimize if flagged + if( _optimize && job.optimizeApplicable ) { + verbose1f( "optimizing %s\n", job.file.c_str() ); + if( !MP4Optimize( job.file.c_str(), NULL )) + hwarnf( "optimize failed: %s\n", job.file.c_str() ); + } + } + + // free data flagged with job + list<void*>::iterator ie = job.tofree.end(); + for( list<void*>::iterator it = job.tofree.begin(); it != ie; it++ ) + free( *it ); + + + verbose2f( "job end\n" ); + _jobCount++; + return result; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +Utility::herrf( const char* format, ... ) +{ + va_list ap; + va_start( ap, format ); + + if( _keepgoing ) { + fprintf( stdout, "WARNING: " ); + vfprintf( stdout, format, ap ); + } + else { + fprintf( stderr, "ERROR: " ); + vfprintf( stderr, format, ap ); + } + + va_end( ap ); + return FAILURE; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +Utility::hwarnf( const char* format, ... ) +{ + fprintf( stdout, "WARNING: " ); + va_list ap; + va_start( ap, format ); + vfprintf( stdout, format, ap ); + va_end( ap ); + return FAILURE; +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Utility::outf( const char* format, ... ) +{ + va_list ap; + va_start( ap, format ); + vfprintf( stdout, format, ap ); + va_end( ap ); +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Utility::printHelp( bool extended, bool toerr ) +{ + ostringstream oss; + oss << "Usage: " << _name << " " << _usage << '\n' << _description << '\n' << _help; + + if( extended ) { + const list<Group*>::reverse_iterator ie = _groups.rend(); + for( list<Group*>::reverse_iterator it = _groups.rbegin(); it != ie; it++ ) { + Group& group = **it; + const Group::List::const_iterator ieo = group.options.end(); + for( Group::List::const_iterator ito = group.options.begin(); ito != ieo; ito++ ) { + const Option& option = **ito; + if( option.help.empty() ) + continue; + + oss << '\n' << option.help; + } + } + } + + if( toerr ) + errf( "%s\n\n", oss.str().c_str() ); + else + outf( "%s\n\n", oss.str().c_str() ); +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Utility::printUsage( bool toerr ) +{ + ostringstream oss; + oss << "Usage: " << _name << " " << _usage + << "\nTry -h for brief help or --help for extended help"; + + if( toerr ) + errf( "%s\n", oss.str().c_str() ); + else + outf( "%s\n", oss.str().c_str() ); +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Utility::printVersion( bool extended ) +{ + ostringstream oss; + oss << left; + + if( extended ) { + oss << setw(13) << "utility:" << _name + << '\n' << setw(13) << "product:" << MP4V2_PROJECT_name + << '\n' << setw(13) << "version:" << MP4V2_PROJECT_version + << '\n' << setw(13) << "build date:" << MP4V2_PROJECT_build + << '\n' + << '\n' << setw(18) << "repository URL:" << MP4V2_PROJECT_repo_url + << '\n' << setw(18) << "repository root:" << MP4V2_PROJECT_repo_root + << '\n' << setw(18) << "repository UUID:" << MP4V2_PROJECT_repo_uuid + << '\n' << setw(18) << "repository rev:" << MP4V2_PROJECT_repo_rev + << '\n' << setw(18) << "repository date:" << MP4V2_PROJECT_repo_date + << '\n' << setw(18) << "repository type:" << MP4V2_PROJECT_repo_type; + } + else { + oss << _name << " - " << MP4V2_PROJECT_name_formal; + } + + outf( "%s\n", oss.str().c_str() ); +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +Utility::process() +{ + bool rv = true; + + try { + rv = process_impl(); + } + catch( MP4Exception* x ) { + // rare usage of herrf, make sure its not a warning header. + _keepgoing = false; + herrf( "%s\n", x->what.c_str() ); + delete x; + } + + return rv; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +Utility::process_impl() +{ + formatGroups(); + + // populate code lookup set + set<int> codes; + const Group::List::const_iterator ie = _group.options.end(); + for( Group::List::const_iterator it = _group.options.begin(); it != ie; it++ ) { + const Option& option = **it; + if( option.scode != 0 ) + codes.insert( option.scode ); + if( option.lcode != LC_NONE ) + codes.insert( option.lcode ); + } + + for( ;; ) { + const int code = prog::getOption( _argc, _argv, _shortOptions.c_str(), _longOptions, NULL ); + if( code == -1 ) + break; + + bool handled = false; + if( utility_option( code, handled )) + return FAILURE; + if( handled ) + continue; + + if( codes.find( code ) == codes.end() ) + continue; + + switch( code ) { + case 'z': + _optimize = true; + break; + + case 'y': + _dryrun = true; + break; + + case 'k': + _keepgoing = true; + break; + + case 'o': + _overwrite = true; + break; + + case 'f': + _force = true; + break; + + case 'q': + _verbosity = 0; + debugUpdate( 0 ); + break; + + case 'v': + _verbosity++; + break; + + case 'd': + debugUpdate( _debug + 1 ); + break; + + case 'h': + printHelp( false, false ); + return SUCCESS; + + case LC_DEBUG: + debugUpdate( std::strtoul( prog::optarg, NULL, 0 ) ); + break; + + case LC_VERBOSE: + { + const uint32_t level = std::strtoul( prog::optarg, NULL, 0 ); + _verbosity = ( level < 4 ) ? level : 3; + break; + } + + case LC_HELP: + printHelp( true, false ); + return SUCCESS; + + case LC_VERSION: + printVersion( false ); + return SUCCESS; + + case LC_VERSIONX: + printVersion( true ); + return SUCCESS; + + default: + printUsage( true ); + return FAILURE; + } + } + + if( !(prog::optind < _argc) ) { + printUsage( true ); + return FAILURE; + } + + const bool result = batch( prog::optind ); + verbose2f( "exit code %d\n", result ); + return result; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +Utility::openFileForWriting( io::File& file ) +{ + // simple case is file does not exist + if( !io::FileSystem::exists( file.name )) { + if( file.open() ) + return herrf( "unable to open %s for write: %s\n", file.name.c_str(), sys::getLastErrorStr() ); + return SUCCESS; + } + + // fail if overwrite is not enabled + if( !_overwrite ) + return herrf( "file already exists: %s\n", file.name.c_str() ); + + // only overwrite if it is a file + if( !io::FileSystem::isFile( file.name )) + return herrf( "cannot overwrite non-file: %s\n", file.name.c_str() ); + + // first attemp to re-open/truncate so as to keep any file perms + if( !file.open() ) + return SUCCESS; + + // fail if force is not enabled + if( !_force ) + return herrf( "unable to overwrite file: %s\n", file.name.c_str() ); + + // first attempt to open, truncating file + if( !file.open() ) + return SUCCESS; + + // nuke file + if( ::remove( file.name.c_str() )) + return herrf( "unable to remove %s: %s\n", file.name.c_str(), sys::getLastErrorStr() ); + + // final effort + if( !file.open() ) + return SUCCESS; + + return herrf( "unable to open %s for write: %s\n", file.name.c_str(), sys::getLastErrorStr() ); +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Utility::verbose( uint32_t level, const char* format, va_list ap ) +{ + if( level > _verbosity ) + return; + vfprintf( stdout, format, ap ); +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Utility::verbose1f( const char* format, ... ) +{ + va_list ap; + va_start( ap, format ); + verbose( 1, format, ap ); + va_end( ap ); +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Utility::verbose2f( const char* format, ... ) +{ + va_list ap; + va_start( ap, format ); + verbose( 2, format, ap ); + va_end( ap ); +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Utility::verbose3f( const char* format, ... ) +{ + va_list ap; + va_start( ap, format ); + verbose( 3, format, ap ); + va_end( ap ); +} + +/////////////////////////////////////////////////////////////////////////////// + +const bool Utility::SUCCESS = false; +const bool Utility::FAILURE = true; + +/////////////////////////////////////////////////////////////////////////////// + +Utility::Group::Group( string name_ ) + : name ( name_ ) + , options ( _options ) +{ +} + +/////////////////////////////////////////////////////////////////////////////// + +Utility::Group::~Group() +{ + const List::iterator ie = _optionsDelete.end(); + for( List::iterator it = _optionsDelete.begin(); it != ie; it++ ) + delete *it; +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Utility::Group::add( const Option& option ) +{ + _options.push_back( &option ); +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Utility::Group::add( + char scode, + bool shasarg, + string lname, + bool lhasarg, + uint32_t lcode, + string descr, + string argname, + string help, + bool hidden ) +{ + Option* o = new Option( scode, shasarg, lname, lhasarg, lcode, descr, argname, help, hidden ); + _options.push_back( o ); + _optionsDelete.push_back( o ); +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Utility::Group::add( + string lname, + bool lhasarg, + uint32_t lcode, + string descr, + string argname, + string help, + bool hidden ) +{ + add( 0, false, lname, lhasarg, lcode, descr, argname, help, hidden ); +} + +/////////////////////////////////////////////////////////////////////////////// + +Utility::Option::Option( + char scode_, + bool shasarg_, + string lname_, + bool lhasarg_, + uint32_t lcode_, + string descr_, + string argname_, + string help_, + bool hidden_ ) + : scode ( scode_ ) + , shasarg ( shasarg_ ) + , lname ( lname_ ) + , lhasarg ( lhasarg_ ) + , lcode ( lcode_ ) + , descr ( descr_ ) + , argname ( argname_ ) + , help ( help_ ) + , hidden ( hidden_ ) +{ +} + +/////////////////////////////////////////////////////////////////////////////// + +Utility::JobContext::JobContext( string file_ ) + : file ( file_ ) + , fileHandle ( MP4_INVALID_FILE_HANDLE ) + , optimizeApplicable ( false ) +{ +} + +/////////////////////////////////////////////////////////////////////////////// + +}} // namespace mp4v2::util diff --git a/libutil/Utility.h b/libutil/Utility.h new file mode 100644 index 0000000..c8c7caf --- /dev/null +++ b/libutil/Utility.h @@ -0,0 +1,206 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is MP4v2. +// +// The Initial Developer of the Original Code is Kona Blend. +// Portions created by Kona Blend are Copyright (C) 2008. +// All Rights Reserved. +// +// Contributors: +// Kona Blend, kona8lend@@gmail.com +// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef MP4V2_UTIL_UTILITY_H +#define MP4V2_UTIL_UTILITY_H + +namespace mp4v2 { namespace util { + +/////////////////////////////////////////////////////////////////////////////// +/// +/// Utility general program class. +/// +/// This class provides a base implementation for a general utility which +/// helps meet behavioral criteria for command-line executables. +/// +/// Inherit batch processing ability is also provided and is used optionally +/// by the concrete implementation. +/// +/// Criteria and guidelines for utility behavior in MP4v2 are as follows: +/// @li exit with 0 when the utility succeeds at its main task, 1 for failure. +/// @li print brief-usage when no arguments are supplied and exit with 1. +/// @li print brief-usage when too many arguments are supplied and exit with 1. +/// @li issue brief-usage when invalid argument is supplied and exit with 1. +/// @li support --help option and exit with 0. +/// @li support --version option and exit with 0. +/// @li utilities which <b>create</b> new output files should never +/// over-write an existing file unless given the project's universal +/// '-o' or '--overwrite' option. +/// +/////////////////////////////////////////////////////////////////////////////// +class MP4V2_EXPORT Utility +{ +protected: + enum LongCode { + LC_NONE = 0xf0000000, // safe (cannot conflict with char values) + LC_DEBUG, + LC_VERBOSE, + LC_HELP, + LC_VERSION, + LC_VERSIONX, + _LC_MAX // will be used to seeed derived-class long-codes enum + }; + + class MP4V2_EXPORT Option { + public: + Option( char, bool, string, bool, uint32_t, string, string = "ARG", string = "", bool = false ); + + const char scode; + const bool shasarg; + const string lname; + const bool lhasarg; + const uint32_t lcode; + const string descr; + const string argname; + const string help; + const bool hidden; + }; + + class MP4V2_EXPORT Group { + public: + explicit Group( string ); + ~Group(); + + void add( const Option& ); // options added this way will not be deleted + void add( char, bool, string, bool, uint32_t, string, string = "ARG", string = "", bool = false ); + void add( string, bool, uint32_t, string, string = "ARG", string = "", bool = false ); + + const string name; + + public: + typedef list<const Option*> List; + + private: + List _options; + List _optionsDelete; + + public: + const List& options; + }; + + //! structure passed as argument to each job during batch processing + class MP4V2_EXPORT JobContext + { + public: + JobContext( string file_ ); + + const string file; //!< file job is working on + MP4FileHandle fileHandle; //!< handle of file, if applicable to job + bool optimizeApplicable; //!< indicate file optimization is applicable + list<void*> tofree; //!< memory to free at end of job + }; + +public: + virtual ~Utility(); + + bool process(); + +protected: + Utility( string, int, char** ); + + void printUsage ( bool ); //!< print usage + void printHelp ( bool, bool ); //!< print help + void printVersion ( bool ); //!< print utility version + + void errf ( const char*, ... ) MP4V2_WFORMAT_PRINTF(2,3); //!< print to stderr + void outf ( const char*, ... ) MP4V2_WFORMAT_PRINTF(2,3); //!< print to stdout + + bool herrf ( const char*, ... ) MP4V2_WFORMAT_PRINTF(2,3); //!< print to stderr indicating error + bool hwarnf ( const char*, ... ) MP4V2_WFORMAT_PRINTF(2,3); //!< print to stderr indicating warning + + void verbose1f ( const char*, ... ) MP4V2_WFORMAT_PRINTF(2,3); + void verbose2f ( const char*, ... ) MP4V2_WFORMAT_PRINTF(2,3); + void verbose3f ( const char*, ... ) MP4V2_WFORMAT_PRINTF(2,3); + + bool batch ( int ); //!< process all remaining arguments (jobs) + bool job ( string ); //!< process next argument + + //! open file in consideration of overwrite/force options + bool openFileForWriting( io::File& ); + + bool dryrunAbort(); + + // delegates + virtual bool utility_option( int, bool& ) = 0; //!< process command-line option + virtual bool utility_job( JobContext& ) = 0; //!< process positional argument + +private: + void formatGroups(); + void debugUpdate( uint32_t ); + void verbose( uint32_t, const char*, va_list ); + bool process_impl(); + +private: + string _help; + + prog::Option* _longOptions; + string _shortOptions; + +protected: + const string _name; //!< executable basename + const int _argc; //!< arg count + char* const* const _argv; //!< arg vector + + // common options state + bool _optimize; //!< optimize mp4 file after modification + bool _dryrun; //!< dry-run, no writing is actually performed + bool _keepgoing; //!< contine batch processing even after error + bool _overwrite; //!< overwrite file if already exists + bool _force; //!< force overwriting a file even if read-only + uint32_t _debug; //!< mp4 file I/O verbosity + uint32_t _verbosity; //!< verbosity level, default=1 + + uint32_t _jobCount; + uint32_t _jobTotal; + uint32_t _debugVerbosity; + bool _debugImplicits; + + Group _group; // group to which standard options are added + string _usage; + string _description; + list<Group*> _groups; + +protected: + // standard options for concrete utilities to add to _group in constructor + const Option STD_OPTIMIZE; + const Option STD_DRYRUN; + const Option STD_KEEPGOING; + const Option STD_OVERWRITE; + const Option STD_FORCE; + const Option STD_QUIET; + const Option STD_DEBUG; + const Option STD_VERBOSE; + const Option STD_HELP; + const Option STD_VERSION; + const Option STD_VERSIONX; + +public: + static const bool SUCCESS; + static const bool FAILURE; +}; + +/////////////////////////////////////////////////////////////////////////////// + +}} // namespace mp4v2::util + +#endif // MP4V2_UTIL_UTILITY_H diff --git a/libutil/crc.cpp b/libutil/crc.cpp new file mode 100644 index 0000000..18d1147 --- /dev/null +++ b/libutil/crc.cpp @@ -0,0 +1,110 @@ +/* + * Copyright (c) 1988, 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "libutil/impl.h" + +namespace mp4v2 { namespace util { + +/////////////////////////////////////////////////////////////////////////////// + +uint32_t +crc32( const unsigned char* data, uint32_t size ) +{ + static const uint32_t __crctab[256] = { + 0x0, + 0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b, + 0x1a864db2, 0x1e475005, 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, + 0x2b4bcb61, 0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd, + 0x4c11db70, 0x48d0c6c7, 0x4593e01e, 0x4152fda9, 0x5f15adac, + 0x5bd4b01b, 0x569796c2, 0x52568b75, 0x6a1936c8, 0x6ed82b7f, + 0x639b0da6, 0x675a1011, 0x791d4014, 0x7ddc5da3, 0x709f7b7a, + 0x745e66cd, 0x9823b6e0, 0x9ce2ab57, 0x91a18d8e, 0x95609039, + 0x8b27c03c, 0x8fe6dd8b, 0x82a5fb52, 0x8664e6e5, 0xbe2b5b58, + 0xbaea46ef, 0xb7a96036, 0xb3687d81, 0xad2f2d84, 0xa9ee3033, + 0xa4ad16ea, 0xa06c0b5d, 0xd4326d90, 0xd0f37027, 0xddb056fe, + 0xd9714b49, 0xc7361b4c, 0xc3f706fb, 0xceb42022, 0xca753d95, + 0xf23a8028, 0xf6fb9d9f, 0xfbb8bb46, 0xff79a6f1, 0xe13ef6f4, + 0xe5ffeb43, 0xe8bccd9a, 0xec7dd02d, 0x34867077, 0x30476dc0, + 0x3d044b19, 0x39c556ae, 0x278206ab, 0x23431b1c, 0x2e003dc5, + 0x2ac12072, 0x128e9dcf, 0x164f8078, 0x1b0ca6a1, 0x1fcdbb16, + 0x018aeb13, 0x054bf6a4, 0x0808d07d, 0x0cc9cdca, 0x7897ab07, + 0x7c56b6b0, 0x71159069, 0x75d48dde, 0x6b93dddb, 0x6f52c06c, + 0x6211e6b5, 0x66d0fb02, 0x5e9f46bf, 0x5a5e5b08, 0x571d7dd1, + 0x53dc6066, 0x4d9b3063, 0x495a2dd4, 0x44190b0d, 0x40d816ba, + 0xaca5c697, 0xa864db20, 0xa527fdf9, 0xa1e6e04e, 0xbfa1b04b, + 0xbb60adfc, 0xb6238b25, 0xb2e29692, 0x8aad2b2f, 0x8e6c3698, + 0x832f1041, 0x87ee0df6, 0x99a95df3, 0x9d684044, 0x902b669d, + 0x94ea7b2a, 0xe0b41de7, 0xe4750050, 0xe9362689, 0xedf73b3e, + 0xf3b06b3b, 0xf771768c, 0xfa325055, 0xfef34de2, 0xc6bcf05f, + 0xc27dede8, 0xcf3ecb31, 0xcbffd686, 0xd5b88683, 0xd1799b34, + 0xdc3abded, 0xd8fba05a, 0x690ce0ee, 0x6dcdfd59, 0x608edb80, + 0x644fc637, 0x7a089632, 0x7ec98b85, 0x738aad5c, 0x774bb0eb, + 0x4f040d56, 0x4bc510e1, 0x46863638, 0x42472b8f, 0x5c007b8a, + 0x58c1663d, 0x558240e4, 0x51435d53, 0x251d3b9e, 0x21dc2629, + 0x2c9f00f0, 0x285e1d47, 0x36194d42, 0x32d850f5, 0x3f9b762c, + 0x3b5a6b9b, 0x0315d626, 0x07d4cb91, 0x0a97ed48, 0x0e56f0ff, + 0x1011a0fa, 0x14d0bd4d, 0x19939b94, 0x1d528623, 0xf12f560e, + 0xf5ee4bb9, 0xf8ad6d60, 0xfc6c70d7, 0xe22b20d2, 0xe6ea3d65, + 0xeba91bbc, 0xef68060b, 0xd727bbb6, 0xd3e6a601, 0xdea580d8, + 0xda649d6f, 0xc423cd6a, 0xc0e2d0dd, 0xcda1f604, 0xc960ebb3, + 0xbd3e8d7e, 0xb9ff90c9, 0xb4bcb610, 0xb07daba7, 0xae3afba2, + 0xaafbe615, 0xa7b8c0cc, 0xa379dd7b, 0x9b3660c6, 0x9ff77d71, + 0x92b45ba8, 0x9675461f, 0x8832161a, 0x8cf30bad, 0x81b02d74, + 0x857130c3, 0x5d8a9099, 0x594b8d2e, 0x5408abf7, 0x50c9b640, + 0x4e8ee645, 0x4a4ffbf2, 0x470cdd2b, 0x43cdc09c, 0x7b827d21, + 0x7f436096, 0x7200464f, 0x76c15bf8, 0x68860bfd, 0x6c47164a, + 0x61043093, 0x65c52d24, 0x119b4be9, 0x155a565e, 0x18197087, + 0x1cd86d30, 0x029f3d35, 0x065e2082, 0x0b1d065b, 0x0fdc1bec, + 0x3793a651, 0x3352bbe6, 0x3e119d3f, 0x3ad08088, 0x2497d08d, + 0x2056cd3a, 0x2d15ebe3, 0x29d4f654, 0xc5a92679, 0xc1683bce, + 0xcc2b1d17, 0xc8ea00a0, 0xd6ad50a5, 0xd26c4d12, 0xdf2f6bcb, + 0xdbee767c, 0xe3a1cbc1, 0xe760d676, 0xea23f0af, 0xeee2ed18, + 0xf0a5bd1d, 0xf464a0aa, 0xf9278673, 0xfde69bc4, 0x89b8fd09, + 0x8d79e0be, 0x803ac667, 0x84fbdbd0, 0x9abc8bd5, 0x9e7d9662, + 0x933eb0bb, 0x97ffad0c, 0xafb010b1, 0xab710d06, 0xa6322bdf, + 0xa2f33668, 0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4, + }; + +#define COMPUTE(var,ch) (var) = (var) << 8 ^ __crctab[(var) >> 24 ^ (ch)] + + uint32_t crc = 0; + const unsigned char* const max = data + size; + + for (const unsigned char* p = data; p < max; p++) + COMPUTE( crc, *p ); + + for( ; size != 0; size >>= 8 ) + COMPUTE( crc, size & 0xff ); + + return ~crc; +} + +/////////////////////////////////////////////////////////////////////////////// + +}} // namespace mp4v2::util diff --git a/libutil/crc.h b/libutil/crc.h new file mode 100644 index 0000000..470b14d --- /dev/null +++ b/libutil/crc.h @@ -0,0 +1,38 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is MP4v2. +// +// The Initial Developer of the Original Code is Kona Blend. +// Portions created by Kona Blend are Copyright (C) 2008. +// All Rights Reserved. +// +// Contributors: +// Kona Blend, kona8lend@@gmail.com +// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef MP4V2_UTIL_CRC_H +#define MP4V2_UTIL_CRC_H + +namespace mp4v2 { namespace util { + +/////////////////////////////////////////////////////////////////////////////// + +MP4V2_EXPORT +uint32_t crc32( const unsigned char*, uint32_t ); // ISO/IEC 8802-3:1989 + +/////////////////////////////////////////////////////////////////////////////// + +}} // namespace mp4v2::util + +#endif // MP4V2_UTIL_CRC_H diff --git a/libutil/impl.h b/libutil/impl.h new file mode 100644 index 0000000..3824a14 --- /dev/null +++ b/libutil/impl.h @@ -0,0 +1,10 @@ +#ifndef MP4V2_UTIL_IMPL_H +#define MP4V2_UTIL_IMPL_H + +/////////////////////////////////////////////////////////////////////////////// + +#include "util.h" + +/////////////////////////////////////////////////////////////////////////////// + +#endif // MP4V2_UTIL_IMPL_H diff --git a/libutil/other.cpp b/libutil/other.cpp new file mode 100644 index 0000000..698b588 --- /dev/null +++ b/libutil/other.cpp @@ -0,0 +1,106 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is MP4v2. +// +// The Initial Developer of the Original Code is Kona Blend. +// Portions created by Kona Blend are Copyright (C) 2008. +// All Rights Reserved. +// +// Contributors: +// Kona Blend, kona8lend@@gmail.com +// +/////////////////////////////////////////////////////////////////////////////// + +#include "libutil/impl.h" + +namespace mp4v2 { namespace util { + using namespace mp4v2::impl; + +/////////////////////////////////////////////////////////////////////////////// + +// search atom recursively for any 64-bit characteristics. +// nlargsize indicates number of atoms which use largesize extension. +// nversion1 indicates number of atoms which use version==1 extension. +// nspecial indicates number of special 64-bit atoms; +// eg: stbl may container one of { stco || co64 } for chunkoffsets. + +void +searchFor64bit( MP4Atom& atom, FileSummaryInfo& info ) +{ + const uint32_t max = atom.GetNumberOfChildAtoms(); + for( uint32_t i = 0; i < max; i++ ) { + MP4Atom& child = *atom.GetChildAtom( i ); + + if( child.GetLargesizeMode() ) + info.nlargesize++; + + MP4Integer8Property* version; + if( child.FindProperty( "version", (MP4Property**)&version ) && version->GetValue() == 1 ) + info.nversion1++; + + if( !strcmp( child.GetType(), "co64" )) + info.nspecial++; + + searchFor64bit( child, info ); + } +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +fileFetchSummaryInfo( MP4FileHandle file, FileSummaryInfo& info ) +{ + if( file == MP4_INVALID_FILE_HANDLE ) + return true; + MP4File& mp4 = *((MP4File*)file); + + MP4Atom* root = mp4.FindAtom( "" ); + if( !root ) + return true; + + MP4FtypAtom* ftyp = (MP4FtypAtom*)root->FindAtom( "ftyp" ); + if( !ftyp ) + return true; + + info.major_brand = ftyp->majorBrand.GetValue(); + info.minor_version = ftyp->minorVersion.GetValue(); + + const uint32_t cbmax = ftyp->compatibleBrands.GetCount(); + for( uint32_t i = 0; i < cbmax; i++ ) { + string s = ftyp->compatibleBrands.GetValue( i ); + + // remove spaces so brand set is presentable + string stripped; + const string::size_type max = s.length(); + for( string::size_type pos = 0; pos < max; pos++ ) { + if( s[pos] != ' ' ) + stripped += s[pos]; + } + + if( stripped.empty() ) + continue; + + info.compatible_brands.insert( stripped ); + } + + info.nlargesize = 0; + info.nversion1 = 0; + info.nspecial = 0; + searchFor64bit( *root, info ); + + return false; +} + +/////////////////////////////////////////////////////////////////////////////// + +}} // namespace mp4v2::util diff --git a/libutil/other.h b/libutil/other.h new file mode 100644 index 0000000..83d5411 --- /dev/null +++ b/libutil/other.h @@ -0,0 +1,40 @@ +#ifndef MP4V2_UTIL_OTHER_H +#define MP4V2_UTIL_OTHER_H + +/////////////////////////////////////////////////////////////////////////////// + +namespace mp4v2 { namespace util { + +/////////////////////////////////////////////////////////////////////////////// + +struct MP4V2_EXPORT FileSummaryInfo { + typedef set<string> BrandSet; + + // standard ftyp box attributes + string major_brand; + uint32_t minor_version; + BrandSet compatible_brands; + + uint32_t nlargesize; + uint32_t nversion1; + uint32_t nspecial; +}; + +/////////////////////////////////////////////////////////////////////////////// +/// +/// Fetch mp4 file summary information. +/// +/// This function fetches summary information for <b>file</b> and information +/// is stored in <b>info</b>. +/// +/// @return On success <b>true</b>. +/// On failure <b>false</b>, and contents of <b>info</b> are undefined. +/// +MP4V2_EXPORT +bool fileFetchSummaryInfo( MP4FileHandle file, FileSummaryInfo& info ); + +/////////////////////////////////////////////////////////////////////////////// + +}} // namespace mp4v2::util + +#endif // MP4V2_UTIL_OTHER_H diff --git a/libutil/util.h b/libutil/util.h new file mode 100644 index 0000000..2ea7246 --- /dev/null +++ b/libutil/util.h @@ -0,0 +1,34 @@ +#ifndef MP4V2_UTIL_UTIL_H +#define MP4V2_UTIL_UTIL_H + +/////////////////////////////////////////////////////////////////////////////// + +#include "src/src.h" + +/////////////////////////////////////////////////////////////////////////////// + +/// @namespace mp4v2::util (private) Command-line utility support. +/// <b>WARNING: THIS IS A PRIVATE NAMESPACE. NOT FOR PUBLIC CONSUMPTION.</b> +/// +/// This namespace is used for command-line utilities. Some symbols from this +/// namespace are exported from libmp4v2 in order to support new functionality +/// which may or may not make it into some form of public API, at which time +/// it will be moved out of this namespace. +/// +namespace mp4v2 { namespace util { + using namespace std; + using namespace mp4v2::impl; +}} // namespace mp4v2::util + +/////////////////////////////////////////////////////////////////////////////// + +#include "Database.h" +#include "Timecode.h" +#include "TrackModifier.h" +#include "Utility.h" +#include "crc.h" +#include "other.h" + +/////////////////////////////////////////////////////////////////////////////// + +#endif // MP4V2_UTIL_UTIL_H diff --git a/mp4v2.xcodeproj/project.pbxproj b/mp4v2.xcodeproj/project.pbxproj new file mode 100644 index 0000000..75f968e --- /dev/null +++ b/mp4v2.xcodeproj/project.pbxproj @@ -0,0 +1,974 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 45; + objects = { + +/* Begin PBXBuildFile section */ + D74419F610D1C59300116965 /* config.h in Headers */ = {isa = PBXBuildFile; fileRef = D74419EF10D1C59300116965 /* config.h */; }; + D74419F710D1C59300116965 /* endian.h in Headers */ = {isa = PBXBuildFile; fileRef = D74419F010D1C59300116965 /* endian.h */; }; + D74419F810D1C59300116965 /* impl.h in Headers */ = {isa = PBXBuildFile; fileRef = D74419F110D1C59300116965 /* impl.h */; }; + D74419F910D1C59300116965 /* platform.h in Headers */ = {isa = PBXBuildFile; fileRef = D74419F210D1C59300116965 /* platform.h */; }; + D74419FA10D1C59300116965 /* platform_base.h in Headers */ = {isa = PBXBuildFile; fileRef = D74419F310D1C59300116965 /* platform_base.h */; }; + D74419FB10D1C59300116965 /* platform_posix.h in Headers */ = {isa = PBXBuildFile; fileRef = D74419F410D1C59300116965 /* platform_posix.h */; }; + D74419FC10D1C59300116965 /* warning.h in Headers */ = {isa = PBXBuildFile; fileRef = D74419F510D1C59300116965 /* warning.h */; }; + D750F00410D1C264009AA50B /* File.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F00010D1C264009AA50B /* File.cpp */; }; + D750F00510D1C264009AA50B /* File_posix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F00110D1C264009AA50B /* File_posix.cpp */; }; + D750F00610D1C264009AA50B /* FileSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F00210D1C264009AA50B /* FileSystem.cpp */; }; + D750F00710D1C264009AA50B /* FileSystem_posix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F00310D1C264009AA50B /* FileSystem_posix.cpp */; }; + D750F00A10D1C280009AA50B /* random_posix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F00910D1C280009AA50B /* random_posix.cpp */; }; + D750F00C10D1C28F009AA50B /* random.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F00B10D1C28F009AA50B /* random.h */; }; + D750F01010D1C2AC009AA50B /* FileSystem.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F00E10D1C2AC009AA50B /* FileSystem.h */; }; + D750F01710D1C302009AA50B /* process.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F01510D1C302009AA50B /* process.h */; }; + D750F01810D1C302009AA50B /* process_posix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F01610D1C302009AA50B /* process_posix.cpp */; }; + D750F01B10D1C316009AA50B /* option.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F01910D1C316009AA50B /* option.cpp */; }; + D750F01C10D1C316009AA50B /* option.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F01A10D1C316009AA50B /* option.h */; }; + D750F01F10D1C339009AA50B /* error.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F01D10D1C339009AA50B /* error.cpp */; }; + D750F02410D1C348009AA50B /* time.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F02110D1C348009AA50B /* time.cpp */; }; + D750F02610D1C348009AA50B /* time_posix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F02310D1C348009AA50B /* time_posix.cpp */; }; + D750F03510D1C375009AA50B /* crc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F02710D1C375009AA50B /* crc.cpp */; }; + D750F03610D1C375009AA50B /* crc.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F02810D1C375009AA50B /* crc.h */; }; + D750F03710D1C375009AA50B /* Database.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F02910D1C375009AA50B /* Database.cpp */; }; + D750F03810D1C375009AA50B /* Database.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F02A10D1C375009AA50B /* Database.h */; }; + D750F03910D1C375009AA50B /* impl.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F02B10D1C375009AA50B /* impl.h */; }; + D750F03A10D1C375009AA50B /* other.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F02C10D1C375009AA50B /* other.cpp */; }; + D750F03B10D1C375009AA50B /* other.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F02D10D1C375009AA50B /* other.h */; }; + D750F03C10D1C375009AA50B /* Timecode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F02E10D1C375009AA50B /* Timecode.cpp */; }; + D750F03D10D1C375009AA50B /* Timecode.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F02F10D1C375009AA50B /* Timecode.h */; }; + D750F03E10D1C375009AA50B /* TrackModifier.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F03010D1C375009AA50B /* TrackModifier.cpp */; }; + D750F03F10D1C375009AA50B /* TrackModifier.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F03110D1C375009AA50B /* TrackModifier.h */; }; + D750F04010D1C375009AA50B /* util.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F03210D1C375009AA50B /* util.h */; }; + D750F04110D1C375009AA50B /* Utility.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F03310D1C375009AA50B /* Utility.cpp */; }; + D750F04210D1C375009AA50B /* Utility.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F03410D1C375009AA50B /* Utility.h */; }; + D750F05A10D1C42B009AA50B /* chapter.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F04A10D1C42B009AA50B /* chapter.h */; }; + D750F05B10D1C42B009AA50B /* file.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F04B10D1C42B009AA50B /* file.h */; }; + D750F05C10D1C42B009AA50B /* file_prop.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F04C10D1C42B009AA50B /* file_prop.h */; }; + D750F05D10D1C42B009AA50B /* general.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F04D10D1C42B009AA50B /* general.h */; }; + D750F05E10D1C42B009AA50B /* isma.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F04E10D1C42B009AA50B /* isma.h */; }; + D750F05F10D1C42B009AA50B /* itmf_generic.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F04F10D1C42B009AA50B /* itmf_generic.h */; }; + D750F06010D1C42B009AA50B /* itmf_tags.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F05010D1C42B009AA50B /* itmf_tags.h */; }; + D750F06110D1C42B009AA50B /* meta.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F05110D1C42B009AA50B /* meta.h */; }; + D750F06210D1C42B009AA50B /* mp4v2.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F05210D1C42B009AA50B /* mp4v2.h */; }; + D750F06310D1C42B009AA50B /* platform.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F05310D1C42B009AA50B /* platform.h */; }; + D750F06410D1C42B009AA50B /* project.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F05410D1C42B009AA50B /* project.h */; }; + D750F06510D1C42B009AA50B /* sample.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F05610D1C42B009AA50B /* sample.h */; }; + D750F06610D1C42B009AA50B /* streaming.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F05710D1C42B009AA50B /* streaming.h */; }; + D750F06710D1C42B009AA50B /* track.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F05810D1C42B009AA50B /* track.h */; }; + D750F06810D1C42B009AA50B /* track_prop.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F05910D1C42B009AA50B /* track_prop.h */; }; + D750F0CB10D1C4A8009AA50B /* 3gp.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F06910D1C4A8009AA50B /* 3gp.cpp */; }; + D750F0CC10D1C4A8009AA50B /* atom_ac3.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F06A10D1C4A8009AA50B /* atom_ac3.cpp */; }; + D750F0CD10D1C4A8009AA50B /* atom_amr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F06B10D1C4A8009AA50B /* atom_amr.cpp */; }; + D750F0CE10D1C4A8009AA50B /* atom_avc1.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F06C10D1C4A8009AA50B /* atom_avc1.cpp */; }; + D750F0CF10D1C4A8009AA50B /* atom_avcC.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F06D10D1C4A8009AA50B /* atom_avcC.cpp */; }; + D750F0D010D1C4A8009AA50B /* atom_chpl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F06E10D1C4A8009AA50B /* atom_chpl.cpp */; }; + D750F0D110D1C4A8009AA50B /* atom_colr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F06F10D1C4A8009AA50B /* atom_colr.cpp */; }; + D750F0D210D1C4A8009AA50B /* atom_d263.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F07010D1C4A8009AA50B /* atom_d263.cpp */; }; + D750F0D310D1C4A8009AA50B /* atom_dac3.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F07110D1C4A8009AA50B /* atom_dac3.cpp */; }; + D750F0D410D1C4A8009AA50B /* atom_damr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F07210D1C4A8009AA50B /* atom_damr.cpp */; }; + D750F0D510D1C4A8009AA50B /* atom_dref.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F07310D1C4A8009AA50B /* atom_dref.cpp */; }; + D750F0D610D1C4A8009AA50B /* atom_elst.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F07410D1C4A8009AA50B /* atom_elst.cpp */; }; + D750F0D710D1C4A8009AA50B /* atom_enca.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F07510D1C4A8009AA50B /* atom_enca.cpp */; }; + D750F0D810D1C4A8009AA50B /* atom_encv.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F07610D1C4A8009AA50B /* atom_encv.cpp */; }; + D750F0D910D1C4A8009AA50B /* atom_free.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F07710D1C4A8009AA50B /* atom_free.cpp */; }; + D750F0DA10D1C4A8009AA50B /* atom_ftab.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F07810D1C4A8009AA50B /* atom_ftab.cpp */; }; + D750F0DB10D1C4A8009AA50B /* atom_ftyp.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F07910D1C4A8009AA50B /* atom_ftyp.cpp */; }; + D750F0DC10D1C4A8009AA50B /* atom_gmin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F07A10D1C4A8009AA50B /* atom_gmin.cpp */; }; + D750F0DD10D1C4A8009AA50B /* atom_hdlr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F07B10D1C4A8009AA50B /* atom_hdlr.cpp */; }; + D750F0DE10D1C4A8009AA50B /* atom_hinf.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F07C10D1C4A8009AA50B /* atom_hinf.cpp */; }; + D750F0DF10D1C4A8009AA50B /* atom_hnti.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F07D10D1C4A8009AA50B /* atom_hnti.cpp */; }; + D750F0E010D1C4A8009AA50B /* atom_href.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F07E10D1C4A8009AA50B /* atom_href.cpp */; }; + D750F0E110D1C4A8009AA50B /* atom_mdat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F07F10D1C4A8009AA50B /* atom_mdat.cpp */; }; + D750F0E210D1C4A8009AA50B /* atom_mdhd.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F08010D1C4A8009AA50B /* atom_mdhd.cpp */; }; + D750F0E310D1C4A8009AA50B /* atom_meta.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F08110D1C4A8009AA50B /* atom_meta.cpp */; }; + D750F0E410D1C4A8009AA50B /* atom_mp4s.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F08210D1C4A8009AA50B /* atom_mp4s.cpp */; }; + D750F0E510D1C4A8009AA50B /* atom_mp4v.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F08310D1C4A8009AA50B /* atom_mp4v.cpp */; }; + D750F0E610D1C4A8009AA50B /* atom_mvhd.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F08410D1C4A8009AA50B /* atom_mvhd.cpp */; }; + D750F0E710D1C4A8009AA50B /* atom_nmhd.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F08510D1C4A8009AA50B /* atom_nmhd.cpp */; }; + D750F0E810D1C4A8009AA50B /* atom_ohdr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F08610D1C4A8009AA50B /* atom_ohdr.cpp */; }; + D750F0E910D1C4A8009AA50B /* atom_pasp.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F08710D1C4A8009AA50B /* atom_pasp.cpp */; }; + D750F0EA10D1C4A8009AA50B /* atom_root.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F08810D1C4A8009AA50B /* atom_root.cpp */; }; + D750F0EB10D1C4A8009AA50B /* atom_rtp.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F08910D1C4A8009AA50B /* atom_rtp.cpp */; }; + D750F0EC10D1C4A8009AA50B /* atom_s263.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F08A10D1C4A8009AA50B /* atom_s263.cpp */; }; + D750F0ED10D1C4A8009AA50B /* atom_sdp.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F08B10D1C4A8009AA50B /* atom_sdp.cpp */; }; + D750F0EE10D1C4A8009AA50B /* atom_sdtp.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F08C10D1C4A8009AA50B /* atom_sdtp.cpp */; }; + D750F0EF10D1C4A8009AA50B /* atom_smi.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F08D10D1C4A8009AA50B /* atom_smi.cpp */; }; + D750F0F010D1C4A8009AA50B /* atom_sound.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F08E10D1C4A8009AA50B /* atom_sound.cpp */; }; + D750F0F110D1C4A8009AA50B /* atom_standard.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F08F10D1C4A8009AA50B /* atom_standard.cpp */; }; + D750F0F210D1C4A8009AA50B /* atom_stbl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F09010D1C4A8009AA50B /* atom_stbl.cpp */; }; + D750F0F310D1C4A8009AA50B /* atom_stdp.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F09110D1C4A8009AA50B /* atom_stdp.cpp */; }; + D750F0F410D1C4A8009AA50B /* atom_stsc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F09210D1C4A8009AA50B /* atom_stsc.cpp */; }; + D750F0F510D1C4A8009AA50B /* atom_stsd.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F09310D1C4A8009AA50B /* atom_stsd.cpp */; }; + D750F0F610D1C4A8009AA50B /* atom_stsz.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F09410D1C4A8009AA50B /* atom_stsz.cpp */; }; + D750F0F710D1C4A8009AA50B /* atom_stz2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F09510D1C4A8009AA50B /* atom_stz2.cpp */; }; + D750F0F810D1C4A8009AA50B /* atom_text.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F09610D1C4A8009AA50B /* atom_text.cpp */; }; + D750F0F910D1C4A8009AA50B /* atom_tfhd.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F09710D1C4A8009AA50B /* atom_tfhd.cpp */; }; + D750F0FA10D1C4A8009AA50B /* atom_tkhd.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F09810D1C4A8009AA50B /* atom_tkhd.cpp */; }; + D750F0FB10D1C4A8009AA50B /* atom_treftype.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F09910D1C4A8009AA50B /* atom_treftype.cpp */; }; + D750F0FC10D1C4A8009AA50B /* atom_trun.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F09A10D1C4A8009AA50B /* atom_trun.cpp */; }; + D750F0FD10D1C4A8009AA50B /* atom_tx3g.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F09B10D1C4A8009AA50B /* atom_tx3g.cpp */; }; + D750F0FE10D1C4A8009AA50B /* atom_udta.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F09C10D1C4A8009AA50B /* atom_udta.cpp */; }; + D750F0FF10D1C4A8009AA50B /* atom_url.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F09D10D1C4A8009AA50B /* atom_url.cpp */; }; + D750F10010D1C4A8009AA50B /* atom_urn.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F09E10D1C4A8009AA50B /* atom_urn.cpp */; }; + D750F10110D1C4A8009AA50B /* atom_uuid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F09F10D1C4A8009AA50B /* atom_uuid.cpp */; }; + D750F10210D1C4A8009AA50B /* atom_video.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F0A010D1C4A8009AA50B /* atom_video.cpp */; }; + D750F10310D1C4A8009AA50B /* atom_vmhd.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F0A110D1C4A8009AA50B /* atom_vmhd.cpp */; }; + D750F10410D1C4A8009AA50B /* atoms.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F0A210D1C4A8009AA50B /* atoms.h */; }; + D750F10510D1C4A8009AA50B /* cmeta.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F0A310D1C4A8009AA50B /* cmeta.cpp */; }; + D750F10610D1C4A8009AA50B /* descriptors.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F0A410D1C4A8009AA50B /* descriptors.cpp */; }; + D750F10710D1C4A8009AA50B /* descriptors.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F0A510D1C4A8009AA50B /* descriptors.h */; }; + D750F10810D1C4A8009AA50B /* enum.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F0A610D1C4A8009AA50B /* enum.h */; }; + D750F10910D1C4A8009AA50B /* exception.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F0A710D1C4A8009AA50B /* exception.cpp */; }; + D750F10A10D1C4A8009AA50B /* exception.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F0A810D1C4A8009AA50B /* exception.h */; }; + D750F10B10D1C4A8009AA50B /* impl.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F0A910D1C4A8009AA50B /* impl.h */; }; + D750F10C10D1C4A8009AA50B /* isma.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F0AA10D1C4A8009AA50B /* isma.cpp */; }; + D750F10D10D1C4A8009AA50B /* mp4.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F0AB10D1C4A8009AA50B /* mp4.cpp */; }; + D750F10E10D1C4A8009AA50B /* mp4array.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F0AC10D1C4A8009AA50B /* mp4array.h */; }; + D750F10F10D1C4A8009AA50B /* mp4atom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F0AD10D1C4A8009AA50B /* mp4atom.cpp */; }; + D750F11010D1C4A8009AA50B /* mp4atom.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F0AE10D1C4A8009AA50B /* mp4atom.h */; }; + D750F11110D1C4A8009AA50B /* mp4container.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F0AF10D1C4A8009AA50B /* mp4container.cpp */; }; + D750F11210D1C4A8009AA50B /* mp4container.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F0B010D1C4A8009AA50B /* mp4container.h */; }; + D750F11310D1C4A8009AA50B /* mp4descriptor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F0B110D1C4A8009AA50B /* mp4descriptor.cpp */; }; + D750F11410D1C4A8009AA50B /* mp4descriptor.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F0B210D1C4A8009AA50B /* mp4descriptor.h */; }; + D750F11510D1C4A8009AA50B /* mp4error.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F0B310D1C4A8009AA50B /* mp4error.h */; }; + D750F11610D1C4A8009AA50B /* mp4file.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F0B410D1C4A8009AA50B /* mp4file.cpp */; }; + D750F11710D1C4A8009AA50B /* mp4file.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F0B510D1C4A8009AA50B /* mp4file.h */; }; + D750F11810D1C4A8009AA50B /* mp4file_io.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F0B610D1C4A8009AA50B /* mp4file_io.cpp */; }; + D750F11910D1C4A8009AA50B /* mp4info.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F0B710D1C4A8009AA50B /* mp4info.cpp */; }; + D750F11A10D1C4A8009AA50B /* mp4meta.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F0B810D1C4A8009AA50B /* mp4meta.cpp */; }; + D750F11B10D1C4A8009AA50B /* mp4property.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F0B910D1C4A8009AA50B /* mp4property.cpp */; }; + D750F11C10D1C4A8009AA50B /* mp4property.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F0BA10D1C4A8009AA50B /* mp4property.h */; }; + D750F11D10D1C4A8009AA50B /* mp4track.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F0BB10D1C4A8009AA50B /* mp4track.cpp */; }; + D750F11E10D1C4A8009AA50B /* mp4track.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F0BC10D1C4A8009AA50B /* mp4track.h */; }; + D750F11F10D1C4A8009AA50B /* mp4util.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F0BD10D1C4A8009AA50B /* mp4util.cpp */; }; + D750F12010D1C4A8009AA50B /* mp4util.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F0BE10D1C4A8009AA50B /* mp4util.h */; }; + D750F12110D1C4A8009AA50B /* ocidescriptors.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F0BF10D1C4A8009AA50B /* ocidescriptors.cpp */; }; + D750F12210D1C4A8009AA50B /* ocidescriptors.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F0C010D1C4A8009AA50B /* ocidescriptors.h */; }; + D750F12310D1C4A8009AA50B /* odcommands.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F0C110D1C4A8009AA50B /* odcommands.cpp */; }; + D750F12410D1C4A8009AA50B /* odcommands.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F0C210D1C4A8009AA50B /* odcommands.h */; }; + D750F12510D1C4A8009AA50B /* qosqualifiers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F0C310D1C4A8009AA50B /* qosqualifiers.cpp */; }; + D750F12610D1C4A8009AA50B /* qosqualifiers.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F0C410D1C4A8009AA50B /* qosqualifiers.h */; }; + D750F12710D1C4A8009AA50B /* rtphint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F0C510D1C4A8009AA50B /* rtphint.cpp */; }; + D750F12810D1C4A8009AA50B /* rtphint.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F0C610D1C4A8009AA50B /* rtphint.h */; }; + D750F12910D1C4A8009AA50B /* src.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F0C710D1C4A8009AA50B /* src.h */; }; + D750F12A10D1C4A8009AA50B /* text.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F0C810D1C4A8009AA50B /* text.cpp */; }; + D750F12B10D1C4A8009AA50B /* text.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F0C910D1C4A8009AA50B /* text.h */; }; + D750F12C10D1C4A8009AA50B /* util.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F0CA10D1C4A8009AA50B /* util.h */; }; + D750F13110D1C4C1009AA50B /* bmff.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F12D10D1C4C1009AA50B /* bmff.h */; }; + D750F13210D1C4C1009AA50B /* impl.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F12E10D1C4C1009AA50B /* impl.h */; }; + D750F13310D1C4C1009AA50B /* typebmff.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F12F10D1C4C1009AA50B /* typebmff.cpp */; }; + D750F13410D1C4C1009AA50B /* typebmff.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F13010D1C4C1009AA50B /* typebmff.h */; }; + D750F13F10D1C4DE009AA50B /* CoverArtBox.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F13510D1C4DE009AA50B /* CoverArtBox.cpp */; }; + D750F14010D1C4DE009AA50B /* CoverArtBox.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F13610D1C4DE009AA50B /* CoverArtBox.h */; }; + D750F14110D1C4DE009AA50B /* generic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F13710D1C4DE009AA50B /* generic.cpp */; }; + D750F14210D1C4DE009AA50B /* generic.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F13810D1C4DE009AA50B /* generic.h */; }; + D750F14310D1C4DE009AA50B /* impl.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F13910D1C4DE009AA50B /* impl.h */; }; + D750F14410D1C4DE009AA50B /* itmf.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F13A10D1C4DE009AA50B /* itmf.h */; }; + D750F14510D1C4DE009AA50B /* Tags.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F13B10D1C4DE009AA50B /* Tags.cpp */; }; + D750F14610D1C4DE009AA50B /* Tags.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F13C10D1C4DE009AA50B /* Tags.h */; }; + D750F14710D1C4DE009AA50B /* type.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F13D10D1C4DE009AA50B /* type.cpp */; }; + D750F14810D1C4DE009AA50B /* type.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F13E10D1C4DE009AA50B /* type.h */; }; + D750F15110D1C4F5009AA50B /* coding.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F14910D1C4F5009AA50B /* coding.cpp */; }; + D750F15210D1C4F5009AA50B /* coding.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F14A10D1C4F5009AA50B /* coding.h */; }; + D750F15310D1C4F5009AA50B /* ColorParameterBox.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F14B10D1C4F5009AA50B /* ColorParameterBox.cpp */; }; + D750F15410D1C4F5009AA50B /* ColorParameterBox.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F14C10D1C4F5009AA50B /* ColorParameterBox.h */; }; + D750F15510D1C4F5009AA50B /* impl.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F14D10D1C4F5009AA50B /* impl.h */; }; + D750F15610D1C4F5009AA50B /* PictureAspectRatioBox.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D750F14E10D1C4F5009AA50B /* PictureAspectRatioBox.cpp */; }; + D750F15710D1C4F5009AA50B /* PictureAspectRatioBox.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F14F10D1C4F5009AA50B /* PictureAspectRatioBox.h */; }; + D750F15810D1C4F5009AA50B /* qtff.h in Headers */ = {isa = PBXBuildFile; fileRef = D750F15010D1C4F5009AA50B /* qtff.h */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + B033B6950B2FAA7C00CEEEDA /* MacConfigExternalDebug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.xcconfig; name = MacConfigExternalDebug.xcconfig; path = ../MacConfigExternalDebug.xcconfig; sourceTree = SOURCE_ROOT; }; + B033B6960B2FAA7C00CEEEDA /* MacConfigExternalRelease.xcconfig */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.xcconfig; name = MacConfigExternalRelease.xcconfig; path = ../MacConfigExternalRelease.xcconfig; sourceTree = SOURCE_ROOT; }; + D2AAC046055464E500DB518D /* libmp4v2.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libmp4v2.a; sourceTree = BUILT_PRODUCTS_DIR; }; + D74419EF10D1C59300116965 /* config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = config.h; path = libplatform/config.h; sourceTree = SOURCE_ROOT; }; + D74419F010D1C59300116965 /* endian.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = endian.h; path = libplatform/endian.h; sourceTree = SOURCE_ROOT; }; + D74419F110D1C59300116965 /* impl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = impl.h; path = libplatform/impl.h; sourceTree = SOURCE_ROOT; }; + D74419F210D1C59300116965 /* platform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = platform.h; path = libplatform/platform.h; sourceTree = SOURCE_ROOT; }; + D74419F310D1C59300116965 /* platform_base.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = platform_base.h; path = libplatform/platform_base.h; sourceTree = SOURCE_ROOT; }; + D74419F410D1C59300116965 /* platform_posix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = platform_posix.h; path = libplatform/platform_posix.h; sourceTree = SOURCE_ROOT; }; + D74419F510D1C59300116965 /* warning.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = warning.h; path = libplatform/warning.h; sourceTree = SOURCE_ROOT; }; + D750F00010D1C264009AA50B /* File.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = File.cpp; path = libplatform/io/File.cpp; sourceTree = SOURCE_ROOT; }; + D750F00110D1C264009AA50B /* File_posix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = File_posix.cpp; path = libplatform/io/File_posix.cpp; sourceTree = SOURCE_ROOT; }; + D750F00210D1C264009AA50B /* FileSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FileSystem.cpp; path = libplatform/io/FileSystem.cpp; sourceTree = SOURCE_ROOT; }; + D750F00310D1C264009AA50B /* FileSystem_posix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FileSystem_posix.cpp; path = libplatform/io/FileSystem_posix.cpp; sourceTree = SOURCE_ROOT; }; + D750F00910D1C280009AA50B /* random_posix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = random_posix.cpp; path = libplatform/number/random_posix.cpp; sourceTree = SOURCE_ROOT; }; + D750F00B10D1C28F009AA50B /* random.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = random.h; path = libplatform/number/random.h; sourceTree = SOURCE_ROOT; }; + D750F00E10D1C2AC009AA50B /* FileSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FileSystem.h; path = libplatform/io/FileSystem.h; sourceTree = SOURCE_ROOT; }; + D750F01510D1C302009AA50B /* process.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = process.h; path = libplatform/process/process.h; sourceTree = SOURCE_ROOT; }; + D750F01610D1C302009AA50B /* process_posix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = process_posix.cpp; path = libplatform/process/process_posix.cpp; sourceTree = SOURCE_ROOT; }; + D750F01910D1C316009AA50B /* option.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = option.cpp; path = libplatform/prog/option.cpp; sourceTree = SOURCE_ROOT; }; + D750F01A10D1C316009AA50B /* option.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = option.h; path = libplatform/prog/option.h; sourceTree = SOURCE_ROOT; }; + D750F01D10D1C339009AA50B /* error.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = error.cpp; path = libplatform/sys/error.cpp; sourceTree = SOURCE_ROOT; }; + D750F02110D1C348009AA50B /* time.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = time.cpp; path = libplatform/time/time.cpp; sourceTree = SOURCE_ROOT; }; + D750F02310D1C348009AA50B /* time_posix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = time_posix.cpp; path = libplatform/time/time_posix.cpp; sourceTree = SOURCE_ROOT; }; + D750F02710D1C375009AA50B /* crc.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = crc.cpp; path = libutil/crc.cpp; sourceTree = SOURCE_ROOT; }; + D750F02810D1C375009AA50B /* crc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = crc.h; path = libutil/crc.h; sourceTree = SOURCE_ROOT; }; + D750F02910D1C375009AA50B /* Database.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Database.cpp; path = libutil/Database.cpp; sourceTree = SOURCE_ROOT; }; + D750F02A10D1C375009AA50B /* Database.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Database.h; path = libutil/Database.h; sourceTree = SOURCE_ROOT; }; + D750F02B10D1C375009AA50B /* impl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = impl.h; path = libutil/impl.h; sourceTree = SOURCE_ROOT; }; + D750F02C10D1C375009AA50B /* other.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = other.cpp; path = libutil/other.cpp; sourceTree = SOURCE_ROOT; }; + D750F02D10D1C375009AA50B /* other.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = other.h; path = libutil/other.h; sourceTree = SOURCE_ROOT; }; + D750F02E10D1C375009AA50B /* Timecode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Timecode.cpp; path = libutil/Timecode.cpp; sourceTree = SOURCE_ROOT; }; + D750F02F10D1C375009AA50B /* Timecode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Timecode.h; path = libutil/Timecode.h; sourceTree = SOURCE_ROOT; }; + D750F03010D1C375009AA50B /* TrackModifier.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TrackModifier.cpp; path = libutil/TrackModifier.cpp; sourceTree = SOURCE_ROOT; }; + D750F03110D1C375009AA50B /* TrackModifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TrackModifier.h; path = libutil/TrackModifier.h; sourceTree = SOURCE_ROOT; }; + D750F03210D1C375009AA50B /* util.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = util.h; path = libutil/util.h; sourceTree = SOURCE_ROOT; }; + D750F03310D1C375009AA50B /* Utility.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Utility.cpp; path = libutil/Utility.cpp; sourceTree = SOURCE_ROOT; }; + D750F03410D1C375009AA50B /* Utility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Utility.h; path = libutil/Utility.h; sourceTree = SOURCE_ROOT; }; + D750F04A10D1C42B009AA50B /* chapter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = chapter.h; path = include/mp4v2/chapter.h; sourceTree = SOURCE_ROOT; }; + D750F04B10D1C42B009AA50B /* file.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = file.h; path = include/mp4v2/file.h; sourceTree = SOURCE_ROOT; }; + D750F04C10D1C42B009AA50B /* file_prop.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = file_prop.h; path = include/mp4v2/file_prop.h; sourceTree = SOURCE_ROOT; }; + D750F04D10D1C42B009AA50B /* general.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = general.h; path = include/mp4v2/general.h; sourceTree = SOURCE_ROOT; }; + D750F04E10D1C42B009AA50B /* isma.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = isma.h; path = include/mp4v2/isma.h; sourceTree = SOURCE_ROOT; }; + D750F04F10D1C42B009AA50B /* itmf_generic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = itmf_generic.h; path = include/mp4v2/itmf_generic.h; sourceTree = SOURCE_ROOT; }; + D750F05010D1C42B009AA50B /* itmf_tags.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = itmf_tags.h; path = include/mp4v2/itmf_tags.h; sourceTree = SOURCE_ROOT; }; + D750F05110D1C42B009AA50B /* meta.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = meta.h; path = include/mp4v2/meta.h; sourceTree = SOURCE_ROOT; }; + D750F05210D1C42B009AA50B /* mp4v2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mp4v2.h; path = include/mp4v2/mp4v2.h; sourceTree = SOURCE_ROOT; }; + D750F05310D1C42B009AA50B /* platform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = platform.h; path = include/mp4v2/platform.h; sourceTree = SOURCE_ROOT; }; + D750F05410D1C42B009AA50B /* project.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = project.h; path = include/mp4v2/project.h; sourceTree = SOURCE_ROOT; }; + D750F05510D1C42B009AA50B /* project.h.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = project.h.in; path = include/mp4v2/project.h.in; sourceTree = SOURCE_ROOT; }; + D750F05610D1C42B009AA50B /* sample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = sample.h; path = include/mp4v2/sample.h; sourceTree = SOURCE_ROOT; }; + D750F05710D1C42B009AA50B /* streaming.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = streaming.h; path = include/mp4v2/streaming.h; sourceTree = SOURCE_ROOT; }; + D750F05810D1C42B009AA50B /* track.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = track.h; path = include/mp4v2/track.h; sourceTree = SOURCE_ROOT; }; + D750F05910D1C42B009AA50B /* track_prop.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = track_prop.h; path = include/mp4v2/track_prop.h; sourceTree = SOURCE_ROOT; }; + D750F06910D1C4A8009AA50B /* 3gp.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = 3gp.cpp; path = src/3gp.cpp; sourceTree = SOURCE_ROOT; }; + D750F06A10D1C4A8009AA50B /* atom_ac3.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_ac3.cpp; path = src/atom_ac3.cpp; sourceTree = SOURCE_ROOT; }; + D750F06B10D1C4A8009AA50B /* atom_amr.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_amr.cpp; path = src/atom_amr.cpp; sourceTree = SOURCE_ROOT; }; + D750F06C10D1C4A8009AA50B /* atom_avc1.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_avc1.cpp; path = src/atom_avc1.cpp; sourceTree = SOURCE_ROOT; }; + D750F06D10D1C4A8009AA50B /* atom_avcC.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_avcC.cpp; path = src/atom_avcC.cpp; sourceTree = SOURCE_ROOT; }; + D750F06E10D1C4A8009AA50B /* atom_chpl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_chpl.cpp; path = src/atom_chpl.cpp; sourceTree = SOURCE_ROOT; }; + D750F06F10D1C4A8009AA50B /* atom_colr.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_colr.cpp; path = src/atom_colr.cpp; sourceTree = SOURCE_ROOT; }; + D750F07010D1C4A8009AA50B /* atom_d263.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_d263.cpp; path = src/atom_d263.cpp; sourceTree = SOURCE_ROOT; }; + D750F07110D1C4A8009AA50B /* atom_dac3.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_dac3.cpp; path = src/atom_dac3.cpp; sourceTree = SOURCE_ROOT; }; + D750F07210D1C4A8009AA50B /* atom_damr.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_damr.cpp; path = src/atom_damr.cpp; sourceTree = SOURCE_ROOT; }; + D750F07310D1C4A8009AA50B /* atom_dref.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_dref.cpp; path = src/atom_dref.cpp; sourceTree = SOURCE_ROOT; }; + D750F07410D1C4A8009AA50B /* atom_elst.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_elst.cpp; path = src/atom_elst.cpp; sourceTree = SOURCE_ROOT; }; + D750F07510D1C4A8009AA50B /* atom_enca.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_enca.cpp; path = src/atom_enca.cpp; sourceTree = SOURCE_ROOT; }; + D750F07610D1C4A8009AA50B /* atom_encv.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_encv.cpp; path = src/atom_encv.cpp; sourceTree = SOURCE_ROOT; }; + D750F07710D1C4A8009AA50B /* atom_free.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_free.cpp; path = src/atom_free.cpp; sourceTree = SOURCE_ROOT; }; + D750F07810D1C4A8009AA50B /* atom_ftab.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_ftab.cpp; path = src/atom_ftab.cpp; sourceTree = SOURCE_ROOT; }; + D750F07910D1C4A8009AA50B /* atom_ftyp.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_ftyp.cpp; path = src/atom_ftyp.cpp; sourceTree = SOURCE_ROOT; }; + D750F07A10D1C4A8009AA50B /* atom_gmin.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_gmin.cpp; path = src/atom_gmin.cpp; sourceTree = SOURCE_ROOT; }; + D750F07B10D1C4A8009AA50B /* atom_hdlr.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_hdlr.cpp; path = src/atom_hdlr.cpp; sourceTree = SOURCE_ROOT; }; + D750F07C10D1C4A8009AA50B /* atom_hinf.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_hinf.cpp; path = src/atom_hinf.cpp; sourceTree = SOURCE_ROOT; }; + D750F07D10D1C4A8009AA50B /* atom_hnti.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_hnti.cpp; path = src/atom_hnti.cpp; sourceTree = SOURCE_ROOT; }; + D750F07E10D1C4A8009AA50B /* atom_href.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_href.cpp; path = src/atom_href.cpp; sourceTree = SOURCE_ROOT; }; + D750F07F10D1C4A8009AA50B /* atom_mdat.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_mdat.cpp; path = src/atom_mdat.cpp; sourceTree = SOURCE_ROOT; }; + D750F08010D1C4A8009AA50B /* atom_mdhd.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_mdhd.cpp; path = src/atom_mdhd.cpp; sourceTree = SOURCE_ROOT; }; + D750F08110D1C4A8009AA50B /* atom_meta.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_meta.cpp; path = src/atom_meta.cpp; sourceTree = SOURCE_ROOT; }; + D750F08210D1C4A8009AA50B /* atom_mp4s.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_mp4s.cpp; path = src/atom_mp4s.cpp; sourceTree = SOURCE_ROOT; }; + D750F08310D1C4A8009AA50B /* atom_mp4v.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_mp4v.cpp; path = src/atom_mp4v.cpp; sourceTree = SOURCE_ROOT; }; + D750F08410D1C4A8009AA50B /* atom_mvhd.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_mvhd.cpp; path = src/atom_mvhd.cpp; sourceTree = SOURCE_ROOT; }; + D750F08510D1C4A8009AA50B /* atom_nmhd.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_nmhd.cpp; path = src/atom_nmhd.cpp; sourceTree = SOURCE_ROOT; }; + D750F08610D1C4A8009AA50B /* atom_ohdr.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_ohdr.cpp; path = src/atom_ohdr.cpp; sourceTree = SOURCE_ROOT; }; + D750F08710D1C4A8009AA50B /* atom_pasp.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_pasp.cpp; path = src/atom_pasp.cpp; sourceTree = SOURCE_ROOT; }; + D750F08810D1C4A8009AA50B /* atom_root.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_root.cpp; path = src/atom_root.cpp; sourceTree = SOURCE_ROOT; }; + D750F08910D1C4A8009AA50B /* atom_rtp.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_rtp.cpp; path = src/atom_rtp.cpp; sourceTree = SOURCE_ROOT; }; + D750F08A10D1C4A8009AA50B /* atom_s263.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_s263.cpp; path = src/atom_s263.cpp; sourceTree = SOURCE_ROOT; }; + D750F08B10D1C4A8009AA50B /* atom_sdp.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_sdp.cpp; path = src/atom_sdp.cpp; sourceTree = SOURCE_ROOT; }; + D750F08C10D1C4A8009AA50B /* atom_sdtp.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_sdtp.cpp; path = src/atom_sdtp.cpp; sourceTree = SOURCE_ROOT; }; + D750F08D10D1C4A8009AA50B /* atom_smi.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_smi.cpp; path = src/atom_smi.cpp; sourceTree = SOURCE_ROOT; }; + D750F08E10D1C4A8009AA50B /* atom_sound.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_sound.cpp; path = src/atom_sound.cpp; sourceTree = SOURCE_ROOT; }; + D750F08F10D1C4A8009AA50B /* atom_standard.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_standard.cpp; path = src/atom_standard.cpp; sourceTree = SOURCE_ROOT; }; + D750F09010D1C4A8009AA50B /* atom_stbl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_stbl.cpp; path = src/atom_stbl.cpp; sourceTree = SOURCE_ROOT; }; + D750F09110D1C4A8009AA50B /* atom_stdp.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_stdp.cpp; path = src/atom_stdp.cpp; sourceTree = SOURCE_ROOT; }; + D750F09210D1C4A8009AA50B /* atom_stsc.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_stsc.cpp; path = src/atom_stsc.cpp; sourceTree = SOURCE_ROOT; }; + D750F09310D1C4A8009AA50B /* atom_stsd.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_stsd.cpp; path = src/atom_stsd.cpp; sourceTree = SOURCE_ROOT; }; + D750F09410D1C4A8009AA50B /* atom_stsz.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_stsz.cpp; path = src/atom_stsz.cpp; sourceTree = SOURCE_ROOT; }; + D750F09510D1C4A8009AA50B /* atom_stz2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_stz2.cpp; path = src/atom_stz2.cpp; sourceTree = SOURCE_ROOT; }; + D750F09610D1C4A8009AA50B /* atom_text.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_text.cpp; path = src/atom_text.cpp; sourceTree = SOURCE_ROOT; }; + D750F09710D1C4A8009AA50B /* atom_tfhd.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_tfhd.cpp; path = src/atom_tfhd.cpp; sourceTree = SOURCE_ROOT; }; + D750F09810D1C4A8009AA50B /* atom_tkhd.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_tkhd.cpp; path = src/atom_tkhd.cpp; sourceTree = SOURCE_ROOT; }; + D750F09910D1C4A8009AA50B /* atom_treftype.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_treftype.cpp; path = src/atom_treftype.cpp; sourceTree = SOURCE_ROOT; }; + D750F09A10D1C4A8009AA50B /* atom_trun.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_trun.cpp; path = src/atom_trun.cpp; sourceTree = SOURCE_ROOT; }; + D750F09B10D1C4A8009AA50B /* atom_tx3g.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_tx3g.cpp; path = src/atom_tx3g.cpp; sourceTree = SOURCE_ROOT; }; + D750F09C10D1C4A8009AA50B /* atom_udta.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_udta.cpp; path = src/atom_udta.cpp; sourceTree = SOURCE_ROOT; }; + D750F09D10D1C4A8009AA50B /* atom_url.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_url.cpp; path = src/atom_url.cpp; sourceTree = SOURCE_ROOT; }; + D750F09E10D1C4A8009AA50B /* atom_urn.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_urn.cpp; path = src/atom_urn.cpp; sourceTree = SOURCE_ROOT; }; + D750F09F10D1C4A8009AA50B /* atom_uuid.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_uuid.cpp; path = src/atom_uuid.cpp; sourceTree = SOURCE_ROOT; }; + D750F0A010D1C4A8009AA50B /* atom_video.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_video.cpp; path = src/atom_video.cpp; sourceTree = SOURCE_ROOT; }; + D750F0A110D1C4A8009AA50B /* atom_vmhd.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atom_vmhd.cpp; path = src/atom_vmhd.cpp; sourceTree = SOURCE_ROOT; }; + D750F0A210D1C4A8009AA50B /* atoms.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = atoms.h; path = src/atoms.h; sourceTree = SOURCE_ROOT; }; + D750F0A310D1C4A8009AA50B /* cmeta.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = cmeta.cpp; path = src/cmeta.cpp; sourceTree = SOURCE_ROOT; }; + D750F0A410D1C4A8009AA50B /* descriptors.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = descriptors.cpp; path = src/descriptors.cpp; sourceTree = SOURCE_ROOT; }; + D750F0A510D1C4A8009AA50B /* descriptors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = descriptors.h; path = src/descriptors.h; sourceTree = SOURCE_ROOT; }; + D750F0A610D1C4A8009AA50B /* enum.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = enum.h; path = src/enum.h; sourceTree = SOURCE_ROOT; }; + D750F0A710D1C4A8009AA50B /* exception.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = exception.cpp; path = src/exception.cpp; sourceTree = SOURCE_ROOT; }; + D750F0A810D1C4A8009AA50B /* exception.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = exception.h; path = src/exception.h; sourceTree = SOURCE_ROOT; }; + D750F0A910D1C4A8009AA50B /* impl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = impl.h; path = src/impl.h; sourceTree = SOURCE_ROOT; }; + D750F0AA10D1C4A8009AA50B /* isma.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = isma.cpp; path = src/isma.cpp; sourceTree = SOURCE_ROOT; }; + D750F0AB10D1C4A8009AA50B /* mp4.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = mp4.cpp; path = src/mp4.cpp; sourceTree = SOURCE_ROOT; }; + D750F0AC10D1C4A8009AA50B /* mp4array.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mp4array.h; path = src/mp4array.h; sourceTree = SOURCE_ROOT; }; + D750F0AD10D1C4A8009AA50B /* mp4atom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = mp4atom.cpp; path = src/mp4atom.cpp; sourceTree = SOURCE_ROOT; }; + D750F0AE10D1C4A8009AA50B /* mp4atom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mp4atom.h; path = src/mp4atom.h; sourceTree = SOURCE_ROOT; }; + D750F0AF10D1C4A8009AA50B /* mp4container.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = mp4container.cpp; path = src/mp4container.cpp; sourceTree = SOURCE_ROOT; }; + D750F0B010D1C4A8009AA50B /* mp4container.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mp4container.h; path = src/mp4container.h; sourceTree = SOURCE_ROOT; }; + D750F0B110D1C4A8009AA50B /* mp4descriptor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = mp4descriptor.cpp; path = src/mp4descriptor.cpp; sourceTree = SOURCE_ROOT; }; + D750F0B210D1C4A8009AA50B /* mp4descriptor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mp4descriptor.h; path = src/mp4descriptor.h; sourceTree = SOURCE_ROOT; }; + D750F0B310D1C4A8009AA50B /* mp4error.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mp4error.h; path = src/mp4error.h; sourceTree = SOURCE_ROOT; }; + D750F0B410D1C4A8009AA50B /* mp4file.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = mp4file.cpp; path = src/mp4file.cpp; sourceTree = SOURCE_ROOT; }; + D750F0B510D1C4A8009AA50B /* mp4file.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mp4file.h; path = src/mp4file.h; sourceTree = SOURCE_ROOT; }; + D750F0B610D1C4A8009AA50B /* mp4file_io.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = mp4file_io.cpp; path = src/mp4file_io.cpp; sourceTree = SOURCE_ROOT; }; + D750F0B710D1C4A8009AA50B /* mp4info.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = mp4info.cpp; path = src/mp4info.cpp; sourceTree = SOURCE_ROOT; }; + D750F0B810D1C4A8009AA50B /* mp4meta.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = mp4meta.cpp; path = src/mp4meta.cpp; sourceTree = SOURCE_ROOT; }; + D750F0B910D1C4A8009AA50B /* mp4property.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = mp4property.cpp; path = src/mp4property.cpp; sourceTree = SOURCE_ROOT; }; + D750F0BA10D1C4A8009AA50B /* mp4property.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mp4property.h; path = src/mp4property.h; sourceTree = SOURCE_ROOT; }; + D750F0BB10D1C4A8009AA50B /* mp4track.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = mp4track.cpp; path = src/mp4track.cpp; sourceTree = SOURCE_ROOT; }; + D750F0BC10D1C4A8009AA50B /* mp4track.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mp4track.h; path = src/mp4track.h; sourceTree = SOURCE_ROOT; }; + D750F0BD10D1C4A8009AA50B /* mp4util.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = mp4util.cpp; path = src/mp4util.cpp; sourceTree = SOURCE_ROOT; }; + D750F0BE10D1C4A8009AA50B /* mp4util.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mp4util.h; path = src/mp4util.h; sourceTree = SOURCE_ROOT; }; + D750F0BF10D1C4A8009AA50B /* ocidescriptors.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ocidescriptors.cpp; path = src/ocidescriptors.cpp; sourceTree = SOURCE_ROOT; }; + D750F0C010D1C4A8009AA50B /* ocidescriptors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ocidescriptors.h; path = src/ocidescriptors.h; sourceTree = SOURCE_ROOT; }; + D750F0C110D1C4A8009AA50B /* odcommands.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = odcommands.cpp; path = src/odcommands.cpp; sourceTree = SOURCE_ROOT; }; + D750F0C210D1C4A8009AA50B /* odcommands.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = odcommands.h; path = src/odcommands.h; sourceTree = SOURCE_ROOT; }; + D750F0C310D1C4A8009AA50B /* qosqualifiers.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = qosqualifiers.cpp; path = src/qosqualifiers.cpp; sourceTree = SOURCE_ROOT; }; + D750F0C410D1C4A8009AA50B /* qosqualifiers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = qosqualifiers.h; path = src/qosqualifiers.h; sourceTree = SOURCE_ROOT; }; + D750F0C510D1C4A8009AA50B /* rtphint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = rtphint.cpp; path = src/rtphint.cpp; sourceTree = SOURCE_ROOT; }; + D750F0C610D1C4A8009AA50B /* rtphint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = rtphint.h; path = src/rtphint.h; sourceTree = SOURCE_ROOT; }; + D750F0C710D1C4A8009AA50B /* src.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = src.h; path = src/src.h; sourceTree = SOURCE_ROOT; }; + D750F0C810D1C4A8009AA50B /* text.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = text.cpp; path = src/text.cpp; sourceTree = SOURCE_ROOT; }; + D750F0C910D1C4A8009AA50B /* text.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = text.h; path = src/text.h; sourceTree = SOURCE_ROOT; }; + D750F0CA10D1C4A8009AA50B /* util.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = util.h; path = src/util.h; sourceTree = SOURCE_ROOT; }; + D750F12D10D1C4C1009AA50B /* bmff.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = bmff.h; path = src/bmff/bmff.h; sourceTree = SOURCE_ROOT; }; + D750F12E10D1C4C1009AA50B /* impl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = impl.h; path = src/bmff/impl.h; sourceTree = SOURCE_ROOT; }; + D750F12F10D1C4C1009AA50B /* typebmff.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = typebmff.cpp; path = src/bmff/typebmff.cpp; sourceTree = SOURCE_ROOT; }; + D750F13010D1C4C1009AA50B /* typebmff.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = typebmff.h; path = src/bmff/typebmff.h; sourceTree = SOURCE_ROOT; }; + D750F13510D1C4DE009AA50B /* CoverArtBox.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CoverArtBox.cpp; path = src/itmf/CoverArtBox.cpp; sourceTree = SOURCE_ROOT; }; + D750F13610D1C4DE009AA50B /* CoverArtBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CoverArtBox.h; path = src/itmf/CoverArtBox.h; sourceTree = SOURCE_ROOT; }; + D750F13710D1C4DE009AA50B /* generic.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = generic.cpp; path = src/itmf/generic.cpp; sourceTree = SOURCE_ROOT; }; + D750F13810D1C4DE009AA50B /* generic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = generic.h; path = src/itmf/generic.h; sourceTree = SOURCE_ROOT; }; + D750F13910D1C4DE009AA50B /* impl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = impl.h; path = src/itmf/impl.h; sourceTree = SOURCE_ROOT; }; + D750F13A10D1C4DE009AA50B /* itmf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = itmf.h; path = src/itmf/itmf.h; sourceTree = SOURCE_ROOT; }; + D750F13B10D1C4DE009AA50B /* Tags.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Tags.cpp; path = src/itmf/Tags.cpp; sourceTree = SOURCE_ROOT; }; + D750F13C10D1C4DE009AA50B /* Tags.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Tags.h; path = src/itmf/Tags.h; sourceTree = SOURCE_ROOT; }; + D750F13D10D1C4DE009AA50B /* type.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = type.cpp; path = src/itmf/type.cpp; sourceTree = SOURCE_ROOT; }; + D750F13E10D1C4DE009AA50B /* type.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = type.h; path = src/itmf/type.h; sourceTree = SOURCE_ROOT; }; + D750F14910D1C4F5009AA50B /* coding.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = coding.cpp; path = src/qtff/coding.cpp; sourceTree = SOURCE_ROOT; }; + D750F14A10D1C4F5009AA50B /* coding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = coding.h; path = src/qtff/coding.h; sourceTree = SOURCE_ROOT; }; + D750F14B10D1C4F5009AA50B /* ColorParameterBox.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ColorParameterBox.cpp; path = src/qtff/ColorParameterBox.cpp; sourceTree = SOURCE_ROOT; }; + D750F14C10D1C4F5009AA50B /* ColorParameterBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ColorParameterBox.h; path = src/qtff/ColorParameterBox.h; sourceTree = SOURCE_ROOT; }; + D750F14D10D1C4F5009AA50B /* impl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = impl.h; path = src/qtff/impl.h; sourceTree = SOURCE_ROOT; }; + D750F14E10D1C4F5009AA50B /* PictureAspectRatioBox.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PictureAspectRatioBox.cpp; path = src/qtff/PictureAspectRatioBox.cpp; sourceTree = SOURCE_ROOT; }; + D750F14F10D1C4F5009AA50B /* PictureAspectRatioBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PictureAspectRatioBox.h; path = src/qtff/PictureAspectRatioBox.h; sourceTree = SOURCE_ROOT; }; + D750F15010D1C4F5009AA50B /* qtff.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = qtff.h; path = src/qtff/qtff.h; sourceTree = SOURCE_ROOT; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + D289987405E68DCB004EDB86 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 08FB7794FE84155DC02AAC07 /* mp4v2 */ = { + isa = PBXGroup; + children = ( + B033B6950B2FAA7C00CEEEDA /* MacConfigExternalDebug.xcconfig */, + B033B6960B2FAA7C00CEEEDA /* MacConfigExternalRelease.xcconfig */, + D750F04810D1C42B009AA50B /* include */, + 08FB7795FE84155DC02AAC07 /* Source */, + 1AB674ADFE9D54B511CA2CBB /* Products */, + ); + name = mp4v2; + sourceTree = "<group>"; + }; + 08FB7795FE84155DC02AAC07 /* Source */ = { + isa = PBXGroup; + children = ( + D750EFFD10D1C212009AA50B /* libplatform */, + D750EFFE10D1C21B009AA50B /* libutil */, + D750EFFB10D1C1F0009AA50B /* src */, + ); + name = Source; + sourceTree = "<group>"; + }; + 1AB674ADFE9D54B511CA2CBB /* Products */ = { + isa = PBXGroup; + children = ( + D2AAC046055464E500DB518D /* libmp4v2.a */, + ); + name = Products; + sourceTree = "<group>"; + }; + D750EFFB10D1C1F0009AA50B /* src */ = { + isa = PBXGroup; + children = ( + D750F06910D1C4A8009AA50B /* 3gp.cpp */, + D750F06A10D1C4A8009AA50B /* atom_ac3.cpp */, + D750F06B10D1C4A8009AA50B /* atom_amr.cpp */, + D750F06C10D1C4A8009AA50B /* atom_avc1.cpp */, + D750F06D10D1C4A8009AA50B /* atom_avcC.cpp */, + D750F06E10D1C4A8009AA50B /* atom_chpl.cpp */, + D750F06F10D1C4A8009AA50B /* atom_colr.cpp */, + D750F07010D1C4A8009AA50B /* atom_d263.cpp */, + D750F07110D1C4A8009AA50B /* atom_dac3.cpp */, + D750F07210D1C4A8009AA50B /* atom_damr.cpp */, + D750F07310D1C4A8009AA50B /* atom_dref.cpp */, + D750F07410D1C4A8009AA50B /* atom_elst.cpp */, + D750F07510D1C4A8009AA50B /* atom_enca.cpp */, + D750F07610D1C4A8009AA50B /* atom_encv.cpp */, + D750F07710D1C4A8009AA50B /* atom_free.cpp */, + D750F07810D1C4A8009AA50B /* atom_ftab.cpp */, + D750F07910D1C4A8009AA50B /* atom_ftyp.cpp */, + D750F07A10D1C4A8009AA50B /* atom_gmin.cpp */, + D750F07B10D1C4A8009AA50B /* atom_hdlr.cpp */, + D750F07C10D1C4A8009AA50B /* atom_hinf.cpp */, + D750F07D10D1C4A8009AA50B /* atom_hnti.cpp */, + D750F07E10D1C4A8009AA50B /* atom_href.cpp */, + D750F07F10D1C4A8009AA50B /* atom_mdat.cpp */, + D750F08010D1C4A8009AA50B /* atom_mdhd.cpp */, + D750F08110D1C4A8009AA50B /* atom_meta.cpp */, + D750F08210D1C4A8009AA50B /* atom_mp4s.cpp */, + D750F08310D1C4A8009AA50B /* atom_mp4v.cpp */, + D750F08410D1C4A8009AA50B /* atom_mvhd.cpp */, + D750F08510D1C4A8009AA50B /* atom_nmhd.cpp */, + D750F08610D1C4A8009AA50B /* atom_ohdr.cpp */, + D750F08710D1C4A8009AA50B /* atom_pasp.cpp */, + D750F08810D1C4A8009AA50B /* atom_root.cpp */, + D750F08910D1C4A8009AA50B /* atom_rtp.cpp */, + D750F08A10D1C4A8009AA50B /* atom_s263.cpp */, + D750F08B10D1C4A8009AA50B /* atom_sdp.cpp */, + D750F08C10D1C4A8009AA50B /* atom_sdtp.cpp */, + D750F08D10D1C4A8009AA50B /* atom_smi.cpp */, + D750F08E10D1C4A8009AA50B /* atom_sound.cpp */, + D750F08F10D1C4A8009AA50B /* atom_standard.cpp */, + D750F09010D1C4A8009AA50B /* atom_stbl.cpp */, + D750F09110D1C4A8009AA50B /* atom_stdp.cpp */, + D750F09210D1C4A8009AA50B /* atom_stsc.cpp */, + D750F09310D1C4A8009AA50B /* atom_stsd.cpp */, + D750F09410D1C4A8009AA50B /* atom_stsz.cpp */, + D750F09510D1C4A8009AA50B /* atom_stz2.cpp */, + D750F09610D1C4A8009AA50B /* atom_text.cpp */, + D750F09710D1C4A8009AA50B /* atom_tfhd.cpp */, + D750F09810D1C4A8009AA50B /* atom_tkhd.cpp */, + D750F09910D1C4A8009AA50B /* atom_treftype.cpp */, + D750F09A10D1C4A8009AA50B /* atom_trun.cpp */, + D750F09B10D1C4A8009AA50B /* atom_tx3g.cpp */, + D750F09C10D1C4A8009AA50B /* atom_udta.cpp */, + D750F09D10D1C4A8009AA50B /* atom_url.cpp */, + D750F09E10D1C4A8009AA50B /* atom_urn.cpp */, + D750F09F10D1C4A8009AA50B /* atom_uuid.cpp */, + D750F0A010D1C4A8009AA50B /* atom_video.cpp */, + D750F0A110D1C4A8009AA50B /* atom_vmhd.cpp */, + D750F0A210D1C4A8009AA50B /* atoms.h */, + D750F0A310D1C4A8009AA50B /* cmeta.cpp */, + D750F0A410D1C4A8009AA50B /* descriptors.cpp */, + D750F0A510D1C4A8009AA50B /* descriptors.h */, + D750F0A610D1C4A8009AA50B /* enum.h */, + D750F0A710D1C4A8009AA50B /* exception.cpp */, + D750F0A810D1C4A8009AA50B /* exception.h */, + D750F0A910D1C4A8009AA50B /* impl.h */, + D750F0AA10D1C4A8009AA50B /* isma.cpp */, + D750F0AB10D1C4A8009AA50B /* mp4.cpp */, + D750F0AC10D1C4A8009AA50B /* mp4array.h */, + D750F0AD10D1C4A8009AA50B /* mp4atom.cpp */, + D750F0AE10D1C4A8009AA50B /* mp4atom.h */, + D750F0AF10D1C4A8009AA50B /* mp4container.cpp */, + D750F0B010D1C4A8009AA50B /* mp4container.h */, + D750F0B110D1C4A8009AA50B /* mp4descriptor.cpp */, + D750F0B210D1C4A8009AA50B /* mp4descriptor.h */, + D750F0B310D1C4A8009AA50B /* mp4error.h */, + D750F0B410D1C4A8009AA50B /* mp4file.cpp */, + D750F0B510D1C4A8009AA50B /* mp4file.h */, + D750F0B610D1C4A8009AA50B /* mp4file_io.cpp */, + D750F0B710D1C4A8009AA50B /* mp4info.cpp */, + D750F0B810D1C4A8009AA50B /* mp4meta.cpp */, + D750F0B910D1C4A8009AA50B /* mp4property.cpp */, + D750F0BA10D1C4A8009AA50B /* mp4property.h */, + D750F0BB10D1C4A8009AA50B /* mp4track.cpp */, + D750F0BC10D1C4A8009AA50B /* mp4track.h */, + D750F0BD10D1C4A8009AA50B /* mp4util.cpp */, + D750F0BE10D1C4A8009AA50B /* mp4util.h */, + D750F0BF10D1C4A8009AA50B /* ocidescriptors.cpp */, + D750F0C010D1C4A8009AA50B /* ocidescriptors.h */, + D750F0C110D1C4A8009AA50B /* odcommands.cpp */, + D750F0C210D1C4A8009AA50B /* odcommands.h */, + D750F0C310D1C4A8009AA50B /* qosqualifiers.cpp */, + D750F0C410D1C4A8009AA50B /* qosqualifiers.h */, + D750F0C510D1C4A8009AA50B /* rtphint.cpp */, + D750F0C610D1C4A8009AA50B /* rtphint.h */, + D750F0C710D1C4A8009AA50B /* src.h */, + D750F0C810D1C4A8009AA50B /* text.cpp */, + D750F0C910D1C4A8009AA50B /* text.h */, + D750F0CA10D1C4A8009AA50B /* util.h */, + D750F04310D1C38C009AA50B /* bmff */, + D750F04410D1C396009AA50B /* itmf */, + D750F04510D1C3A4009AA50B /* qtff */, + ); + name = src; + sourceTree = "<group>"; + }; + D750EFFD10D1C212009AA50B /* libplatform */ = { + isa = PBXGroup; + children = ( + D74419EF10D1C59300116965 /* config.h */, + D74419F010D1C59300116965 /* endian.h */, + D74419F110D1C59300116965 /* impl.h */, + D74419F210D1C59300116965 /* platform.h */, + D74419F310D1C59300116965 /* platform_base.h */, + D74419F410D1C59300116965 /* platform_posix.h */, + D74419F510D1C59300116965 /* warning.h */, + D750EFFF10D1C238009AA50B /* io */, + D750F00810D1C26A009AA50B /* number */, + D750F01110D1C2B4009AA50B /* process */, + D750F01210D1C2BE009AA50B /* prog */, + D750F01310D1C2CB009AA50B /* sys */, + D750F01410D1C2D6009AA50B /* time */, + ); + name = libplatform; + sourceTree = "<group>"; + }; + D750EFFE10D1C21B009AA50B /* libutil */ = { + isa = PBXGroup; + children = ( + D750F02710D1C375009AA50B /* crc.cpp */, + D750F02810D1C375009AA50B /* crc.h */, + D750F02910D1C375009AA50B /* Database.cpp */, + D750F02A10D1C375009AA50B /* Database.h */, + D750F02B10D1C375009AA50B /* impl.h */, + D750F02C10D1C375009AA50B /* other.cpp */, + D750F02D10D1C375009AA50B /* other.h */, + D750F02E10D1C375009AA50B /* Timecode.cpp */, + D750F02F10D1C375009AA50B /* Timecode.h */, + D750F03010D1C375009AA50B /* TrackModifier.cpp */, + D750F03110D1C375009AA50B /* TrackModifier.h */, + D750F03210D1C375009AA50B /* util.h */, + D750F03310D1C375009AA50B /* Utility.cpp */, + D750F03410D1C375009AA50B /* Utility.h */, + ); + name = libutil; + sourceTree = "<group>"; + }; + D750EFFF10D1C238009AA50B /* io */ = { + isa = PBXGroup; + children = ( + D750F00E10D1C2AC009AA50B /* FileSystem.h */, + D750F00010D1C264009AA50B /* File.cpp */, + D750F00110D1C264009AA50B /* File_posix.cpp */, + D750F00210D1C264009AA50B /* FileSystem.cpp */, + D750F00310D1C264009AA50B /* FileSystem_posix.cpp */, + ); + name = io; + sourceTree = "<group>"; + }; + D750F00810D1C26A009AA50B /* number */ = { + isa = PBXGroup; + children = ( + D750F00B10D1C28F009AA50B /* random.h */, + D750F00910D1C280009AA50B /* random_posix.cpp */, + ); + name = number; + sourceTree = "<group>"; + }; + D750F01110D1C2B4009AA50B /* process */ = { + isa = PBXGroup; + children = ( + D750F01510D1C302009AA50B /* process.h */, + D750F01610D1C302009AA50B /* process_posix.cpp */, + ); + name = process; + sourceTree = "<group>"; + }; + D750F01210D1C2BE009AA50B /* prog */ = { + isa = PBXGroup; + children = ( + D750F01910D1C316009AA50B /* option.cpp */, + D750F01A10D1C316009AA50B /* option.h */, + ); + name = prog; + sourceTree = "<group>"; + }; + D750F01310D1C2CB009AA50B /* sys */ = { + isa = PBXGroup; + children = ( + D750F01D10D1C339009AA50B /* error.cpp */, + ); + name = sys; + sourceTree = "<group>"; + }; + D750F01410D1C2D6009AA50B /* time */ = { + isa = PBXGroup; + children = ( + D750F02110D1C348009AA50B /* time.cpp */, + D750F02310D1C348009AA50B /* time_posix.cpp */, + ); + name = time; + sourceTree = "<group>"; + }; + D750F04310D1C38C009AA50B /* bmff */ = { + isa = PBXGroup; + children = ( + D750F12D10D1C4C1009AA50B /* bmff.h */, + D750F12E10D1C4C1009AA50B /* impl.h */, + D750F12F10D1C4C1009AA50B /* typebmff.cpp */, + D750F13010D1C4C1009AA50B /* typebmff.h */, + ); + name = bmff; + sourceTree = "<group>"; + }; + D750F04410D1C396009AA50B /* itmf */ = { + isa = PBXGroup; + children = ( + D750F13510D1C4DE009AA50B /* CoverArtBox.cpp */, + D750F13610D1C4DE009AA50B /* CoverArtBox.h */, + D750F13710D1C4DE009AA50B /* generic.cpp */, + D750F13810D1C4DE009AA50B /* generic.h */, + D750F13910D1C4DE009AA50B /* impl.h */, + D750F13A10D1C4DE009AA50B /* itmf.h */, + D750F13B10D1C4DE009AA50B /* Tags.cpp */, + D750F13C10D1C4DE009AA50B /* Tags.h */, + D750F13D10D1C4DE009AA50B /* type.cpp */, + D750F13E10D1C4DE009AA50B /* type.h */, + ); + name = itmf; + sourceTree = "<group>"; + }; + D750F04510D1C3A4009AA50B /* qtff */ = { + isa = PBXGroup; + children = ( + D750F14910D1C4F5009AA50B /* coding.cpp */, + D750F14A10D1C4F5009AA50B /* coding.h */, + D750F14B10D1C4F5009AA50B /* ColorParameterBox.cpp */, + D750F14C10D1C4F5009AA50B /* ColorParameterBox.h */, + D750F14D10D1C4F5009AA50B /* impl.h */, + D750F14E10D1C4F5009AA50B /* PictureAspectRatioBox.cpp */, + D750F14F10D1C4F5009AA50B /* PictureAspectRatioBox.h */, + D750F15010D1C4F5009AA50B /* qtff.h */, + ); + name = qtff; + sourceTree = "<group>"; + }; + D750F04810D1C42B009AA50B /* include */ = { + isa = PBXGroup; + children = ( + D750F04910D1C42B009AA50B /* mp4v2 */, + ); + path = include; + sourceTree = SOURCE_ROOT; + }; + D750F04910D1C42B009AA50B /* mp4v2 */ = { + isa = PBXGroup; + children = ( + D750F04A10D1C42B009AA50B /* chapter.h */, + D750F04B10D1C42B009AA50B /* file.h */, + D750F04C10D1C42B009AA50B /* file_prop.h */, + D750F04D10D1C42B009AA50B /* general.h */, + D750F04E10D1C42B009AA50B /* isma.h */, + D750F04F10D1C42B009AA50B /* itmf_generic.h */, + D750F05010D1C42B009AA50B /* itmf_tags.h */, + D750F05110D1C42B009AA50B /* meta.h */, + D750F05210D1C42B009AA50B /* mp4v2.h */, + D750F05310D1C42B009AA50B /* platform.h */, + D750F05410D1C42B009AA50B /* project.h */, + D750F05510D1C42B009AA50B /* project.h.in */, + D750F05610D1C42B009AA50B /* sample.h */, + D750F05710D1C42B009AA50B /* streaming.h */, + D750F05810D1C42B009AA50B /* track.h */, + D750F05910D1C42B009AA50B /* track_prop.h */, + ); + name = mp4v2; + path = include/mp4v2; + sourceTree = SOURCE_ROOT; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + D2AAC043055464E500DB518D /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + D750F00C10D1C28F009AA50B /* random.h in Headers */, + D750F01010D1C2AC009AA50B /* FileSystem.h in Headers */, + D750F01710D1C302009AA50B /* process.h in Headers */, + D750F01C10D1C316009AA50B /* option.h in Headers */, + D750F03610D1C375009AA50B /* crc.h in Headers */, + D750F03810D1C375009AA50B /* Database.h in Headers */, + D750F03910D1C375009AA50B /* impl.h in Headers */, + D750F03B10D1C375009AA50B /* other.h in Headers */, + D750F03D10D1C375009AA50B /* Timecode.h in Headers */, + D750F03F10D1C375009AA50B /* TrackModifier.h in Headers */, + D750F04010D1C375009AA50B /* util.h in Headers */, + D750F04210D1C375009AA50B /* Utility.h in Headers */, + D750F05A10D1C42B009AA50B /* chapter.h in Headers */, + D750F05B10D1C42B009AA50B /* file.h in Headers */, + D750F05C10D1C42B009AA50B /* file_prop.h in Headers */, + D750F05D10D1C42B009AA50B /* general.h in Headers */, + D750F05E10D1C42B009AA50B /* isma.h in Headers */, + D750F05F10D1C42B009AA50B /* itmf_generic.h in Headers */, + D750F06010D1C42B009AA50B /* itmf_tags.h in Headers */, + D750F06110D1C42B009AA50B /* meta.h in Headers */, + D750F06210D1C42B009AA50B /* mp4v2.h in Headers */, + D750F06310D1C42B009AA50B /* platform.h in Headers */, + D750F06410D1C42B009AA50B /* project.h in Headers */, + D750F06510D1C42B009AA50B /* sample.h in Headers */, + D750F06610D1C42B009AA50B /* streaming.h in Headers */, + D750F06710D1C42B009AA50B /* track.h in Headers */, + D750F06810D1C42B009AA50B /* track_prop.h in Headers */, + D750F10410D1C4A8009AA50B /* atoms.h in Headers */, + D750F10710D1C4A8009AA50B /* descriptors.h in Headers */, + D750F10810D1C4A8009AA50B /* enum.h in Headers */, + D750F10A10D1C4A8009AA50B /* exception.h in Headers */, + D750F10B10D1C4A8009AA50B /* impl.h in Headers */, + D750F10E10D1C4A8009AA50B /* mp4array.h in Headers */, + D750F11010D1C4A8009AA50B /* mp4atom.h in Headers */, + D750F11210D1C4A8009AA50B /* mp4container.h in Headers */, + D750F11410D1C4A8009AA50B /* mp4descriptor.h in Headers */, + D750F11510D1C4A8009AA50B /* mp4error.h in Headers */, + D750F11710D1C4A8009AA50B /* mp4file.h in Headers */, + D750F11C10D1C4A8009AA50B /* mp4property.h in Headers */, + D750F11E10D1C4A8009AA50B /* mp4track.h in Headers */, + D750F12010D1C4A8009AA50B /* mp4util.h in Headers */, + D750F12210D1C4A8009AA50B /* ocidescriptors.h in Headers */, + D750F12410D1C4A8009AA50B /* odcommands.h in Headers */, + D750F12610D1C4A8009AA50B /* qosqualifiers.h in Headers */, + D750F12810D1C4A8009AA50B /* rtphint.h in Headers */, + D750F12910D1C4A8009AA50B /* src.h in Headers */, + D750F12B10D1C4A8009AA50B /* text.h in Headers */, + D750F12C10D1C4A8009AA50B /* util.h in Headers */, + D750F13110D1C4C1009AA50B /* bmff.h in Headers */, + D750F13210D1C4C1009AA50B /* impl.h in Headers */, + D750F13410D1C4C1009AA50B /* typebmff.h in Headers */, + D750F14010D1C4DE009AA50B /* CoverArtBox.h in Headers */, + D750F14210D1C4DE009AA50B /* generic.h in Headers */, + D750F14310D1C4DE009AA50B /* impl.h in Headers */, + D750F14410D1C4DE009AA50B /* itmf.h in Headers */, + D750F14610D1C4DE009AA50B /* Tags.h in Headers */, + D750F14810D1C4DE009AA50B /* type.h in Headers */, + D750F15210D1C4F5009AA50B /* coding.h in Headers */, + D750F15410D1C4F5009AA50B /* ColorParameterBox.h in Headers */, + D750F15510D1C4F5009AA50B /* impl.h in Headers */, + D750F15710D1C4F5009AA50B /* PictureAspectRatioBox.h in Headers */, + D750F15810D1C4F5009AA50B /* qtff.h in Headers */, + D74419F610D1C59300116965 /* config.h in Headers */, + D74419F710D1C59300116965 /* endian.h in Headers */, + D74419F810D1C59300116965 /* impl.h in Headers */, + D74419F910D1C59300116965 /* platform.h in Headers */, + D74419FA10D1C59300116965 /* platform_base.h in Headers */, + D74419FB10D1C59300116965 /* platform_posix.h in Headers */, + D74419FC10D1C59300116965 /* warning.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + D2AAC045055464E500DB518D /* mp4v2 */ = { + isa = PBXNativeTarget; + buildConfigurationList = 1DEB91EB08733DB70010E9CD /* Build configuration list for PBXNativeTarget "mp4v2" */; + buildPhases = ( + D2AAC043055464E500DB518D /* Headers */, + D2AAC044055464E500DB518D /* Sources */, + D289987405E68DCB004EDB86 /* Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = mp4v2; + productName = mp4v2; + productReference = D2AAC046055464E500DB518D /* libmp4v2.a */; + productType = "com.apple.product-type.library.static"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 08FB7793FE84155DC02AAC07 /* Project object */ = { + isa = PBXProject; + buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "mp4v2" */; + compatibilityVersion = "Xcode 3.1"; + hasScannedForEncodings = 1; + mainGroup = 08FB7794FE84155DC02AAC07 /* mp4v2 */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + D2AAC045055464E500DB518D /* mp4v2 */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + D2AAC044055464E500DB518D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + D750F00410D1C264009AA50B /* File.cpp in Sources */, + D750F00510D1C264009AA50B /* File_posix.cpp in Sources */, + D750F00610D1C264009AA50B /* FileSystem.cpp in Sources */, + D750F00710D1C264009AA50B /* FileSystem_posix.cpp in Sources */, + D750F00A10D1C280009AA50B /* random_posix.cpp in Sources */, + D750F01810D1C302009AA50B /* process_posix.cpp in Sources */, + D750F01B10D1C316009AA50B /* option.cpp in Sources */, + D750F01F10D1C339009AA50B /* error.cpp in Sources */, + D750F02410D1C348009AA50B /* time.cpp in Sources */, + D750F02610D1C348009AA50B /* time_posix.cpp in Sources */, + D750F03510D1C375009AA50B /* crc.cpp in Sources */, + D750F03710D1C375009AA50B /* Database.cpp in Sources */, + D750F03A10D1C375009AA50B /* other.cpp in Sources */, + D750F03C10D1C375009AA50B /* Timecode.cpp in Sources */, + D750F03E10D1C375009AA50B /* TrackModifier.cpp in Sources */, + D750F04110D1C375009AA50B /* Utility.cpp in Sources */, + D750F0CB10D1C4A8009AA50B /* 3gp.cpp in Sources */, + D750F0CC10D1C4A8009AA50B /* atom_ac3.cpp in Sources */, + D750F0CD10D1C4A8009AA50B /* atom_amr.cpp in Sources */, + D750F0CE10D1C4A8009AA50B /* atom_avc1.cpp in Sources */, + D750F0CF10D1C4A8009AA50B /* atom_avcC.cpp in Sources */, + D750F0D010D1C4A8009AA50B /* atom_chpl.cpp in Sources */, + D750F0D110D1C4A8009AA50B /* atom_colr.cpp in Sources */, + D750F0D210D1C4A8009AA50B /* atom_d263.cpp in Sources */, + D750F0D310D1C4A8009AA50B /* atom_dac3.cpp in Sources */, + D750F0D410D1C4A8009AA50B /* atom_damr.cpp in Sources */, + D750F0D510D1C4A8009AA50B /* atom_dref.cpp in Sources */, + D750F0D610D1C4A8009AA50B /* atom_elst.cpp in Sources */, + D750F0D710D1C4A8009AA50B /* atom_enca.cpp in Sources */, + D750F0D810D1C4A8009AA50B /* atom_encv.cpp in Sources */, + D750F0D910D1C4A8009AA50B /* atom_free.cpp in Sources */, + D750F0DA10D1C4A8009AA50B /* atom_ftab.cpp in Sources */, + D750F0DB10D1C4A8009AA50B /* atom_ftyp.cpp in Sources */, + D750F0DC10D1C4A8009AA50B /* atom_gmin.cpp in Sources */, + D750F0DD10D1C4A8009AA50B /* atom_hdlr.cpp in Sources */, + D750F0DE10D1C4A8009AA50B /* atom_hinf.cpp in Sources */, + D750F0DF10D1C4A8009AA50B /* atom_hnti.cpp in Sources */, + D750F0E010D1C4A8009AA50B /* atom_href.cpp in Sources */, + D750F0E110D1C4A8009AA50B /* atom_mdat.cpp in Sources */, + D750F0E210D1C4A8009AA50B /* atom_mdhd.cpp in Sources */, + D750F0E310D1C4A8009AA50B /* atom_meta.cpp in Sources */, + D750F0E410D1C4A8009AA50B /* atom_mp4s.cpp in Sources */, + D750F0E510D1C4A8009AA50B /* atom_mp4v.cpp in Sources */, + D750F0E610D1C4A8009AA50B /* atom_mvhd.cpp in Sources */, + D750F0E710D1C4A8009AA50B /* atom_nmhd.cpp in Sources */, + D750F0E810D1C4A8009AA50B /* atom_ohdr.cpp in Sources */, + D750F0E910D1C4A8009AA50B /* atom_pasp.cpp in Sources */, + D750F0EA10D1C4A8009AA50B /* atom_root.cpp in Sources */, + D750F0EB10D1C4A8009AA50B /* atom_rtp.cpp in Sources */, + D750F0EC10D1C4A8009AA50B /* atom_s263.cpp in Sources */, + D750F0ED10D1C4A8009AA50B /* atom_sdp.cpp in Sources */, + D750F0EE10D1C4A8009AA50B /* atom_sdtp.cpp in Sources */, + D750F0EF10D1C4A8009AA50B /* atom_smi.cpp in Sources */, + D750F0F010D1C4A8009AA50B /* atom_sound.cpp in Sources */, + D750F0F110D1C4A8009AA50B /* atom_standard.cpp in Sources */, + D750F0F210D1C4A8009AA50B /* atom_stbl.cpp in Sources */, + D750F0F310D1C4A8009AA50B /* atom_stdp.cpp in Sources */, + D750F0F410D1C4A8009AA50B /* atom_stsc.cpp in Sources */, + D750F0F510D1C4A8009AA50B /* atom_stsd.cpp in Sources */, + D750F0F610D1C4A8009AA50B /* atom_stsz.cpp in Sources */, + D750F0F710D1C4A8009AA50B /* atom_stz2.cpp in Sources */, + D750F0F810D1C4A8009AA50B /* atom_text.cpp in Sources */, + D750F0F910D1C4A8009AA50B /* atom_tfhd.cpp in Sources */, + D750F0FA10D1C4A8009AA50B /* atom_tkhd.cpp in Sources */, + D750F0FB10D1C4A8009AA50B /* atom_treftype.cpp in Sources */, + D750F0FC10D1C4A8009AA50B /* atom_trun.cpp in Sources */, + D750F0FD10D1C4A8009AA50B /* atom_tx3g.cpp in Sources */, + D750F0FE10D1C4A8009AA50B /* atom_udta.cpp in Sources */, + D750F0FF10D1C4A8009AA50B /* atom_url.cpp in Sources */, + D750F10010D1C4A8009AA50B /* atom_urn.cpp in Sources */, + D750F10110D1C4A8009AA50B /* atom_uuid.cpp in Sources */, + D750F10210D1C4A8009AA50B /* atom_video.cpp in Sources */, + D750F10310D1C4A8009AA50B /* atom_vmhd.cpp in Sources */, + D750F10510D1C4A8009AA50B /* cmeta.cpp in Sources */, + D750F10610D1C4A8009AA50B /* descriptors.cpp in Sources */, + D750F10910D1C4A8009AA50B /* exception.cpp in Sources */, + D750F10C10D1C4A8009AA50B /* isma.cpp in Sources */, + D750F10D10D1C4A8009AA50B /* mp4.cpp in Sources */, + D750F10F10D1C4A8009AA50B /* mp4atom.cpp in Sources */, + D750F11110D1C4A8009AA50B /* mp4container.cpp in Sources */, + D750F11310D1C4A8009AA50B /* mp4descriptor.cpp in Sources */, + D750F11610D1C4A8009AA50B /* mp4file.cpp in Sources */, + D750F11810D1C4A8009AA50B /* mp4file_io.cpp in Sources */, + D750F11910D1C4A8009AA50B /* mp4info.cpp in Sources */, + D750F11A10D1C4A8009AA50B /* mp4meta.cpp in Sources */, + D750F11B10D1C4A8009AA50B /* mp4property.cpp in Sources */, + D750F11D10D1C4A8009AA50B /* mp4track.cpp in Sources */, + D750F11F10D1C4A8009AA50B /* mp4util.cpp in Sources */, + D750F12110D1C4A8009AA50B /* ocidescriptors.cpp in Sources */, + D750F12310D1C4A8009AA50B /* odcommands.cpp in Sources */, + D750F12510D1C4A8009AA50B /* qosqualifiers.cpp in Sources */, + D750F12710D1C4A8009AA50B /* rtphint.cpp in Sources */, + D750F12A10D1C4A8009AA50B /* text.cpp in Sources */, + D750F13310D1C4C1009AA50B /* typebmff.cpp in Sources */, + D750F13F10D1C4DE009AA50B /* CoverArtBox.cpp in Sources */, + D750F14110D1C4DE009AA50B /* generic.cpp in Sources */, + D750F14510D1C4DE009AA50B /* Tags.cpp in Sources */, + D750F14710D1C4DE009AA50B /* type.cpp in Sources */, + D750F15110D1C4F5009AA50B /* coding.cpp in Sources */, + D750F15310D1C4F5009AA50B /* ColorParameterBox.cpp in Sources */, + D750F15610D1C4F5009AA50B /* PictureAspectRatioBox.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 1DEB91EC08733DB70010E9CD /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + PRODUCT_NAME = mp4v2; + }; + name = Debug; + }; + 1DEB91ED08733DB70010E9CD /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + PRODUCT_NAME = mp4v2; + }; + name = Release; + }; + 1DEB91F008733DB70010E9CD /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = B033B6950B2FAA7C00CEEEDA /* MacConfigExternalDebug.xcconfig */; + buildSettings = { + GCC_WARN_INHIBIT_ALL_WARNINGS = YES; + OTHER_CFLAGS = ( + "$(inherited)", + "-DHAVE_CONFIG_H", + ); + USER_HEADER_SEARCH_PATHS = "/usr/include . ./include"; + WARNING_CFLAGS = "-w"; + }; + name = Debug; + }; + 1DEB91F108733DB70010E9CD /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = B033B6960B2FAA7C00CEEEDA /* MacConfigExternalRelease.xcconfig */; + buildSettings = { + GCC_WARN_INHIBIT_ALL_WARNINGS = YES; + OTHER_CFLAGS = ( + "$(inherited)", + "-DHAVE_CONFIG_H", + ); + USER_HEADER_SEARCH_PATHS = "/usr/include . ./include"; + WARNING_CFLAGS = "-w"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 1DEB91EB08733DB70010E9CD /* Build configuration list for PBXNativeTarget "mp4v2" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1DEB91EC08733DB70010E9CD /* Debug */, + 1DEB91ED08733DB70010E9CD /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "mp4v2" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1DEB91F008733DB70010E9CD /* Debug */, + 1DEB91F108733DB70010E9CD /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 08FB7793FE84155DC02AAC07 /* Project object */; +} diff --git a/project/project.m4 b/project/project.m4 new file mode 100644 index 0000000..dbd639b --- /dev/null +++ b/project/project.m4 @@ -0,0 +1,24 @@ +define(<<__PROJECT_name>>, <<MP4v2>>)dnl +define(<<__PROJECT_name_lower>>, <<mp4v2>>)dnl +define(<<__PROJECT_name_upper>>, <<MP4V2>>)dnl +define(<<__PROJECT_name_formal>>, <<MP4v2 1.9.1>>)dnl +define(<<__PROJECT_url_website>>, <<http://code.google.com/p/mp4v2>>)dnl +define(<<__PROJECT_url_downloads>>, <<http://code.google.com/p/mp4v2/downloads/list>>)dnl +define(<<__PROJECT_url_discussion>>, <<http://groups.google.com/group/mp4v2>>)dnl +define(<<__PROJECT_irc>>, <<irc://irc.freenode.net/mp4v2>>)dnl +define(<<__PROJECT_bugreport>>, <<<eddyg@myreflection.org>>>)dnl +define(<<__PROJECT_version>>, <<1.9.1>>)dnl +define(<<__PROJECT_version_hex>>, <<0x00010901>>)dnl +define(<<__PROJECT_version_major>>, <<1>>)dnl +define(<<__PROJECT_version_minor>>, <<9>>)dnl +define(<<__PROJECT_version_point>>, <<1>>)dnl +define(<<__PROJECT_repo_url>>, <<https://mp4v2.googlecode.com/svn/releases/1.9.1>>)dnl +define(<<__PROJECT_repo_root>>, <<https://mp4v2.googlecode.com/svn>>)dnl +define(<<__PROJECT_repo_uuid>>, <<6e6572fa-98a6-11dd-ad9f-f77439c74b79>>)dnl +define(<<__PROJECT_repo_rev>>, <<368>>)dnl +define(<<__PROJECT_repo_date>>, <<2009-07-14 11:25:03 +1200 (Tue, 14 Jul 2009)>>)dnl +define(<<__PROJECT_repo_type>>, <<stable>>)dnl +define(<<__PROJECT_build>>, <<Wed May 19 14:32:21 PDT 2010>>)dnl +dnl +define(<<__MAKE_ABS_TOP_BUILDDIR>>, <</home/saintlou/Work/jingle-jumper/jumper/third_party/mp4v2>>)dnl +define(<<__MAKE_ABS_TOP_SRCDIR>>, <</home/saintlou/Work/jingle-jumper/jumper/third_party/mp4v2>>)dnl diff --git a/project/project.m4.in b/project/project.m4.in new file mode 100644 index 0000000..6ba66f4 --- /dev/null +++ b/project/project.m4.in @@ -0,0 +1,24 @@ +define(<<__PROJECT_name>>, <<@PROJECT_name@>>)dnl +define(<<__PROJECT_name_lower>>, <<@PROJECT_name_lower@>>)dnl +define(<<__PROJECT_name_upper>>, <<@PROJECT_name_upper@>>)dnl +define(<<__PROJECT_name_formal>>, <<@PROJECT_name_formal@>>)dnl +define(<<__PROJECT_url_website>>, <<@PROJECT_url_website@>>)dnl +define(<<__PROJECT_url_downloads>>, <<@PROJECT_url_downloads@>>)dnl +define(<<__PROJECT_url_discussion>>, <<@PROJECT_url_discussion@>>)dnl +define(<<__PROJECT_irc>>, <<@PROJECT_irc@>>)dnl +define(<<__PROJECT_bugreport>>, <<@PROJECT_bugreport@>>)dnl +define(<<__PROJECT_version>>, <<@PROJECT_version@>>)dnl +define(<<__PROJECT_version_hex>>, <<@PROJECT_version_hex@>>)dnl +define(<<__PROJECT_version_major>>, <<@PROJECT_version_major@>>)dnl +define(<<__PROJECT_version_minor>>, <<@PROJECT_version_minor@>>)dnl +define(<<__PROJECT_version_point>>, <<@PROJECT_version_point@>>)dnl +define(<<__PROJECT_repo_url>>, <<@PROJECT_repo_url@>>)dnl +define(<<__PROJECT_repo_root>>, <<@PROJECT_repo_root@>>)dnl +define(<<__PROJECT_repo_uuid>>, <<@PROJECT_repo_uuid@>>)dnl +define(<<__PROJECT_repo_rev>>, <<@PROJECT_repo_rev@>>)dnl +define(<<__PROJECT_repo_date>>, <<@PROJECT_repo_date@>>)dnl +define(<<__PROJECT_repo_type>>, <<@PROJECT_repo_type@>>)dnl +define(<<__PROJECT_build>>, <<@PROJECT_build@>>)dnl +dnl +define(<<__MAKE_ABS_TOP_BUILDDIR>>, <<@abs_top_builddir@>>)dnl +define(<<__MAKE_ABS_TOP_SRCDIR>>, <<@abs_top_srcdir@>>)dnl diff --git a/project/project.m4sugar b/project/project.m4sugar new file mode 100644 index 0000000..ea8822b --- /dev/null +++ b/project/project.m4sugar @@ -0,0 +1,15 @@ +dnl +dnl This file defines highest-level project meta-data in autoconf M4 format. +dnl It is needed downstream by configure.ac. +dnl +define([PRJ_name], [MP4v2]) +define([PRJ_name_lower], [mp4v2]) +define([PRJ_name_upper], [MP4V2]) +define([PRJ_url_website], [http://code.google.com/p/mp4v2]) +define([PRJ_url_downloads], [http://code.google.com/p/mp4v2/downloads/list]) +define([PRJ_url_discussion], [http://groups.google.com/group/mp4v2]) +define([PRJ_irc], [irc://irc.freenode.net/mp4v2]) +define([PRJ_bugreport], [eddyg@myreflection.org]) +define([PRJ_version_major], [1]) +define([PRJ_version_minor], [9]) +define([PRJ_version_point], [1]) diff --git a/src/3gp.cpp b/src/3gp.cpp new file mode 100644 index 0000000..28c7daf --- /dev/null +++ b/src/3gp.cpp @@ -0,0 +1,69 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * 3GPP features implementation is based on 3GPP's TS26.234-v5.60, + * and was contributed by Ximpo Group Ltd. + * + * Portions created by Ximpo Group Ltd. are + * Copyright (C) Ximpo Group Ltd. 2003, 2004. All Rights Reserved. + * + * Contributor(s): + * Ximpo Group Ltd. mp4v2@ximpo.com + */ + +#include "src/impl.h" + +namespace mp4v2 { namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +#define _3GP_MAJOR_BRAND "3gp5" +#define _3GP_MINOR_VERSION 0x0001 + +void MP4File::Make3GPCompliant(const char* fileName, char* majorBrand, uint32_t minorVersion, char** supportedBrands, uint32_t supportedBrandsCount, bool deleteIodsAtom) +{ + char brand[5] = "3gp5"; + char* _3gpSupportedBrands[1] = { (char*)&brand }; + + if (majorBrand) { + if (!supportedBrands || !supportedBrandsCount) { + throw new MP4Error("Invalid parameters", "MP4File::Make3GPCompliant"); + } + } + + MakeFtypAtom( + majorBrand ? majorBrand : (char*)brand, + majorBrand ? minorVersion : _3GP_MINOR_VERSION, + majorBrand ? supportedBrands : (char**)_3gpSupportedBrands, + majorBrand ? supportedBrandsCount : 1); + + if (deleteIodsAtom) { + // Delete the iods atom, if it exists.... + MP4Atom* iodsAtom = m_pRootAtom->FindAtom("moov.iods"); + if (iodsAtom) { + MP4Atom* moovAtom = m_pRootAtom->FindAtom("moov"); + ASSERT(moovAtom); + + moovAtom->DeleteChildAtom(iodsAtom); + } + } + +} + +/////////////////////////////////////////////////////////////////////////////// + +}} // namespace mp4v2::impl diff --git a/src/atom_ac3.cpp b/src/atom_ac3.cpp new file mode 100644 index 0000000..9da04dc --- /dev/null +++ b/src/atom_ac3.cpp @@ -0,0 +1,71 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * See ETSI TS 102 366 V1.2.1 Annex F for how to put Ac3 in MP4. + * + * Contributor(s): + * Edward Groenendaal egroenen@cisco.com + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4Ac3Atom::MP4Ac3Atom() + : MP4Atom("ac-3") +{ + AddReserved("reserved1", 6); /* 0 */ + + AddProperty( /* 1 */ + new MP4Integer16Property("dataReferenceIndex")); + + AddReserved("reserved2", 8); /* 2 */ + + AddProperty( /* 3 */ + new MP4Integer16Property("channelCount")); + + AddProperty( /* 4 */ + new MP4Integer16Property("sampleSize")); + + AddReserved("reserved3", 4); /* 5 */ + + AddProperty( /* 6 */ + new MP4Integer16Property("samplingRate")); + + AddReserved("reserved4", 2); /* 7 */ + + ExpectChildAtom("dac3", Required, OnlyOne); +} + +void MP4Ac3Atom::Generate() +{ + MP4Atom::Generate(); + + ((MP4Integer16Property*)m_pProperties[1])->SetValue(1); // data-reference-index + ((MP4Integer16Property*)m_pProperties[3])->SetValue(2); // channelCount - ignored + ((MP4Integer16Property*)m_pProperties[4])->SetValue(0x0010); // sampleSize - ignored + + // The user should set the samplingRate as appropriate - and create the dac3 atom +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/atom_amr.cpp b/src/atom_amr.cpp new file mode 100644 index 0000000..7bf0c66 --- /dev/null +++ b/src/atom_amr.cpp @@ -0,0 +1,75 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * 3GPP features implementation is based on 3GPP's TS26.234-v5.60, + * and was contributed by Ximpo Group Ltd. + * + * Portions created by Ximpo Group Ltd. are + * Copyright (C) Ximpo Group Ltd. 2003, 2004. All Rights Reserved. + * + * Contributor(s): + * Ximpo Group Ltd. mp4v2@ximpo.com + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4AmrAtom::MP4AmrAtom(const char *type) + : MP4Atom(type) +{ + AddReserved("reserved1", 6); /* 0 */ + + AddProperty( /* 1 */ + new MP4Integer16Property("dataReferenceIndex")); + + AddReserved("reserved2", 16); /* 2 */ + + AddProperty( /* 3 */ + new MP4Integer16Property("timeScale")); + + AddReserved("reserved3", 2); /* 4 */ + + ExpectChildAtom("damr", Required, OnlyOne); +} + +void MP4AmrAtom::Generate() +{ + MP4Atom::Generate(); + + ((MP4Integer16Property*)m_pProperties[1])->SetValue(1); + + // property reserved2 has non-zero fixed values + static uint8_t reserved2[16] = { + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x02, 0x00, 0x10, + 0x00, 0x00, 0x00, 0x00, + }; + m_pProperties[2]->SetReadOnly(false); + ((MP4BytesProperty*)m_pProperties[2])-> + SetValue(reserved2, sizeof(reserved2)); + m_pProperties[2]->SetReadOnly(true); +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/atom_avc1.cpp b/src/atom_avc1.cpp new file mode 100644 index 0000000..ffff1d7 --- /dev/null +++ b/src/atom_avc1.cpp @@ -0,0 +1,93 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2004. All Rights Reserved. + * + * Contributor(s): + * Bill May wmay@cisco.com + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4Avc1Atom::MP4Avc1Atom() + : MP4Atom("avc1") +{ + AddReserved("reserved1", 6); /* 0 */ + + AddProperty( /* 1 */ + new MP4Integer16Property("dataReferenceIndex")); + + AddReserved("reserved2", 16); /* 2 */ + + AddProperty( /* 3 */ + new MP4Integer16Property("width")); + AddProperty( /* 4 */ + new MP4Integer16Property("height")); + + AddReserved("reserved3", 14); /* 5 */ + + MP4StringProperty* pProp = + new MP4StringProperty("compressorName"); + pProp->SetFixedLength(32); + pProp->SetCountedFormat(true); + pProp->SetValue("JVT/AVC Coding"); + AddProperty(pProp); /* 6 */ + + AddReserved("reserved4", 4); /* 7 */ + + ExpectChildAtom("avcC", Required, OnlyOne); + ExpectChildAtom("btrt", Optional, OnlyOne); + ExpectChildAtom("colr", Optional, OnlyOne); + ExpectChildAtom("pasp", Optional, OnlyOne); + // for now ExpectChildAtom("m4ds", Optional, OnlyOne); +} + +void MP4Avc1Atom::Generate() +{ + MP4Atom::Generate(); + + ((MP4Integer16Property*)m_pProperties[1])->SetValue(1); + + // property reserved3 has non-zero fixed values + static uint8_t reserved3[14] = { + 0x00, 0x48, 0x00, 0x00, + 0x00, 0x48, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, + }; + m_pProperties[5]->SetReadOnly(false); + ((MP4BytesProperty*)m_pProperties[5])-> + SetValue(reserved3, sizeof(reserved3)); + m_pProperties[5]->SetReadOnly(true); + + // property reserved4 has non-zero fixed values + static uint8_t reserved4[4] = { + 0x00, 0x18, 0xFF, 0xFF, + }; + m_pProperties[7]->SetReadOnly(false); + ((MP4BytesProperty*)m_pProperties[7])-> + SetValue(reserved4, sizeof(reserved4)); + m_pProperties[7]->SetReadOnly(true); +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/atom_avcC.cpp b/src/atom_avcC.cpp new file mode 100644 index 0000000..fb0e6e5 --- /dev/null +++ b/src/atom_avcC.cpp @@ -0,0 +1,269 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2004. All Rights Reserved. + * + * Contributor(s): + * Bill May wmay@cisco.com + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +/* + * SizeTableProperty is a special version of the MP4TableProperty - + * the BytesProperty will need to set the value before it can read + * from the file + */ +class SizeTableProperty : public MP4TableProperty +{ +public: + SizeTableProperty(const char *name, MP4IntegerProperty *pCountProperty) : + MP4TableProperty(name, pCountProperty) {}; +protected: + void ReadEntry(MP4File *pFile, uint32_t index) { + // Each table has a size, followed by the length field + // first, read the length + m_pProperties[0]->Read(pFile, index); + MP4IntegerProperty *pIntProp = (MP4IntegerProperty *)m_pProperties[0]; + // set the size in the bytes property + MP4BytesProperty *pBytesProp = (MP4BytesProperty *)m_pProperties[1]; + pBytesProp->SetValueSize(pIntProp->GetValue(index), index); + // And read the bytes + m_pProperties[1]->Read(pFile, index); + }; +}; + +MP4AvcCAtom::MP4AvcCAtom() + : MP4Atom("avcC") +{ + MP4BitfieldProperty *pCount; + MP4TableProperty *pTable; + + AddProperty( new MP4Integer8Property("configurationVersion")); /* 0 */ + + AddProperty( new MP4Integer8Property("AVCProfileIndication")); /* 1 */ + + AddProperty( new MP4Integer8Property("profile_compatibility")); /* 2 */ + + AddProperty( new MP4Integer8Property("AVCLevelIndication")); /* 3 */ + + AddProperty( new MP4BitfieldProperty("reserved", 6)); /* 4 */ + AddProperty( new MP4BitfieldProperty("lengthSizeMinusOne", 2)); /* 5 */ + AddProperty( new MP4BitfieldProperty("reserved1", 3)); /* 6 */ + pCount = new MP4BitfieldProperty("numOfSequenceParameterSets", 5); + AddProperty(pCount); /* 7 */ + + pTable = new SizeTableProperty("sequenceEntries", pCount); + AddProperty(pTable); /* 8 */ + pTable->AddProperty(new MP4Integer16Property("sequenceParameterSetLength")); + pTable->AddProperty(new MP4BytesProperty("sequenceParameterSetNALUnit")); + + MP4Integer8Property *pCount2 = new MP4Integer8Property("numOfPictureParameterSets"); + AddProperty(pCount2); /* 9 */ + + pTable = new SizeTableProperty("pictureEntries", pCount2); + AddProperty(pTable); /* 10 */ + pTable->AddProperty(new MP4Integer16Property("pictureParameterSetLength")); + pTable->AddProperty(new MP4BytesProperty("pictureParameterSetNALUnit")); +} + +void MP4AvcCAtom::Generate() +{ + MP4Atom::Generate(); + + ((MP4Integer8Property*)m_pProperties[0])->SetValue(1); + + m_pProperties[4]->SetReadOnly(false); + ((MP4BitfieldProperty*)m_pProperties[4])->SetValue(0x3f); + m_pProperties[4]->SetReadOnly(true); + + m_pProperties[6]->SetReadOnly(false); + ((MP4BitfieldProperty*)m_pProperties[6])->SetValue(0x7); + m_pProperties[6]->SetReadOnly(true); +#if 0 + // property reserved4 has non-zero fixed values + static uint8_t reserved4[4] = { + 0x00, 0x18, 0xFF, 0xFF, + }; + m_pProperties[7]->SetReadOnly(false); + ((MP4BytesProperty*)m_pProperties[7])-> + SetValue(reserved4, sizeof(reserved4)); + m_pProperties[7]->SetReadOnly(true); +#endif +} + +// +// Clone - clone my properties to destination atom +// +// this method simplifies duplicating avcC atom properties from +// source to destination file using a single API rather than +// having to copy each property. This API encapsulates the object +// so the application layer need not concern with each property +// thereby isolating any future changes to atom properties. +// +// ---------------------------------------- +// property description +// ---------------------------------------- +// +// 0 configurationVersion +// 1 AVCProfileIndication +// 2 profile_compatibility +// 3 AVCLevelIndication +// 4 reserved +// 5 lengthSizeMinusOne +// 6 reserved +// 7 number of SPS +// 8 SPS entries +// 9 number of PPS +// 10 PPS entries +// +// +void MP4AvcCAtom::Clone(MP4AvcCAtom *dstAtom) +{ + + MP4Property *dstProperty; + MP4TableProperty *pTable; + uint16_t i16; + uint64_t i32; + uint64_t i64; + uint8_t *tmp; + + // source pointer Property I16 + MP4Integer16Property *spPI16; + // source pointer Property Bytes + MP4BytesProperty *spPB; + + // dest pointer Property I16 + MP4Integer16Property *dpPI16; + // dest pointer Property Bytes + MP4BytesProperty *dpPB; + + + // start with defaults and reserved fields + dstAtom->Generate(); + + // 0, 4, 6 are now generated from defaults + // leaving 1, 2, 3, 5, 7, 8, 9, 10 to export + + dstProperty=dstAtom->GetProperty(1); + ((MP4Integer8Property *)dstProperty)->SetValue( + ((MP4Integer8Property *)m_pProperties[1])->GetValue()); + + dstProperty=dstAtom->GetProperty(2); + ((MP4Integer8Property *)dstProperty)->SetValue( + ((MP4Integer8Property *)m_pProperties[2])->GetValue()); + + dstProperty=dstAtom->GetProperty(3); + ((MP4Integer8Property *)dstProperty)->SetValue( + ((MP4Integer8Property *)m_pProperties[3])->GetValue()); + + dstProperty=dstAtom->GetProperty(5); + ((MP4BitfieldProperty *)dstProperty)->SetValue( + ((MP4BitfieldProperty *)m_pProperties[5])->GetValue()); + + // + // 7 and 8 are related SPS (one set of sequence parameters) + // + // first the count bitfield + // + dstProperty=dstAtom->GetProperty(7); + dstProperty->SetReadOnly(false); + ((MP4BitfieldProperty *)dstProperty)->SetValue( + ((MP4BitfieldProperty *)m_pProperties[7])->GetValue()); + dstProperty->SetReadOnly(true); + + // next export SPS Length and NAL bytes */ + + // first source pointers + pTable = (MP4TableProperty *) m_pProperties[8]; + spPI16 = (MP4Integer16Property *)pTable->GetProperty(0); + spPB = (MP4BytesProperty *)pTable->GetProperty(1); + + // now dest pointers + dstProperty=dstAtom->GetProperty(8); + pTable = (MP4TableProperty *) dstProperty; + dpPI16 = (MP4Integer16Property *)pTable->GetProperty(0); + dpPB = (MP4BytesProperty *)pTable->GetProperty(1); + + // sps length + i16 = spPI16->GetValue(); + i64 = i16; + // FIXME - this leaves m_maxNumElements =2 + // but src atom m_maxNumElements is 1 + dpPI16->InsertValue(i64, 0); + + // export byte array + i32 = i16; + // copy bytes to local buffer + tmp = (uint8_t *)MP4Malloc(i32); + ASSERT(tmp != NULL); + spPB->CopyValue(tmp, 0); + // set element count + dpPB->SetCount(1); + // copy bytes + dpPB->SetValue(tmp, i32, 0); + MP4Free((void *)tmp); + + // + // 9 and 10 are related PPS (one set of picture parameters) + // + // first the integer8 count + // + dstProperty=dstAtom->GetProperty(9); + dstProperty->SetReadOnly(false); + ((MP4Integer8Property *)dstProperty)->SetValue( + ((MP4Integer8Property *)m_pProperties[9])->GetValue()); + dstProperty->SetReadOnly(true); + + // next export PPS Length and NAL bytes */ + + // first source pointers + pTable = (MP4TableProperty *) m_pProperties[10]; + spPI16 = (MP4Integer16Property *)pTable->GetProperty(0); + spPB = (MP4BytesProperty *)pTable->GetProperty(1); + + // now dest pointers + dstProperty=dstAtom->GetProperty(10); + pTable = (MP4TableProperty *) dstProperty; + dpPI16 = (MP4Integer16Property *)pTable->GetProperty(0); + dpPB = (MP4BytesProperty *)pTable->GetProperty(1); + + // pps length + i16 = spPI16->GetValue(); + i64 = i16; + dpPI16->InsertValue(i64, 0); + + // export byte array + i32 = i16; + // copy bytes to local buffer + tmp = (uint8_t *)MP4Malloc(i32); + ASSERT(tmp != NULL); + spPB->CopyValue(tmp, 0); + // set element count + dpPB->SetCount(1); + // copy bytes + dpPB->SetValue(tmp, i32, 0); + MP4Free((void *)tmp); +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/atom_chpl.cpp b/src/atom_chpl.cpp new file mode 100644 index 0000000..b3a1cd2 --- /dev/null +++ b/src/atom_chpl.cpp @@ -0,0 +1,65 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +// MP4ChplAtom is for Nero chapter list atom which is a child of udta +MP4ChplAtom::MP4ChplAtom () + : MP4Atom("chpl") +{ + // it is not completely clear if version, flags, reserved and chaptercount + // have the right sizes but + // one thing is clear: chaptercount is not only 8-bit it is at least 16-bit + + // add the version + AddVersionAndFlags(); + + // add reserved bytes + AddReserved("reserved", 1); + + // define the chaptercount + MP4Integer32Property * counter = new MP4Integer32Property("chaptercount"); + AddProperty(counter); + + // define the chapterlist + MP4TableProperty * list = new MP4TableProperty("chapters", counter); + + // the start time as 100 nanoseconds units + list->AddProperty(new MP4Integer64Property("starttime")); + + // the chapter name as UTF-8 + list->AddProperty(new MP4StringProperty("title", true)); + + // add the chapterslist + AddProperty(list); +} + +void MP4ChplAtom::Generate () +{ + SetVersion(1); +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/atom_colr.cpp b/src/atom_colr.cpp new file mode 100644 index 0000000..01de485 --- /dev/null +++ b/src/atom_colr.cpp @@ -0,0 +1,55 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * Contributer has declined to give copyright information, and gives + * it freely to the world. + * + * Contributor(s): + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4ColrAtom::MP4ColrAtom() + : MP4Atom("colr") +{ + MP4StringProperty* cpt = new MP4StringProperty("colorParameterType"); + cpt->SetFixedLength(4); + AddProperty(cpt); /* 0 */ + + AddProperty( /* 1 */ new MP4Integer16Property("primariesIndex")); + + AddProperty( /* 2 */ new MP4Integer16Property("transferFunctionIndex")); + + AddProperty( /* 3 */ new MP4Integer16Property("matrixIndex")); +} + +void MP4ColrAtom::Generate() +{ + MP4Atom::Generate(); + + ((MP4StringProperty*)m_pProperties[0])->SetValue("nclc"); + // default to ITU BT.709 values + ((MP4Integer16Property*)m_pProperties[1])->SetValue(1); + ((MP4Integer16Property*)m_pProperties[2])->SetValue(1); + ((MP4Integer16Property*)m_pProperties[3])->SetValue(1); +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/atom_d263.cpp b/src/atom_d263.cpp new file mode 100644 index 0000000..38b6d4e --- /dev/null +++ b/src/atom_d263.cpp @@ -0,0 +1,98 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * 3GPP features implementation is based on 3GPP's TS26.234-v5.60, + * and was contributed by Ximpo Group Ltd. + * + * Portions created by Ximpo Group Ltd. are + * Copyright (C) Ximpo Group Ltd. 2003, 2004. All Rights Reserved. + * + * Contributor(s): + * Ximpo Group Ltd. mp4v2@ximpo.com + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +#define H263_VENDOR 0x6d346970 + +MP4D263Atom::MP4D263Atom() + : MP4Atom("d263") +{ + AddProperty( /* 0 */ + new MP4Integer32Property("vendor")); + + AddProperty( /* 1 */ + new MP4Integer8Property("decoderVersion")); + + AddProperty( /* 2 */ + new MP4Integer8Property("h263Level")); + + AddProperty( /* 3 */ + new MP4Integer8Property("h263Profile")); + + ExpectChildAtom("bitr", Optional, OnlyOne); + +} + +void MP4D263Atom::Generate() +{ + MP4Atom::Generate(); + + ((MP4Integer32Property*)m_pProperties[0])->SetValue(H263_VENDOR); + ((MP4Integer8Property*)m_pProperties[1])->SetValue(1); + +} + +void MP4D263Atom::Write() +{ + // Check whether we have valid values in the bitr atom + // (if it exists, of course) + MP4Atom* bitrAtom = FindAtom("d263.bitr"); + if (bitrAtom) { + uint32_t avgBitrate; + uint32_t maxBitrate; + + MP4Integer32Property* pProp; + bitrAtom->FindProperty("bitr.avgBitrate", + (MP4Property**)&pProp, + NULL); + ASSERT(pProp); + avgBitrate = pProp->GetValue(); + + bitrAtom->FindProperty("bitr.maxBitrate", + (MP4Property**)&pProp, + NULL); + ASSERT(pProp); + maxBitrate = pProp->GetValue(); + + if (!maxBitrate && !avgBitrate) { + DeleteChildAtom(bitrAtom); + } + } + + MP4Atom::Write(); +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/atom_dac3.cpp b/src/atom_dac3.cpp new file mode 100644 index 0000000..a217bd8 --- /dev/null +++ b/src/atom_dac3.cpp @@ -0,0 +1,253 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * See ETSI TS 102 366 V1.2.1 Annex F for how to put Ac3 in MP4. + * + * Contributor(s): + * Edward Groenendaal egroenen@cisco.com + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + + +MP4DAc3Atom::MP4DAc3Atom() + : MP4Atom("dac3") +{ + AddProperty( new MP4BitfieldProperty("fscod", 2)); /* 0 */ + AddProperty( new MP4BitfieldProperty("bsid", 5)); /* 1 */ + AddProperty( new MP4BitfieldProperty("bsmod", 3)); /* 2 */ + AddProperty( new MP4BitfieldProperty("acmod", 3)); /* 3 */ + AddProperty( new MP4BitfieldProperty("lfeon", 1)); /* 4 */ + AddProperty( new MP4BitfieldProperty("bit_rate_code", 5)); /* 5 */ + AddProperty( new MP4BitfieldProperty("reserved", 5)); /* 6 */ + m_pProperties[6]->SetReadOnly(true); +} + +void MP4DAc3Atom::Generate() +{ + MP4Atom::Generate(); + + +} + +/* + * Normalling the Dump of the atom looks like the following, we want to spruce + * this up a bit to give more information. + * + * type = dac3 + * fscod = 0 (0x0) <2 bits> + * bsid = 8 (0x08) <5 bits> + * bsmod = 0 (0x0) <3 bits> + * acmod = 7 (0x7) <3 bits> + * lfeon = 1 (0x1) <1 bits> + * bit_rate_code = 15 (0x0f) <5 bits> + * reserved = 0 (0x00) <5 bits> + * + * into: + * type = dac3 + * fscod = 0 (0x0) <2 bits> [48 kHz] + * bsid = 8 (0x08) <5 bits> + * bsmod = 0 (0x0) <3 bits> [Main audio service: complete main (CM)] + * acmod = 7 (0x7) <3 bits> [3/2 (L, C, R, SL, SR)] + * lfeon = 1 (0x1) <1 bits> [ENABLED] + * bit_rate_code = 15 (0x0f) <5 bits> [448 kbit/s] + * reserved = 0 (0x00) <5 bits> + * + */ +void MP4DAc3Atom::Dump(FILE* pFile, uint8_t indent, bool dumpImplicits) +{ + + MP4BitfieldProperty* fscodProp = ((MP4BitfieldProperty*)m_pProperties[0]); + MP4BitfieldProperty* bsidProp = ((MP4BitfieldProperty*)m_pProperties[1]); + MP4BitfieldProperty* bsmodProp = ((MP4BitfieldProperty*)m_pProperties[2]); + MP4BitfieldProperty* acmodProp = ((MP4BitfieldProperty*)m_pProperties[3]); + MP4BitfieldProperty* lfeonProp = ((MP4BitfieldProperty*)m_pProperties[4]); + MP4BitfieldProperty* brcProp = ((MP4BitfieldProperty*)m_pProperties[5]); + MP4BitfieldProperty* resProp = ((MP4BitfieldProperty*)m_pProperties[6]); + + Indent(pFile, indent++); + + fprintf(pFile, "type = dac3\n"); + + if (fscodProp) { + uint64_t fscod = 0xFF; + const char* fscodString; + const char* fscods[] = { + "48", "44.1", "32", "Reserved", + }; + + Indent(pFile, indent); + + fscod = fscodProp->GetValue(); + + if (fscod < (sizeof(fscods) / sizeof(fscods[0]))) { + fscodString = fscods[fscod]; + } else { + fscodString = "Invalid value"; + } + + uint8_t hexWidth = fscodProp->GetNumBits() / 4; + if (hexWidth == 0 || (fscodProp->GetNumBits() % 4)) { + hexWidth++; + } + + fprintf(pFile, + "fscod = %" PRIu64 " (0x%0*" PRIx64 ") <%u bits> [%s kHz]\n", + fscod, (int)hexWidth, fscod, fscodProp->GetNumBits(), fscodString); + } + if (bsidProp) bsidProp->Dump(pFile, indent, dumpImplicits); + + if (bsmodProp) { + uint64_t bsmod = 0xFF; + const char* bsmodString; + const char* bsmods[] = { + "Main audio service: complete main (CM)", + "Main audio srrvice: music and effects (ME)", + "Associated service: visually impaired (VI)", + "Associated service: hearing impaired (HI)", + "Associated service: dialogue (D)", + "Associated service: commentary (C)", + "Associated service: emergency (E)", + "Associated service: voice over (VO) or Main audio service: karaoke", + }; + + Indent(pFile, indent); + + bsmod = bsmodProp->GetValue(); + + if (bsmod < (sizeof(bsmods) / sizeof(bsmods[0]))) { + bsmodString = bsmods[bsmod]; + } else { + bsmodString = "Invalid value"; + } + + uint8_t hexWidth = bsmodProp->GetNumBits() / 4; + if (hexWidth == 0 || (bsmodProp->GetNumBits() % 4)) { + hexWidth++; + } + + fprintf(pFile, + "bsmod = %" PRIu64 " (0x%0*" PRIx64 ") <%u bits> [%s]\n", + bsmod, (int)hexWidth, bsmod, bsmodProp->GetNumBits(), bsmodString); + } + + if (acmodProp) { + uint64_t acmod = 0xFF; + const char* acmodString; + + const char* acmods[] = { + "1 + 1 (Ch1, Ch2)", + "1/0 (C)", + "2/0 (L, R)", + "3/0 (L, C, R)", + "2/1 (L, R, S)", + "3/1 (L, C, R, S)", + "2/2 (L, R, SL, SR)", + "3/2 (L, C, R, SL, SR)", + }; + + Indent(pFile, indent); + + acmod = acmodProp->GetValue(); + + if (acmod < (sizeof(acmods) / sizeof(acmods[0]))) { + acmodString = acmods[acmod]; + } else { + acmodString = "Invalid value"; + } + + uint8_t hexWidth = acmodProp->GetNumBits() / 4; + if (hexWidth == 0 || (acmodProp->GetNumBits() % 4)) { + hexWidth++; + } + + fprintf(pFile, + "acmod = %" PRIu64 " (0x%0*" PRIx64 ") <%u bits> [%s]\n", + acmod, (int)hexWidth, acmod, acmodProp->GetNumBits(), acmodString); + } + + if (lfeonProp) { + uint64_t lfeon = lfeonProp->GetValue(); + uint8_t hexWidth = lfeonProp->GetNumBits() / 4; + + Indent(pFile, indent); + + if (hexWidth == 0 || (lfeonProp->GetNumBits() % 4)) { + hexWidth++; + } + + fprintf(pFile, + "lfeon = %" PRIu64 " (0x%0*" PRIx64 ") <%u bits> [%s]\n", + lfeon, (int)hexWidth, lfeon, + lfeonProp->GetNumBits(), lfeon ? "ENABLED" : "DISABLED"); + } + + if (brcProp) { + uint32_t bit_rate_codes[] = { + 32, + 40, + 48, + 56, + 64, + 80, + 96, + 112, + 128, + 160, + 192, + 224, + 256, + 320, + 384, + 448, + 512, + 576, + 640, + }; + uint64_t bit_rate_code = brcProp->GetValue(); + uint32_t bit_rate; + + Indent(pFile, indent); + + if (bit_rate_code < (sizeof(bit_rate_codes) / sizeof(bit_rate_codes[0]))) { + bit_rate = bit_rate_codes[bit_rate_code]; + } else { + bit_rate = 0; + } + + uint8_t hexWidth = brcProp->GetNumBits() / 4; + if (hexWidth == 0 || (brcProp->GetNumBits() % 4)) { + hexWidth++; + } + + fprintf(pFile, + "bit_rate_code = %" PRIu64 " (0x%0*" PRIx64 ") <%u bits> [%" PRIu32 " kbit/s]\n", + bit_rate_code, (int)hexWidth, bit_rate_code, + brcProp->GetNumBits(), bit_rate); + } + if (resProp) resProp->Dump(pFile, indent, dumpImplicits); +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/atom_damr.cpp b/src/atom_damr.cpp new file mode 100644 index 0000000..609807d --- /dev/null +++ b/src/atom_damr.cpp @@ -0,0 +1,69 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * 3GPP features implementation is based on 3GPP's TS26.234-v5.60, + * and was contributed by Ximpo Group Ltd. + * + * Portions created by Ximpo Group Ltd. are + * Copyright (C) Ximpo Group Ltd. 2003, 2004. All Rights Reserved. + * + * Contributor(s): + * Ximpo Group Ltd. mp4v2@ximpo.com + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +#define AMR_VENDOR 0x6d346970 + +MP4DamrAtom::MP4DamrAtom() + : MP4Atom("damr") +{ + AddProperty( /* 0 */ + new MP4Integer32Property("vendor")); + + AddProperty( /* 1 */ + new MP4Integer8Property("decoderVersion")); + + AddProperty( /* 2 */ + new MP4Integer16Property("modeSet")); + + AddProperty( /* 3 */ + new MP4Integer8Property("modeChangePeriod")); + + AddProperty( /* 4 */ + new MP4Integer8Property("framesPerSample")); + +} + +void MP4DamrAtom::Generate() +{ + MP4Atom::Generate(); + + ((MP4Integer32Property*)m_pProperties[0])->SetValue(AMR_VENDOR); + ((MP4Integer8Property*)m_pProperties[1])->SetValue(1); + +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/atom_dref.cpp b/src/atom_dref.cpp new file mode 100644 index 0000000..9d04f6d --- /dev/null +++ b/src/atom_dref.cpp @@ -0,0 +1,67 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4DrefAtom::MP4DrefAtom() + : MP4Atom("dref") +{ + AddVersionAndFlags(); + + MP4Integer32Property* pCount = + new MP4Integer32Property("entryCount"); + pCount->SetReadOnly(); + AddProperty(pCount); + + ExpectChildAtom("url ", Optional, Many); + ExpectChildAtom("urn ", Optional, Many); + ExpectChildAtom("alis", Optional, Many); +} + +void MP4DrefAtom::Read() +{ + /* do the usual read */ + MP4Atom::Read(); + + // check that number of children == entryCount + MP4Integer32Property* pCount = + (MP4Integer32Property*)m_pProperties[2]; + + if (m_pChildAtoms.Size() != pCount->GetValue()) { + VERBOSE_READ(GetVerbosity(), + MP4Printf("Warning: dref inconsistency with number of entries")); + + /* fix it */ + pCount->SetReadOnly(false); + pCount->SetValue(m_pChildAtoms.Size()); + pCount->SetReadOnly(true); + } +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/atom_elst.cpp b/src/atom_elst.cpp new file mode 100644 index 0000000..c2bc3d4 --- /dev/null +++ b/src/atom_elst.cpp @@ -0,0 +1,89 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4ElstAtom::MP4ElstAtom() + : MP4Atom("elst") +{ + AddVersionAndFlags(); + + MP4Integer32Property* pCount = + new MP4Integer32Property("entryCount"); + AddProperty(pCount); + + MP4TableProperty* pTable = new MP4TableProperty("entries", pCount); + AddProperty(pTable); +} + +void MP4ElstAtom::AddProperties(uint8_t version) +{ + MP4TableProperty* pTable = (MP4TableProperty*)m_pProperties[3]; + + if (version == 1) { + pTable->AddProperty( + new MP4Integer64Property("segmentDuration")); + pTable->AddProperty( + new MP4Integer64Property("mediaTime")); + } else { + pTable->AddProperty( + new MP4Integer32Property("segmentDuration")); + pTable->AddProperty( + new MP4Integer32Property("mediaTime")); + } + + pTable->AddProperty( + new MP4Integer16Property("mediaRate")); + pTable->AddProperty( + new MP4Integer16Property("reserved")); +} + +void MP4ElstAtom::Generate() +{ + SetVersion(0); + AddProperties(GetVersion()); + + MP4Atom::Generate(); +} + +void MP4ElstAtom::Read() +{ + /* read atom version */ + ReadProperties(0, 1); + + /* need to create the properties based on the atom version */ + AddProperties(GetVersion()); + + /* now we can read the remaining properties */ + ReadProperties(1); + + Skip(); // to end of atom +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/atom_enca.cpp b/src/atom_enca.cpp new file mode 100644 index 0000000..7d52912 --- /dev/null +++ b/src/atom_enca.cpp @@ -0,0 +1,71 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + * Alix Marchandise-Franquet alix@cisco.com + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4EncaAtom::MP4EncaAtom() + : MP4Atom("enca") +{ + AddReserved("reserved1", 6); /* 0 */ + + AddProperty( /* 1 */ + new MP4Integer16Property("dataReferenceIndex")); + + AddReserved("reserved2", 16); /* 2 */ + + AddProperty( /* 3 */ + new MP4Integer16Property("timeScale")); + + AddReserved("reserved3", 2); /* 4 */ + + ExpectChildAtom("esds", Required, OnlyOne); + ExpectChildAtom("sinf", Required, OnlyOne); +} + +void MP4EncaAtom::Generate() +{ + MP4Atom::Generate(); + + ((MP4Integer16Property*)m_pProperties[1])->SetValue(1); + + // property reserved2 has non-zero fixed values + static uint8_t reserved2[16] = { + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x02, 0x00, 0x10, + 0x00, 0x00, 0x00, 0x00, + }; + m_pProperties[2]->SetReadOnly(false); + ((MP4BytesProperty*)m_pProperties[2])-> + SetValue(reserved2, sizeof(reserved2)); + m_pProperties[2]->SetReadOnly(true); +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/atom_encv.cpp b/src/atom_encv.cpp new file mode 100644 index 0000000..077b6fa --- /dev/null +++ b/src/atom_encv.cpp @@ -0,0 +1,91 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + * Alix Marchandise-Franquet alix@cisco.com + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4EncvAtom::MP4EncvAtom() + : MP4Atom("encv") +{ + AddReserved("reserved1", 6); /* 0 */ + + AddProperty( /* 1 */ + new MP4Integer16Property("dataReferenceIndex")); + + AddReserved("reserved2", 16); /* 2 */ + + AddProperty( /* 3 */ + new MP4Integer16Property("width")); + AddProperty( /* 4 */ + new MP4Integer16Property("height")); + + AddReserved("reserved3", 14); /* 5 */ + + MP4StringProperty* pProp = + new MP4StringProperty("compressorName"); + pProp->SetFixedLength(32); + pProp->SetCountedFormat(true); + pProp->SetValue(""); + AddProperty(pProp); /* 6 */ + AddReserved("reserved4", 4); /* 7 */ + + ExpectChildAtom("esds", Required, OnlyOne); + ExpectChildAtom("sinf", Required, OnlyOne); + ExpectChildAtom("avcC", Optional, OnlyOne); +} + +void MP4EncvAtom::Generate() +{ + MP4Atom::Generate(); + + ((MP4Integer16Property*)m_pProperties[1])->SetValue(1); + + // property reserved3 has non-zero fixed values + static uint8_t reserved3[14] = { + 0x00, 0x48, 0x00, 0x00, + 0x00, 0x48, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, + }; + m_pProperties[5]->SetReadOnly(false); + ((MP4BytesProperty*)m_pProperties[5])-> + SetValue(reserved3, sizeof(reserved3)); + m_pProperties[5]->SetReadOnly(true); + + // property reserved4 has non-zero fixed values + static uint8_t reserved4[4] = { + 0x00, 0x18, 0xFF, 0xFF, + }; + m_pProperties[7]->SetReadOnly(false); + ((MP4BytesProperty*)m_pProperties[7])-> + SetValue(reserved4, sizeof(reserved4)); + m_pProperties[7]->SetReadOnly(true); +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/atom_free.cpp b/src/atom_free.cpp new file mode 100644 index 0000000..825e3f3 --- /dev/null +++ b/src/atom_free.cpp @@ -0,0 +1,58 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4FreeAtom::MP4FreeAtom( const char* type ) + : MP4Atom( type ? type : "free" ) +{ +} + +void MP4FreeAtom::Read() +{ + Skip(); +} + +void MP4FreeAtom::Write() +{ + ASSERT(m_pFile); + + bool use64 = (GetSize() > (0xFFFFFFFF - 8)); + BeginWrite(use64); +#if 1 + for (uint64_t ix = 0; ix < GetSize(); ix++) { + m_pFile->WriteUInt8(0); + } +#else + m_pFile->SetPosition(m_pFile->GetPosition() + GetSize()); +#endif + FinishWrite(use64); +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/atom_ftab.cpp b/src/atom_ftab.cpp new file mode 100644 index 0000000..579f6d3 --- /dev/null +++ b/src/atom_ftab.cpp @@ -0,0 +1,42 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4FtabAtom::MP4FtabAtom() + : MP4Atom("ftab") +{ + MP4Integer16Property* pCount = new MP4Integer16Property("entryCount"); /* 0 */ + AddProperty(pCount); + + MP4TableProperty* pTable = new MP4TableProperty("fontEntries", pCount); /* 1 */ + AddProperty(pTable); + + pTable->AddProperty(new MP4Integer16Property("fontID")); /* 0 */ + pTable->AddProperty(new MP4StringProperty("name", true)); /* 1 */ +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/atom_ftyp.cpp b/src/atom_ftyp.cpp new file mode 100644 index 0000000..e8269d4 --- /dev/null +++ b/src/atom_ftyp.cpp @@ -0,0 +1,62 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + */ + +#include "src/impl.h" + +namespace mp4v2 { namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4FtypAtom::MP4FtypAtom() + : MP4Atom( "ftyp" ) + , majorBrand ( *new MP4StringProperty( "majorBrand" )) + , minorVersion ( *new MP4Integer32Property( "minorVersion" )) + , compatibleBrands ( *new MP4StringProperty( "compatibleBrands", false, false, true )) +{ + majorBrand.SetFixedLength( 4 ); + compatibleBrands.SetFixedLength( 4 ); + + AddProperty( &majorBrand ); + AddProperty( &minorVersion ); + AddProperty( &compatibleBrands ); +} + +void MP4FtypAtom::Generate() +{ + MP4Atom::Generate(); + + majorBrand.SetValue( "mp42" ); + minorVersion.SetValue( 0 ); + + compatibleBrands.SetCount( 2 ); + compatibleBrands.SetValue( "mp42", 0 ); + compatibleBrands.SetValue( "isom", 1 ); +} + +void MP4FtypAtom::Read() +{ + compatibleBrands.SetCount( (m_size - 8) / 4 ); // brands array fills rest of atom + MP4Atom::Read(); +} + +/////////////////////////////////////////////////////////////////////////////// + +}} // namespace mp4v2::impl diff --git a/src/atom_gmin.cpp b/src/atom_gmin.cpp new file mode 100644 index 0000000..8c42bee --- /dev/null +++ b/src/atom_gmin.cpp @@ -0,0 +1,58 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * Contributer has declined to give copyright information, and gives + * it freely to the world. + * + * Contributor(s): + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4GminAtom::MP4GminAtom() + : MP4Atom("gmin") +{ + + AddVersionAndFlags(); /* 0, 1 */ + + AddProperty(new MP4Integer16Property("graphicsMode")); /* 2 */ + AddProperty(new MP4Integer16Property("opColorRed")); /* 3 */ + AddProperty(new MP4Integer16Property("opColorGreen")); /* 4 */ + AddProperty(new MP4Integer16Property("opColorBlue")); /* 5 */ + AddProperty(new MP4Integer16Property("balance")); /* 6 */ + AddReserved("reserved", 2); /* 7 */ + +} + +void MP4GminAtom::Generate() +{ + + MP4Atom::Generate(); + + ((MP4Integer16Property*)m_pProperties[2])->SetValue(0x0040); + ((MP4Integer16Property*)m_pProperties[3])->SetValue(0x8000); + ((MP4Integer16Property*)m_pProperties[4])->SetValue(0x8000); + ((MP4Integer16Property*)m_pProperties[5])->SetValue(0x8000); + ((MP4Integer16Property*)m_pProperties[6])->SetValue(0x0000); + +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/atom_hdlr.cpp b/src/atom_hdlr.cpp new file mode 100644 index 0000000..612709f --- /dev/null +++ b/src/atom_hdlr.cpp @@ -0,0 +1,82 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4HdlrAtom::MP4HdlrAtom() + : MP4Atom("hdlr") +{ + AddVersionAndFlags(); /* 0, 1 */ + AddReserved("reserved1", 4); /* 2 */ + MP4StringProperty* pProp = new MP4StringProperty("handlerType"); + pProp->SetFixedLength(4); + AddProperty(pProp); /* 3 */ + AddReserved("reserved2", 12); /* 4 */ + AddProperty( /* 5 */ + new MP4StringProperty("name")); +} + +// There is a spec incompatiblity between QT and MP4 +// QT says name field is a counted string +// MP4 says name field is a null terminated string +// Here we attempt to make all things work +void MP4HdlrAtom::Read() +{ + // read all the properties but the "name" field + ReadProperties(0, 5); + uint64_t pos = m_pFile->GetPosition(); + uint64_t end = GetEnd(); + if (pos == end) return; + + // YZG: A hdlr atom with missing "name". + // Apperantly that's what some of the iTunes m4p files have. + if (m_pFile->GetPosition() == GetEnd()) { + return; + } + + // take a peek at the next byte + uint8_t strLength; + m_pFile->PeekBytes(&strLength, 1); + // if the value matches the remaining atom length + if (pos + strLength + 1 == end) { + // read a counted string + MP4StringProperty* pNameProp = + (MP4StringProperty*)m_pProperties[5]; + pNameProp->SetCountedFormat(true); + ReadProperties(5); + pNameProp->SetCountedFormat(false); + } else { + // read a null terminated string + ReadProperties(5); + } + + Skip(); // to end of atom +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/atom_hinf.cpp b/src/atom_hinf.cpp new file mode 100644 index 0000000..33d8b24 --- /dev/null +++ b/src/atom_hinf.cpp @@ -0,0 +1,64 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + */ + +#include "src/impl.h" + +namespace mp4v2 { namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4HinfAtom::MP4HinfAtom() + : MP4Atom("hinf") +{ + ExpectChildAtom("trpy", Optional, OnlyOne); + ExpectChildAtom("nump", Optional, OnlyOne); + ExpectChildAtom("tpyl", Optional, OnlyOne); + ExpectChildAtom("maxr", Optional, Many); + ExpectChildAtom("dmed", Optional, OnlyOne); + ExpectChildAtom("dimm", Optional, OnlyOne); + ExpectChildAtom("drep", Optional, OnlyOne); + ExpectChildAtom("tmin", Optional, OnlyOne); + ExpectChildAtom("tmax", Optional, OnlyOne); + ExpectChildAtom("pmax", Optional, OnlyOne); + ExpectChildAtom("dmax", Optional, OnlyOne); + ExpectChildAtom("payt", Optional, OnlyOne); +} + +void MP4HinfAtom::Generate() +{ + // hinf is special in that although all it's child atoms + // are optional (on read), if we generate it for writing + // we really want all the children + + for (uint32_t i = 0; i < m_pChildAtomInfos.Size(); i++) { + MP4Atom* pChildAtom = + CreateAtom(this, m_pChildAtomInfos[i]->m_name); + + AddChildAtom(pChildAtom); + + // and ask it to self generate + pChildAtom->Generate(); + } +} + +/////////////////////////////////////////////////////////////////////////////// + +}} // namespace mp4v2::impl diff --git a/src/atom_hnti.cpp b/src/atom_hnti.cpp new file mode 100644 index 0000000..0fd2cb1 --- /dev/null +++ b/src/atom_hnti.cpp @@ -0,0 +1,50 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4HntiAtom::MP4HntiAtom() + : MP4Atom("hnti") +{ +} + +void MP4HntiAtom::Read() +{ + MP4Atom* grandParent = m_pParentAtom->GetParentAtom(); + ASSERT(grandParent); + if (ATOMID(grandParent->GetType()) == ATOMID("trak")) { + ExpectChildAtom("sdp ", Optional, OnlyOne); + } else { + ExpectChildAtom("rtp ", Optional, OnlyOne); + } + + MP4Atom::Read(); +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/atom_href.cpp b/src/atom_href.cpp new file mode 100644 index 0000000..d7d7f41 --- /dev/null +++ b/src/atom_href.cpp @@ -0,0 +1,50 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2005. All Rights Reserved. + * + * Contributor(s): + * Bill May wmay@cisco.com + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4HrefAtom::MP4HrefAtom() + : MP4Atom("href") +{ + AddReserved("reserved1", 6); /* 0 */ + + AddProperty( /* 1 */ + new MP4Integer16Property("dataReferenceIndex")); + ExpectChildAtom("burl", Optional, OnlyOne); +} + +void MP4HrefAtom::Generate() +{ + MP4Atom::Generate(); + + ((MP4Integer16Property*)m_pProperties[1])->SetValue(1); + +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/atom_mdat.cpp b/src/atom_mdat.cpp new file mode 100644 index 0000000..a61b87f --- /dev/null +++ b/src/atom_mdat.cpp @@ -0,0 +1,48 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4MdatAtom::MP4MdatAtom() + : MP4Atom("mdat") +{ +} + +void MP4MdatAtom::Read() +{ + Skip(); +} + +void MP4MdatAtom::Write() +{ + // should never get here + ASSERT(false); +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/atom_mdhd.cpp b/src/atom_mdhd.cpp new file mode 100644 index 0000000..9dfff27 --- /dev/null +++ b/src/atom_mdhd.cpp @@ -0,0 +1,98 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + */ + +#include "src/impl.h" + +namespace mp4v2 { namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4MdhdAtom::MP4MdhdAtom() + : MP4Atom("mdhd") +{ + AddVersionAndFlags(); +} + +void MP4MdhdAtom::AddProperties(uint8_t version) +{ + if (version == 1) { + AddProperty( + new MP4Integer64Property("creationTime")); + AddProperty( + new MP4Integer64Property("modificationTime")); + } else { + AddProperty( + new MP4Integer32Property("creationTime")); + AddProperty( + new MP4Integer32Property("modificationTime")); + } + + AddProperty( + new MP4Integer32Property("timeScale")); + + if (version == 1) { + AddProperty( + new MP4Integer64Property("duration")); + } else { + AddProperty( + new MP4Integer32Property("duration")); + } + + AddProperty( new MP4LanguageCodeProperty( "language" )); + AddReserved("reserved", 2); +} + +void MP4MdhdAtom::Generate() +{ + uint8_t version = m_pFile->Use64Bits(GetType()) ? 1 : 0; + SetVersion(version); + AddProperties(version); + + MP4Atom::Generate(); + + // set creation and modification times + MP4Timestamp now = MP4GetAbsTimestamp(); + if (version == 1) { + ((MP4Integer64Property*)m_pProperties[2])->SetValue(now); + ((MP4Integer64Property*)m_pProperties[3])->SetValue(now); + } else { + ((MP4Integer32Property*)m_pProperties[2])->SetValue(now); + ((MP4Integer32Property*)m_pProperties[3])->SetValue(now); + } +} + +void MP4MdhdAtom::Read() +{ + /* read atom version */ + ReadProperties(0, 1); + + /* need to create the properties based on the atom version */ + AddProperties(GetVersion()); + + /* now we can read the remaining properties */ + ReadProperties(1); + + Skip(); // to end of atom +} + +/////////////////////////////////////////////////////////////////////////////// + +}} // namespace mp4v2::impl diff --git a/src/atom_meta.cpp b/src/atom_meta.cpp new file mode 100644 index 0000000..63c8178 --- /dev/null +++ b/src/atom_meta.cpp @@ -0,0 +1,127 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * Contributor(s): + * M. Bakker mbakker at nero.com + * + * Apple iTunes META data + */ + +#include "src/impl.h" + +namespace mp4v2 { namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4DataAtom::MP4DataAtom() + : MP4Atom ( "data" ) + , typeReserved ( *new MP4Integer16Property( "typeReserved" )) + , typeSetIdentifier ( *new MP4Integer8Property( "typeSetIdentifier" )) + , typeCode ( *new MP4BasicTypeProperty( "typeCode" )) + , locale ( *new MP4Integer32Property( "locale" )) + , metadata ( *new MP4BytesProperty( "metadata" )) +{ + AddProperty( &typeReserved ); + AddProperty( &typeSetIdentifier ); + AddProperty( &typeCode ); + AddProperty( &locale ); + AddProperty( &metadata ); +} + +void +MP4DataAtom::Read() +{ + // calculate size of the metadata from the atom size + metadata.SetValueSize( m_size - 8 ); + MP4Atom::Read(); +} + +/////////////////////////////////////////////////////////////////////////////// + +MP4FullAtom::MP4FullAtom( const char* type ) + : MP4Atom ( type ) + , version ( *new MP4Integer8Property( "version" )) + , flags ( *new MP4Integer24Property( "flags" )) +{ + AddProperty( &version ); + AddProperty( &flags ); +} + +/////////////////////////////////////////////////////////////////////////////// + +MP4ItemAtom::MP4ItemAtom( const char* type ) + : MP4Atom( type ) +{ + ExpectChildAtom( "mean", Optional, OnlyOne ); + ExpectChildAtom( "name", Optional, OnlyOne ); + ExpectChildAtom( "data", Required, Many ); +} + +/////////////////////////////////////////////////////////////////////////////// + +MP4MeanAtom::MP4MeanAtom() + : MP4FullAtom ( "mean" ) + , value ( *new MP4StringProperty( "value" )) +{ + AddProperty( &value ); +} + +void +MP4MeanAtom::Read() +{ + // calculate size of the metadata from the atom size + value.SetFixedLength( m_size - 4 ); + MP4Atom::Read(); +} + +/////////////////////////////////////////////////////////////////////////////// + +MP4NameAtom::MP4NameAtom() + : MP4FullAtom( "name" ) + , value ( *new MP4StringProperty( "value" )) +{ + AddProperty( &value ); +} + +void +MP4NameAtom::Read() +{ + // calculate size of the metadata from the atom size + value.SetFixedLength( m_size - 4 ); + MP4FullAtom::Read(); +} + +/////////////////////////////////////////////////////////////////////////////// + +MP4UdtaElementAtom::MP4UdtaElementAtom( const char* type ) + : MP4Atom ( type ) + , value ( *new MP4BytesProperty( "value" )) +{ + AddProperty( &value ); +} + +void +MP4UdtaElementAtom::Read() +{ + // calculate size of the metadata from the atom size + value.SetValueSize( m_size ); + MP4Atom::Read(); +} + +/////////////////////////////////////////////////////////////////////////////// + +}} // namespace mp4v2::impl diff --git a/src/atom_mp4s.cpp b/src/atom_mp4s.cpp new file mode 100644 index 0000000..2015d2e --- /dev/null +++ b/src/atom_mp4s.cpp @@ -0,0 +1,49 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4Mp4sAtom::MP4Mp4sAtom() + : MP4Atom("mp4s") +{ + AddReserved("reserved1", 6); + AddProperty( + new MP4Integer16Property("dataReferenceIndex")); + + ExpectChildAtom("esds", Required, OnlyOne); +} + +void MP4Mp4sAtom::Generate() +{ + MP4Atom::Generate(); + + ((MP4Integer16Property*)m_pProperties[1])->SetValue(1); +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/atom_mp4v.cpp b/src/atom_mp4v.cpp new file mode 100644 index 0000000..b7e9f5c --- /dev/null +++ b/src/atom_mp4v.cpp @@ -0,0 +1,91 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4Mp4vAtom::MP4Mp4vAtom() + : MP4Atom("mp4v") +{ + AddReserved("reserved1", 6); /* 0 */ + + AddProperty( /* 1 */ + new MP4Integer16Property("dataReferenceIndex")); + + AddReserved("reserved2", 16); /* 2 */ + + AddProperty( /* 3 */ + new MP4Integer16Property("width")); + AddProperty( /* 4 */ + new MP4Integer16Property("height")); + + AddReserved("reserved3", 14); /* 5 */ + + MP4StringProperty* pProp = + new MP4StringProperty("compressorName"); + pProp->SetFixedLength(32); + pProp->SetCountedFormat(true); + pProp->SetValue(""); + AddProperty(pProp); /* 6 */ + + AddReserved("reserved4", 4); /* 7 */ + + ExpectChildAtom("colr", Optional, OnlyOne); + ExpectChildAtom("esds", Required, OnlyOne); + ExpectChildAtom("pasp", Optional, OnlyOne); +} + +void MP4Mp4vAtom::Generate() +{ + MP4Atom::Generate(); + + ((MP4Integer16Property*)m_pProperties[1])->SetValue(1); + + // property reserved3 has non-zero fixed values + static uint8_t reserved3[14] = { + 0x00, 0x48, 0x00, 0x00, + 0x00, 0x48, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, + }; + m_pProperties[5]->SetReadOnly(false); + ((MP4BytesProperty*)m_pProperties[5])-> + SetValue(reserved3, sizeof(reserved3)); + m_pProperties[5]->SetReadOnly(true); + + // property reserved4 has non-zero fixed values + static uint8_t reserved4[4] = { + 0x00, 0x18, 0xFF, 0xFF, + }; + m_pProperties[7]->SetReadOnly(false); + ((MP4BytesProperty*)m_pProperties[7])-> + SetValue(reserved4, sizeof(reserved4)); + m_pProperties[7]->SetReadOnly(true); +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/atom_mvhd.cpp b/src/atom_mvhd.cpp new file mode 100644 index 0000000..a1a7cf2 --- /dev/null +++ b/src/atom_mvhd.cpp @@ -0,0 +1,146 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4MvhdAtom::MP4MvhdAtom() + : MP4Atom("mvhd") +{ + AddVersionAndFlags(); +} + +void MP4MvhdAtom::AddProperties(uint8_t version) +{ + if (version == 1) { + AddProperty( /* 2 */ + new MP4Integer64Property("creationTime")); + AddProperty( /* 3 */ + new MP4Integer64Property("modificationTime")); + } else { + AddProperty( /* 2 */ + new MP4Integer32Property("creationTime")); + AddProperty( /* 3 */ + new MP4Integer32Property("modificationTime")); + } + + AddProperty( /* 4 */ + new MP4Integer32Property("timeScale")); + + if (version == 1) { + AddProperty( /* 5 */ + new MP4Integer64Property("duration")); + } else { + AddProperty( /* 5 */ + new MP4Integer32Property("duration")); + } + + MP4Float32Property* pProp; + + pProp = new MP4Float32Property("rate"); + pProp->SetFixed32Format(); + AddProperty(pProp); /* 6 */ + + pProp = new MP4Float32Property("volume"); + pProp->SetFixed16Format(); + AddProperty(pProp); /* 7 */ + + AddReserved("reserved1", 70); /* 8 */ + + AddProperty( /* 9 */ + new MP4Integer32Property("nextTrackId")); +} + +void MP4MvhdAtom::Generate() +{ + uint8_t version = m_pFile->Use64Bits(GetType()) ? 1 : 0; + SetVersion(version); + AddProperties(version); + + MP4Atom::Generate(); + + // set creation and modification times + MP4Timestamp now = MP4GetAbsTimestamp(); + if (version == 1) { + ((MP4Integer64Property*)m_pProperties[2])->SetValue(now); + ((MP4Integer64Property*)m_pProperties[3])->SetValue(now); + } else { + ((MP4Integer32Property*)m_pProperties[2])->SetValue(now); + ((MP4Integer32Property*)m_pProperties[3])->SetValue(now); + } + + ((MP4Integer32Property*)m_pProperties[4])->SetValue(1000); + + ((MP4Float32Property*)m_pProperties[6])->SetValue(1.0); + ((MP4Float32Property*)m_pProperties[7])->SetValue(1.0); + + // property reserved has non-zero fixed values + static uint8_t reserved[70] = { + 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x40, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + }; + m_pProperties[8]->SetReadOnly(false); + ((MP4BytesProperty*)m_pProperties[8])-> + SetValue(reserved, sizeof(reserved)); + m_pProperties[8]->SetReadOnly(true); + + // set next track id + ((MP4Integer32Property*)m_pProperties[9])->SetValue(1); +} + +void MP4MvhdAtom::Read() +{ + /* read atom version */ + ReadProperties(0, 1); + + /* need to create the properties based on the atom version */ + AddProperties(GetVersion()); + + /* now we can read the remaining properties */ + ReadProperties(1); + + Skip(); // to end of atom +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/atom_nmhd.cpp b/src/atom_nmhd.cpp new file mode 100644 index 0000000..b74c44d --- /dev/null +++ b/src/atom_nmhd.cpp @@ -0,0 +1,35 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4NmhdAtom::MP4NmhdAtom() + : MP4Atom("nmhd") +{ + AddVersionAndFlags(); +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/atom_ohdr.cpp b/src/atom_ohdr.cpp new file mode 100644 index 0000000..3a60547 --- /dev/null +++ b/src/atom_ohdr.cpp @@ -0,0 +1,102 @@ +/** \file atom_ohdr.cpp + + \author Danijel Kopcinovic (danijel.kopcinovic@adnecto.net) +*/ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +/*! \brief Patch class for read/write operations when string is 0-length. + + We want to use string property, but mpeg4ip doesn't support ohdr way of + encoding of string (in ohdr atom we first have 3 lengths of 3 strings and + then their string values, and it cannot be simulated with any of the + current mpeg4ip string property parameters), so we have to write our own + Read() and Write() routines. +*/ +class OhdrMP4StringProperty: public MP4StringProperty { +public: + /*! \brief Constructor. + + \param name name of the property. + \param useCountedFormat counted format flag. + \param useUnicode unicode flag. + */ + OhdrMP4StringProperty(const char* name, bool useCountedFormat = false, + bool useUnicode = false): MP4StringProperty(name, useCountedFormat, + useUnicode) { + } + + /*! \brief Read property from file. + + \param pFile input, file handle. + \param index input, index to read. + */ + void Read(MP4File* pFile, uint32_t index = 0) { + MP4Free(m_values[index]); + m_values[index] = (char*)MP4Calloc(m_fixedLength + 1); + (void)pFile->ReadBytes((uint8_t*)m_values[index], m_fixedLength); + } + + /*! \brief Write property to file. + + \param pFile input, file handle. + \param index input, index to write. + */ + void Write(MP4File* pFile, uint32_t index = 0) { + pFile->WriteBytes((uint8_t*)m_values[index], m_fixedLength); + } +}; + +/*! \brief OMA DRM headers atom. + + Contained in OMA DRM key management atom. It must contain content identifier. +*/ +/*! \brief Constructor. +*/ +MP4OhdrAtom::MP4OhdrAtom(): MP4Atom("ohdr") { + AddVersionAndFlags(); + + AddProperty(new MP4Integer8Property("EncryptionMethod")); + AddProperty(new MP4Integer8Property("EncryptionPadding")); + AddProperty(new MP4Integer64Property("PlaintextLength")); + AddProperty(new MP4Integer16Property("ContentIDLength")); + AddProperty(new MP4Integer16Property("RightsIssuerURLLength")); + AddProperty(new MP4Integer16Property("TextualHeadersLength")); + AddProperty(new OhdrMP4StringProperty("ContentID")); + AddProperty(new OhdrMP4StringProperty("RightsIssuerURL")); + AddProperty(new MP4BytesProperty("TextualHeaders")); +} + +MP4OhdrAtom::~MP4OhdrAtom() { +} + +/*! \brief Read atom. +*/ +void MP4OhdrAtom::Read() { + ReadProperties(0, 8); + MP4Property* lProperty; + MP4Property* property; + lProperty = GetProperty(5); + property = GetProperty(8); + ((OhdrMP4StringProperty*)property)->SetFixedLength( + ((MP4Integer16Property*)lProperty)->GetValue()); + lProperty = GetProperty(6); + property = GetProperty(9); + ((OhdrMP4StringProperty*)property)->SetFixedLength( + ((MP4Integer16Property*)lProperty)->GetValue()); + lProperty = GetProperty(7); + property = GetProperty(10); + ((MP4BytesProperty*)property)->SetFixedSize( + ((MP4Integer16Property*)lProperty)->GetValue()); + ReadProperties(8, 3); +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/atom_pasp.cpp b/src/atom_pasp.cpp new file mode 100644 index 0000000..241b986 --- /dev/null +++ b/src/atom_pasp.cpp @@ -0,0 +1,52 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * Contributer has declined to give copyright information, and gives + * it freely to the world. + * + * Contributor(s): + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4PaspAtom::MP4PaspAtom() + : MP4Atom("pasp") +{ + + AddProperty( /* 0 */ + new MP4Integer32Property("hSpacing")); + + AddProperty( /* 1 */ + new MP4Integer32Property("vSpacing")); + +} + +void MP4PaspAtom::Generate() +{ + + MP4Atom::Generate(); + + ((MP4Integer32Property*)m_pProperties[0])->SetValue(1); + ((MP4Integer32Property*)m_pProperties[1])->SetValue(1); + +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/atom_root.cpp b/src/atom_root.cpp new file mode 100644 index 0000000..ececd95 --- /dev/null +++ b/src/atom_root.cpp @@ -0,0 +1,160 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + */ + +#include "src/impl.h" + +namespace mp4v2 { namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4RootAtom::MP4RootAtom() + : MP4Atom( NULL ) + , m_rewrite_ftyp ( NULL ) + , m_rewrite_ftypPosition ( 0 ) + , m_rewrite_free ( NULL ) + , m_rewrite_freePosition ( 0 ) +{ + ExpectChildAtom( "moov", Required, OnlyOne ); + ExpectChildAtom( "ftyp", Optional, OnlyOne ); + ExpectChildAtom( "mdat", Optional, Many ); + ExpectChildAtom( "free", Optional, Many ); + ExpectChildAtom( "skip", Optional, Many ); + ExpectChildAtom( "udta", Optional, Many ); + ExpectChildAtom( "moof", Optional, Many ); +} + +void MP4RootAtom::BeginWrite(bool use64) +{ + m_rewrite_ftyp = (MP4FtypAtom*)FindChildAtom( "ftyp" ); + if( m_rewrite_ftyp ) { + m_rewrite_free = (MP4FreeAtom*)MP4Atom::CreateAtom( NULL, "free" ); + m_rewrite_free->SetSize( 32*4 ); // room for 32 additional brands + AddChildAtom( m_rewrite_free ); + + m_rewrite_ftypPosition = m_pFile->GetPosition(); + m_rewrite_ftyp->Write(); + + m_rewrite_freePosition = m_pFile->GetPosition(); + m_rewrite_free->Write(); + } + + m_pChildAtoms[GetLastMdatIndex()]->BeginWrite( m_pFile->Use64Bits( "mdat" )); +} + +void MP4RootAtom::Write() +{ + // no-op +} + +void MP4RootAtom::FinishWrite(bool use64) +{ + if( m_rewrite_ftyp ) { + const uint64_t savepos = m_pFile->GetPosition(); + m_pFile->SetPosition( m_rewrite_ftypPosition ); + m_rewrite_ftyp->Write(); + + const uint64_t newpos = m_pFile->GetPosition(); + if( newpos > m_rewrite_freePosition ) + m_rewrite_free->SetSize( m_rewrite_free->GetSize() - (newpos - m_rewrite_freePosition) ); // shrink + else if( newpos < m_rewrite_freePosition ) + m_rewrite_free->SetSize( m_rewrite_free->GetSize() + (m_rewrite_freePosition - newpos) ); // grow + + m_rewrite_free->Write(); + m_pFile->SetPosition( savepos ); + } + + // finish writing last mdat atom + const uint32_t mdatIndex = GetLastMdatIndex(); + m_pChildAtoms[mdatIndex]->FinishWrite( m_pFile->Use64Bits( "mdat" )); + + // write all atoms after last mdat + const uint32_t size = m_pChildAtoms.Size(); + for ( uint32_t i = mdatIndex + 1; i < size; i++ ) + m_pChildAtoms[i]->Write(); +} + +void MP4RootAtom::BeginOptimalWrite() +{ + WriteAtomType("ftyp", OnlyOne); + WriteAtomType("moov", OnlyOne); + WriteAtomType("udta", Many); + + m_pChildAtoms[GetLastMdatIndex()]->BeginWrite(m_pFile->Use64Bits("mdat")); +} + +void MP4RootAtom::FinishOptimalWrite() +{ + // finish writing mdat + m_pChildAtoms[GetLastMdatIndex()]->FinishWrite(m_pFile->Use64Bits("mdat")); + + // find moov atom + uint32_t size = m_pChildAtoms.Size(); + MP4Atom* pMoovAtom = NULL; + + uint32_t i; + for (i = 0; i < size; i++) { + if (!strcmp("moov", m_pChildAtoms[i]->GetType())) { + pMoovAtom = m_pChildAtoms[i]; + break; + } + } + ASSERT(i < size); + ASSERT(pMoovAtom != NULL); + + // rewrite moov so that updated chunkOffsets are written to disk + m_pFile->SetPosition(pMoovAtom->GetStart()); + uint64_t oldSize = pMoovAtom->GetSize(); + + pMoovAtom->Write(); + + // sanity check + uint64_t newSize = pMoovAtom->GetSize(); + ASSERT(oldSize == newSize); +} + +uint32_t MP4RootAtom::GetLastMdatIndex() +{ + for (int32_t i = m_pChildAtoms.Size() - 1; i >= 0; i--) { + if (!strcmp("mdat", m_pChildAtoms[i]->GetType())) { + return i; + } + } + ASSERT(false); + return (uint32_t)-1; +} + +void MP4RootAtom::WriteAtomType(const char* type, bool onlyOne) +{ + uint32_t size = m_pChildAtoms.Size(); + + for (uint32_t i = 0; i < size; i++) { + if (!strcmp(type, m_pChildAtoms[i]->GetType())) { + m_pChildAtoms[i]->Write(); + if (onlyOne) { + break; + } + } + } +} + +/////////////////////////////////////////////////////////////////////////////// + +}} // namespace mp4v2::impl diff --git a/src/atom_rtp.cpp b/src/atom_rtp.cpp new file mode 100644 index 0000000..5171c83 --- /dev/null +++ b/src/atom_rtp.cpp @@ -0,0 +1,157 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4RtpAtom::MP4RtpAtom() + : MP4Atom("rtp ") +{ + // The atom type "rtp " is used in two complete unrelated ways + // i.e. it's real two atoms with the same name + // To handle that we need to postpone property creation until + // we know who our parent atom is (stsd or hnti) which gives us + // the context info we need to know who we are +} + +void MP4RtpAtom::AddPropertiesStsdType() +{ + AddReserved("reserved1", 6); /* 0 */ + + AddProperty( /* 1 */ + new MP4Integer16Property("dataReferenceIndex")); + + AddProperty( /* 2 */ + new MP4Integer16Property("hintTrackVersion")); + AddProperty( /* 3 */ + new MP4Integer16Property("highestCompatibleVersion")); + AddProperty( /* 4 */ + new MP4Integer32Property("maxPacketSize")); + + ExpectChildAtom("tims", Required, OnlyOne); + ExpectChildAtom("tsro", Optional, OnlyOne); + ExpectChildAtom("snro", Optional, OnlyOne); +} + +void MP4RtpAtom::AddPropertiesHntiType() +{ + MP4StringProperty* pProp = + new MP4StringProperty("descriptionFormat"); + pProp->SetFixedLength(4); + AddProperty(pProp); /* 0 */ + + AddProperty( /* 1 */ + new MP4StringProperty("sdpText")); +} + +void MP4RtpAtom::Generate() +{ + if (!strcmp(m_pParentAtom->GetType(), "stsd")) { + AddPropertiesStsdType(); + GenerateStsdType(); + } else if (!strcmp(m_pParentAtom->GetType(), "hnti")) { + AddPropertiesHntiType(); + GenerateHntiType(); + } else { + VERBOSE_WARNING(m_pFile->GetVerbosity(), + printf("Warning: rtp atom in unexpected context, can not generate")); + } +} + +void MP4RtpAtom::GenerateStsdType() +{ + // generate children + MP4Atom::Generate(); + + ((MP4Integer16Property*)m_pProperties[1])->SetValue(1); + ((MP4Integer16Property*)m_pProperties[2])->SetValue(1); + ((MP4Integer16Property*)m_pProperties[3])->SetValue(1); +} + +void MP4RtpAtom::GenerateHntiType() +{ + MP4Atom::Generate(); + + ((MP4StringProperty*)m_pProperties[0])->SetValue("sdp "); +} + +void MP4RtpAtom::Read() +{ + if (!strcmp(m_pParentAtom->GetType(), "stsd")) { + AddPropertiesStsdType(); + ReadStsdType(); + } else if (!strcmp(m_pParentAtom->GetType(), "hnti")) { + AddPropertiesHntiType(); + ReadHntiType(); + } else { + VERBOSE_READ(m_pFile->GetVerbosity(), + printf("rtp atom in unexpected context, can not read")); + } + + Skip(); // to end of atom +} + +void MP4RtpAtom::ReadStsdType() +{ + MP4Atom::Read(); +} + +void MP4RtpAtom::ReadHntiType() +{ + ReadProperties(0, 1); + + // read sdp string, length is implicit in size of atom + uint64_t size = GetEnd() - m_pFile->GetPosition(); + char* data = (char*)MP4Malloc(size + 1); + ASSERT(data != NULL); + m_pFile->ReadBytes((uint8_t*)data, size); + data[size] = '\0'; + ((MP4StringProperty*)m_pProperties[1])->SetValue(data); + MP4Free(data); +} + +void MP4RtpAtom::Write() +{ + if (!strcmp(m_pParentAtom->GetType(), "hnti")) { + WriteHntiType(); + } else { + MP4Atom::Write(); + } +} + +void MP4RtpAtom::WriteHntiType() +{ + // since length of string is implicit in size of atom + // we need to handle this specially, and not write the terminating \0 + MP4StringProperty* pSdp = (MP4StringProperty*)m_pProperties[1]; + pSdp->SetFixedLength(strlen(pSdp->GetValue())); + MP4Atom::Write(); + pSdp->SetFixedLength(0); +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/atom_s263.cpp b/src/atom_s263.cpp new file mode 100644 index 0000000..220d282 --- /dev/null +++ b/src/atom_s263.cpp @@ -0,0 +1,88 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * 3GPP features implementation is based on 3GPP's TS26.234-v5.60, + * and was contributed by Ximpo Group Ltd. + * + * Portions created by Ximpo Group Ltd. are + * Copyright (C) Ximpo Group Ltd. 2003, 2004. All Rights Reserved. + * + * Contributor(s): + * Ximpo Group Ltd. mp4v2@ximpo.com + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4S263Atom::MP4S263Atom() + : MP4Atom("s263") +{ + AddReserved("reserved1", 6); /* 0 */ + + AddProperty( /* 1 */ + new MP4Integer16Property("dataReferenceIndex")); + + AddReserved("reserved2", 16); /* 2 */ + + AddProperty( /* 3 */ + new MP4Integer16Property("width")); + + AddProperty( /* 4 */ + new MP4Integer16Property("height")); + + AddReserved("reserved3", 50); /* 5 */ + + + ExpectChildAtom("d263", Required, OnlyOne); +} + +void MP4S263Atom::Generate() +{ + MP4Atom::Generate(); + + ((MP4Integer16Property*)m_pProperties[1])->SetValue(1); + + // property reserved2 has non-zero fixed values + static uint8_t reserved3[50] = { + 0x00, 0x48, 0x00, 0x00, + 0x00, 0x48, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x24, + 0xFF, 0xFF + }; + m_pProperties[5]->SetReadOnly(false); + ((MP4BytesProperty*)m_pProperties[5])-> + SetValue(reserved3, sizeof(reserved3)); + m_pProperties[5]->SetReadOnly(true); +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/atom_sdp.cpp b/src/atom_sdp.cpp new file mode 100644 index 0000000..05eb1a8 --- /dev/null +++ b/src/atom_sdp.cpp @@ -0,0 +1,63 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4SdpAtom::MP4SdpAtom() : MP4Atom("sdp ") +{ + AddProperty( + new MP4StringProperty("sdpText")); +} + +void MP4SdpAtom::Read() +{ + // read sdp string, length is implicit in size of atom + uint64_t size = GetEnd() - m_pFile->GetPosition(); + char* data = (char*)MP4Malloc(size + 1); + ASSERT(data != NULL); + m_pFile->ReadBytes((uint8_t*)data, size); + data[size] = '\0'; + ((MP4StringProperty*)m_pProperties[0])->SetValue(data); + MP4Free(data); +} + +void MP4SdpAtom::Write() +{ + // since length of string is implicit in size of atom + // we need to handle this specially, and not write the terminating \0 + MP4StringProperty* pSdp = (MP4StringProperty*)m_pProperties[0]; + const char* sdpText = pSdp->GetValue(); + if (sdpText) { + pSdp->SetFixedLength(strlen(sdpText)); + } + MP4Atom::Write(); + pSdp->SetFixedLength(0); +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/atom_sdtp.cpp b/src/atom_sdtp.cpp new file mode 100644 index 0000000..0f42f2d --- /dev/null +++ b/src/atom_sdtp.cpp @@ -0,0 +1,47 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is MP4v2. +// +// The Initial Developer of the Original Code is Kona Blend. +// Portions created by Kona Blend are Copyright (C) 2008. +// All Rights Reserved. +// +// Contributors: +// Kona Blend, kona8lend@@gmail.com +// +/////////////////////////////////////////////////////////////////////////////// + +#include "src/impl.h" + +namespace mp4v2 { namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4SdtpAtom::MP4SdtpAtom() + : MP4FullAtom ( "sdtp" ) + , data ( *new MP4BytesProperty( "data" )) +{ + AddProperty( &data ); +} + +/////////////////////////////////////////////////////////////////////////////// + +void MP4SdtpAtom::Read() +{ + data.SetValueSize( m_size - 4 ); + MP4FullAtom::Read(); +} + +/////////////////////////////////////////////////////////////////////////////// + +}} // namespace mp4v2::impl diff --git a/src/atom_smi.cpp b/src/atom_smi.cpp new file mode 100644 index 0000000..dfbe91c --- /dev/null +++ b/src/atom_smi.cpp @@ -0,0 +1,50 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2004. All Rights Reserved. + * + * Contributor(s): + * Bill May wmay@cisco.com + * + * Apple iTunes META data + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4SmiAtom::MP4SmiAtom() + : MP4Atom("meta") +{ + + AddProperty( new MP4BytesProperty("metadata")); + +} + +void MP4SmiAtom::Read() +{ + // calculate size of the metadata from the atom size + ((MP4BytesProperty*)m_pProperties[0])->SetValueSize(m_size); + + MP4Atom::Read(); +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/atom_sound.cpp b/src/atom_sound.cpp new file mode 100644 index 0000000..dc348c4 --- /dev/null +++ b/src/atom_sound.cpp @@ -0,0 +1,135 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2004. All Rights Reserved. + * + * Contributor(s): + * Bill May wmay@cisco.com + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4SoundAtom::MP4SoundAtom(const char *atomid) + : MP4Atom(atomid) +{ + AddReserved("reserved1", 6); /* 0 */ + + AddProperty( /* 1 */ + new MP4Integer16Property("dataReferenceIndex")); + AddProperty( /* 2 */ + new MP4Integer16Property("soundVersion")); + AddReserved( "reserved2", 6); /* 3 */ + + AddProperty( /* 4 */ + new MP4Integer16Property("channels")); + AddProperty( /* 5 */ + new MP4Integer16Property("sampleSize")); + AddProperty( /* 6 */ + new MP4Integer16Property("packetSize")); + AddProperty( /* 7 */ + new MP4Integer32Property("timeScale")); + + if (ATOMID(atomid) == ATOMID("mp4a")) { + AddReserved("reserved3", 2); /* 8 */ + ExpectChildAtom("esds", Required, OnlyOne); + ExpectChildAtom("wave", Optional, OnlyOne); + } else if (ATOMID(atomid) == ATOMID("alac")) { + AddReserved("reserved3", 2); /* 8 */ + ExpectChildAtom("alac", Optional, Optional); + //AddProperty( new MP4BytesProperty("alacInfo", 36)); + } +} + +void MP4SoundAtom::AddProperties (uint8_t version) +{ + if (version > 0) { + AddProperty( /* 8 */ + new MP4Integer32Property("samplesPerPacket")); + AddProperty( /* 9 */ + new MP4Integer32Property("bytesPerPacket")); + AddProperty( /* 10 */ + new MP4Integer32Property("bytesPerFrame")); + AddProperty( /* 11 */ + new MP4Integer32Property("bytesPerSample")); + } + if (version == 2) { + AddReserved("reserved4", 20); + } +} +void MP4SoundAtom::Generate() +{ + MP4Atom::Generate(); + + ((MP4Integer16Property*)m_pProperties[1])->SetValue(1); + + // property reserved2 has non-zero fixed values + ((MP4Integer16Property*)m_pProperties[2])->SetValue(0); + static const uint8_t reserved2[6] = { + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, + }; + m_pProperties[3]->SetReadOnly(false); + ((MP4BytesProperty*)m_pProperties[3])-> + SetValue(reserved2, sizeof(reserved2)); + m_pProperties[3]->SetReadOnly(true); + ((MP4Integer16Property*)m_pProperties[4])->SetValue(2); + ((MP4Integer16Property*)m_pProperties[5])->SetValue(0x0010); + ((MP4Integer16Property*)m_pProperties[6])->SetValue(0); + +} + +void MP4SoundAtom::Read() +{ + MP4Atom *parent = GetParentAtom(); + if (ATOMID(parent->GetType()) != ATOMID("stsd")) { + // Quicktime has an interesting thing - they'll put an mp4a atom + // which is blank inside a wave atom, which is inside an mp4a atom + // we have a mp4a inside an wave inside an mp4a - delete all properties + m_pProperties.Delete(8); + m_pProperties.Delete(7); + m_pProperties.Delete(6); + m_pProperties.Delete(5); + m_pProperties.Delete(4); + m_pProperties.Delete(3); + m_pProperties.Delete(2); + m_pProperties.Delete(1); + m_pProperties.Delete(0); + if (ATOMID(GetType()) == ATOMID("alac")) { + AddProperty(new MP4BytesProperty("decoderConfig", m_size)); + ReadProperties(); + } + if (m_pChildAtomInfos.Size() > 0) { + ReadChildAtoms(); + } + } else { + ReadProperties(0, 3); // read first 3 properties + AddProperties(((MP4IntegerProperty *)m_pProperties[2])->GetValue()); + ReadProperties(3); // continue + if (m_pChildAtomInfos.Size() > 0) { + ReadChildAtoms(); + } + } + Skip(); +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/atom_standard.cpp b/src/atom_standard.cpp new file mode 100644 index 0000000..8d2e101 --- /dev/null +++ b/src/atom_standard.cpp @@ -0,0 +1,406 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2004. All Rights Reserved. + * + * Contributor(s): + * Bill May (from others work). + */ + +#include "src/impl.h" + +namespace mp4v2 { namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4StandardAtom::MP4StandardAtom (const char *type) : MP4Atom(type) +{ + /* + * This is a big if else loop. Make sure that you don't break it + * when adding new atoms, or you will set the unknown type flag + * + * Try to keep it in alphabetical order - it should only be called + * 1 time per atom, so it's not that urgent. + */ + if (ATOMID(type) == ATOMID("bitr")) { + AddProperty( /* 0 */ + new MP4Integer32Property("avgBitrate")); + + AddProperty( /* 1 */ + new MP4Integer32Property("maxBitrate")); + + } else if (ATOMID(type) == ATOMID("btrt")) { + AddProperty( new MP4Integer32Property("bufferSizeDB")); /* 0 */ + AddProperty( new MP4Integer32Property("avgBitrate")); /* 1 */ + AddProperty( new MP4Integer32Property("maxBitrate")); /* 2 */ + } else if (ATOMID(type) == ATOMID("burl")) { + AddProperty( new MP4StringProperty("base_url")); + /* + * c??? + */ + } else if (ATOMID(type) == ATOMID("co64")) { + AddVersionAndFlags(); + + MP4Integer32Property* pCount = + new MP4Integer32Property("entryCount"); + AddProperty(pCount); + + MP4TableProperty* pTable = new MP4TableProperty("entries", pCount); + AddProperty(pTable); + + pTable->AddProperty( + new MP4Integer64Property("chunkOffset")); + } else if (ATOMID(type) == ATOMID("ctts")) { + AddVersionAndFlags(); + + MP4Integer32Property* pCount = + new MP4Integer32Property("entryCount"); + AddProperty(pCount); + + MP4TableProperty* pTable = new MP4TableProperty("entries", pCount); + AddProperty(pTable); + + pTable->AddProperty(new MP4Integer32Property("sampleCount")); + pTable->AddProperty(new MP4Integer32Property("sampleOffset")); + /* + * d??? + */ + } else if (ATOMID(type) == ATOMID("dinf")) { + ExpectChildAtom("dref", Required, OnlyOne); + + } else if (ATOMID(type) == ATOMID("dimm")) { + AddProperty( // bytes of immediate data + new MP4Integer64Property("bytes")); + + } else if (ATOMID(type) == ATOMID("dmax")) { + AddProperty( // max packet duration + new MP4Integer32Property("milliSecs")); + + } else if (ATOMID(type) == ATOMID("dmed")) { + AddProperty( // bytes sent from media data + new MP4Integer64Property("bytes")); + + } else if (ATOMID(type) == ATOMID("drep")) { + AddProperty( // bytes of repeated data + new MP4Integer64Property("bytes")); + /* + * e??? + */ + } else if (ATOMID(type) == ATOMID("edts")) { + ExpectChildAtom("elst", Required, OnlyOne); + + } else if (ATOMID(type) == ATOMID("esds")) { + AddVersionAndFlags(); + AddProperty( + new MP4DescriptorProperty(NULL, MP4ESDescrTag, 0, + Required, OnlyOne)); + /* + * f??? + */ + } else if (ATOMID(type) == ATOMID("frma")) { + AddProperty( /* 0 */ + new MP4Integer32Property("data-format")); + /* + * g??? + */ + } else if (ATOMID(type) == ATOMID("gmhd")) { + ExpectChildAtom("gmin", Required, OnlyOne); + ExpectChildAtom("tmcd", Optional, OnlyOne); + ExpectChildAtom("text", Optional, OnlyOne); + } else if (ATOMID(type) == ATOMID("hmhd")) { + AddVersionAndFlags(); + + AddProperty(new MP4Integer16Property("maxPduSize")); + AddProperty(new MP4Integer16Property("avgPduSize")); + AddProperty(new MP4Integer32Property("maxBitRate")); + AddProperty(new MP4Integer32Property("avgBitRate")); + AddProperty(new MP4Integer32Property("slidingAvgBitRate")); + /* + * i??? + */ + } else if (ATOMID(type) == ATOMID("iKMS")) { + AddVersionAndFlags(); /* 0, 1 */ + MP4StringProperty* pProp = new MP4StringProperty("kms_URI"); + AddProperty(pProp); /* 2 */ + + } else if (ATOMID(type) == ATOMID("iSFM")) { + AddVersionAndFlags(); /* 0, 1 */ + AddProperty( /* 2 */ + new MP4BitfieldProperty("selective-encryption", 1)); + AddProperty( /* 3 */ + new MP4BitfieldProperty("reserved", 7)); + AddProperty( /* 4 */ + new MP4Integer8Property("key-indicator-length")); + AddProperty( /* 5 */ + new MP4Integer8Property("IV-length")); + + } else if (ATOMID(type) == ATOMID("ilst")) { + ExpectChildAtom("\251nam", Optional, OnlyOne); /* name */ + ExpectChildAtom("\251ART", Optional, OnlyOne); /* artist */ + ExpectChildAtom("\251wrt", Optional, OnlyOne); /* writer */ + ExpectChildAtom("\251alb", Optional, OnlyOne); /* album */ + ExpectChildAtom("\251day", Optional, OnlyOne); /* date */ + ExpectChildAtom("\251too", Optional, OnlyOne); /* tool */ + ExpectChildAtom("\251cmt", Optional, OnlyOne); /* comment */ + ExpectChildAtom("\251gen", Optional, OnlyOne); /* custom genre */ + ExpectChildAtom("trkn", Optional, OnlyOne); /* tracknumber */ + ExpectChildAtom("disk", Optional, OnlyOne); /* disknumber */ + ExpectChildAtom("gnre", Optional, OnlyOne); /* genre (ID3v1 index + 1) */ + ExpectChildAtom("cpil", Optional, OnlyOne); /* compilation */ + ExpectChildAtom("tmpo", Optional, OnlyOne); /* BPM */ + ExpectChildAtom("covr", Optional, OnlyOne); /* cover art */ + ExpectChildAtom("aART", Optional, OnlyOne); /* album artist */ + ExpectChildAtom("----", Optional, Many); /* ---- free form */ + ExpectChildAtom("pgap", Optional, OnlyOne); /* part of gapless album */ + ExpectChildAtom("tvsh", Optional, OnlyOne); /* TV show */ + ExpectChildAtom("tvsn", Optional, OnlyOne); /* TV season */ + ExpectChildAtom("tven", Optional, OnlyOne); /* TV episode number */ + ExpectChildAtom("tvnn", Optional, OnlyOne); /* TV network name */ + ExpectChildAtom("tves", Optional, OnlyOne); /* TV epsidoe */ + ExpectChildAtom("desc", Optional, OnlyOne); /* description */ + ExpectChildAtom("ldes", Optional, OnlyOne); /* long description */ + ExpectChildAtom("soal", Optional, OnlyOne); /* sort album */ + ExpectChildAtom("soar", Optional, OnlyOne); /* sort artist */ + ExpectChildAtom("soaa", Optional, OnlyOne); /* sort album artist */ + ExpectChildAtom("sonm", Optional, OnlyOne); /* sort name */ + ExpectChildAtom("soco", Optional, OnlyOne); /* sort composer */ + ExpectChildAtom("sosn", Optional, OnlyOne); /* sort show */ + ExpectChildAtom("hdvd", Optional, OnlyOne); /* HD video */ + ExpectChildAtom("©enc", Optional, OnlyOne); /* Encoded by */ + ExpectChildAtom("pcst", Optional, OnlyOne); /* Podcast flag */ + ExpectChildAtom("keyw", Optional, OnlyOne); /* Keywords (for podcasts?) */ + ExpectChildAtom("catg", Optional, OnlyOne); /* Category (for podcasts?) */ + ExpectChildAtom("purl", Optional, OnlyOne); /* Podcast URL */ + ExpectChildAtom("egid", Optional, OnlyOne); /* Podcast episode global unique ID */ + + } else if (ATOMID(type) == ATOMID("imif")) { + AddVersionAndFlags(); + AddProperty(new MP4DescriptorProperty("ipmp_desc", MP4IPMPDescrTag, + MP4IPMPDescrTag, Required, Many)); + } else if (ATOMID(type) == ATOMID("iods")) { + AddVersionAndFlags(); + AddProperty( + new MP4DescriptorProperty(NULL, MP4FileIODescrTag, + MP4FileODescrTag, + Required, OnlyOne)); + /* + * m??? + */ + } else if (ATOMID(type) == ATOMID("maxr")) { + AddProperty(new MP4Integer32Property("granularity")); + AddProperty(new MP4Integer32Property("bytes")); + + } else if (ATOMID(type) == ATOMID("mdia")) { + ExpectChildAtom("mdhd", Required, OnlyOne); + ExpectChildAtom("hdlr", Required, OnlyOne); + ExpectChildAtom("minf", Required, OnlyOne); + + } else if (ATOMID(type) == ATOMID("meta")) { // iTunes + AddVersionAndFlags(); /* 0, 1 */ + ExpectChildAtom("hdlr", Required, OnlyOne); + ExpectChildAtom("ilst", Required, OnlyOne); + + } else if (ATOMID(type) == ATOMID("mfhd")) { + AddVersionAndFlags(); /* 0, 1 */ + AddProperty( /* 2 */ + new MP4Integer32Property("sequenceNumber")); + + } else if (ATOMID(type) == ATOMID("minf")) { + ExpectChildAtom("vmhd", Optional, OnlyOne); + ExpectChildAtom("smhd", Optional, OnlyOne); + ExpectChildAtom("hmhd", Optional, OnlyOne); + ExpectChildAtom("nmhd", Optional, OnlyOne); + ExpectChildAtom("gmhd", Optional, OnlyOne); + ExpectChildAtom("dinf", Required, OnlyOne); + ExpectChildAtom("stbl", Required, OnlyOne); + + } else if (ATOMID(type) == ATOMID("moof")) { + ExpectChildAtom("mfhd", Required, OnlyOne); + ExpectChildAtom("traf", Optional, Many); + + } else if (ATOMID(type) == ATOMID("moov")) { + ExpectChildAtom("mvhd", Required, OnlyOne); + ExpectChildAtom("iods", Optional, OnlyOne); + ExpectChildAtom("trak", Required, Many); + ExpectChildAtom("udta", Optional, Many); + ExpectChildAtom("mvex", Optional, OnlyOne); + + } else if (ATOMID(type) == ATOMID("mvex")) { + ExpectChildAtom("trex", Required, Many); + + /* + * n??? + */ + } else if (ATOMID(type) == ATOMID("nmhd")) { + AddVersionAndFlags(); + + } else if (ATOMID(type) == ATOMID("nump")) { + AddProperty( // packets sent + new MP4Integer64Property("packets")); + /* + * o??? + */ + } else if (ATOMID(type) == ATOMID("odkm")) { + AddVersionAndFlags(); + ExpectChildAtom("ohdr", Required, OnlyOne); + /* + * p??? + */ + } else if (ATOMID(type) == ATOMID("payt")) { + AddProperty(new MP4Integer32Property("payloadNumber")); + AddProperty(new MP4StringProperty("rtpMap", Counted)); + + } else if (ATOMID(type) == ATOMID("pinf")) { + ExpectChildAtom("frma", Required, OnlyOne); + } else if (ATOMID(type) == ATOMID("pmax")) { + AddProperty( // max packet size + new MP4Integer32Property("bytes")); + } else if (ATOMID(type) == ATOMID("schi")) { + // not sure if this is child atoms or table of boxes + // get clarification on spec 9.1.2.5 + ExpectChildAtom("odkm", Optional, OnlyOne); + ExpectChildAtom("iKMS", Optional, OnlyOne); + ExpectChildAtom("iSFM", Optional, OnlyOne); + + } else if (ATOMID(type) == ATOMID("schm")) { + AddVersionAndFlags(); /* 0, 1 */ + AddProperty( /* 2 */ + new MP4Integer32Property("scheme_type")); + AddProperty( /* 3 */ + new MP4Integer32Property("scheme_version")); + // browser URI if flags set, TODO + + } else if (ATOMID(type) == ATOMID("sinf")) { + ExpectChildAtom("frma", Required, OnlyOne); + ExpectChildAtom("imif", Optional, OnlyOne); + ExpectChildAtom("schm", Optional, OnlyOne); + ExpectChildAtom("schi", Optional, OnlyOne); + + } else if (ATOMID(type) == ATOMID("smhd")) { + AddVersionAndFlags(); + AddReserved("reserved", 4); + + } else if (ATOMID(type) == ATOMID("snro")) { + AddProperty(new MP4Integer32Property("offset")); + + } else if (ATOMID(type) == ATOMID("stco")) { + AddVersionAndFlags(); + + MP4Integer32Property* pCount = new MP4Integer32Property("entryCount"); + AddProperty(pCount); + + MP4TableProperty* pTable = new MP4TableProperty("entries", pCount); + AddProperty(pTable); + + pTable->AddProperty(new MP4Integer32Property("chunkOffset")); + + } else if (ATOMID(type) == ATOMID("stsh")) { + AddVersionAndFlags(); + + MP4Integer32Property* pCount = new MP4Integer32Property("entryCount"); + AddProperty(pCount); + + MP4TableProperty* pTable = new MP4TableProperty("entries", pCount); + AddProperty(pTable); + + pTable->AddProperty(new MP4Integer32Property("shadowedSampleNumber")); + pTable->AddProperty(new MP4Integer32Property("syncSampleNumber")); + + } else if (ATOMID(type) == ATOMID("stss")) { + AddVersionAndFlags(); + + MP4Integer32Property* pCount = new MP4Integer32Property("entryCount"); + AddProperty(pCount); + + MP4TableProperty* pTable = new MP4TableProperty("entries", pCount); + AddProperty(pTable); + + pTable->AddProperty(new MP4Integer32Property("sampleNumber")); + + } else if (ATOMID(type) == ATOMID("stts")) { + AddVersionAndFlags(); + MP4Integer32Property* pCount = new MP4Integer32Property("entryCount"); + AddProperty(pCount); + + MP4TableProperty* pTable = new MP4TableProperty("entries", pCount); + AddProperty(pTable); + + pTable->AddProperty(new MP4Integer32Property("sampleCount")); + pTable->AddProperty(new MP4Integer32Property("sampleDelta")); + } else if (ATOMID(type) == ATOMID("tims")) { + AddProperty( + new MP4Integer32Property("timeScale")); + + } else if (ATOMID(type) == ATOMID("tmin")) { + AddProperty( // min relative xmit time + new MP4Integer32Property("milliSecs")); + + } else if (ATOMID(type) == ATOMID("tmax")) { + AddProperty( // max relative xmit time + new MP4Integer32Property("milliSecs")); + + } else if (ATOMID(type) == ATOMID("traf")) { + ExpectChildAtom("tfhd", Required, OnlyOne); + ExpectChildAtom("trun", Optional, Many); + + } else if (ATOMID(type) == ATOMID("trak")) { + ExpectChildAtom("tkhd", Required, OnlyOne); + ExpectChildAtom("tref", Optional, OnlyOne); + ExpectChildAtom("edts", Optional, OnlyOne); + ExpectChildAtom("mdia", Required, OnlyOne); + ExpectChildAtom("udta", Optional, Many); + + } else if (ATOMID(type) == ATOMID("tref")) { + ExpectChildAtom("chap", Optional, OnlyOne); + ExpectChildAtom("dpnd", Optional, OnlyOne); + ExpectChildAtom("hint", Optional, OnlyOne); + ExpectChildAtom("ipir", Optional, OnlyOne); + ExpectChildAtom("mpod", Optional, OnlyOne); + ExpectChildAtom("sync", Optional, OnlyOne); + + } else if (ATOMID(type) == ATOMID("trex")) { + AddVersionAndFlags(); /* 0, 1 */ + AddProperty( /* 2 */ + new MP4Integer32Property("trackId")); + AddProperty( /* 3 */ + new MP4Integer32Property("defaultSampleDesriptionIndex")); + AddProperty( /* 4 */ + new MP4Integer32Property("defaultSampleDuration")); + AddProperty( /* 5 */ + new MP4Integer32Property("defaultSampleSize")); + AddProperty( /* 6 */ + new MP4Integer32Property("defaultSampleFlags")); + + } else if (ATOMID(type) == ATOMID("trpy") || + ATOMID(type) == ATOMID("tpyl")) { + AddProperty( // bytes sent including RTP headers + new MP4Integer64Property("bytes")); + + } else if (ATOMID(type) == ATOMID("tsro")) { + AddProperty( + new MP4Integer32Property("offset")); + } else if (ATOMID(type) == ATOMID("wave")) { + ExpectChildAtom("esds", Required, OnlyOne); + } else { + /* + * default - unknown type + */ + SetUnknownType(true); + } +} + +/////////////////////////////////////////////////////////////////////////////// + +}} // namespace mp4v2::impl diff --git a/src/atom_stbl.cpp b/src/atom_stbl.cpp new file mode 100644 index 0000000..27a53d8 --- /dev/null +++ b/src/atom_stbl.cpp @@ -0,0 +1,66 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + */ + +#include "src/impl.h" + +namespace mp4v2 { namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4StblAtom::MP4StblAtom() + : MP4Atom("stbl") +{ + ExpectChildAtom("stsd", Required, OnlyOne); + ExpectChildAtom("stts", Required, OnlyOne); + ExpectChildAtom("ctts", Optional, OnlyOne); + ExpectChildAtom("stsz", Required, OnlyOne); + ExpectChildAtom("stz2", Optional, OnlyOne); + ExpectChildAtom("stsc", Required, OnlyOne); + ExpectChildAtom("stco", Optional, OnlyOne); + ExpectChildAtom("co64", Optional, OnlyOne); + ExpectChildAtom("stss", Optional, OnlyOne); + ExpectChildAtom("stsh", Optional, OnlyOne); + ExpectChildAtom("stdp", Optional, OnlyOne); + ExpectChildAtom("sdtp", Optional, OnlyOne); +} + +void MP4StblAtom::Generate() +{ + // as usual + MP4Atom::Generate(); + + // but we also need one of the chunk offset atoms + MP4Atom* pChunkOffsetAtom; + if (m_pFile->Use64Bits(GetType())) { + pChunkOffsetAtom = CreateAtom(this, "co64"); + } else { + pChunkOffsetAtom = CreateAtom(this, "stco"); + } + + AddChildAtom(pChunkOffsetAtom); + + // and ask it to self generate + pChunkOffsetAtom->Generate(); +} + +/////////////////////////////////////////////////////////////////////////////// + +}} // namespace mp4v2::impl diff --git a/src/atom_stdp.cpp b/src/atom_stdp.cpp new file mode 100644 index 0000000..1243d47 --- /dev/null +++ b/src/atom_stdp.cpp @@ -0,0 +1,59 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4StdpAtom::MP4StdpAtom() + : MP4Atom("stdp") +{ + AddVersionAndFlags(); + + MP4Integer32Property* pCount = + new MP4Integer32Property("entryCount"); + pCount->SetImplicit(); + AddProperty(pCount); + + MP4TableProperty* pTable = new MP4TableProperty("entries", pCount); + AddProperty(pTable); + + pTable->AddProperty( + new MP4Integer16Property("priority")); +} + +void MP4StdpAtom::Read() +{ + // table entry count computed from atom size + ((MP4Integer32Property*)m_pProperties[2])->SetReadOnly(false); + ((MP4Integer32Property*)m_pProperties[2])->SetValue((m_size - 4) / 2); + ((MP4Integer32Property*)m_pProperties[2])->SetReadOnly(true); + + MP4Atom::Read(); +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/atom_stsc.cpp b/src/atom_stsc.cpp new file mode 100644 index 0000000..c0ca42d --- /dev/null +++ b/src/atom_stsc.cpp @@ -0,0 +1,88 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4StscAtom::MP4StscAtom() + : MP4Atom("stsc") +{ + AddVersionAndFlags(); + + MP4Integer32Property* pCount = + new MP4Integer32Property("entryCount"); + AddProperty(pCount); + + MP4TableProperty* pTable = new MP4TableProperty("entries", pCount); + AddProperty(pTable); + + pTable->AddProperty( + new MP4Integer32Property("firstChunk")); + pTable->AddProperty( + new MP4Integer32Property("samplesPerChunk")); + pTable->AddProperty( + new MP4Integer32Property("sampleDescriptionIndex")); + + // As an optimization we add an implicit property to this table, + // "firstSample" that corresponds to the first sample of the firstChunk + MP4Integer32Property* pSample = + new MP4Integer32Property("firstSample"); + pSample->SetImplicit(); + pTable->AddProperty(pSample); +} + +void MP4StscAtom::Read() +{ + // Read as usual + MP4Atom::Read(); + + // Compute the firstSample values for later use + uint32_t count = + ((MP4Integer32Property*)m_pProperties[2])->GetValue(); + + MP4Integer32Property* pFirstChunk = (MP4Integer32Property*) + ((MP4TableProperty*)m_pProperties[3])->GetProperty(0); + MP4Integer32Property* pSamplesPerChunk = (MP4Integer32Property*) + ((MP4TableProperty*)m_pProperties[3])->GetProperty(1); + MP4Integer32Property* pFirstSample = (MP4Integer32Property*) + ((MP4TableProperty*)m_pProperties[3])->GetProperty(3); + + MP4SampleId sampleId = 1; + + for (uint32_t i = 0; i < count; i++) { + pFirstSample->SetValue(sampleId, i); + + if (i < count - 1) { + sampleId += + (pFirstChunk->GetValue(i+1) - pFirstChunk->GetValue(i)) + * pSamplesPerChunk->GetValue(i); + } + } +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/atom_stsd.cpp b/src/atom_stsd.cpp new file mode 100644 index 0000000..113ed0e --- /dev/null +++ b/src/atom_stsd.cpp @@ -0,0 +1,85 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001 - 2004. All Rights Reserved. + * + * 3GPP features implementation is based on 3GPP's TS26.234-v5.60, + * and was contributed by Ximpo Group Ltd. + * + * Portions created by Ximpo Group Ltd. are + * Copyright (C) Ximpo Group Ltd. 2003, 2004. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + * Alix Marchandise-Franquet alix@cisco.com + * Ximpo Group Ltd. mp4v2@ximpo.com + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4StsdAtom::MP4StsdAtom() + : MP4Atom("stsd") +{ + AddVersionAndFlags(); + + MP4Integer32Property* pCount = + new MP4Integer32Property("entryCount"); + pCount->SetReadOnly(); + AddProperty(pCount); + + ExpectChildAtom("mp4a", Optional, Many); + ExpectChildAtom("enca", Optional, Many); + ExpectChildAtom("mp4s", Optional, Many); + ExpectChildAtom("mp4v", Optional, Many); + ExpectChildAtom("encv", Optional, Many); + ExpectChildAtom("rtp ", Optional, Many); + ExpectChildAtom("samr", Optional, Many); // For AMR-NB + ExpectChildAtom("sawb", Optional, Many); // For AMR-WB + ExpectChildAtom("s263", Optional, Many); // For H.263 + ExpectChildAtom("avc1", Optional, Many); + ExpectChildAtom("alac", Optional, Many); + ExpectChildAtom("text", Optional, Many); + ExpectChildAtom("ac-3", Optional, Many); +} + +void MP4StsdAtom::Read() +{ + /* do the usual read */ + MP4Atom::Read(); + + // check that number of children == entryCount + MP4Integer32Property* pCount = + (MP4Integer32Property*)m_pProperties[2]; + + if (m_pChildAtoms.Size() != pCount->GetValue()) { + VERBOSE_READ(GetVerbosity(), + printf("Warning: stsd inconsistency with number of entries")); + + /* fix it */ + pCount->SetReadOnly(false); + pCount->SetValue(m_pChildAtoms.Size()); + pCount->SetReadOnly(true); + } +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/atom_stsz.cpp b/src/atom_stsz.cpp new file mode 100644 index 0000000..a4e4a62 --- /dev/null +++ b/src/atom_stsz.cpp @@ -0,0 +1,79 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4StszAtom::MP4StszAtom() + : MP4Atom("stsz") +{ + AddVersionAndFlags(); /* 0, 1 */ + + AddProperty( /* 2 */ + new MP4Integer32Property("sampleSize")); + + MP4Integer32Property* pCount = + new MP4Integer32Property("sampleCount"); + AddProperty(pCount); /* 3 */ + + MP4TableProperty* pTable = new MP4TableProperty("entries", pCount); + AddProperty(pTable); /* 4 */ + + pTable->AddProperty( /* 4/0 */ + new MP4Integer32Property("entrySize")); +} + +void MP4StszAtom::Read() +{ + ReadProperties(0, 4); + + uint32_t sampleSize = + ((MP4Integer32Property*)m_pProperties[2])->GetValue(); + + // only attempt to read entries table if sampleSize is zero + // i.e sample size is not constant + m_pProperties[4]->SetImplicit(sampleSize != 0); + + ReadProperties(4); + + Skip(); // to end of atom +} + +void MP4StszAtom::Write() +{ + uint32_t sampleSize = + ((MP4Integer32Property*)m_pProperties[2])->GetValue(); + + // only attempt to write entries table if sampleSize is zero + // i.e sample size is not constant + m_pProperties[4]->SetImplicit(sampleSize != 0); + + MP4Atom::Write(); +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/atom_stz2.cpp b/src/atom_stz2.cpp new file mode 100644 index 0000000..bd4d041 --- /dev/null +++ b/src/atom_stz2.cpp @@ -0,0 +1,104 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +/* + * This is used for the 4 bit sample size below. We need the sampleCount + * to be correct for the number of samples, but the table size needs to + * be correct to read and write it. + */ + +class MP4HalfSizeTableProperty : public MP4TableProperty +{ +public: + MP4HalfSizeTableProperty(const char *name, MP4IntegerProperty *pCountProperty) : + MP4TableProperty(name, pCountProperty) {}; + + // The count is half the actual size + uint32_t GetCount() { + return (m_pCountProperty->GetValue() + 1)/ 2; + }; + void SetCount(uint32_t count) { + m_pCountProperty->SetValue(count * 2); + }; +}; + + +MP4Stz2Atom::MP4Stz2Atom() + : MP4Atom("stz2") +{ + AddVersionAndFlags(); /* 0, 1 */ + + AddReserved("reserved", 3); /* 2 */ + + AddProperty( /* 3 */ + new MP4Integer8Property("fieldSize")); + + MP4Integer32Property* pCount = + new MP4Integer32Property("sampleCount"); + AddProperty(pCount); /* 4 */ + +} + +void MP4Stz2Atom::Read() +{ + ReadProperties(0, 4); + + uint8_t fieldSize = + ((MP4Integer8Property *)m_pProperties[3])->GetValue(); + // uint32_t sampleCount = 0; + + MP4Integer32Property* pCount = + (MP4Integer32Property *)m_pProperties[4]; + + MP4TableProperty *pTable; + if (fieldSize != 4) { + pTable = new MP4TableProperty("entries", pCount); + } else { + // 4 bit field size uses a special table. + pTable = new MP4HalfSizeTableProperty("entries", pCount); + } + + AddProperty(pTable); + + if (fieldSize == 16) { + pTable->AddProperty( /* 5/0 */ + new MP4Integer16Property("entrySize")); + } else { + pTable->AddProperty( /* 5/0 */ + new MP4Integer8Property("entrySize")); + } + + ReadProperties(4); + + Skip(); // to end of atom +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/atom_text.cpp b/src/atom_text.cpp new file mode 100644 index 0000000..f890c4a --- /dev/null +++ b/src/atom_text.cpp @@ -0,0 +1,147 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * Contributer has declined to give copyright information, and gives + * it freely to the world. + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4TextAtom::MP4TextAtom() + : MP4Atom("text") +{ + // The atom type "text" is used in two complete unrelated ways + // i.e. it's real two atoms with the same name + // To handle that we need to postpone property creation until + // we know who our parent atom is (stsd or gmhd) which gives us + // the context info we need to know who we are +} + +void MP4TextAtom::AddPropertiesStsdType() +{ + + AddReserved("reserved1", 6); /* 0 */ + + AddProperty(new MP4Integer16Property("dataReferenceIndex"));/* 1 */ + + AddProperty(new MP4Integer32Property("displayFlags")); /* 2 */ + AddProperty(new MP4Integer32Property("textJustification")); /* 3 */ + + AddProperty(new MP4Integer16Property("bgColorRed")); /* 4 */ + AddProperty(new MP4Integer16Property("bgColorGreen")); /* 5 */ + AddProperty(new MP4Integer16Property("bgColorBlue")); /* 6 */ + + AddProperty(new MP4Integer16Property("defTextBoxTop")); /* 7 */ + AddProperty(new MP4Integer16Property("defTextBoxLeft")); /* 8 */ + AddProperty(new MP4Integer16Property("defTextBoxBottom")); /* 9 */ + AddProperty(new MP4Integer16Property("defTextBoxRight")); /* 10 */ + + AddReserved("reserved2", 8); /* 11 */ + + AddProperty(new MP4Integer16Property("fontNumber")); /* 12 */ + AddProperty(new MP4Integer16Property("fontFace")); /* 13 */ + + AddReserved("reserved3", 1); /* 14 */ + AddReserved("reserved4", 2); /* 15 */ + + AddProperty(new MP4Integer16Property("foreColorRed")); /* 16 */ + AddProperty(new MP4Integer16Property("foreColorGreen")); /* 17 */ + AddProperty(new MP4Integer16Property("foreColorBlue")); /* 18 */ + +} + +void MP4TextAtom::AddPropertiesGmhdType() +{ + + AddProperty(new MP4BytesProperty("textData", 36)); /* 0 */ + +} + + +void MP4TextAtom::Generate() +{ + + if (ATOMID(m_pParentAtom->GetType()) == ATOMID("stsd")) { + AddPropertiesStsdType(); + GenerateStsdType(); + } else if (ATOMID(m_pParentAtom->GetType()) == ATOMID("gmhd")) { + AddPropertiesGmhdType(); + GenerateGmhdType(); + } else { + VERBOSE_WARNING(m_pFile->GetVerbosity(), + printf("Warning: text atom in unexpected context, can not generate")); + } + +} + +void MP4TextAtom::GenerateStsdType() +{ + // generate children + MP4Atom::Generate(); + + ((MP4Integer16Property*)m_pProperties[1])->SetValue(1); + + ((MP4Integer32Property*)m_pProperties[2])->SetValue(1); + ((MP4Integer32Property*)m_pProperties[3])->SetValue(1); + +} + +void MP4TextAtom::GenerateGmhdType() +{ + MP4Atom::Generate(); + + // property 0 has non-zero fixed values + static uint8_t textData[36] = { + 0x00, 0x01, + 0x00, 0x00, + 0x00, 0x00, + 0x00, 0x00, + 0x00, 0x00, + 0x00, 0x00, + 0x00, 0x00, + 0x00, 0x00, + 0x00, 0x01, + 0x00, 0x00, + 0x00, 0x00, + 0x00, 0x00, + 0x00, 0x00, + 0x00, 0x00, + 0x00, 0x00, + 0x00, 0x00, + 0x40, 0x00, + 0x00, 0x00, + }; + ((MP4BytesProperty*)m_pProperties[0])->SetValue(textData, sizeof(textData)); + +} + +void MP4TextAtom::Read () +{ + if (ATOMID(m_pParentAtom->GetType()) == ATOMID("stsd")) { + AddPropertiesStsdType(); + } else if (ATOMID(m_pParentAtom->GetType()) == ATOMID("gmhd")) { + AddPropertiesGmhdType(); + } + + MP4Atom::Read(); +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/atom_tfhd.cpp b/src/atom_tfhd.cpp new file mode 100644 index 0000000..c5c1f83 --- /dev/null +++ b/src/atom_tfhd.cpp @@ -0,0 +1,79 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4TfhdAtom::MP4TfhdAtom() + : MP4Atom("tfhd") +{ + AddVersionAndFlags(); /* 0, 1 */ + AddProperty( /* 2 */ + new MP4Integer32Property("trackId")); +} + +void MP4TfhdAtom::AddProperties(uint32_t flags) +{ + if (flags & 0x01) { + // note this property is signed 64! + AddProperty( + new MP4Integer64Property("baseDataOffset")); + } + if (flags & 0x02) { + AddProperty( + new MP4Integer32Property("sampleDescriptionIndex")); + } + if (flags & 0x08) { + AddProperty( + new MP4Integer32Property("defaultSampleDuration")); + } + if (flags & 0x10) { + AddProperty( + new MP4Integer32Property("defaultSampleSize")); + } + if (flags & 0x20) { + AddProperty( + new MP4Integer32Property("defaultSampleFlags")); + } +} + +void MP4TfhdAtom::Read() +{ + /* read atom version, flags, and trackId */ + ReadProperties(0, 3); + + /* need to create the properties based on the atom flags */ + AddProperties(GetFlags()); + + /* now we can read the remaining properties */ + ReadProperties(3); + + Skip(); // to end of atom +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/atom_tkhd.cpp b/src/atom_tkhd.cpp new file mode 100644 index 0000000..2db3b77 --- /dev/null +++ b/src/atom_tkhd.cpp @@ -0,0 +1,145 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4TkhdAtom::MP4TkhdAtom() + : MP4Atom("tkhd") +{ + AddVersionAndFlags(); +} + +void MP4TkhdAtom::AddProperties(uint8_t version) +{ + if (version == 1) { + AddProperty( /* 2 */ + new MP4Integer64Property("creationTime")); + AddProperty( /* 3 */ + new MP4Integer64Property("modificationTime")); + } else { // version == 0 + AddProperty( /* 2 */ + new MP4Integer32Property("creationTime")); + AddProperty( /* 3 */ + new MP4Integer32Property("modificationTime")); + } + + AddProperty( /* 4 */ + new MP4Integer32Property("trackId")); + AddReserved("reserved1", 4); /* 5 */ + + if (version == 1) { + AddProperty( /* 6 */ + new MP4Integer64Property("duration")); + } else { + AddProperty( /* 6 */ + new MP4Integer32Property("duration")); + } + + AddReserved("reserved2", 8); /* 7 */ + + AddProperty( /* 8 */ + new MP4Integer16Property("layer")); + AddProperty( /* 9 */ + new MP4Integer16Property("alternate_group")); + + MP4Float32Property* pProp; + + pProp = new MP4Float32Property("volume"); + pProp->SetFixed16Format(); + AddProperty(pProp); /* 10 */ + + AddReserved("reserved3", 2); /* 11 */ + + AddProperty(new MP4BytesProperty("matrix", 36)); /* 12 */ + + pProp = new MP4Float32Property("width"); + pProp->SetFixed32Format(); + AddProperty(pProp); /* 13 */ + + pProp = new MP4Float32Property("height"); + pProp->SetFixed32Format(); + AddProperty(pProp); /* 14 */ +} + +void MP4TkhdAtom::Generate() +{ + uint8_t version = m_pFile->Use64Bits(GetType()) ? 1 : 0; + SetVersion(version); + AddProperties(version); + + MP4Atom::Generate(); + + // set creation and modification times + MP4Timestamp now = MP4GetAbsTimestamp(); + if (version == 1) { + ((MP4Integer64Property*)m_pProperties[2])->SetValue(now); + ((MP4Integer64Property*)m_pProperties[3])->SetValue(now); + } else { + ((MP4Integer32Property*)m_pProperties[2])->SetValue(now); + ((MP4Integer32Property*)m_pProperties[3])->SetValue(now); + } + + // property "matrix" has non-zero fixed values + // this default identity matrix indicates no transformation, i.e. + // 1, 0, 0 + // 0, 1, 0 + // 0, 0, 1 + // see http://developer.apple.com/documentation/QuickTime/QTFF/QTFFChap4/chapter_5_section_4.html + + static uint8_t matrix[36] = { + 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x40, 0x00, 0x00, 0x00, + }; + + ((MP4BytesProperty*)m_pProperties[12])-> + SetValue(matrix, sizeof(matrix)); +} + +void MP4TkhdAtom::Read() +{ + /* read atom version */ + ReadProperties(0, 1); + + /* need to create the properties based on the atom version */ + AddProperties(GetVersion()); + + /* now we can read the remaining properties */ + ReadProperties(1); + + Skip(); // to end of atom +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/atom_treftype.cpp b/src/atom_treftype.cpp new file mode 100644 index 0000000..6fb237d --- /dev/null +++ b/src/atom_treftype.cpp @@ -0,0 +1,57 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4TrefTypeAtom::MP4TrefTypeAtom(const char* type) + : MP4Atom(type) +{ + MP4Integer32Property* pCount = + new MP4Integer32Property("entryCount"); + pCount->SetImplicit(); + AddProperty(pCount); /* 0 */ + + MP4TableProperty* pTable = new MP4TableProperty("entries", pCount); + AddProperty(pTable); /* 1 */ + + pTable->AddProperty( /* 1, 0 */ + new MP4Integer32Property("trackId")); +} + +void MP4TrefTypeAtom::Read() +{ + // table entry count computed from atom size + ((MP4Integer32Property*)m_pProperties[0])->SetReadOnly(false); + ((MP4Integer32Property*)m_pProperties[0])->SetValue(m_size / 4); + ((MP4Integer32Property*)m_pProperties[0])->SetReadOnly(true); + + MP4Atom::Read(); +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/atom_trun.cpp b/src/atom_trun.cpp new file mode 100644 index 0000000..0534352 --- /dev/null +++ b/src/atom_trun.cpp @@ -0,0 +1,89 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4TrunAtom::MP4TrunAtom() + : MP4Atom("trun") +{ + AddVersionAndFlags(); /* 0, 1 */ + AddProperty( /* 2 */ + new MP4Integer32Property("sampleCount")); +} + +void MP4TrunAtom::AddProperties(uint32_t flags) +{ + if (flags & 0x01) { + // Note this is a signed 32 value + AddProperty( + new MP4Integer32Property("dataOffset")); + } + if (flags & 0x04) { + AddProperty( + new MP4Integer32Property("firstSampleFlags")); + } + + MP4TableProperty* pTable = + new MP4TableProperty("samples", + (MP4Integer32Property *)m_pProperties[2]); + AddProperty(pTable); + + if (flags & 0x100) { + pTable->AddProperty( + new MP4Integer32Property("sampleDuration")); + } + if (flags & 0x200) { + pTable->AddProperty( + new MP4Integer32Property("sampleSize")); + } + if (flags & 0x400) { + pTable->AddProperty( + new MP4Integer32Property("sampleFlags")); + } + if (flags & 0x800) { + pTable->AddProperty( + new MP4Integer32Property("sampleCompositionTimeOffset")); + } +} + +void MP4TrunAtom::Read() +{ + /* read atom version, flags, and sampleCount */ + ReadProperties(0, 3); + + /* need to create the properties based on the atom flags */ + AddProperties(GetFlags()); + + /* now we can read the remaining properties */ + ReadProperties(3); + + Skip(); // to end of atom +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/atom_tx3g.cpp b/src/atom_tx3g.cpp new file mode 100644 index 0000000..662c641 --- /dev/null +++ b/src/atom_tx3g.cpp @@ -0,0 +1,73 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4Tx3gAtom::MP4Tx3gAtom() + : MP4Atom("tx3g") +{ + AddReserved("reserved1", 4); /* 0 */ + AddReserved("reserved2", 2); /* 1 */ + + AddProperty(new MP4Integer16Property("dataReferenceIndex"));/* 2 */ + + AddProperty(new MP4Integer32Property("displayFlags")); /* 3 */ + AddProperty(new MP4Integer8Property("horizontalJustification")); /* 4 */ + AddProperty(new MP4Integer8Property("verticalJustification")); /* 5 */ + + AddProperty(new MP4Integer8Property("bgColorRed")); /* 6 */ + AddProperty(new MP4Integer8Property("bgColorGreen")); /* 7 */ + AddProperty(new MP4Integer8Property("bgColorBlue")); /* 8 */ + AddProperty(new MP4Integer8Property("bgColorAlpha")); /* 9 */ + + AddProperty(new MP4Integer16Property("defTextBoxTop")); /* 10 */ + AddProperty(new MP4Integer16Property("defTextBoxLeft")); /* 11 */ + AddProperty(new MP4Integer16Property("defTextBoxBottom")); /* 12 */ + AddProperty(new MP4Integer16Property("defTextBoxRight")); /* 13 */ + + AddProperty(new MP4Integer16Property("startChar")); /* 14 */ + AddProperty(new MP4Integer16Property("endChar")); /* 15 */ + AddProperty(new MP4Integer16Property("fontID")); /* 16 */ + AddProperty(new MP4Integer8Property("fontFace")); /* 17 */ + AddProperty(new MP4Integer8Property("fontSize")); /* 18 */ + + AddProperty(new MP4Integer8Property("fontColorRed")); /* 19 */ + AddProperty(new MP4Integer8Property("fontColorGreen")); /* 20 */ + AddProperty(new MP4Integer8Property("fontColorBlue")); /* 21 */ + AddProperty(new MP4Integer8Property("fontColorAlpha")); /* 22 */ + + ExpectChildAtom("ftab", Optional, Many); +} + +void MP4Tx3gAtom::Generate() +{ + // generate children + MP4Atom::Generate(); + + ((MP4Integer16Property*)m_pProperties[2])->SetValue(1); +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/atom_udta.cpp b/src/atom_udta.cpp new file mode 100644 index 0000000..6a894db --- /dev/null +++ b/src/atom_udta.cpp @@ -0,0 +1,56 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4UdtaAtom::MP4UdtaAtom() + : MP4Atom("udta") +{ + ExpectChildAtom("chpl", Optional, OnlyOne); + ExpectChildAtom("cprt", Optional, Many); + ExpectChildAtom("hnti", Optional, OnlyOne); + ExpectChildAtom("meta", Optional, OnlyOne); + ExpectChildAtom("\251cpy", Optional, OnlyOne); + ExpectChildAtom("\251des", Optional, OnlyOne); + ExpectChildAtom("\251nam", Optional, OnlyOne); + ExpectChildAtom("\251cmt", Optional, OnlyOne); + ExpectChildAtom("\251prd", Optional, OnlyOne); +} + +void MP4UdtaAtom::Read() +{ + if (ATOMID(m_pParentAtom->GetType()) == ATOMID("trak")) { + ExpectChildAtom("hinf", Optional, OnlyOne); + ExpectChildAtom("name", Optional, OnlyOne); + } + + MP4Atom::Read(); +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/atom_url.cpp b/src/atom_url.cpp new file mode 100644 index 0000000..943f0b1 --- /dev/null +++ b/src/atom_url.cpp @@ -0,0 +1,73 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4UrlAtom::MP4UrlAtom(const char *type) + : MP4Atom(type) +{ + AddVersionAndFlags(); + AddProperty(new MP4StringProperty("location")); +} + +void MP4UrlAtom::Read() +{ + // read the version and flags properties + ReadProperties(0, 2); + + // check if self-contained flag is set + if (!(GetFlags() & 1)) { + // if not then read url location + ReadProperties(2); + } + + Skip(); // to end of atom +} + +void MP4UrlAtom::Write() +{ + MP4StringProperty* pLocationProp = + (MP4StringProperty*)m_pProperties[2]; + + // if no url location has been set + // then set self-contained flag + // and don't attempt to write anything + if (pLocationProp->GetValue() == NULL) { + SetFlags(GetFlags() | 1); + pLocationProp->SetImplicit(true); + } else { + SetFlags(GetFlags() & 0xFFFFFE); + pLocationProp->SetImplicit(false); + } + + // write atom as usual + MP4Atom::Write(); +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/atom_urn.cpp b/src/atom_urn.cpp new file mode 100644 index 0000000..885d546 --- /dev/null +++ b/src/atom_urn.cpp @@ -0,0 +1,54 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4UrnAtom::MP4UrnAtom() + : MP4Atom("urn ") +{ + AddVersionAndFlags(); + AddProperty(new MP4StringProperty("name")); + AddProperty(new MP4StringProperty("location")); +} + +void MP4UrnAtom::Read() +{ + // read the version, flags, and name properties + ReadProperties(0, 3); + + // check if location is present + if (m_pFile->GetPosition() < GetEnd()) { + // read it + ReadProperties(3); + } + + Skip(); // to end of atom +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/atom_uuid.cpp b/src/atom_uuid.cpp new file mode 100644 index 0000000..36f32bc --- /dev/null +++ b/src/atom_uuid.cpp @@ -0,0 +1,50 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * Contributor(s): + * + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +IPodUUIDAtom::IPodUUIDAtom() + : MP4Atom("uuid") +{ + // + // This is a hack, the contents of this atom need to be well defined. + // + static uint8_t ipod_magic[] = { + 0x6b, 0x68, 0x40, 0xf2, 0x5f, 0x24, 0x4f, 0xc5, + 0xba, 0x39, 0xa5, 0x1b, 0xcf, 0x03, 0x23, 0xf3 + }; + + SetExtendedType(ipod_magic); + + MP4Integer32Property* value = new MP4Integer32Property("value"); + value->SetValue(1); + AddProperty(value); +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/atom_video.cpp b/src/atom_video.cpp new file mode 100644 index 0000000..e69476a --- /dev/null +++ b/src/atom_video.cpp @@ -0,0 +1,88 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2004. All Rights Reserved. + * + * Contributor(s): + * Bill May wmay@cisco.com + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4VideoAtom::MP4VideoAtom (const char *type) + : MP4Atom(type) +{ + AddReserved("reserved1", 6); /* 0 */ + + AddProperty( /* 1 */ + new MP4Integer16Property("dataReferenceIndex")); + + AddReserved("reserved2", 16); /* 2 */ + + AddProperty( /* 3 */ + new MP4Integer16Property("width")); + AddProperty( /* 4 */ + new MP4Integer16Property("height")); + + AddReserved("reserved3", 14); /* 5 */ + + MP4StringProperty* pProp = + new MP4StringProperty("compressorName"); + pProp->SetFixedLength(32); + pProp->SetCountedFormat(true); + pProp->SetValue(""); + AddProperty(pProp); /* 6 */ + + AddProperty(/* 7 */ + new MP4Integer16Property("depth")); + AddProperty(/* 8 */ + new MP4Integer16Property("colorTableId")); + ExpectChildAtom("smi ", Optional, OnlyOne); +} + +void MP4VideoAtom::Generate() +{ + MP4Atom::Generate(); + + ((MP4Integer16Property*)m_pProperties[1])->SetValue(1); + + // property reserved3 has non-zero fixed values + static uint8_t reserved3[14] = { + 0x00, 0x48, 0x00, 0x00, + 0x00, 0x48, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, + }; + m_pProperties[5]->SetReadOnly(false); + ((MP4BytesProperty*)m_pProperties[5])-> + SetValue(reserved3, sizeof(reserved3)); + m_pProperties[5]->SetReadOnly(true); + + // depth and color table id values - should be set later + // as far as depth - color table is most likely 0xff + ((MP4IntegerProperty *)m_pProperties[7])->SetValue(0x18); + ((MP4IntegerProperty *)m_pProperties[8])->SetValue(0xffff); + +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/atom_vmhd.cpp b/src/atom_vmhd.cpp new file mode 100644 index 0000000..000516f --- /dev/null +++ b/src/atom_vmhd.cpp @@ -0,0 +1,46 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4VmhdAtom::MP4VmhdAtom() + : MP4Atom("vmhd") +{ + AddVersionAndFlags(); + AddReserved("reserved", 8); +} + +void MP4VmhdAtom::Generate() +{ + MP4Atom::Generate(); + + SetFlags(1); +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/atoms.h b/src/atoms.h new file mode 100644 index 0000000..9bd88bd --- /dev/null +++ b/src/atoms.h @@ -0,0 +1,561 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001 - 2005. All Rights Reserved. + * + * 3GPP features implementation is based on 3GPP's TS26.234-v5.60, + * and was contributed by Ximpo Group Ltd. + * + * Portions created by Ximpo Group Ltd. are + * Copyright (C) Ximpo Group Ltd. 2003, 2004. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + * Ximpo Group Ltd. mp4v2@ximpo.com + * Bill May wmay@cisco.com + */ + +#ifndef MP4V2_IMPL_ATOMS_H +#define MP4V2_IMPL_ATOMS_H + +namespace mp4v2 { namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +class MP4FtypAtom; +class MP4FreeAtom; + +/// ISO base media full-atom. +class MP4FullAtom : public MP4Atom +{ +public: + MP4FullAtom( const char* type ); + + MP4Integer8Property& version; + MP4Integer24Property& flags; +}; + +// declare all the atom subclasses +// i.e. spare us atom_xxxx.h for all the atoms +// +// The majority of atoms just need their own constructor declared +// Some atoms have a few special needs +// A small minority of atoms need lots of special handling + +class MP4RootAtom : public MP4Atom +{ +public: + MP4RootAtom(); + void BeginWrite(bool use64 = false); + void Write(); + void FinishWrite(bool use64 = false); + + void BeginOptimalWrite(); + void FinishOptimalWrite(); + +protected: + uint32_t GetLastMdatIndex(); + void WriteAtomType(const char* type, bool onlyOne); + +private: + MP4FtypAtom* m_rewrite_ftyp; + uint64_t m_rewrite_ftypPosition; + MP4FreeAtom* m_rewrite_free; + uint64_t m_rewrite_freePosition; +}; + +/*********************************************************************** + * Common atom classes - standard for anything that just contains atoms + * and non-maleable properties, treftype and url + ***********************************************************************/ +class MP4StandardAtom : public MP4Atom { +public: + MP4StandardAtom(const char *name); +}; + +class MP4TrefTypeAtom : public MP4Atom { +public: + MP4TrefTypeAtom(const char* type); + void Read(); +}; + +class MP4UrlAtom : public MP4Atom { +public: + MP4UrlAtom(const char *type="url "); + void Read(); + void Write(); +}; + +/*********************************************************************** + * Sound and Video atoms - use the generic atoms when possible + * (MP4SoundAtom and MP4VideoAtom) + ***********************************************************************/ +class MP4SoundAtom : public MP4Atom { +public: + MP4SoundAtom(const char *atomid); + void Generate(); + void Read(); +protected: + void AddProperties(uint8_t version); +}; + +class MP4VideoAtom : public MP4Atom { +public: + MP4VideoAtom(const char *atomid); + void Generate(); +}; + +class MP4AmrAtom : public MP4Atom { +public: + MP4AmrAtom(const char *type); + void Generate(); +}; + +// H.264 atoms + +class MP4Avc1Atom : public MP4Atom { +public: + MP4Avc1Atom(); + void Generate(); +}; + +class MP4AvcCAtom : public MP4Atom { +public: + MP4AvcCAtom(); + void Generate(); + void Clone(MP4AvcCAtom *dstAtom); +}; + + +class MP4D263Atom : public MP4Atom { +public: + MP4D263Atom(); + void Generate(); + void Write(); +}; + +class MP4DamrAtom : public MP4Atom { +public: + MP4DamrAtom(); + void Generate(); +}; + +class MP4EncaAtom : public MP4Atom { +public: + MP4EncaAtom(); + void Generate(); +}; + +class MP4EncvAtom : public MP4Atom { +public: + MP4EncvAtom(); + void Generate(); +}; + +class MP4Mp4aAtom : public MP4Atom { +public: + MP4Mp4aAtom(); + void Generate(); +}; + +class MP4Ac3Atom : public MP4Atom { +public: + MP4Ac3Atom(); + void Generate(); +}; + +class MP4DAc3Atom : public MP4Atom { +public: + MP4DAc3Atom(); + void Generate(); + void Dump(FILE* pFile, uint8_t indent, bool dumpImplicits); +}; + +class MP4Mp4sAtom : public MP4Atom { +public: + MP4Mp4sAtom(); + void Generate(); +}; + +class MP4Mp4vAtom : public MP4Atom { +public: + MP4Mp4vAtom(); + void Generate(); +}; + + +class MP4S263Atom : public MP4Atom { +public: + MP4S263Atom(); + void Generate(); +}; + + + +/************************************************************************ + * Specialized Atoms + ************************************************************************/ + +class MP4DrefAtom : public MP4Atom { +public: + MP4DrefAtom(); + void Read(); +}; + +class MP4ElstAtom : public MP4Atom { +public: + MP4ElstAtom(); + void Generate(); + void Read(); +protected: + void AddProperties(uint8_t version); +}; + +class MP4FreeAtom : public MP4Atom { +public: + MP4FreeAtom( const char* = NULL ); + void Read(); + void Write(); +}; + +class MP4FtypAtom : public MP4Atom { +public: + MP4FtypAtom(); + void Generate(); + void Read(); + + MP4StringProperty& majorBrand; + MP4Integer32Property& minorVersion; + MP4StringProperty& compatibleBrands; +}; + +class MP4GminAtom : public MP4Atom { +public: + MP4GminAtom(); + void Generate(); +}; + +class MP4HdlrAtom : public MP4Atom { +public: + MP4HdlrAtom(); + void Read(); +}; + +class MP4HinfAtom : public MP4Atom { +public: + MP4HinfAtom(); + void Generate(); +}; + +class MP4HntiAtom : public MP4Atom { +public: + MP4HntiAtom(); + void Read(); +}; + + +class MP4MdatAtom : public MP4Atom { +public: + MP4MdatAtom(); + void Read(); + void Write(); +}; + +class MP4MdhdAtom : public MP4Atom { +public: + MP4MdhdAtom(); + void Generate(); + void Read(); +protected: + void AddProperties(uint8_t version); +}; + +class MP4MvhdAtom : public MP4Atom { +public: + MP4MvhdAtom(); + void Generate(); + void Read(); +protected: + void AddProperties(uint8_t version); +}; + +class MP4OhdrAtom : public MP4Atom { +public: + MP4OhdrAtom(); + ~MP4OhdrAtom(); + void Read(); +}; + +class MP4RtpAtom : public MP4Atom { +public: + MP4RtpAtom(); + void Generate(); + void Read(); + void Write(); + +protected: + void AddPropertiesStsdType(); + void AddPropertiesHntiType(); + + void GenerateStsdType(); + void GenerateHntiType(); + + void ReadStsdType(); + void ReadHntiType(); + + void WriteHntiType(); +}; + +class MP4SdpAtom : public MP4Atom { +public: + MP4SdpAtom(); + void Read(); + void Write(); +}; + +// sdtp - Independent and Disposable Samples Atom. +class MP4SdtpAtom : public MP4FullAtom { +public: + MP4SdtpAtom(); + void Read(); + + // raw bytes; one byte for each sample. + // number of bytes == stsz.sampleCount. + MP4BytesProperty& data; +}; + +class MP4SmiAtom : public MP4Atom { +public: + MP4SmiAtom(void); + void Read(); +}; + +class MP4StblAtom : public MP4Atom { +public: + MP4StblAtom(); + void Generate(); +}; + +class MP4StdpAtom : public MP4Atom { +public: + MP4StdpAtom(); + void Read(); +}; + +class MP4StscAtom : public MP4Atom { +public: + MP4StscAtom(); + void Read(); +}; + +class MP4StsdAtom : public MP4Atom { +public: + MP4StsdAtom(); + void Read(); +}; + +class MP4StszAtom : public MP4Atom { +public: + MP4StszAtom(); + void Read(); + void Write(); +}; + +class MP4Stz2Atom : public MP4Atom { +public: + MP4Stz2Atom(); + void Read(); +}; + +class MP4TextAtom : public MP4Atom { +public: + MP4TextAtom(); + void Generate(); + void Read(); +protected: + void AddPropertiesStsdType(); + void AddPropertiesGmhdType(); + + void GenerateStsdType(); + void GenerateGmhdType(); +}; + +class MP4Tx3gAtom : public MP4Atom { +public: + MP4Tx3gAtom(); + void Generate(); +}; + +class MP4FtabAtom : public MP4Atom { +public: + MP4FtabAtom(); +}; + +class MP4TfhdAtom : public MP4Atom { +public: + MP4TfhdAtom(); + void Read(); +protected: + void AddProperties(uint32_t flags); +}; + +class MP4TkhdAtom : public MP4Atom { +public: + MP4TkhdAtom(); + void Generate(); + void Read(); +protected: + void AddProperties(uint8_t version); +}; +class MP4TrunAtom : public MP4Atom { +public: + MP4TrunAtom(); + void Read(); +protected: + void AddProperties(uint32_t flags); +}; + +class MP4UdtaAtom : public MP4Atom { +public: + MP4UdtaAtom(); + void Read(); +}; + +class MP4UrnAtom : public MP4Atom { +public: + MP4UrnAtom(); + void Read(); +}; +class MP4VmhdAtom : public MP4Atom { +public: + MP4VmhdAtom(); + void Generate(); +}; + +class MP4HrefAtom : public MP4Atom { +public: + MP4HrefAtom(); + void Generate(void); +}; + +class MP4PaspAtom : public MP4Atom { +public: + MP4PaspAtom(); + void Generate(); +}; + +class MP4ColrAtom : public MP4Atom { +public: + MP4ColrAtom(); + void Generate(); +}; + +class IPodUUIDAtom : public MP4Atom { +public: + IPodUUIDAtom(); +}; + +class MP4NmhdAtom : public MP4Atom { +public: + MP4NmhdAtom(); +}; + +/*! Nero Chapter List. + * This atom defines the structure of a Nero chapter list. + * Although it is not completely clear if this structure is + * correct it is complete enough to successfully read and write + * the chapter list so that even Nero's software accepts it. + * + * The assumed format is as follows: + * - MP4Integer8Property("version") + * - MP4Integer24Property("flags") + * - MP4BytesProperty("reserved", 1) + * - MP4Integer32Property("chaptercount")\n + * - MP4TableProperty("chapters", "ref to chaptercount"); + * - MP4Integer64Property("starttime")\n + * The start time of the chapter expressed in 100 nanosecond units + * - MP4StringProperty("title", true)\n + * The title of the chapter encoded in UTF-8 + * + * The chapter title only accepts strings of 255 bytes so if a string + * only contains simple (two-byte) UTF-8 chars the maximum length is + * 127 chars. + */ +class MP4ChplAtom : public MP4Atom { +public: + MP4ChplAtom(); + void Generate(); +}; + +/////////////////////////////////////////////////////////////////////////////// + +/// iTMF item-atom. +class MP4ItemAtom : public MP4Atom +{ +public: + MP4ItemAtom( const char* type ); +}; + +/// iTMF meaning-atom. +class MP4MeanAtom : public MP4FullAtom +{ +public: + MP4MeanAtom(); + void Read(); + + MP4StringProperty& value; +}; + +/// iTMF name-atom. +class MP4NameAtom : public MP4FullAtom +{ +public: + MP4NameAtom(); + void Read(); + + MP4StringProperty& value; +}; + +/// iTMF data-atom. +class MP4DataAtom : public MP4Atom +{ +public: + MP4DataAtom(); + void Read(); + + MP4Integer16Property& typeReserved; + MP4Integer8Property& typeSetIdentifier; + MP4BasicTypeProperty& typeCode; + MP4Integer32Property& locale; + MP4BytesProperty& metadata; +}; + +/////////////////////////////////////////////////////////////////////////////// + +/// QTFF udta data element-atom. +class MP4UdtaElementAtom : public MP4Atom +{ +public: + MP4UdtaElementAtom( const char* type ); + void Read(); + + MP4BytesProperty& value; +}; + +/////////////////////////////////////////////////////////////////////////////// + +}} // namespace mp4v2::impl + +#endif // MP4V2_IMPL_ATOMS_H diff --git a/src/bmff/bmff.h b/src/bmff/bmff.h new file mode 100644 index 0000000..8fa3020 --- /dev/null +++ b/src/bmff/bmff.h @@ -0,0 +1,43 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is MP4v2. +// +// The Initial Developer of the Original Code is Kona Blend. +// Portions created by Kona Blend are Copyright (C) 2008. +// All Rights Reserved. +// +// Contributors: +// Kona Blend, kona8lend@@gmail.com +// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef MP4V2_IMPL_BMFF_BMFF_H +#define MP4V2_IMPL_BMFF_BMFF_H + +/// @namespace mp4v2::impl::bmff (private) ISO base media file format. +/// <b>WARNING: THIS IS A PRIVATE NAMESPACE. NOT FOR PUBLIC CONSUMPTION.</b> +/// +/// This namespace implements some features that are specified by +/// ISO base media file format, ISO/IEC 14496-12:2005(E). +/// +namespace mp4v2 { namespace impl { namespace bmff { + ; +}}} + +/////////////////////////////////////////////////////////////////////////////// + +//#include "type.h" + +/////////////////////////////////////////////////////////////////////////////// + +#endif // MP4V2_IMPL_BMFF_BMFF_H diff --git a/src/bmff/impl.h b/src/bmff/impl.h new file mode 100644 index 0000000..b247807 --- /dev/null +++ b/src/bmff/impl.h @@ -0,0 +1,34 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is MP4v2. +// +// The Initial Developer of the Original Code is Kona Blend. +// Portions created by Kona Blend are Copyright (C) 2008. +// All Rights Reserved. +// +// Contributors: +// Kona Blend, kona8lend@@gmail.com +// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef MP4V2_IMPL_BMFF_IMPL_H +#define MP4V2_IMPL_BMFF_IMPL_H + +/////////////////////////////////////////////////////////////////////////////// + +#include "src/impl.h" +#include "bmff.h" + +/////////////////////////////////////////////////////////////////////////////// + +#endif // MP4V2_IMPL_BMFF_IMPL_H diff --git a/src/bmff/typebmff.cpp b/src/bmff/typebmff.cpp new file mode 100644 index 0000000..c34f831 --- /dev/null +++ b/src/bmff/typebmff.cpp @@ -0,0 +1,540 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is MP4v2. +// +// The Initial Developer of the Original Code is Kona Blend. +// Portions created by Kona Blend are Copyright (C) 2008. +// All Rights Reserved. +// +// Contributors: +// Kona Blend, kona8lend@@gmail.com +// +/////////////////////////////////////////////////////////////////////////////// + +#include "impl.h" + +// VStudio idiocy prevents defining template instanced static data +// in a namespace. Workaround it by defining in global scope. +// Other platforms will continue to put things in the proper namespace. +#if defined( _MSC_VER ) +using namespace mp4v2::impl::bmff; +#else +namespace mp4v2 { namespace impl { namespace bmff { +#endif + +/////////////////////////////////////////////////////////////////////////////// + +template <> +const EnumLanguageCode::Entry EnumLanguageCode::data[] = { + { mp4v2::impl::bmff::ILC_AAR, "aar", "Afar" }, + { mp4v2::impl::bmff::ILC_ABK, "abk", "Abkhazian" }, + { mp4v2::impl::bmff::ILC_ACE, "ace", "Achinese" }, + { mp4v2::impl::bmff::ILC_ACH, "ach", "Acoli" }, + { mp4v2::impl::bmff::ILC_ADA, "ada", "Adangme" }, + { mp4v2::impl::bmff::ILC_ADY, "ady", "Adyghe; Adygei" }, + { mp4v2::impl::bmff::ILC_AFA, "afa", "Afro-Asiatic (Other)" }, + { mp4v2::impl::bmff::ILC_AFH, "afh", "Afrihili" }, + { mp4v2::impl::bmff::ILC_AFR, "afr", "Afrikaans" }, + { mp4v2::impl::bmff::ILC_AIN, "ain", "Ainu" }, + { mp4v2::impl::bmff::ILC_AKA, "aka", "Akan" }, + { mp4v2::impl::bmff::ILC_AKK, "akk", "Akkadian" }, + { mp4v2::impl::bmff::ILC_SQI, "sqi", "Albanian" }, + { mp4v2::impl::bmff::ILC_ALE, "ale", "Aleut" }, + { mp4v2::impl::bmff::ILC_ALG, "alg", "Algonquian languages" }, + { mp4v2::impl::bmff::ILC_ALT, "alt", "Southern Altai" }, + { mp4v2::impl::bmff::ILC_AMH, "amh", "Amharic" }, + { mp4v2::impl::bmff::ILC_ANG, "ang", "English, Old (ca.450-1100)" }, + { mp4v2::impl::bmff::ILC_ANP, "anp", "Angika" }, + { mp4v2::impl::bmff::ILC_APA, "apa", "Apache languages" }, + { mp4v2::impl::bmff::ILC_ARA, "ara", "Arabic" }, + { mp4v2::impl::bmff::ILC_ARC, "arc", "Official Aramaic (700-300 BCE); Imperial Aramaic (700-300 BCE)" }, + { mp4v2::impl::bmff::ILC_ARG, "arg", "Aragonese" }, + { mp4v2::impl::bmff::ILC_HYE, "hye", "Armenian" }, + { mp4v2::impl::bmff::ILC_ARN, "arn", "Mapudungun; Mapuche" }, + { mp4v2::impl::bmff::ILC_ARP, "arp", "Arapaho" }, + { mp4v2::impl::bmff::ILC_ART, "art", "Artificial (Other)" }, + { mp4v2::impl::bmff::ILC_ARW, "arw", "Arawak" }, + { mp4v2::impl::bmff::ILC_ASM, "asm", "Assamese" }, + { mp4v2::impl::bmff::ILC_AST, "ast", "Asturian; Bable; Leonese; Asturleonese" }, + { mp4v2::impl::bmff::ILC_ATH, "ath", "Athapascan languages" }, + { mp4v2::impl::bmff::ILC_AUS, "aus", "Australian languages" }, + { mp4v2::impl::bmff::ILC_AVA, "ava", "Avaric" }, + { mp4v2::impl::bmff::ILC_AVE, "ave", "Avestan" }, + { mp4v2::impl::bmff::ILC_AWA, "awa", "Awadhi" }, + { mp4v2::impl::bmff::ILC_AYM, "aym", "Aymara" }, + { mp4v2::impl::bmff::ILC_AZE, "aze", "Azerbaijani" }, + { mp4v2::impl::bmff::ILC_BAD, "bad", "Banda languages" }, + { mp4v2::impl::bmff::ILC_BAI, "bai", "Bamileke languages" }, + { mp4v2::impl::bmff::ILC_BAK, "bak", "Bashkir" }, + { mp4v2::impl::bmff::ILC_BAL, "bal", "Baluchi" }, + { mp4v2::impl::bmff::ILC_BAM, "bam", "Bambara" }, + { mp4v2::impl::bmff::ILC_BAN, "ban", "Balinese" }, + { mp4v2::impl::bmff::ILC_EUS, "eus", "Basque" }, + { mp4v2::impl::bmff::ILC_BAS, "bas", "Basa" }, + { mp4v2::impl::bmff::ILC_BAT, "bat", "Baltic (Other)" }, + { mp4v2::impl::bmff::ILC_BEJ, "bej", "Beja; Bedawiyet" }, + { mp4v2::impl::bmff::ILC_BEL, "bel", "Belarusian" }, + { mp4v2::impl::bmff::ILC_BEM, "bem", "Bemba" }, + { mp4v2::impl::bmff::ILC_BEN, "ben", "Bengali" }, + { mp4v2::impl::bmff::ILC_BER, "ber", "Berber (Other)" }, + { mp4v2::impl::bmff::ILC_BHO, "bho", "Bhojpuri" }, + { mp4v2::impl::bmff::ILC_BIH, "bih", "Bihari" }, + { mp4v2::impl::bmff::ILC_BIK, "bik", "Bikol" }, + { mp4v2::impl::bmff::ILC_BIN, "bin", "Bini; Edo" }, + { mp4v2::impl::bmff::ILC_BIS, "bis", "Bislama" }, + { mp4v2::impl::bmff::ILC_BLA, "bla", "Siksika" }, + { mp4v2::impl::bmff::ILC_BNT, "bnt", "Bantu (Other)" }, + { mp4v2::impl::bmff::ILC_BOS, "bos", "Bosnian" }, + { mp4v2::impl::bmff::ILC_BRA, "bra", "Braj" }, + { mp4v2::impl::bmff::ILC_BRE, "bre", "Breton" }, + { mp4v2::impl::bmff::ILC_BTK, "btk", "Batak languages" }, + { mp4v2::impl::bmff::ILC_BUA, "bua", "Buriat" }, + { mp4v2::impl::bmff::ILC_BUG, "bug", "Buginese" }, + { mp4v2::impl::bmff::ILC_BUL, "bul", "Bulgarian" }, + { mp4v2::impl::bmff::ILC_MYA, "mya", "Burmese" }, + { mp4v2::impl::bmff::ILC_BYN, "byn", "Blin; Bilin" }, + { mp4v2::impl::bmff::ILC_CAD, "cad", "Caddo" }, + { mp4v2::impl::bmff::ILC_CAI, "cai", "Central American Indian (Other)" }, + { mp4v2::impl::bmff::ILC_CAR, "car", "Galibi Carib" }, + { mp4v2::impl::bmff::ILC_CAT, "cat", "Catalan; Valencian" }, + { mp4v2::impl::bmff::ILC_CAU, "cau", "Caucasian (Other)" }, + { mp4v2::impl::bmff::ILC_CEB, "ceb", "Cebuano" }, + { mp4v2::impl::bmff::ILC_CEL, "cel", "Celtic (Other)" }, + { mp4v2::impl::bmff::ILC_CHA, "cha", "Chamorro" }, + { mp4v2::impl::bmff::ILC_CHB, "chb", "Chibcha" }, + { mp4v2::impl::bmff::ILC_CHE, "che", "Chechen" }, + { mp4v2::impl::bmff::ILC_CHG, "chg", "Chagatai" }, + { mp4v2::impl::bmff::ILC_ZHO, "zho", "Chinese" }, + { mp4v2::impl::bmff::ILC_CHK, "chk", "Chuukese" }, + { mp4v2::impl::bmff::ILC_CHM, "chm", "Mari" }, + { mp4v2::impl::bmff::ILC_CHN, "chn", "Chinook jargon" }, + { mp4v2::impl::bmff::ILC_CHO, "cho", "Choctaw" }, + { mp4v2::impl::bmff::ILC_CHP, "chp", "Chipewyan; Dene Suline" }, + { mp4v2::impl::bmff::ILC_CHR, "chr", "Cherokee" }, + { mp4v2::impl::bmff::ILC_CHU, "chu", "Church Slavic; Old Slavonic; Church Slavonic; Old Bulgarian; Old Church Slavonic" }, + { mp4v2::impl::bmff::ILC_CHV, "chv", "Chuvash" }, + { mp4v2::impl::bmff::ILC_CHY, "chy", "Cheyenne" }, + { mp4v2::impl::bmff::ILC_CMC, "cmc", "Chamic languages" }, + { mp4v2::impl::bmff::ILC_COP, "cop", "Coptic" }, + { mp4v2::impl::bmff::ILC_COR, "cor", "Cornish" }, + { mp4v2::impl::bmff::ILC_COS, "cos", "Corsican" }, + { mp4v2::impl::bmff::ILC_CPE, "cpe", "Creoles and pidgins, English based (Other)" }, + { mp4v2::impl::bmff::ILC_CPF, "cpf", "Creoles and pidgins, French-based (Other)" }, + { mp4v2::impl::bmff::ILC_CPP, "cpp", "Creoles and pidgins, Portuguese-based (Other)" }, + { mp4v2::impl::bmff::ILC_CRE, "cre", "Cree" }, + { mp4v2::impl::bmff::ILC_CRH, "crh", "Crimean Tatar; Crimean Turkish" }, + { mp4v2::impl::bmff::ILC_CRP, "crp", "Creoles and pidgins (Other)" }, + { mp4v2::impl::bmff::ILC_CSB, "csb", "Kashubian" }, + { mp4v2::impl::bmff::ILC_CUS, "cus", "Cushitic (Other)" }, + { mp4v2::impl::bmff::ILC_CES, "ces", "Czech" }, + { mp4v2::impl::bmff::ILC_DAK, "dak", "Dakota" }, + { mp4v2::impl::bmff::ILC_DAN, "dan", "Danish" }, + { mp4v2::impl::bmff::ILC_DAR, "dar", "Dargwa" }, + { mp4v2::impl::bmff::ILC_DAY, "day", "Land Dayak languages" }, + { mp4v2::impl::bmff::ILC_DEL, "del", "Delaware" }, + { mp4v2::impl::bmff::ILC_DEN, "den", "Slave (Athapascan)" }, + { mp4v2::impl::bmff::ILC_DGR, "dgr", "Dogrib" }, + { mp4v2::impl::bmff::ILC_DIN, "din", "Dinka" }, + { mp4v2::impl::bmff::ILC_DIV, "div", "Divehi; Dhivehi; Maldivian" }, + { mp4v2::impl::bmff::ILC_DOI, "doi", "Dogri" }, + { mp4v2::impl::bmff::ILC_DRA, "dra", "Dravidian (Other)" }, + { mp4v2::impl::bmff::ILC_DSB, "dsb", "Lower Sorbian" }, + { mp4v2::impl::bmff::ILC_DUA, "dua", "Duala" }, + { mp4v2::impl::bmff::ILC_DUM, "dum", "Dutch, Middle (ca.1050-1350)" }, + { mp4v2::impl::bmff::ILC_NLD, "nld", "Dutch; Flemish" }, + { mp4v2::impl::bmff::ILC_DYU, "dyu", "Dyula" }, + { mp4v2::impl::bmff::ILC_DZO, "dzo", "Dzongkha" }, + { mp4v2::impl::bmff::ILC_EFI, "efi", "Efik" }, + { mp4v2::impl::bmff::ILC_EGY, "egy", "Egyptian (Ancient)" }, + { mp4v2::impl::bmff::ILC_EKA, "eka", "Ekajuk" }, + { mp4v2::impl::bmff::ILC_ELX, "elx", "Elamite" }, + { mp4v2::impl::bmff::ILC_ENG, "eng", "English" }, + { mp4v2::impl::bmff::ILC_ENM, "enm", "English, Middle (1100-1500)" }, + { mp4v2::impl::bmff::ILC_EPO, "epo", "Esperanto" }, + { mp4v2::impl::bmff::ILC_EST, "est", "Estonian" }, + { mp4v2::impl::bmff::ILC_EWE, "ewe", "Ewe" }, + { mp4v2::impl::bmff::ILC_EWO, "ewo", "Ewondo" }, + { mp4v2::impl::bmff::ILC_FAN, "fan", "Fang" }, + { mp4v2::impl::bmff::ILC_FAO, "fao", "Faroese" }, + { mp4v2::impl::bmff::ILC_FAT, "fat", "Fanti" }, + { mp4v2::impl::bmff::ILC_FIJ, "fij", "Fijian" }, + { mp4v2::impl::bmff::ILC_FIL, "fil", "Filipino; Pilipino" }, + { mp4v2::impl::bmff::ILC_FIN, "fin", "Finnish" }, + { mp4v2::impl::bmff::ILC_FIU, "fiu", "Finno-Ugrian (Other)" }, + { mp4v2::impl::bmff::ILC_FON, "fon", "Fon" }, + { mp4v2::impl::bmff::ILC_FRA, "fra", "French" }, + { mp4v2::impl::bmff::ILC_FRM, "frm", "French, Middle (ca.1400-1600)" }, + { mp4v2::impl::bmff::ILC_FRO, "fro", "French, Old (842-ca.1400)" }, + { mp4v2::impl::bmff::ILC_FRR, "frr", "Northern Frisian" }, + { mp4v2::impl::bmff::ILC_FRS, "frs", "Eastern Frisian" }, + { mp4v2::impl::bmff::ILC_FRY, "fry", "Western Frisian" }, + { mp4v2::impl::bmff::ILC_FUL, "ful", "Fulah" }, + { mp4v2::impl::bmff::ILC_FUR, "fur", "Friulian" }, + { mp4v2::impl::bmff::ILC_GAA, "gaa", "Ga" }, + { mp4v2::impl::bmff::ILC_GAY, "gay", "Gayo" }, + { mp4v2::impl::bmff::ILC_GBA, "gba", "Gbaya" }, + { mp4v2::impl::bmff::ILC_GEM, "gem", "Germanic (Other)" }, + { mp4v2::impl::bmff::ILC_KAT, "kat", "Georgian" }, + { mp4v2::impl::bmff::ILC_DEU, "deu", "German" }, + { mp4v2::impl::bmff::ILC_GEZ, "gez", "Geez" }, + { mp4v2::impl::bmff::ILC_GIL, "gil", "Gilbertese" }, + { mp4v2::impl::bmff::ILC_GLA, "gla", "Gaelic; Scottish Gaelic" }, + { mp4v2::impl::bmff::ILC_GLE, "gle", "Irish" }, + { mp4v2::impl::bmff::ILC_GLG, "glg", "Galician" }, + { mp4v2::impl::bmff::ILC_GLV, "glv", "Manx" }, + { mp4v2::impl::bmff::ILC_GMH, "gmh", "German, Middle High (ca.1050-1500)" }, + { mp4v2::impl::bmff::ILC_GOH, "goh", "German, Old High (ca.750-1050)" }, + { mp4v2::impl::bmff::ILC_GON, "gon", "Gondi" }, + { mp4v2::impl::bmff::ILC_GOR, "gor", "Gorontalo" }, + { mp4v2::impl::bmff::ILC_GOT, "got", "Gothic" }, + { mp4v2::impl::bmff::ILC_GRB, "grb", "Grebo" }, + { mp4v2::impl::bmff::ILC_GRC, "grc", "Greek, Ancient (to 1453)" }, + { mp4v2::impl::bmff::ILC_ELL, "ell", "Greek, Modern (1453-)" }, + { mp4v2::impl::bmff::ILC_GRN, "grn", "Guarani" }, + { mp4v2::impl::bmff::ILC_GSW, "gsw", "Swiss German; Alemannic; Alsatian" }, + { mp4v2::impl::bmff::ILC_GUJ, "guj", "Gujarati" }, + { mp4v2::impl::bmff::ILC_GWI, "gwi", "Gwich'in" }, + { mp4v2::impl::bmff::ILC_HAI, "hai", "Haida" }, + { mp4v2::impl::bmff::ILC_HAT, "hat", "Haitian; Haitian Creole" }, + { mp4v2::impl::bmff::ILC_HAU, "hau", "Hausa" }, + { mp4v2::impl::bmff::ILC_HAW, "haw", "Hawaiian" }, + { mp4v2::impl::bmff::ILC_HEB, "heb", "Hebrew" }, + { mp4v2::impl::bmff::ILC_HER, "her", "Herero" }, + { mp4v2::impl::bmff::ILC_HIL, "hil", "Hiligaynon" }, + { mp4v2::impl::bmff::ILC_HIM, "him", "Himachali" }, + { mp4v2::impl::bmff::ILC_HIN, "hin", "Hindi" }, + { mp4v2::impl::bmff::ILC_HIT, "hit", "Hittite" }, + { mp4v2::impl::bmff::ILC_HMN, "hmn", "Hmong" }, + { mp4v2::impl::bmff::ILC_HMO, "hmo", "Hiri Motu" }, + { mp4v2::impl::bmff::ILC_HRV, "hrv", "Croatian" }, + { mp4v2::impl::bmff::ILC_HSB, "hsb", "Upper Sorbian" }, + { mp4v2::impl::bmff::ILC_HUN, "hun", "Hungarian" }, + { mp4v2::impl::bmff::ILC_HUP, "hup", "Hupa" }, + { mp4v2::impl::bmff::ILC_IBA, "iba", "Iban" }, + { mp4v2::impl::bmff::ILC_IBO, "ibo", "Igbo" }, + { mp4v2::impl::bmff::ILC_ISL, "isl", "Icelandic" }, + { mp4v2::impl::bmff::ILC_IDO, "ido", "Ido" }, + { mp4v2::impl::bmff::ILC_III, "iii", "Sichuan Yi; Nuosu" }, + { mp4v2::impl::bmff::ILC_IJO, "ijo", "Ijo languages" }, + { mp4v2::impl::bmff::ILC_IKU, "iku", "Inuktitut" }, + { mp4v2::impl::bmff::ILC_ILE, "ile", "Interlingue; Occidental" }, + { mp4v2::impl::bmff::ILC_ILO, "ilo", "Iloko" }, + { mp4v2::impl::bmff::ILC_INA, "ina", "Interlingua (International Auxiliary Language Association)" }, + { mp4v2::impl::bmff::ILC_INC, "inc", "Indic (Other)" }, + { mp4v2::impl::bmff::ILC_IND, "ind", "Indonesian" }, + { mp4v2::impl::bmff::ILC_INE, "ine", "Indo-European (Other)" }, + { mp4v2::impl::bmff::ILC_INH, "inh", "Ingush" }, + { mp4v2::impl::bmff::ILC_IPK, "ipk", "Inupiaq" }, + { mp4v2::impl::bmff::ILC_IRA, "ira", "Iranian (Other)" }, + { mp4v2::impl::bmff::ILC_IRO, "iro", "Iroquoian languages" }, + { mp4v2::impl::bmff::ILC_ITA, "ita", "Italian" }, + { mp4v2::impl::bmff::ILC_JAV, "jav", "Javanese" }, + { mp4v2::impl::bmff::ILC_JBO, "jbo", "Lojban" }, + { mp4v2::impl::bmff::ILC_JPN, "jpn", "Japanese" }, + { mp4v2::impl::bmff::ILC_JPR, "jpr", "Judeo-Persian" }, + { mp4v2::impl::bmff::ILC_JRB, "jrb", "Judeo-Arabic" }, + { mp4v2::impl::bmff::ILC_KAA, "kaa", "Kara-Kalpak" }, + { mp4v2::impl::bmff::ILC_KAB, "kab", "Kabyle" }, + { mp4v2::impl::bmff::ILC_KAC, "kac", "Kachin; Jingpho" }, + { mp4v2::impl::bmff::ILC_KAL, "kal", "Kalaallisut; Greenlandic" }, + { mp4v2::impl::bmff::ILC_KAM, "kam", "Kamba" }, + { mp4v2::impl::bmff::ILC_KAN, "kan", "Kannada" }, + { mp4v2::impl::bmff::ILC_KAR, "kar", "Karen languages" }, + { mp4v2::impl::bmff::ILC_KAS, "kas", "Kashmiri" }, + { mp4v2::impl::bmff::ILC_KAU, "kau", "Kanuri" }, + { mp4v2::impl::bmff::ILC_KAW, "kaw", "Kawi" }, + { mp4v2::impl::bmff::ILC_KAZ, "kaz", "Kazakh" }, + { mp4v2::impl::bmff::ILC_KBD, "kbd", "Kabardian" }, + { mp4v2::impl::bmff::ILC_KHA, "kha", "Khasi" }, + { mp4v2::impl::bmff::ILC_KHI, "khi", "Khoisan (Other)" }, + { mp4v2::impl::bmff::ILC_KHM, "khm", "Central Khmer" }, + { mp4v2::impl::bmff::ILC_KHO, "kho", "Khotanese; Sakan" }, + { mp4v2::impl::bmff::ILC_KIK, "kik", "Kikuyu; Gikuyu" }, + { mp4v2::impl::bmff::ILC_KIN, "kin", "Kinyarwanda" }, + { mp4v2::impl::bmff::ILC_KIR, "kir", "Kirghiz; Kyrgyz" }, + { mp4v2::impl::bmff::ILC_KMB, "kmb", "Kimbundu" }, + { mp4v2::impl::bmff::ILC_KOK, "kok", "Konkani" }, + { mp4v2::impl::bmff::ILC_KOM, "kom", "Komi" }, + { mp4v2::impl::bmff::ILC_KON, "kon", "Kongo" }, + { mp4v2::impl::bmff::ILC_KOR, "kor", "Korean" }, + { mp4v2::impl::bmff::ILC_KOS, "kos", "Kosraean" }, + { mp4v2::impl::bmff::ILC_KPE, "kpe", "Kpelle" }, + { mp4v2::impl::bmff::ILC_KRC, "krc", "Karachay-Balkar" }, + { mp4v2::impl::bmff::ILC_KRL, "krl", "Karelian" }, + { mp4v2::impl::bmff::ILC_KRO, "kro", "Kru languages" }, + { mp4v2::impl::bmff::ILC_KRU, "kru", "Kurukh" }, + { mp4v2::impl::bmff::ILC_KUA, "kua", "Kuanyama; Kwanyama" }, + { mp4v2::impl::bmff::ILC_KUM, "kum", "Kumyk" }, + { mp4v2::impl::bmff::ILC_KUR, "kur", "Kurdish" }, + { mp4v2::impl::bmff::ILC_KUT, "kut", "Kutenai" }, + { mp4v2::impl::bmff::ILC_LAD, "lad", "Ladino" }, + { mp4v2::impl::bmff::ILC_LAH, "lah", "Lahnda" }, + { mp4v2::impl::bmff::ILC_LAM, "lam", "Lamba" }, + { mp4v2::impl::bmff::ILC_LAO, "lao", "Lao" }, + { mp4v2::impl::bmff::ILC_LAT, "lat", "Latin" }, + { mp4v2::impl::bmff::ILC_LAV, "lav", "Latvian" }, + { mp4v2::impl::bmff::ILC_LEZ, "lez", "Lezghian" }, + { mp4v2::impl::bmff::ILC_LIM, "lim", "Limburgan; Limburger; Limburgish" }, + { mp4v2::impl::bmff::ILC_LIN, "lin", "Lingala" }, + { mp4v2::impl::bmff::ILC_LIT, "lit", "Lithuanian" }, + { mp4v2::impl::bmff::ILC_LOL, "lol", "Mongo" }, + { mp4v2::impl::bmff::ILC_LOZ, "loz", "Lozi" }, + { mp4v2::impl::bmff::ILC_LTZ, "ltz", "Luxembourgish; Letzeburgesch" }, + { mp4v2::impl::bmff::ILC_LUA, "lua", "Luba-Lulua" }, + { mp4v2::impl::bmff::ILC_LUB, "lub", "Luba-Katanga" }, + { mp4v2::impl::bmff::ILC_LUG, "lug", "Ganda" }, + { mp4v2::impl::bmff::ILC_LUI, "lui", "Luiseno" }, + { mp4v2::impl::bmff::ILC_LUN, "lun", "Lunda" }, + { mp4v2::impl::bmff::ILC_LUO, "luo", "Luo (Kenya and Tanzania)" }, + { mp4v2::impl::bmff::ILC_LUS, "lus", "Lushai" }, + { mp4v2::impl::bmff::ILC_MKD, "mkd", "Macedonian" }, + { mp4v2::impl::bmff::ILC_MAD, "mad", "Madurese" }, + { mp4v2::impl::bmff::ILC_MAG, "mag", "Magahi" }, + { mp4v2::impl::bmff::ILC_MAH, "mah", "Marshallese" }, + { mp4v2::impl::bmff::ILC_MAI, "mai", "Maithili" }, + { mp4v2::impl::bmff::ILC_MAK, "mak", "Makasar" }, + { mp4v2::impl::bmff::ILC_MAL, "mal", "Malayalam" }, + { mp4v2::impl::bmff::ILC_MAN, "man", "Mandingo" }, + { mp4v2::impl::bmff::ILC_MRI, "mri", "Maori" }, + { mp4v2::impl::bmff::ILC_MAP, "map", "Austronesian (Other)" }, + { mp4v2::impl::bmff::ILC_MAR, "mar", "Marathi" }, + { mp4v2::impl::bmff::ILC_MAS, "mas", "Masai" }, + { mp4v2::impl::bmff::ILC_MSA, "msa", "Malay" }, + { mp4v2::impl::bmff::ILC_MDF, "mdf", "Moksha" }, + { mp4v2::impl::bmff::ILC_MDR, "mdr", "Mandar" }, + { mp4v2::impl::bmff::ILC_MEN, "men", "Mende" }, + { mp4v2::impl::bmff::ILC_MGA, "mga", "Irish, Middle (900-1200)" }, + { mp4v2::impl::bmff::ILC_MIC, "mic", "Mi'kmaq; Micmac" }, + { mp4v2::impl::bmff::ILC_MIN, "min", "Minangkabau" }, + { mp4v2::impl::bmff::ILC_MIS, "mis", "Uncoded languages" }, + { mp4v2::impl::bmff::ILC_MKH, "mkh", "Mon-Khmer (Other)" }, + { mp4v2::impl::bmff::ILC_MLG, "mlg", "Malagasy" }, + { mp4v2::impl::bmff::ILC_MLT, "mlt", "Maltese" }, + { mp4v2::impl::bmff::ILC_MNC, "mnc", "Manchu" }, + { mp4v2::impl::bmff::ILC_MNI, "mni", "Manipuri" }, + { mp4v2::impl::bmff::ILC_MNO, "mno", "Manobo languages" }, + { mp4v2::impl::bmff::ILC_MOH, "moh", "Mohawk" }, + { mp4v2::impl::bmff::ILC_MON, "mon", "Mongolian" }, + { mp4v2::impl::bmff::ILC_MOS, "mos", "Mossi" }, + { mp4v2::impl::bmff::ILC_MUL, "mul", "Multiple languages" }, + { mp4v2::impl::bmff::ILC_MUN, "mun", "Munda languages" }, + { mp4v2::impl::bmff::ILC_MUS, "mus", "Creek" }, + { mp4v2::impl::bmff::ILC_MWL, "mwl", "Mirandese" }, + { mp4v2::impl::bmff::ILC_MWR, "mwr", "Marwari" }, + { mp4v2::impl::bmff::ILC_MYN, "myn", "Mayan languages" }, + { mp4v2::impl::bmff::ILC_MYV, "myv", "Erzya" }, + { mp4v2::impl::bmff::ILC_NAH, "nah", "Nahuatl languages" }, + { mp4v2::impl::bmff::ILC_NAI, "nai", "North American Indian" }, + { mp4v2::impl::bmff::ILC_NAP, "nap", "Neapolitan" }, + { mp4v2::impl::bmff::ILC_NAU, "nau", "Nauru" }, + { mp4v2::impl::bmff::ILC_NAV, "nav", "Navajo; Navaho" }, + { mp4v2::impl::bmff::ILC_NBL, "nbl", "Ndebele, South; South Ndebele" }, + { mp4v2::impl::bmff::ILC_NDE, "nde", "Ndebele, North; North Ndebele" }, + { mp4v2::impl::bmff::ILC_NDO, "ndo", "Ndonga" }, + { mp4v2::impl::bmff::ILC_NDS, "nds", "Low German; Low Saxon; German, Low; Saxon, Low" }, + { mp4v2::impl::bmff::ILC_NEP, "nep", "Nepali" }, + { mp4v2::impl::bmff::ILC_NEW, "new", "Nepal Bhasa; Newari" }, + { mp4v2::impl::bmff::ILC_NIA, "nia", "Nias" }, + { mp4v2::impl::bmff::ILC_NIC, "nic", "Niger-Kordofanian (Other)" }, + { mp4v2::impl::bmff::ILC_NIU, "niu", "Niuean" }, + { mp4v2::impl::bmff::ILC_NNO, "nno", "Norwegian Nynorsk; Nynorsk, Norwegian" }, + { mp4v2::impl::bmff::ILC_NOB, "nob", "BokmÃ¥l, Norwegian; Norwegian BokmÃ¥l" }, + { mp4v2::impl::bmff::ILC_NOG, "nog", "Nogai" }, + { mp4v2::impl::bmff::ILC_NON, "non", "Norse, Old" }, + { mp4v2::impl::bmff::ILC_NOR, "nor", "Norwegian" }, + { mp4v2::impl::bmff::ILC_NQO, "nqo", "N'Ko" }, + { mp4v2::impl::bmff::ILC_NSO, "nso", "Pedi; Sepedi; Northern Sotho" }, + { mp4v2::impl::bmff::ILC_NUB, "nub", "Nubian languages" }, + { mp4v2::impl::bmff::ILC_NWC, "nwc", "Classical Newari; Old Newari; Classical Nepal Bhasa" }, + { mp4v2::impl::bmff::ILC_NYA, "nya", "Chichewa; Chewa; Nyanja" }, + { mp4v2::impl::bmff::ILC_NYM, "nym", "Nyamwezi" }, + { mp4v2::impl::bmff::ILC_NYN, "nyn", "Nyankole" }, + { mp4v2::impl::bmff::ILC_NYO, "nyo", "Nyoro" }, + { mp4v2::impl::bmff::ILC_NZI, "nzi", "Nzima" }, + { mp4v2::impl::bmff::ILC_OCI, "oci", "Occitan (post 1500); Provençal" }, + { mp4v2::impl::bmff::ILC_OJI, "oji", "Ojibwa" }, + { mp4v2::impl::bmff::ILC_ORI, "ori", "Oriya" }, + { mp4v2::impl::bmff::ILC_ORM, "orm", "Oromo" }, + { mp4v2::impl::bmff::ILC_OSA, "osa", "Osage" }, + { mp4v2::impl::bmff::ILC_OSS, "oss", "Ossetian; Ossetic" }, + { mp4v2::impl::bmff::ILC_OTA, "ota", "Turkish, Ottoman (1500-1928)" }, + { mp4v2::impl::bmff::ILC_OTO, "oto", "Otomian languages" }, + { mp4v2::impl::bmff::ILC_PAA, "paa", "Papuan (Other)" }, + { mp4v2::impl::bmff::ILC_PAG, "pag", "Pangasinan" }, + { mp4v2::impl::bmff::ILC_PAL, "pal", "Pahlavi" }, + { mp4v2::impl::bmff::ILC_PAM, "pam", "Pampanga; Kapampangan" }, + { mp4v2::impl::bmff::ILC_PAN, "pan", "Panjabi; Punjabi" }, + { mp4v2::impl::bmff::ILC_PAP, "pap", "Papiamento" }, + { mp4v2::impl::bmff::ILC_PAU, "pau", "Palauan" }, + { mp4v2::impl::bmff::ILC_PEO, "peo", "Persian, Old (ca.600-400 B.C.)" }, + { mp4v2::impl::bmff::ILC_FAS, "fas", "Persian" }, + { mp4v2::impl::bmff::ILC_PHI, "phi", "Philippine (Other)" }, + { mp4v2::impl::bmff::ILC_PHN, "phn", "Phoenician" }, + { mp4v2::impl::bmff::ILC_PLI, "pli", "Pali" }, + { mp4v2::impl::bmff::ILC_POL, "pol", "Polish" }, + { mp4v2::impl::bmff::ILC_PON, "pon", "Pohnpeian" }, + { mp4v2::impl::bmff::ILC_POR, "por", "Portuguese" }, + { mp4v2::impl::bmff::ILC_PRA, "pra", "Prakrit languages" }, + { mp4v2::impl::bmff::ILC_PRO, "pro", "Provençal, Old (to 1500)" }, + { mp4v2::impl::bmff::ILC_PUS, "pus", "Pushto; Pashto" }, + { mp4v2::impl::bmff::ILC_QUE, "que", "Quechua" }, + { mp4v2::impl::bmff::ILC_RAJ, "raj", "Rajasthani" }, + { mp4v2::impl::bmff::ILC_RAP, "rap", "Rapanui" }, + { mp4v2::impl::bmff::ILC_RAR, "rar", "Rarotongan; Cook Islands Maori" }, + { mp4v2::impl::bmff::ILC_ROA, "roa", "Romance (Other)" }, + { mp4v2::impl::bmff::ILC_ROH, "roh", "Romansh" }, + { mp4v2::impl::bmff::ILC_ROM, "rom", "Romany" }, + { mp4v2::impl::bmff::ILC_RON, "ron", "Romanian; Moldavian; Moldovan" }, + { mp4v2::impl::bmff::ILC_RUN, "run", "Rundi" }, + { mp4v2::impl::bmff::ILC_RUP, "rup", "Aromanian; Arumanian; Macedo-Romanian" }, + { mp4v2::impl::bmff::ILC_RUS, "rus", "Russian" }, + { mp4v2::impl::bmff::ILC_SAD, "sad", "Sandawe" }, + { mp4v2::impl::bmff::ILC_SAG, "sag", "Sango" }, + { mp4v2::impl::bmff::ILC_SAH, "sah", "Yakut" }, + { mp4v2::impl::bmff::ILC_SAI, "sai", "South American Indian (Other)" }, + { mp4v2::impl::bmff::ILC_SAL, "sal", "Salishan languages" }, + { mp4v2::impl::bmff::ILC_SAM, "sam", "Samaritan Aramaic" }, + { mp4v2::impl::bmff::ILC_SAN, "san", "Sanskrit" }, + { mp4v2::impl::bmff::ILC_SAS, "sas", "Sasak" }, + { mp4v2::impl::bmff::ILC_SAT, "sat", "Santali" }, + { mp4v2::impl::bmff::ILC_SCN, "scn", "Sicilian" }, + { mp4v2::impl::bmff::ILC_SCO, "sco", "Scots" }, + { mp4v2::impl::bmff::ILC_SEL, "sel", "Selkup" }, + { mp4v2::impl::bmff::ILC_SEM, "sem", "Semitic (Other)" }, + { mp4v2::impl::bmff::ILC_SGA, "sga", "Irish, Old (to 900)" }, + { mp4v2::impl::bmff::ILC_SGN, "sgn", "Sign Languages" }, + { mp4v2::impl::bmff::ILC_SHN, "shn", "Shan" }, + { mp4v2::impl::bmff::ILC_SID, "sid", "Sidamo" }, + { mp4v2::impl::bmff::ILC_SIN, "sin", "Sinhala; Sinhalese" }, + { mp4v2::impl::bmff::ILC_SIO, "sio", "Siouan languages" }, + { mp4v2::impl::bmff::ILC_SIT, "sit", "Sino-Tibetan (Other)" }, + { mp4v2::impl::bmff::ILC_SLA, "sla", "Slavic (Other)" }, + { mp4v2::impl::bmff::ILC_SLK, "slk", "Slovak" }, + { mp4v2::impl::bmff::ILC_SLV, "slv", "Slovenian" }, + { mp4v2::impl::bmff::ILC_SMA, "sma", "Southern Sami" }, + { mp4v2::impl::bmff::ILC_SME, "sme", "Northern Sami" }, + { mp4v2::impl::bmff::ILC_SMI, "smi", "Sami languages (Other)" }, + { mp4v2::impl::bmff::ILC_SMJ, "smj", "Lule Sami" }, + { mp4v2::impl::bmff::ILC_SMN, "smn", "Inari Sami" }, + { mp4v2::impl::bmff::ILC_SMO, "smo", "Samoan" }, + { mp4v2::impl::bmff::ILC_SMS, "sms", "Skolt Sami" }, + { mp4v2::impl::bmff::ILC_SNA, "sna", "Shona" }, + { mp4v2::impl::bmff::ILC_SND, "snd", "Sindhi" }, + { mp4v2::impl::bmff::ILC_SNK, "snk", "Soninke" }, + { mp4v2::impl::bmff::ILC_SOG, "sog", "Sogdian" }, + { mp4v2::impl::bmff::ILC_SOM, "som", "Somali" }, + { mp4v2::impl::bmff::ILC_SON, "son", "Songhai languages" }, + { mp4v2::impl::bmff::ILC_SOT, "sot", "Sotho, Southern" }, + { mp4v2::impl::bmff::ILC_SPA, "spa", "Spanish; Castilian" }, + { mp4v2::impl::bmff::ILC_SRD, "srd", "Sardinian" }, + { mp4v2::impl::bmff::ILC_SRN, "srn", "Sranan Tongo" }, + { mp4v2::impl::bmff::ILC_SRP, "srp", "Serbian" }, + { mp4v2::impl::bmff::ILC_SRR, "srr", "Serer" }, + { mp4v2::impl::bmff::ILC_SSA, "ssa", "Nilo-Saharan (Other)" }, + { mp4v2::impl::bmff::ILC_SSW, "ssw", "Swati" }, + { mp4v2::impl::bmff::ILC_SUK, "suk", "Sukuma" }, + { mp4v2::impl::bmff::ILC_SUN, "sun", "Sundanese" }, + { mp4v2::impl::bmff::ILC_SUS, "sus", "Susu" }, + { mp4v2::impl::bmff::ILC_SUX, "sux", "Sumerian" }, + { mp4v2::impl::bmff::ILC_SWA, "swa", "Swahili" }, + { mp4v2::impl::bmff::ILC_SWE, "swe", "Swedish" }, + { mp4v2::impl::bmff::ILC_SYC, "syc", "Classical Syriac" }, + { mp4v2::impl::bmff::ILC_SYR, "syr", "Syriac" }, + { mp4v2::impl::bmff::ILC_TAH, "tah", "Tahitian" }, + { mp4v2::impl::bmff::ILC_TAI, "tai", "Tai (Other)" }, + { mp4v2::impl::bmff::ILC_TAM, "tam", "Tamil" }, + { mp4v2::impl::bmff::ILC_TAT, "tat", "Tatar" }, + { mp4v2::impl::bmff::ILC_TEL, "tel", "Telugu" }, + { mp4v2::impl::bmff::ILC_TEM, "tem", "Timne" }, + { mp4v2::impl::bmff::ILC_TER, "ter", "Tereno" }, + { mp4v2::impl::bmff::ILC_TET, "tet", "Tetum" }, + { mp4v2::impl::bmff::ILC_TGK, "tgk", "Tajik" }, + { mp4v2::impl::bmff::ILC_TGL, "tgl", "Tagalog" }, + { mp4v2::impl::bmff::ILC_THA, "tha", "Thai" }, + { mp4v2::impl::bmff::ILC_BOD, "bod", "Tibetan" }, + { mp4v2::impl::bmff::ILC_TIG, "tig", "Tigre" }, + { mp4v2::impl::bmff::ILC_TIR, "tir", "Tigrinya" }, + { mp4v2::impl::bmff::ILC_TIV, "tiv", "Tiv" }, + { mp4v2::impl::bmff::ILC_TKL, "tkl", "Tokelau" }, + { mp4v2::impl::bmff::ILC_TLH, "tlh", "Klingon; tlhIngan-Hol" }, + { mp4v2::impl::bmff::ILC_TLI, "tli", "Tlingit" }, + { mp4v2::impl::bmff::ILC_TMH, "tmh", "Tamashek" }, + { mp4v2::impl::bmff::ILC_TOG, "tog", "Tonga (Nyasa)" }, + { mp4v2::impl::bmff::ILC_TON, "ton", "Tonga (Tonga Islands)" }, + { mp4v2::impl::bmff::ILC_TPI, "tpi", "Tok Pisin" }, + { mp4v2::impl::bmff::ILC_TSI, "tsi", "Tsimshian" }, + { mp4v2::impl::bmff::ILC_TSN, "tsn", "Tswana" }, + { mp4v2::impl::bmff::ILC_TSO, "tso", "Tsonga" }, + { mp4v2::impl::bmff::ILC_TUK, "tuk", "Turkmen" }, + { mp4v2::impl::bmff::ILC_TUM, "tum", "Tumbuka" }, + { mp4v2::impl::bmff::ILC_TUP, "tup", "Tupi languages" }, + { mp4v2::impl::bmff::ILC_TUR, "tur", "Turkish" }, + { mp4v2::impl::bmff::ILC_TUT, "tut", "Altaic (Other)" }, + { mp4v2::impl::bmff::ILC_TVL, "tvl", "Tuvalu" }, + { mp4v2::impl::bmff::ILC_TWI, "twi", "Twi" }, + { mp4v2::impl::bmff::ILC_TYV, "tyv", "Tuvinian" }, + { mp4v2::impl::bmff::ILC_UDM, "udm", "Udmurt" }, + { mp4v2::impl::bmff::ILC_UGA, "uga", "Ugaritic" }, + { mp4v2::impl::bmff::ILC_UIG, "uig", "Uighur; Uyghur" }, + { mp4v2::impl::bmff::ILC_UKR, "ukr", "Ukrainian" }, + { mp4v2::impl::bmff::ILC_UMB, "umb", "Umbundu" }, + { mp4v2::impl::bmff::ILC_UND, "und", "Undetermined" }, + { mp4v2::impl::bmff::ILC_URD, "urd", "Urdu" }, + { mp4v2::impl::bmff::ILC_UZB, "uzb", "Uzbek" }, + { mp4v2::impl::bmff::ILC_VAI, "vai", "Vai" }, + { mp4v2::impl::bmff::ILC_VEN, "ven", "Venda" }, + { mp4v2::impl::bmff::ILC_VIE, "vie", "Vietnamese" }, + { mp4v2::impl::bmff::ILC_VOL, "vol", "Volapük" }, + { mp4v2::impl::bmff::ILC_VOT, "vot", "Votic" }, + { mp4v2::impl::bmff::ILC_WAK, "wak", "Wakashan languages" }, + { mp4v2::impl::bmff::ILC_WAL, "wal", "Walamo" }, + { mp4v2::impl::bmff::ILC_WAR, "war", "Waray" }, + { mp4v2::impl::bmff::ILC_WAS, "was", "Washo" }, + { mp4v2::impl::bmff::ILC_CYM, "cym", "Welsh" }, + { mp4v2::impl::bmff::ILC_WEN, "wen", "Sorbian languages" }, + { mp4v2::impl::bmff::ILC_WLN, "wln", "Walloon" }, + { mp4v2::impl::bmff::ILC_WOL, "wol", "Wolof" }, + { mp4v2::impl::bmff::ILC_XAL, "xal", "Kalmyk; Oirat" }, + { mp4v2::impl::bmff::ILC_XHO, "xho", "Xhosa" }, + { mp4v2::impl::bmff::ILC_YAO, "yao", "Yao" }, + { mp4v2::impl::bmff::ILC_YAP, "yap", "Yapese" }, + { mp4v2::impl::bmff::ILC_YID, "yid", "Yiddish" }, + { mp4v2::impl::bmff::ILC_YOR, "yor", "Yoruba" }, + { mp4v2::impl::bmff::ILC_YPK, "ypk", "Yupik languages" }, + { mp4v2::impl::bmff::ILC_ZAP, "zap", "Zapotec" }, + { mp4v2::impl::bmff::ILC_ZBL, "zbl", "Blissymbols; Blissymbolics; Bliss" }, + { mp4v2::impl::bmff::ILC_ZEN, "zen", "Zenaga" }, + { mp4v2::impl::bmff::ILC_ZHA, "zha", "Zhuang; Chuang" }, + { mp4v2::impl::bmff::ILC_ZND, "znd", "Zande languages" }, + { mp4v2::impl::bmff::ILC_ZUL, "zul", "Zulu" }, + { mp4v2::impl::bmff::ILC_ZUN, "zun", "Zuni" }, + { mp4v2::impl::bmff::ILC_ZXX, "zxx", "No linguistic content; Not applicable" }, + { mp4v2::impl::bmff::ILC_ZZA, "zza", "Zaza; Dimili; Dimli; Kirdki; Kirmanjki; Zazaki" }, + + { mp4v2::impl::bmff::ILC_UNDEFINED } // must be last +}; + +/////////////////////////////////////////////////////////////////////////////// + +#if defined( _MSC_VER ) +namespace mp4v2 { namespace impl { namespace bmff { +#endif + +/////////////////////////////////////////////////////////////////////////////// + +// must come after static data init +const EnumLanguageCode enumLanguageCode; + +/////////////////////////////////////////////////////////////////////////////// + +}}} // namespace mp4v2::impl::bmff diff --git a/src/bmff/typebmff.h b/src/bmff/typebmff.h new file mode 100644 index 0000000..4b69b7e --- /dev/null +++ b/src/bmff/typebmff.h @@ -0,0 +1,528 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is MP4v2. +// +// The Initial Developer of the Original Code is Kona Blend. +// Portions created by Kona Blend are Copyright (C) 2008. +// All Rights Reserved. +// +// Contributors: +// Kona Blend, kona8lend@@gmail.com +// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef MP4V2_IMPL_BMFF_TYPE_H +#define MP4V2_IMPL_BMFF_TYPE_H + +namespace mp4v2 { namespace impl { namespace bmff { + +/////////////////////////////////////////////////////////////////////////////// + +/// enumerated ISO-639-2/T language codes. +enum LanguageCode { + ILC_UNDEFINED = 0, + + ILC_AAR, + ILC_ABK, + ILC_ACE, + ILC_ACH, + ILC_ADA, + ILC_ADY, + ILC_AFA, + ILC_AFH, + ILC_AFR, + ILC_AIN, + ILC_AKA, + ILC_AKK, + ILC_SQI, + ILC_ALE, + ILC_ALG, + ILC_ALT, + ILC_AMH, + ILC_ANG, + ILC_ANP, + ILC_APA, + ILC_ARA, + ILC_ARC, + ILC_ARG, + ILC_HYE, + ILC_ARN, + ILC_ARP, + ILC_ART, + ILC_ARW, + ILC_ASM, + ILC_AST, + ILC_ATH, + ILC_AUS, + ILC_AVA, + ILC_AVE, + ILC_AWA, + ILC_AYM, + ILC_AZE, + ILC_BAD, + ILC_BAI, + ILC_BAK, + ILC_BAL, + ILC_BAM, + ILC_BAN, + ILC_EUS, + ILC_BAS, + ILC_BAT, + ILC_BEJ, + ILC_BEL, + ILC_BEM, + ILC_BEN, + ILC_BER, + ILC_BHO, + ILC_BIH, + ILC_BIK, + ILC_BIN, + ILC_BIS, + ILC_BLA, + ILC_BNT, + ILC_BOS, + ILC_BRA, + ILC_BRE, + ILC_BTK, + ILC_BUA, + ILC_BUG, + ILC_BUL, + ILC_MYA, + ILC_BYN, + ILC_CAD, + ILC_CAI, + ILC_CAR, + ILC_CAT, + ILC_CAU, + ILC_CEB, + ILC_CEL, + ILC_CHA, + ILC_CHB, + ILC_CHE, + ILC_CHG, + ILC_ZHO, + ILC_CHK, + ILC_CHM, + ILC_CHN, + ILC_CHO, + ILC_CHP, + ILC_CHR, + ILC_CHU, + ILC_CHV, + ILC_CHY, + ILC_CMC, + ILC_COP, + ILC_COR, + ILC_COS, + ILC_CPE, + ILC_CPF, + ILC_CPP, + ILC_CRE, + ILC_CRH, + ILC_CRP, + ILC_CSB, + ILC_CUS, + ILC_CES, + ILC_DAK, + ILC_DAN, + ILC_DAR, + ILC_DAY, + ILC_DEL, + ILC_DEN, + ILC_DGR, + ILC_DIN, + ILC_DIV, + ILC_DOI, + ILC_DRA, + ILC_DSB, + ILC_DUA, + ILC_DUM, + ILC_NLD, + ILC_DYU, + ILC_DZO, + ILC_EFI, + ILC_EGY, + ILC_EKA, + ILC_ELX, + ILC_ENG, + ILC_ENM, + ILC_EPO, + ILC_EST, + ILC_EWE, + ILC_EWO, + ILC_FAN, + ILC_FAO, + ILC_FAT, + ILC_FIJ, + ILC_FIL, + ILC_FIN, + ILC_FIU, + ILC_FON, + ILC_FRA, + ILC_FRM, + ILC_FRO, + ILC_FRR, + ILC_FRS, + ILC_FRY, + ILC_FUL, + ILC_FUR, + ILC_GAA, + ILC_GAY, + ILC_GBA, + ILC_GEM, + ILC_KAT, + ILC_DEU, + ILC_GEZ, + ILC_GIL, + ILC_GLA, + ILC_GLE, + ILC_GLG, + ILC_GLV, + ILC_GMH, + ILC_GOH, + ILC_GON, + ILC_GOR, + ILC_GOT, + ILC_GRB, + ILC_GRC, + ILC_ELL, + ILC_GRN, + ILC_GSW, + ILC_GUJ, + ILC_GWI, + ILC_HAI, + ILC_HAT, + ILC_HAU, + ILC_HAW, + ILC_HEB, + ILC_HER, + ILC_HIL, + ILC_HIM, + ILC_HIN, + ILC_HIT, + ILC_HMN, + ILC_HMO, + ILC_HRV, + ILC_HSB, + ILC_HUN, + ILC_HUP, + ILC_IBA, + ILC_IBO, + ILC_ISL, + ILC_IDO, + ILC_III, + ILC_IJO, + ILC_IKU, + ILC_ILE, + ILC_ILO, + ILC_INA, + ILC_INC, + ILC_IND, + ILC_INE, + ILC_INH, + ILC_IPK, + ILC_IRA, + ILC_IRO, + ILC_ITA, + ILC_JAV, + ILC_JBO, + ILC_JPN, + ILC_JPR, + ILC_JRB, + ILC_KAA, + ILC_KAB, + ILC_KAC, + ILC_KAL, + ILC_KAM, + ILC_KAN, + ILC_KAR, + ILC_KAS, + ILC_KAU, + ILC_KAW, + ILC_KAZ, + ILC_KBD, + ILC_KHA, + ILC_KHI, + ILC_KHM, + ILC_KHO, + ILC_KIK, + ILC_KIN, + ILC_KIR, + ILC_KMB, + ILC_KOK, + ILC_KOM, + ILC_KON, + ILC_KOR, + ILC_KOS, + ILC_KPE, + ILC_KRC, + ILC_KRL, + ILC_KRO, + ILC_KRU, + ILC_KUA, + ILC_KUM, + ILC_KUR, + ILC_KUT, + ILC_LAD, + ILC_LAH, + ILC_LAM, + ILC_LAO, + ILC_LAT, + ILC_LAV, + ILC_LEZ, + ILC_LIM, + ILC_LIN, + ILC_LIT, + ILC_LOL, + ILC_LOZ, + ILC_LTZ, + ILC_LUA, + ILC_LUB, + ILC_LUG, + ILC_LUI, + ILC_LUN, + ILC_LUO, + ILC_LUS, + ILC_MKD, + ILC_MAD, + ILC_MAG, + ILC_MAH, + ILC_MAI, + ILC_MAK, + ILC_MAL, + ILC_MAN, + ILC_MRI, + ILC_MAP, + ILC_MAR, + ILC_MAS, + ILC_MSA, + ILC_MDF, + ILC_MDR, + ILC_MEN, + ILC_MGA, + ILC_MIC, + ILC_MIN, + ILC_MIS, + ILC_MKH, + ILC_MLG, + ILC_MLT, + ILC_MNC, + ILC_MNI, + ILC_MNO, + ILC_MOH, + ILC_MON, + ILC_MOS, + ILC_MUL, + ILC_MUN, + ILC_MUS, + ILC_MWL, + ILC_MWR, + ILC_MYN, + ILC_MYV, + ILC_NAH, + ILC_NAI, + ILC_NAP, + ILC_NAU, + ILC_NAV, + ILC_NBL, + ILC_NDE, + ILC_NDO, + ILC_NDS, + ILC_NEP, + ILC_NEW, + ILC_NIA, + ILC_NIC, + ILC_NIU, + ILC_NNO, + ILC_NOB, + ILC_NOG, + ILC_NON, + ILC_NOR, + ILC_NQO, + ILC_NSO, + ILC_NUB, + ILC_NWC, + ILC_NYA, + ILC_NYM, + ILC_NYN, + ILC_NYO, + ILC_NZI, + ILC_OCI, + ILC_OJI, + ILC_ORI, + ILC_ORM, + ILC_OSA, + ILC_OSS, + ILC_OTA, + ILC_OTO, + ILC_PAA, + ILC_PAG, + ILC_PAL, + ILC_PAM, + ILC_PAN, + ILC_PAP, + ILC_PAU, + ILC_PEO, + ILC_FAS, + ILC_PHI, + ILC_PHN, + ILC_PLI, + ILC_POL, + ILC_PON, + ILC_POR, + ILC_PRA, + ILC_PRO, + ILC_PUS, + ILC_QUE, + ILC_RAJ, + ILC_RAP, + ILC_RAR, + ILC_ROA, + ILC_ROH, + ILC_ROM, + ILC_RON, + ILC_RUN, + ILC_RUP, + ILC_RUS, + ILC_SAD, + ILC_SAG, + ILC_SAH, + ILC_SAI, + ILC_SAL, + ILC_SAM, + ILC_SAN, + ILC_SAS, + ILC_SAT, + ILC_SCN, + ILC_SCO, + ILC_SEL, + ILC_SEM, + ILC_SGA, + ILC_SGN, + ILC_SHN, + ILC_SID, + ILC_SIN, + ILC_SIO, + ILC_SIT, + ILC_SLA, + ILC_SLK, + ILC_SLV, + ILC_SMA, + ILC_SME, + ILC_SMI, + ILC_SMJ, + ILC_SMN, + ILC_SMO, + ILC_SMS, + ILC_SNA, + ILC_SND, + ILC_SNK, + ILC_SOG, + ILC_SOM, + ILC_SON, + ILC_SOT, + ILC_SPA, + ILC_SRD, + ILC_SRN, + ILC_SRP, + ILC_SRR, + ILC_SSA, + ILC_SSW, + ILC_SUK, + ILC_SUN, + ILC_SUS, + ILC_SUX, + ILC_SWA, + ILC_SWE, + ILC_SYC, + ILC_SYR, + ILC_TAH, + ILC_TAI, + ILC_TAM, + ILC_TAT, + ILC_TEL, + ILC_TEM, + ILC_TER, + ILC_TET, + ILC_TGK, + ILC_TGL, + ILC_THA, + ILC_BOD, + ILC_TIG, + ILC_TIR, + ILC_TIV, + ILC_TKL, + ILC_TLH, + ILC_TLI, + ILC_TMH, + ILC_TOG, + ILC_TON, + ILC_TPI, + ILC_TSI, + ILC_TSN, + ILC_TSO, + ILC_TUK, + ILC_TUM, + ILC_TUP, + ILC_TUR, + ILC_TUT, + ILC_TVL, + ILC_TWI, + ILC_TYV, + ILC_UDM, + ILC_UGA, + ILC_UIG, + ILC_UKR, + ILC_UMB, + ILC_UND, + ILC_URD, + ILC_UZB, + ILC_VAI, + ILC_VEN, + ILC_VIE, + ILC_VOL, + ILC_VOT, + ILC_WAK, + ILC_WAL, + ILC_WAR, + ILC_WAS, + ILC_CYM, + ILC_WEN, + ILC_WLN, + ILC_WOL, + ILC_XAL, + ILC_XHO, + ILC_YAO, + ILC_YAP, + ILC_YID, + ILC_YOR, + ILC_YPK, + ILC_ZAP, + ILC_ZBL, + ILC_ZEN, + ILC_ZHA, + ILC_ZND, + ILC_ZUL, + ILC_ZUN, + ILC_ZXX, + ILC_ZZA, +}; + +typedef Enum<LanguageCode,ILC_UNDEFINED> EnumLanguageCode; +MP4V2_EXPORT extern const EnumLanguageCode enumLanguageCode; + +/////////////////////////////////////////////////////////////////////////////// + +}}} // namespace mp4v2::impl::bmff + +#endif // MP4V2_IMPL_BMFF_TYPE_H diff --git a/src/cmeta.cpp b/src/cmeta.cpp new file mode 100644 index 0000000..fb47c6a --- /dev/null +++ b/src/cmeta.cpp @@ -0,0 +1,1439 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001 - 2005. All Rights Reserved. + * + * 3GPP features implementation is based on 3GPP's TS26.234-v5.60, + * and was contributed by Ximpo Group Ltd. + * + * Portions created by Ximpo Group Ltd. are + * Copyright (C) Ximpo Group Ltd. 2003, 2004. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + * Alix Marchandise-Franquet alix@cisco.com + * Ximpo Group Ltd. mp4v2@ximpo.com + * Bill May wmay@cisco.com + * Rouven Wessling mp4v2@rouvenwessling.de + */ + +/* + * MP4 library API functions + * + * These are wrapper functions that provide C linkage conventions + * to the library, and catch any internal errors, ensuring that + * a proper return value is given. + */ + +#include "src/impl.h" + +#define PRINT_ERROR(e) \ + VERBOSE_ERROR(((MP4File*)hFile)->GetVerbosity(), e->Print()); + +using namespace mp4v2::impl; + +extern "C" { + +/////////////////////////////////////////////////////////////////////////////// + +bool MP4GetMetadataByIndex(MP4FileHandle hFile, uint32_t index, + char** ppName, + uint8_t** ppValue, uint32_t* pValueSize) +{ + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetMetadataByIndex( + index, ppName, ppValue, pValueSize); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; +} + +bool MP4MetadataDelete(MP4FileHandle hFile) +{ + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->MetadataDelete(); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; +} + +bool MP4SetMetadataName(MP4FileHandle hFile, + const char* value) +{ + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->SetMetadataString("\251nam", value); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; +} + +bool MP4GetMetadataName(MP4FileHandle hFile, + char** value) +{ + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetMetadataString("\251nam", value); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; +} + +bool MP4DeleteMetadataName(MP4FileHandle hFile) +{ + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->DeleteMetadataAtom("\251nam"); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; +} + +bool MP4SetMetadataWriter(MP4FileHandle hFile, + const char* value) +{ + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->SetMetadataString("\251wrt", value); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; +} + +bool MP4GetMetadataWriter(MP4FileHandle hFile, + char** value) +{ + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetMetadataString("\251wrt", value); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; +} + +bool MP4DeleteMetadataWriter(MP4FileHandle hFile) +{ + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->DeleteMetadataAtom("\251wrt"); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; +} + +bool MP4SetMetadataAlbum(MP4FileHandle hFile, + const char* value) +{ + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->SetMetadataString("\251alb", value); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; +} + +bool MP4GetMetadataAlbum(MP4FileHandle hFile, + char** value) +{ + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetMetadataString("\251alb", value); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; +} + +bool MP4DeleteMetadataAlbum(MP4FileHandle hFile) +{ + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->DeleteMetadataAtom("\251alb"); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; +} + +bool MP4SetMetadataArtist(MP4FileHandle hFile, + const char* value) +{ + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->SetMetadataString("\251ART", value); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; +} + +bool MP4GetMetadataArtist(MP4FileHandle hFile, + char** value) +{ + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetMetadataString("\251ART", value); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; +} + +bool MP4DeleteMetadataArtist(MP4FileHandle hFile) +{ + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->DeleteMetadataAtom("\251ART"); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; +} + +bool MP4SetMetadataTool(MP4FileHandle hFile, + const char* value) +{ + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->SetMetadataString("\251too", value); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; +} + +bool MP4GetMetadataTool(MP4FileHandle hFile, + char** value) +{ + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetMetadataString("\251too", value); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; +} + +bool MP4DeleteMetadataTool(MP4FileHandle hFile) +{ + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->DeleteMetadataAtom("\251too"); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; +} + +bool MP4SetMetadataComment(MP4FileHandle hFile, + const char* value) +{ + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->SetMetadataString("\251cmt", value); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; +} + +bool MP4GetMetadataComment(MP4FileHandle hFile, + char** value) +{ + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetMetadataString("\251cmt", value); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; +} + +bool MP4DeleteMetadataComment(MP4FileHandle hFile) +{ + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->DeleteMetadataAtom("\251cmt"); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; +} + +bool MP4SetMetadataYear(MP4FileHandle hFile, + const char* value) +{ + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->SetMetadataString("\251day", value); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; +} + +bool MP4GetMetadataYear(MP4FileHandle hFile, + char** value) +{ + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetMetadataString("\251day", value); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; +} + +bool MP4DeleteMetadataYear(MP4FileHandle hFile) +{ + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->DeleteMetadataAtom("\251day"); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; +} + +bool MP4SetMetadataTrack(MP4FileHandle hFile, + uint16_t track, uint16_t totalTracks) +{ + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->SetMetadataTrack(track, totalTracks); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; +} + +bool MP4GetMetadataTrack(MP4FileHandle hFile, + uint16_t* track, uint16_t* totalTracks) +{ + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetMetadataTrack(track, totalTracks); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; +} + +bool MP4DeleteMetadataTrack(MP4FileHandle hFile) +{ + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->DeleteMetadataAtom("trkn"); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; +} + +bool MP4SetMetadataDisk(MP4FileHandle hFile, + uint16_t disk, uint16_t totalDisks) +{ + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->SetMetadataDisk(disk, totalDisks); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; +} + +bool MP4GetMetadataDisk(MP4FileHandle hFile, + uint16_t* disk, uint16_t* totalDisks) +{ + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetMetadataDisk(disk, totalDisks); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; +} + +bool MP4DeleteMetadataDisk(MP4FileHandle hFile) +{ + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->DeleteMetadataAtom("disk"); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; +} + +bool MP4SetMetadataGenre(MP4FileHandle hFile, const char *genre) +{ + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->SetMetadataGenre(genre); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; +} + +bool MP4GetMetadataGenre(MP4FileHandle hFile, char **genre) +{ + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetMetadataGenre(genre); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; +} + +bool MP4DeleteMetadataGenre(MP4FileHandle hFile) +{ + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->DeleteMetadataGenre(); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; +} + +bool MP4SetMetadataGrouping(MP4FileHandle hFile, const char *grouping) +{ + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->SetMetadataString("\251grp", grouping); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; +} + +bool MP4GetMetadataGrouping(MP4FileHandle hFile, char **grouping) +{ + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetMetadataString("\251grp", grouping); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; +} + +bool MP4DeleteMetadataGrouping(MP4FileHandle hFile) +{ + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->DeleteMetadataAtom("\251grp"); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; +} + +bool MP4SetMetadataTempo(MP4FileHandle hFile, uint16_t tempo) +{ + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->SetMetadataUint16("tmpo", tempo); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; +} + +bool MP4GetMetadataTempo(MP4FileHandle hFile, uint16_t* tempo) +{ + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetMetadataUint16("tmpo", tempo); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; +} + +bool MP4DeleteMetadataTempo(MP4FileHandle hFile) +{ + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->DeleteMetadataAtom("tmpo"); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; +} + +bool MP4SetMetadataCompilation(MP4FileHandle hFile, uint8_t cpl) +{ + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->SetMetadataUint8("cpil", cpl & 0x1); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; +} + +bool MP4GetMetadataCompilation(MP4FileHandle hFile, uint8_t* cpl) +{ + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetMetadataUint8("cpil", cpl); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; +} + +bool MP4DeleteMetadataCompilation(MP4FileHandle hFile) +{ + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->DeleteMetadataAtom("cpil"); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; +} + +bool MP4SetMetadataPartOfGaplessAlbum (MP4FileHandle hFile, + uint8_t pgap) +{ + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->SetMetadataUint8("pgap", pgap & 0x1); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; +} + +bool MP4GetMetadataPartOfGaplessAlbum (MP4FileHandle hFile, + uint8_t* pgap) +{ + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetMetadataUint8("pgap", pgap); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; +} + +bool MP4DeleteMetadataPartOfGaplessAlbum (MP4FileHandle hFile) +{ + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->DeleteMetadataAtom("pgap"); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; +} + +bool MP4SetMetadataCoverArt(MP4FileHandle hFile, + uint8_t *coverArt, uint32_t size) +{ + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->SetMetadataCoverArt(coverArt, size); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; +} + +bool MP4GetMetadataCoverArt(MP4FileHandle hFile, + uint8_t **coverArt, uint32_t* size, + uint32_t index) +{ + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetMetadataCoverArt(coverArt, size, index); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; +} + +uint32_t MP4GetMetadataCoverArtCount(MP4FileHandle hFile) +{ + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetMetadataCoverArtCount(); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; +} + +bool MP4DeleteMetadataCoverArt(MP4FileHandle hFile) +{ + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->DeleteMetadataAtom("covr"); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; +} + +bool MP4SetMetadataAlbumArtist (MP4FileHandle hFile, + const char* value) +{ + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->SetMetadataString("aART", value); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; +} + +bool MP4GetMetadataAlbumArtist (MP4FileHandle hFile, + char** value) +{ + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetMetadataString("aART", value); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; +} + +bool MP4DeleteMetadataAlbumArtist (MP4FileHandle hFile) +{ + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->DeleteMetadataAtom("aART"); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; +} + +bool MP4SetMetadataFreeForm(MP4FileHandle hFile, + const char *name, + const uint8_t* pValue, + uint32_t valueSize, + const char *owner) +{ + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->SetMetadataFreeForm(name, pValue, valueSize, owner); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; +} + +bool MP4GetMetadataFreeForm(MP4FileHandle hFile, const char *name, + uint8_t** pValue, uint32_t* valueSize, const char *owner) +{ + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetMetadataFreeForm(name, pValue, valueSize, owner); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; +} + +bool MP4DeleteMetadataFreeForm(MP4FileHandle hFile, const char *name, const char *owner) +{ + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->DeleteMetadataFreeForm(name, owner); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; +} + +/////////////////////////////////////////////////////////////////////////////// + +void +MP4TagsAddArtwork( const MP4Tags* tags, MP4TagArtwork* artwork ) +{ + itmf::Tags& cpp = *static_cast<itmf::Tags*>(tags->__handle); + MP4Tags* c = const_cast<MP4Tags*>(tags); + cpp.c_addArtwork( c, *artwork ); +} + +/////////////////////////////////////////////////////////////////////////////// + +const MP4Tags* +MP4TagsAlloc() +{ + MP4Tags* result = NULL; + itmf::Tags& m = *new itmf::Tags(); + m.c_alloc( result ); + return result; +} + +/////////////////////////////////////////////////////////////////////////////// + +void +MP4TagsFree( const MP4Tags* tags ) +{ + itmf::Tags* cpp = static_cast<itmf::Tags*>(tags->__handle); + MP4Tags* c = const_cast<MP4Tags*>(tags); + cpp->c_free( c ); + delete cpp; +} + +/////////////////////////////////////////////////////////////////////////////// + +void +MP4TagsFetch( const MP4Tags* tags, MP4FileHandle hFile ) +{ + if( !MP4_IS_VALID_FILE_HANDLE( hFile )) + return; + + itmf::Tags* cpp = static_cast<itmf::Tags*>(tags->__handle); + MP4Tags* c = const_cast<MP4Tags*>(tags); + + try { + cpp->c_fetch( c, hFile ); + } + catch( MP4Error* e ) { + VERBOSE_ERROR( static_cast<MP4File*>(hFile)->GetVerbosity(), e->Print() ); + delete e; + } +} + +/////////////////////////////////////////////////////////////////////////////// + +void +MP4TagsRemoveArtwork( const MP4Tags* tags, uint32_t index ) +{ + itmf::Tags& cpp = *static_cast<itmf::Tags*>(tags->__handle); + MP4Tags* c = const_cast<MP4Tags*>(tags); + cpp.c_removeArtwork( c, index ); +} + +/////////////////////////////////////////////////////////////////////////////// + +void +MP4TagsSetArtwork( const MP4Tags* tags, uint32_t index, MP4TagArtwork* artwork ) +{ + itmf::Tags& cpp = *static_cast<itmf::Tags*>(tags->__handle); + MP4Tags* c = const_cast<MP4Tags*>(tags); + cpp.c_setArtwork( c, index, *artwork ); +} + +/////////////////////////////////////////////////////////////////////////////// + +void +MP4TagsStore( const MP4Tags* tags, MP4FileHandle hFile ) +{ + itmf::Tags* cpp = static_cast<itmf::Tags*>(tags->__handle); + MP4Tags* c = const_cast<MP4Tags*>(tags); + + try { + cpp->c_store( c, hFile ); + } + catch( MP4Error* e ) { + VERBOSE_ERROR( static_cast<MP4File*>(hFile)->GetVerbosity(), e->Print() ); + delete e; + } +} + +/////////////////////////////////////////////////////////////////////////////// + +void +MP4TagsSetName( const MP4Tags* m, const char* value ) +{ + itmf::Tags& cpp = *static_cast<itmf::Tags*>(m->__handle); + MP4Tags& c = *const_cast<MP4Tags*>(m); + cpp.c_setString( value, cpp.name, c.name ); +} + +void +MP4TagsSetArtist( const MP4Tags* m, const char* value ) +{ + itmf::Tags& cpp = *static_cast<itmf::Tags*>(m->__handle); + MP4Tags& c = *const_cast<MP4Tags*>(m); + cpp.c_setString( value, cpp.artist, c.artist ); +} + +void +MP4TagsSetAlbumArtist( const MP4Tags* m, const char* value ) +{ + itmf::Tags& cpp = *static_cast<itmf::Tags*>(m->__handle); + MP4Tags& c = *const_cast<MP4Tags*>(m); + cpp.c_setString( value, cpp.albumArtist, c.albumArtist ); +} + +void +MP4TagsSetAlbum( const MP4Tags* m, const char* value ) +{ + itmf::Tags& cpp = *static_cast<itmf::Tags*>(m->__handle); + MP4Tags& c = *const_cast<MP4Tags*>(m); + cpp.c_setString( value, cpp.album, c.album ); +} + +void +MP4TagsSetGrouping( const MP4Tags* m, const char* value ) +{ + itmf::Tags& cpp = *static_cast<itmf::Tags*>(m->__handle); + MP4Tags& c = *const_cast<MP4Tags*>(m); + cpp.c_setString( value, cpp.grouping, c.grouping ); +} + +void +MP4TagsSetComposer( const MP4Tags* m, const char* value ) +{ + itmf::Tags& cpp = *static_cast<itmf::Tags*>(m->__handle); + MP4Tags& c = *const_cast<MP4Tags*>(m); + cpp.c_setString( value, cpp.composer, c.composer ); +} + +void +MP4TagsSetComments( const MP4Tags* m, const char* value ) +{ + itmf::Tags& cpp = *static_cast<itmf::Tags*>(m->__handle); + MP4Tags& c = *const_cast<MP4Tags*>(m); + cpp.c_setString( value, cpp.comments, c.comments ); +} + +void +MP4TagsSetGenre( const MP4Tags* m, const char* value ) +{ + itmf::Tags& cpp = *static_cast<itmf::Tags*>(m->__handle); + MP4Tags& c = *const_cast<MP4Tags*>(m); + cpp.c_setString( value, cpp.genre, c.genre ); +} + +void +MP4TagsSetGenreType( const MP4Tags* m, const uint16_t* value ) +{ + itmf::Tags& cpp = *static_cast<itmf::Tags*>(m->__handle); + MP4Tags& c = *const_cast<MP4Tags*>(m); + cpp.c_setInteger( value, cpp.genreType, c.genreType ); +} + +void +MP4TagsSetReleaseDate( const MP4Tags* m, const char* value ) +{ + itmf::Tags& cpp = *static_cast<itmf::Tags*>(m->__handle); + MP4Tags& c = *const_cast<MP4Tags*>(m); + cpp.c_setString( value, cpp.releaseDate, c.releaseDate ); +} + +void +MP4TagsSetTrack( const MP4Tags* m, const MP4TagTrack* value ) +{ + itmf::Tags& cpp = *static_cast<itmf::Tags*>(m->__handle); + MP4Tags& c = *const_cast<MP4Tags*>(m); + cpp.c_setTrack( value, cpp.track, c.track ); +} + +void +MP4TagsSetDisk( const MP4Tags* m, const MP4TagDisk* value ) +{ + itmf::Tags& cpp = *static_cast<itmf::Tags*>(m->__handle); + MP4Tags& c = *const_cast<MP4Tags*>(m); + cpp.c_setDisk( value, cpp.disk, c.disk ); +} + +void +MP4TagsSetTempo( const MP4Tags* m, const uint16_t* value ) +{ + itmf::Tags& cpp = *static_cast<itmf::Tags*>(m->__handle); + MP4Tags& c = *const_cast<MP4Tags*>(m); + cpp.c_setInteger( value, cpp.tempo, c.tempo ); +} + +void +MP4TagsSetCompilation( const MP4Tags* m, const uint8_t* value ) +{ + itmf::Tags& cpp = *static_cast<itmf::Tags*>(m->__handle); + MP4Tags& c = *const_cast<MP4Tags*>(m); + cpp.c_setInteger( value, cpp.compilation, c.compilation ); +} + +void +MP4TagsSetTVShow( const MP4Tags* m, const char* value ) +{ + itmf::Tags& cpp = *static_cast<itmf::Tags*>(m->__handle); + MP4Tags& c = *const_cast<MP4Tags*>(m); + cpp.c_setString( value, cpp.tvShow, c.tvShow ); +} + +void +MP4TagsSetTVNetwork( const MP4Tags* m, const char* value ) +{ + itmf::Tags& cpp = *static_cast<itmf::Tags*>(m->__handle); + MP4Tags& c = *const_cast<MP4Tags*>(m); + cpp.c_setString( value, cpp.tvNetwork, c.tvNetwork ); +} + +void +MP4TagsSetTVEpisodeID( const MP4Tags* m, const char* value ) +{ + itmf::Tags& cpp = *static_cast<itmf::Tags*>(m->__handle); + MP4Tags& c = *const_cast<MP4Tags*>(m); + cpp.c_setString( value, cpp.tvEpisodeID, c.tvEpisodeID ); +} + +void +MP4TagsSetTVSeason( const MP4Tags* m, const uint32_t* value ) +{ + itmf::Tags& cpp = *static_cast<itmf::Tags*>(m->__handle); + MP4Tags& c = *const_cast<MP4Tags*>(m); + cpp.c_setInteger( value, cpp.tvSeason, c.tvSeason ); +} + +void +MP4TagsSetTVEpisode( const MP4Tags* m, const uint32_t* value ) +{ + itmf::Tags& cpp = *static_cast<itmf::Tags*>(m->__handle); + MP4Tags& c = *const_cast<MP4Tags*>(m); + cpp.c_setInteger( value, cpp.tvEpisode, c.tvEpisode ); +} + +void +MP4TagsSetSortName( const MP4Tags* m, const char* value ) +{ + itmf::Tags& cpp = *static_cast<itmf::Tags*>(m->__handle); + MP4Tags& c = *const_cast<MP4Tags*>(m); + cpp.c_setString( value, cpp.sortName, c.sortName ); +} + +void +MP4TagsSetSortArtist( const MP4Tags* m, const char* value ) +{ + itmf::Tags& cpp = *static_cast<itmf::Tags*>(m->__handle); + MP4Tags& c = *const_cast<MP4Tags*>(m); + cpp.c_setString( value, cpp.sortArtist, c.sortArtist ); +} + +void +MP4TagsSetSortAlbumArtist( const MP4Tags* m, const char* value ) +{ + itmf::Tags& cpp = *static_cast<itmf::Tags*>(m->__handle); + MP4Tags& c = *const_cast<MP4Tags*>(m); + cpp.c_setString( value, cpp.sortAlbumArtist, c.sortAlbumArtist ); +} + +void +MP4TagsSetSortAlbum( const MP4Tags* m, const char* value ) +{ + itmf::Tags& cpp = *static_cast<itmf::Tags*>(m->__handle); + MP4Tags& c = *const_cast<MP4Tags*>(m); + cpp.c_setString( value, cpp.sortAlbum, c.sortAlbum ); +} + +void +MP4TagsSetSortComposer( const MP4Tags* m, const char* value ) +{ + itmf::Tags& cpp = *static_cast<itmf::Tags*>(m->__handle); + MP4Tags& c = *const_cast<MP4Tags*>(m); + cpp.c_setString( value, cpp.sortComposer, c.sortComposer ); +} + +void +MP4TagsSetSortTVShow( const MP4Tags* m, const char* value ) +{ + itmf::Tags& cpp = *static_cast<itmf::Tags*>(m->__handle); + MP4Tags& c = *const_cast<MP4Tags*>(m); + cpp.c_setString( value, cpp.sortTVShow, c.sortTVShow ); +} + +void +MP4TagsSetDescription( const MP4Tags* m, const char* value ) +{ + itmf::Tags& cpp = *static_cast<itmf::Tags*>(m->__handle); + MP4Tags& c = *const_cast<MP4Tags*>(m); + cpp.c_setString( value, cpp.description, c.description ); +} + +void +MP4TagsSetLongDescription( const MP4Tags* m, const char* value ) +{ + itmf::Tags& cpp = *static_cast<itmf::Tags*>(m->__handle); + MP4Tags& c = *const_cast<MP4Tags*>(m); + cpp.c_setString( value, cpp.longDescription, c.longDescription ); +} + +void +MP4TagsSetLyrics( const MP4Tags* m, const char* value ) +{ + itmf::Tags& cpp = *static_cast<itmf::Tags*>(m->__handle); + MP4Tags& c = *const_cast<MP4Tags*>(m); + cpp.c_setString( value, cpp.lyrics, c.lyrics ); +} + +void +MP4TagsSetCopyright( const MP4Tags* m, const char* value ) +{ + itmf::Tags& cpp = *static_cast<itmf::Tags*>(m->__handle); + MP4Tags& c = *const_cast<MP4Tags*>(m); + cpp.c_setString( value, cpp.copyright, c.copyright ); +} + +void +MP4TagsSetEncodingTool( const MP4Tags* m, const char* value ) +{ + itmf::Tags& cpp = *static_cast<itmf::Tags*>(m->__handle); + MP4Tags& c = *const_cast<MP4Tags*>(m); + cpp.c_setString( value, cpp.encodingTool, c.encodingTool ); +} + +void +MP4TagsSetEncodedBy( const MP4Tags* m, const char* value ) +{ + itmf::Tags& cpp = *static_cast<itmf::Tags*>(m->__handle); + MP4Tags& c = *const_cast<MP4Tags*>(m); + cpp.c_setString( value, cpp.encodedBy, c.encodedBy ); +} + +void +MP4TagsSetPurchaseDate( const MP4Tags* m, const char* value ) +{ + itmf::Tags& cpp = *static_cast<itmf::Tags*>(m->__handle); + MP4Tags& c = *const_cast<MP4Tags*>(m); + cpp.c_setString( value, cpp.purchaseDate, c.purchaseDate ); +} + +void +MP4TagsSetPodcast( const MP4Tags* m, const uint8_t* value ) +{ + itmf::Tags& cpp = *static_cast<itmf::Tags*>(m->__handle); + MP4Tags& c = *const_cast<MP4Tags*>(m); + cpp.c_setInteger( value, cpp.podcast, c.podcast ); +} + +void +MP4TagsSetKeywords( const MP4Tags* m, const char* value ) +{ + itmf::Tags& cpp = *static_cast<itmf::Tags*>(m->__handle); + MP4Tags& c = *const_cast<MP4Tags*>(m); + cpp.c_setString( value, cpp.keywords, c.keywords ); +} + +void +MP4TagsSetCategory( const MP4Tags* m, const char* value ) +{ + itmf::Tags& cpp = *static_cast<itmf::Tags*>(m->__handle); + MP4Tags& c = *const_cast<MP4Tags*>(m); + cpp.c_setString( value, cpp.category, c.category ); +} + +void +MP4TagsSetHDVideo( const MP4Tags* m, const uint8_t* value ) +{ + itmf::Tags& cpp = *static_cast<itmf::Tags*>(m->__handle); + MP4Tags& c = *const_cast<MP4Tags*>(m); + cpp.c_setInteger( value, cpp.hdVideo, c.hdVideo ); +} + +void +MP4TagsSetMediaType( const MP4Tags* m, const uint8_t* value ) +{ + itmf::Tags& cpp = *static_cast<itmf::Tags*>(m->__handle); + MP4Tags& c = *const_cast<MP4Tags*>(m); + cpp.c_setInteger( value, cpp.mediaType, c.mediaType ); +} + +void +MP4TagsSetContentRating( const MP4Tags* m, const uint8_t* value ) +{ + itmf::Tags& cpp = *static_cast<itmf::Tags*>(m->__handle); + MP4Tags& c = *const_cast<MP4Tags*>(m); + cpp.c_setInteger( value, cpp.contentRating, c.contentRating ); +} + +void +MP4TagsSetGapless( const MP4Tags* m, const uint8_t* value ) +{ + itmf::Tags& cpp = *static_cast<itmf::Tags*>(m->__handle); + MP4Tags& c = *const_cast<MP4Tags*>(m); + cpp.c_setInteger( value, cpp.gapless, c.gapless ); +} + +void +MP4TagsSetITunesAccount( const MP4Tags* m, const char* value ) +{ + itmf::Tags& cpp = *static_cast<itmf::Tags*>(m->__handle); + MP4Tags& c = *const_cast<MP4Tags*>(m); + cpp.c_setString( value, cpp.iTunesAccount, c.iTunesAccount ); +} + +void +MP4TagsSetITunesAccountType( const MP4Tags* m, const uint8_t* value ) +{ + itmf::Tags& cpp = *static_cast<itmf::Tags*>(m->__handle); + MP4Tags& c = *const_cast<MP4Tags*>(m); + cpp.c_setInteger( value, cpp.iTunesAccountType, c.iTunesAccountType ); +} + +void +MP4TagsSetITunesCountry( const MP4Tags* m, const uint32_t* value ) +{ + itmf::Tags& cpp = *static_cast<itmf::Tags*>(m->__handle); + MP4Tags& c = *const_cast<MP4Tags*>(m); + cpp.c_setInteger( value, cpp.iTunesCountry, c.iTunesCountry ); +} + +void +MP4TagsSetCNID( const MP4Tags* m, const uint32_t* value ) +{ + itmf::Tags& cpp = *static_cast<itmf::Tags*>(m->__handle); + MP4Tags& c = *const_cast<MP4Tags*>(m); + cpp.c_setInteger( value, cpp.cnID, c.cnID ); +} + +void +MP4TagsSetATID( const MP4Tags* m, const uint32_t* value ) +{ + itmf::Tags& cpp = *static_cast<itmf::Tags*>(m->__handle); + MP4Tags& c = *const_cast<MP4Tags*>(m); + cpp.c_setInteger( value, cpp.atID, c.atID ); +} + +void +MP4TagsSetPLID( const MP4Tags* m, const uint64_t* value ) +{ + itmf::Tags& cpp = *static_cast<itmf::Tags*>(m->__handle); + MP4Tags& c = *const_cast<MP4Tags*>(m); + cpp.c_setInteger( value, cpp.plID, c.plID ); +} + +void +MP4TagsSetGEID( const MP4Tags* m, const uint32_t* value ) +{ + itmf::Tags& cpp = *static_cast<itmf::Tags*>(m->__handle); + MP4Tags& c = *const_cast<MP4Tags*>(m); + cpp.c_setInteger( value, cpp.geID, c.geID ); +} + +/////////////////////////////////////////////////////////////////////////////// + +MP4ItmfItem* +MP4ItmfItemAlloc( const char* code, uint32_t numData ) +{ + return itmf::genericItemAlloc( code, numData ); +} + +/////////////////////////////////////////////////////////////////////////////// + +void +MP4ItmfItemFree( MP4ItmfItem* item ) +{ + itmf::genericItemFree( item ); +} + +/////////////////////////////////////////////////////////////////////////////// + +void +MP4ItmfItemListFree( MP4ItmfItemList* list ) +{ + itmf::genericItemListFree( list ); +} + +/////////////////////////////////////////////////////////////////////////////// + +MP4ItmfItemList* +MP4ItmfGetItems( MP4FileHandle hFile ) +{ + if( !MP4_IS_VALID_FILE_HANDLE( hFile )) + return NULL; + + try { + return itmf::genericGetItems( *(MP4File*)hFile ); + } + catch( MP4Error* e ) { + PRINT_ERROR( e ); + delete e; + } + + return NULL; +} + +/////////////////////////////////////////////////////////////////////////////// + +MP4ItmfItemList* +MP4ItmfGetItemsByCode( MP4FileHandle hFile, const char* code ) +{ + if( !MP4_IS_VALID_FILE_HANDLE( hFile )) + return NULL; + + try { + return itmf::genericGetItemsByCode( *(MP4File*)hFile, code ); + } + catch( MP4Error* e ) { + PRINT_ERROR( e ); + delete e; + } + + return NULL; +} + +/////////////////////////////////////////////////////////////////////////////// + +MP4ItmfItemList* +MP4ItmfGetItemsByMeaning( MP4FileHandle hFile, const char* meaning, const char* name ) +{ + if( !MP4_IS_VALID_FILE_HANDLE( hFile )) + return NULL; + + try { + return itmf::genericGetItemsByMeaning( *(MP4File*)hFile, meaning, name ? name : "" ); + } + catch( MP4Error* e ) { + PRINT_ERROR( e ); + delete e; + } + + return NULL; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +MP4ItmfAddItem( MP4FileHandle hFile, const MP4ItmfItem* item ) +{ + if( !MP4_IS_VALID_FILE_HANDLE( hFile )) + return NULL; + + try { + return itmf::genericAddItem( *(MP4File*)hFile, item ); + } + catch( MP4Error* e ) { + PRINT_ERROR( e ); + delete e; + } + + return false; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +MP4ItmfSetItem( MP4FileHandle hFile, const MP4ItmfItem* item ) +{ + if( !MP4_IS_VALID_FILE_HANDLE( hFile )) + return NULL; + + try { + return itmf::genericSetItem( *(MP4File*)hFile, item ); + } + catch( MP4Error* e ) { + PRINT_ERROR( e ); + delete e; + } + + return false; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +MP4ItmfRemoveItem( MP4FileHandle hFile, const MP4ItmfItem* item ) +{ + if( !MP4_IS_VALID_FILE_HANDLE( hFile )) + return NULL; + + try { + return itmf::genericRemoveItem( *(MP4File*)hFile, item ); + } + catch( MP4Error* e ) { + PRINT_ERROR( e ); + delete e; + } + + return false; +} + +/////////////////////////////////////////////////////////////////////////////// + +} // extern "C" diff --git a/src/descriptors.cpp b/src/descriptors.cpp new file mode 100644 index 0000000..2896920 --- /dev/null +++ b/src/descriptors.cpp @@ -0,0 +1,615 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4BaseDescriptor::MP4BaseDescriptor (uint8_t tag) : MP4Descriptor(tag) +{ + switch (tag) { + case MP4ESIDIncDescrTag: + AddProperty( /* 0 */ + new MP4Integer32Property("id")); + break; + case MP4ESIDRefDescrTag: + AddProperty( /* 0 */ + new MP4Integer16Property("refIndex")); + break; + case MP4IPIPtrDescrTag: + AddProperty( /* 0 */ + new MP4Integer16Property("IPIESId")); + break; + case MP4SupplContentIdDescrTag: + AddProperty( /* 0 */ + new MP4BytesProperty("languageCode", 3)); + AddProperty( /* 1 */ + new MP4StringProperty("title", Counted)); + AddProperty( /* 2 */ + new MP4StringProperty("value", Counted)); + break; + case MP4IPMPPtrDescrTag: + AddProperty( /* 0 */ + new MP4Integer8Property("IPMPDescriptorId")); + break; + case MP4ExtProfileLevelDescrTag: + AddProperty( /* 0 */ + new MP4Integer8Property("profileLevelIndicationIndex")); + AddProperty( /* 1 */ + new MP4Integer8Property("ODProfileLevelIndication")); + AddProperty( /* 2 */ + new MP4Integer8Property("sceneProfileLevelIndication")); + AddProperty( /* 3 */ + new MP4Integer8Property("audioProfileLevelIndication")); + AddProperty( /* 4 */ + new MP4Integer8Property("visualProfileLevelIndication")); + AddProperty( /* 5 */ + new MP4Integer8Property("graphicsProfileLevelIndication")); + AddProperty( /* 6 */ + new MP4Integer8Property("MPEGJProfileLevelIndication")); + break; + default: + MP4Printf("error in base descriptor - tag %u", tag); + break; + + } +} + +MP4BytesDescriptor::MP4BytesDescriptor (uint8_t tag) : MP4Descriptor(tag) +{ + m_size_offset = 0; + m_bytes_index = 0; + if (tag >= MP4ExtDescrTagsStart && tag <= MP4ExtDescrTagsEnd) { + AddProperty( /* 0 */ + new MP4BytesProperty("data")); + } else { + switch (tag) { + case MP4DecSpecificDescrTag: + AddProperty( /* 0 */ + new MP4BytesProperty("info")); + // no change to m_size + break; + case MP4IPMPDescrTag: + AddProperty( /* 0 */ + new MP4Integer8Property("IPMPDescriptorId")); + AddProperty( /* 1 */ + new MP4Integer16Property("IPMPSType")); + AddProperty( /* 2 */ + new MP4BytesProperty("IPMPData")); + /* note: if IPMPSType == 0, IPMPData is an URL */ + m_size_offset = 3; + m_bytes_index = 2; + break; + case MP4RegistrationDescrTag: + AddProperty( /* 0 */ + new MP4Integer32Property("formatIdentifier")); + AddProperty( /* 1 */ + new MP4BytesProperty("additionalIdentificationInfo")); + m_size_offset = 4; + m_bytes_index = 1; + break; + default: + MP4Printf("error in bytes descriptor - tag %u", tag); + break; + } + } +} + +void MP4BytesDescriptor::Read(MP4File *pFile) +{ + ReadHeader(pFile); + + /* byte properties need to know how long they are before reading */ + ((MP4BytesProperty*)m_pProperties[m_bytes_index])->SetValueSize(m_size - m_size_offset); + + ReadProperties(pFile); +} +MP4IODescriptor::MP4IODescriptor() + : MP4Descriptor(MP4FileIODescrTag) +{ + /* N.B. other member functions depend on the property indicies */ + AddProperty( /* 0 */ + new MP4BitfieldProperty("objectDescriptorId", 10)); + AddProperty( /* 1 */ + new MP4BitfieldProperty("URLFlag", 1)); + AddProperty( /* 2 */ + new MP4BitfieldProperty("includeInlineProfileLevelFlag", 1)); + AddProperty( /* 3 */ + new MP4BitfieldProperty("reserved", 4)); + AddProperty( /* 4 */ + new MP4StringProperty("URL", Counted)); + AddProperty( /* 5 */ + new MP4Integer8Property("ODProfileLevelId")); + AddProperty( /* 6 */ + new MP4Integer8Property("sceneProfileLevelId")); + AddProperty( /* 7 */ + new MP4Integer8Property("audioProfileLevelId")); + AddProperty( /* 8 */ + new MP4Integer8Property("visualProfileLevelId")); + AddProperty( /* 9 */ + new MP4Integer8Property("graphicsProfileLevelId")); + AddProperty( /* 10 */ + new MP4DescriptorProperty("esIds", + MP4ESIDIncDescrTag, 0, Required, Many)); + AddProperty( /* 11 */ + new MP4DescriptorProperty("ociDescr", + MP4OCIDescrTagsStart, MP4OCIDescrTagsEnd, Optional, Many)); + AddProperty( /* 12 */ + new MP4DescriptorProperty("ipmpDescrPtr", + MP4IPMPPtrDescrTag, 0, Optional, Many)); + AddProperty( /* 13 */ + new MP4DescriptorProperty("extDescr", + MP4ExtDescrTagsStart, MP4ExtDescrTagsEnd, Optional, Many)); + + SetReadMutate(2); +} + +void MP4IODescriptor::Generate() +{ + ((MP4BitfieldProperty*)m_pProperties[0])->SetValue(1); + ((MP4BitfieldProperty*)m_pProperties[3])->SetValue(0xF); + for (uint32_t i = 5; i <= 9; i++) { + ((MP4Integer8Property*)m_pProperties[i])->SetValue(0xFF); + } +} + +void MP4IODescriptor::Mutate() +{ + bool urlFlag = ((MP4BitfieldProperty*)m_pProperties[1])->GetValue(); + + m_pProperties[4]->SetImplicit(!urlFlag); + for (uint32_t i = 5; i <= 12; i++) { + m_pProperties[i]->SetImplicit(urlFlag); + } +} + +MP4ODescriptor::MP4ODescriptor() + : MP4Descriptor(MP4FileODescrTag) +{ + /* N.B. other member functions depend on the property indicies */ + AddProperty( /* 0 */ + new MP4BitfieldProperty("objectDescriptorId", 10)); + AddProperty( /* 1 */ + new MP4BitfieldProperty("URLFlag", 1)); + AddProperty( /* 2 */ + new MP4BitfieldProperty("reserved", 5)); + AddProperty( /* 3 */ + new MP4StringProperty("URL", Counted)); + AddProperty( /* 4 */ + new MP4DescriptorProperty("esIds", + MP4ESIDRefDescrTag, 0, Required, Many)); + AddProperty( /* 5 */ + new MP4DescriptorProperty("ociDescr", + MP4OCIDescrTagsStart, MP4OCIDescrTagsEnd, Optional, Many)); + AddProperty( /* 6 */ + new MP4DescriptorProperty("ipmpDescrPtr", + MP4IPMPPtrDescrTag, 0, Optional, Many)); + AddProperty( /* 7 */ + new MP4DescriptorProperty("extDescr", + MP4ExtDescrTagsStart, MP4ExtDescrTagsEnd, Optional, Many)); + + SetReadMutate(2); +} + +void MP4ODescriptor::Generate() +{ + ((MP4BitfieldProperty*)m_pProperties[2])->SetValue(0x1F); +} + +void MP4ODescriptor::Mutate() +{ + bool urlFlag = ((MP4BitfieldProperty*)m_pProperties[1])->GetValue(); + + m_pProperties[3]->SetImplicit(!urlFlag); + for (uint32_t i = 4; i <= 6; i++) { + m_pProperties[i]->SetImplicit(urlFlag); + } +} + +MP4ESDescriptor::MP4ESDescriptor() + : MP4Descriptor(MP4ESDescrTag) +{ + /* N.B. other class functions depend on the property indicies */ + AddProperty( /* 0 */ + new MP4Integer16Property("ESID")); + AddProperty( /* 1 */ + new MP4BitfieldProperty("streamDependenceFlag", 1)); + AddProperty( /* 2 */ + new MP4BitfieldProperty("URLFlag", 1)); + AddProperty( /* 3 */ + new MP4BitfieldProperty("OCRstreamFlag", 1)); + AddProperty( /* 4 */ + new MP4BitfieldProperty("streamPriority", 5)); + AddProperty( /* 5 */ + new MP4Integer16Property("dependsOnESID")); + AddProperty( /* 6 */ + new MP4StringProperty("URL", Counted)); + AddProperty( /* 7 */ + new MP4Integer16Property("OCRESID")); + AddProperty( /* 8 */ + new MP4DescriptorProperty("decConfigDescr", + MP4DecConfigDescrTag, 0, Required, OnlyOne)); + AddProperty( /* 9 */ + new MP4DescriptorProperty("slConfigDescr", + MP4SLConfigDescrTag, 0, Required, OnlyOne)); + AddProperty( /* 10 */ + new MP4DescriptorProperty("ipiPtr", + MP4IPIPtrDescrTag, 0, Optional, OnlyOne)); + AddProperty( /* 11 */ + new MP4DescriptorProperty("ipIds", + MP4ContentIdDescrTag, MP4SupplContentIdDescrTag, Optional, Many)); + AddProperty( /* 12 */ + new MP4DescriptorProperty("ipmpDescrPtr", + MP4IPMPPtrDescrTag, 0, Optional, Many)); + AddProperty( /* 13 */ + new MP4DescriptorProperty("langDescr", + MP4LanguageDescrTag, 0, Optional, Many)); + AddProperty( /* 14 */ + new MP4DescriptorProperty("qosDescr", + MP4QosDescrTag, 0, Optional, OnlyOne)); + AddProperty( /* 15 */ + new MP4DescriptorProperty("regDescr", + MP4RegistrationDescrTag, 0, Optional, OnlyOne)); + AddProperty( /* 16 */ + new MP4DescriptorProperty("extDescr", + MP4ExtDescrTagsStart, MP4ExtDescrTagsEnd, Optional, Many)); + + SetReadMutate(5); +} + +void MP4ESDescriptor::Mutate() +{ + bool streamDependFlag = + ((MP4BitfieldProperty*)m_pProperties[1])->GetValue(); + m_pProperties[5]->SetImplicit(!streamDependFlag); + + bool urlFlag = + ((MP4BitfieldProperty*)m_pProperties[2])->GetValue(); + m_pProperties[6]->SetImplicit(!urlFlag); + + bool ocrFlag = + ((MP4BitfieldProperty*)m_pProperties[3])->GetValue(); + m_pProperties[7]->SetImplicit(!ocrFlag); +} + +MP4DecConfigDescriptor::MP4DecConfigDescriptor() + : MP4Descriptor(MP4DecConfigDescrTag) +{ + AddProperty( /* 0 */ + new MP4Integer8Property("objectTypeId")); + AddProperty( /* 1 */ + new MP4BitfieldProperty("streamType", 6)); + AddProperty( /* 2 */ + new MP4BitfieldProperty("upStream", 1)); + AddProperty( /* 3 */ + new MP4BitfieldProperty("reserved", 1)); + AddProperty( /* 4 */ + new MP4BitfieldProperty("bufferSizeDB", 24)); + AddProperty( /* 5 */ + new MP4Integer32Property("maxBitrate")); + AddProperty( /* 6 */ + new MP4Integer32Property("avgBitrate")); + AddProperty( /* 7 */ + new MP4DescriptorProperty("decSpecificInfo", + MP4DecSpecificDescrTag, 0, Optional, OnlyOne)); + AddProperty( /* 8 */ + new MP4DescriptorProperty("profileLevelIndicationIndexDescr", + MP4ExtProfileLevelDescrTag, 0, Optional, Many)); +} + +void MP4DecConfigDescriptor::Generate() +{ + ((MP4BitfieldProperty*)m_pProperties[3])->SetValue(1); +} + +MP4SLConfigDescriptor::MP4SLConfigDescriptor() + : MP4Descriptor(MP4SLConfigDescrTag) +{ + AddProperty( /* 0 */ + new MP4Integer8Property("predefined")); + AddProperty( /* 1 */ + new MP4BitfieldProperty("useAccessUnitStartFlag", 1)); + AddProperty( /* 2 */ + new MP4BitfieldProperty("useAccessUnitEndFlag", 1)); + AddProperty( /* 3 */ + new MP4BitfieldProperty("useRandomAccessPointFlag", 1)); + AddProperty( /* 4 */ + new MP4BitfieldProperty("hasRandomAccessUnitsOnlyFlag", 1)); + AddProperty( /* 5 */ + new MP4BitfieldProperty("usePaddingFlag", 1)); + AddProperty( /* 6 */ + new MP4BitfieldProperty("useTimeStampsFlag", 1)); + AddProperty( /* 7 */ + new MP4BitfieldProperty("useIdleFlag", 1)); + AddProperty( /* 8 */ + new MP4BitfieldProperty("durationFlag", 1)); + AddProperty( /* 9 */ + new MP4Integer32Property("timeStampResolution")); + AddProperty( /* 10 */ + new MP4Integer32Property("OCRResolution")); + AddProperty( /* 11 */ + new MP4Integer8Property("timeStampLength")); + AddProperty( /* 12 */ + new MP4Integer8Property("OCRLength")); + AddProperty( /* 13 */ + new MP4Integer8Property("AULength")); + AddProperty( /* 14 */ + new MP4Integer8Property("instantBitrateLength")); + AddProperty( /* 15 */ + new MP4BitfieldProperty("degradationPriortyLength", 4)); + AddProperty( /* 16 */ + new MP4BitfieldProperty("AUSeqNumLength", 5)); + AddProperty( /* 17 */ + new MP4BitfieldProperty("packetSeqNumLength", 5)); + AddProperty( /* 18 */ + new MP4BitfieldProperty("reserved", 2)); + + // if durationFlag + AddProperty( /* 19 */ + new MP4Integer32Property("timeScale")); + AddProperty( /* 20 */ + new MP4Integer16Property("accessUnitDuration")); + AddProperty( /* 21 */ + new MP4Integer16Property("compositionUnitDuration")); + + // if !useTimeStampsFlag + AddProperty( /* 22 */ + new MP4BitfieldProperty("startDecodingTimeStamp", 64)); + AddProperty( /* 23 */ + new MP4BitfieldProperty("startCompositionTimeStamp", 64)); +} + +void MP4SLConfigDescriptor::Generate() +{ + // by default all tracks in an mp4 file + // use predefined SLConfig descriptor == 2 + ((MP4Integer8Property*)m_pProperties[0])->SetValue(2); + + // which implies UseTimestampsFlag = 1 + ((MP4BitfieldProperty*)m_pProperties[6])->SetValue(1); + + // reserved = 3 + ((MP4BitfieldProperty*)m_pProperties[18])->SetValue(3); +} + +void MP4SLConfigDescriptor::Read(MP4File* pFile) +{ + ReadHeader(pFile); + + // read the first property, 'predefined' + ReadProperties(pFile, 0, 1); + + // if predefined == 0 + if (((MP4Integer8Property*)m_pProperties[0])->GetValue() == 0) { + + /* read the next 18 properties */ + ReadProperties(pFile, 1, 18); + } + + // now mutate + Mutate(); + + // and read the remaining properties + ReadProperties(pFile, 19); +} + +void MP4SLConfigDescriptor::Mutate() +{ + uint32_t i; + uint8_t predefined = + ((MP4Integer8Property*)m_pProperties[0])->GetValue(); + + if (predefined) { + // properties 1-18 are implicit + for (i = 1; i < m_pProperties.Size(); i++) { + m_pProperties[i]->SetImplicit(true); + } + + if (predefined == 1) { + // UseTimestampsFlag = 0 + ((MP4BitfieldProperty*)m_pProperties[6])->SetValue(0); + + // TimestampResolution = 1000 + ((MP4Integer32Property*)m_pProperties[9])->SetValue(1000); + + // TimeStampLength = 32 + ((MP4Integer8Property*)m_pProperties[11])->SetValue(32); + + } else if (predefined == 2) { + // UseTimestampsFlag = 1 + ((MP4BitfieldProperty*)m_pProperties[6])->SetValue(1); + } + } else { +#if 1 + for (i = 1; i <= 18; i++) { + m_pProperties[i]->SetImplicit(false); + } + ((MP4BitfieldProperty*)m_pProperties[18])->SetValue(3); +#endif + } + + bool durationFlag = + ((MP4BitfieldProperty*)m_pProperties[8])->GetValue(); + + for (i = 19; i <= 21; i++) { + m_pProperties[i]->SetImplicit(!durationFlag); + } + + bool useTimeStampsFlag = + ((MP4BitfieldProperty*)m_pProperties[6])->GetValue(); + + for (i = 22; i <= 23; i++) { + m_pProperties[i]->SetImplicit(useTimeStampsFlag); + + uint8_t timeStampLength = min((uint8_t)64, + ((MP4Integer8Property*)m_pProperties[11])->GetValue()); + + ((MP4BitfieldProperty*)m_pProperties[i])->SetNumBits(timeStampLength); + + // handle a nonsensical situation gracefully + if (timeStampLength == 0) { + m_pProperties[i]->SetImplicit(true); + } + } +} + +MP4ContentIdDescriptor::MP4ContentIdDescriptor() + : MP4Descriptor(MP4ContentIdDescrTag) +{ + AddProperty( /* 0 */ + new MP4BitfieldProperty("compatibility", 2)); + AddProperty( /* 1 */ + new MP4BitfieldProperty("contentTypeFlag", 1)); + AddProperty( /* 2 */ + new MP4BitfieldProperty("contentIdFlag", 1)); + AddProperty( /* 3 */ + new MP4BitfieldProperty("protectedContent", 1)); + AddProperty( /* 4 */ + new MP4BitfieldProperty("reserved", 3)); + AddProperty( /* 5 */ + new MP4Integer8Property("contentType")); + AddProperty( /* 6 */ + new MP4Integer8Property("contentIdType")); + AddProperty( /* 7 */ + new MP4BytesProperty("contentId")); +} + +void MP4ContentIdDescriptor::Read(MP4File* pFile) +{ + ReadHeader(pFile); + + /* read the first property, 'compatiblity' */ + ReadProperties(pFile, 0, 1); + + /* if compatiblity != 0 */ + if (((MP4Integer8Property*)m_pProperties[0])->GetValue() != 0) { + /* we don't understand it */ + VERBOSE_READ(pFile->GetVerbosity(), + printf("incompatible content id descriptor\n")); + return; + } + + /* read the next four properties */ + ReadProperties(pFile, 1, 4); + + /* which allows us to reconfigure ourselves */ + Mutate(); + + bool contentTypeFlag = ((MP4BitfieldProperty*)m_pProperties[1])->GetValue(); + + bool contentIdFlag = ((MP4BitfieldProperty*)m_pProperties[2])->GetValue(); + + if (contentIdFlag) { + + uint32_t cIdOffset = 2; + + if (contentTypeFlag) { + + cIdOffset++; + + } + + ((MP4BytesProperty*)m_pProperties[7])->SetValueSize(m_size - cIdOffset); + + } + + + + /* read the remaining properties */ + ReadProperties(pFile, 5); +} + +void MP4ContentIdDescriptor::Mutate() +{ + bool contentTypeFlag = ((MP4BitfieldProperty*)m_pProperties[1])->GetValue(); + m_pProperties[5]->SetImplicit(!contentTypeFlag); + + bool contentIdFlag = ((MP4BitfieldProperty*)m_pProperties[2])->GetValue(); + m_pProperties[6]->SetImplicit(!contentIdFlag); + m_pProperties[7]->SetImplicit(!contentIdFlag); + +} + +MP4Descriptor* MP4DescriptorProperty::CreateDescriptor(uint8_t tag) +{ + MP4Descriptor* pDescriptor = NULL; + + switch (tag) { + case MP4ESDescrTag: + pDescriptor = new MP4ESDescriptor(); + break; + case MP4DecConfigDescrTag: + pDescriptor = new MP4DecConfigDescriptor(); + break; + case MP4DecSpecificDescrTag: + case MP4IPMPDescrTag: + case MP4RegistrationDescrTag: + pDescriptor = new MP4BytesDescriptor(tag); + break; + case MP4SLConfigDescrTag: + pDescriptor = new MP4SLConfigDescriptor(); + break; + case MP4ContentIdDescrTag: + pDescriptor = new MP4ContentIdDescriptor(); + break; + case MP4ESIDIncDescrTag: + case MP4ESIDRefDescrTag: + case MP4IPIPtrDescrTag: + case MP4SupplContentIdDescrTag: + case MP4IPMPPtrDescrTag: + case MP4ExtProfileLevelDescrTag: + pDescriptor = new MP4BaseDescriptor(tag); + break; + case MP4QosDescrTag: + pDescriptor = new MP4QosDescriptorBase(MP4QosDescrTag); + break; + case MP4IODescrTag: + case MP4FileIODescrTag: + pDescriptor = new MP4IODescriptor(); + pDescriptor->SetTag(tag); + break; + case MP4ODescrTag: + case MP4FileODescrTag: + pDescriptor = new MP4ODescriptor(); + pDescriptor->SetTag(tag); + break; + } + + if (pDescriptor == NULL) { + if (tag >= MP4OCIDescrTagsStart && tag <= MP4OCIDescrTagsEnd) { + pDescriptor = CreateOCIDescriptor(tag); + } + + if (tag >= MP4ExtDescrTagsStart && tag <= MP4ExtDescrTagsEnd) { + pDescriptor = new MP4BytesDescriptor(tag); + } + } + + return pDescriptor; +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/descriptors.h b/src/descriptors.h new file mode 100644 index 0000000..117ab13 --- /dev/null +++ b/src/descriptors.h @@ -0,0 +1,140 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + */ + +#ifndef MP4V2_IMPL_DESCRIPTORS_H +#define MP4V2_IMPL_DESCRIPTORS_H + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +const uint8_t MP4ODescrTag = 0x01; +const uint8_t MP4IODescrTag = 0x02; +const uint8_t MP4ESDescrTag = 0x03; +const uint8_t MP4DecConfigDescrTag = 0x04; +const uint8_t MP4DecSpecificDescrTag = 0x05; +const uint8_t MP4SLConfigDescrTag = 0x06; +const uint8_t MP4ContentIdDescrTag = 0x07; +const uint8_t MP4SupplContentIdDescrTag = 0x08; +const uint8_t MP4IPIPtrDescrTag = 0x09; +const uint8_t MP4IPMPPtrDescrTag = 0x0A; +const uint8_t MP4IPMPDescrTag = 0x0B; +const uint8_t MP4RegistrationDescrTag = 0x0D; +const uint8_t MP4ESIDIncDescrTag = 0x0E; +const uint8_t MP4ESIDRefDescrTag = 0x0F; +const uint8_t MP4FileIODescrTag = 0x10; +const uint8_t MP4FileODescrTag = 0x11; +const uint8_t MP4ExtProfileLevelDescrTag = 0x13; +const uint8_t MP4ExtDescrTagsStart = 0x80; +const uint8_t MP4ExtDescrTagsEnd = 0xFE; + +class MP4BaseDescriptor : public MP4Descriptor { +public: + MP4BaseDescriptor(uint8_t tag); +}; + +class MP4BytesDescriptor : public MP4Descriptor { +public: + MP4BytesDescriptor(uint8_t tag); + void Read(MP4File* pFile); +protected: + uint32_t m_size_offset; // size to adjust the size for the bytes property + uint32_t m_bytes_index; // index into properties for bytes property +}; + +class MP4IODescriptor : public MP4Descriptor { +public: + MP4IODescriptor(); + void Generate(); +protected: + void Mutate(); +}; + +class MP4ODescriptor : public MP4Descriptor { +public: + MP4ODescriptor(); + void Generate(); +protected: + void Mutate(); +}; + + +class MP4ESDescriptor : public MP4Descriptor { +public: + MP4ESDescriptor(); +protected: + void Mutate(); +}; + +class MP4DecConfigDescriptor : public MP4Descriptor { +public: + MP4DecConfigDescriptor(); + void Generate(); +}; + + +class MP4SLConfigDescriptor : public MP4Descriptor { +public: + MP4SLConfigDescriptor(); + void Generate(); + void Read(MP4File* pFile); +protected: + void Mutate(); +}; + +class MP4IPIPtrDescriptor : public MP4Descriptor { +public: + MP4IPIPtrDescriptor(); +}; + +class MP4ContentIdDescriptor : public MP4Descriptor { +public: + MP4ContentIdDescriptor(); + void Read(MP4File* pFile); +protected: + void Mutate(); +}; + +// associated values in descriptors + +// ES objectTypeId +const uint8_t MP4SystemsV1ObjectType = 0x01; +const uint8_t MP4SystemsV2ObjectType = 0x02; + +// ES streamType +const uint8_t MP4ObjectDescriptionStreamType = 0x01; +const uint8_t MP4ClockReferenceStreamType = 0x02; +const uint8_t MP4SceneDescriptionStreamType = 0x03; +const uint8_t MP4VisualStreamType = 0x04; +const uint8_t MP4AudioStreamType = 0x05; +const uint8_t MP4Mpeg7StreamType = 0x06; +const uint8_t MP4IPMPStreamType = 0x07; +const uint8_t MP4OCIStreamType = 0x08; +const uint8_t MP4MPEGJStreamType = 0x09; +const uint8_t MP4UserPrivateStreamType = 0x20; + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl + +#endif // MP4V2_IMPL_DESCRIPTORS_H diff --git a/src/enum.h b/src/enum.h new file mode 100644 index 0000000..af5b6d4 --- /dev/null +++ b/src/enum.h @@ -0,0 +1,110 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is MP4v2. +// +// The Initial Developer of the Original Code is Kona Blend. +// Portions created by Kona Blend are Copyright (C) 2008. +// All Rights Reserved. +// +// Contributors: +// Kona Blend, kona8lend@@gmail.com +// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef MP4V2_IMPL_ENUM_H +#define MP4V2_IMPL_ENUM_H + +namespace mp4v2 { namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +/// class Template to support enums with to/from string conversions. +/// +/// This class template is meant only to add support for enums which have +/// useful string equivalents. The model is that each enum value has +/// two string equivalents: compact and formal. <b>compact</b> is a short, +/// compact string which usually excludes spaces and punctuation and makes it +/// suitable for use with command-line arguments or any situation where +/// superfluous characters make parsing needlessly complicated. <b>formal</b> +/// is a string suitable for use in human-readable situations where spaces, +/// punctuation and even case is desirable. +/// +/// For end usability, enums will have the full list of enums available +/// which is suitable for help-usage scenerios. And all values will be +/// convertable from enum to string, or from string to enum. When converting +/// from enum to string, you may optionally specify a boolean value which +/// will return the <b>formal</b> string value; otherwise a <b>compact</b> +/// value is returned. +/// +/// Conversion from string to enum (integral) value will always assume +/// <b>compact</b> string is used as it makes little sense to convert formal +/// strings to enum. Furthermore, the string conversion is optimized to +/// ignore case, and in the case an exact full-string match is not found, +/// a <b>best-match</b> is then checked for. Basically this means that if +/// enough beginning characters are used to match exactly 1 string-enum, +/// it is considered a match. +/// +/// The template has 2 strict requirements. First, the enum must be a true +/// enum type; ie: not just some integer constants. Second, the enum must have +/// a value which indicates an undefined or illegal value; which is used as +/// a return value by string-to-enum conversion to indicate the string did +/// not match. +/// +/// This template implementation itself should never be exposed. That is +/// to say, the .tcc file must not be used by code outside this library. +/// +/// WARNING: since enum types are typically made static file scope, +/// care must be taken to make sure Entry data[] initialization occurs +/// in the <b>same file</b> and <b>before</b> instantiation. +/// +template <typename T, T UNDEFINED> +class Enum +{ +public: + struct MP4V2_EXPORT Entry + { + T type; + const string compact; + const string formal; + }; + + typedef map<string,const Entry*,LessIgnoreCase> MapToType; + typedef map<T,const Entry*> MapToString; + +public: + static const Entry data[]; + +private: + MapToType _mapToType; + MapToString _mapToString; + +public: + const MapToType& mapToType; + const MapToString& mapToString; + +public: + Enum(); + ~Enum(); + + T toType ( const string& ) const; + string toString ( T, bool = false ) const; + string& toString ( T, string&, bool = false ) const; +}; + +/////////////////////////////////////////////////////////////////////////////// + +}} // namespace mp4v2::impl + +#include "enum.tcc" + +#endif // MP4V2_IMPL_ENUM_H diff --git a/src/enum.tcc b/src/enum.tcc new file mode 100644 index 0000000..1f3395a --- /dev/null +++ b/src/enum.tcc @@ -0,0 +1,121 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is MP4v2. +// +// The Initial Developer of the Original Code is Kona Blend. +// Portions created by Kona Blend are Copyright (C) 2008. +// All Rights Reserved. +// +// Contributors: +// Kona Blend, kona8lend@@gmail.com +// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef MP4V2_IMPL_ENUM_TCC +#define MP4V2_IMPL_ENUM_TCC + +#include <sstream> + +namespace mp4v2 { namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +template <typename T, T UNDEFINED> +Enum<T,UNDEFINED>::Enum() + : mapToType ( _mapToType ) + , mapToString ( _mapToString ) +{ + for( const Entry* p = data; p->type != UNDEFINED; p++ ) { + _mapToType.insert( typename MapToType::value_type( p->compact, p )); + _mapToString.insert( typename MapToString::value_type( p->type, p )); + } +} + +////////////////////////////////////////////////////////////////////////////// + +template <typename T, T UNDEFINED> +Enum<T,UNDEFINED>::~Enum() +{ +} + +////////////////////////////////////////////////////////////////////////////// + +template <typename T, T UNDEFINED> +string +Enum<T,UNDEFINED>::toString( T value, bool formal ) const +{ + string buffer; + return toString( value, buffer, formal ); +} + +////////////////////////////////////////////////////////////////////////////// + +template <typename T, T UNDEFINED> +string& +Enum<T,UNDEFINED>::toString( T value, string& buffer, bool formal ) const +{ + const typename MapToString::const_iterator found = _mapToString.find( value ); + if( found != _mapToString.end() ) { + const Entry& entry = *(found->second); + buffer = formal ? entry.formal : entry.compact; + return buffer; + } + + ostringstream oss; + oss << "UNDEFINED(" << value << ")"; + buffer = oss.str(); + return buffer; +} + +////////////////////////////////////////////////////////////////////////////// + +template <typename T, T UNDEFINED> +T +Enum<T,UNDEFINED>::toType( const string& value ) const +{ + // if number perform enum lookup + int ivalue; + istringstream iss( value ); + iss >> ivalue; + if( iss.rdstate() == ios::eofbit ) { + const typename MapToString::const_iterator found = _mapToString.find( static_cast<T>(ivalue) ); + if( found != _mapToString.end() ) + return found->second->type; + } + + // exact match + const typename MapToType::const_iterator found = _mapToType.find( value ); + if( found != _mapToType.end() ) + return found->second->type; + + // partial match + int matches = 0; + T matched = static_cast<T>( 0 ); + + const typename MapToType::const_iterator ie = _mapToType.end(); + for( typename MapToType::const_iterator it = _mapToType.begin(); it != ie; it++ ) { + const Entry& entry = *(it->second); + if( entry.compact.find( value ) == 0 ) { + matches++; + matched = entry.type; + } + } + + return (matches == 1) ? matched : UNDEFINED; +} + +////////////////////////////////////////////////////////////////////////////// + +}} // namespace mp4v2::impl + +#endif // MP4V2_IMPL_ENUM_TCC diff --git a/src/exception.cpp b/src/exception.cpp new file mode 100644 index 0000000..aed950f --- /dev/null +++ b/src/exception.cpp @@ -0,0 +1,52 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is MP4v2. +// +// The Initial Developer of the Original Code is Kona Blend. +// Portions created by Kona Blend are Copyright (C) 2008. +// All Rights Reserved. +// +// Contributors: +// Kona Blend, kona8lend@@gmail.com +// +/////////////////////////////////////////////////////////////////////////////// + +#include "src/impl.h" + +namespace mp4v2 { namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4Exception::MP4Exception( const string& what_ ) + : _what ( what_ ) + , what ( _what ) +{ +} + +/////////////////////////////////////////////////////////////////////////////// + +MP4Exception::MP4Exception( const ostringstream& what_ ) + : _what ( what_.str() ) + , what ( _what ) +{ +} + +/////////////////////////////////////////////////////////////////////////////// + +MP4Exception::~MP4Exception() +{ +} + +/////////////////////////////////////////////////////////////////////////////// + +}} // namespace mp4v2::impl diff --git a/src/exception.h b/src/exception.h new file mode 100644 index 0000000..b98f9d9 --- /dev/null +++ b/src/exception.h @@ -0,0 +1,49 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is MP4v2. +// +// The Initial Developer of the Original Code is Kona Blend. +// Portions created by Kona Blend are Copyright (C) 2008. +// All Rights Reserved. +// +// Contributors: +// Kona Blend, kona8lend@@gmail.com +// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef MP4V2_IMPL_MP4EXCEPTION_H +#define MP4V2_IMPL_MP4EXCEPTION_H + +namespace mp4v2 { namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +class MP4V2_EXPORT MP4Exception +{ +protected: + string _what; + +public: + const string& what; + +public: + explicit MP4Exception( const string& what ); + explicit MP4Exception( const ostringstream& what ); + ~MP4Exception(); +}; + +/////////////////////////////////////////////////////////////////////////////// + +}} // namespace mp4v2::impl + +#endif // MP4V2_IMPL_MP4EXCEPTION_H diff --git a/src/impl.h b/src/impl.h new file mode 100644 index 0000000..f35e3fe --- /dev/null +++ b/src/impl.h @@ -0,0 +1,10 @@ +#ifndef MP4V2_IMPL_IMPL_H +#define MP4V2_IMPL_IMPL_H + +/////////////////////////////////////////////////////////////////////////////// + +#include "src.h" + +/////////////////////////////////////////////////////////////////////////////// + +#endif // MP4V2_IMPL_IMPL_H diff --git a/src/isma.cpp b/src/isma.cpp new file mode 100644 index 0000000..9420e30 --- /dev/null +++ b/src/isma.cpp @@ -0,0 +1,951 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001 - 2004. All Rights Reserved. + * + * 3GPP features implementation is based on 3GPP's TS26.234-v5.60, + * and was contributed by Ximpo Group Ltd. + * + * Portions created by Ximpo Group Ltd. are + * Copyright (C) Ximpo Group Ltd. 2003, 2004. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + * Alix Marchandise-Franquet alix@cisco.com + * Ximpo Group Ltd. mp4v2@ximpo.com + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +static const uint8_t BifsV2Config[3] = { + 0x00, 0x00, 0x60 // IsCommandStream = 1, PixelMetric = 1 +}; + +void MP4File::MakeIsmaCompliant(bool addIsmaComplianceSdp) +{ + ProtectWriteOperation("MP4MakeIsmaCompliant"); + + if (m_useIsma) { + // already done + return; + } + + // find first audio and/or video tracks + + MP4TrackId audioTrackId = MP4_INVALID_TRACK_ID; + try { + audioTrackId = FindTrackId(0, MP4_AUDIO_TRACK_TYPE); + } + catch (MP4Error* e) { + delete e; + } + + MP4TrackId videoTrackId = MP4_INVALID_TRACK_ID; + try { + videoTrackId = FindTrackId(0, MP4_VIDEO_TRACK_TYPE); + } + catch (MP4Error* e) { + delete e; + } + if (audioTrackId == MP4_INVALID_TRACK_ID && + videoTrackId == MP4_INVALID_TRACK_ID) return; + + const char *audio_media_data_name, *video_media_data_name; + uint8_t videoProfile = 0xff; + if (audioTrackId != MP4_INVALID_TRACK_ID) { + audio_media_data_name = MP4GetTrackMediaDataName(this, audioTrackId); + if (!(ATOMID(audio_media_data_name) == ATOMID("mp4a") || + ATOMID(audio_media_data_name) == ATOMID("enca"))) { + VERBOSE_ERROR(m_verbosity, + printf("MakeIsmaCompliant:can't make ISMA compliant when file contains an %s track\n", audio_media_data_name); + ); + return; + } + } + // + // Note - might have to check for avc1 here... + if (videoTrackId != MP4_INVALID_TRACK_ID) { + video_media_data_name = MP4GetTrackMediaDataName(this, videoTrackId); + if (!(ATOMID(video_media_data_name) == ATOMID("mp4v") || + ATOMID(video_media_data_name) == ATOMID("encv"))) { + VERBOSE_ERROR(m_verbosity, + printf("MakeIsmaCompliant:can't make ISMA compliant when file contains an %s track\n", video_media_data_name); + ); + return; + } + uint32_t verb = GetVerbosity(); + SetVerbosity(verb & ~MP4_DETAILS_ERROR); + videoProfile = MP4GetVideoProfileLevel(this, videoTrackId); + SetVerbosity(verb); + } + + m_useIsma = true; + + uint64_t fileMsDuration = 0; + fileMsDuration = + ConvertFromMovieDuration(GetDuration(), MP4_MSECS_TIME_SCALE); + + // delete any existing OD track + if (m_odTrackId != MP4_INVALID_TRACK_ID) { + DeleteTrack(m_odTrackId); + } + + if (m_pRootAtom->FindAtom("moov.iods") == NULL) { + (void)AddChildAtom("moov", "iods"); + } + (void)AddODTrack(); + SetODProfileLevel(0xFF); + + if (audioTrackId != MP4_INVALID_TRACK_ID) { + AddTrackToOd(audioTrackId); + MP4SetAudioProfileLevel(this, 0xf); + } + if (videoTrackId != MP4_INVALID_TRACK_ID) { + AddTrackToOd(videoTrackId); + MP4SetVideoProfileLevel(this, videoProfile); + } + + // delete any existing scene track + MP4TrackId sceneTrackId = MP4_INVALID_TRACK_ID; + try { + sceneTrackId = FindTrackId(0, MP4_SCENE_TRACK_TYPE); + } + catch (MP4Error *e) { + delete e; + } + if (sceneTrackId != MP4_INVALID_TRACK_ID) { + DeleteTrack(sceneTrackId); + } + + // add scene track + sceneTrackId = AddSceneTrack(); + SetSceneProfileLevel(0xFF); + SetGraphicsProfileLevel(0xFF); + SetTrackIntegerProperty(sceneTrackId, + "mdia.minf.stbl.stsd.mp4s.esds.decConfigDescr.objectTypeId", + MP4SystemsV2ObjectType); + + SetTrackESConfiguration(sceneTrackId, + BifsV2Config, sizeof(BifsV2Config)); + + uint8_t* pBytes = NULL; + uint64_t numBytes = 0; + + // write OD Update Command + CreateIsmaODUpdateCommandFromFileForFile( + m_odTrackId, + audioTrackId, + videoTrackId, + &pBytes, + &numBytes); + + WriteSample(m_odTrackId, pBytes, numBytes, fileMsDuration); + + MP4Free(pBytes); + pBytes = NULL; + + // write BIFS Scene Replace Command + CreateIsmaSceneCommand( + MP4_IS_VALID_TRACK_ID(audioTrackId), + MP4_IS_VALID_TRACK_ID(videoTrackId), + &pBytes, + &numBytes); + + WriteSample(sceneTrackId, pBytes, numBytes, fileMsDuration); + + MP4Free(pBytes); + pBytes = NULL; + + // add session level sdp + CreateIsmaIodFromFile( + m_odTrackId, + sceneTrackId, + audioTrackId, + videoTrackId, + &pBytes, + &numBytes); + + char* iodBase64 = MP4ToBase64(pBytes, numBytes); + + uint32_t sdpBufLen = strlen(iodBase64) + 256; + uint32_t used; + char* sdpBuf = (char*)MP4Calloc(sdpBufLen); + + if (addIsmaComplianceSdp) { + strncpy(sdpBuf, "a=isma-compliance:1,1.0,1\015\012", sdpBufLen); + } + + used = strlen(sdpBuf); + sdpBufLen -= used; + snprintf(&sdpBuf[used], sdpBufLen, + "a=mpeg4-iod: \042data:application/mpeg4-iod;base64,%s\042\015\012", + iodBase64); + + SetSessionSdp(sdpBuf); + + VERBOSE_ISMA(GetVerbosity(), + printf("IOD SDP = %s\n", sdpBuf)); + + MP4Free(iodBase64); + iodBase64 = NULL; + MP4Free(pBytes); + pBytes = NULL; + MP4Free(sdpBuf); + sdpBuf = NULL; +} + +static void CloneIntegerProperty( + MP4Descriptor* pDest, + MP4DescriptorProperty* pSrc, + const char* name) +{ + MP4IntegerProperty* pGetProperty; + MP4IntegerProperty* pSetProperty; + + if (!pSrc->FindProperty(name, (MP4Property**)&pGetProperty)) return; + if (!pDest->FindProperty(name, (MP4Property**)&pSetProperty)) return; + pSetProperty->SetValue(pGetProperty->GetValue()); +} + +void MP4File::CreateIsmaIodFromFile( + MP4TrackId odTrackId, + MP4TrackId sceneTrackId, + MP4TrackId audioTrackId, + MP4TrackId videoTrackId, + uint8_t** ppBytes, + uint64_t* pNumBytes) +{ + MP4Descriptor* pIod = new MP4IODescriptor(); + pIod->SetTag(MP4IODescrTag); + pIod->Generate(); + + MP4Atom* pIodsAtom = FindAtom("moov.iods"); + ASSERT(pIodsAtom); + MP4DescriptorProperty* pSrcIod = + (MP4DescriptorProperty*)pIodsAtom->GetProperty(2); + + CloneIntegerProperty(pIod, pSrcIod, "objectDescriptorId"); + CloneIntegerProperty(pIod, pSrcIod, "ODProfileLevelId"); + CloneIntegerProperty(pIod, pSrcIod, "sceneProfileLevelId"); + CloneIntegerProperty(pIod, pSrcIod, "audioProfileLevelId"); + CloneIntegerProperty(pIod, pSrcIod, "visualProfileLevelId"); + CloneIntegerProperty(pIod, pSrcIod, "graphicsProfileLevelId"); + + // mutate esIds from MP4ESIDIncDescrTag to MP4ESDescrTag + MP4DescriptorProperty* pEsProperty; + if (!pIod->FindProperty("esIds", (MP4Property**)&pEsProperty)) return; + pEsProperty->SetTags(MP4ESDescrTag); + + MP4IntegerProperty* pSetProperty; + MP4IntegerProperty* pSceneESID; + MP4IntegerProperty* pOdESID; + + // OD + MP4Descriptor* pOdEsd = + pEsProperty->AddDescriptor(MP4ESDescrTag); + pOdEsd->Generate(); + + if (!pOdEsd->FindProperty("ESID", (MP4Property**)&pOdESID)) return; + + // we set the OD ESID to a non-zero unique value + pOdESID->SetValue(m_odTrackId); + + if (pOdEsd->FindProperty("URLFlag", + (MP4Property**)&pSetProperty)) + pSetProperty->SetValue(1); + + uint8_t* pBytes; + uint64_t numBytes; + + CreateIsmaODUpdateCommandFromFileForStream( + audioTrackId, + videoTrackId, + &pBytes, + &numBytes); + + VERBOSE_ISMA(GetVerbosity(), + printf("OD data =\n"); MP4HexDump(pBytes, numBytes)); + + char* odCmdBase64 = MP4ToBase64(pBytes, numBytes); + + uint32_t urlBufLen = strlen(odCmdBase64) + 64; + char* urlBuf = (char*)MP4Malloc(urlBufLen); + + snprintf(urlBuf, urlBufLen, + "data:application/mpeg4-od-au;base64,%s", + odCmdBase64); + + MP4StringProperty* pUrlProperty; + if (pOdEsd->FindProperty("URL", + (MP4Property**)&pUrlProperty)) + pUrlProperty->SetValue(urlBuf); + + VERBOSE_ISMA(GetVerbosity(), + printf("OD data URL = \042%s\042\n", urlBuf)); + + MP4Free(odCmdBase64); + odCmdBase64 = NULL; + MP4Free(pBytes); + pBytes = NULL; + MP4Free(urlBuf); + urlBuf = NULL; + + MP4DescriptorProperty* pSrcDcd = NULL; + + // HACK temporarily point to scene decoder config + (void)FindProperty(MakeTrackName(odTrackId, + "mdia.minf.stbl.stsd.mp4s.esds.decConfigDescr"), + (MP4Property**)&pSrcDcd); + ASSERT(pSrcDcd); + MP4Property* pOrgOdEsdProperty = + pOdEsd->GetProperty(8); + pOdEsd->SetProperty(8, pSrcDcd); + + // bufferSizeDB needs to be set appropriately + MP4BitfieldProperty* pBufferSizeProperty = NULL; + if (pOdEsd->FindProperty("decConfigDescr.bufferSizeDB", + (MP4Property**)&pBufferSizeProperty)) { + ASSERT(pBufferSizeProperty); + pBufferSizeProperty->SetValue(numBytes); + } + + // SL config needs to change from 2 (file) to 1 (null) + if (pOdEsd->FindProperty("slConfigDescr.predefined", + (MP4Property**)&pSetProperty)) + pSetProperty->SetValue(1); + + + // Scene + MP4Descriptor* pSceneEsd = + pEsProperty->AddDescriptor(MP4ESDescrTag); + pSceneEsd->Generate(); + + if (pSceneEsd->FindProperty("ESID", + (MP4Property**)&pSceneESID)) { + // we set the Scene ESID to a non-zero unique value + pSceneESID->SetValue(sceneTrackId); + } + + if (pSceneEsd->FindProperty("URLFlag", + (MP4Property**)&pSetProperty)) + pSetProperty->SetValue(1); + + CreateIsmaSceneCommand( + MP4_IS_VALID_TRACK_ID(audioTrackId), + MP4_IS_VALID_TRACK_ID(videoTrackId), + &pBytes, + &numBytes); + + VERBOSE_ISMA(GetVerbosity(), + printf("Scene data =\n"); MP4HexDump(pBytes, numBytes)); + + char *sceneCmdBase64 = MP4ToBase64(pBytes, numBytes); + + urlBuf = (char*)MP4Malloc(strlen(sceneCmdBase64) + 64); + snprintf(urlBuf, strlen(sceneCmdBase64) + 64, + "data:application/mpeg4-bifs-au;base64,%s", + sceneCmdBase64); + + if (pSceneEsd->FindProperty("URL", + (MP4Property**)&pUrlProperty)) + pUrlProperty->SetValue(urlBuf); + + VERBOSE_ISMA(GetVerbosity(), + printf("Scene data URL = \042%s\042\n", urlBuf)); + + MP4Free(sceneCmdBase64); + sceneCmdBase64 = NULL; + MP4Free(urlBuf); + urlBuf = NULL; + MP4Free(pBytes); + pBytes = NULL; + + // HACK temporarily point to scene decoder config + ASSERT(FindProperty(MakeTrackName(sceneTrackId, + "mdia.minf.stbl.stsd.mp4s.esds.decConfigDescr"), + (MP4Property**)&pSrcDcd)); + ASSERT(pSrcDcd); + MP4Property* pOrgSceneEsdProperty = + pSceneEsd->GetProperty(8); + pSceneEsd->SetProperty(8, pSrcDcd); + + // bufferSizeDB needs to be set + pBufferSizeProperty = NULL; + if (pSceneEsd->FindProperty("decConfigDescr.bufferSizeDB", + (MP4Property**)&pBufferSizeProperty)) { + ASSERT(pBufferSizeProperty); + pBufferSizeProperty->SetValue(numBytes); + } + + // SL config needs to change from 2 (file) to 1 (null) + if (pSceneEsd->FindProperty("slConfigDescr.predefined", + (MP4Property**)&pSetProperty)) + pSetProperty->SetValue(1); + + + // finally get the whole thing written to a memory + pIod->WriteToMemory(this, ppBytes, pNumBytes); + + + // now carefully replace esd properties before destroying + pOdEsd->SetProperty(8, pOrgOdEsdProperty); + pSceneEsd->SetProperty(8, pOrgSceneEsdProperty); + pSceneESID->SetValue(0); // restore 0 value + pOdESID->SetValue(0); + + delete pIod; + + VERBOSE_ISMA(GetVerbosity(), + printf("IOD data =\n"); MP4HexDump(*ppBytes, *pNumBytes)); +} + +void MP4File::CreateIsmaIodFromParams( + uint8_t videoProfile, + uint32_t videoBitrate, + uint8_t* videoConfig, + uint32_t videoConfigLength, + uint8_t audioProfile, + uint32_t audioBitrate, + uint8_t* audioConfig, + uint32_t audioConfigLength, + uint8_t** ppIodBytes, + uint64_t* pIodNumBytes) +{ + MP4IntegerProperty* pInt; + uint8_t* pBytes = NULL; + uint64_t numBytes; + + // Create the IOD + MP4Descriptor* pIod = new MP4IODescriptor(); + pIod->SetTag(MP4IODescrTag); + pIod->Generate(); + + // Set audio and video profileLevels + if (pIod->FindProperty("audioProfileLevelId", + (MP4Property**)&pInt)) + pInt->SetValue(audioProfile); + + if (pIod->FindProperty("visualProfileLevelId", + (MP4Property**)&pInt)) + pInt->SetValue(videoProfile); + + // Mutate esIds from MP4ESIDIncDescrTag to MP4ESDescrTag + MP4DescriptorProperty* pEsProperty; + if (!pIod->FindProperty("esIds", (MP4Property**)&pEsProperty)) return; + pEsProperty->SetTags(MP4ESDescrTag); + + // Add ES Descriptors + + // Scene + CreateIsmaSceneCommand( + (audioProfile != 0xFF), + (videoProfile != 0xFF), + &pBytes, + &numBytes); + + VERBOSE_ISMA(GetVerbosity(), + printf("Scene data =\n"); MP4HexDump(pBytes, numBytes)); + + char* sceneCmdBase64 = MP4ToBase64(pBytes, numBytes); + + char* urlBuf = + (char*)MP4Malloc(strlen(sceneCmdBase64) + 64); + snprintf(urlBuf, strlen(sceneCmdBase64) + 64, + "data:application/mpeg4-bifs-au;base64,%s", + sceneCmdBase64); + + VERBOSE_ISMA(GetVerbosity(), + printf("Scene data URL = \042%s\042\n", urlBuf)); + + /* MP4Descriptor* pSceneEsd = */ + CreateESD( + pEsProperty, + 201, // esid + MP4SystemsV2ObjectType, + MP4SceneDescriptionStreamType, + numBytes, // bufferSize + numBytes * 8, // bitrate + BifsV2Config, + sizeof(BifsV2Config), + urlBuf); + MP4Free(urlBuf); + urlBuf = NULL; + + MP4Free(sceneCmdBase64); + sceneCmdBase64 = NULL; + MP4Free(pBytes); + pBytes = NULL; + + // OD + + // Video + MP4DescriptorProperty* pVideoEsdProperty = + new MP4DescriptorProperty(); + pVideoEsdProperty->SetTags(MP4ESDescrTag); + + /* MP4Descriptor* pVideoEsd = */ + CreateESD( + pVideoEsdProperty, + 20, // esid + MP4_MPEG4_VIDEO_TYPE, + MP4VisualStreamType, + videoBitrate / 8, // bufferSize + videoBitrate, + videoConfig, + videoConfigLength, + NULL); + + // Audio + MP4DescriptorProperty* pAudioEsdProperty = + new MP4DescriptorProperty(); + pAudioEsdProperty->SetTags(MP4ESDescrTag); + + /* MP4Descriptor* pAudioEsd = */ + CreateESD( + pAudioEsdProperty, + 10, // esid + MP4_MPEG4_AUDIO_TYPE, + MP4AudioStreamType, + audioBitrate / 8, // bufferSize + audioBitrate, + audioConfig, + audioConfigLength, + NULL); + + CreateIsmaODUpdateCommandForStream( + pAudioEsdProperty, + pVideoEsdProperty, + &pBytes, + &numBytes); + + // cleanup temporary descriptor properties + delete pAudioEsdProperty; + delete pVideoEsdProperty; + + VERBOSE_ISMA(GetVerbosity(), + printf("OD data = %" PRIu64 " bytes\n", numBytes); MP4HexDump(pBytes, numBytes)); + + char* odCmdBase64 = MP4ToBase64(pBytes, numBytes); + + urlBuf = (char*)MP4Malloc(strlen(odCmdBase64) + 64); + if (urlBuf != NULL) { + snprintf(urlBuf, strlen(odCmdBase64) + 64, + "data:application/mpeg4-od-au;base64,%s", + odCmdBase64); + + VERBOSE_ISMA(GetVerbosity(), + printf("OD data URL = \042%s\042\n", urlBuf)); + + /* MP4Descriptor* pOdEsd = */ + CreateESD( + pEsProperty, + 101, + MP4SystemsV1ObjectType, + MP4ObjectDescriptionStreamType, + numBytes, // bufferSize + numBytes * 8, // bitrate + NULL, // config + 0, // configLength + urlBuf); + + MP4Free(urlBuf); + urlBuf = NULL; + } + MP4Free(odCmdBase64); + odCmdBase64 = NULL; + MP4Free(pBytes); + pBytes = NULL; + + // finally get the whole thing written to a memory + pIod->WriteToMemory(this, ppIodBytes, pIodNumBytes); + + delete pIod; + + VERBOSE_ISMA(GetVerbosity(), + printf("IOD data =\n"); MP4HexDump(*ppIodBytes, *pIodNumBytes)); +} + +void MP4File::CreateESD( + MP4DescriptorProperty* pEsProperty, + uint32_t esid, + uint8_t objectType, + uint8_t streamType, + uint32_t bufferSize, + uint32_t bitrate, + const uint8_t* pConfig, + uint32_t configLength, + char* url) +{ + MP4IntegerProperty* pInt; + MP4StringProperty* pString; + MP4BytesProperty* pBytes; + MP4BitfieldProperty* pBits; + + MP4Descriptor* pEsd = + pEsProperty->AddDescriptor(MP4ESDescrTag); + pEsd->Generate(); + + if (pEsd->FindProperty("ESID", + (MP4Property**)&pInt)) + pInt->SetValue(esid); + + if (pEsd->FindProperty("decConfigDescr.objectTypeId", + (MP4Property**)&pInt)) + pInt->SetValue(objectType); + + if (pEsd->FindProperty("decConfigDescr.streamType", + (MP4Property**)&pInt)) + pInt->SetValue(streamType); + + if (pEsd->FindProperty("decConfigDescr.bufferSizeDB", + (MP4Property**)&pInt)) + pInt->SetValue(bufferSize); + + if (pEsd->FindProperty("decConfigDescr.maxBitrate", + (MP4Property**)&pInt)) + pInt->SetValue(bitrate); + + if (pEsd->FindProperty("decConfigDescr.avgBitrate", + (MP4Property**)&pInt)) + pInt->SetValue(bitrate); + + MP4DescriptorProperty* pConfigDescrProperty; + if (pEsd->FindProperty("decConfigDescr.decSpecificInfo", + (MP4Property**)&pConfigDescrProperty)) { + + MP4Descriptor* pConfigDescr = + pConfigDescrProperty->AddDescriptor(MP4DecSpecificDescrTag); + pConfigDescr->Generate(); + + if (pConfigDescrProperty->FindProperty("decSpecificInfo[0].info", + (MP4Property**)&pBytes)) + pBytes->SetValue(pConfig, configLength); + } + + if (pEsd->FindProperty("slConfigDescr.predefined", + (MP4Property**)&pInt)) + // changed 12/5/02 from plugfest to value 0 + pInt->SetValue(0); + + if (pEsd->FindProperty("slConfig.useAccessUnitEndFlag", + (MP4Property **)&pBits)) + pBits->SetValue(1); + + if (url) { + if (pEsd->FindProperty("URLFlag", + (MP4Property**)&pInt)) + pInt->SetValue(1); + + if (pEsd->FindProperty("URL", + (MP4Property**)&pString)) + pString->SetValue(url); + } + + //return pEsd; +} + +void MP4File::CreateIsmaODUpdateCommandFromFileForFile( + MP4TrackId odTrackId, + MP4TrackId audioTrackId, + MP4TrackId videoTrackId, + uint8_t** ppBytes, + uint64_t* pNumBytes) +{ + MP4Descriptor* pCommand = CreateODCommand(MP4ODUpdateODCommandTag); + pCommand->Generate(); + + for (uint8_t i = 0; i < 2; i++) { + MP4TrackId trackId; + uint16_t odId; + + if (i == 0) { + trackId = audioTrackId; + odId = 10; + } else { + trackId = videoTrackId; + odId = 20; + } + + if (trackId == MP4_INVALID_TRACK_ID) { + continue; + } + + MP4DescriptorProperty* pOdDescrProperty = + (MP4DescriptorProperty*)(pCommand->GetProperty(0)); + + pOdDescrProperty->SetTags(MP4FileODescrTag); + + MP4Descriptor* pOd = + pOdDescrProperty->AddDescriptor(MP4FileODescrTag); + + pOd->Generate(); + + MP4BitfieldProperty* pOdIdProperty = NULL; + if (pOd->FindProperty("objectDescriptorId", + (MP4Property**)&pOdIdProperty)) + pOdIdProperty->SetValue(odId); + + MP4DescriptorProperty* pEsIdsDescriptorProperty = NULL; + ASSERT(pOd->FindProperty("esIds", + (MP4Property**)&pEsIdsDescriptorProperty)); + ASSERT(pEsIdsDescriptorProperty); + + pEsIdsDescriptorProperty->SetTags(MP4ESIDRefDescrTag); + + MP4Descriptor *pRefDescriptor = + pEsIdsDescriptorProperty->AddDescriptor(MP4ESIDRefDescrTag); + pRefDescriptor->Generate(); + + MP4Integer16Property* pRefIndexProperty = NULL; + ASSERT(pRefDescriptor->FindProperty("refIndex", + (MP4Property**)&pRefIndexProperty)); + ASSERT(pRefIndexProperty); + + uint32_t mpodIndex = FindTrackReference( + MakeTrackName(odTrackId, "tref.mpod"), trackId); + ASSERT(mpodIndex != 0); + + pRefIndexProperty->SetValue(mpodIndex); + } + + pCommand->WriteToMemory(this, ppBytes, pNumBytes); + + delete pCommand; +} + +void MP4File::CreateIsmaODUpdateCommandFromFileForStream( + MP4TrackId audioTrackId, + MP4TrackId videoTrackId, + uint8_t** ppBytes, + uint64_t* pNumBytes) +{ + MP4DescriptorProperty* pAudioEsd = NULL; + MP4Integer8Property* pAudioSLConfigPredef = NULL; + MP4BitfieldProperty* pAudioAccessUnitEndFlag = NULL; + int oldAudioUnitEndFlagValue = 0; + MP4DescriptorProperty* pVideoEsd = NULL; + MP4Integer8Property* pVideoSLConfigPredef = NULL; + MP4BitfieldProperty* pVideoAccessUnitEndFlag = NULL; + int oldVideoUnitEndFlagValue = 0; + MP4IntegerProperty* pAudioEsdId = NULL; + MP4IntegerProperty* pVideoEsdId = NULL; + + if (audioTrackId != MP4_INVALID_TRACK_ID) { + // changed mp4a to * to handle enca case + MP4Atom* pEsdsAtom = + FindAtom(MakeTrackName(audioTrackId, + "mdia.minf.stbl.stsd.*.esds")); + ASSERT(pEsdsAtom); + + pAudioEsd = (MP4DescriptorProperty*)(pEsdsAtom->GetProperty(2)); + // ESID is 0 for file, stream needs to be non-ze + ASSERT(pAudioEsd->FindProperty("ESID", + (MP4Property**)&pAudioEsdId)); + + ASSERT(pAudioEsdId); + pAudioEsdId->SetValue(audioTrackId); + + // SL config needs to change from 2 (file) to 1 (null) + if (pAudioEsd->FindProperty("slConfigDescr.predefined", + (MP4Property**)&pAudioSLConfigPredef)) { + ASSERT(pAudioSLConfigPredef); + pAudioSLConfigPredef->SetValue(0); + } + + if (pAudioEsd->FindProperty("slConfigDescr.useAccessUnitEndFlag", + (MP4Property **)&pAudioAccessUnitEndFlag)) { + oldAudioUnitEndFlagValue = + pAudioAccessUnitEndFlag->GetValue(); + pAudioAccessUnitEndFlag->SetValue(1); + } + } + + if (videoTrackId != MP4_INVALID_TRACK_ID) { + // changed mp4v to * to handle encv case + MP4Atom* pEsdsAtom = + FindAtom(MakeTrackName(videoTrackId, + "mdia.minf.stbl.stsd.*.esds")); + ASSERT(pEsdsAtom); + + pVideoEsd = (MP4DescriptorProperty*)(pEsdsAtom->GetProperty(2)); + ASSERT(pVideoEsd->FindProperty("ESID", + (MP4Property**)&pVideoEsdId)); + + ASSERT(pVideoEsdId); + pVideoEsdId->SetValue(videoTrackId); + + // SL config needs to change from 2 (file) to 1 (null) + ASSERT(pVideoEsd->FindProperty("slConfigDescr.predefined", + (MP4Property **)&pVideoSLConfigPredef)); + ASSERT(pVideoSLConfigPredef); + pVideoSLConfigPredef->SetValue(0); + + if (pVideoEsd->FindProperty("slConfigDescr.useAccessUnitEndFlag", + (MP4Property **)&pVideoAccessUnitEndFlag)) { + oldVideoUnitEndFlagValue = + pVideoAccessUnitEndFlag->GetValue(); + pVideoAccessUnitEndFlag->SetValue(1); + } + } + + CreateIsmaODUpdateCommandForStream( + pAudioEsd, pVideoEsd, ppBytes, pNumBytes); + VERBOSE_ISMA(GetVerbosity(), + printf("After CreateImsaODUpdateCommandForStream len %" PRIu64 " =\n", *pNumBytes); MP4HexDump(*ppBytes, *pNumBytes)); + // return SL config values to 2 (file) + // return ESID values to 0 + if (pAudioSLConfigPredef) { + pAudioSLConfigPredef->SetValue(2); + } + if (pAudioEsdId) { + pAudioEsdId->SetValue(0); + } + if (pAudioAccessUnitEndFlag) { + pAudioAccessUnitEndFlag->SetValue(oldAudioUnitEndFlagValue ); + } + if (pVideoEsdId) { + pVideoEsdId->SetValue(0); + } + if (pVideoSLConfigPredef) { + pVideoSLConfigPredef->SetValue(2); + } + if (pVideoAccessUnitEndFlag) { + pVideoAccessUnitEndFlag->SetValue(oldVideoUnitEndFlagValue ); + } +} + +void MP4File::CreateIsmaODUpdateCommandForStream( + MP4DescriptorProperty* pAudioEsdProperty, + MP4DescriptorProperty* pVideoEsdProperty, + uint8_t** ppBytes, + uint64_t* pNumBytes) +{ + MP4Descriptor* pAudioOd = NULL; + MP4Descriptor* pVideoOd = NULL; + + MP4Descriptor* pCommand = + CreateODCommand(MP4ODUpdateODCommandTag); + pCommand->Generate(); + + for (uint8_t i = 0; i < 2; i++) { + uint16_t odId; + MP4DescriptorProperty* pEsdProperty = NULL; + + if (i == 0) { + odId = 10; + pEsdProperty = pAudioEsdProperty; + } else { + odId = 20; + pEsdProperty = pVideoEsdProperty; + } + + if (pEsdProperty == NULL) { + continue; + } + + MP4DescriptorProperty* pOdDescrProperty = + (MP4DescriptorProperty*)(pCommand->GetProperty(0)); + + pOdDescrProperty->SetTags(MP4ODescrTag); + + MP4Descriptor* pOd = + pOdDescrProperty->AddDescriptor(MP4ODescrTag); + pOd->Generate(); + + if (i == 0) { + pAudioOd = pOd; + } else { + pVideoOd = pOd; + } + + MP4BitfieldProperty* pOdIdProperty = NULL; + if (pOd->FindProperty("objectDescriptorId", + (MP4Property**)&pOdIdProperty)) { + pOdIdProperty->SetValue(odId); + } + + delete (MP4DescriptorProperty*)pOd->GetProperty(4); + pOd->SetProperty(4, pEsdProperty); + } + + // serialize OD command + pCommand->WriteToMemory(this, ppBytes, pNumBytes); + + // detach from esd descriptor params + if (pAudioOd) { + pAudioOd->SetProperty(4, NULL); + } + if (pVideoOd) { + pVideoOd->SetProperty(4, NULL); + } + + // then destroy + delete pCommand; +} + +void MP4File::CreateIsmaSceneCommand( + bool hasAudio, + bool hasVideo, + uint8_t** ppBytes, + uint64_t* pNumBytes) +{ + // from ISMA 1.0 Tech Spec Appendix E + static const uint8_t bifsAudioOnly[] = { + 0xC0, 0x10, 0x12, + 0x81, 0x30, 0x2A, 0x05, 0x6D, 0xC0 + }; + static const uint8_t bifsVideoOnly[] = { + 0xC0, 0x10, 0x12, + 0x61, 0x04, + 0x1F, 0xC0, 0x00, 0x00, + 0x1F, 0xC0, 0x00, 0x00, + 0x44, 0x28, 0x22, 0x82, 0x9F, 0x80 + }; + static const uint8_t bifsAudioVideo[] = { + 0xC0, 0x10, 0x12, + 0x81, 0x30, 0x2A, 0x05, 0x6D, 0x26, + 0x10, 0x41, 0xFC, 0x00, 0x00, 0x01, 0xFC, 0x00, 0x00, + 0x04, 0x42, 0x82, 0x28, 0x29, 0xF8 + }; + + if (hasAudio && hasVideo) { + *pNumBytes = sizeof(bifsAudioVideo); + *ppBytes = (uint8_t*)MP4Malloc(*pNumBytes); + memcpy(*ppBytes, bifsAudioVideo, sizeof(bifsAudioVideo)); + + } else if (hasAudio) { + *pNumBytes = sizeof(bifsAudioOnly); + *ppBytes = (uint8_t*)MP4Malloc(*pNumBytes); + memcpy(*ppBytes, bifsAudioOnly, sizeof(bifsAudioOnly)); + + } else if (hasVideo) { + *pNumBytes = sizeof(bifsVideoOnly); + *ppBytes = (uint8_t*)MP4Malloc(*pNumBytes); + memcpy(*ppBytes, bifsVideoOnly, sizeof(bifsVideoOnly)); + } else { + *pNumBytes = 0; + *ppBytes = NULL; + } +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/itmf/CoverArtBox.cpp b/src/itmf/CoverArtBox.cpp new file mode 100644 index 0000000..330d053 --- /dev/null +++ b/src/itmf/CoverArtBox.cpp @@ -0,0 +1,258 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is MP4v2. +// +// The Initial Developer of the Original Code is Kona Blend. +// Portions created by Kona Blend are Copyright (C) 2008. +// All Rights Reserved. +// +// Contributors: +// Kona Blend, kona8lend@@gmail.com +// +/////////////////////////////////////////////////////////////////////////////// + +#include "impl.h" + +namespace mp4v2 { namespace impl { namespace itmf { + +/////////////////////////////////////////////////////////////////////////////// + +CoverArtBox::Item::Item() + : type ( BT_UNDEFINED ) + , buffer ( NULL ) + , size ( 0 ) + , autofree ( false ) +{ +} + +/////////////////////////////////////////////////////////////////////////////// + +CoverArtBox::Item::Item( const Item& rhs ) + : type ( BT_UNDEFINED ) + , buffer ( NULL ) + , size ( 0 ) + , autofree ( false ) +{ + operator=( rhs ); +} + +/////////////////////////////////////////////////////////////////////////////// + +CoverArtBox::Item::~Item() +{ + reset(); +} + +/////////////////////////////////////////////////////////////////////////////// + +CoverArtBox::Item& +CoverArtBox::Item::operator=( const Item& rhs ) +{ + type = rhs.type; + size = rhs.size; + autofree = rhs.autofree; + + if( rhs.autofree ) { + buffer = (uint8_t*)MP4Malloc(rhs.size); + memcpy( buffer, rhs.buffer, rhs.size ); + } + else { + buffer = rhs.buffer; + } + + return *this; +} + +/////////////////////////////////////////////////////////////////////////////// + +void +CoverArtBox::Item::reset() +{ + if( autofree && buffer ) + MP4Free( buffer ); + + type = BT_UNDEFINED; + buffer = NULL; + size = 0; + autofree = false; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +CoverArtBox::add( MP4FileHandle hFile, const Item& item ) +{ + MP4File& file = *((MP4File*)hFile); + + const char* const covr_name = "moov.udta.meta.ilst.covr"; + MP4Atom* covr = file.FindAtom( covr_name ); + if( !covr ) { + file.AddDescendantAtoms( "moov", "udta.meta.ilst.covr" ); + + covr = file.FindAtom( covr_name ); + if( !covr ) + return true; + } + + // use empty data atom if one exists + MP4Atom* data = NULL; + uint32_t index = 0; + const uint32_t atomc = covr->GetNumberOfChildAtoms(); + for( uint32_t i = 0; i < atomc; i++ ) { + MP4Atom* atom = covr->GetChildAtom( i ); + + MP4BytesProperty* metadata = NULL; + if( !atom->FindProperty( "data.metadata", (MP4Property**)&metadata )) + continue; + + if( metadata->GetCount() ) + continue; + + data = atom; + index = i; + break; + } + + // no empty atom found, create one. + if( !data ) { + data = MP4Atom::CreateAtom( covr, "data" ); + covr->AddChildAtom( data ); + data->Generate(); + index = covr->GetNumberOfChildAtoms() - 1; + } + + return set( hFile, item, index ); +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +CoverArtBox::get( MP4FileHandle hFile, Item& item, uint32_t index ) +{ + item.reset(); + MP4File& file = *((MP4File*)hFile); + + MP4Atom* covr = file.FindAtom( "moov.udta.meta.ilst.covr" ); + if( !covr ) + return true; + + if( !(index < covr->GetNumberOfChildAtoms()) ) + return true; + + MP4DataAtom* data = static_cast<MP4DataAtom*>( covr->GetChildAtom( index )); + if( !data ) + return true; + + MP4BytesProperty* metadata = NULL; + if ( !data->FindProperty( "data.metadata", (MP4Property**)&metadata )) + return true; + + metadata->GetValue( &item.buffer, &item.size ); + item.autofree = true; + item.type = data->typeCode.GetValue(); + + return false; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +CoverArtBox::list( MP4FileHandle hFile, ItemList& out ) +{ + out.clear(); + MP4File& file = *((MP4File*)hFile); + MP4ItmfItemList* itemList = genericGetItemsByCode( file, "covr" ); // alloc + + out.resize( itemList->size ); + for( uint32_t i = 0; i < itemList->size; i++ ) + get( hFile, out[i], i ); + + genericItemListFree( itemList ); // free + return false; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +CoverArtBox::remove( MP4FileHandle hFile, uint32_t index ) +{ + MP4File& file = *((MP4File*)hFile); + + MP4Atom* covr = file.FindAtom( "moov.udta.meta.ilst.covr" ); + if( !covr ) + return true; + + // wildcard mode: delete covr and all images + if( index == numeric_limits<uint32_t>::max() ) { + covr->GetParentAtom()->DeleteChildAtom( covr ); + delete covr; + return false; + } + + if( !(index < covr->GetNumberOfChildAtoms()) ) + return true; + + MP4Atom* data = covr->GetChildAtom( index ); + if( !data ) + return true; + + // delete single image + covr->DeleteChildAtom( data ); + delete data; + + // delete empty covr + if( covr->GetNumberOfChildAtoms() == 0 ) { + covr->GetParentAtom()->DeleteChildAtom( covr ); + delete covr; + } + + return false; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +CoverArtBox::set( MP4FileHandle hFile, const Item& item, uint32_t index ) +{ + MP4File& file = *((MP4File*)hFile); + + MP4Atom* covr = file.FindAtom( "moov.udta.meta.ilst.covr" ); + if( !covr ) + return true; + + if( !(index < covr->GetNumberOfChildAtoms()) ) + return true; + + MP4DataAtom* data = static_cast<MP4DataAtom*>( covr->GetChildAtom( index )); + if( !data ) + return true; + + MP4BytesProperty* metadata = NULL; + if ( !data->FindProperty( "data.metadata", (MP4Property**)&metadata )) + return true; + + // autodetect type if BT_UNDEFINED + const BasicType final_type = (item.type == BT_UNDEFINED) + ? computeBasicType( item.buffer, item.size ) + : item.type; + + // set type; note: not really flags due to b0rked atom structure + data->typeCode.SetValue( final_type ); + metadata->SetValue( item.buffer, item.size ); + + return false; +} + +/////////////////////////////////////////////////////////////////////////////// + +}}} // namespace mp4v2::impl::itmf diff --git a/src/itmf/CoverArtBox.h b/src/itmf/CoverArtBox.h new file mode 100644 index 0000000..023e3c9 --- /dev/null +++ b/src/itmf/CoverArtBox.h @@ -0,0 +1,121 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is MP4v2. +// +// The Initial Developer of the Original Code is Kona Blend. +// Portions created by Kona Blend are Copyright (C) 2008. +// All Rights Reserved. +// +// Contributors: +// Kona Blend, kona8lend@@gmail.com +// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef MP4V2_IMPL_ITMF_COVERARTBOX_H +#define MP4V2_IMPL_ITMF_COVERARTBOX_H + +namespace mp4v2 { namespace impl { namespace itmf { + +/////////////////////////////////////////////////////////////////////////////// + +/// Functional class for covr-box (Cover-art Box) support. +/// +class MP4V2_EXPORT CoverArtBox +{ +public: + /// Data object for covr-box item. + /// This object correlates to one covr->data atom and offers automatic + /// memory freeing when <b>autofree</b> is true. + /// + class MP4V2_EXPORT Item + { + public: + Item(); + Item( const Item& ); + ~Item(); + + Item& operator=( const Item& ); + + /// Reset to state of newly constructed object. + /// If <b>buffer</b> is not NULL and <b>autofree</b> is true the + /// buffer will be free'd. + void reset(); + + BasicType type; ///< covr-box type. + uint8_t* buffer; ///< buffer point to raw covr-box data. + uint32_t size; ///< size of covr-box buffer size in bytes. + bool autofree; ///< when true invoke free(buffer) upon destruction. + }; + + /// Object representing a list of covr-box items. + typedef vector<Item> ItemList; + + /// Fetch list of covr-box items from file. + /// + /// @param hFile on which to operate. + /// @param out vector of ArtItem objects. + /// + /// @return <b>true</b> on failure, <b>false</b> on success. + /// + static bool list( MP4FileHandle hFile, ItemList& out ); + + /// Add covr-box item to file. + /// Any necessary metadata atoms are first created. + /// Additionally, if an empty data-atom exists it will be used, + /// otherwise a new data-atom is added to <b>covr-atom</b>. + /// + /// @param hFile on which to operate. + /// @param item covr-box object to place in file. + /// + /// @return <b>true</b> on failure, <b>false</b> on success. + /// + static bool add( MP4FileHandle hFile, const Item& item ); + + /// Replace covr-box item in file. + /// + /// @param hFile on which to operate. + /// @param item covr-box object to place in file. + /// @param index 0-based index of image to replace. + /// + /// @return <b>true</b> on failure, <b>false</b> on success. + /// + static bool set( MP4FileHandle hFile, const Item& item, uint32_t index ); + + /// Fetch covr-box item from file. + /// + /// @param hFile on which to operate. + /// @param item covr-box object populated with data. + /// The resulting object owns the malloc'd buffer and <b>item.autofree</b> + /// is set to true for convenient memory management. + /// @param index 0-based index of image to fetch. + /// + /// @return <b>true</b> on failure, <b>false</b> on success. + /// + static bool get( MP4FileHandle hFile, Item& item, uint32_t index ); + + /// Remove covr-box item from file. + /// + /// @param hFile on which to operate. + /// @param index 0-based index of image to remove. + /// Default value indicates wildcard behavior to remove all items. + /// + /// @return <b>true</b> on failure, <b>false</b> on success. + /// + static bool remove( MP4FileHandle hFile, uint32_t index = numeric_limits<uint32_t>::max() ); +}; + +/////////////////////////////////////////////////////////////////////////////// + +}}} // namespace mp4v2::impl::itmf + +#endif // MP4V2_IMPL_ITMF_COVERARTBOX_H diff --git a/src/itmf/Tags.cpp b/src/itmf/Tags.cpp new file mode 100644 index 0000000..9568900 --- /dev/null +++ b/src/itmf/Tags.cpp @@ -0,0 +1,859 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is MP4v2. +// +// The Initial Developer of the Original Code is Kona Blend. +// Portions created by Kona Blend are Copyright (C) 2008. +// All Rights Reserved. +// +// Contributors: +// Kona Blend, kona8lend@@gmail.com +// Rouven Wessling, mp4v2@rouvenwessling.de +// +/////////////////////////////////////////////////////////////////////////////// + +#include "impl.h" + +namespace mp4v2 { namespace impl { namespace itmf { + +/////////////////////////////////////////////////////////////////////////////// + +Tags::Tags() +{ +} + +/////////////////////////////////////////////////////////////////////////////// + +Tags::~Tags() +{ +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Tags::c_addArtwork( MP4Tags*& tags, MP4TagArtwork& c_artwork ) +{ + artwork.resize( artwork.size() + 1 ); + c_setArtwork( tags, artwork.size() - 1, c_artwork ); + updateArtworkShadow( tags ); +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Tags::c_alloc( MP4Tags*& tags ) +{ + tags = new MP4Tags(); + memset( tags, 0, sizeof(MP4Tags) ); // safe: pure C-struct + tags->__handle = this; +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Tags::c_fetch( MP4Tags*& tags, MP4FileHandle hFile ) +{ + MP4Tags& c = *tags; + MP4File& file = *static_cast<MP4File*>(hFile); + + MP4ItmfItemList* itemList = genericGetItems( file ); // alloc + + /* create code -> item map. + * map will only be used for items which do not repeat; we do not care if + * cover-art is inserted multiple times. + */ + CodeItemMap cim; + for( uint32_t i = 0; i < itemList->size; i++ ) { + MP4ItmfItem& item = itemList->elements[i]; + cim.insert( CodeItemMap::value_type( item.code, &item )); + } + + fetchString( cim, CODE_NAME, name, c.name ); + fetchString( cim, CODE_ARTIST, artist, c.artist ); + fetchString( cim, CODE_ALBUMARTIST, albumArtist, c.albumArtist ); + fetchString( cim, CODE_ALBUM, album, c.album ); + fetchString( cim, CODE_GROUPING, grouping, c.grouping ); + fetchString( cim, CODE_COMPOSER, composer, c.composer ); + fetchString( cim, CODE_COMMENTS, comments, c.comments ); + + fetchString( cim, CODE_GENRE, genre, c.genre ); + fetchGenre( cim, genreType, c.genreType ); + + fetchString( cim, CODE_RELEASEDATE, releaseDate, c.releaseDate ); + fetchTrack( cim, track, c.track ); + fetchDisk( cim, disk, c.disk ); + fetchInteger( cim, CODE_TEMPO, tempo, c.tempo ); + fetchInteger( cim, CODE_COMPILATION, compilation, c.compilation ); + + fetchString( cim, CODE_TVSHOW, tvShow, c.tvShow ); + fetchString( cim, CODE_TVNETWORK, tvNetwork, c.tvNetwork ); + fetchString( cim, CODE_TVEPISODEID, tvEpisodeID, c.tvEpisodeID ); + fetchInteger( cim, CODE_TVSEASON, tvSeason, c.tvSeason ); + fetchInteger( cim, CODE_TVEPISODE, tvEpisode, c.tvEpisode ); + + fetchString( cim, CODE_SORTNAME, sortName, c.sortName ); + fetchString( cim, CODE_SORTARTIST, sortArtist, c.sortArtist ); + fetchString( cim, CODE_SORTALBUMARTIST, sortAlbumArtist, c.sortAlbumArtist ); + fetchString( cim, CODE_SORTALBUM, sortAlbum, c.sortAlbum ); + fetchString( cim, CODE_SORTCOMPOSER, sortComposer, c.sortComposer ); + fetchString( cim, CODE_SORTTVSHOW, sortTVShow, c.sortTVShow ); + + fetchString( cim, CODE_DESCRIPTION, description, c.description ); + fetchString( cim, CODE_LONGDESCRIPTION, longDescription, c.longDescription ); + fetchString( cim, CODE_LYRICS, lyrics, c.lyrics ); + + fetchString( cim, CODE_COPYRIGHT, copyright, c.copyright ); + fetchString( cim, CODE_ENCODINGTOOL, encodingTool, c.encodingTool ); + fetchString( cim, CODE_ENCODEDBY, encodedBy, c.encodedBy ); + fetchString( cim, CODE_PURCHASEDATE, purchaseDate, c.purchaseDate ); + + fetchInteger( cim, CODE_PODCAST, podcast, c.podcast ); + fetchString( cim, CODE_KEYWORDS, keywords, c.keywords ); + fetchString( cim, CODE_CATEGORY, category, c.category ); + + fetchInteger( cim, CODE_HDVIDEO, hdVideo, c.hdVideo ); + fetchInteger( cim, CODE_MEDIATYPE, mediaType, c.mediaType ); + fetchInteger( cim, CODE_CONTENTRATING, contentRating, c.contentRating ); + fetchInteger( cim, CODE_GAPLESS, gapless, c.gapless ); + + fetchString( cim, CODE_ITUNESACCOUNT, iTunesAccount, c.iTunesAccount ); + fetchInteger( cim, CODE_ITUNESACCOUNTTYPE, iTunesAccountType, c.iTunesAccountType ); + fetchInteger( cim, CODE_ITUNESCOUNTRY, iTunesCountry, c.iTunesCountry ); + + fetchInteger( cim, CODE_CNID, cnID, c.cnID ); + fetchInteger( cim, CODE_ATID, atID, c.atID ); + fetchInteger( cim, CODE_PLID, plID, c.plID ); + fetchInteger( cim, CODE_GEID, geID, c.geID ); + + genericItemListFree( itemList ); // free + + // fetch full list and overwrite our copy, otherwise clear + { + CoverArtBox::ItemList items; + if( CoverArtBox::list( hFile, items )) + artwork.clear(); + else + artwork = items; + + updateArtworkShadow( tags ); + } +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Tags::c_free( MP4Tags*& tags ) +{ + MP4Tags* c = const_cast<MP4Tags*>(tags); + + delete[] c->artwork; + delete c; + + tags = NULL; +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Tags::c_removeArtwork( MP4Tags*& tags, uint32_t index ) +{ + if( !(index < artwork.size()) ) + return; + + artwork.erase( artwork.begin() + index ); + updateArtworkShadow( tags ); +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Tags::c_setArtwork( MP4Tags*& tags, uint32_t index, MP4TagArtwork& c_artwork ) +{ + if( !(index < artwork.size()) ) + return; + + CoverArtBox::Item& item = artwork[index]; + + switch( c_artwork.type ) { + case MP4_ART_BMP: + item.type = BT_BMP; + break; + + case MP4_ART_GIF: + item.type = BT_GIF; + break; + + case MP4_ART_JPEG: + item.type = BT_JPEG; + break; + + case MP4_ART_PNG: + item.type = BT_PNG; + break; + + case MP4_ART_UNDEFINED: + default: + item.type = computeBasicType( c_artwork.data, c_artwork.size ); + break; + } + + item.buffer = (uint8_t*)malloc( c_artwork.size ); + item.size = c_artwork.size; + item.autofree = true; + + memcpy( item.buffer, c_artwork.data, c_artwork.size ); + updateArtworkShadow( tags ); +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Tags::c_setInteger( const uint8_t* value, uint8_t& cpp, const uint8_t*& c ) +{ + if( !value ) { + cpp = 0; + c = NULL; + } + else { + cpp = *value; + c = &cpp; + } +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Tags::c_setInteger( const uint16_t* value, uint16_t& cpp, const uint16_t*& c ) +{ + if( !value ) { + cpp = 0; + c = NULL; + } + else { + cpp = *value; + c = &cpp; + } +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Tags::c_setInteger( const uint32_t* value, uint32_t& cpp, const uint32_t*& c ) +{ + if( !value ) { + cpp = 0; + c = NULL; + } + else { + cpp = *value; + c = &cpp; + } +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Tags::c_setInteger( const uint64_t* value, uint64_t& cpp, const uint64_t*& c ) +{ + if( !value ) { + cpp = 0; + c = NULL; + } + else { + cpp = *value; + c = &cpp; + } +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Tags::c_setString( const char* value, string& cpp, const char*& c ) +{ + if( !value ) { + cpp.clear(); + c = NULL; + } + else { + cpp = value; + c = cpp.c_str(); + } +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Tags::c_setTrack( const MP4TagTrack* value, MP4TagTrack& cpp, const MP4TagTrack*& c ) +{ + if( !value ) { + cpp.index = 0; + cpp.total = 0; + c = NULL; + } + else { + cpp.index = value->index; + cpp.total = value->total; + c = &cpp; + } +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Tags::c_setDisk( const MP4TagDisk* value, MP4TagDisk& cpp, const MP4TagDisk*& c ) +{ + if( !value ) { + cpp.index = 0; + cpp.total = 0; + c = NULL; + } + else { + cpp.index = value->index; + cpp.total = value->total; + c = &cpp; + } +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Tags::c_store( MP4Tags*& tags, MP4FileHandle hFile ) +{ + MP4Tags& c = *tags; + MP4File& file = *static_cast<MP4File*>(hFile); + + storeString( file, CODE_NAME, name, c.name ); + storeString( file, CODE_ARTIST, artist, c.artist ); + storeString( file, CODE_ALBUMARTIST, albumArtist, c.albumArtist ); + storeString( file, CODE_ALBUM, album, c.album ); + storeString( file, CODE_GROUPING, grouping, c.grouping ); + storeString( file, CODE_COMPOSER, composer, c.composer ); + storeString( file, CODE_COMMENTS, comments, c.comments ); + + storeString( file, CODE_GENRE, genre, c.genre ); + storeGenre( file, genreType, c.genreType ); + + storeString( file, CODE_RELEASEDATE, releaseDate, c.releaseDate ); + storeTrack( file, track, c.track ); + storeDisk( file, disk, c.disk ); + storeInteger( file, CODE_TEMPO, tempo, c.tempo ); + storeInteger( file, CODE_COMPILATION, compilation, c.compilation ); + + storeString( file, CODE_TVSHOW, tvShow, c.tvShow ); + storeString( file, CODE_TVNETWORK, tvNetwork, c.tvNetwork ); + storeString( file, CODE_TVEPISODEID, tvEpisodeID, c.tvEpisodeID ); + storeInteger( file, CODE_TVSEASON, tvSeason, c.tvSeason ); + storeInteger( file, CODE_TVEPISODE, tvEpisode, c.tvEpisode ); + + storeString( file, CODE_SORTNAME, sortName, c.sortName ); + storeString( file, CODE_SORTARTIST, sortArtist, c.sortArtist ); + storeString( file, CODE_SORTALBUMARTIST, sortAlbumArtist, c.sortAlbumArtist ); + storeString( file, CODE_SORTALBUM, sortAlbum, c.sortAlbum ); + storeString( file, CODE_SORTCOMPOSER, sortComposer, c.sortComposer ); + storeString( file, CODE_SORTTVSHOW, sortTVShow, c.sortTVShow ); + + storeString( file, CODE_DESCRIPTION, description, c.description ); + storeString( file, CODE_LONGDESCRIPTION, longDescription, c.longDescription ); + storeString( file, CODE_LYRICS, lyrics, c.lyrics ); + + storeString( file, CODE_COPYRIGHT, copyright, c.copyright ); + storeString( file, CODE_ENCODINGTOOL, encodingTool, c.encodingTool ); + storeString( file, CODE_ENCODEDBY, encodedBy, c.encodedBy ); + storeString( file, CODE_PURCHASEDATE, purchaseDate, c.purchaseDate ); + + storeInteger( file, CODE_PODCAST, podcast, c.podcast ); + storeString( file, CODE_KEYWORDS, keywords, c.keywords ); + storeString( file, CODE_CATEGORY, category, c.category ); + + storeInteger( file, CODE_HDVIDEO, hdVideo, c.hdVideo ); + storeInteger( file, CODE_MEDIATYPE, mediaType, c.mediaType ); + storeInteger( file, CODE_CONTENTRATING, contentRating, c.contentRating ); + storeInteger( file, CODE_GAPLESS, gapless, c.gapless ); + + storeString( file, CODE_ITUNESACCOUNT, iTunesAccount, c.iTunesAccount ); + storeInteger( file, CODE_ITUNESACCOUNTTYPE, iTunesAccountType, c.iTunesAccountType ); + storeInteger( file, CODE_ITUNESCOUNTRY, iTunesCountry, c.iTunesCountry ); + + storeInteger( file, CODE_CNID, cnID, c.cnID ); + storeInteger( file, CODE_ATID, atID, c.atID ); + storeInteger( file, CODE_PLID, plID, c.plID ); + storeInteger( file, CODE_GEID, geID, c.geID ); + + // destroy all cover-art then add each + { + CoverArtBox::remove( hFile ); + const CoverArtBox::ItemList::size_type max = artwork.size(); + for( CoverArtBox::ItemList::size_type i = 0; i < max; i++ ) + CoverArtBox::add( hFile, artwork[i] ); + } +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Tags::fetchGenre( const CodeItemMap& cim, uint16_t& cpp, const uint16_t*& c ) +{ + cpp = 0; + c = NULL; + + CodeItemMap::const_iterator f = cim.find( CODE_GENRETYPE ); + if( f == cim.end() ) + return; + + MP4ItmfData& data = f->second->dataList.elements[0]; + + cpp = (uint16_t(data.value[0]) << 8) + | (uint16_t(data.value[1]) ); + + c = &cpp; +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Tags::fetchDisk( const CodeItemMap& cim, MP4TagDisk& cpp, const MP4TagDisk*& c ) +{ + cpp.index = 0; + cpp.total = 0; + c = NULL; + + CodeItemMap::const_iterator f = cim.find( CODE_DISK ); + if( f == cim.end() ) + return; + + MP4ItmfData& data = f->second->dataList.elements[0]; + + cpp.index = (uint16_t(data.value[2]) << 8) + | (uint16_t(data.value[3]) ); + + cpp.total = (uint16_t(data.value[4]) << 8) + | (uint16_t(data.value[5]) ); + + c = &cpp; +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Tags::fetchTrack( const CodeItemMap& cim, MP4TagTrack& cpp, const MP4TagTrack*& c ) +{ + cpp.index = 0; + cpp.total = 0; + c = NULL; + + CodeItemMap::const_iterator f = cim.find( CODE_TRACK ); + if( f == cim.end() ) + return; + + MP4ItmfData& data = f->second->dataList.elements[0]; + + cpp.index = (uint16_t(data.value[2]) << 8) + | (uint16_t(data.value[3]) ); + + cpp.total = (uint16_t(data.value[4]) << 8) + | (uint16_t(data.value[5]) ); + + c = &cpp; +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Tags::fetchInteger( const CodeItemMap& cim, const string& code, uint8_t& cpp, const uint8_t*& c ) +{ + cpp = 0; + c = NULL; + + CodeItemMap::const_iterator f = cim.find( code ); + if( f == cim.end() ) + return; + + MP4ItmfData& data = f->second->dataList.elements[0]; + cpp = data.value[0]; + c = &cpp; +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Tags::fetchInteger( const CodeItemMap& cim, const string& code, uint16_t& cpp, const uint16_t*& c ) +{ + cpp = 0; + c = NULL; + + CodeItemMap::const_iterator f = cim.find( code ); + if( f == cim.end() ) + return; + + MP4ItmfData& data = f->second->dataList.elements[0]; + + cpp = (uint16_t(data.value[0]) << 8) + | (uint16_t(data.value[1]) ); + + c = &cpp; +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Tags::fetchInteger( const CodeItemMap& cim, const string& code, uint32_t& cpp, const uint32_t*& c ) +{ + cpp = 0; + c = NULL; + + CodeItemMap::const_iterator f = cim.find( code ); + if( f == cim.end() ) + return; + + MP4ItmfData& data = f->second->dataList.elements[0]; + + cpp = (uint32_t(data.value[0]) << 24) + | (uint32_t(data.value[1]) << 16) + | (uint32_t(data.value[2]) << 8) + | (uint32_t(data.value[3]) ); + + c = &cpp; +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Tags::fetchInteger( const CodeItemMap& cim, const string& code, uint64_t& cpp, const uint64_t*& c ) +{ + cpp = 0; + c = NULL; + + CodeItemMap::const_iterator f = cim.find( code ); + if( f == cim.end() ) + return; + + MP4ItmfData& data = f->second->dataList.elements[0]; + + cpp = (uint64_t(data.value[0]) << 56) + | (uint64_t(data.value[1]) << 48) + | (uint64_t(data.value[2]) << 40) + | (uint64_t(data.value[3]) << 32) + | (uint64_t(data.value[4]) << 24) + | (uint64_t(data.value[5]) << 16) + | (uint64_t(data.value[6]) << 8) + | (uint64_t(data.value[7]) ); + + c = &cpp; +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Tags::fetchString( const CodeItemMap& cim, const string& code, string& cpp, const char*& c ) +{ + cpp.clear(); + c = NULL; + + CodeItemMap::const_iterator f = cim.find( code ); + if( f == cim.end() ) + return; + + MP4ItmfData& data = f->second->dataList.elements[0]; + cpp.append( reinterpret_cast<char*>( data.value ), data.valueSize ); + c = cpp.c_str(); +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Tags::remove( MP4File& file, const string& code ) +{ + MP4ItmfItemList* itemList = genericGetItemsByCode( file, code ); // alloc + + if( itemList->size ) + genericRemoveItem( file, &itemList->elements[0] ); + + genericItemListFree( itemList ); // free +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Tags::store( MP4File& file, const string& code, MP4ItmfBasicType basicType, const void* buffer, uint32_t size ) +{ + // remove existing item + remove( file, code ); + + // add item + MP4ItmfItem& item = *genericItemAlloc( code, 1 ); // alloc + MP4ItmfData& data = item.dataList.elements[0]; + + data.typeCode = MP4_ITMF_BT_UTF8; + data.valueSize = size; + data.value = (uint8_t*)malloc( data.valueSize ); + memcpy( data.value, buffer, data.valueSize ); + + genericAddItem( file, &item ); + genericItemFree( &item ); // free +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Tags::storeGenre( MP4File& file, uint16_t cpp, const uint16_t* c ) +{ + if( c ) { + uint8_t buf[2]; + + buf[0] = uint8_t((cpp & 0xff00) >> 8); + buf[1] = uint8_t((cpp & 0x00ff) ); + + store( file, CODE_GENRETYPE, MP4_ITMF_BT_GENRES, buf, sizeof(buf) ); + } + else { + remove( file, CODE_GENRETYPE ); + } +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Tags::storeDisk( MP4File& file, const MP4TagDisk& cpp, const MP4TagDisk* c ) +{ + if( c ) { + uint8_t buf[6]; + memset( buf, 0, sizeof(buf) ); + + buf[2] = uint8_t((cpp.index & 0xff00) >> 8); + buf[3] = uint8_t((cpp.index & 0x00ff) ); + buf[4] = uint8_t((cpp.total & 0xff00) >> 8); + buf[5] = uint8_t((cpp.total & 0x00ff) ); + + store( file, CODE_DISK, MP4_ITMF_BT_IMPLICIT, buf, sizeof(buf) ); + } + else { + remove( file, CODE_DISK ); + } +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Tags::storeTrack( MP4File& file, const MP4TagTrack& cpp, const MP4TagTrack* c ) +{ + if( c ) { + uint8_t buf[7]; + memset( buf, 0, sizeof(buf) ); + + buf[2] = uint8_t((cpp.index & 0xff00) >> 8); + buf[3] = uint8_t((cpp.index & 0x00ff) ); + buf[4] = uint8_t((cpp.total & 0xff00) >> 8); + buf[5] = uint8_t((cpp.total & 0x00ff) ); + + store( file, CODE_TRACK, MP4_ITMF_BT_IMPLICIT, buf, sizeof(buf) ); + } + else { + remove( file, CODE_TRACK ); + } +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Tags::storeInteger( MP4File& file, const string& code, uint8_t cpp, const uint8_t* c ) +{ + if( c ) + store( file, code, MP4_ITMF_BT_INTEGER, &cpp, sizeof(cpp) ); + else + remove( file, code ); +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Tags::storeInteger( MP4File& file, const string& code, uint16_t cpp, const uint16_t* c ) +{ + if( c ) { + uint8_t buf[2]; + + buf[0] = uint8_t((cpp & 0xff00) >> 8); + buf[1] = uint8_t((cpp & 0x00ff) ); + + store( file, code, MP4_ITMF_BT_INTEGER, buf, sizeof(buf) ); + } + else { + remove( file, code ); + } +} + + +/////////////////////////////////////////////////////////////////////////////// + +void +Tags::storeInteger( MP4File& file, const string& code, uint32_t cpp, const uint32_t* c ) +{ + if( c ) { + uint8_t buf[4]; + + buf[0] = uint8_t((cpp & 0xff000000) >> 24 ); + buf[1] = uint8_t((cpp & 0x00ff0000) >> 16 ); + buf[2] = uint8_t((cpp & 0x0000ff00) >> 8 ); + buf[3] = uint8_t((cpp & 0x000000ff) ); + + store( file, code, MP4_ITMF_BT_INTEGER, buf, sizeof(buf) ); + } + else { + remove( file, code ); + } +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Tags::storeInteger( MP4File& file, const string& code, uint64_t cpp, const uint64_t* c ) +{ + if( c ) { + uint8_t buf[8]; + + buf[0] = uint8_t((cpp & 0xff00000000000000LL) >> 56 ); + buf[1] = uint8_t((cpp & 0x00ff000000000000LL) >> 48 ); + buf[2] = uint8_t((cpp & 0x0000ff0000000000LL) >> 40 ); + buf[3] = uint8_t((cpp & 0x000000ff00000000LL) >> 32 ); + buf[4] = uint8_t((cpp & 0x00000000ff000000LL) >> 24 ); + buf[5] = uint8_t((cpp & 0x0000000000ff0000LL) >> 16 ); + buf[6] = uint8_t((cpp & 0x000000000000ff00LL) >> 8 ); + buf[7] = uint8_t((cpp & 0x00000000000000ffLL) ); + + store( file, code, MP4_ITMF_BT_INTEGER, buf, sizeof(buf) ); + } + else { + remove( file, code ); + } +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Tags::storeString( MP4File& file, const string& code, const string& cpp, const char* c ) +{ + if( c ) + store( file, code, MP4_ITMF_BT_UTF8, cpp.c_str(), cpp.size() ); + else + remove( file, code ); +} + +/////////////////////////////////////////////////////////////////////////////// + +void +Tags::updateArtworkShadow( MP4Tags*& tags ) +{ + if( tags->artwork ) { + delete[] tags->artwork; + tags->artwork = NULL; + tags->artworkCount = 0; + } + + if( artwork.empty() ) + return; + + MP4TagArtwork* const cartwork = new MP4TagArtwork[ artwork.size() ]; + uint32_t max = artwork.size(); + + for( uint32_t i = 0; i < max; i++ ) { + MP4TagArtwork& a = cartwork[i]; + CoverArtBox::Item& item = artwork[i]; + + a.data = item.buffer; + a.size = item.size; + + switch( item.type ) { + case BT_BMP: + a.type = MP4_ART_BMP; + break; + + case BT_GIF: + a.type = MP4_ART_GIF; + break; + + case BT_JPEG: + a.type = MP4_ART_JPEG; + break; + + case BT_PNG: + a.type = MP4_ART_PNG; + break; + + default: + a.type = MP4_ART_UNDEFINED; + break; + } + } + + tags->artwork = cartwork; + tags->artworkCount = max; +} + +/////////////////////////////////////////////////////////////////////////////// + +const string Tags::CODE_NAME = "\xa9" "nam"; +const string Tags::CODE_ARTIST = "\xa9" "ART"; +const string Tags::CODE_ALBUMARTIST = "aART"; +const string Tags::CODE_ALBUM = "\xa9" "alb"; +const string Tags::CODE_GROUPING = "\xa9" "grp"; +const string Tags::CODE_COMPOSER = "\xa9" "wrt"; +const string Tags::CODE_COMMENTS = "\xa9" "cmt"; +const string Tags::CODE_GENRE = "\xa9" "gen"; +const string Tags::CODE_GENRETYPE = "gnre"; +const string Tags::CODE_RELEASEDATE = "\xa9" "day"; +const string Tags::CODE_TRACK = "trkn"; +const string Tags::CODE_DISK = "disk"; +const string Tags::CODE_TEMPO = "tmpo"; +const string Tags::CODE_COMPILATION = "cpil"; + +const string Tags::CODE_TVSHOW = "tvsh"; +const string Tags::CODE_TVNETWORK = "tvnn"; +const string Tags::CODE_TVEPISODEID = "tven"; +const string Tags::CODE_TVSEASON = "tvsn"; +const string Tags::CODE_TVEPISODE = "tves"; + +const string Tags::CODE_DESCRIPTION = "desc"; +const string Tags::CODE_LONGDESCRIPTION = "ldes"; +const string Tags::CODE_LYRICS = "\xa9" "lyr"; + +const string Tags::CODE_SORTNAME = "sonm"; +const string Tags::CODE_SORTARTIST = "soar"; +const string Tags::CODE_SORTALBUMARTIST = "soaa"; +const string Tags::CODE_SORTALBUM = "soal"; +const string Tags::CODE_SORTCOMPOSER = "soco"; +const string Tags::CODE_SORTTVSHOW = "sosn"; + +const string Tags::CODE_COPYRIGHT = "cprt"; +const string Tags::CODE_ENCODINGTOOL = "\xa9" "too"; +const string Tags::CODE_ENCODEDBY = "\xa9" "enc"; +const string Tags::CODE_PURCHASEDATE = "purd"; + +const string Tags::CODE_PODCAST = "pcst"; +const string Tags::CODE_KEYWORDS = "keyw"; +const string Tags::CODE_CATEGORY = "catg"; + +const string Tags::CODE_HDVIDEO = "hdvd"; +const string Tags::CODE_MEDIATYPE = "stik"; +const string Tags::CODE_CONTENTRATING = "rtng"; +const string Tags::CODE_GAPLESS = "pgap"; + +const string Tags::CODE_ITUNESACCOUNT = "apID"; +const string Tags::CODE_ITUNESACCOUNTTYPE = "akID"; +const string Tags::CODE_ITUNESCOUNTRY = "sfID"; +const string Tags::CODE_CNID = "cnID"; +const string Tags::CODE_ATID = "atID"; +const string Tags::CODE_PLID = "plID"; +const string Tags::CODE_GEID = "geID"; + +/////////////////////////////////////////////////////////////////////////////// + +}}} // namespace mp4v2::impl::itmf diff --git a/src/itmf/Tags.h b/src/itmf/Tags.h new file mode 100644 index 0000000..5842adf --- /dev/null +++ b/src/itmf/Tags.h @@ -0,0 +1,202 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is MP4v2. +// +// The Initial Developer of the Original Code is Kona Blend. +// Portions created by Kona Blend are Copyright (C) 2008. +// All Rights Reserved. +// +// Contributors: +// Kona Blend, kona8lend@gmail.com +// Rouven Wessling, mp4v2@rouvenwessling.de +// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef MP4V2_IMPL_ITMF_TAGS_H +#define MP4V2_IMPL_ITMF_TAGS_H + +namespace mp4v2 { namespace impl { namespace itmf { + +/////////////////////////////////////////////////////////////////////////////// + +class Tags +{ +public: + static const string CODE_NAME; + static const string CODE_ARTIST; + static const string CODE_ALBUMARTIST; + static const string CODE_ALBUM; + static const string CODE_GROUPING; + static const string CODE_COMPOSER; + static const string CODE_COMMENTS; + static const string CODE_GENRE; + static const string CODE_GENRETYPE; + static const string CODE_RELEASEDATE; + static const string CODE_TRACK; + static const string CODE_DISK; + static const string CODE_TEMPO; + static const string CODE_COMPILATION; + + static const string CODE_TVSHOW; + static const string CODE_TVNETWORK; + static const string CODE_TVEPISODEID; + static const string CODE_TVSEASON; + static const string CODE_TVEPISODE; + + static const string CODE_DESCRIPTION; + static const string CODE_LONGDESCRIPTION; + static const string CODE_LYRICS; + + static const string CODE_SORTNAME; + static const string CODE_SORTARTIST; + static const string CODE_SORTALBUMARTIST; + static const string CODE_SORTALBUM; + static const string CODE_SORTCOMPOSER; + static const string CODE_SORTTVSHOW; + + static const string CODE_COPYRIGHT; + static const string CODE_ENCODINGTOOL; + static const string CODE_ENCODEDBY; + static const string CODE_PURCHASEDATE; + + static const string CODE_PODCAST; + static const string CODE_KEYWORDS; + static const string CODE_CATEGORY; + + static const string CODE_HDVIDEO; + static const string CODE_MEDIATYPE; + static const string CODE_CONTENTRATING; + static const string CODE_GAPLESS; + + static const string CODE_ITUNESACCOUNT; + static const string CODE_ITUNESACCOUNTTYPE; + static const string CODE_ITUNESCOUNTRY; + static const string CODE_CNID; + static const string CODE_ATID; + static const string CODE_PLID; + static const string CODE_GEID; + +public: + string name; + string artist; + string albumArtist; + string album; + string grouping; + string composer; + string comments; + string genre; + uint16_t genreType; + string releaseDate; + MP4TagTrack track; + MP4TagDisk disk; + uint16_t tempo; + uint8_t compilation; + + string tvShow; + string tvEpisodeID; + uint32_t tvSeason; + uint32_t tvEpisode; + string tvNetwork; + + string description; + string longDescription; + string lyrics; + + string sortName; + string sortArtist; + string sortAlbumArtist; + string sortAlbum; + string sortComposer; + string sortTVShow; + + CoverArtBox::ItemList artwork; + + string copyright; + string encodingTool; + string encodedBy; + string purchaseDate; + + uint8_t podcast; + string keywords; + string category; + + uint8_t hdVideo; + uint8_t mediaType; + uint8_t contentRating; + uint8_t gapless; + + string iTunesAccount; + uint8_t iTunesAccountType; + uint32_t iTunesCountry; + uint32_t cnID; + uint32_t atID; + uint64_t plID; + uint32_t geID; + +public: + Tags(); + ~Tags(); + + void c_alloc ( MP4Tags*& ); + void c_fetch ( MP4Tags*&, MP4FileHandle ); + void c_store ( MP4Tags*&, MP4FileHandle ); + void c_free ( MP4Tags*& ); + + void c_addArtwork ( MP4Tags*&, MP4TagArtwork& ); + void c_setArtwork ( MP4Tags*&, uint32_t, MP4TagArtwork& ); + void c_removeArtwork ( MP4Tags*&, uint32_t ); + + void c_setString ( const char*, string&, const char*& ); + void c_setInteger ( const uint8_t*, uint8_t&, const uint8_t*& ); + void c_setInteger ( const uint16_t*, uint16_t&, const uint16_t*& ); + void c_setInteger ( const uint32_t*, uint32_t&, const uint32_t*& ); + void c_setInteger ( const uint64_t*, uint64_t&, const uint64_t*& ); + + void c_setTrack ( const MP4TagTrack*, MP4TagTrack&, const MP4TagTrack*& ); + void c_setDisk ( const MP4TagDisk*, MP4TagDisk&, const MP4TagDisk*& ); + +private: + typedef map<string,MP4ItmfItem*> CodeItemMap; + +private: + void fetchString ( const CodeItemMap&, const string&, string&, const char*& ); + void fetchInteger ( const CodeItemMap&, const string&, uint8_t&, const uint8_t*& ); + void fetchInteger ( const CodeItemMap&, const string&, uint16_t&, const uint16_t*& ); + void fetchInteger ( const CodeItemMap&, const string&, uint32_t&, const uint32_t*& ); + void fetchInteger ( const CodeItemMap&, const string&, uint64_t&, const uint64_t*& ); + + void fetchGenre ( const CodeItemMap&, uint16_t&, const uint16_t*& ); + void fetchTrack ( const CodeItemMap&, MP4TagTrack&, const MP4TagTrack*& ); + void fetchDisk ( const CodeItemMap&, MP4TagDisk&, const MP4TagDisk*& ); + + void storeString ( MP4File&, const string&, const string&, const char* ); + void storeInteger ( MP4File&, const string&, uint8_t, const uint8_t* ); + void storeInteger ( MP4File&, const string&, uint16_t, const uint16_t* ); + void storeInteger ( MP4File&, const string&, uint32_t, const uint32_t* ); + void storeInteger ( MP4File&, const string&, uint64_t, const uint64_t* ); + + void storeGenre ( MP4File&, uint16_t, const uint16_t* ); + void storeTrack ( MP4File&, const MP4TagTrack&, const MP4TagTrack* ); + void storeDisk ( MP4File&, const MP4TagDisk&, const MP4TagDisk* ); + + void remove ( MP4File&, const string& ); + void store ( MP4File&, const string&, MP4ItmfBasicType, const void*, uint32_t ); + + void updateArtworkShadow( MP4Tags*& ); +}; + +/////////////////////////////////////////////////////////////////////////////// + +}}} // namespace mp4v2::impl::itmf + +#endif // MP4V2_IMPL_ITMF_TAGS_H diff --git a/src/itmf/generic.cpp b/src/itmf/generic.cpp new file mode 100644 index 0000000..e6e2dee --- /dev/null +++ b/src/itmf/generic.cpp @@ -0,0 +1,453 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is MP4v2. +// +// The Initial Developer of the Original Code is Kona Blend. +// Portions created by Kona Blend are Copyright (C) 2008. +// All Rights Reserved. +// +// Contributors: +// Kona Blend, kona8lend@@gmail.com +// +/////////////////////////////////////////////////////////////////////////////// + +#include "impl.h" + +namespace mp4v2 { namespace impl { namespace itmf { namespace { + +/////////////////////////////////////////////////////////////////////////////// + +void +__dataInit( MP4ItmfData& data ) +{ + data.typeSetIdentifier = 0; + data.typeCode = MP4_ITMF_BT_IMPLICIT; + data.locale = 0; + data.value = NULL; + data.valueSize = 0; +} + +void +__dataClear( MP4ItmfData& data ) +{ + if( data.value ) + free( data.value ); + __dataInit( data ); +} + +/////////////////////////////////////////////////////////////////////////////// + +void +__dataListInit( MP4ItmfDataList& list ) +{ + list.elements = NULL; + list.size = 0; +} + +void +__dataListClear( MP4ItmfDataList& list ) +{ + if( list.elements ) { + for( uint32_t i = 0; i < list.size; i++ ) + __dataClear( list.elements[i] ); + free( list.elements ); + } + + __dataListInit( list ); +} + +void +__dataListResize( MP4ItmfDataList& list, uint32_t size ) +{ + __dataListClear( list ); + + list.elements = (MP4ItmfData*)malloc( sizeof( MP4ItmfData ) * size ); + list.size = size; + + for( uint32_t i = 0; i < size; i++ ) + __dataInit( list.elements[i] ); +} + +/////////////////////////////////////////////////////////////////////////////// + +void +__itemInit( MP4ItmfItem& item ) +{ + item.index = -1; + item.code = NULL; + item.mean = NULL; + item.name = NULL; + + __dataListInit( item.dataList ); +} + +void +__itemClear( MP4ItmfItem& item ) +{ + if( item.code ) + free( item.code ); + if( item.mean ) + free( item.mean ); + if( item.name ) + free( item.name ); + + __dataListClear( item.dataList ); + __itemInit( item ); +} + +/////////////////////////////////////////////////////////////////////////////// + +void +__itemListInit( MP4ItmfItemList& list ) +{ + list.elements = NULL; + list.size = 0; +} + +void +__itemListClear( MP4ItmfItemList& list ) +{ + if( list.elements ) { + for( uint32_t i = 0; i < list.size; i++ ) + __itemClear( list.elements[i] ); + free( list.elements ); + } + + __itemListInit( list ); +} + +void +__itemListResize( MP4ItmfItemList& list, uint32_t size ) +{ + __itemListClear( list ); + if( !size ) + return; + + list.elements = (MP4ItmfItem*)malloc( sizeof( MP4ItmfItem ) * size ); + list.size = size; + + for( uint32_t i = 0; i < size; i++ ) + __itemInit( list.elements[i] ); +} + +MP4ItmfItemList* +__itemListAlloc() +{ + MP4ItmfItemList& list = *(MP4ItmfItemList*)malloc( sizeof( MP4ItmfItemList )); + __itemListInit( list ); + return &list; +} + +/////////////////////////////////////////////////////////////////////////////// + +static bool +__itemAtomToModel( uint32_t index, MP4ItemAtom& item_atom, MP4ItmfItem& model ) +{ + __itemClear( model ); + model.index = index; + model.code = strdup( item_atom.GetType() ); + + // handle special meaning atom + if( ATOMID( item_atom.GetType() ) == ATOMID( "----" )) { + // meaning is mandatory + MP4MeanAtom* mean = (MP4MeanAtom*)item_atom.FindAtom( "----.mean" ); + if( !mean ) + return true; + // copy atom UTF-8 value (not NULL-terminated) to model (NULL-terminated) + model.mean = strdup( mean->value.GetValue() ); + + // name is optional + MP4NameAtom* name = (MP4NameAtom*)item_atom.FindAtom( "----.name" ); + if( name ) { + // copy atom UTF-8 value (not NULL-terminated) to model (NULL-terminated) + model.name = strdup( name->value.GetValue() ); + } + } + + // pass 1: count data atoms + const uint32_t childCount = item_atom.GetNumberOfChildAtoms(); + uint32_t dataCount = 0; + for( uint32_t i = 0; i < childCount; i++ ) { + if( ATOMID( item_atom.GetChildAtom( i )->GetType() ) != ATOMID( "data" )) + continue; + dataCount++; + } + + // one or more data atoms is mandatory + if( dataCount < 1 ) + return true; + + __dataListResize( model.dataList, dataCount ); + + // pass 2: populate data model + for( uint32_t i = 0, idata = 0; i < childCount; i++ ) { + MP4Atom* atom = item_atom.GetChildAtom( i ); + if( ATOMID( atom->GetType() ) != ATOMID( "data" )) + continue; + + MP4DataAtom& data_atom = *(MP4DataAtom*)atom; + MP4ItmfData& data_model = model.dataList.elements[idata]; + + data_model.typeSetIdentifier = data_atom.typeSetIdentifier.GetValue(); + data_model.typeCode = (MP4ItmfBasicType)data_atom.typeCode.GetValue(); + data_model.locale = data_atom.locale.GetValue(); + + data_atom.metadata.GetValue( &data_model.value, &data_model.valueSize ); + idata++; + } + + return false; +} + +/////////////////////////////////////////////////////////////////////////////// + +static bool +__itemModelToAtom( const MP4ItmfItem& model, MP4ItemAtom& atom ) +{ + if( ATOMID( atom.GetType() ) == ATOMID( "----" )) { + ASSERT( model.mean ); // mandatory + MP4MeanAtom& meanAtom = *(MP4MeanAtom*)MP4Atom::CreateAtom( &atom, "mean" ); + atom.AddChildAtom( &meanAtom ); + meanAtom.value.SetValue( model.mean ); + + if( model.name ) { + MP4NameAtom& nameAtom = *(MP4NameAtom*)MP4Atom::CreateAtom( &atom, "name" ); + atom.AddChildAtom( &nameAtom ); + nameAtom.value.SetValue( model.name ); + } + } + + for( uint32_t i = 0; i < model.dataList.size; i++ ) { + MP4ItmfData& dataModel = model.dataList.elements[i]; + MP4DataAtom& dataAtom = *(MP4DataAtom*)MP4Atom::CreateAtom( &atom, "data" ); + atom.AddChildAtom( &dataAtom ); + + dataAtom.typeSetIdentifier.SetValue( dataModel.typeSetIdentifier ); + dataAtom.typeCode.SetValue( (itmf::BasicType)dataModel.typeCode ); + dataAtom.locale.SetValue( dataModel.locale ); + dataAtom.metadata.SetValue( dataModel.value, dataModel.valueSize ); + } + + return true; +} + +/////////////////////////////////////////////////////////////////////////////// + +} // namespace anonymous + +/////////////////////////////////////////////////////////////////////////////// + +MP4ItmfItem* +genericItemAlloc( const string& code, uint32_t numData ) +{ + MP4ItmfItem& item = *(MP4ItmfItem*)malloc( sizeof( MP4ItmfItem )); + __itemInit( item ); + item.code = strdup( code.c_str() ); + + // always create array size of 1 + __dataListResize( item.dataList, numData ); + + return &item; +} + +/////////////////////////////////////////////////////////////////////////////// + +void +genericItemFree( MP4ItmfItem* item ) +{ + if( !item ) + return; + + __itemClear( *item ); + free( item ); +} + +/////////////////////////////////////////////////////////////////////////////// + +void +genericItemListFree( MP4ItmfItemList* list ) +{ + if( !list ) + return; + + __itemListClear( *list ); + free( list ); +} + +/////////////////////////////////////////////////////////////////////////////// + +MP4ItmfItemList* +genericGetItems( MP4File& file ) +{ + MP4Atom* ilst = file.FindAtom( "moov.udta.meta.ilst" ); + if( !ilst ) + return __itemListAlloc(); + + const uint32_t itemCount = ilst->GetNumberOfChildAtoms(); + if( itemCount < 1 ) + return __itemListAlloc(); + + MP4ItmfItemList& list = *__itemListAlloc(); + __itemListResize( list, itemCount ); + + for( uint32_t i = 0; i < list.size; i++ ) + __itemAtomToModel( i, *(MP4ItemAtom*)ilst->GetChildAtom( i ), list.elements[i] ); + + return &list; +} + +/////////////////////////////////////////////////////////////////////////////// + +MP4ItmfItemList* +genericGetItemsByCode( MP4File& file, const string& code ) +{ + MP4Atom* ilst = file.FindAtom( "moov.udta.meta.ilst" ); + if( !ilst ) + return __itemListAlloc(); + + // pass 1: filter by code and populate indexList + const uint32_t childCount = ilst->GetNumberOfChildAtoms(); + vector<uint32_t> indexList; + for( uint32_t i = 0; i < childCount; i++ ) { + if( ATOMID( ilst->GetChildAtom( i )->GetType() ) != ATOMID( code.c_str() )) + continue; + indexList.push_back( i ); + } + + if( indexList.size() < 1 ) + return __itemListAlloc(); + + MP4ItmfItemList& list = *__itemListAlloc(); + __itemListResize( list, indexList.size() ); + + // pass 2: process each atom + const vector<uint32_t>::size_type max = indexList.size(); + for( vector<uint32_t>::size_type i = 0; i < max; i++ ) { + uint32_t& aidx = indexList[i]; + __itemAtomToModel( aidx, *(MP4ItemAtom*)ilst->GetChildAtom( aidx ), list.elements[i] ); + } + + return &list; +} + +/////////////////////////////////////////////////////////////////////////////// + +MP4ItmfItemList* +genericGetItemsByMeaning( MP4File& file, const string& meaning, const string& name ) +{ + MP4Atom* ilst = file.FindAtom( "moov.udta.meta.ilst" ); + if( !ilst ) + return __itemListAlloc(); + + // pass 1: filter by code and populate indexList + const uint32_t childCount = ilst->GetNumberOfChildAtoms(); + vector<uint32_t> indexList; + for( uint32_t i = 0; i < childCount; i++ ) { + MP4Atom& atom = *ilst->GetChildAtom( i ); + if( ATOMID( atom.GetType() ) != ATOMID( "----" )) + continue; + + // filter-out meaning mismatch + MP4MeanAtom* meanAtom = (MP4MeanAtom*)atom.FindAtom( "----.mean" ); + if( !meanAtom ) + continue; + if( meaning != meanAtom->value.GetValue() ) + continue; + + if( !name.empty() ) { + // filter-out name mismatch + MP4MeanAtom* nameAtom = (MP4MeanAtom*)atom.FindAtom( "----.name" ); + if( !nameAtom ) + continue; + if( name != nameAtom->value.GetValue() ) + continue; + } + + indexList.push_back( i ); + } + + if( indexList.size() < 1 ) + return __itemListAlloc(); + + MP4ItmfItemList& list = *__itemListAlloc(); + __itemListResize( list, indexList.size() ); + + // pass 2: process each atom + const vector<uint32_t>::size_type max = indexList.size(); + for( vector<uint32_t>::size_type i = 0; i < max; i++ ) { + uint32_t& aidx = indexList[i]; + __itemAtomToModel( aidx, *(MP4ItemAtom*)ilst->GetChildAtom( aidx ), list.elements[i] ); + } + + return &list; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +genericAddItem( MP4File& file, const MP4ItmfItem* item ) +{ + MP4Atom* ilst = file.FindAtom( "moov.udta.meta.ilst" ); + if( !ilst ) + return false; + + MP4ItemAtom& itemAtom = *(MP4ItemAtom*)MP4Atom::CreateAtom( ilst, item->code ); + ilst->AddChildAtom( &itemAtom ); + + return __itemModelToAtom( *item, itemAtom ); +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +genericSetItem( MP4File& file, const MP4ItmfItem* item ) +{ + if( item->index == -1 ) + return false; + + MP4Atom* ilst = file.FindAtom( "moov.udta.meta.ilst" ); + if( !ilst ) + return false; + + if( (uint32_t)item->index >= ilst->GetNumberOfChildAtoms() ) + return genericAddItem( file, item ); + + MP4ItemAtom& itemAtom = *(MP4ItemAtom*)MP4Atom::CreateAtom( ilst, item->code ); + ilst->DeleteChildAtom( ilst->GetChildAtom( item->index )); + ilst->InsertChildAtom( &itemAtom, item->index ); + + return __itemModelToAtom( *item, itemAtom ); +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +genericRemoveItem( MP4File& file, const MP4ItmfItem* item ) +{ + if( item->index == -1 ) + return false; + + MP4Atom* ilst = file.FindAtom( "moov.udta.meta.ilst" ); + if( !ilst ) + return false; + + if( (uint32_t)item->index >= ilst->GetNumberOfChildAtoms() ) + return false; + + ilst->DeleteChildAtom( ilst->GetChildAtom( item->index )); + return true; +} + +/////////////////////////////////////////////////////////////////////////////// + +}}} // namespace mp4v2::impl::itmf diff --git a/src/itmf/generic.h b/src/itmf/generic.h new file mode 100644 index 0000000..9edc7eb --- /dev/null +++ b/src/itmf/generic.h @@ -0,0 +1,66 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is MP4v2. +// +// The Initial Developer of the Original Code is Kona Blend. +// Portions created by Kona Blend are Copyright (C) 2008. +// All Rights Reserved. +// +// Contributors: +// KonaBlend, kona8lend@gmail.com +// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef MP4V2_IMPL_ITMF_GENERIC_H +#define MP4V2_IMPL_ITMF_GENERIC_H + +namespace mp4v2 { namespace impl { namespace itmf { + +/////////////////////////////////////////////////////////////////////////////// + +MP4ItmfItem* +genericItemAlloc( const string& code, uint32_t numData ); + +void +genericItemFree( MP4ItmfItem* item ); + +void +genericItemListFree( MP4ItmfItemList* list ); + +/////////////////////////////////////////////////////////////////////////////// + +MP4ItmfItemList* +genericGetItems( MP4File& file ); + +MP4ItmfItemList* +genericGetItemsByCode( MP4File& file, const string& code ); + +MP4ItmfItemList* +genericGetItemsByMeaning( MP4File& file, const string& meaning, const string& name ); + +/////////////////////////////////////////////////////////////////////////////// + +bool +genericAddItem( MP4File& file, const MP4ItmfItem* item ); + +bool +genericSetItem( MP4File& file, const MP4ItmfItem* item ); + +bool +genericRemoveItem( MP4File& file, const MP4ItmfItem* item ); + +/////////////////////////////////////////////////////////////////////////////// + +}}} // namespace mp4v2::impl::itmf + +#endif // MP4V2_IMPL_ITMF_GENERIC_H diff --git a/src/itmf/impl.h b/src/itmf/impl.h new file mode 100644 index 0000000..9c7eb44 --- /dev/null +++ b/src/itmf/impl.h @@ -0,0 +1,34 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is MP4v2. +// +// The Initial Developer of the Original Code is Kona Blend. +// Portions created by Kona Blend are Copyright (C) 2008. +// All Rights Reserved. +// +// Contributors: +// Kona Blend, kona8lend@@gmail.com +// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef MP4V2_IMPL_ITMF_IMPL_H +#define MP4V2_IMPL_ITMF_IMPL_H + +/////////////////////////////////////////////////////////////////////////////// + +#include "src/impl.h" +#include "itmf.h" + +/////////////////////////////////////////////////////////////////////////////// + +#endif // MP4V2_IMPL_ITMF_IMPL_H diff --git a/src/itmf/itmf.h b/src/itmf/itmf.h new file mode 100644 index 0000000..cad38ed --- /dev/null +++ b/src/itmf/itmf.h @@ -0,0 +1,45 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is MP4v2. +// +// The Initial Developer of the Original Code is Kona Blend. +// Portions created by Kona Blend are Copyright (C) 2008. +// All Rights Reserved. +// +// Contributors: +// Kona Blend, kona8lend@@gmail.com +// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef MP4V2_IMPL_ITMF_ITMF_H +#define MP4V2_IMPL_ITMF_ITMF_H + +/// @namespace mp4v2::impl::itmf (private) iTunes Metadata Format. +/// <b>WARNING: THIS IS A PRIVATE NAMESPACE. NOT FOR PUBLIC CONSUMPTION.</b> +/// +/// This namespace implements some features that are specified by the +/// iTunes Metadata Format Specification, revision 2008-04-16. +/// +namespace mp4v2 { namespace impl { namespace itmf { + ; +}}} + +/////////////////////////////////////////////////////////////////////////////// + +#include "CoverArtBox.h" +#include "Tags.h" +#include "generic.h" + +/////////////////////////////////////////////////////////////////////////////// + +#endif // MP4V2_IMPL_ITMF_ITMF_H diff --git a/src/itmf/type.cpp b/src/itmf/type.cpp new file mode 100644 index 0000000..da76720 --- /dev/null +++ b/src/itmf/type.cpp @@ -0,0 +1,323 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is MP4v2. +// +// The Initial Developer of the Original Code is Kona Blend. +// Portions created by Kona Blend are Copyright (C) 2008. +// All Rights Reserved. +// +// Contributors: +// Kona Blend, kona8lend@@gmail.com +// Rouven Wessling, mp4v2@rouvenwessling.de +// +/////////////////////////////////////////////////////////////////////////////// + +#include "impl.h" + +// VStudio idiocy prevents defining template instanced static data +// in a namespace. Workaround it by defining in global scope. +// Other platforms will continue to put things in the proper namespace. +#if defined( _MSC_VER ) +using namespace mp4v2::impl::itmf; +#else +namespace mp4v2 { namespace impl { namespace itmf { +#endif + +/////////////////////////////////////////////////////////////////////////////// + +template <> +const EnumBasicType::Entry EnumBasicType::data[] = { + { mp4v2::impl::itmf::BT_IMPLICIT, "implicit", "implicit" }, + { mp4v2::impl::itmf::BT_UTF8, "utf8", "UTF-8" }, + { mp4v2::impl::itmf::BT_UTF16, "utf16", "UTF-16" }, + { mp4v2::impl::itmf::BT_SJIS, "sjis", "S/JIS" }, + { mp4v2::impl::itmf::BT_HTML, "html", "HTML" }, + { mp4v2::impl::itmf::BT_XML, "xml", "XML" }, + { mp4v2::impl::itmf::BT_UUID, "uuid", "UUID" }, + { mp4v2::impl::itmf::BT_ISRC, "isrc", "ISRC" }, + { mp4v2::impl::itmf::BT_MI3P, "mi3p", "MI3P" }, + { mp4v2::impl::itmf::BT_GIF, "gif", "GIF" }, + { mp4v2::impl::itmf::BT_JPEG, "jpeg", "JPEG" }, + { mp4v2::impl::itmf::BT_PNG, "png", "PNG" }, + { mp4v2::impl::itmf::BT_URL, "url", "URL" }, + { mp4v2::impl::itmf::BT_DURATION, "duration", "duration" }, + { mp4v2::impl::itmf::BT_DATETIME, "datetime", "date/time" }, + { mp4v2::impl::itmf::BT_GENRES, "genres", "genres" }, + { mp4v2::impl::itmf::BT_INTEGER, "integer", "integer" }, + { mp4v2::impl::itmf::BT_RIAA_PA, "riaapa", "RIAA-PA" }, + { mp4v2::impl::itmf::BT_UPC, "upc", "UPC" }, + { mp4v2::impl::itmf::BT_BMP, "bmp", "BMP" }, + + { mp4v2::impl::itmf::BT_UNDEFINED } // must be last +}; + +/////////////////////////////////////////////////////////////////////////////// + +template <> +const EnumGenreType::Entry EnumGenreType::data[] = { + { mp4v2::impl::itmf::GENRE_BLUES, "blues", "Blues" }, + { mp4v2::impl::itmf::GENRE_CLASSIC_ROCK, "classicrock", "Classic Rock" }, + { mp4v2::impl::itmf::GENRE_COUNTRY, "country", "Country" }, + { mp4v2::impl::itmf::GENRE_DANCE, "dance", "Dance" }, + { mp4v2::impl::itmf::GENRE_DISCO, "disco", "Disco" }, + { mp4v2::impl::itmf::GENRE_FUNK, "funk", "Funk" }, + { mp4v2::impl::itmf::GENRE_GRUNGE, "grunge", "Grunge" }, + { mp4v2::impl::itmf::GENRE_HIP_HOP, "hiphop", "Hop-Hop" }, + { mp4v2::impl::itmf::GENRE_JAZZ, "jazz", "Jazz" }, + { mp4v2::impl::itmf::GENRE_METAL, "metal", "Metal" }, + { mp4v2::impl::itmf::GENRE_NEW_AGE, "newage", "New Age" }, + { mp4v2::impl::itmf::GENRE_OLDIES, "oldies", "Oldies" }, + { mp4v2::impl::itmf::GENRE_OTHER, "other", "Other" }, + { mp4v2::impl::itmf::GENRE_POP, "pop", "Pop" }, + { mp4v2::impl::itmf::GENRE_R_AND_B, "rand_b", "R&B" }, + { mp4v2::impl::itmf::GENRE_RAP, "rap", "Rap" }, + { mp4v2::impl::itmf::GENRE_REGGAE, "reggae", "Reggae" }, + { mp4v2::impl::itmf::GENRE_ROCK, "rock", "Rock" }, + { mp4v2::impl::itmf::GENRE_TECHNO, "techno", "Techno" }, + { mp4v2::impl::itmf::GENRE_INDUSTRIAL, "industrial", "Industrial" }, + { mp4v2::impl::itmf::GENRE_ALTERNATIVE, "alternative", "Alternative" }, + { mp4v2::impl::itmf::GENRE_SKA, "ska", "Ska" }, + { mp4v2::impl::itmf::GENRE_DEATH_METAL, "deathmetal", "Death Metal" }, + { mp4v2::impl::itmf::GENRE_PRANKS, "pranks", "Pranks" }, + { mp4v2::impl::itmf::GENRE_SOUNDTRACK, "soundtrack", "Soundtrack" }, + { mp4v2::impl::itmf::GENRE_EURO_TECHNO, "eurotechno", "Euro-Techno" }, + { mp4v2::impl::itmf::GENRE_AMBIENT, "ambient", "Ambient" }, + { mp4v2::impl::itmf::GENRE_TRIP_HOP, "triphop", "Trip-Hop" }, + { mp4v2::impl::itmf::GENRE_VOCAL, "vocal", "Vocal" }, + { mp4v2::impl::itmf::GENRE_JAZZ_FUNK, "jazzfunk", "Jazz+Funk" }, + { mp4v2::impl::itmf::GENRE_FUSION, "fusion", "Fusion" }, + { mp4v2::impl::itmf::GENRE_TRANCE, "trance", "Trance" }, + { mp4v2::impl::itmf::GENRE_CLASSICAL, "classical", "Classical" }, + { mp4v2::impl::itmf::GENRE_INSTRUMENTAL, "instrumental", "Instrumental" }, + { mp4v2::impl::itmf::GENRE_ACID, "acid", "Acid" }, + { mp4v2::impl::itmf::GENRE_HOUSE, "house", "House" }, + { mp4v2::impl::itmf::GENRE_GAME, "game", "Game" }, + { mp4v2::impl::itmf::GENRE_SOUND_CLIP, "soundclip", "Sound Clip" }, + { mp4v2::impl::itmf::GENRE_GOSPEL, "gospel", "Gospel" }, + { mp4v2::impl::itmf::GENRE_NOISE, "noise", "Noise" }, + { mp4v2::impl::itmf::GENRE_ALTERNROCK, "alternrock", "AlternRock" }, + { mp4v2::impl::itmf::GENRE_BASS, "bass", "Bass" }, + { mp4v2::impl::itmf::GENRE_SOUL, "soul", "Soul" }, + { mp4v2::impl::itmf::GENRE_PUNK, "punk", "Punk" }, + { mp4v2::impl::itmf::GENRE_SPACE, "space", "Space" }, + { mp4v2::impl::itmf::GENRE_MEDITATIVE, "meditative", "Meditative" }, + { mp4v2::impl::itmf::GENRE_INSTRUMENTAL_POP, "instrumentalpop", "Instrumental Pop" }, + { mp4v2::impl::itmf::GENRE_INSTRUMENTAL_ROCK, "instrumentalrock", "Instrumental Rock" }, + { mp4v2::impl::itmf::GENRE_ETHNIC, "ethnic", "Ethnic" }, + { mp4v2::impl::itmf::GENRE_GOTHIC, "gothic", "Gothic" }, + { mp4v2::impl::itmf::GENRE_DARKWAVE, "darkwave", "Darkwave" }, + { mp4v2::impl::itmf::GENRE_TECHNO_INDUSTRIAL, "technoindustrial", "Techno-Industrial" }, + { mp4v2::impl::itmf::GENRE_ELECTRONIC, "electronic", "Electronic" }, + { mp4v2::impl::itmf::GENRE_POP_FOLK, "popfolk", "Pop-Folk" }, + { mp4v2::impl::itmf::GENRE_EURODANCE, "eurodance", "Eurodance" }, + { mp4v2::impl::itmf::GENRE_DREAM, "dream", "Dream" }, + { mp4v2::impl::itmf::GENRE_SOUTHERN_ROCK, "southernrock", "Southern Rock" }, + { mp4v2::impl::itmf::GENRE_COMEDY, "comedy", "Comedy" }, + { mp4v2::impl::itmf::GENRE_CULT, "cult", "Cult" }, + { mp4v2::impl::itmf::GENRE_GANGSTA, "gangsta", "Gangsta" }, + { mp4v2::impl::itmf::GENRE_TOP_40, "top40", "Top 40" }, + { mp4v2::impl::itmf::GENRE_CHRISTIAN_RAP, "christianrap", "Christian Rap" }, + { mp4v2::impl::itmf::GENRE_POP_FUNK, "popfunk", "Pop/Funk" }, + { mp4v2::impl::itmf::GENRE_JUNGLE, "jungle", "Jungle" }, + { mp4v2::impl::itmf::GENRE_NATIVE_AMERICAN, "nativeamerican", "Native American" }, + { mp4v2::impl::itmf::GENRE_CABARET, "cabaret", "Cabaret" }, + { mp4v2::impl::itmf::GENRE_NEW_WAVE, "newwave", "New Wave" }, + { mp4v2::impl::itmf::GENRE_PSYCHEDELIC, "psychedelic", "Psychedelic" }, + { mp4v2::impl::itmf::GENRE_RAVE, "rave", "Rave" }, + { mp4v2::impl::itmf::GENRE_SHOWTUNES, "showtunes", "Showtunes" }, + { mp4v2::impl::itmf::GENRE_TRAILER, "trailer", "Trailer" }, + { mp4v2::impl::itmf::GENRE_LO_FI, "lofi", "Lo-Fi" }, + { mp4v2::impl::itmf::GENRE_TRIBAL, "tribal", "Tribal" }, + { mp4v2::impl::itmf::GENRE_ACID_PUNK, "acidpunk", "Acid Punk" }, + { mp4v2::impl::itmf::GENRE_ACID_JAZZ, "acidjazz", "Acid Jazz" }, + { mp4v2::impl::itmf::GENRE_POLKA, "polka", "Polka" }, + { mp4v2::impl::itmf::GENRE_RETRO, "retro", "Retro" }, + { mp4v2::impl::itmf::GENRE_MUSICAL, "musical", "Musical" }, + { mp4v2::impl::itmf::GENRE_ROCK_AND_ROLL, "rockand_roll", "Rock & Roll" }, + + { mp4v2::impl::itmf::GENRE_HARD_ROCK, "hardrock", "Hard Rock" }, + { mp4v2::impl::itmf::GENRE_FOLK, "folk", "Folk" }, + { mp4v2::impl::itmf::GENRE_FOLK_ROCK, "folkrock", "Folk-Rock" }, + { mp4v2::impl::itmf::GENRE_NATIONAL_FOLK, "nationalfolk", "National Folk" }, + { mp4v2::impl::itmf::GENRE_SWING, "swing", "Swing" }, + { mp4v2::impl::itmf::GENRE_FAST_FUSION, "fastfusion", "Fast Fusion" }, + { mp4v2::impl::itmf::GENRE_BEBOB, "bebob", "Bebob" }, + { mp4v2::impl::itmf::GENRE_LATIN, "latin", "Latin" }, + { mp4v2::impl::itmf::GENRE_REVIVAL, "revival", "Revival" }, + { mp4v2::impl::itmf::GENRE_CELTIC, "celtic", "Celtic" }, + { mp4v2::impl::itmf::GENRE_BLUEGRASS, "bluegrass", "Bluegrass" }, + { mp4v2::impl::itmf::GENRE_AVANTGARDE, "avantgarde", "Avantgarde" }, + { mp4v2::impl::itmf::GENRE_GOTHIC_ROCK, "gothicrock", "Gothic Rock" }, + { mp4v2::impl::itmf::GENRE_PROGRESSIVE_ROCK, "progressiverock", "Progresive Rock" }, + { mp4v2::impl::itmf::GENRE_PSYCHEDELIC_ROCK, "psychedelicrock", "Psychedelic Rock" }, + { mp4v2::impl::itmf::GENRE_SYMPHONIC_ROCK, "symphonicrock", "SYMPHONIC_ROCK" }, + { mp4v2::impl::itmf::GENRE_SLOW_ROCK, "slowrock", "Slow Rock" }, + { mp4v2::impl::itmf::GENRE_BIG_BAND, "bigband", "Big Band" }, + { mp4v2::impl::itmf::GENRE_CHORUS, "chorus", "Chorus" }, + { mp4v2::impl::itmf::GENRE_EASY_LISTENING, "easylistening", "Easy Listening" }, + { mp4v2::impl::itmf::GENRE_ACOUSTIC, "acoustic", "Acoustic" }, + { mp4v2::impl::itmf::GENRE_HUMOUR, "humour", "Humor" }, + { mp4v2::impl::itmf::GENRE_SPEECH, "speech", "Speech" }, + { mp4v2::impl::itmf::GENRE_CHANSON, "chanson", "Chason" }, + { mp4v2::impl::itmf::GENRE_OPERA, "opera", "Opera" }, + { mp4v2::impl::itmf::GENRE_CHAMBER_MUSIC, "chambermusic", "Chamber Music" }, + { mp4v2::impl::itmf::GENRE_SONATA, "sonata", "Sonata" }, + { mp4v2::impl::itmf::GENRE_SYMPHONY, "symphony", "Symphony" }, + { mp4v2::impl::itmf::GENRE_BOOTY_BASS, "bootybass", "Booty Bass" }, + { mp4v2::impl::itmf::GENRE_PRIMUS, "primus", "Primus" }, + { mp4v2::impl::itmf::GENRE_PORN_GROOVE, "porngroove", "Porn Groove" }, + { mp4v2::impl::itmf::GENRE_SATIRE, "satire", "Satire" }, + { mp4v2::impl::itmf::GENRE_SLOW_JAM, "slowjam", "Slow Jam" }, + { mp4v2::impl::itmf::GENRE_CLUB, "club", "Club" }, + { mp4v2::impl::itmf::GENRE_TANGO, "tango", "Tango" }, + { mp4v2::impl::itmf::GENRE_SAMBA, "samba", "Samba" }, + { mp4v2::impl::itmf::GENRE_FOLKLORE, "folklore", "Folklore" }, + { mp4v2::impl::itmf::GENRE_BALLAD, "ballad", "Ballad" }, + { mp4v2::impl::itmf::GENRE_POWER_BALLAD, "powerballad", "Power Ballad" }, + { mp4v2::impl::itmf::GENRE_RHYTHMIC_SOUL, "rhythmicsoul", "Rhythmic Soul" }, + { mp4v2::impl::itmf::GENRE_FREESTYLE, "freestyle", "Freestyle" }, + { mp4v2::impl::itmf::GENRE_DUET, "duet", "Duet" }, + { mp4v2::impl::itmf::GENRE_PUNK_ROCK, "punkrock", "Punk Rock" }, + { mp4v2::impl::itmf::GENRE_DRUM_SOLO, "drumsolo", "Drum Solo" }, + { mp4v2::impl::itmf::GENRE_A_CAPELLA, "acapella", "A capella" }, + { mp4v2::impl::itmf::GENRE_EURO_HOUSE, "eurohouse", "Euro-House" }, + { mp4v2::impl::itmf::GENRE_DANCE_HALL, "dancehall", "Dance Hall" }, + { mp4v2::impl::itmf::GENRE_NONE, "none", "none" }, + + { mp4v2::impl::itmf::GENRE_UNDEFINED } // must be last +}; + +/////////////////////////////////////////////////////////////////////////////// + +template <> +const EnumStikType::Entry EnumStikType::data[] = { + { mp4v2::impl::itmf::STIK_OLD_MOVIE, "oldmovie", "Movie" }, + { mp4v2::impl::itmf::STIK_NORMAL, "normal", "Normal" }, + { mp4v2::impl::itmf::STIK_AUDIOBOOK, "audiobook", "Audio Book" }, + { mp4v2::impl::itmf::STIK_MUSIC_VIDEO, "musicvideo", "Music Video" }, + { mp4v2::impl::itmf::STIK_MOVIE, "movie", "Movie" }, + { mp4v2::impl::itmf::STIK_TV_SHOW, "tvshow", "TV Show" }, + { mp4v2::impl::itmf::STIK_BOOKLET, "booklet", "Booklet" }, + { mp4v2::impl::itmf::STIK_RINGTONE, "ringtone", "Ringtone" }, + + { mp4v2::impl::itmf::STIK_UNDEFINED } // must be last +}; + +/////////////////////////////////////////////////////////////////////////////// + +template <> +const EnumAccountType::Entry EnumAccountType::data[] = { + { mp4v2::impl::itmf::AT_ITUNES, "itunes", "iTunes" }, + { mp4v2::impl::itmf::AT_AOL, "aol", "AOL" }, + + { mp4v2::impl::itmf::AT_UNDEFINED } // must be last +}; + +/////////////////////////////////////////////////////////////////////////////// + +template <> +const EnumCountryCode::Entry EnumCountryCode::data[] = { + { mp4v2::impl::itmf::CC_USA, "usa", "United States" }, + { mp4v2::impl::itmf::CC_USA, "fra", "France" }, + { mp4v2::impl::itmf::CC_DEU, "ger", "Germany" }, + { mp4v2::impl::itmf::CC_GBR, "gbr", "United Kingdom" }, + { mp4v2::impl::itmf::CC_AUT, "aut", "Austria" }, + { mp4v2::impl::itmf::CC_BEL, "bel", "Belgium" }, + { mp4v2::impl::itmf::CC_FIN, "fin", "Finland" }, + { mp4v2::impl::itmf::CC_GRC, "grc", "Greece" }, + { mp4v2::impl::itmf::CC_IRL, "irl", "Ireland" }, + { mp4v2::impl::itmf::CC_ITA, "ita", "Italy" }, + { mp4v2::impl::itmf::CC_LUX, "lux", "Luxembourg" }, + { mp4v2::impl::itmf::CC_NLD, "nld", "Netherlands" }, + { mp4v2::impl::itmf::CC_PRT, "prt", "Portugal" }, + { mp4v2::impl::itmf::CC_ESP, "esp", "Spain" }, + { mp4v2::impl::itmf::CC_CAN, "can", "Canada" }, + { mp4v2::impl::itmf::CC_SWE, "swe", "Sweden" }, + { mp4v2::impl::itmf::CC_NOR, "nor", "Norway" }, + { mp4v2::impl::itmf::CC_DNK, "dnk", "Denmark" }, + { mp4v2::impl::itmf::CC_CHE, "che", "Switzerland" }, + { mp4v2::impl::itmf::CC_AUS, "aus", "Australia" }, + { mp4v2::impl::itmf::CC_NZL, "nzl", "New Zealand" }, + { mp4v2::impl::itmf::CC_JPN, "jpn", "Japan" }, + + { mp4v2::impl::itmf::CC_UNDEFINED } // must be last +}; + +/////////////////////////////////////////////////////////////////////////////// + +template <> +const EnumContentRating::Entry EnumContentRating::data[] = { + { mp4v2::impl::itmf::CR_NONE, "none", "None" }, + { mp4v2::impl::itmf::CR_CLEAN, "clean", "Clean" }, + { mp4v2::impl::itmf::CR_EXPLICIT, "explicit", "Explicit" }, + + { mp4v2::impl::itmf::CR_UNDEFINED } // must be last +}; + +/////////////////////////////////////////////////////////////////////////////// + +#if defined( _MSC_VER ) +namespace mp4v2 { namespace impl { namespace itmf { +#endif + +/////////////////////////////////////////////////////////////////////////////// + +// must come after static data init +const EnumBasicType enumBasicType; +const EnumGenreType enumGenreType; +const EnumStikType enumStikType; +const EnumAccountType enumAccountType; +const EnumCountryCode enumCountryCode; +const EnumContentRating enumContentRating; + +/////////////////////////////////////////////////////////////////////////////// + +namespace { + struct ImageHeader { + BasicType type; + string data; + }; + + // POD static init does not need singletons + static ImageHeader IMAGE_HEADERS[] = { + { BT_BMP, "\x4d\x42" }, + { BT_GIF, "GIF87a" }, + { BT_GIF, "GIF89a" }, + { BT_JPEG, "\xff\xd8\xff\xe0" }, + { BT_PNG, "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a" }, + { BT_UNDEFINED } // must be last + }; +} + +BasicType +computeBasicType( const void* buffer, uint32_t size ) +{ + ImageHeader* found = NULL; + for( ImageHeader* p = IMAGE_HEADERS; p->type != BT_UNDEFINED; p++ ) { + ImageHeader& h = *p; + + if( size < h.data.size() ) + continue; + + if( memcmp(h.data.data(), buffer, h.data.size()) == 0 ) { + found = &h; + break; + } + } + + return found ? found->type : BT_IMPLICIT; +} + +/////////////////////////////////////////////////////////////////////////////// + +}}} // namespace mp4v2::impl::itmf diff --git a/src/itmf/type.h b/src/itmf/type.h new file mode 100644 index 0000000..484c241 --- /dev/null +++ b/src/itmf/type.h @@ -0,0 +1,296 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is MP4v2. +// +// The Initial Developer of the Original Code is Kona Blend. +// Portions created by Kona Blend are Copyright (C) 2008. +// All Rights Reserved. +// +// Contributors: +// Kona Blend, kona8lend@@gmail.com +// Rouven Wessling, mp4v2@rouvenwessling.de +// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef MP4V2_IMPL_ITMF_TYPE_H +#define MP4V2_IMPL_ITMF_TYPE_H + +namespace mp4v2 { namespace impl { namespace itmf { + +/////////////////////////////////////////////////////////////////////////////// + +/// Basic set of types as detailed in spec. +enum BasicType { + BT_IMPLICIT = 0, ///< for use with tags for which no type needs to be indicated + BT_UTF8 = 1, ///< without any count or null terminator + BT_UTF16 = 2, ///< also known as UTF-16BE + BT_SJIS = 3, ///< deprecated unless it is needed for special Japanese characters + BT_HTML = 6, ///< the HTML file header specifies which HTML version + BT_XML = 7, ///< the XML header must identify the DTD or schemas + BT_UUID = 8, ///< also known as GUID; stored as 16 bytes in binary (valid as an ID) + BT_ISRC = 9, ///< stored as UTF-8 text (valid as an ID) + BT_MI3P = 10, ///< stored as UTF-8 text (valid as an ID) + BT_GIF = 12, ///< (deprecated) a GIF image + BT_JPEG = 13, ///< a JPEG image + BT_PNG = 14, ///< a PNG image + BT_URL = 15, ///< absolute, in UTF-8 characters + BT_DURATION = 16, ///< in milliseconds, 32-bit integer + BT_DATETIME = 17, ///< in UTC, counting seconds since midnight, January 1, 1904; 32 or 64-bits + BT_GENRES = 18, ///< a list of enumerated values, see #Genre + BT_INTEGER = 21, ///< a signed big-endian integer with length one of { 1,2,3,4,8 } bytes + BT_RIAA_PA = 24, ///< RIAA parental advisory; { -1=no, 1=yes, 0=unspecified }, 8-bit ingteger + BT_UPC = 25, ///< Universal Product Code, in text UTF-8 format (valid as an ID) + BT_BMP = 27, ///< Windows bitmap image + + BT_UNDEFINED = 255 +}; + +typedef Enum<BasicType,BT_UNDEFINED> EnumBasicType; +MP4V2_EXPORT extern const EnumBasicType enumBasicType; + +/////////////////////////////////////////////////////////////////////////////// + +/// enumerated genre as defined in ID3v1 specification but +1 as per iTMF spec. +/// Note values 80 and higher are Winamp extensions. +enum GenreType { + GENRE_UNDEFINED = 0, + + /* ID3v1 standard */ + GENRE_BLUES = 1, + GENRE_CLASSIC_ROCK = 2, + GENRE_COUNTRY = 3, + GENRE_DANCE = 4, + GENRE_DISCO = 5, + GENRE_FUNK = 6, + GENRE_GRUNGE = 7, + GENRE_HIP_HOP = 8, + GENRE_JAZZ = 9, + GENRE_METAL = 10, + GENRE_NEW_AGE = 11, + GENRE_OLDIES = 12, + GENRE_OTHER = 13, + GENRE_POP = 14, + GENRE_R_AND_B = 15, + GENRE_RAP = 16, + GENRE_REGGAE = 17, + GENRE_ROCK = 18, + GENRE_TECHNO = 19, + GENRE_INDUSTRIAL = 20, + GENRE_ALTERNATIVE = 21, + GENRE_SKA = 22, + GENRE_DEATH_METAL = 23, + GENRE_PRANKS = 24, + GENRE_SOUNDTRACK = 25, + GENRE_EURO_TECHNO = 26, + GENRE_AMBIENT = 27, + GENRE_TRIP_HOP = 28, + GENRE_VOCAL = 29, + GENRE_JAZZ_FUNK = 30, + GENRE_FUSION = 31, + GENRE_TRANCE = 32, + GENRE_CLASSICAL = 33, + GENRE_INSTRUMENTAL = 34, + GENRE_ACID = 35, + GENRE_HOUSE = 36, + GENRE_GAME = 37, + GENRE_SOUND_CLIP = 38, + GENRE_GOSPEL = 39, + GENRE_NOISE = 40, + GENRE_ALTERNROCK = 41, + GENRE_BASS = 42, + GENRE_SOUL = 43, + GENRE_PUNK = 44, + GENRE_SPACE = 45, + GENRE_MEDITATIVE = 46, + GENRE_INSTRUMENTAL_POP = 47, + GENRE_INSTRUMENTAL_ROCK = 48, + GENRE_ETHNIC = 49, + GENRE_GOTHIC = 50, + GENRE_DARKWAVE = 51, + GENRE_TECHNO_INDUSTRIAL = 52, + GENRE_ELECTRONIC = 53, + GENRE_POP_FOLK = 54, + GENRE_EURODANCE = 55, + GENRE_DREAM = 56, + GENRE_SOUTHERN_ROCK = 57, + GENRE_COMEDY = 58, + GENRE_CULT = 59, + GENRE_GANGSTA = 60, + GENRE_TOP_40 = 61, + GENRE_CHRISTIAN_RAP = 62, + GENRE_POP_FUNK = 63, + GENRE_JUNGLE = 64, + GENRE_NATIVE_AMERICAN = 65, + GENRE_CABARET = 66, + GENRE_NEW_WAVE = 67, + GENRE_PSYCHEDELIC = 68, + GENRE_RAVE = 69, + GENRE_SHOWTUNES = 70, + GENRE_TRAILER = 71, + GENRE_LO_FI = 72, + GENRE_TRIBAL = 73, + GENRE_ACID_PUNK = 74, + GENRE_ACID_JAZZ = 75, + GENRE_POLKA = 76, + GENRE_RETRO = 77, + GENRE_MUSICAL = 78, + GENRE_ROCK_AND_ROLL = 79, + + /* Winamp extension */ + GENRE_HARD_ROCK = 80, + GENRE_FOLK = 81, + GENRE_FOLK_ROCK = 82, + GENRE_NATIONAL_FOLK = 83, + GENRE_SWING = 84, + GENRE_FAST_FUSION = 85, + GENRE_BEBOB = 86, + GENRE_LATIN = 87, + GENRE_REVIVAL = 88, + GENRE_CELTIC = 89, + GENRE_BLUEGRASS = 90, + GENRE_AVANTGARDE = 91, + GENRE_GOTHIC_ROCK = 92, + GENRE_PROGRESSIVE_ROCK = 93, + GENRE_PSYCHEDELIC_ROCK = 94, + GENRE_SYMPHONIC_ROCK = 95, + GENRE_SLOW_ROCK = 96, + GENRE_BIG_BAND = 97, + GENRE_CHORUS = 98, + GENRE_EASY_LISTENING = 99, + GENRE_ACOUSTIC = 100, + GENRE_HUMOUR = 101, + GENRE_SPEECH = 102, + GENRE_CHANSON = 103, + GENRE_OPERA = 104, + GENRE_CHAMBER_MUSIC = 105, + GENRE_SONATA = 106, + GENRE_SYMPHONY = 107, + GENRE_BOOTY_BASS = 108, + GENRE_PRIMUS = 109, + GENRE_PORN_GROOVE = 110, + GENRE_SATIRE = 111, + GENRE_SLOW_JAM = 112, + GENRE_CLUB = 113, + GENRE_TANGO = 114, + GENRE_SAMBA = 115, + GENRE_FOLKLORE = 116, + GENRE_BALLAD = 117, + GENRE_POWER_BALLAD = 118, + GENRE_RHYTHMIC_SOUL = 119, + GENRE_FREESTYLE = 120, + GENRE_DUET = 121, + GENRE_PUNK_ROCK = 122, + GENRE_DRUM_SOLO = 123, + GENRE_A_CAPELLA = 124, + GENRE_EURO_HOUSE = 125, + GENRE_DANCE_HALL = 126, + + GENRE_NONE = 255 +}; + +typedef Enum<GenreType,GENRE_UNDEFINED> EnumGenreType; +MP4V2_EXPORT extern const EnumGenreType enumGenreType; + +/////////////////////////////////////////////////////////////////////////////// + +/// enumerated 8-bit Video Type used by iTunes. +/// Note values are not formally defined in any specification. +enum StikType { + STIK_OLD_MOVIE = 0, + STIK_NORMAL = 1, + STIK_AUDIOBOOK = 2, + STIK_MUSIC_VIDEO = 6, + STIK_MOVIE = 9, + STIK_TV_SHOW = 10, + STIK_BOOKLET = 11, + STIK_RINGTONE = 14, + + STIK_UNDEFINED = 255 +}; + +typedef Enum<StikType,STIK_UNDEFINED> EnumStikType; +MP4V2_EXPORT extern const EnumStikType enumStikType; + +/////////////////////////////////////////////////////////////////////////////// + +/// enumerated 8-bit Account Type used by the iTunes Store. +/// Note values are not formally defined in any specification. +enum AccountType { + AT_ITUNES = 0, + AT_AOL = 1, + + AT_UNDEFINED = 255 +}; + +typedef Enum<AccountType,AT_UNDEFINED> EnumAccountType; +MP4V2_EXPORT extern const EnumAccountType enumAccountType; + +/////////////////////////////////////////////////////////////////////////////// + +/// enumerated 32-bit Country Code used by the iTunes Store. +/// Note values are not formally defined in any specification. +enum CountryCode { + CC_USA = 143441, + CC_FRA = 143442, + CC_DEU = 143443, + CC_GBR = 143444, + CC_AUT = 143445, + CC_BEL = 143446, + CC_FIN = 143447, + CC_GRC = 143448, + CC_IRL = 143449, + CC_ITA = 143450, + CC_LUX = 143451, + CC_NLD = 143452, + CC_PRT = 143453, + CC_ESP = 143454, + CC_CAN = 143455, + CC_SWE = 143456, + CC_NOR = 143457, + CC_DNK = 143458, + CC_CHE = 143459, + CC_AUS = 143460, + CC_NZL = 143461, + CC_JPN = 143462, + + CC_UNDEFINED = 0 +}; + +typedef Enum<CountryCode,CC_UNDEFINED> EnumCountryCode; +MP4V2_EXPORT extern const EnumCountryCode enumCountryCode; + +/////////////////////////////////////////////////////////////////////////////// + +/// enumerated 8-bit Content Rating used by iTunes. +/// Note values are not formally defined in any specification. +enum ContentRating { + CR_NONE = 0, + CR_CLEAN = 2, + CR_EXPLICIT = 4, + + CR_UNDEFINED = 255 +}; + +typedef Enum<ContentRating,CR_UNDEFINED> EnumContentRating; +MP4V2_EXPORT extern const EnumContentRating enumContentRating; + +/////////////////////////////////////////////////////////////////////////////// +/// compute BasicType by examining raw bytes header. +MP4V2_EXPORT BasicType +computeBasicType( const void* buffer, uint32_t size ); + +/////////////////////////////////////////////////////////////////////////////// + +}}} // namespace mp4v2::impl::itmf + +#endif // MP4V2_IMPL_ITMF_TYPE_H diff --git a/src/mp4.cpp b/src/mp4.cpp new file mode 100644 index 0000000..e5ce1d0 --- /dev/null +++ b/src/mp4.cpp @@ -0,0 +1,3951 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001 - 2005. All Rights Reserved. + * + * 3GPP features implementation is based on 3GPP's TS26.234-v5.60, + * and was contributed by Ximpo Group Ltd. + * + * Portions created by Ximpo Group Ltd. are + * Copyright (C) Ximpo Group Ltd. 2003, 2004. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + * Alix Marchandise-Franquet alix@cisco.com + * Ximpo Group Ltd. mp4v2@ximpo.com + * Bill May wmay@cisco.com + */ + +/* + * MP4 library API functions + * + * These are wrapper functions that provide C linkage conventions + * to the library, and catch any internal errors, ensuring that + * a proper return value is given. + */ + +#include "src/impl.h" + +#define PRINT_ERROR(e) \ + VERBOSE_ERROR(((MP4File*)hFile)->GetVerbosity(), e->Print()); + +using namespace mp4v2::impl; + +extern "C" { + +/////////////////////////////////////////////////////////////////////////////// + +MP4FileHandle MP4Read( const char* fileName, uint32_t verbosity ) +{ + MP4File* pFile = NULL; + try { + pFile = new MP4File( verbosity ); + pFile->Read( fileName, NULL ); + return (MP4FileHandle)pFile; + } + catch ( MP4Error* e ) { + VERBOSE_ERROR( verbosity, e->Print() ); + delete e; + delete pFile; + return MP4_INVALID_FILE_HANDLE; + } +} + +MP4FileHandle MP4ReadProvider( const char* fileName, uint32_t verbosity, const MP4FileProvider* fileProvider ) +{ + MP4File* pFile = NULL; + try { + pFile = new MP4File( verbosity ); + pFile->Read( fileName, fileProvider ); + return (MP4FileHandle)pFile; + } + catch ( MP4Error* e ) { + VERBOSE_ERROR( verbosity, e->Print() ); + delete e; + delete pFile; + return MP4_INVALID_FILE_HANDLE; + } +} + +/////////////////////////////////////////////////////////////////////////////// + + MP4FileHandle MP4Create (const char* fileName, + uint32_t verbosity, + uint32_t flags) + { + return MP4CreateEx(fileName, verbosity, flags); + } + + MP4FileHandle MP4CreateEx (const char* fileName, + uint32_t verbosity, + uint32_t flags, + int add_ftyp, + int add_iods, + char* majorBrand, + uint32_t minorVersion, + char** supportedBrands, + uint32_t supportedBrandsCount) + { + MP4File* pFile = NULL; + try { + pFile = new MP4File(verbosity); + // LATER useExtensibleFormat, moov first, then mvex's + pFile->Create(fileName, flags, add_ftyp, add_iods, + majorBrand, minorVersion, + supportedBrands, supportedBrandsCount); + return (MP4FileHandle)pFile; + } + catch (MP4Error* e) { + VERBOSE_ERROR(verbosity, e->Print()); + delete e; + delete pFile; + return MP4_INVALID_FILE_HANDLE; + } + } + + MP4FileHandle MP4Modify(const char* fileName, + uint32_t verbosity, uint32_t flags) + { + MP4File* pFile = NULL; + try { + pFile = new MP4File(verbosity); + // LATER useExtensibleFormat, moov first, then mvex's + if (pFile->Modify(fileName)) + return (MP4FileHandle)pFile; + } + catch (MP4Error* e) { + VERBOSE_ERROR(verbosity, e->Print()); + delete e; + } + + if (pFile) delete pFile; + return MP4_INVALID_FILE_HANDLE; + } + + bool MP4Optimize(const char* existingFileName, + const char* newFileName, + uint32_t verbosity) + { + try { + MP4File* pFile = new MP4File(verbosity); + pFile->Optimize(existingFileName, newFileName); + delete pFile; + return true; + } + catch (MP4Error* e) { + VERBOSE_ERROR(verbosity, e->Print()); + delete e; + } + return false; + } + + void MP4Close(MP4FileHandle hFile) + { + if( !MP4_IS_VALID_FILE_HANDLE( hFile )) + return; + + MP4File& f = *(MP4File*)hFile; + try { + f.Close(); + } + catch ( MP4Error* e ) { + PRINT_ERROR( e ); + delete e; + } + + delete &f; + } + + bool MP4Dump( + MP4FileHandle hFile, + FILE* pDumpFile, + bool dumpImplicits) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + ((MP4File*)hFile)->Dump(pDumpFile, dumpImplicits); + return true; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; + } + + + /* specific file properties */ + + uint32_t MP4GetVerbosity(MP4FileHandle hFile) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetVerbosity(); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return 0; + } + + void MP4SetVerbosity(MP4FileHandle hFile, uint32_t verbosity) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + ((MP4File*)hFile)->SetVerbosity(verbosity); + return; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return; + } + + MP4Duration MP4GetDuration(MP4FileHandle hFile) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetDuration(); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return MP4_INVALID_DURATION; + } + + uint32_t MP4GetTimeScale(MP4FileHandle hFile) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetTimeScale(); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return 0; + } + + bool MP4SetTimeScale(MP4FileHandle hFile, uint32_t value) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + ((MP4File*)hFile)->SetTimeScale(value); + return true; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; + } + + uint8_t MP4GetODProfileLevel(MP4FileHandle hFile) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetODProfileLevel(); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return 0; + } + + bool MP4SetODProfileLevel(MP4FileHandle hFile, uint8_t value) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + ((MP4File*)hFile)->SetODProfileLevel(value); + return true; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; + } + + uint8_t MP4GetSceneProfileLevel(MP4FileHandle hFile) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetSceneProfileLevel(); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return 0; + } + + bool MP4SetSceneProfileLevel(MP4FileHandle hFile, uint8_t value) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + ((MP4File*)hFile)->SetSceneProfileLevel(value); + return true; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; + } + + uint8_t MP4GetVideoProfileLevel(MP4FileHandle hFile, + MP4TrackId trackId) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetVideoProfileLevel(); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + if (MP4_IS_VALID_TRACK_ID(trackId)) { + uint8_t *foo; + uint32_t bufsize; + uint8_t type; + // for mpeg4 video tracks, try to look for the VOSH header, + // which has this info. + type = MP4GetTrackEsdsObjectTypeId(hFile, trackId); + if (type == MP4_MPEG4_VIDEO_TYPE) { + if (MP4GetTrackESConfiguration(hFile, + trackId, + &foo, + &bufsize)) { + uint8_t *ptr = foo; + while (bufsize > 0) { + if (MP4V2_HTONL(*(uint32_t *)ptr) == 0x1b0) { + uint8_t ret = ptr[4]; + free(foo); + return ret; + } + ptr++; + bufsize--; + } + free(foo); + } + } + } + + } + return 0; + } + + void MP4SetVideoProfileLevel(MP4FileHandle hFile, uint8_t value) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + ((MP4File*)hFile)->SetVideoProfileLevel(value); + return ; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return ; + } + + uint8_t MP4GetAudioProfileLevel(MP4FileHandle hFile) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetAudioProfileLevel(); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return 0; + } + + void MP4SetAudioProfileLevel(MP4FileHandle hFile, uint8_t value) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + ((MP4File*)hFile)->SetAudioProfileLevel(value); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + } + + uint8_t MP4GetGraphicsProfileLevel(MP4FileHandle hFile) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetGraphicsProfileLevel(); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return 0; + } + + bool MP4SetGraphicsProfileLevel(MP4FileHandle hFile, uint8_t value) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + ((MP4File*)hFile)->SetGraphicsProfileLevel(value); + return true; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; + } + + /* generic file properties */ + + bool MP4HaveAtom (MP4FileHandle hFile, const char *atomName) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File *)hFile)->FindAtom(atomName) != NULL; + } catch (MP4Error *e) { + PRINT_ERROR(e); + delete e; + } + } + return false; + } + + bool MP4GetIntegerProperty( + MP4FileHandle hFile, const char* propName, uint64_t *retvalue) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + *retvalue = ((MP4File*)hFile)->GetIntegerProperty(propName); + return true; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; + } + + bool MP4GetFloatProperty( + MP4FileHandle hFile, const char* propName, float *retvalue) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + *retvalue = ((MP4File*)hFile)->GetFloatProperty(propName); + return true; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; + } + + bool MP4GetStringProperty( + MP4FileHandle hFile, const char* propName, + const char **retvalue) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + *retvalue = ((MP4File*)hFile)->GetStringProperty(propName); + return true; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; + } + + bool MP4GetBytesProperty( + MP4FileHandle hFile, const char* propName, + uint8_t** ppValue, uint32_t* pValueSize) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + ((MP4File*)hFile)->GetBytesProperty(propName, ppValue, pValueSize); + return true; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + *ppValue = NULL; + *pValueSize = 0; + return false; + } + + bool MP4SetIntegerProperty( + MP4FileHandle hFile, const char* propName, int64_t value) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + ((MP4File*)hFile)->SetIntegerProperty(propName, value); + return true; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; + } + + bool MP4SetFloatProperty( + MP4FileHandle hFile, const char* propName, float value) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + ((MP4File*)hFile)->SetFloatProperty(propName, value); + return true; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; + } + + bool MP4SetStringProperty( + MP4FileHandle hFile, const char* propName, const char* value) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + ((MP4File*)hFile)->SetStringProperty(propName, value); + return true; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; + } + + bool MP4SetBytesProperty( + MP4FileHandle hFile, const char* propName, + const uint8_t* pValue, uint32_t valueSize) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + ((MP4File*)hFile)->SetBytesProperty(propName, pValue, valueSize); + return true; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; + } + + /* track operations */ + + MP4TrackId MP4AddTrack( + MP4FileHandle hFile, const char* type) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->AddSystemsTrack(type); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return MP4_INVALID_TRACK_ID; + } + + MP4TrackId MP4AddSystemsTrack( + MP4FileHandle hFile, const char* type) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->AddSystemsTrack(type); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return MP4_INVALID_TRACK_ID; + } + + MP4TrackId MP4AddODTrack(MP4FileHandle hFile) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->AddODTrack(); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return MP4_INVALID_TRACK_ID; + } + + MP4TrackId MP4AddSceneTrack(MP4FileHandle hFile) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->AddSceneTrack(); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return MP4_INVALID_TRACK_ID; + } + + MP4TrackId MP4AddAudioTrack( + MP4FileHandle hFile, + uint32_t timeScale, + MP4Duration sampleDuration, + uint8_t audioType) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)-> + AddAudioTrack(timeScale, sampleDuration, audioType); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return MP4_INVALID_TRACK_ID; + } + +// +// API to initialize ismacryp properties to sensible defaults. +// if the input pointer is null then an ismacryp params is malloc'd. +// caller must see to it that it is properly disposed of. +// + mp4v2_ismacrypParams *MP4DefaultISMACrypParams(mp4v2_ismacrypParams *ptr) + { + try + { + if (ptr == NULL) { + ptr = (mp4v2_ismacrypParams *)MP4Malloc(sizeof(mp4v2_ismacrypParams)); + } + memset(ptr, 0, sizeof(*ptr)); + return ptr; + } + + catch (...) { + return MP4_INVALID_TRACK_ID; + } + } + + + MP4TrackId MP4AddAC3AudioTrack( + MP4FileHandle hFile, + uint32_t samplingRate, + uint8_t fscod, + uint8_t bsid, + uint8_t bsmod, + uint8_t acmod, + uint8_t lfeon, + uint8_t bit_rate_code) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)-> + AddAC3AudioTrack(samplingRate, fscod, bsid, bsmod, acmod, lfeon, bit_rate_code); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return MP4_INVALID_TRACK_ID; + } + + MP4TrackId MP4AddEncAudioTrack(MP4FileHandle hFile, + uint32_t timeScale, + MP4Duration sampleDuration, + mp4v2_ismacrypParams *icPp, + uint8_t audioType) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + if (icPp == NULL) { + return ((MP4File*)hFile)-> + AddEncAudioTrack(timeScale, sampleDuration, audioType, + 0, 0, + 0, 0, + false, NULL, false); + } else { + return ((MP4File*)hFile)-> + AddEncAudioTrack(timeScale, sampleDuration, audioType, + icPp->scheme_type, icPp->scheme_version, + icPp->key_ind_len, icPp->iv_len, + icPp->selective_enc, icPp->kms_uri, true); + } + } catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return MP4_INVALID_TRACK_ID; + } + MP4TrackId MP4AddAmrAudioTrack( + MP4FileHandle hFile, + uint32_t timeScale, + uint16_t modeSet, + uint8_t modeChangePeriod, + uint8_t framesPerSample, + bool isAmrWB) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)-> + AddAmrAudioTrack(timeScale, modeSet, modeChangePeriod, framesPerSample, isAmrWB); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return MP4_INVALID_TRACK_ID; + } + + void MP4SetAmrVendor( + MP4FileHandle hFile, + MP4TrackId trackId, + uint32_t vendor) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + ((MP4File*)hFile)-> + SetAmrVendor(trackId, vendor); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + } + + void MP4SetAmrDecoderVersion( + MP4FileHandle hFile, + MP4TrackId trackId, + uint8_t decoderVersion) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + ((MP4File*)hFile)-> + SetAmrDecoderVersion(trackId, decoderVersion); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + } + + void MP4SetAmrModeSet( + MP4FileHandle hFile, + MP4TrackId trackId, + uint16_t modeSet) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + ((MP4File*)hFile)-> + SetAmrModeSet(trackId, modeSet); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + } + + uint16_t MP4GetAmrModeSet( + MP4FileHandle hFile, + MP4TrackId trackId) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)-> + GetAmrModeSet(trackId); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return 0; + } + + MP4TrackId MP4AddHrefTrack (MP4FileHandle hFile, + uint32_t timeScale, + MP4Duration sampleDuration, + const char *base_url) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + MP4File *pFile = (MP4File *)hFile; + + return pFile->AddHrefTrack(timeScale, + sampleDuration, + base_url); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return MP4_INVALID_TRACK_ID; + } + + const char *MP4GetHrefTrackBaseUrl (MP4FileHandle hFile, + MP4TrackId trackId) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetTrackStringProperty(trackId, + "mdia.minf.stbl.stsd.href.burl.base_url"); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return NULL; + } + + MP4TrackId MP4AddVideoTrack( + MP4FileHandle hFile, + uint32_t timeScale, + MP4Duration sampleDuration, + uint16_t width, + uint16_t height, + uint8_t videoType) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + MP4File *pFile = (MP4File *)hFile; + + return pFile->AddMP4VideoTrack(timeScale, + sampleDuration, + width, + height, + videoType); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return MP4_INVALID_TRACK_ID; + } + + MP4TrackId MP4AddEncVideoTrack(MP4FileHandle hFile, + uint32_t timeScale, + MP4Duration sampleDuration, + uint16_t width, + uint16_t height, + mp4v2_ismacrypParams *icPp, + uint8_t videoType, + const char *oFormat) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + + // test for valid ismacrypt session descriptor + if (icPp == NULL) { + return MP4_INVALID_TRACK_ID; + } + MP4File *pFile = (MP4File *)hFile; + + return pFile->AddEncVideoTrack(timeScale, + sampleDuration, + width, + height, + videoType, + icPp, + oFormat); + + } catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return MP4_INVALID_TRACK_ID; + } + + MP4TrackId MP4AddColr( + MP4FileHandle hFile, MP4TrackId refTrackId, uint16_t pri, uint16_t tran, uint16_t mat) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->AddColr(refTrackId, pri, tran, mat); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return MP4_INVALID_TRACK_ID; + } + + + MP4TrackId MP4AddH264VideoTrack(MP4FileHandle hFile, + uint32_t timeScale, + MP4Duration sampleDuration, + uint16_t width, + uint16_t height, + uint8_t AVCProfileIndication, + uint8_t profile_compat, + uint8_t AVCLevelIndication, + uint8_t sampleLenFieldSizeMinusOne) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + MP4File *pFile = (MP4File *)hFile; + + return pFile->AddH264VideoTrack(timeScale, + sampleDuration, + width, + height, + AVCProfileIndication, + profile_compat, + AVCLevelIndication, + sampleLenFieldSizeMinusOne); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return MP4_INVALID_TRACK_ID; + } + + MP4TrackId MP4AddEncH264VideoTrack( + MP4FileHandle hFile, + uint32_t timeScale, + MP4Duration sampleDuration, + uint16_t width, + uint16_t height, + MP4FileHandle srcFile, + MP4TrackId srcTrackId, + mp4v2_ismacrypParams *icPp + ) + + { + MP4Atom *srcAtom; + MP4File *pFile; + + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + + pFile = (MP4File *)srcFile; + srcAtom = pFile->FindTrackAtom(srcTrackId, "mdia.minf.stbl.stsd.avc1.avcC"); + if (srcAtom == NULL) + return MP4_INVALID_TRACK_ID; + + pFile = (MP4File *)hFile; + + return pFile->AddEncH264VideoTrack(timeScale, + sampleDuration, + width, + height, + srcAtom, + icPp); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return MP4_INVALID_TRACK_ID; + } + + void MP4AddH264SequenceParameterSet (MP4FileHandle hFile, + MP4TrackId trackId, + const uint8_t *pSequence, + uint16_t sequenceLen) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + MP4File *pFile = (MP4File *)hFile; + + pFile->AddH264SequenceParameterSet(trackId, + pSequence, + sequenceLen); + return; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return; + } + void MP4AddH264PictureParameterSet (MP4FileHandle hFile, + MP4TrackId trackId, + const uint8_t *pPict, + uint16_t pictLen) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + MP4File *pFile = (MP4File *)hFile; + + pFile->AddH264PictureParameterSet(trackId, + pPict, + pictLen); + return; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return; + } + + MP4TrackId MP4AddH263VideoTrack( + MP4FileHandle hFile, + uint32_t timeScale, + MP4Duration sampleDuration, + uint16_t width, + uint16_t height, + uint8_t h263Level, + uint8_t h263Profile, + uint32_t avgBitrate, + uint32_t maxBitrate) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)-> + AddH263VideoTrack(timeScale, sampleDuration, width, height, h263Level, h263Profile, avgBitrate, maxBitrate); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + + return MP4_INVALID_TRACK_ID; + } + + void MP4SetH263Vendor( + MP4FileHandle hFile, + MP4TrackId trackId, + uint32_t vendor) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + ((MP4File*)hFile)-> + SetH263Vendor(trackId, vendor); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + } + + void MP4SetH263DecoderVersion( + MP4FileHandle hFile, + MP4TrackId trackId, + uint8_t decoderVersion) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + + try { + ((MP4File*)hFile)-> + SetH263DecoderVersion(trackId, decoderVersion); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + } + + void MP4SetH263Bitrates( + MP4FileHandle hFile, + MP4TrackId trackId, + uint32_t avgBitrate, + uint32_t maxBitrate) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + + try { + ((MP4File*)hFile)-> + SetH263Bitrates(trackId, avgBitrate, maxBitrate); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + } + + MP4TrackId MP4AddHintTrack( + MP4FileHandle hFile, MP4TrackId refTrackId) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->AddHintTrack(refTrackId); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return MP4_INVALID_TRACK_ID; + } + + MP4TrackId MP4AddTextTrack( + MP4FileHandle hFile, MP4TrackId refTrackId) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->AddTextTrack(refTrackId); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return MP4_INVALID_TRACK_ID; + } + + MP4TrackId MP4AddSubtitleTrack(MP4FileHandle hFile, + uint32_t timescale, + uint16_t width, + uint16_t height) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->AddSubtitleTrack(timescale, width, height); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return MP4_INVALID_TRACK_ID; + } + + MP4TrackId MP4AddChapterTextTrack( + MP4FileHandle hFile, MP4TrackId refTrackId, uint32_t timescale) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->AddChapterTextTrack(refTrackId, timescale); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return MP4_INVALID_TRACK_ID; + } + + MP4TrackId MP4AddPixelAspectRatio( + MP4FileHandle hFile, MP4TrackId refTrackId, uint32_t hSpacing, uint32_t vSpacing) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->AddPixelAspectRatio(refTrackId, hSpacing, vSpacing); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return MP4_INVALID_TRACK_ID; + } + + void MP4AddChapter( + MP4FileHandle hFile, MP4TrackId chapterTrackId, MP4Duration chapterDuration, const char *chapterTitle) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + ((MP4File*)hFile)->AddChapter(chapterTrackId, chapterDuration, chapterTitle); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + } + + void MP4AddNeroChapter( + MP4FileHandle hFile, MP4Timestamp chapterStart, const char *chapterTitle) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + ((MP4File*)hFile)->AddNeroChapter(chapterStart, chapterTitle); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + } + + MP4ChapterType MP4ConvertChapters( + MP4FileHandle hFile, MP4ChapterType toChapterType) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) + { + try { + return ((MP4File*)hFile)->ConvertChapters(toChapterType); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return MP4ChapterTypeNone; + } + + MP4ChapterType MP4DeleteChapters( + MP4FileHandle hFile, MP4ChapterType fromChapterType, MP4TrackId chapterTrackId) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->DeleteChapters(fromChapterType, chapterTrackId); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return MP4ChapterTypeNone; + } + + MP4ChapterType MP4GetChapters( + MP4FileHandle hFile, MP4Chapter_t ** chapterList, uint32_t * chapterCount, MP4ChapterType fromChapterType) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetChapters(chapterList, chapterCount, fromChapterType); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return MP4ChapterTypeNone; + } + + MP4ChapterType MP4SetChapters( + MP4FileHandle hFile, MP4Chapter_t * chapterList, uint32_t chapterCount, MP4ChapterType toChapterType) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->SetChapters(chapterList, chapterCount, toChapterType); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return MP4ChapterTypeNone; + } + + void MP4ChangeMovieTimeScale( + MP4FileHandle hFile, uint32_t value) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + ((MP4File*)hFile)->ChangeMovieTimeScale(value); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + } + + MP4TrackId MP4CloneTrack (MP4FileHandle srcFile, + MP4TrackId srcTrackId, + MP4FileHandle dstFile, + MP4TrackId dstHintTrackReferenceTrack) + { + MP4TrackId dstTrackId = MP4_INVALID_TRACK_ID; + + if (dstFile == NULL) { + dstFile = srcFile; + } + + const char* trackType = + MP4GetTrackType(srcFile, srcTrackId); + + if (!trackType) { + return dstTrackId; + } + + const char *media_data_name = + MP4GetTrackMediaDataName(srcFile, srcTrackId); + if (media_data_name == NULL) return dstTrackId; + + if (MP4_IS_VIDEO_TRACK_TYPE(trackType)) { + if (ATOMID(media_data_name) == ATOMID("mp4v")) { + MP4SetVideoProfileLevel(dstFile, + MP4GetVideoProfileLevel(srcFile)); + dstTrackId = MP4AddVideoTrack( + dstFile, + MP4GetTrackTimeScale(srcFile, + srcTrackId), + MP4GetTrackFixedSampleDuration(srcFile, + srcTrackId), + MP4GetTrackVideoWidth(srcFile, + srcTrackId), + MP4GetTrackVideoHeight(srcFile, + srcTrackId), + MP4GetTrackEsdsObjectTypeId(srcFile, + srcTrackId)); + } else if (ATOMID(media_data_name) == ATOMID("avc1")) { + uint8_t AVCProfileIndication; + uint8_t profile_compat; + uint8_t AVCLevelIndication; + uint32_t sampleLenFieldSizeMinusOne; + uint64_t temp; + + if (MP4GetTrackH264ProfileLevel(srcFile, srcTrackId, + &AVCProfileIndication, + &AVCLevelIndication) == false) { + return dstTrackId; + } + if (MP4GetTrackH264LengthSize(srcFile, srcTrackId, + &sampleLenFieldSizeMinusOne) == false) { + return dstTrackId; + } + sampleLenFieldSizeMinusOne--; + if (MP4GetTrackIntegerProperty(srcFile, srcTrackId, + "mdia.minf.stbl.stsd.*[0].avcC.profile_compatibility", + &temp) == false) return dstTrackId; + profile_compat = temp & 0xff; + + dstTrackId = MP4AddH264VideoTrack(dstFile, + MP4GetTrackTimeScale(srcFile, + srcTrackId), + MP4GetTrackFixedSampleDuration(srcFile, + srcTrackId), + MP4GetTrackVideoWidth(srcFile, + srcTrackId), + MP4GetTrackVideoHeight(srcFile, + srcTrackId), + AVCProfileIndication, + profile_compat, + AVCLevelIndication, + sampleLenFieldSizeMinusOne); + uint8_t **seqheader, **pictheader; + uint32_t *pictheadersize, *seqheadersize; + uint32_t ix; + MP4GetTrackH264SeqPictHeaders(srcFile, srcTrackId, + &seqheader, &seqheadersize, + &pictheader, &pictheadersize); + for (ix = 0; seqheadersize[ix] != 0; ix++) { + MP4AddH264SequenceParameterSet(dstFile, dstTrackId, + seqheader[ix], seqheadersize[ix]); + free(seqheader[ix]); + } + free(seqheader); + free(seqheadersize); + for (ix = 0; pictheadersize[ix] != 0; ix++) { + MP4AddH264PictureParameterSet(dstFile, dstTrackId, + pictheader[ix], pictheadersize[ix]); + free(pictheader[ix]); + } + free(pictheader); + free(pictheadersize); + } else + return dstTrackId; + } else if (MP4_IS_AUDIO_TRACK_TYPE(trackType)) { + if (ATOMID(media_data_name) != ATOMID("mp4a")) return dstTrackId; + MP4SetAudioProfileLevel(dstFile, + MP4GetAudioProfileLevel(srcFile)); + dstTrackId = MP4AddAudioTrack( + dstFile, + MP4GetTrackTimeScale(srcFile, srcTrackId), + MP4GetTrackFixedSampleDuration(srcFile, srcTrackId), + MP4GetTrackEsdsObjectTypeId(srcFile, srcTrackId)); + + } else if (MP4_IS_OD_TRACK_TYPE(trackType)) { + dstTrackId = MP4AddODTrack(dstFile); + + } else if (MP4_IS_SCENE_TRACK_TYPE(trackType)) { + dstTrackId = MP4AddSceneTrack(dstFile); + + } else if (MP4_IS_HINT_TRACK_TYPE(trackType)) { + if (dstHintTrackReferenceTrack == MP4_INVALID_TRACK_ID) { + dstTrackId = MP4_INVALID_TRACK_ID; + } else { + dstTrackId = MP4AddHintTrack( + dstFile, + dstHintTrackReferenceTrack); + } + + } else if (MP4_IS_SYSTEMS_TRACK_TYPE(trackType)) { + dstTrackId = MP4AddSystemsTrack(dstFile, trackType); + + } else { + dstTrackId = MP4AddTrack(dstFile, trackType); + } + + if (dstTrackId == MP4_INVALID_TRACK_ID) { + return dstTrackId; + } + + MP4SetTrackTimeScale( + dstFile, + dstTrackId, + MP4GetTrackTimeScale(srcFile, srcTrackId)); + + if (MP4_IS_AUDIO_TRACK_TYPE(trackType) + || MP4_IS_VIDEO_TRACK_TYPE(trackType)) { + // copy track ES configuration + uint8_t* pConfig = NULL; + uint32_t configSize = 0; + uint32_t verb = MP4GetVerbosity(srcFile); + MP4SetVerbosity(srcFile, verb & ~(MP4_DETAILS_ERROR)); + bool haveEs = MP4GetTrackESConfiguration(srcFile, + srcTrackId, + &pConfig, + &configSize); + MP4SetVerbosity(srcFile, verb); + if (haveEs && + pConfig != NULL && configSize != 0) { + if (!MP4SetTrackESConfiguration( + dstFile, + dstTrackId, + pConfig, + configSize)) { + free(pConfig); + MP4DeleteTrack(dstFile, dstTrackId); + return MP4_INVALID_TRACK_ID; + } + + free(pConfig); + } + } + + if (MP4_IS_HINT_TRACK_TYPE(trackType)) { + // probably not exactly what is wanted + // but caller can adjust later to fit their desires + + char* payloadName = NULL; + char *encodingParms = NULL; + uint8_t payloadNumber; + uint16_t maxPayloadSize; + + if (MP4GetHintTrackRtpPayload( + srcFile, + srcTrackId, + &payloadName, + &payloadNumber, + &maxPayloadSize, + &encodingParms)) { + + if (MP4SetHintTrackRtpPayload( + dstFile, + dstTrackId, + payloadName, + &payloadNumber, + maxPayloadSize, + encodingParms) == false) { + MP4DeleteTrack(dstFile, dstTrackId); + return MP4_INVALID_TRACK_ID; + } + } +#if 0 + MP4SetHintTrackSdp( + dstFile, + dstTrackId, + MP4GetHintTrackSdp(srcFile, srcTrackId)); +#endif + } + + return dstTrackId; + } + +// Given a track, make an encrypted clone of it in the dest. file + MP4TrackId MP4EncAndCloneTrack(MP4FileHandle srcFile, + MP4TrackId srcTrackId, + mp4v2_ismacrypParams *icPp, + MP4FileHandle dstFile, + MP4TrackId dstHintTrackReferenceTrack + ) + { + const char *oFormat; + + MP4TrackId dstTrackId = MP4_INVALID_TRACK_ID; + + if (dstFile == NULL) { + dstFile = srcFile; + } + + const char* trackType = MP4GetTrackType(srcFile, srcTrackId); + + if (!trackType) { + return dstTrackId; + } + + if (MP4_IS_VIDEO_TRACK_TYPE(trackType)) { + + // test source file format for avc1 + oFormat = MP4GetTrackMediaDataName(srcFile, srcTrackId); + if (!strcasecmp(oFormat, "avc1")) + { + dstTrackId = MP4AddEncH264VideoTrack(dstFile, + MP4GetTrackTimeScale(srcFile, srcTrackId), + MP4GetTrackFixedSampleDuration(srcFile, srcTrackId), + MP4GetTrackVideoWidth(srcFile, srcTrackId), + MP4GetTrackVideoHeight(srcFile, srcTrackId), + srcFile, + srcTrackId, + icPp + ); + } + else + { + MP4SetVideoProfileLevel(dstFile, MP4GetVideoProfileLevel(srcFile)); + dstTrackId = MP4AddEncVideoTrack(dstFile, + MP4GetTrackTimeScale(srcFile, srcTrackId), + MP4GetTrackFixedSampleDuration(srcFile, srcTrackId), + MP4GetTrackVideoWidth(srcFile, srcTrackId), + MP4GetTrackVideoHeight(srcFile, srcTrackId), + icPp, + MP4GetTrackEsdsObjectTypeId(srcFile, srcTrackId), + oFormat + ); + } + + } else if (MP4_IS_AUDIO_TRACK_TYPE(trackType)) { + MP4SetAudioProfileLevel(dstFile, MP4GetAudioProfileLevel(srcFile)); + dstTrackId = MP4AddEncAudioTrack(dstFile, + MP4GetTrackTimeScale(srcFile, srcTrackId), + MP4GetTrackFixedSampleDuration(srcFile, + srcTrackId), + icPp, + MP4GetTrackEsdsObjectTypeId(srcFile, + srcTrackId) + ); + + } else if (MP4_IS_OD_TRACK_TYPE(trackType)) { + dstTrackId = MP4AddODTrack(dstFile); + + } else if (MP4_IS_SCENE_TRACK_TYPE(trackType)) { + dstTrackId = MP4AddSceneTrack(dstFile); + + } else if (MP4_IS_HINT_TRACK_TYPE(trackType)) { + if (dstHintTrackReferenceTrack == MP4_INVALID_TRACK_ID) { + dstTrackId = MP4_INVALID_TRACK_ID; + } else { + dstTrackId = MP4AddHintTrack(dstFile, + MP4GetHintTrackReferenceTrackId(srcFile, + srcTrackId)); + } + } else if (MP4_IS_SYSTEMS_TRACK_TYPE(trackType)) { + dstTrackId = MP4AddSystemsTrack(dstFile, trackType); + + } else { + dstTrackId = MP4AddTrack(dstFile, trackType); + } + + if (dstTrackId == MP4_INVALID_TRACK_ID) { + return dstTrackId; + } + + MP4SetTrackTimeScale(dstFile, + dstTrackId, + MP4GetTrackTimeScale(srcFile, srcTrackId)); + + if (MP4_IS_AUDIO_TRACK_TYPE(trackType) + || MP4_IS_VIDEO_TRACK_TYPE(trackType)) { + // copy track ES configuration + uint8_t* pConfig = NULL; + uint32_t configSize = 0; + if (MP4GetTrackESConfiguration(srcFile, srcTrackId, + &pConfig, &configSize)) { + + if (pConfig != NULL) { + MP4SetTrackESConfiguration(dstFile, dstTrackId, + pConfig, configSize); + } + } + if (pConfig != NULL) + free(pConfig); + } + + // Bill's change to MP4CloneTrack + if (MP4_IS_HINT_TRACK_TYPE(trackType)) { + // probably not exactly what is wanted + // but caller can adjust later to fit their desires + + char* payloadName = NULL; + char *encodingParms = NULL; + uint8_t payloadNumber; + uint16_t maxPayloadSize; + + if (MP4GetHintTrackRtpPayload( + srcFile, + srcTrackId, + &payloadName, + &payloadNumber, + &maxPayloadSize, + &encodingParms)) { + + (void)MP4SetHintTrackRtpPayload( + dstFile, + dstTrackId, + payloadName, + &payloadNumber, + maxPayloadSize, + encodingParms); + } +#if 0 + MP4SetHintTrackSdp( + dstFile, + dstTrackId, + MP4GetHintTrackSdp(srcFile, srcTrackId)); +#endif + } + + return dstTrackId; + } + + MP4TrackId MP4CopyTrack(MP4FileHandle srcFile, + MP4TrackId srcTrackId, + MP4FileHandle dstFile, + bool applyEdits, + MP4TrackId dstHintTrackReferenceTrack) + { + bool copySamples = true; // LATER allow false => reference samples + + MP4TrackId dstTrackId = + MP4CloneTrack(srcFile, srcTrackId, dstFile, dstHintTrackReferenceTrack); + + if (dstTrackId == MP4_INVALID_TRACK_ID) { + return dstTrackId; + } + + bool viaEdits = + applyEdits && MP4GetTrackNumberOfEdits(srcFile, srcTrackId); + + MP4SampleId sampleId = 0; + MP4SampleId numSamples = + MP4GetTrackNumberOfSamples(srcFile, srcTrackId); + + MP4Timestamp when = 0; + MP4Duration editsDuration = + MP4GetTrackEditTotalDuration(srcFile, srcTrackId); + + while (true) { + MP4Duration sampleDuration = MP4_INVALID_DURATION; + + if (viaEdits) { + sampleId = MP4GetSampleIdFromEditTime( + srcFile, + srcTrackId, + when, + NULL, + &sampleDuration); + + // in theory, this shouldn't happen + if (sampleId == MP4_INVALID_SAMPLE_ID) { + MP4DeleteTrack(dstFile, dstTrackId); + return MP4_INVALID_TRACK_ID; + } + + when += sampleDuration; + + if (when >= editsDuration) { + break; + } + } else { + sampleId++; + if (sampleId > numSamples) { + break; + } + } + + bool rc = false; + + if (copySamples) { + rc = MP4CopySample( + srcFile, + srcTrackId, + sampleId, + dstFile, + dstTrackId, + sampleDuration); + + } else { + rc = MP4ReferenceSample( + srcFile, + srcTrackId, + sampleId, + dstFile, + dstTrackId, + sampleDuration); + } + + if (!rc) { + MP4DeleteTrack(dstFile, dstTrackId); + return MP4_INVALID_TRACK_ID; + } + } + + return dstTrackId; + } + +// Given a source track in a source file, make an encrypted copy of +// the track in the destination file, including sample encryption + MP4TrackId MP4EncAndCopyTrack(MP4FileHandle srcFile, + MP4TrackId srcTrackId, + mp4v2_ismacrypParams *icPp, + encryptFunc_t encfcnp, + uint32_t encfcnparam1, + MP4FileHandle dstFile, + bool applyEdits, + MP4TrackId dstHintTrackReferenceTrack + ) + { + bool copySamples = true; // LATER allow false => reference samples + + MP4TrackId dstTrackId = + MP4EncAndCloneTrack(srcFile, srcTrackId, + icPp, + dstFile, dstHintTrackReferenceTrack); + + if (dstTrackId == MP4_INVALID_TRACK_ID) { + return dstTrackId; + } + + bool viaEdits = + applyEdits && MP4GetTrackNumberOfEdits(srcFile, srcTrackId); + + MP4SampleId sampleId = 0; + MP4SampleId numSamples = + MP4GetTrackNumberOfSamples(srcFile, srcTrackId); + + MP4Timestamp when = 0; + MP4Duration editsDuration = + MP4GetTrackEditTotalDuration(srcFile, srcTrackId); + + while (true) { + MP4Duration sampleDuration = MP4_INVALID_DURATION; + + if (viaEdits) { + sampleId = MP4GetSampleIdFromEditTime(srcFile, + srcTrackId, + when, + NULL, + &sampleDuration); + + // in theory, this shouldn't happen + if (sampleId == MP4_INVALID_SAMPLE_ID) { + MP4DeleteTrack(dstFile, dstTrackId); + return MP4_INVALID_TRACK_ID; + } + + when += sampleDuration; + + if (when >= editsDuration) { + break; + } + } else { + sampleId++; + if (sampleId > numSamples) { + break; + } + } + + bool rc = false; + + if (copySamples) { + // encrypt and copy + rc = MP4EncAndCopySample(srcFile, + srcTrackId, + sampleId, + encfcnp, + encfcnparam1, + dstFile, + dstTrackId, + sampleDuration); + + } else { + // not sure what these are - encrypt? + rc = MP4ReferenceSample(srcFile, + srcTrackId, + sampleId, + dstFile, + dstTrackId, + sampleDuration); + } + + if (!rc) { + MP4DeleteTrack(dstFile, dstTrackId); + return MP4_INVALID_TRACK_ID; + } + } + + return dstTrackId; + } + + void MP4DeleteTrack( + MP4FileHandle hFile, + MP4TrackId trackId) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + ((MP4File*)hFile)->DeleteTrack(trackId); + return ; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return; + } + + uint32_t MP4GetNumberOfTracks( + MP4FileHandle hFile, + const char* type, + uint8_t subType) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetNumberOfTracks(type, subType); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return 0; + } + + MP4TrackId MP4FindTrackId( + MP4FileHandle hFile, + uint16_t index, + const char* type, + uint8_t subType) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->FindTrackId(index, type, subType); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return MP4_INVALID_TRACK_ID; + } + + uint16_t MP4FindTrackIndex( + MP4FileHandle hFile, MP4TrackId trackId) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->FindTrackIndex(trackId); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return (uint16_t)-1; + } + + /* specific track properties */ + + const char* MP4GetTrackType( + MP4FileHandle hFile, MP4TrackId trackId) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetTrackType(trackId); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return NULL; + } + const char* MP4GetTrackMediaDataName( + MP4FileHandle hFile, MP4TrackId trackId) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetTrackMediaDataName(trackId); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return NULL; + } + + bool MP4GetTrackMediaDataOriginalFormat( + MP4FileHandle hFile, MP4TrackId trackId, char *originalFormat, + uint32_t buflen) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + + return ((MP4File*)hFile)->GetTrackMediaDataOriginalFormat(trackId, + originalFormat, buflen); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; + } + + MP4Duration MP4GetTrackDuration( + MP4FileHandle hFile, MP4TrackId trackId) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetTrackDuration(trackId); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return MP4_INVALID_DURATION; + } + + uint32_t MP4GetTrackTimeScale( + MP4FileHandle hFile, MP4TrackId trackId) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetTrackTimeScale(trackId); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return 0; + } + + void MP4SetTrackTimeScale( + MP4FileHandle hFile, MP4TrackId trackId, uint32_t value) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + ((MP4File*)hFile)->SetTrackTimeScale(trackId, value); + return; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return; + } + + uint8_t MP4GetTrackAudioMpeg4Type( + MP4FileHandle hFile, MP4TrackId trackId) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetTrackAudioMpeg4Type(trackId); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return MP4_MPEG4_INVALID_AUDIO_TYPE; + } + + + +// Replacement to MP4GetTrackVideoType and MP4GetTrackAudioType +// Basically does the same thing but with a more self-explanatory name + uint8_t MP4GetTrackEsdsObjectTypeId( + MP4FileHandle hFile, MP4TrackId trackId) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + + return ((MP4File*)hFile)->GetTrackEsdsObjectTypeId(trackId); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return MP4_INVALID_AUDIO_TYPE; + } + + MP4Duration MP4GetTrackFixedSampleDuration( + MP4FileHandle hFile, MP4TrackId trackId) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetTrackFixedSampleDuration(trackId); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return MP4_INVALID_DURATION; + } + + uint32_t MP4GetTrackBitRate( + MP4FileHandle hFile, MP4TrackId trackId) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + MP4File *pFile = (MP4File *)hFile; + try { + return pFile->GetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.*.esds.decConfigDescr.avgBitrate"); + } + catch (MP4Error* e) { + //PRINT_ERROR(e); we don't really need to print this. + delete e; + } + // if we're here, we can't get the bitrate from above - + // lets calculate it + try { + MP4Duration trackDur; + trackDur = MP4GetTrackDuration(hFile, trackId); + uint64_t msDuration = + pFile->ConvertFromTrackDuration(trackId, trackDur, + MP4_MSECS_TIME_SCALE); + if (msDuration == 0) return 0; + + MP4Track *pTrack = pFile->GetTrack(trackId); + uint64_t bytes = pTrack->GetTotalOfSampleSizes(); + bytes *= UINT64_C(8 * 1000); + bytes /= msDuration; + return (uint32_t)bytes; + } + catch (MP4Error* e) { + PRINT_ERROR(e); // print this one. + delete e; + } + + } + return 0; + } + + bool MP4GetTrackESConfiguration( + MP4FileHandle hFile, MP4TrackId trackId, + uint8_t** ppConfig, uint32_t* pConfigSize) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + ((MP4File*)hFile)->GetTrackESConfiguration( + trackId, ppConfig, pConfigSize); + return true; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + *ppConfig = NULL; + *pConfigSize = 0; + return false; + } + bool MP4GetTrackVideoMetadata( + MP4FileHandle hFile, MP4TrackId trackId, + uint8_t** ppConfig, uint32_t* pConfigSize) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + ((MP4File*)hFile)->GetTrackVideoMetadata( + trackId, ppConfig, pConfigSize); + return true; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + *ppConfig = NULL; + *pConfigSize = 0; + return false; + } + + bool MP4SetTrackESConfiguration( + MP4FileHandle hFile, MP4TrackId trackId, + const uint8_t* pConfig, uint32_t configSize) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + ((MP4File*)hFile)->SetTrackESConfiguration( + trackId, pConfig, configSize); + return true; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; + } + + bool MP4GetTrackH264ProfileLevel (MP4FileHandle hFile, + MP4TrackId trackId, + uint8_t *pProfile, + uint8_t *pLevel) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + *pProfile = + ((MP4File *)hFile)->GetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.*[0].avcC.AVCProfileIndication"); + *pLevel = + ((MP4File *)hFile)->GetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.*[0].avcC.AVCLevelIndication"); + + return true; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; + } + void MP4GetTrackH264SeqPictHeaders (MP4FileHandle hFile, + MP4TrackId trackId, + uint8_t ***pSeqHeader, + uint32_t **pSeqHeaderSize, + uint8_t ***pPictHeader, + uint32_t **pPictHeaderSize) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + ((MP4File*)hFile)->GetTrackH264SeqPictHeaders(trackId, + pSeqHeader, + pSeqHeaderSize, + pPictHeader, + pPictHeaderSize); + return; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return; + } + bool MP4GetTrackH264LengthSize (MP4FileHandle hFile, + MP4TrackId trackId, + uint32_t *pLength) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + *pLength = 1 + + ((MP4File*) hFile)->GetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.*[0].avcC.lengthSizeMinusOne"); + return true; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; + } + + MP4SampleId MP4GetTrackNumberOfSamples( + MP4FileHandle hFile, MP4TrackId trackId) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetTrackNumberOfSamples(trackId); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return 0; + } + + uint16_t MP4GetTrackVideoWidth( + MP4FileHandle hFile, MP4TrackId trackId) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.*.width"); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return 0; + } + + uint16_t MP4GetTrackVideoHeight( + MP4FileHandle hFile, MP4TrackId trackId) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.*.height"); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return 0; + } + + double MP4GetTrackVideoFrameRate( + MP4FileHandle hFile, MP4TrackId trackId) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetTrackVideoFrameRate(trackId); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return 0.0; + } + + int MP4GetTrackAudioChannels (MP4FileHandle hFile, + MP4TrackId trackId) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetTrackAudioChannels(trackId); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return -1; + } + +// returns true if the track is a media track encrypted according to ismacryp + bool MP4IsIsmaCrypMediaTrack( + MP4FileHandle hFile, MP4TrackId trackId) + { + bool retval = false; + uint32_t verb = MP4GetVerbosity(hFile); + MP4SetVerbosity(hFile, verb & ~(MP4_DETAILS_ERROR)); + + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + retval = ((MP4File*)hFile)->IsIsmaCrypMediaTrack(trackId); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + MP4SetVerbosity(hFile, verb); + return retval; + } + + + /* generic track properties */ + + bool MP4HaveTrackAtom (MP4FileHandle hFile, + MP4TrackId trackId, + const char *atomName) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->FindTrackAtom(trackId, atomName) != NULL; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; + } + + bool MP4GetTrackIntegerProperty ( + MP4FileHandle hFile, MP4TrackId trackId, + const char* propName, + uint64_t *retvalue) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + *retvalue = ((MP4File*)hFile)->GetTrackIntegerProperty(trackId, + propName); + return true; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; + } + + bool MP4GetTrackFloatProperty( + MP4FileHandle hFile, MP4TrackId trackId, + const char* propName, + float *retvalue) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + *retvalue = ((MP4File*)hFile)->GetTrackFloatProperty(trackId, propName); + return true; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; + } + + bool MP4GetTrackStringProperty( + MP4FileHandle hFile, MP4TrackId trackId, + const char* propName, + const char **retvalue) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + *retvalue = ((MP4File*)hFile)->GetTrackStringProperty(trackId, propName); + return true; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; + } + + bool MP4GetTrackBytesProperty( + MP4FileHandle hFile, MP4TrackId trackId, const char* propName, + uint8_t** ppValue, uint32_t* pValueSize) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + ((MP4File*)hFile)->GetTrackBytesProperty( + trackId, propName, ppValue, pValueSize); + return true; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + *ppValue = NULL; + *pValueSize = 0; + return false; + } + + bool MP4SetTrackIntegerProperty( + MP4FileHandle hFile, MP4TrackId trackId, + const char* propName, int64_t value) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + ((MP4File*)hFile)->SetTrackIntegerProperty(trackId, + propName, value); + return true; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; + } + + bool MP4SetTrackFloatProperty( + MP4FileHandle hFile, MP4TrackId trackId, + const char* propName, float value) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + ((MP4File*)hFile)->SetTrackFloatProperty(trackId, propName, value); + return true; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; + } + + bool MP4SetTrackStringProperty( + MP4FileHandle hFile, MP4TrackId trackId, + const char* propName, const char* value) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + ((MP4File*)hFile)->SetTrackStringProperty(trackId, propName, value); + return true; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; + } + + bool MP4SetTrackBytesProperty( + MP4FileHandle hFile, MP4TrackId trackId, + const char* propName, const uint8_t* pValue, uint32_t valueSize) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + ((MP4File*)hFile)->SetTrackBytesProperty( + trackId, propName, pValue, valueSize); + return true; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; + } + + /* sample operations */ + + bool MP4ReadSample( + /* input parameters */ + MP4FileHandle hFile, + MP4TrackId trackId, + MP4SampleId sampleId, + /* output parameters */ + uint8_t** ppBytes, + uint32_t* pNumBytes, + MP4Timestamp* pStartTime, + MP4Duration* pDuration, + MP4Duration* pRenderingOffset, + bool* pIsSyncSample) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + ((MP4File*)hFile)->ReadSample( + trackId, + sampleId, + ppBytes, + pNumBytes, + pStartTime, + pDuration, + pRenderingOffset, + pIsSyncSample); + return true; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + *pNumBytes = 0; + return false; + } + + bool MP4ReadSampleFromTime( + /* input parameters */ + MP4FileHandle hFile, + MP4TrackId trackId, + MP4Timestamp when, + /* output parameters */ + uint8_t** ppBytes, + uint32_t* pNumBytes, + MP4Timestamp* pStartTime, + MP4Duration* pDuration, + MP4Duration* pRenderingOffset, + bool* pIsSyncSample) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + MP4SampleId sampleId = + ((MP4File*)hFile)->GetSampleIdFromTime( + trackId, when, false); + + ((MP4File*)hFile)->ReadSample( + trackId, + sampleId, + ppBytes, + pNumBytes, + pStartTime, + pDuration, + pRenderingOffset, + pIsSyncSample); + + return true; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + *pNumBytes = 0; + return false; + } + + bool MP4WriteSample( + MP4FileHandle hFile, + MP4TrackId trackId, + const uint8_t* pBytes, + uint32_t numBytes, + MP4Duration duration, + MP4Duration renderingOffset, + bool isSyncSample ) + { + if( MP4_IS_VALID_FILE_HANDLE( hFile )) { + try { + ((MP4File*)hFile)->WriteSample( + trackId, + pBytes, + numBytes, + duration, + renderingOffset, + isSyncSample ); + return true; + } + catch( MP4Error* e ) { + PRINT_ERROR( e ); + delete e; + } + } + return false; + } + + bool MP4WriteSampleDependency( + MP4FileHandle hFile, + MP4TrackId trackId, + const uint8_t* pBytes, + uint32_t numBytes, + MP4Duration duration, + MP4Duration renderingOffset, + bool isSyncSample, + uint32_t dependencyFlags ) + { + if( MP4_IS_VALID_FILE_HANDLE( hFile )) { + try { + ((MP4File*)hFile)->WriteSampleDependency( + trackId, + pBytes, + numBytes, + duration, + renderingOffset, + isSyncSample, + dependencyFlags ); + return true; + } + catch( MP4Error* e ) { + PRINT_ERROR( e ); + delete e; + } + } + return false; + } + + bool MP4CopySample( + MP4FileHandle srcFile, + MP4TrackId srcTrackId, + MP4SampleId srcSampleId, + MP4FileHandle dstFile, + MP4TrackId dstTrackId, + MP4Duration dstSampleDuration) + { + bool rc; + uint8_t* pBytes = NULL; + uint32_t numBytes = 0; + MP4Duration sampleDuration; + MP4Duration renderingOffset; + bool isSyncSample; + + // Note: we leave it up to the caller to ensure that the + // source and destination tracks are compatible. + // i.e. copying audio samples into a video track + // is unlikely to do anything useful + + rc = MP4ReadSample( + srcFile, + srcTrackId, + srcSampleId, + &pBytes, + &numBytes, + NULL, + &sampleDuration, + &renderingOffset, + &isSyncSample); + + if (!rc) { + return false; + } + + if (dstFile == MP4_INVALID_FILE_HANDLE) { + dstFile = srcFile; + } + if (dstTrackId == MP4_INVALID_TRACK_ID) { + dstTrackId = srcTrackId; + } + if (dstSampleDuration != MP4_INVALID_DURATION) { + sampleDuration = dstSampleDuration; + } + + rc = MP4WriteSample( + dstFile, + dstTrackId, + pBytes, + numBytes, + sampleDuration, + renderingOffset, + isSyncSample); + + free(pBytes); + + return rc; + } + + bool MP4EncAndCopySample( + MP4FileHandle srcFile, + MP4TrackId srcTrackId, + MP4SampleId srcSampleId, + encryptFunc_t encfcnp, + uint32_t encfcnparam1, + MP4FileHandle dstFile, + MP4TrackId dstTrackId, + MP4Duration dstSampleDuration) + { + bool rc; + uint8_t* pBytes = NULL; + uint32_t numBytes = 0; + uint8_t* encSampleData = NULL; + uint32_t encSampleLength = 0; + MP4Duration sampleDuration; + MP4Duration renderingOffset; + bool isSyncSample; + + // Note: we leave it up to the caller to ensure that the + // source and destination tracks are compatible. + // i.e. copying audio samples into a video track + // is unlikely to do anything useful + + rc = MP4ReadSample( + srcFile, + srcTrackId, + srcSampleId, + &pBytes, + &numBytes, + NULL, + &sampleDuration, + &renderingOffset, + &isSyncSample); + + if (!rc) { + return false; + } + + if (dstFile == MP4_INVALID_FILE_HANDLE) { + dstFile = srcFile; + } + if (dstTrackId == MP4_INVALID_TRACK_ID) { + dstTrackId = srcTrackId; + } + if (dstSampleDuration != MP4_INVALID_DURATION) { + sampleDuration = dstSampleDuration; + } + + //if (ismacrypEncryptSampleAddHeader(ismaCryptSId, numBytes, pBytes, + // &encSampleLength, &encSampleData) != 0) { + if (encfcnp(encfcnparam1, numBytes, pBytes, + &encSampleLength, &encSampleData) != 0) { + fprintf(stderr, + "Can't encrypt the sample and add its header %u\n", + srcSampleId); + } + + rc = MP4WriteSample( + dstFile, + dstTrackId, + encSampleData, + encSampleLength, + sampleDuration, + renderingOffset, + isSyncSample); + + free(pBytes); + + if (encSampleData != NULL) { + free(encSampleData); + } + + return rc; + } + + bool MP4ReferenceSample( + MP4FileHandle srcFile, + MP4TrackId srcTrackId, + MP4SampleId srcSampleId, + MP4FileHandle dstFile, + MP4TrackId dstTrackId, + MP4Duration dstSampleDuration) + { + // LATER Not yet implemented + return false; + } + + uint32_t MP4GetSampleSize( + MP4FileHandle hFile, + MP4TrackId trackId, + MP4SampleId sampleId) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetSampleSize( + trackId, sampleId); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return 0; + } + + uint32_t MP4GetTrackMaxSampleSize( + MP4FileHandle hFile, + MP4TrackId trackId) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetTrackMaxSampleSize(trackId); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return 0; + } + + MP4SampleId MP4GetSampleIdFromTime( + MP4FileHandle hFile, + MP4TrackId trackId, + MP4Timestamp when, + bool wantSyncSample) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetSampleIdFromTime( + trackId, when, wantSyncSample); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return MP4_INVALID_SAMPLE_ID; + } + + MP4Timestamp MP4GetSampleTime( + MP4FileHandle hFile, + MP4TrackId trackId, + MP4SampleId sampleId) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetSampleTime( + trackId, sampleId); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return MP4_INVALID_TIMESTAMP; + } + + MP4Duration MP4GetSampleDuration( + MP4FileHandle hFile, + MP4TrackId trackId, + MP4SampleId sampleId) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetSampleDuration( + trackId, sampleId); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return MP4_INVALID_DURATION; + } + + MP4Duration MP4GetSampleRenderingOffset( + MP4FileHandle hFile, + MP4TrackId trackId, + MP4SampleId sampleId) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetSampleRenderingOffset( + trackId, sampleId); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return MP4_INVALID_DURATION; + } + + bool MP4SetSampleRenderingOffset( + MP4FileHandle hFile, + MP4TrackId trackId, + MP4SampleId sampleId, + MP4Duration renderingOffset) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + ((MP4File*)hFile)->SetSampleRenderingOffset( + trackId, sampleId, renderingOffset); + return true; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; + } + + int8_t MP4GetSampleSync( + MP4FileHandle hFile, + MP4TrackId trackId, + MP4SampleId sampleId) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetSampleSync( + trackId, sampleId); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return -1; + } + + + uint64_t MP4ConvertFromMovieDuration( + MP4FileHandle hFile, + MP4Duration duration, + uint32_t timeScale) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->ConvertFromMovieDuration( + duration, timeScale); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return (uint64_t)MP4_INVALID_DURATION; + } + + uint64_t MP4ConvertFromTrackTimestamp( + MP4FileHandle hFile, + MP4TrackId trackId, + MP4Timestamp timeStamp, + uint32_t timeScale) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->ConvertFromTrackTimestamp( + trackId, timeStamp, timeScale); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return (uint64_t)MP4_INVALID_TIMESTAMP; + } + + MP4Timestamp MP4ConvertToTrackTimestamp( + MP4FileHandle hFile, + MP4TrackId trackId, + uint64_t timeStamp, + uint32_t timeScale) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->ConvertToTrackTimestamp( + trackId, timeStamp, timeScale); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return MP4_INVALID_TIMESTAMP; + } + + uint64_t MP4ConvertFromTrackDuration( + MP4FileHandle hFile, + MP4TrackId trackId, + MP4Duration duration, + uint32_t timeScale) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->ConvertFromTrackDuration( + trackId, duration, timeScale); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return (uint64_t)MP4_INVALID_DURATION; + } + + MP4Duration MP4ConvertToTrackDuration( + MP4FileHandle hFile, + MP4TrackId trackId, + uint64_t duration, + uint32_t timeScale) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->ConvertToTrackDuration( + trackId, duration, timeScale); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return MP4_INVALID_DURATION; + } + + bool MP4GetHintTrackRtpPayload( + MP4FileHandle hFile, + MP4TrackId hintTrackId, + char** ppPayloadName, + uint8_t* pPayloadNumber, + uint16_t* pMaxPayloadSize, + char **ppEncodingParams) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + ((MP4File*)hFile)->GetHintTrackRtpPayload( + hintTrackId, ppPayloadName, pPayloadNumber, pMaxPayloadSize, + ppEncodingParams); + return true; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; + } + + bool MP4SetHintTrackRtpPayload( + MP4FileHandle hFile, + MP4TrackId hintTrackId, + const char* pPayloadName, + uint8_t* pPayloadNumber, + uint16_t maxPayloadSize, + const char *encode_params, + bool include_rtp_map, + bool include_mpeg4_esid) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + ((MP4File*)hFile)->SetHintTrackRtpPayload( + hintTrackId, pPayloadName, pPayloadNumber, maxPayloadSize, encode_params, + include_rtp_map, include_mpeg4_esid); + return true; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; + } + + const char* MP4GetSessionSdp( + MP4FileHandle hFile) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetSessionSdp(); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return NULL; + } + + bool MP4SetSessionSdp( + MP4FileHandle hFile, + const char* sdpString) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + ((MP4File*)hFile)->SetSessionSdp(sdpString); + return true; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; + } + + bool MP4AppendSessionSdp( + MP4FileHandle hFile, + const char* sdpString) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + ((MP4File*)hFile)->AppendSessionSdp(sdpString); + return true; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; + } + + const char* MP4GetHintTrackSdp( + MP4FileHandle hFile, + MP4TrackId hintTrackId) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetHintTrackSdp(hintTrackId); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return NULL; + } + + bool MP4SetHintTrackSdp( + MP4FileHandle hFile, + MP4TrackId hintTrackId, + const char* sdpString) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + ((MP4File*)hFile)->SetHintTrackSdp(hintTrackId, sdpString); + return true; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; + } + + bool MP4AppendHintTrackSdp( + MP4FileHandle hFile, + MP4TrackId hintTrackId, + const char* sdpString) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + ((MP4File*)hFile)->AppendHintTrackSdp(hintTrackId, sdpString); + return true; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; + } + + MP4TrackId MP4GetHintTrackReferenceTrackId( + MP4FileHandle hFile, + MP4TrackId hintTrackId) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)-> + GetHintTrackReferenceTrackId(hintTrackId); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return MP4_INVALID_TRACK_ID; + } + + bool MP4ReadRtpHint( + MP4FileHandle hFile, + MP4TrackId hintTrackId, + MP4SampleId hintSampleId, + uint16_t* pNumPackets) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + ((MP4File*)hFile)->ReadRtpHint( + hintTrackId, hintSampleId, pNumPackets); + return true; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; + } + + uint16_t MP4GetRtpHintNumberOfPackets( + MP4FileHandle hFile, + MP4TrackId hintTrackId) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetRtpHintNumberOfPackets(hintTrackId); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return 0; + } + + int8_t MP4GetRtpPacketBFrame( + MP4FileHandle hFile, + MP4TrackId hintTrackId, + uint16_t packetIndex) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)-> + GetRtpPacketBFrame(hintTrackId, packetIndex); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return -1; + } + + int32_t MP4GetRtpPacketTransmitOffset( + MP4FileHandle hFile, + MP4TrackId hintTrackId, + uint16_t packetIndex) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)-> + GetRtpPacketTransmitOffset(hintTrackId, packetIndex); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return 0; + } + + bool MP4ReadRtpPacket( + MP4FileHandle hFile, + MP4TrackId hintTrackId, + uint16_t packetIndex, + uint8_t** ppBytes, + uint32_t* pNumBytes, + uint32_t ssrc, + bool includeHeader, + bool includePayload) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + ((MP4File*)hFile)->ReadRtpPacket( + hintTrackId, packetIndex, + ppBytes, pNumBytes, + ssrc, includeHeader, includePayload); + return true; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; + } + + MP4Timestamp MP4GetRtpTimestampStart( + MP4FileHandle hFile, + MP4TrackId hintTrackId) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetRtpTimestampStart(hintTrackId); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return MP4_INVALID_TIMESTAMP; + } + + bool MP4SetRtpTimestampStart( + MP4FileHandle hFile, + MP4TrackId hintTrackId, + MP4Timestamp rtpStart) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + ((MP4File*)hFile)->SetRtpTimestampStart( + hintTrackId, rtpStart); + return true; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; + } + + bool MP4AddRtpHint( + MP4FileHandle hFile, + MP4TrackId hintTrackId) + { + return MP4AddRtpVideoHint(hFile, hintTrackId, false, 0); + } + + bool MP4AddRtpVideoHint( + MP4FileHandle hFile, + MP4TrackId hintTrackId, + bool isBframe, + uint32_t timestampOffset) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + ((MP4File*)hFile)->AddRtpHint(hintTrackId, + isBframe, timestampOffset); + return true; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; + } + + bool MP4AddRtpPacket( + MP4FileHandle hFile, + MP4TrackId hintTrackId, + bool setMbit, + int32_t transmitOffset) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + ((MP4File*)hFile)->AddRtpPacket( + hintTrackId, setMbit, transmitOffset); + return true; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; + } + + bool MP4AddRtpImmediateData( + MP4FileHandle hFile, + MP4TrackId hintTrackId, + const uint8_t* pBytes, + uint32_t numBytes) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + ((MP4File*)hFile)->AddRtpImmediateData(hintTrackId, + pBytes, numBytes); + return true; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; + } + + bool MP4AddRtpSampleData( + MP4FileHandle hFile, + MP4TrackId hintTrackId, + MP4SampleId sampleId, + uint32_t dataOffset, + uint32_t dataLength) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + ((MP4File*)hFile)->AddRtpSampleData( + hintTrackId, sampleId, dataOffset, dataLength); + return true; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; + } + + bool MP4AddRtpESConfigurationPacket( + MP4FileHandle hFile, + MP4TrackId hintTrackId) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + ((MP4File*)hFile)->AddRtpESConfigurationPacket(hintTrackId); + return true; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; + } + + bool MP4WriteRtpHint( + MP4FileHandle hFile, + MP4TrackId hintTrackId, + MP4Duration duration, + bool isSyncSample) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + ((MP4File*)hFile)->WriteRtpHint( + hintTrackId, duration, isSyncSample); + return true; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; + } + /* 3GPP specific operations */ + + bool MP4Make3GPCompliant( + const char* fileName, + uint32_t verbosity, + char* majorBrand, + uint32_t minorVersion, + char** supportedBrands, + uint32_t supportedBrandsCount, + bool deleteIodsAtom) + { + MP4File* pFile; + pFile = NULL; + + try { + pFile = new MP4File(verbosity); + pFile->Modify(fileName); + pFile->Make3GPCompliant(fileName, majorBrand, minorVersion, supportedBrands, supportedBrandsCount, deleteIodsAtom); + pFile->Close(); + delete pFile; + return true; + } + catch (MP4Error* e) { + VERBOSE_ERROR(verbosity, e->Print()); + delete e; + } + delete pFile; + return false; + } + + /* ISMA specific operations */ + + bool MP4MakeIsmaCompliant( + const char* fileName, + uint32_t verbosity, + bool addIsmaComplianceSdp) + { + MP4File* pFile; + pFile = NULL; + + try { + pFile = new MP4File(verbosity); + pFile->Modify(fileName); + pFile->MakeIsmaCompliant(addIsmaComplianceSdp); + pFile->Close(); + delete pFile; + return true; + } + catch (MP4Error* e) { + VERBOSE_ERROR(verbosity, e->Print()); + delete e; + } + delete pFile; + return false; + } + + char* MP4MakeIsmaSdpIod( + uint8_t videoProfile, + uint32_t videoBitrate, + uint8_t* videoConfig, + uint32_t videoConfigLength, + uint8_t audioProfile, + uint32_t audioBitrate, + uint8_t* audioConfig, + uint32_t audioConfigLength, + uint32_t verbosity) + { + MP4File* pFile = NULL; + + try { + pFile = new MP4File(verbosity); + + uint8_t* pBytes = NULL; + uint64_t numBytes = 0; + + pFile->CreateIsmaIodFromParams( + videoProfile, + videoBitrate, + videoConfig, + videoConfigLength, + audioProfile, + audioBitrate, + audioConfig, + audioConfigLength, + &pBytes, + &numBytes); + + char* iodBase64 = + MP4ToBase64(pBytes, numBytes); + MP4Free(pBytes); + + char* sdpIod = + (char*)MP4Malloc(strlen(iodBase64) + 64); + snprintf(sdpIod, strlen(iodBase64) + 64, + "a=mpeg4-iod: \042data:application/mpeg4-iod;base64,%s\042", + iodBase64); + MP4Free(iodBase64); + + delete pFile; + + return sdpIod; + } + catch (MP4Error* e) { + VERBOSE_ERROR(verbosity, e->Print()); + delete e; + } + return NULL; + } + + /* Edit list */ + + MP4EditId MP4AddTrackEdit( + MP4FileHandle hFile, + MP4TrackId trackId, + MP4EditId editId, + MP4Timestamp startTime, + MP4Duration duration, + bool dwell) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + MP4EditId newEditId = + ((MP4File*)hFile)->AddTrackEdit(trackId, editId); + + if (newEditId != MP4_INVALID_EDIT_ID) { + ((MP4File*)hFile)->SetTrackEditMediaStart( + trackId, newEditId, startTime); + ((MP4File*)hFile)->SetTrackEditDuration( + trackId, newEditId, duration); + ((MP4File*)hFile)->SetTrackEditDwell( + trackId, newEditId, dwell); + } + + return newEditId; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return MP4_INVALID_EDIT_ID; + } + + bool MP4DeleteTrackEdit( + MP4FileHandle hFile, + MP4TrackId trackId, + MP4EditId editId) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + ((MP4File*)hFile)->DeleteTrackEdit(trackId, editId); + return true; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; + } + + uint32_t MP4GetTrackNumberOfEdits( + MP4FileHandle hFile, + MP4TrackId trackId) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetTrackNumberOfEdits(trackId); + } + catch (MP4Error* e) { + //PRINT_ERROR(e); + delete e; + } + } + return 0; + } + + MP4Timestamp MP4GetTrackEditMediaStart( + MP4FileHandle hFile, + MP4TrackId trackId, + MP4EditId editId) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetTrackEditMediaStart( + trackId, editId); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return MP4_INVALID_TIMESTAMP; + } + + MP4Duration MP4GetTrackEditTotalDuration( + MP4FileHandle hFile, + MP4TrackId trackId, + MP4EditId editId) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetTrackEditTotalDuration( + trackId, editId); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return MP4_INVALID_DURATION; + } + + bool MP4SetTrackEditMediaStart( + MP4FileHandle hFile, + MP4TrackId trackId, + MP4EditId editId, + MP4Timestamp startTime) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + ((MP4File*)hFile)->SetTrackEditMediaStart( + trackId, editId, startTime); + return true; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; + } + + MP4Duration MP4GetTrackEditDuration( + MP4FileHandle hFile, + MP4TrackId trackId, + MP4EditId editId) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetTrackEditDuration(trackId, editId); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return MP4_INVALID_DURATION; + } + + bool MP4SetTrackEditDuration( + MP4FileHandle hFile, + MP4TrackId trackId, + MP4EditId editId, + MP4Duration duration) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + ((MP4File*)hFile)->SetTrackEditDuration(trackId, editId, duration); + return true; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; + } + + int8_t MP4GetTrackEditDwell( + MP4FileHandle hFile, + MP4TrackId trackId, + MP4EditId editId) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetTrackEditDwell(trackId, editId); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return -1; + } + + bool MP4SetTrackEditDwell( + MP4FileHandle hFile, + MP4TrackId trackId, + MP4EditId editId, + bool dwell) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + ((MP4File*)hFile)->SetTrackEditDwell(trackId, editId, dwell); + return true; + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return false; + } + + bool MP4ReadSampleFromEditTime( + /* input parameters */ + MP4FileHandle hFile, + MP4TrackId trackId, + MP4Timestamp when, + /* output parameters */ + uint8_t** ppBytes, + uint32_t* pNumBytes, + MP4Timestamp* pStartTime, + MP4Duration* pDuration, + MP4Duration* pRenderingOffset, + bool* pIsSyncSample) + { + MP4SampleId sampleId = + MP4GetSampleIdFromEditTime( + hFile, + trackId, + when, + pStartTime, + pDuration); + + return MP4ReadSample( + hFile, + trackId, + sampleId, + ppBytes, + pNumBytes, + NULL, + NULL, + pRenderingOffset, + pIsSyncSample); + } + + MP4SampleId MP4GetSampleIdFromEditTime( + MP4FileHandle hFile, + MP4TrackId trackId, + MP4Timestamp when, + MP4Timestamp* pStartTime, + MP4Duration* pDuration) + { + if (MP4_IS_VALID_FILE_HANDLE(hFile)) { + try { + return ((MP4File*)hFile)->GetSampleIdFromEditTime( + trackId, when, pStartTime, pDuration); + } + catch (MP4Error* e) { + PRINT_ERROR(e); + delete e; + } + } + return MP4_INVALID_SAMPLE_ID; + } + + /* Utlities */ + + char* MP4BinaryToBase16( + const uint8_t* pData, + uint32_t dataSize) + { + if (pData || dataSize == 0) { + try { + return MP4ToBase16(pData, dataSize); + } + catch (MP4Error* e) { + delete e; + } + } + return NULL; + } + + char* MP4BinaryToBase64( + const uint8_t* pData, + uint32_t dataSize) + { + if (pData || dataSize == 0) { + try { + return MP4ToBase64(pData, dataSize); + } + catch (MP4Error* e) { + delete e; + } + } + return NULL; + } + + void MP4Free (void *p) + { + if (p != NULL) + free(p); + } + + void MP4AddIPodUUID (MP4FileHandle hFile, MP4TrackId trackId) + { + MP4Track* track = ((MP4File*)hFile)->GetTrack(trackId); + MP4Atom* avc1 = track->GetTrakAtom()->FindChildAtom("mdia.minf.stbl.stsd.avc1") + ; + avc1->AddChildAtom(new IPodUUIDAtom()); + } + +/////////////////////////////////////////////////////////////////////////////// + +bool MP4GetTrackLanguage( + MP4FileHandle hFile, + MP4TrackId trackId, + char* code ) +{ + if( !MP4_IS_VALID_FILE_HANDLE( hFile )) + return false; + + try { + return ((MP4File*)hFile)->GetTrackLanguage( trackId, code ); + } + catch( MP4Error* e ) { + PRINT_ERROR( e ); + delete e; + } + + return false; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool MP4SetTrackLanguage( + MP4FileHandle hFile, + MP4TrackId trackId, + const char* code ) +{ + if( !MP4_IS_VALID_FILE_HANDLE( hFile )) + return false; + + try { + return ((MP4File*)hFile)->SetTrackLanguage( trackId, code ); + } + catch( MP4Error* e ) { + PRINT_ERROR( e ); + delete e; + } + + return false; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool MP4GetTrackName( + MP4FileHandle hFile, + MP4TrackId trackId, + char** name ) +{ + if( !MP4_IS_VALID_FILE_HANDLE( hFile )) + return false; + + try { + return ((MP4File*)hFile)->GetTrackName( trackId, name ); + } + catch( MP4Error* e ) { + PRINT_ERROR( e ); + delete e; + } + + return false; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool MP4SetTrackName( + MP4FileHandle hFile, + MP4TrackId trackId, + const char* code ) +{ + if( !MP4_IS_VALID_FILE_HANDLE( hFile )) + return false; + + try { + return ((MP4File*)hFile)->SetTrackName( trackId, code ); + } + catch( MP4Error* e ) { + PRINT_ERROR( e ); + delete e; + } + + return false; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool MP4GetTrackDurationPerChunk( + MP4FileHandle hFile, + MP4TrackId trackId, + MP4Duration* duration ) +{ + if( !MP4_IS_VALID_FILE_HANDLE( hFile )) + return false; + + try { + *duration = ((MP4File*)hFile)->GetTrackDurationPerChunk( trackId ); + return true; + } + catch( MP4Error* e ) { + PRINT_ERROR( e ); + delete e; + } + + return false; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool MP4SetTrackDurationPerChunk( + MP4FileHandle hFile, + MP4TrackId trackId, + MP4Duration duration ) +{ + if( !MP4_IS_VALID_FILE_HANDLE( hFile )) + return false; + + try { + ((MP4File*)hFile)->SetTrackDurationPerChunk( trackId, duration ); + return true; + } + catch( MP4Error* e ) { + PRINT_ERROR( e ); + delete e; + } + + return false; +} + +/////////////////////////////////////////////////////////////////////////////// + +} // extern "C" diff --git a/src/mp4array.h b/src/mp4array.h new file mode 100644 index 0000000..3333fa8 --- /dev/null +++ b/src/mp4array.h @@ -0,0 +1,104 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + */ + + +#ifndef MP4V2_IMPL_MP4ARRAY_H +#define MP4V2_IMPL_MP4ARRAY_H + +#include <vector> +using namespace std; + +typedef uint32_t MP4ArrayIndex; + +template<class T> +class Array +{ + /* ----------------------------------------------------------------------------------------------------------------- + ------------------------------------------------------------------------------------------------------------------- */ + public: + inline MP4ArrayIndex Size(void) + { + return m_vector.size(); + } + + inline void Add(T newElement) + { + m_vector.push_back(newElement); + } + + inline void Insert(T newElement, MP4ArrayIndex newIndex) + { + if(newIndex > m_vector.size()) { + throw new mp4v2::impl::MP4Error(ERANGE, "MP4Array::Insert"); + } + + m_vector.insert(m_vector.begin() + newIndex, newElement); + } + + inline void Delete(MP4ArrayIndex index) + { + if(index >= m_vector.size()) { + throw new mp4v2::impl::MP4Error(ERANGE, "MP4Array::Delete"); + } + + typename vector<T>::iterator arrayIter = m_vector.begin() + index; + m_vector.erase(arrayIter); + } + + inline void Resize(MP4ArrayIndex newSize) + { + m_vector.resize(newSize); + } + + inline T &operator[](MP4ArrayIndex index) + { + if(index >= m_vector.size()) { + throw new mp4v2::impl::MP4Error(ERANGE, "index %u of %u", "MP4Array::[]", index, m_vector.size()); + } + + return m_vector[index]; + } + + /* ----------------------------------------------------------------------------------------------------------------- + ------------------------------------------------------------------------------------------------------------------- */ + protected: + vector<T> m_vector; +}; + +#define MP4ARRAY_DECL(name, type) typedef Array<type> name##Array; + +MP4ARRAY_DECL(MP4Integer8, uint8_t) + +MP4ARRAY_DECL(MP4Integer16, uint16_t) + +MP4ARRAY_DECL(MP4Integer32, uint32_t) + +MP4ARRAY_DECL(MP4Integer64, uint64_t) + +MP4ARRAY_DECL(MP4Float32, float) + +MP4ARRAY_DECL(MP4Float64, double) + +MP4ARRAY_DECL(MP4String, char *) + +MP4ARRAY_DECL(MP4Bytes, uint8_t *) + +#endif /* MP4V2_IMPL_MP4ARRAY_H */ diff --git a/src/mp4atom.cpp b/src/mp4atom.cpp new file mode 100644 index 0000000..de0bd9b --- /dev/null +++ b/src/mp4atom.cpp @@ -0,0 +1,1041 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001 - 2004. All Rights Reserved. + * + * 3GPP features implementation is based on 3GPP's TS26.234-v5.60, + * and was contributed by Ximpo Group Ltd. + * + * Portions created by Ximpo Group Ltd. are + * Copyright (C) Ximpo Group Ltd. 2003, 2004. All Rights Reserved. + * + * Portions created by Adnecto d.o.o. are + * Copyright (C) Adnecto d.o.o. 2005. All Rights Reserved + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + * Alix Marchandise-Franquet alix@cisco.com + * Ximpo Group Ltd. mp4v2@ximpo.com + * Danijel Kopcinovic danijel.kopcinovic@adnecto.net + */ + +#include "src/impl.h" + +namespace mp4v2 { namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4AtomInfo::MP4AtomInfo(const char* name, bool mandatory, bool onlyOne) +{ + m_name = name; + m_mandatory = mandatory; + m_onlyOne = onlyOne; + m_count = 0; +} + +MP4Atom::MP4Atom(const char* type) +{ + SetType(type); + m_unknownType = false; + m_pFile = NULL; + m_start = 0; + m_end = 0; + m_largesizeMode = false; + m_size = 0; + m_pParentAtom = NULL; + m_depth = 0xFF; +} + +MP4Atom::~MP4Atom() +{ + uint32_t i; + + for (i = 0; i < m_pProperties.Size(); i++) { + delete m_pProperties[i]; + } + for (i = 0; i < m_pChildAtomInfos.Size(); i++) { + delete m_pChildAtomInfos[i]; + } + for (i = 0; i < m_pChildAtoms.Size(); i++) { + delete m_pChildAtoms[i]; + } +} + +MP4Atom* MP4Atom::CreateAtom( MP4Atom* parent, const char* type ) +{ + MP4Atom* atom = factory( parent, type ); + ASSERT( atom ); + return atom; +} + +// generate a skeletal self + +void MP4Atom::Generate() +{ + uint32_t i; + + // for all properties + for (i = 0; i < m_pProperties.Size(); i++) { + // ask it to self generate + m_pProperties[i]->Generate(); + } + + // for all mandatory, single child atom types + for (i = 0; i < m_pChildAtomInfos.Size(); i++) { + if (m_pChildAtomInfos[i]->m_mandatory + && m_pChildAtomInfos[i]->m_onlyOne) { + + // create the mandatory, single child atom + MP4Atom* pChildAtom = + CreateAtom(this, m_pChildAtomInfos[i]->m_name); + + AddChildAtom(pChildAtom); + + // and ask it to self generate + pChildAtom->Generate(); + } + } +} + +MP4Atom* MP4Atom::ReadAtom(MP4File* pFile, MP4Atom* pParentAtom) +{ + uint8_t hdrSize = 8; + uint8_t extendedType[16]; + + uint64_t pos = pFile->GetPosition(); + + VERBOSE_READ(pFile->GetVerbosity(), + printf("ReadAtom: pos = 0x%" PRIx64 "\n", pos)); + + uint64_t dataSize = pFile->ReadUInt32(); + + char type[5]; + pFile->ReadBytes((uint8_t*)&type[0], 4); + type[4] = '\0'; + + // extended size + const bool largesizeMode = (dataSize == 1); + if (dataSize == 1) { + dataSize = pFile->ReadUInt64(); + hdrSize += 8; + pFile->Check64BitStatus(type); + } + + // extended type + if (ATOMID(type) == ATOMID("uuid")) { + pFile->ReadBytes(extendedType, sizeof(extendedType)); + hdrSize += sizeof(extendedType); + } + + if (dataSize == 0) { + // extends to EOF + dataSize = pFile->GetSize() - pos; + } + + dataSize -= hdrSize; + + VERBOSE_READ(pFile->GetVerbosity(), + printf("ReadAtom: type = \"%s\" data-size = %" PRIu64 " (0x%" PRIx64 ") hdr %u\n", + type, dataSize, dataSize, hdrSize)); + + if (pos + hdrSize + dataSize > pParentAtom->GetEnd()) { + VERBOSE_ERROR(pFile->GetVerbosity(), + printf("ReadAtom: invalid atom size, extends outside parent atom - skipping to end of \"%s\" \"%s\" %" PRIu64 " vs %" PRIu64 "\n", + pParentAtom->GetType(), type, + pos + hdrSize + dataSize, + pParentAtom->GetEnd())); + VERBOSE_READ(pFile->GetVerbosity(), + printf("parent %s (%" PRIu64 ") pos %" PRIu64 " hdr %d data %" PRIu64 " sum %" PRIu64 "\n", + pParentAtom->GetType(), + pParentAtom->GetEnd(), + pos, + hdrSize, + dataSize, + pos + hdrSize + dataSize)); +#if 0 + throw new MP4Error("invalid atom size", "ReadAtom"); +#else + // skip to end of atom + dataSize = pParentAtom->GetEnd() - pos - hdrSize; +#endif + } + + MP4Atom* pAtom = CreateAtom(pParentAtom, type); + pAtom->SetFile(pFile); + pAtom->SetStart(pos); + pAtom->SetEnd(pos + hdrSize + dataSize); + pAtom->SetLargesizeMode(largesizeMode); + pAtom->SetSize(dataSize); + if (ATOMID(type) == ATOMID("uuid")) { + pAtom->SetExtendedType(extendedType); + } + if (pAtom->IsUnknownType()) { + if (!IsReasonableType(pAtom->GetType())) { + VERBOSE_READ(pFile->GetVerbosity(), + printf("Warning: atom type %s is suspect\n", pAtom->GetType())); + } else { + VERBOSE_READ(pFile->GetVerbosity(), + printf("Info: atom type %s is unknown\n", pAtom->GetType())); + } + + if (dataSize > 0) { + pAtom->AddProperty( + new MP4BytesProperty("data", dataSize)); + } + } + + pAtom->SetParentAtom(pParentAtom); + + try { + pAtom->Read(); + } + catch (MP4Error* e) { + delete pAtom; + throw e; + } + + return pAtom; +} + +bool MP4Atom::IsReasonableType(const char* type) +{ + for (uint8_t i = 0; i < 4; i++) { + if (isalnum((unsigned char)type[i])) { + continue; + } + if (i == 3 && type[i] == ' ') { + continue; + } + return false; + } + return true; +} + +// generic read +void MP4Atom::Read() +{ + ASSERT(m_pFile); + + if (ATOMID(m_type) != 0 && m_size > 1000000) { + VERBOSE_READ(GetVerbosity(), + printf("Warning: %s atom size %" PRIu64 " is suspect\n", + m_type, m_size)); + } + + ReadProperties(); + + // read child atoms, if we expect there to be some + if (m_pChildAtomInfos.Size() > 0) { + ReadChildAtoms(); + } + + Skip(); // to end of atom +} + +void MP4Atom::Skip() +{ + if (m_pFile->GetPosition() != m_end) { + VERBOSE_READ(m_pFile->GetVerbosity(), + printf("Skip: %" PRIu64 " bytes\n", m_end - m_pFile->GetPosition())); + } + m_pFile->SetPosition(m_end); +} + +MP4Atom* MP4Atom::FindAtom(const char* name) +{ + if (!IsMe(name)) { + return NULL; + } + + if (!IsRootAtom()) { + VERBOSE_FIND(m_pFile->GetVerbosity(), + printf("FindAtom: matched %s\n", name)); + + name = MP4NameAfterFirst(name); + + // I'm the sought after atom + if (name == NULL) { + return this; + } + } + + // else it's one of my children + return FindChildAtom(name); +} + +bool MP4Atom::FindProperty(const char *name, + MP4Property** ppProperty, uint32_t* pIndex) +{ + if (!IsMe(name)) { + return false; + } + + if (!IsRootAtom()) { + VERBOSE_FIND(m_pFile->GetVerbosity(), + printf("FindProperty: matched %s\n", name)); + + name = MP4NameAfterFirst(name); + + // no property name given + if (name == NULL) { + return false; + } + } + + return FindContainedProperty(name, ppProperty, pIndex); +} + +bool MP4Atom::IsMe(const char* name) +{ + if (name == NULL) { + return false; + } + + // root atom always matches + if (!strcmp(m_type, "")) { + return true; + } + + // check if our atom name is specified as the first component + if (!MP4NameFirstMatches(m_type, name)) { + return false; + } + + return true; +} + +MP4Atom* MP4Atom::FindChildAtom(const char* name) +{ + uint32_t atomIndex = 0; + + // get the index if we have one, e.g. moov.trak[2].mdia... + (void)MP4NameFirstIndex(name, &atomIndex); + + // need to get to the index'th child atom of the right type + for (uint32_t i = 0; i < m_pChildAtoms.Size(); i++) { + if (MP4NameFirstMatches(m_pChildAtoms[i]->GetType(), name)) { + if (atomIndex == 0) { + // this is the one, ask it to match + return m_pChildAtoms[i]->FindAtom(name); + } + atomIndex--; + } + } + + return NULL; +} + +bool MP4Atom::FindContainedProperty(const char *name, + MP4Property** ppProperty, uint32_t* pIndex) +{ + uint32_t numProperties = m_pProperties.Size(); + uint32_t i; + // check all of our properties + for (i = 0; i < numProperties; i++) { + if (m_pProperties[i]->FindProperty(name, ppProperty, pIndex)) { + return true; + } + } + + // not one of our properties, + // presumably one of our children's properties + // check child atoms... + + // check if we have an index, e.g. trak[2].mdia... + uint32_t atomIndex = 0; + (void)MP4NameFirstIndex(name, &atomIndex); + + // need to get to the index'th child atom of the right type + for (i = 0; i < m_pChildAtoms.Size(); i++) { + if (MP4NameFirstMatches(m_pChildAtoms[i]->GetType(), name)) { + if (atomIndex == 0) { + // this is the one, ask it to match + return m_pChildAtoms[i]->FindProperty(name, ppProperty, pIndex); + } + atomIndex--; + } + } + + VERBOSE_FIND(m_pFile->GetVerbosity(), + printf("FindProperty: no match for %s\n", name)); + return false; +} + +void MP4Atom::ReadProperties(uint32_t startIndex, uint32_t count) +{ + uint32_t numProperties = min(count, m_pProperties.Size() - startIndex); + + // read any properties of the atom + for (uint32_t i = startIndex; i < startIndex + numProperties; i++) { + + m_pProperties[i]->Read(m_pFile); + + if (m_pFile->GetPosition() > m_end) { + VERBOSE_READ(GetVerbosity(), + printf("ReadProperties: insufficient data for property: %s pos 0x%" PRIx64 " atom end 0x%" PRIx64 "\n", + m_pProperties[i]->GetName(), + m_pFile->GetPosition(), m_end)); + + ostringstream oss; + oss << "atom '" << GetType() << "' is too small; overrun at property: " << m_pProperties[i]->GetName(); + throw new MP4Error( oss.str().c_str(), "Atom ReadProperties" ); + } + + if (m_pProperties[i]->GetType() == TableProperty) { + VERBOSE_READ_TABLE(GetVerbosity(), + printf("Read: "); m_pProperties[i]->Dump(stdout, 0, true)); + } else if (m_pProperties[i]->GetType() != DescriptorProperty) { + VERBOSE_READ(GetVerbosity(), + printf("Read: "); m_pProperties[i]->Dump(stdout, 0, true)); + } + } +} + +void MP4Atom::ReadChildAtoms() +{ + bool this_is_udta = ATOMID(m_type) == ATOMID("udta"); + + VERBOSE_READ(GetVerbosity(), + printf("ReadChildAtoms: of %s\n", m_type[0] ? m_type : "root")); + for (uint64_t position = m_pFile->GetPosition(); + position < m_end; + position = m_pFile->GetPosition()) { + // make sure that we have enough to read at least 8 bytes + // size and type. + if (m_end - position < 2 * sizeof(uint32_t)) { + // if we're reading udta, it's okay to have 4 bytes of 0 + if (this_is_udta && + m_end - position == sizeof(uint32_t)) { + uint32_t mbz = m_pFile->ReadUInt32(); + if (mbz != 0) { + VERBOSE_WARNING(GetVerbosity(), + printf("Error: In udta atom, end value is not zero %x\n", + mbz)); + } + continue; + } + // otherwise, output a warning, but don't care + VERBOSE_WARNING(GetVerbosity(), + printf("Error: In %s atom, extra %" PRId64 " bytes at end of atom\n", + m_type, (m_end - position))); + for (uint64_t ix = 0; ix < m_end - position; ix++) { + (void)m_pFile->ReadUInt8(); + } + continue; + } + MP4Atom* pChildAtom = MP4Atom::ReadAtom(m_pFile, this); + + AddChildAtom(pChildAtom); + + MP4AtomInfo* pChildAtomInfo = FindAtomInfo(pChildAtom->GetType()); + + // if child atom is of known type + // but not expected here print warning + if (pChildAtomInfo == NULL && !pChildAtom->IsUnknownType()) { + VERBOSE_READ(GetVerbosity(), + printf("Warning: In atom %s unexpected child atom %s\n", + GetType(), pChildAtom->GetType())); + } + + // if child atoms should have just one instance + // and this is more than one, print warning + if (pChildAtomInfo) { + pChildAtomInfo->m_count++; + + if (pChildAtomInfo->m_onlyOne && pChildAtomInfo->m_count > 1) { + VERBOSE_READ(GetVerbosity(), + printf("Warning: In atom %s multiple child atoms %s\n", + GetType(), pChildAtom->GetType())); + } + } + + } + + // if mandatory child atom doesn't exist, print warning + uint32_t numAtomInfo = m_pChildAtomInfos.Size(); + for (uint32_t i = 0; i < numAtomInfo; i++) { + if (m_pChildAtomInfos[i]->m_mandatory + && m_pChildAtomInfos[i]->m_count == 0) { + VERBOSE_READ(GetVerbosity(), + printf("Warning: In atom %s missing child atom %s\n", + GetType(), m_pChildAtomInfos[i]->m_name)); + } + } + + VERBOSE_READ(GetVerbosity(), + printf("ReadChildAtoms: finished %s\n", m_type)); +} + +MP4AtomInfo* MP4Atom::FindAtomInfo(const char* name) +{ + uint32_t numAtomInfo = m_pChildAtomInfos.Size(); + for (uint32_t i = 0; i < numAtomInfo; i++) { + if (ATOMID(m_pChildAtomInfos[i]->m_name) == ATOMID(name)) { + return m_pChildAtomInfos[i]; + } + } + return NULL; +} + +// generic write +void MP4Atom::Write() +{ + ASSERT(m_pFile); + + BeginWrite(); + + WriteProperties(); + + WriteChildAtoms(); + + FinishWrite(); +} + +void MP4Atom::Rewrite() +{ + ASSERT(m_pFile); + + if (!m_end) { + // This atom hasn't been written yet... + return; + } + + uint64_t fPos = m_pFile->GetPosition(); + m_pFile->SetPosition(GetStart()); + Write(); + m_pFile->SetPosition(fPos); +} + +void MP4Atom::BeginWrite(bool use64) +{ + m_start = m_pFile->GetPosition(); + //use64 = m_pFile->Use64Bits(); + if (use64) { + m_pFile->WriteUInt32(1); + } else { + m_pFile->WriteUInt32(0); + } + m_pFile->WriteBytes((uint8_t*)&m_type[0], 4); + if (use64) { + m_pFile->WriteUInt64(0); + } + if (ATOMID(m_type) == ATOMID("uuid")) { + m_pFile->WriteBytes(m_extendedType, sizeof(m_extendedType)); + } +} + +void MP4Atom::FinishWrite(bool use64) +{ + m_end = m_pFile->GetPosition(); + m_size = (m_end - m_start); + VERBOSE_WRITE(GetVerbosity(), + printf("end: type %s %" PRIu64 " %" PRIu64 " size %" PRIu64 "\n", m_type, + m_start, m_end, + m_size)); + //use64 = m_pFile->Use64Bits(); + if (use64) { + m_pFile->SetPosition(m_start + 8); + m_pFile->WriteUInt64(m_size); + } else { + ASSERT(m_size <= (uint64_t)0xFFFFFFFF); + m_pFile->SetPosition(m_start); + m_pFile->WriteUInt32(m_size); + } + m_pFile->SetPosition(m_end); + + // adjust size to just reflect data portion of atom + m_size -= (use64 ? 16 : 8); + if (ATOMID(m_type) == ATOMID("uuid")) { + m_size -= sizeof(m_extendedType); + } +} + +void MP4Atom::WriteProperties(uint32_t startIndex, uint32_t count) +{ + uint32_t numProperties = min(count, m_pProperties.Size() - startIndex); + + VERBOSE_WRITE(GetVerbosity(), + printf("Write: type %s\n", m_type)); + + for (uint32_t i = startIndex; i < startIndex + numProperties; i++) { + m_pProperties[i]->Write(m_pFile); + + if (m_pProperties[i]->GetType() == TableProperty) { + VERBOSE_WRITE_TABLE(GetVerbosity(), + printf("Write: "); m_pProperties[i]->Dump(stdout, 0, false)); + } else { + VERBOSE_WRITE(GetVerbosity(), + printf("Write: "); m_pProperties[i]->Dump(stdout, 0, false)); + } + } +} + +void MP4Atom::WriteChildAtoms() +{ + uint32_t size = m_pChildAtoms.Size(); + for (uint32_t i = 0; i < size; i++) { + m_pChildAtoms[i]->Write(); + } + + VERBOSE_WRITE(GetVerbosity(), + printf("Write: finished %s\n", m_type)); +} + +void MP4Atom::AddProperty(MP4Property* pProperty) +{ + ASSERT(pProperty); + m_pProperties.Add(pProperty); + pProperty->SetParentAtom(this); +} + +void MP4Atom::AddVersionAndFlags() +{ + AddProperty(new MP4Integer8Property("version")); + AddProperty(new MP4Integer24Property("flags")); +} + +void MP4Atom::AddReserved(const char* name, uint32_t size) +{ + MP4BytesProperty* pReserved = new MP4BytesProperty(name, size); + pReserved->SetReadOnly(); + AddProperty(pReserved); +} + +void MP4Atom::ExpectChildAtom(const char* name, bool mandatory, bool onlyOne) +{ + m_pChildAtomInfos.Add(new MP4AtomInfo(name, mandatory, onlyOne)); +} + +uint8_t MP4Atom::GetVersion() +{ + if (strcmp("version", m_pProperties[0]->GetName())) { + return 0; + } + return ((MP4Integer8Property*)m_pProperties[0])->GetValue(); +} + +void MP4Atom::SetVersion(uint8_t version) +{ + if (strcmp("version", m_pProperties[0]->GetName())) { + return; + } + ((MP4Integer8Property*)m_pProperties[0])->SetValue(version); +} + +uint32_t MP4Atom::GetFlags() +{ + if (strcmp("flags", m_pProperties[1]->GetName())) { + return 0; + } + return ((MP4Integer24Property*)m_pProperties[1])->GetValue(); +} + +void MP4Atom::SetFlags(uint32_t flags) +{ + if (strcmp("flags", m_pProperties[1]->GetName())) { + return; + } + ((MP4Integer24Property*)m_pProperties[1])->SetValue(flags); +} + +void MP4Atom::Dump(FILE* pFile, uint8_t indent, bool dumpImplicits) +{ + if ( m_type[0] != '\0' ) { + // create list of ancestors + list<string> tlist; + for( MP4Atom* atom = this; atom; atom = atom->GetParentAtom() ) { + const char* const type = atom->GetType(); + if( type && type[0] != '\0' ) + tlist.push_front( type ); + } + + // create contextual atom-name + string can; + const list<string>::iterator ie = tlist.end(); + for( list<string>::iterator it = tlist.begin(); it != ie; it++ ) + can += *it + '.'; + if( can.length() ) + can.resize( can.length() - 1 ); + + Indent( pFile, indent ); + fprintf( pFile, "type %s (%s)\n", m_type, can.c_str() ); + fflush( pFile ); + } + + uint32_t i; + uint32_t size; + + // dump our properties + size = m_pProperties.Size(); + for (i = 0; i < size; i++) { + + /* skip details of tables unless we're told to be verbose */ + if (m_pProperties[i]->GetType() == TableProperty + && !(GetVerbosity() & MP4_DETAILS_TABLE)) { + Indent(pFile, indent + 1); + fprintf(pFile, "<table entries suppressed>\n"); + continue; + } + + m_pProperties[i]->Dump(pFile, indent + 1, dumpImplicits); + } + + // dump our children + size = m_pChildAtoms.Size(); + for (i = 0; i < size; i++) { + m_pChildAtoms[i]->Dump(pFile, indent + 1, dumpImplicits); + } +} + +uint32_t MP4Atom::GetVerbosity() +{ + ASSERT(m_pFile); + return m_pFile->GetVerbosity(); +} + +uint8_t MP4Atom::GetDepth() +{ + if (m_depth < 0xFF) { + return m_depth; + } + + MP4Atom *pAtom = this; + m_depth = 0; + + while ((pAtom = pAtom->GetParentAtom()) != NULL) { + m_depth++; + ASSERT(m_depth < 255); + } + return m_depth; +} + +bool MP4Atom::GetLargesizeMode() +{ + return m_largesizeMode; +} + +void MP4Atom::SetLargesizeMode( bool mode ) +{ + m_largesizeMode = mode; +} + +bool +MP4Atom::descendsFrom( MP4Atom* parent, const char* type ) +{ + const uint32_t id = ATOMID( type ); + for( MP4Atom* atom = parent; atom; atom = atom->GetParentAtom() ) { + if( id == ATOMID(atom->GetType()) ) + return true; + } + return false; +} + +// UDTA child atom types to be constructed as MP4UdtaElementAtom. +// List gleaned from QTFF 2007-09-04. +static const char* const UDTA_ELEMENTS[] = { + "\xA9" "arg", + "\xA9" "ark", + "\xA9" "cok", + "\xA9" "com", + "\xA9" "cpy", + "\xA9" "day", + "\xA9" "dir", + "\xA9" "ed1", + "\xA9" "ed2", + "\xA9" "ed3", + "\xA9" "ed4", + "\xA9" "ed5", + "\xA9" "ed6", + "\xA9" "ed7", + "\xA9" "ed8", + "\xA9" "ed9", + "\xA9" "fmt", + "\xA9" "inf", + "\xA9" "isr", + "\xA9" "lab", + "\xA9" "lal", + "\xA9" "mak", + "\xA9" "nak", + "\xA9" "nam", + "\xA9" "pdk", + "\xA9" "phg", + "\xA9" "prd", + "\xA9" "prf", + "\xA9" "prk", + "\xA9" "prl", + "\xA9" "req", + "\xA9" "snk", + "\xA9" "snm", + "\xA9" "src", + "\xA9" "swf", + "\xA9" "swk", + "\xA9" "swr", + "\xA9" "wrt", + "Allf", + "hinf", + "hnti", + "name", + "LOOP", + "ptv ", + "SelO", + "WLOC", + NULL // must be last +}; + +MP4Atom* +MP4Atom::factory( MP4Atom* parent, const char* type ) +{ + // type may be NULL only in case of root-atom + if( !type ) + return new MP4RootAtom(); + + // construct atoms which are context-savvy + if( parent ) { + const char* const ptype = parent->GetType(); + + if( descendsFrom( parent, "ilst" )) { + if( ATOMID( ptype ) == ATOMID( "ilst" )) + return new MP4ItemAtom( type ); + + if( ATOMID( type ) == ATOMID( "data" )) + return new MP4DataAtom(); + + if( ATOMID( ptype ) == ATOMID( "----" )) { + if( ATOMID( type ) == ATOMID( "mean" )) + return new MP4MeanAtom(); + if( ATOMID( type ) == ATOMID( "name" )) + return new MP4NameAtom(); + } + } + else if( ATOMID( ptype ) == ATOMID( "udta" )) { + for( const char* const* p = UDTA_ELEMENTS; *p; p++ ) + if( !strcmp( type, *p )) + return new MP4UdtaElementAtom( type ); + } + } + + // no-context construction (old-style) + switch( (uint8_t)type[0] ) { + case 'S': + if( ATOMID(type) == ATOMID("SVQ3") ) + return new MP4VideoAtom( type ); + if( ATOMID(type) == ATOMID("SMI ") ) + return new MP4SmiAtom(); + break; + + case 'a': + if( ATOMID(type) == ATOMID("avc1") ) + return new MP4Avc1Atom(); + if( ATOMID(type) == ATOMID("ac-3") ) + return new MP4Ac3Atom(); + if( ATOMID(type) == ATOMID("avcC") ) + return new MP4AvcCAtom(); + if( ATOMID(type) == ATOMID("alis") ) + return new MP4UrlAtom( type ); + if( ATOMID(type) == ATOMID("alaw") ) + return new MP4SoundAtom( type ); + if( ATOMID(type) == ATOMID("alac") ) + return new MP4SoundAtom( type ); + break; + + case 'c': + if( ATOMID(type) == ATOMID("chap") ) + return new MP4TrefTypeAtom( type ); + if( ATOMID(type) == ATOMID("chpl") ) + return new MP4ChplAtom(); + if( ATOMID(type) == ATOMID("colr") ) + return new MP4ColrAtom(); + break; + + case 'd': + if( ATOMID(type) == ATOMID("d263") ) + return new MP4D263Atom(); + if( ATOMID(type) == ATOMID("damr") ) + return new MP4DamrAtom(); + if( ATOMID(type) == ATOMID("dref") ) + return new MP4DrefAtom(); + if( ATOMID(type) == ATOMID("dpnd") ) + return new MP4TrefTypeAtom( type ); + if( ATOMID(type) == ATOMID("dac3") ) + return new MP4DAc3Atom(); + break; + + case 'e': + if( ATOMID(type) == ATOMID("elst") ) + return new MP4ElstAtom(); + if( ATOMID(type) == ATOMID("enca") ) + return new MP4EncaAtom(); + if( ATOMID(type) == ATOMID("encv") ) + return new MP4EncvAtom(); + break; + + case 'f': + if( ATOMID(type) == ATOMID("free") ) + return new MP4FreeAtom(); + if( ATOMID(type) == ATOMID("ftyp") ) + return new MP4FtypAtom(); + if( ATOMID(type) == ATOMID("ftab") ) + return new MP4FtabAtom(); + break; + + case 'g': + if( ATOMID(type) == ATOMID("gmin") ) + return new MP4GminAtom(); + break; + + case 'h': + if( ATOMID(type) == ATOMID("hdlr") ) + return new MP4HdlrAtom(); + if( ATOMID(type) == ATOMID("hint") ) + return new MP4TrefTypeAtom( type ); + if( ATOMID(type) == ATOMID("hnti") ) + return new MP4HntiAtom(); + if( ATOMID(type) == ATOMID("hinf") ) + return new MP4HinfAtom(); + if( ATOMID(type) == ATOMID("h263") ) + return new MP4VideoAtom( type ); + if( ATOMID(type) == ATOMID("href") ) + return new MP4HrefAtom(); + break; + + case 'i': + if( ATOMID(type) == ATOMID("ipir") ) + return new MP4TrefTypeAtom( type ); + if( ATOMID(type) == ATOMID("ima4") ) + return new MP4SoundAtom( type ); + break; + + case 'j': + if( ATOMID(type) == ATOMID("jpeg") ) + return new MP4VideoAtom("jpeg"); + break; + + case 'm': + if( ATOMID(type) == ATOMID("mdhd") ) + return new MP4MdhdAtom(); + if( ATOMID(type) == ATOMID("mvhd") ) + return new MP4MvhdAtom(); + if( ATOMID(type) == ATOMID("mdat") ) + return new MP4MdatAtom(); + if( ATOMID(type) == ATOMID("mpod") ) + return new MP4TrefTypeAtom( type ); + if( ATOMID(type) == ATOMID("mp4a") ) + return new MP4SoundAtom( type ); + if( ATOMID(type) == ATOMID("mp4s") ) + return new MP4Mp4sAtom(); + if( ATOMID(type) == ATOMID("mp4v") ) + return new MP4Mp4vAtom(); + break; + + case 'n': + if( ATOMID(type) == ATOMID("nmhd") ) + return new MP4NmhdAtom(); + break; + + case 'o': + if( ATOMID(type) == ATOMID("ohdr") ) + return new MP4OhdrAtom(); + break; + + case 'p': + if( ATOMID(type) == ATOMID("pasp") ) + return new MP4PaspAtom(); + break; + + case 'r': + if( ATOMID(type) == ATOMID("rtp ") ) + return new MP4RtpAtom(); + if( ATOMID(type) == ATOMID("raw ") ) + return new MP4VideoAtom( type ); + break; + + case 's': + if( ATOMID(type) == ATOMID("s263") ) + return new MP4S263Atom(); + if( ATOMID(type) == ATOMID("samr") ) + return new MP4AmrAtom( type ); + if( ATOMID(type) == ATOMID("sawb") ) + return new MP4AmrAtom( type ); + if( ATOMID(type) == ATOMID("sdtp") ) + return new MP4SdtpAtom(); + if( ATOMID(type) == ATOMID("stbl") ) + return new MP4StblAtom(); + if( ATOMID(type) == ATOMID("stsd") ) + return new MP4StsdAtom(); + if( ATOMID(type) == ATOMID("stsz") ) + return new MP4StszAtom(); + if( ATOMID(type) == ATOMID("stsc") ) + return new MP4StscAtom(); + if( ATOMID(type) == ATOMID("stz2") ) + return new MP4Stz2Atom(); + if( ATOMID(type) == ATOMID("stdp") ) + return new MP4StdpAtom(); + if( ATOMID(type) == ATOMID("sdp ") ) + return new MP4SdpAtom(); + if( ATOMID(type) == ATOMID("sync") ) + return new MP4TrefTypeAtom( type ); + if( ATOMID(type) == ATOMID("skip") ) + return new MP4FreeAtom( type ); + if (ATOMID(type) == ATOMID("sowt") ) + return new MP4SoundAtom( type ); + break; + + case 't': + if( ATOMID(type) == ATOMID("text") ) + return new MP4TextAtom(); + if( ATOMID(type) == ATOMID("tx3g") ) + return new MP4Tx3gAtom(); + if( ATOMID(type) == ATOMID("tkhd") ) + return new MP4TkhdAtom(); + if( ATOMID(type) == ATOMID("tfhd") ) + return new MP4TfhdAtom(); + if( ATOMID(type) == ATOMID("trun") ) + return new MP4TrunAtom(); + if( ATOMID(type) == ATOMID("twos") ) + return new MP4SoundAtom( type ); + break; + + case 'u': + if( ATOMID(type) == ATOMID("udta") ) + return new MP4UdtaAtom(); + if( ATOMID(type) == ATOMID("url ") ) + return new MP4UrlAtom(); + if( ATOMID(type) == ATOMID("urn ") ) + return new MP4UrnAtom(); + if( ATOMID(type) == ATOMID("ulaw") ) + return new MP4SoundAtom( type ); + break; + + case 'v': + if( ATOMID(type) == ATOMID("vmhd") ) + return new MP4VmhdAtom(); + break; + + case 'y': + if( ATOMID(type) == ATOMID("yuv2") ) + return new MP4VideoAtom( type ); + break; + + default: + break; + } + + // default to MP4StandardAtom implementation + return new MP4StandardAtom( type ); +} + +/////////////////////////////////////////////////////////////////////////////// + +}} // namespace mp4v2::impl diff --git a/src/mp4atom.h b/src/mp4atom.h new file mode 100644 index 0000000..c6c1ea3 --- /dev/null +++ b/src/mp4atom.h @@ -0,0 +1,267 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001 - 2004. All Rights Reserved. + * + * 3GPP features implementation is based on 3GPP's TS26.234-v5.60, + * and was contributed by Ximpo Group Ltd. + * + * Portions created by Ximpo Group Ltd. are + * Copyright (C) Ximpo Group Ltd. 2003, 2004. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + * Ximpo Group Ltd. mp4v2@ximpo.com + */ + +#ifndef MP4V2_IMPL_MP4ATOM_H +#define MP4V2_IMPL_MP4ATOM_H + +namespace mp4v2 { namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +class MP4Atom; +MP4ARRAY_DECL(MP4Atom, MP4Atom*); + +#define Required true +#define Optional false +#define OnlyOne true +#define Many false +#define Counted true + +/* helper class */ +class MP4AtomInfo { +public: + MP4AtomInfo() { + m_name = NULL; + } + MP4AtomInfo(const char* name, bool mandatory, bool onlyOne); + + const char* m_name; + bool m_mandatory; + bool m_onlyOne; + uint32_t m_count; +}; + +MP4ARRAY_DECL(MP4AtomInfo, MP4AtomInfo*); + +class MP4Atom +{ +public: + static MP4Atom* ReadAtom( MP4File* pFile, MP4Atom* pParentAtom ); + static MP4Atom* CreateAtom( MP4Atom* parent, const char* type ); + static bool IsReasonableType( const char* type ); + +private: + static MP4Atom* factory( MP4Atom* parent, const char* type ); + static bool descendsFrom( MP4Atom* parent, const char* type ); + +public: + MP4Atom(const char* type = NULL); + virtual ~MP4Atom(); + + MP4File* GetFile() { + return m_pFile; + }; + void SetFile(MP4File* pFile) { + m_pFile = pFile; + }; + + uint64_t GetStart() { + return m_start; + }; + void SetStart(uint64_t pos) { + m_start = pos; + }; + + uint64_t GetEnd() { + return m_end; + }; + void SetEnd(uint64_t pos) { + m_end = pos; + }; + + uint64_t GetSize() { + return m_size; + } + void SetSize(uint64_t size) { + m_size = size; + } + + const char* GetType() { + return m_type; + }; + void SetType(const char* type) { + if (type && *type != '\0') { + // not needed ASSERT(strlen(type) == 4); + memcpy(m_type, type, 4); + m_type[4] = '\0'; + } else { + memset(m_type, 0, 5); + } + } + + void GetExtendedType(uint8_t* pExtendedType) { + memcpy(pExtendedType, m_extendedType, sizeof(m_extendedType)); + }; + void SetExtendedType(uint8_t* pExtendedType) { + memcpy(m_extendedType, pExtendedType, sizeof(m_extendedType)); + }; + + bool IsUnknownType() { + return m_unknownType; + } + void SetUnknownType(bool unknownType = true) { + m_unknownType = unknownType; + } + + bool IsRootAtom() { + return m_type[0] == '\0'; + } + + MP4Atom* GetParentAtom() { + return m_pParentAtom; + } + void SetParentAtom(MP4Atom* pParentAtom) { + m_pParentAtom = pParentAtom; + } + + void AddChildAtom(MP4Atom* pChildAtom) { + pChildAtom->SetFile(m_pFile); + pChildAtom->SetParentAtom(this); + m_pChildAtoms.Add(pChildAtom); + } + + void InsertChildAtom(MP4Atom* pChildAtom, uint32_t index) { + pChildAtom->SetFile(m_pFile); + pChildAtom->SetParentAtom(this); + m_pChildAtoms.Insert(pChildAtom, index); + } + + void DeleteChildAtom(MP4Atom* pChildAtom) { + for (MP4ArrayIndex i = 0; i < m_pChildAtoms.Size(); i++) { + if (m_pChildAtoms[i] == pChildAtom) { + m_pChildAtoms.Delete(i); + return; + } + } + } + + uint32_t GetNumberOfChildAtoms() { + return m_pChildAtoms.Size(); + } + + MP4Atom* GetChildAtom(uint32_t index) { + return m_pChildAtoms[index]; + } + + MP4Property* GetProperty(uint32_t index) { + return m_pProperties[index]; + } + + uint32_t GetCount() { + return m_pProperties.Size(); + } + + MP4Atom* FindAtom(const char* name); + + MP4Atom* FindChildAtom(const char* name); + + bool FindProperty(const char* name, + MP4Property** ppProperty, uint32_t* pIndex = NULL); + + uint32_t GetFlags(); + void SetFlags(uint32_t flags); + + uint8_t GetDepth(); + + void Skip(); + + virtual void Generate(); + virtual void Read(); + virtual void BeginWrite(bool use64 = false); + virtual void Write(); + virtual void Rewrite(); + virtual void FinishWrite(bool use64 = false); + virtual void Dump(FILE* pFile, uint8_t indent, bool dumpImplicits); + + bool GetLargesizeMode(); + +protected: + void AddProperty(MP4Property* pProperty); + + void AddVersionAndFlags(); + + void AddReserved(const char* name, uint32_t size); + + void ExpectChildAtom(const char* name, + bool mandatory, bool onlyOne = true); + + MP4AtomInfo* FindAtomInfo(const char* name); + + bool IsMe(const char* name); + + bool FindContainedProperty(const char* name, + MP4Property** ppProperty, uint32_t* pIndex); + + void ReadProperties( + uint32_t startIndex = 0, uint32_t count = 0xFFFFFFFF); + void ReadChildAtoms(); + + void WriteProperties( + uint32_t startIndex = 0, uint32_t count = 0xFFFFFFFF); + void WriteChildAtoms(); + + uint8_t GetVersion(); + void SetVersion(uint8_t version); + + /* debugging aid */ + uint32_t GetVerbosity(); + + void SetLargesizeMode( bool ); + +protected: + MP4File* m_pFile; + uint64_t m_start; + uint64_t m_end; + bool m_largesizeMode; // true if largesize mode + uint64_t m_size; + char m_type[5]; + bool m_unknownType; + uint8_t m_extendedType[16]; + + MP4Atom* m_pParentAtom; + uint8_t m_depth; + + MP4PropertyArray m_pProperties; + MP4AtomInfoArray m_pChildAtomInfos; + MP4AtomArray m_pChildAtoms; +}; + +inline uint32_t ATOMID(const char* type) { + return STRTOINT32(type); +} + +// inverse ATOMID - 32 bit id to string +inline void IDATOM(uint32_t type, char *s) { + INT32TOSTR(type, s); +} + +/////////////////////////////////////////////////////////////////////////////// + +}} // namespace mp4v2::impl + +#endif // MP4V2_IMPL_MP4ATOM_H diff --git a/src/mp4container.cpp b/src/mp4container.cpp new file mode 100644 index 0000000..ebfbd58 --- /dev/null +++ b/src/mp4container.cpp @@ -0,0 +1,236 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4Container::~MP4Container() +{ + for (uint32_t i = 0; i < m_pProperties.Size(); i++) { + delete m_pProperties[i]; + } +} + +void MP4Container::AddProperty(MP4Property* pProperty) +{ + ASSERT(pProperty); + m_pProperties.Add(pProperty); +} + +bool MP4Container::FindProperty(const char *name, + MP4Property** ppProperty, uint32_t* pIndex) +{ + if (pIndex) { + *pIndex = 0; // set the default answer for index + } + + uint32_t numProperties = m_pProperties.Size(); + + for (uint32_t i = 0; i < numProperties; i++) { + if (m_pProperties[i]->FindProperty(name, ppProperty, pIndex)) { + return true; + } + } + return false; +} + +void MP4Container::FindIntegerProperty(const char* name, + MP4Property** ppProperty, uint32_t* pIndex) +{ + if (!FindProperty(name, ppProperty, pIndex)) { + throw new MP4Error("no such property", + "MP4Container::FindIntegerProperty"); + } + + switch ((*ppProperty)->GetType()) { + case Integer8Property: + case Integer16Property: + case Integer24Property: + case Integer32Property: + case Integer64Property: + break; + default: + throw new MP4Error("type mismatch", + "MP4Container::FindIntegerProperty"); + } +} + +uint64_t MP4Container::GetIntegerProperty(const char* name) +{ + MP4Property* pProperty; + uint32_t index; + + FindIntegerProperty(name, &pProperty, &index); + + return ((MP4IntegerProperty*)pProperty)->GetValue(index); +} + +void MP4Container::SetIntegerProperty(const char* name, uint64_t value) +{ + MP4Property* pProperty = NULL; + uint32_t index = 0; + + FindIntegerProperty(name, &pProperty, &index); + + ((MP4IntegerProperty*)pProperty)->SetValue(value, index); +} + +void MP4Container::FindFloatProperty(const char* name, + MP4Property** ppProperty, uint32_t* pIndex) +{ + if (!FindProperty(name, ppProperty, pIndex)) { + throw new MP4Error("no such property", + "MP4Container::FindFloatProperty"); + } + if ((*ppProperty)->GetType() != Float32Property) { + throw new MP4Error("type mismatch", + "MP4Container::FindFloatProperty"); + } +} + +float MP4Container::GetFloatProperty(const char* name) +{ + MP4Property* pProperty; + uint32_t index; + + FindFloatProperty(name, &pProperty, &index); + + return ((MP4Float32Property*)pProperty)->GetValue(index); +} + +void MP4Container::SetFloatProperty(const char* name, float value) +{ + MP4Property* pProperty; + uint32_t index; + + FindFloatProperty(name, &pProperty, &index); + + ((MP4Float32Property*)pProperty)->SetValue(value, index); +} + +void MP4Container::FindStringProperty(const char* name, + MP4Property** ppProperty, uint32_t* pIndex) +{ + if (!FindProperty(name, ppProperty, pIndex)) { + throw new MP4Error("no such property", + "MP4Container::FindStringProperty"); + } + if ((*ppProperty)->GetType() != StringProperty) { + throw new MP4Error("type mismatch", + "MP4Container::FindStringProperty"); + } +} + +const char* MP4Container::GetStringProperty(const char* name) +{ + MP4Property* pProperty; + uint32_t index; + + FindStringProperty(name, &pProperty, &index); + + return ((MP4StringProperty*)pProperty)->GetValue(index); +} + +void MP4Container::SetStringProperty(const char* name, const char* value) +{ + MP4Property* pProperty; + uint32_t index; + + FindStringProperty(name, &pProperty, &index); + + ((MP4StringProperty*)pProperty)->SetValue(value, index); +} + +void MP4Container::FindBytesProperty(const char* name, + MP4Property** ppProperty, uint32_t* pIndex) +{ + if (!FindProperty(name, ppProperty, pIndex)) { + throw new MP4Error("no such property", + "MP4Container::FindBytesProperty"); + } + if ((*ppProperty)->GetType() != BytesProperty) { + throw new MP4Error("type mismatch", + "MP4Container::FindBytesProperty"); + } +} + +void MP4Container::GetBytesProperty(const char* name, + uint8_t** ppValue, uint32_t* pValueSize) +{ + MP4Property* pProperty; + uint32_t index; + + FindBytesProperty(name, &pProperty, &index); + + ((MP4BytesProperty*)pProperty)->GetValue(ppValue, pValueSize, index); +} + +void MP4Container::SetBytesProperty(const char* name, + const uint8_t* pValue, uint32_t valueSize) +{ + MP4Property* pProperty; + uint32_t index; + + FindBytesProperty(name, &pProperty, &index); + + ((MP4BytesProperty*)pProperty)->SetValue(pValue, valueSize, index); +} + +void MP4Container::Read(MP4File* pFile) +{ + uint32_t numProperties = m_pProperties.Size(); + + for (uint32_t i = 0; i < numProperties; i++) { + m_pProperties[i]->Read(pFile); + } +} + +void MP4Container::Write(MP4File* pFile) +{ + uint32_t numProperties = m_pProperties.Size(); + + if (numProperties == 0) { + WARNING(numProperties == 0); + return; + } + + for (uint32_t i = 0; i < numProperties; i++) { + m_pProperties[i]->Write(pFile); + } +} + +void MP4Container::Dump(FILE* pFile, uint8_t indent, bool dumpImplicits) +{ + uint32_t numProperties = m_pProperties.Size(); + + for (uint32_t i = 0; i < numProperties; i++) { + m_pProperties[i]->Dump(pFile, indent, dumpImplicits); + } +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/mp4container.h b/src/mp4container.h new file mode 100644 index 0000000..201209a --- /dev/null +++ b/src/mp4container.h @@ -0,0 +1,94 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + */ + +#ifndef MP4V2_IMPL_MP4CONTAINER_H +#define MP4V2_IMPL_MP4CONTAINER_H + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +// base class - container of mp4 properties +class MP4Container { +public: + MP4Container() { } + + virtual ~MP4Container(); + + void AddProperty(MP4Property* pProperty); + + virtual void Read(MP4File* pFile); + + virtual void Write(MP4File* pFile); + + virtual void Dump(FILE* pFile, uint8_t indent, bool dumpImplicits); + + MP4Property* GetProperty(uint32_t index) { + return m_pProperties[index]; + } + + // LATER MP4Property* GetProperty(const char* name); throw on error + // LATER MP4Property* FindProperty(const char* name, uint32_t* pIndex = NULL); returns NULL on error + + bool FindProperty(const char* name, + MP4Property** ppProperty, uint32_t* pIndex = NULL); + + void FindIntegerProperty(const char* name, + MP4Property** ppProperty, uint32_t* pIndex = NULL); + + uint64_t GetIntegerProperty(const char* name); + + void SetIntegerProperty(const char* name, uint64_t value); + + void FindFloatProperty(const char* name, + MP4Property** ppProperty, uint32_t* pIndex = NULL); + + float GetFloatProperty(const char* name); + + void SetFloatProperty(const char* name, float value); + + void FindStringProperty(const char* name, + MP4Property** ppProperty, uint32_t* pIndex = NULL); + + const char* GetStringProperty(const char* name); + + void SetStringProperty(const char* name, const char* value); + + void FindBytesProperty(const char* name, + MP4Property** ppProperty, uint32_t* pIndex = NULL); + + void GetBytesProperty(const char* name, + uint8_t** ppValue, uint32_t* pValueSize); + + void SetBytesProperty(const char* name, + const uint8_t* pValue, uint32_t valueSize); + +protected: + MP4PropertyArray m_pProperties; +}; + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl + +#endif // MP4V2_IMPL_MP4CONTAINER_H diff --git a/src/mp4descriptor.cpp b/src/mp4descriptor.cpp new file mode 100644 index 0000000..70b585e --- /dev/null +++ b/src/mp4descriptor.cpp @@ -0,0 +1,221 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4Descriptor::MP4Descriptor(uint8_t tag) { + m_tag = tag; + m_pParentAtom = NULL; + m_start = 0; + m_size = 0; + m_readMutatePoint = 0; +} + +MP4Descriptor::~MP4Descriptor() +{ + for (uint32_t i = 0; i < m_pProperties.Size(); i++) { + delete m_pProperties[i]; + } +} + +void MP4Descriptor::AddProperty(MP4Property* pProperty) +{ + ASSERT(pProperty); + m_pProperties.Add(pProperty); + pProperty->SetParentAtom(m_pParentAtom); +} + +bool MP4Descriptor::FindContainedProperty(const char *name, + MP4Property** ppProperty, uint32_t* pIndex) +{ + uint32_t numProperties = m_pProperties.Size(); + + for (uint32_t i = 0; i < numProperties; i++) { + if (m_pProperties[i]->FindProperty(name, ppProperty, pIndex)) { + return true; + } + } + return false; +} + +void MP4Descriptor::Generate() +{ + // generate properties + for (uint32_t i = 0; i < m_pProperties.Size(); i++) { + m_pProperties[i]->Generate(); + } +} + +void MP4Descriptor::Read(MP4File* pFile) +{ + ReadHeader(pFile); + + ReadProperties(pFile, 0, m_readMutatePoint); + + Mutate(); + + ReadProperties(pFile, m_readMutatePoint); + + // flush any leftover read bits + pFile->FlushReadBits(); +} + +void MP4Descriptor::ReadHeader(MP4File* pFile) +{ + VERBOSE_READ(pFile->GetVerbosity(), + printf("ReadDescriptor: pos = 0x%" PRIx64 "\n", + pFile->GetPosition())); + + // read tag and length + uint8_t tag = pFile->ReadUInt8(); + if (m_tag) { + ASSERT(tag == m_tag); + } else { + m_tag = tag; + } + m_size = pFile->ReadMpegLength(); + m_start = pFile->GetPosition(); + + VERBOSE_READ(pFile->GetVerbosity(), + printf("ReadDescriptor: tag 0x%02x data size %u (0x%x)\n", + m_tag, m_size, m_size)); +} + +void MP4Descriptor::ReadProperties(MP4File* pFile, + uint32_t propStartIndex, uint32_t propCount) +{ + uint32_t numProperties = min(propCount, + m_pProperties.Size() - propStartIndex); + + for (uint32_t i = propStartIndex; + i < propStartIndex + numProperties; i++) { + + MP4Property* pProperty = m_pProperties[i]; + + int32_t remaining = m_size - (pFile->GetPosition() - m_start); + + if (pProperty->GetType() == DescriptorProperty) { + if (remaining > 0) { + // place a limit on how far this sub-descriptor looks + ((MP4DescriptorProperty*)pProperty)->SetSizeLimit(remaining); + pProperty->Read(pFile); + } // else do nothing, empty descriptor + } else { + // non-descriptor property + if (remaining >= 0) { + pProperty->Read(pFile); + + if (pProperty->GetType() == TableProperty) { + VERBOSE_READ_TABLE(pFile->GetVerbosity(), + printf("Read: "); pProperty->Dump(stdout, 0, true)); + } else { + VERBOSE_READ(pFile->GetVerbosity(), + printf("Read: "); pProperty->Dump(stdout, 0, true)); + } + } else { + VERBOSE_ERROR(pFile->GetVerbosity(), + printf("Overran descriptor, tag %u data size %u property %u\n", + m_tag, m_size, i)); + throw new MP4Error("overran descriptor", + "MP4Descriptor::ReadProperties"); + } + } + } +} + +void MP4Descriptor::Write(MP4File* pFile) +{ + // call virtual function to adapt properties before writing + Mutate(); + + uint32_t numProperties = m_pProperties.Size(); + + if (numProperties == 0) { + WARNING(numProperties == 0); + return; + } + + // write tag and length placeholder + pFile->WriteUInt8(m_tag); + uint64_t lengthPos = pFile->GetPosition(); + pFile->WriteMpegLength(0); + uint64_t startPos = pFile->GetPosition(); + + for (uint32_t i = 0; i < numProperties; i++) { + m_pProperties[i]->Write(pFile); + } + + // align with byte boundary (rarely necessary) + pFile->PadWriteBits(); + + // go back and write correct length + uint64_t endPos = pFile->GetPosition(); + pFile->SetPosition(lengthPos); + pFile->WriteMpegLength(endPos - startPos); + pFile->SetPosition(endPos); +} + +void MP4Descriptor::WriteToMemory(MP4File* pFile, + uint8_t** ppBytes, uint64_t* pNumBytes) +{ + // use memory buffer to save descriptor in memory + // instead of going directly to disk + + pFile->EnableMemoryBuffer(); + + Write(pFile); + + pFile->DisableMemoryBuffer(ppBytes, pNumBytes); +} + +void MP4Descriptor::Dump(FILE* pFile, uint8_t indent, bool dumpImplicits) +{ + // call virtual function to adapt properties before dumping + Mutate(); + + uint32_t numProperties = m_pProperties.Size(); + + if (numProperties == 0) { + WARNING(numProperties == 0); + return; + } + for (uint32_t i = 0; i < numProperties; i++) { + m_pProperties[i]->Dump(pFile, indent, dumpImplicits); + } +} + +uint8_t MP4Descriptor::GetDepth() +{ + if (m_pParentAtom) { + return m_pParentAtom->GetDepth(); + } + return 0; +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/mp4descriptor.h b/src/mp4descriptor.h new file mode 100644 index 0000000..4f1a7a5 --- /dev/null +++ b/src/mp4descriptor.h @@ -0,0 +1,107 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + */ + +#ifndef MP4V2_IMPL_MP4DESCRIPTOR_H +#define MP4V2_IMPL_MP4DESCRIPTOR_H + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +class MP4Descriptor { +public: + MP4Descriptor(uint8_t tag = 0); + + virtual ~MP4Descriptor(); + + uint8_t GetTag() { + return m_tag; + } + void SetTag(uint8_t tag) { + m_tag = tag; + } + + void SetParentAtom(MP4Atom* pParentAtom) { + m_pParentAtom = pParentAtom; + for (uint32_t i = 0; i < m_pProperties.Size(); i++) { + m_pProperties[i]->SetParentAtom(pParentAtom); + } + } + + void AddProperty(MP4Property* pProperty); + + virtual void Generate(); + virtual void Read(MP4File* pFile); + virtual void Write(MP4File* pFile); + virtual void Dump(FILE* pFile, uint8_t indent, bool dumpImplicits); + + MP4Property* GetProperty(uint32_t index) { + return m_pProperties[index]; + } + + // use with extreme caution + void SetProperty(uint32_t index, MP4Property* pProperty) { + m_pProperties[index] = pProperty; + } + + bool FindProperty( const char* name, MP4Property** ppProperty, + uint32_t* pIndex = NULL) + { + return FindContainedProperty(name, ppProperty, pIndex); + } + + void WriteToMemory(MP4File* pFile, + uint8_t** ppBytes, uint64_t* pNumBytes); + +protected: + void SetReadMutate(uint32_t propIndex) { + m_readMutatePoint = propIndex; + } + + void ReadHeader(MP4File* pFile); + void ReadProperties(MP4File* pFile, + uint32_t startIndex = 0, uint32_t count = 0xFFFFFFFF); + + virtual void Mutate() { + // default is a no-op + }; + + bool FindContainedProperty(const char* name, + MP4Property** ppProperty, uint32_t* pIndex); + + uint8_t GetDepth(); + +protected: + MP4Atom* m_pParentAtom; + uint8_t m_tag; + uint64_t m_start; + uint32_t m_size; + MP4PropertyArray m_pProperties; + uint32_t m_readMutatePoint; +}; + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl + +#endif // MP4V2_IMPL_MP4DESCRIPTOR_H diff --git a/src/mp4error.h b/src/mp4error.h new file mode 100644 index 0000000..7e785cf --- /dev/null +++ b/src/mp4error.h @@ -0,0 +1,49 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + */ + +#ifndef MP4V2_IMPL_MP4ERROR_H +#define MP4V2_IMPL_MP4ERROR_H + +namespace mp4v2 { namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +class MP4V2_EXPORT MP4Error { +public: + MP4Error(); + MP4Error( int err, const char* where = NULL ); + MP4Error( const char *format, const char *where, ... ); + MP4Error( int err, const char* format, const char* where, ... ); + ~MP4Error(); + + void Print( FILE* pFile = stderr ); + + int m_errno; + const char* m_errstring; + const char* m_where; + bool m_free; +}; + +/////////////////////////////////////////////////////////////////////////////// + +}} // namespace mp4v2::impl + +#endif // MP4V2_IMPL_MP4ERROR_H diff --git a/src/mp4file.cpp b/src/mp4file.cpp new file mode 100644 index 0000000..4cdfeec --- /dev/null +++ b/src/mp4file.cpp @@ -0,0 +1,4039 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001 - 2005. All Rights Reserved. + * + * 3GPP features implementation is based on 3GPP's TS26.234-v5.60, + * and was contributed by Ximpo Group Ltd. + * + * Portions created by Ximpo Group Ltd. are + * Copyright (C) Ximpo Group Ltd. 2003, 2004. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + * Alix Marchandise-Franquet alix@cisco.com + * Ximpo Group Ltd. mp4v2@ximpo.com + * Bill May wmay@cisco.com + */ + +#include "src/impl.h" + +namespace mp4v2 { namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4File::MP4File( uint32_t verbosity ) + : m_file ( NULL ) + , m_fileOriginalSize ( 0 ) + , m_verbosity ( verbosity ) + , m_createFlags ( 0 ) +{ + m_pRootAtom = NULL; + m_odTrackId = MP4_INVALID_TRACK_ID; + + m_useIsma = false; + + m_pModificationProperty = NULL; + m_pTimeScaleProperty = NULL; + m_pDurationProperty = NULL; + + m_memoryBuffer = NULL; + m_memoryBufferSize = 0; + m_memoryBufferPosition = 0; + + m_numReadBits = 0; + m_bufReadBits = 0; + m_numWriteBits = 0; + m_bufWriteBits = 0; + m_editName = NULL; + m_tempFileName[0] = '\0'; + m_trakName[0] = '\0'; +} + +MP4File::~MP4File() +{ + delete m_pRootAtom; + for( uint32_t i = 0; i < m_pTracks.Size(); i++ ) + delete m_pTracks[i]; + MP4Free( m_memoryBuffer ); // just in case + CHECK_AND_FREE( m_editName ); + delete m_file; +} + +void MP4File::Read( const char* name, const MP4FileProvider* provider ) +{ + Open( name, File::MODE_READ, provider ); + ReadFromFile(); + CacheProperties(); +} + +void MP4File::Create( const char* fileName, + uint32_t flags, + int add_ftyp, + int add_iods, + char* majorBrand, + uint32_t minorVersion, + char** supportedBrands, + uint32_t supportedBrandsCount ) +{ + m_createFlags = flags; + Open( fileName, File::MODE_CREATE, NULL ); + + // generate a skeletal atom tree + m_pRootAtom = MP4Atom::CreateAtom(NULL, NULL); + m_pRootAtom->SetFile(this); + m_pRootAtom->Generate(); + + if (add_ftyp != 0) { + MakeFtypAtom(majorBrand, minorVersion, + supportedBrands, supportedBrandsCount); + } + + CacheProperties(); + + // create mdat, and insert it after ftyp, and before moov + (void)InsertChildAtom(m_pRootAtom, "mdat", + add_ftyp != 0 ? 1 : 0); + + // start writing + m_pRootAtom->BeginWrite(); + if (add_iods != 0) { + (void)AddChildAtom("moov", "iods"); + } +} + +bool MP4File::Use64Bits (const char *atomName) +{ + uint32_t atomid = ATOMID(atomName); + if (atomid == ATOMID("mdat") || atomid == ATOMID("stbl")) { + return (m_createFlags & MP4_CREATE_64BIT_DATA) == MP4_CREATE_64BIT_DATA; + } + if (atomid == ATOMID("mvhd") || + atomid == ATOMID("tkhd") || + atomid == ATOMID("mdhd")) { + return (m_createFlags & MP4_CREATE_64BIT_TIME) == MP4_CREATE_64BIT_TIME; + } + return false; +} + +void MP4File::Check64BitStatus (const char *atomName) +{ + uint32_t atomid = ATOMID(atomName); + + if (atomid == ATOMID("mdat") || atomid == ATOMID("stbl")) { + m_createFlags |= MP4_CREATE_64BIT_DATA; + } else if (atomid == ATOMID("mvhd") || + atomid == ATOMID("tkhd") || + atomid == ATOMID("mdhd")) { + m_createFlags |= MP4_CREATE_64BIT_TIME; + } +} + + +bool MP4File::Modify( const char* fileName ) +{ + Open( fileName, File::MODE_MODIFY, NULL ); + ReadFromFile(); + + // find the moov atom + MP4Atom* pMoovAtom = m_pRootAtom->FindAtom("moov"); + uint32_t numAtoms; + + if (pMoovAtom == NULL) { + // there isn't one, odd but we can still proceed + return false; + //pMoovAtom = AddChildAtom(m_pRootAtom, "moov"); + } else { + numAtoms = m_pRootAtom->GetNumberOfChildAtoms(); + + // work backwards thru the top level atoms + int32_t i; + bool lastAtomIsMoov = true; + MP4Atom* pLastAtom = NULL; + + for (i = numAtoms - 1; i >= 0; i--) { + MP4Atom* pAtom = m_pRootAtom->GetChildAtom(i); + const char* type = pAtom->GetType(); + + // get rid of any trailing free or skips + if (!strcmp(type, "free") || !strcmp(type, "skip")) { + m_pRootAtom->DeleteChildAtom(pAtom); + continue; + } + + if (strcmp(type, "moov")) { + if (pLastAtom == NULL) { + pLastAtom = pAtom; + lastAtomIsMoov = false; + } + continue; + } + + // now at moov atom + + // multiple moov atoms?!? + if (pAtom != pMoovAtom) { + throw new MP4Error( + "Badly formed mp4 file, multiple moov atoms", + "MP4Modify"); + } + + if (lastAtomIsMoov) { + // position to start of moov atom, + // effectively truncating file + // prior to adding new mdat + SetPosition(pMoovAtom->GetStart()); + + } else { // last atom isn't moov + // need to place a free atom + MP4Atom* pFreeAtom = MP4Atom::CreateAtom(NULL, "free"); + + // in existing position of the moov atom + m_pRootAtom->InsertChildAtom(pFreeAtom, i); + m_pRootAtom->DeleteChildAtom(pMoovAtom); + m_pRootAtom->AddChildAtom(pMoovAtom); + + // write free atom to disk + SetPosition(pMoovAtom->GetStart()); + pFreeAtom->SetSize(pMoovAtom->GetSize()); + pFreeAtom->Write(); + + // finally set our file position to the end of the last atom + SetPosition(pLastAtom->GetEnd()); + } + + break; + } + ASSERT(i != -1); + } + + CacheProperties(); // of moov atom + + numAtoms = m_pRootAtom->GetNumberOfChildAtoms(); + + // insert another mdat prior to moov atom (the last atom) + MP4Atom* pMdatAtom = InsertChildAtom(m_pRootAtom, "mdat", numAtoms - 1); + + // start writing new mdat + pMdatAtom->BeginWrite(Use64Bits("mdat")); + return true; +} + +void MP4File::Optimize( const char* srcFileName, const char* dstFileName ) +{ + // first load meta-info into memory + Open( srcFileName, File::MODE_READ, NULL ); + ReadFromFile(); + CacheProperties(); // of moov atom + + File* const src = m_file; + m_file = NULL; + + // compute destination filename + string dname; + if( dstFileName ) + dname = dstFileName; + else + FileSystem::pathnameTemp( dname, ".", "tmp", ".mp4" ); + + Open( dname.c_str(), File::MODE_CREATE, NULL ); + File* const dst = m_file; + + SetIntegerProperty( "moov.mvhd.modificationTime", MP4GetAbsTimestamp() ); + + // writing meta info in the optimal order + ((MP4RootAtom*)m_pRootAtom)->BeginOptimalWrite(); + + // write data in optimal order + RewriteMdat( *src, *dst ); + + // finish writing + ((MP4RootAtom*)m_pRootAtom)->FinishOptimalWrite(); + + // cleanup + delete dst; + delete src; + m_file = NULL; + + // move temporary file into place + if( !dstFileName ) + Rename( dname.c_str(), srcFileName ); +} + +void MP4File::RewriteMdat( File& src, File& dst ) +{ + uint32_t numTracks = m_pTracks.Size(); + + MP4ChunkId* chunkIds = new MP4ChunkId[numTracks]; + MP4ChunkId* maxChunkIds = new MP4ChunkId[numTracks]; + MP4Timestamp* nextChunkTimes = new MP4Timestamp[numTracks]; + + for( uint32_t i = 0; i < numTracks; i++ ) { + chunkIds[i] = 1; + maxChunkIds[i] = m_pTracks[i]->GetNumberOfChunks(); + nextChunkTimes[i] = MP4_INVALID_TIMESTAMP; + } + + for( ;; ) { + uint32_t nextTrackIndex = (uint32_t)-1; + MP4Timestamp nextTime = MP4_INVALID_TIMESTAMP; + + for( uint32_t i = 0; i < numTracks; i++ ) { + if( chunkIds[i] > maxChunkIds[i] ) + continue; + + if( nextChunkTimes[i] == MP4_INVALID_TIMESTAMP ) { + MP4Timestamp chunkTime = m_pTracks[i]->GetChunkTime( chunkIds[i] ); + nextChunkTimes[i] = MP4ConvertTime( chunkTime, m_pTracks[i]->GetTimeScale(), GetTimeScale() ); + } + + // time is not earliest so far + if( nextChunkTimes[i] > nextTime ) + continue; + + // prefer hint tracks to media tracks if times are equal + if( nextChunkTimes[i] == nextTime && strcmp( m_pTracks[i]->GetType(), MP4_HINT_TRACK_TYPE )) + continue; + + // this is our current choice of tracks + nextTime = nextChunkTimes[i]; + nextTrackIndex = i; + } + + if( nextTrackIndex == (uint32_t)-1 ) + break; + + uint8_t* pChunk; + uint32_t chunkSize; + + // point into original mp4 file for read chunk call + m_file = &src; + m_pTracks[nextTrackIndex]->ReadChunk( chunkIds[nextTrackIndex], &pChunk, &chunkSize ); + + // point back at the new mp4 file for write chunk + m_file = &dst; + m_pTracks[nextTrackIndex]->RewriteChunk( chunkIds[nextTrackIndex], pChunk, chunkSize ); + + MP4Free( pChunk ); + + chunkIds[nextTrackIndex]++; + nextChunkTimes[nextTrackIndex] = MP4_INVALID_TIMESTAMP; + } + + delete [] chunkIds; + delete [] maxChunkIds; + delete [] nextChunkTimes; +} + +void MP4File::Open( const char* name, File::Mode mode, const MP4FileProvider* provider ) +{ + ASSERT( !m_file ); + + m_file = new File( name, mode, provider ? new io::CustomFileProvider( *provider ) : NULL ); + if( m_file->open() ) + throw new MP4Error( errno, "failed", "MP4Open" ); + + switch( mode ) { + case File::MODE_READ: + case File::MODE_MODIFY: + m_fileOriginalSize = m_file->size; + break; + + case File::MODE_CREATE: + default: + m_fileOriginalSize = 0; + break; + } +} + +void MP4File::ReadFromFile() +{ + // ensure we start at beginning of file + SetPosition(0); + + // create a new root atom + ASSERT(m_pRootAtom == NULL); + m_pRootAtom = MP4Atom::CreateAtom(NULL, NULL); + + uint64_t fileSize = GetSize(); + + m_pRootAtom->SetFile(this); + m_pRootAtom->SetStart(0); + m_pRootAtom->SetSize(fileSize); + m_pRootAtom->SetEnd(fileSize); + + m_pRootAtom->Read(); + + // create MP4Track's for any tracks in the file + GenerateTracks(); +} + +void MP4File::GenerateTracks() +{ + uint32_t trackIndex = 0; + + while (true) { + char trackName[32]; + snprintf(trackName, sizeof(trackName), "moov.trak[%u]", trackIndex); + + // find next trak atom + MP4Atom* pTrakAtom = m_pRootAtom->FindAtom(trackName); + + // done, no more trak atoms + if (pTrakAtom == NULL) { + break; + } + + // find track id property + MP4Integer32Property* pTrackIdProperty = NULL; + (void)pTrakAtom->FindProperty( + "trak.tkhd.trackId", + (MP4Property**)&pTrackIdProperty); + + // find track type property + MP4StringProperty* pTypeProperty = NULL; + (void)pTrakAtom->FindProperty( + "trak.mdia.hdlr.handlerType", + (MP4Property**)&pTypeProperty); + + // ensure we have the basics properties + if (pTrackIdProperty && pTypeProperty) { + + m_trakIds.Add(pTrackIdProperty->GetValue()); + + MP4Track* pTrack = NULL; + try { + if (!strcmp(pTypeProperty->GetValue(), MP4_HINT_TRACK_TYPE)) { + pTrack = new MP4RtpHintTrack(this, pTrakAtom); + } else { + pTrack = new MP4Track(this, pTrakAtom); + } + m_pTracks.Add(pTrack); + } + catch (MP4Error* e) { + VERBOSE_ERROR(m_verbosity, e->Print()); + delete e; + } + + // remember when we encounter the OD track + if (pTrack && !strcmp(pTrack->GetType(), MP4_OD_TRACK_TYPE)) { + if (m_odTrackId == MP4_INVALID_TRACK_ID) { + m_odTrackId = pTrackIdProperty->GetValue(); + } else { + VERBOSE_READ(GetVerbosity(), + printf("Warning: multiple OD tracks present\n")); + } + } + } else { + m_trakIds.Add(0); + } + + trackIndex++; + } +} + +void MP4File::CacheProperties() +{ + FindIntegerProperty("moov.mvhd.modificationTime", + (MP4Property**)&m_pModificationProperty); + + FindIntegerProperty("moov.mvhd.timeScale", + (MP4Property**)&m_pTimeScaleProperty); + + FindIntegerProperty("moov.mvhd.duration", + (MP4Property**)&m_pDurationProperty); +} + +void MP4File::BeginWrite() +{ + m_pRootAtom->BeginWrite(); +} + +void MP4File::FinishWrite() +{ + // for all tracks, flush chunking buffers + for( uint32_t i = 0; i < m_pTracks.Size(); i++ ) { + ASSERT( m_pTracks[i] ); + m_pTracks[i]->FinishWrite(); + } + + // ask root atom to write + m_pRootAtom->FinishWrite(); + + // finished all writes, if position < size then file has shrunk and + // we mark remaining bytes as free atom; otherwise trailing garbage remains. + if( GetPosition() < GetSize() ) { + MP4RootAtom* root = (MP4RootAtom*)FindAtom( "" ); + ASSERT( root ); + + // compute size of free atom; always has 8 bytes of overhead + uint64_t size = GetSize() - GetPosition(); + if( size < 8 ) + size = 0; + else + size -= 8; + + MP4FreeAtom* freeAtom = (MP4FreeAtom*)MP4Atom::CreateAtom( NULL, "free" ); + ASSERT( freeAtom ); + freeAtom->SetSize( size ); + root->AddChildAtom( freeAtom ); + freeAtom->Write(); + } +} + +void MP4File::UpdateDuration(MP4Duration duration) +{ + MP4Duration currentDuration = GetDuration(); + if (duration > currentDuration) { + SetDuration(duration); + } +} + +void MP4File::Dump( FILE* fout, bool dumpImplicits ) +{ + if( !fout ) + fout = stdout; + + fprintf( fout, "Dumping %s meta-information...\n", m_file->name.c_str() ); + m_pRootAtom->Dump( fout, 0, dumpImplicits); +} + +void MP4File::Close() +{ + if( IsWriteMode() ) { + SetIntegerProperty( "moov.mvhd.modificationTime", MP4GetAbsTimestamp() ); + FinishWrite(); + } + + delete m_file; + m_file = NULL; +} + +void MP4File::Rename(const char* oldFileName, const char* newFileName) +{ + if( FileSystem::rename( oldFileName, newFileName )) + throw new MP4Error( sys::getLastError(), sys::getLastErrorStr(), "MP4Rename" ); +} + +void MP4File::ProtectWriteOperation(const char* where) +{ + if( !IsWriteMode() ) + throw new MP4Error( "operation not permitted in read mode", where ); +} + +MP4Track* MP4File::GetTrack(MP4TrackId trackId) +{ + return m_pTracks[FindTrackIndex(trackId)]; +} + +MP4Atom* MP4File::FindAtom(const char* name) +{ + MP4Atom* pAtom = NULL; + if (!name || !strcmp(name, "")) { + pAtom = m_pRootAtom; + } else { + pAtom = m_pRootAtom->FindAtom(name); + } + return pAtom; +} + +MP4Atom* MP4File::AddChildAtom( + const char* parentName, + const char* childName) +{ + return AddChildAtom(FindAtom(parentName), childName); +} + +MP4Atom* MP4File::AddChildAtom( + MP4Atom* pParentAtom, + const char* childName) +{ + return InsertChildAtom(pParentAtom, childName, + pParentAtom->GetNumberOfChildAtoms()); +} + +MP4Atom* MP4File::InsertChildAtom( + const char* parentName, + const char* childName, + uint32_t index) +{ + return InsertChildAtom(FindAtom(parentName), childName, index); +} + +MP4Atom* MP4File::InsertChildAtom( + MP4Atom* pParentAtom, + const char* childName, + uint32_t index) +{ + MP4Atom* pChildAtom = MP4Atom::CreateAtom(pParentAtom, childName); + + ASSERT(pParentAtom); + pParentAtom->InsertChildAtom(pChildAtom, index); + + pChildAtom->Generate(); + + return pChildAtom; +} + +MP4Atom* MP4File::AddDescendantAtoms( + const char* ancestorName, + const char* descendantNames) +{ + return AddDescendantAtoms(FindAtom(ancestorName), descendantNames); +} + +MP4Atom* MP4File::AddDescendantAtoms( + MP4Atom* pAncestorAtom, const char* descendantNames) +{ + ASSERT(pAncestorAtom); + + MP4Atom* pParentAtom = pAncestorAtom; + MP4Atom* pChildAtom = NULL; + + while (true) { + char* childName = MP4NameFirst(descendantNames); + + if (childName == NULL) { + break; + } + + descendantNames = MP4NameAfterFirst(descendantNames); + + pChildAtom = pParentAtom->FindChildAtom(childName); + + if (pChildAtom == NULL) { + pChildAtom = AddChildAtom(pParentAtom, childName); + } + + pParentAtom = pChildAtom; + + MP4Free(childName); + } + + return pChildAtom; +} + +bool MP4File::FindProperty(const char* name, + MP4Property** ppProperty, uint32_t* pIndex) +{ + if( pIndex ) + *pIndex = 0; // set the default answer for index + return m_pRootAtom->FindProperty(name, ppProperty, pIndex); +} + +void MP4File::FindIntegerProperty(const char* name, + MP4Property** ppProperty, uint32_t* pIndex) +{ + if (!FindProperty(name, ppProperty, pIndex)) { + throw new MP4Error("no such property - %s", "MP4File::FindIntegerProperty", name); + } + + switch ((*ppProperty)->GetType()) { + case Integer8Property: + case Integer16Property: + case Integer24Property: + case Integer32Property: + case Integer64Property: + break; + default: + throw new MP4Error("type mismatch - property %s type %d", "MP4File::FindIntegerProperty", name, (*ppProperty)->GetType()); + } +} + +uint64_t MP4File::GetIntegerProperty(const char* name) +{ + MP4Property* pProperty; + uint32_t index; + + FindIntegerProperty(name, &pProperty, &index); + + return ((MP4IntegerProperty*)pProperty)->GetValue(index); +} + +void MP4File::SetIntegerProperty(const char* name, uint64_t value) +{ + ProtectWriteOperation("SetIntegerProperty"); + + MP4Property* pProperty = NULL; + uint32_t index = 0; + + FindIntegerProperty(name, &pProperty, &index); + + ((MP4IntegerProperty*)pProperty)->SetValue(value, index); +} + +void MP4File::FindFloatProperty(const char* name, + MP4Property** ppProperty, uint32_t* pIndex) +{ + if (!FindProperty(name, ppProperty, pIndex)) { + throw new MP4Error("no such property - %s", "MP4File::FindFloatProperty", name); + } + if ((*ppProperty)->GetType() != Float32Property) { + throw new MP4Error("type mismatch - property %s type %d", + "MP4File::FindFloatProperty", + name, + (*ppProperty)->GetType()); + } +} + +float MP4File::GetFloatProperty(const char* name) +{ + MP4Property* pProperty; + uint32_t index; + + FindFloatProperty(name, &pProperty, &index); + + return ((MP4Float32Property*)pProperty)->GetValue(index); +} + +void MP4File::SetFloatProperty(const char* name, float value) +{ + ProtectWriteOperation("SetFloatProperty"); + + MP4Property* pProperty; + uint32_t index; + + FindFloatProperty(name, &pProperty, &index); + + ((MP4Float32Property*)pProperty)->SetValue(value, index); +} + +void MP4File::FindStringProperty(const char* name, + MP4Property** ppProperty, uint32_t* pIndex) +{ + if (!FindProperty(name, ppProperty, pIndex)) { + throw new MP4Error("no such property - %s", "MP4File::FindStringProperty", name); + } + if ((*ppProperty)->GetType() != StringProperty) { + throw new MP4Error("type mismatch - property %s type %d", "MP4File::FindStringProperty", + name, (*ppProperty)->GetType()); + } +} + +const char* MP4File::GetStringProperty(const char* name) +{ + MP4Property* pProperty; + uint32_t index; + + FindStringProperty(name, &pProperty, &index); + + return ((MP4StringProperty*)pProperty)->GetValue(index); +} + +void MP4File::SetStringProperty(const char* name, const char* value) +{ + ProtectWriteOperation("SetStringProperty"); + + MP4Property* pProperty; + uint32_t index; + + FindStringProperty(name, &pProperty, &index); + + ((MP4StringProperty*)pProperty)->SetValue(value, index); +} + +void MP4File::FindBytesProperty(const char* name, + MP4Property** ppProperty, uint32_t* pIndex) +{ + if (!FindProperty(name, ppProperty, pIndex)) { + throw new MP4Error("no such property %s", "MP4File::FindBytesProperty", name); + } + if ((*ppProperty)->GetType() != BytesProperty) { + throw new MP4Error("type mismatch - property %s - type %d", "MP4File::FindBytesProperty", name, (*ppProperty)->GetType()); + } +} + +void MP4File::GetBytesProperty(const char* name, + uint8_t** ppValue, uint32_t* pValueSize) +{ + MP4Property* pProperty; + uint32_t index; + + FindBytesProperty(name, &pProperty, &index); + + ((MP4BytesProperty*)pProperty)->GetValue(ppValue, pValueSize, index); +} + +void MP4File::SetBytesProperty(const char* name, + const uint8_t* pValue, uint32_t valueSize) +{ + ProtectWriteOperation("SetBytesProperty"); + + MP4Property* pProperty; + uint32_t index; + + FindBytesProperty(name, &pProperty, &index); + + ((MP4BytesProperty*)pProperty)->SetValue(pValue, valueSize, index); +} + + +// track functions + +MP4TrackId MP4File::AddTrack(const char* type, uint32_t timeScale) +{ + ProtectWriteOperation("AddTrack"); + + // create and add new trak atom + MP4Atom* pTrakAtom = AddChildAtom("moov", "trak"); + + // allocate a new track id + MP4TrackId trackId = AllocTrackId(); + + m_trakIds.Add(trackId); + + // set track id + MP4Integer32Property* pInteger32Property = NULL; + (void)pTrakAtom->FindProperty("trak.tkhd.trackId", + (MP4Property**)&pInteger32Property); + ASSERT(pInteger32Property); + pInteger32Property->SetValue(trackId); + + // set track type + const char* normType = MP4NormalizeTrackType(type, m_verbosity); + + // sanity check for user defined types + if (strlen(normType) > 4) { + VERBOSE_WARNING(m_verbosity, + printf("AddTrack: type truncated to four characters\n")); + // StringProperty::SetValue() will do the actual truncation + } + + MP4StringProperty* pStringProperty = NULL; + (void)pTrakAtom->FindProperty("trak.mdia.hdlr.handlerType", + (MP4Property**)&pStringProperty); + ASSERT(pStringProperty); + pStringProperty->SetValue(normType); + + // set track time scale + pInteger32Property = NULL; + (void)pTrakAtom->FindProperty("trak.mdia.mdhd.timeScale", + (MP4Property**)&pInteger32Property); + ASSERT(pInteger32Property); + pInteger32Property->SetValue(timeScale ? timeScale : 1000); + + // now have enough to create MP4Track object + MP4Track* pTrack = NULL; + if (!strcmp(normType, MP4_HINT_TRACK_TYPE)) { + pTrack = new MP4RtpHintTrack(this, pTrakAtom); + } else { + pTrack = new MP4Track(this, pTrakAtom); + } + m_pTracks.Add(pTrack); + + // mark non-hint tracks as enabled + if (strcmp(normType, MP4_HINT_TRACK_TYPE)) { + SetTrackIntegerProperty(trackId, "tkhd.flags", 1); + } + + // mark track as contained in this file + // LATER will provide option for external data references + AddDataReference(trackId, NULL); + + return trackId; +} + +void MP4File::AddTrackToIod(MP4TrackId trackId) +{ + MP4DescriptorProperty* pDescriptorProperty = NULL; + (void)m_pRootAtom->FindProperty("moov.iods.esIds", + (MP4Property**)&pDescriptorProperty); + ASSERT(pDescriptorProperty); + + MP4Descriptor* pDescriptor = + pDescriptorProperty->AddDescriptor(MP4ESIDIncDescrTag); + ASSERT(pDescriptor); + + MP4Integer32Property* pIdProperty = NULL; + (void)pDescriptor->FindProperty("id", + (MP4Property**)&pIdProperty); + ASSERT(pIdProperty); + + pIdProperty->SetValue(trackId); +} + +void MP4File::RemoveTrackFromIod(MP4TrackId trackId, bool shallHaveIods) +{ + MP4DescriptorProperty* pDescriptorProperty = NULL; + if (!m_pRootAtom->FindProperty("moov.iods.esIds", + (MP4Property**)&pDescriptorProperty)) + return; +#if 0 + // we may not have iods + if (shallHaveIods) { + ASSERT(pDescriptorProperty); + } else { + if (!pDescriptorProperty) { + return; + } + } +#else + if (pDescriptorProperty == NULL) { + return; + } +#endif + + for (uint32_t i = 0; i < pDescriptorProperty->GetCount(); i++) { + /* static */ + char name[32]; + snprintf(name, sizeof(name), "esIds[%u].id", i); + + MP4Integer32Property* pIdProperty = NULL; + (void)pDescriptorProperty->FindProperty(name, + (MP4Property**)&pIdProperty); + // wmay ASSERT(pIdProperty); + + if (pIdProperty != NULL && + pIdProperty->GetValue() == trackId) { + pDescriptorProperty->DeleteDescriptor(i); + break; + } + } +} + +void MP4File::AddTrackToOd(MP4TrackId trackId) +{ + if (!m_odTrackId) { + return; + } + + AddTrackReference(MakeTrackName(m_odTrackId, "tref.mpod"), trackId); +} + +void MP4File::RemoveTrackFromOd(MP4TrackId trackId) +{ + if (!m_odTrackId) { + return; + } + + RemoveTrackReference(MakeTrackName(m_odTrackId, "tref.mpod"), trackId); +} + +/* + * Try to obtain the properties of this reference track, if not found then return + * NULL in *ppCountProperty and *ppTrackIdProperty. + */ +void MP4File::GetTrackReferenceProperties(const char* trefName, + MP4Property** ppCountProperty, MP4Property** ppTrackIdProperty) +{ + char propName[1024]; + + snprintf(propName, sizeof(propName), "%s.%s", trefName, "entryCount"); + (void)m_pRootAtom->FindProperty(propName, ppCountProperty); + + snprintf(propName, sizeof(propName), "%s.%s", trefName, "entries.trackId"); + (void)m_pRootAtom->FindProperty(propName, ppTrackIdProperty); +} + +void MP4File::AddTrackReference(const char* trefName, MP4TrackId refTrackId) +{ + MP4Integer32Property* pCountProperty = NULL; + MP4Integer32Property* pTrackIdProperty = NULL; + + GetTrackReferenceProperties(trefName, + (MP4Property**)&pCountProperty, + (MP4Property**)&pTrackIdProperty); + + if (pCountProperty && pTrackIdProperty) { + pTrackIdProperty->AddValue(refTrackId); + pCountProperty->IncrementValue(); + } +} + +uint32_t MP4File::FindTrackReference(const char* trefName, + MP4TrackId refTrackId) +{ + MP4Integer32Property* pCountProperty = NULL; + MP4Integer32Property* pTrackIdProperty = NULL; + + GetTrackReferenceProperties(trefName, + (MP4Property**)&pCountProperty, + (MP4Property**)&pTrackIdProperty); + + if (pCountProperty && pTrackIdProperty) { + for (uint32_t i = 0; i < pCountProperty->GetValue(); i++) { + if (refTrackId == pTrackIdProperty->GetValue(i)) { + return i + 1; // N.B. 1 not 0 based index + } + } + } + return 0; +} + +void MP4File::RemoveTrackReference(const char* trefName, MP4TrackId refTrackId) +{ + MP4Integer32Property* pCountProperty = NULL; + MP4Integer32Property* pTrackIdProperty = NULL; + + GetTrackReferenceProperties(trefName, + (MP4Property**)&pCountProperty, + (MP4Property**)&pTrackIdProperty); + + if (pCountProperty && pTrackIdProperty) { + for (uint32_t i = 0; i < pCountProperty->GetValue(); i++) { + if (refTrackId == pTrackIdProperty->GetValue(i)) { + pTrackIdProperty->DeleteValue(i); + pCountProperty->IncrementValue(-1); + } + } + } +} + +void MP4File::AddDataReference(MP4TrackId trackId, const char* url) +{ + MP4Atom* pDrefAtom = + FindAtom(MakeTrackName(trackId, "mdia.minf.dinf.dref")); + ASSERT(pDrefAtom); + + MP4Integer32Property* pCountProperty = NULL; + (void)pDrefAtom->FindProperty("dref.entryCount", + (MP4Property**)&pCountProperty); + ASSERT(pCountProperty); + pCountProperty->IncrementValue(); + + MP4Atom* pUrlAtom = AddChildAtom(pDrefAtom, "url "); + + if (url && url[0] != '\0') { + pUrlAtom->SetFlags(pUrlAtom->GetFlags() & 0xFFFFFE); + + MP4StringProperty* pUrlProperty = NULL; + (void)pUrlAtom->FindProperty("url .location", + (MP4Property**)&pUrlProperty); + ASSERT(pUrlProperty); + pUrlProperty->SetValue(url); + } else { + pUrlAtom->SetFlags(pUrlAtom->GetFlags() | 1); + } +} + +MP4TrackId MP4File::AddSystemsTrack(const char* type) +{ + const char* normType = MP4NormalizeTrackType(type, m_verbosity); + + // TBD if user type, fix name to four chars, and warn + + MP4TrackId trackId = AddTrack(type, MP4_MSECS_TIME_SCALE); + + (void)InsertChildAtom(MakeTrackName(trackId, "mdia.minf"), "nmhd", 0); + + (void)AddChildAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd"), "mp4s"); + + AddDescendantAtoms(MakeTrackName(trackId, NULL), "udta.name"); + + // stsd is a unique beast in that it has a count of the number + // of child atoms that needs to be incremented after we add the mp4s atom + MP4Integer32Property* pStsdCountProperty; + FindIntegerProperty( + MakeTrackName(trackId, "mdia.minf.stbl.stsd.entryCount"), + (MP4Property**)&pStsdCountProperty); + pStsdCountProperty->IncrementValue(); + + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.mp4s.esds.ESID", +#if 0 + // note - for a file, these values need to + // be 0 - wmay - 04/16/2003 + trackId +#else + 0 +#endif + ); + + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.mp4s.esds.decConfigDescr.objectTypeId", + MP4SystemsV1ObjectType); + + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.mp4s.esds.decConfigDescr.streamType", + ConvertTrackTypeToStreamType(normType)); + + return trackId; +} + +MP4TrackId MP4File::AddODTrack() +{ + // until a demonstrated need emerges + // we limit ourselves to one object description track + if (m_odTrackId != MP4_INVALID_TRACK_ID) { + throw new MP4Error("object description track already exists", + "AddObjectDescriptionTrack"); + } + + m_odTrackId = AddSystemsTrack(MP4_OD_TRACK_TYPE); + + AddTrackToIod(m_odTrackId); + + (void)AddDescendantAtoms(MakeTrackName(m_odTrackId, NULL), "tref.mpod"); + + return m_odTrackId; +} + +MP4TrackId MP4File::AddSceneTrack() +{ + MP4TrackId trackId = AddSystemsTrack(MP4_SCENE_TRACK_TYPE); + + AddTrackToIod(trackId); + AddTrackToOd(trackId); + + return trackId; +} + +bool MP4File::ShallHaveIods() +{ + // NULL terminated list of brands which require the IODS atom + const char* brandsWithIods[] = { + "mp42", + "isom", + NULL + }; + + MP4FtypAtom* ftyp = (MP4FtypAtom*)m_pRootAtom->FindAtom( "ftyp" ); + if( !ftyp ) + return false; + + // check major brand + const char* brand = ftyp->majorBrand.GetValue(); + for( uint32_t i = 0; brandsWithIods[i] != NULL; i++ ) { + if( !strcasecmp( brandsWithIods[i], brand )) + return true; + } + + // check compatible brands + uint32_t max = ftyp->compatibleBrands.GetCount(); + for( uint32_t i = 0; i < max; i++ ) { + brand = ftyp->compatibleBrands.GetValue( i ); + for( uint32_t j = 0; brandsWithIods[j] != NULL ; j++) { + if( !strcasecmp( brandsWithIods[j], brand )) + return true; + } + } + + return false; +} + +void MP4File::SetAmrVendor( + MP4TrackId trackId, + uint32_t vendor) +{ + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.*.damr.vendor", + vendor); +} + +void MP4File::SetAmrDecoderVersion( + MP4TrackId trackId, + uint8_t decoderVersion) +{ + + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.*.damr.decoderVersion", + decoderVersion); +} + +void MP4File::SetAmrModeSet( + MP4TrackId trackId, + uint16_t modeSet) +{ + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.*.damr.modeSet", + modeSet); +} +uint16_t MP4File::GetAmrModeSet(MP4TrackId trackId) +{ + return GetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.*.damr.modeSet"); +} + +MP4TrackId MP4File::AddAmrAudioTrack( + uint32_t timeScale, + uint16_t modeSet, + uint8_t modeChangePeriod, + uint8_t framesPerSample, + bool isAmrWB) +{ + + uint32_t fixedSampleDuration = (timeScale * 20)/1000; // 20mSec/Sample + + MP4TrackId trackId = AddTrack(MP4_AUDIO_TRACK_TYPE, timeScale); + + AddTrackToOd(trackId); + + SetTrackFloatProperty(trackId, "tkhd.volume", 1.0); + + (void)InsertChildAtom(MakeTrackName(trackId, "mdia.minf"), "smhd", 0); + + (void)AddChildAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd"), isAmrWB ? "sawb" : "samr"); + + // stsd is a unique beast in that it has a count of the number + // of child atoms that needs to be incremented after we add the mp4a atom + MP4Integer32Property* pStsdCountProperty; + FindIntegerProperty( + MakeTrackName(trackId, "mdia.minf.stbl.stsd.entryCount"), + (MP4Property**)&pStsdCountProperty); + pStsdCountProperty->IncrementValue(); + + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.*.timeScale", + timeScale); + + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.*.damr.modeSet", + modeSet); + + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.*.damr.modeChangePeriod", + modeChangePeriod); + + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.*.damr.framesPerSample", + framesPerSample); + + + m_pTracks[FindTrackIndex(trackId)]-> + SetFixedSampleDuration(fixedSampleDuration); + + return trackId; +} + +MP4TrackId MP4File::AddAudioTrack( + uint32_t timeScale, + MP4Duration sampleDuration, + uint8_t audioType) +{ + MP4TrackId trackId = AddTrack(MP4_AUDIO_TRACK_TYPE, timeScale); + + AddTrackToOd(trackId); + + SetTrackFloatProperty(trackId, "tkhd.volume", 1.0); + + (void)InsertChildAtom(MakeTrackName(trackId, "mdia.minf"), "smhd", 0); + + (void)AddChildAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd"), "mp4a"); + + AddDescendantAtoms(MakeTrackName(trackId, NULL), "udta.name"); + + // stsd is a unique beast in that it has a count of the number + // of child atoms that needs to be incremented after we add the mp4a atom + MP4Integer32Property* pStsdCountProperty; + FindIntegerProperty( + MakeTrackName(trackId, "mdia.minf.stbl.stsd.entryCount"), + (MP4Property**)&pStsdCountProperty); + pStsdCountProperty->IncrementValue(); + + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.mp4a.timeScale", timeScale); + + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.mp4a.esds.ESID", +#if 0 + // note - for a file, these values need to + // be 0 - wmay - 04/16/2003 + trackId +#else + 0 +#endif + ); + + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.mp4a.esds.decConfigDescr.objectTypeId", + audioType); + + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.mp4a.esds.decConfigDescr.streamType", + MP4AudioStreamType); + + m_pTracks[FindTrackIndex(trackId)]-> + SetFixedSampleDuration(sampleDuration); + + return trackId; +} + +MP4TrackId MP4File::AddAC3AudioTrack( + uint32_t samplingRate, + uint8_t fscod, + uint8_t bsid, + uint8_t bsmod, + uint8_t acmod, + uint8_t lfeon, + uint8_t bit_rate_code) +{ + MP4TrackId trackId = AddTrack(MP4_AUDIO_TRACK_TYPE, samplingRate); + + AddTrackToOd(trackId); + + SetTrackFloatProperty(trackId, "tkhd.volume", 1.0); + + InsertChildAtom(MakeTrackName(trackId, "mdia.minf"), "smhd", 0); + + AddChildAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd"), "ac-3"); + + // Set Ac3 settings + MP4Integer16Property* pSampleRateProperty = NULL; + FindIntegerProperty( + MakeTrackName(trackId, "mdia.minf.stbl.stsd.ac-3.samplingRate"), + (MP4Property**)&pSampleRateProperty); + if (pSampleRateProperty) { + pSampleRateProperty->SetValue(samplingRate); + } else { + throw new MP4Error("no property", "ac-3.samplingRate"); + } + + MP4BitfieldProperty* pBitfieldProperty = NULL; + + FindProperty(MakeTrackName(trackId, "mdia.minf.stbl.stsd.ac-3.dac3.fscod"), + (MP4Property**)&pBitfieldProperty); + if (pBitfieldProperty) { + pBitfieldProperty->SetValue(fscod); + pBitfieldProperty = NULL; + } else { + throw new MP4Error("no property", "dac3.fscod"); + } + + FindProperty(MakeTrackName(trackId, "mdia.minf.stbl.stsd.ac-3.dac3.bsid"), + (MP4Property**)&pBitfieldProperty); + if (pBitfieldProperty) { + pBitfieldProperty->SetValue(bsid); + pBitfieldProperty = NULL; + } else { + throw new MP4Error("no property", "dac3.bsid"); + } + + FindProperty(MakeTrackName(trackId, "mdia.minf.stbl.stsd.ac-3.dac3.bsmod"), + (MP4Property**)&pBitfieldProperty); + if (pBitfieldProperty) { + pBitfieldProperty->SetValue(bsmod); + pBitfieldProperty = NULL; + } else { + throw new MP4Error("no property", "dac3.bsmod"); + } + + FindProperty(MakeTrackName(trackId, "mdia.minf.stbl.stsd.ac-3.dac3.acmod"), + (MP4Property**)&pBitfieldProperty); + if (pBitfieldProperty) { + pBitfieldProperty->SetValue(acmod); + pBitfieldProperty = NULL; + } else { + throw new MP4Error("no property", "dac3.acmod"); + } + + FindProperty(MakeTrackName(trackId, "mdia.minf.stbl.stsd.ac-3.dac3.lfeon"), + (MP4Property**)&pBitfieldProperty); + if (pBitfieldProperty) { + pBitfieldProperty->SetValue(lfeon); + pBitfieldProperty = NULL; + } else { + throw new MP4Error("no property", "dac3.lfeon"); + } + + FindProperty(MakeTrackName(trackId, "mdia.minf.stbl.stsd.ac-3.dac3.bit_rate_code"), + (MP4Property**)&pBitfieldProperty); + if (pBitfieldProperty) { + pBitfieldProperty->SetValue(bit_rate_code); + pBitfieldProperty = NULL; + } else { + throw new MP4Error("no property", "dac3.bit_rate_code"); + } + + AddDescendantAtoms(MakeTrackName(trackId, NULL), "udta.name"); + + // stsd is a unique beast in that it has a count of the number + // of child atoms that needs to be incremented after we add the mp4a atom + MP4Integer32Property* pStsdCountProperty; + FindIntegerProperty( + MakeTrackName(trackId, "mdia.minf.stbl.stsd.entryCount"), + (MP4Property**)&pStsdCountProperty); + pStsdCountProperty->IncrementValue(); + + m_pTracks[FindTrackIndex(trackId)]-> + SetFixedSampleDuration(1536); + + return trackId; +} + +MP4TrackId MP4File::AddEncAudioTrack(uint32_t timeScale, + MP4Duration sampleDuration, + uint8_t audioType, + uint32_t scheme_type, + uint16_t scheme_version, + uint8_t key_ind_len, + uint8_t iv_len, + bool selective_enc, + const char *kms_uri, + bool use_ismacryp + ) +{ + uint32_t original_fmt = 0; + + MP4TrackId trackId = AddTrack(MP4_AUDIO_TRACK_TYPE, timeScale); + + AddTrackToOd(trackId); + + SetTrackFloatProperty(trackId, "tkhd.volume", 1.0); + + (void)InsertChildAtom(MakeTrackName(trackId, "mdia.minf"), "smhd", 0); + + (void)AddChildAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd"), "enca"); + + // stsd is a unique beast in that it has a count of the number + // of child atoms that needs to be incremented after we add the enca atom + MP4Integer32Property* pStsdCountProperty; + FindIntegerProperty(MakeTrackName(trackId, "mdia.minf.stbl.stsd.entryCount"), + (MP4Property**)&pStsdCountProperty); + pStsdCountProperty->IncrementValue(); + + + /* set all the ismacryp-specific values */ + // original format is mp4a + if (use_ismacryp) { + original_fmt = ATOMID("mp4a"); + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.enca.sinf.frma.data-format", + original_fmt); + + (void)AddChildAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd.enca.sinf"), + "schm"); + (void)AddChildAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd.enca.sinf"), + "schi"); + (void)AddChildAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd.enca.sinf.schi"), + "iKMS"); + (void)AddChildAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd.enca.sinf.schi"), + "iSFM"); + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.enca.sinf.schm.scheme_type", + scheme_type); + + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.enca.sinf.schm.scheme_version", + scheme_version); + + SetTrackStringProperty(trackId, + "mdia.minf.stbl.stsd.enca.sinf.schi.iKMS.kms_URI", + kms_uri); +#if 0 + if (kms_uri != NULL) { + free((void *)kms_uri); + } +#endif + + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.enca.sinf.schi.iSFM.selective-encryption", + selective_enc); + + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.enca.sinf.schi.iSFM.key-indicator-length", + key_ind_len); + + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.enca.sinf.schi.iSFM.IV-length", + iv_len); + /* end ismacryp */ + } + + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.enca.timeScale", timeScale); + + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.enca.esds.ESID", +#if 0 + // note - for a file, these values need to + // be 0 - wmay - 04/16/2003 + trackId +#else + 0 +#endif + ); + + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.enca.esds.decConfigDescr.objectTypeId", + audioType); + + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.enca.esds.decConfigDescr.streamType", + MP4AudioStreamType); + + m_pTracks[FindTrackIndex(trackId)]-> + SetFixedSampleDuration(sampleDuration); + + return trackId; +} + +MP4TrackId MP4File::AddCntlTrackDefault (uint32_t timeScale, + MP4Duration sampleDuration, + const char *type) +{ + MP4TrackId trackId = AddTrack(MP4_CNTL_TRACK_TYPE, timeScale); + + (void)InsertChildAtom(MakeTrackName(trackId, "mdia.minf"), "nmhd", 0); + (void)AddChildAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd"), type); + + // stsd is a unique beast in that it has a count of the number + // of child atoms that needs to be incremented after we add the mp4v atom + MP4Integer32Property* pStsdCountProperty; + FindIntegerProperty( + MakeTrackName(trackId, "mdia.minf.stbl.stsd.entryCount"), + (MP4Property**)&pStsdCountProperty); + pStsdCountProperty->IncrementValue(); + + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsz.sampleSize", sampleDuration); + + m_pTracks[FindTrackIndex(trackId)]-> + SetFixedSampleDuration(sampleDuration); + + return trackId; +} + +MP4TrackId MP4File::AddHrefTrack (uint32_t timeScale, + MP4Duration sampleDuration, + const char *base_url) +{ + MP4TrackId trackId = AddCntlTrackDefault(timeScale, sampleDuration, "href"); + + if (base_url != NULL) { + (void)AddChildAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd.href"), + "burl"); + SetTrackStringProperty(trackId, "mdia.minf.stbl.stsd.href.burl.base_url", + base_url); + } + + return trackId; +} + +MP4TrackId MP4File::AddVideoTrackDefault( + uint32_t timeScale, + MP4Duration sampleDuration, + uint16_t width, + uint16_t height, + const char *videoType) +{ + MP4TrackId trackId = AddTrack(MP4_VIDEO_TRACK_TYPE, timeScale); + + AddTrackToOd(trackId); + + SetTrackFloatProperty(trackId, "tkhd.width", width); + SetTrackFloatProperty(trackId, "tkhd.height", height); + + (void)InsertChildAtom(MakeTrackName(trackId, "mdia.minf"), "vmhd", 0); + + (void)AddChildAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd"), videoType); + + // stsd is a unique beast in that it has a count of the number + // of child atoms that needs to be incremented after we add the mp4v atom + MP4Integer32Property* pStsdCountProperty; + FindIntegerProperty( + MakeTrackName(trackId, "mdia.minf.stbl.stsd.entryCount"), + (MP4Property**)&pStsdCountProperty); + pStsdCountProperty->IncrementValue(); + + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsz.sampleSize", sampleDuration); + + m_pTracks[FindTrackIndex(trackId)]-> + SetFixedSampleDuration(sampleDuration); + + return trackId; +} +MP4TrackId MP4File::AddMP4VideoTrack( + uint32_t timeScale, + MP4Duration sampleDuration, + uint16_t width, + uint16_t height, + uint8_t videoType) +{ + MP4TrackId trackId = AddVideoTrackDefault(timeScale, + sampleDuration, + width, + height, + "mp4v"); + + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.mp4v.width", width); + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.mp4v.height", height); + + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.mp4v.esds.ESID", +#if 0 + // note - for a file, these values need to + // be 0 - wmay - 04/16/2003 + trackId +#else + 0 +#endif + ); + + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.mp4v.esds.decConfigDescr.objectTypeId", + videoType); + + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.mp4v.esds.decConfigDescr.streamType", + MP4VisualStreamType); + + return trackId; +} + +// ismacrypted +MP4TrackId MP4File::AddEncVideoTrack(uint32_t timeScale, + MP4Duration sampleDuration, + uint16_t width, + uint16_t height, + uint8_t videoType, + mp4v2_ismacrypParams *icPp, + const char *oFormat + ) +{ + uint32_t original_fmt = 0; + + MP4TrackId trackId = AddVideoTrackDefault(timeScale, + sampleDuration, + width, + height, + "encv"); + + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.encv.width", width); + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.encv.height", height); + + /* set all the ismacryp-specific values */ + + original_fmt = ATOMID(oFormat); + + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.encv.sinf.frma.data-format", + original_fmt); + + (void)AddChildAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd.encv.sinf"), + "schm"); + (void)AddChildAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd.encv.sinf"), + "schi"); + (void)AddChildAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd.encv.sinf.schi"), + "iKMS"); + (void)AddChildAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd.encv.sinf.schi"), + "iSFM"); + + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.encv.sinf.schm.scheme_type", + icPp->scheme_type); + + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.encv.sinf.schm.scheme_version", + icPp->scheme_version); + + SetTrackStringProperty(trackId, + "mdia.minf.stbl.stsd.encv.sinf.schi.iKMS.kms_URI", + icPp->kms_uri); + + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.encv.sinf.schi.iSFM.selective-encryption", + icPp->selective_enc); + + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.encv.sinf.schi.iSFM.key-indicator-length", + icPp->key_ind_len); + + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.encv.sinf.schi.iSFM.IV-length", + icPp->iv_len); + +#if 0 + if (icPp->kms_uri != NULL) { + free(icPp->kms_uri); + } +#endif + + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.encv.esds.ESID", +#if 0 + // note - for a file, these values need to + // be 0 - wmay - 04/16/2003 + trackId +#else + 0 +#endif + ); + + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.encv.esds.decConfigDescr.objectTypeId", + videoType); + + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.encv.esds.decConfigDescr.streamType", + MP4VisualStreamType); + + return trackId; +} + +MP4TrackId MP4File::AddH264VideoTrack( + uint32_t timeScale, + MP4Duration sampleDuration, + uint16_t width, + uint16_t height, + uint8_t AVCProfileIndication, + uint8_t profile_compat, + uint8_t AVCLevelIndication, + uint8_t sampleLenFieldSizeMinusOne) +{ + MP4TrackId trackId = AddVideoTrackDefault(timeScale, + sampleDuration, + width, + height, + "avc1"); + + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.avc1.width", width); + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.avc1.height", height); + + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.avc1.avcC.AVCProfileIndication", + AVCProfileIndication); + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.avc1.avcC.profile_compatibility", + profile_compat); + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.avc1.avcC.AVCLevelIndication", + AVCLevelIndication); + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.avc1.avcC.lengthSizeMinusOne", + sampleLenFieldSizeMinusOne); + + return trackId; +} + +MP4TrackId MP4File::AddEncH264VideoTrack( + uint32_t timeScale, + MP4Duration sampleDuration, + uint16_t width, + uint16_t height, + MP4Atom *srcAtom, + mp4v2_ismacrypParams *icPp) + +{ + + uint32_t original_fmt = 0; + MP4Atom *avcCAtom; + + MP4TrackId trackId = AddVideoTrackDefault(timeScale, + sampleDuration, + width, + height, + "encv"); + + SetTrackIntegerProperty(trackId, "mdia.minf.stbl.stsd.encv.width", width); + SetTrackIntegerProperty(trackId, "mdia.minf.stbl.stsd.encv.height", height); + + (void)AddChildAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd.encv"), "avcC"); + + // create default values + avcCAtom = FindAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd.encv.avcC")); + + // export source atom + ((MP4AvcCAtom *) srcAtom)->Clone((MP4AvcCAtom *)avcCAtom); + + /* set all the ismacryp-specific values */ + + (void)AddChildAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd.encv.sinf"), "schm"); + (void)AddChildAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd.encv.sinf"), "schi"); + (void)AddChildAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd.encv.sinf.schi"), "iKMS"); + (void)AddChildAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd.encv.sinf.schi"), "iSFM"); + + // per ismacrypt E&A V1.1 section 9.1.2.1 'avc1' is renamed '264b' + // avc1 must not appear as a sample entry name or original format name + original_fmt = ATOMID("264b"); + SetTrackIntegerProperty(trackId, "mdia.minf.stbl.stsd.encv.sinf.frma.data-format", + original_fmt); + + SetTrackIntegerProperty(trackId, "mdia.minf.stbl.stsd.encv.sinf.schm.scheme_type", + icPp->scheme_type); + + SetTrackIntegerProperty(trackId, "mdia.minf.stbl.stsd.encv.sinf.schm.scheme_version", + icPp->scheme_version); + + SetTrackStringProperty(trackId, "mdia.minf.stbl.stsd.encv.sinf.schi.iKMS.kms_URI", + icPp->kms_uri); + + SetTrackIntegerProperty(trackId, "mdia.minf.stbl.stsd.encv.sinf.schi.iSFM.selective-encryption", + icPp->selective_enc); + + SetTrackIntegerProperty(trackId, "mdia.minf.stbl.stsd.encv.sinf.schi.iSFM.key-indicator-length", + icPp->key_ind_len); + + SetTrackIntegerProperty(trackId, "mdia.minf.stbl.stsd.encv.sinf.schi.iSFM.IV-length", + icPp->iv_len); + + + return trackId; +} + + +void MP4File::AddH264SequenceParameterSet (MP4TrackId trackId, + const uint8_t *pSequence, + uint16_t sequenceLen) +{ + const char *format; + MP4Atom *avcCAtom; + + // get 4cc media format - can be avc1 or encv for ismacrypted track + format = GetTrackMediaDataName(trackId); + + if (!strcasecmp(format, "avc1")) + avcCAtom = FindAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd.avc1.avcC")); + else if (!strcasecmp(format, "encv")) + avcCAtom = FindAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd.encv.avcC")); + else + // huh? unknown track format + return; + + + MP4BitfieldProperty *pCount; + MP4Integer16Property *pLength; + MP4BytesProperty *pUnit; + if ((avcCAtom->FindProperty("avcC.numOfSequenceParameterSets", + (MP4Property **)&pCount) == false) || + (avcCAtom->FindProperty("avcC.sequenceEntries.sequenceParameterSetLength", + (MP4Property **)&pLength) == false) || + (avcCAtom->FindProperty("avcC.sequenceEntries.sequenceParameterSetNALUnit", + (MP4Property **)&pUnit) == false)) { + VERBOSE_ERROR(m_verbosity, WARNING("Could not find avcC properties")); + return; + } + uint32_t count = pCount->GetValue(); + + if (count > 0) { + // see if we already exist + for (uint32_t index = 0; index < count; index++) { + if (pLength->GetValue(index) == sequenceLen) { + uint8_t *seq; + uint32_t seqlen; + pUnit->GetValue(&seq, &seqlen, index); + if (memcmp(seq, pSequence, sequenceLen) == 0) { + free(seq); + return; + } + free(seq); + } + } + } + pLength->AddValue(sequenceLen); + pUnit->AddValue(pSequence, sequenceLen); + pCount->IncrementValue(); + + return; +} +void MP4File::AddH264PictureParameterSet (MP4TrackId trackId, + const uint8_t *pPict, + uint16_t pictLen) +{ + MP4Atom *avcCAtom = + FindAtom(MakeTrackName(trackId, + "mdia.minf.stbl.stsd.avc1.avcC")); + MP4Integer8Property *pCount; + MP4Integer16Property *pLength; + MP4BytesProperty *pUnit; + if ((avcCAtom->FindProperty("avcC.numOfPictureParameterSets", + (MP4Property **)&pCount) == false) || + (avcCAtom->FindProperty("avcC.pictureEntries.pictureParameterSetLength", + (MP4Property **)&pLength) == false) || + (avcCAtom->FindProperty("avcC.pictureEntries.pictureParameterSetNALUnit", + (MP4Property **)&pUnit) == false)) { + VERBOSE_ERROR(m_verbosity, + WARNING("Could not find avcC picture table properties")); + return; + } + uint32_t count = pCount->GetValue(); + + if (count > 0) { + // see if we already exist + for (uint32_t index = 0; index < count; index++) { + if (pLength->GetValue(index) == pictLen) { + uint8_t *seq; + uint32_t seqlen; + pUnit->GetValue(&seq, &seqlen, index); + if (memcmp(seq, pPict, pictLen) == 0) { + VERBOSE_WRITE(m_verbosity, + fprintf(stderr, "picture matches %d\n", index)); + free(seq); + return; + } + free(seq); + } + } + } + pLength->AddValue(pictLen); + pUnit->AddValue(pPict, pictLen); + pCount->IncrementValue(); + VERBOSE_WRITE(m_verbosity, + fprintf(stderr, "new picture added %d\n", pCount->GetValue())); + + return; +} +void MP4File::SetH263Vendor( + MP4TrackId trackId, + uint32_t vendor) +{ + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.s263.d263.vendor", + vendor); +} + +void MP4File::SetH263DecoderVersion( + MP4TrackId trackId, + uint8_t decoderVersion) +{ + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.s263.d263.decoderVersion", + decoderVersion); +} + +void MP4File::SetH263Bitrates( + MP4TrackId trackId, + uint32_t avgBitrate, + uint32_t maxBitrate) +{ + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.s263.d263.bitr.avgBitrate", + avgBitrate); + + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.s263.d263.bitr.maxBitrate", + maxBitrate); + +} + +MP4TrackId MP4File::AddH263VideoTrack( + uint32_t timeScale, + MP4Duration sampleDuration, + uint16_t width, + uint16_t height, + uint8_t h263Level, + uint8_t h263Profile, + uint32_t avgBitrate, + uint32_t maxBitrate) + +{ + MP4TrackId trackId = AddVideoTrackDefault(timeScale, + sampleDuration, + width, + height, + "s263"); + + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.s263.width", width); + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.s263.height", height); + + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.s263.d263.h263Level", h263Level); + + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.s263.d263.h263Profile", h263Profile); + + // Add the bitr atom + (void)AddChildAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd.s263.d263"), + "bitr"); + + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.s263.d263.bitr.avgBitrate", avgBitrate); + + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.s263.d263.bitr.maxBitrate", maxBitrate); + + + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsz.sampleSize", sampleDuration); + + return trackId; + +} + +MP4TrackId MP4File::AddHintTrack(MP4TrackId refTrackId) +{ + // validate reference track id + (void)FindTrackIndex(refTrackId); + + MP4TrackId trackId = + AddTrack(MP4_HINT_TRACK_TYPE, GetTrackTimeScale(refTrackId)); + + (void)InsertChildAtom(MakeTrackName(trackId, "mdia.minf"), "hmhd", 0); + + (void)AddChildAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd"), "rtp "); + + // stsd is a unique beast in that it has a count of the number + // of child atoms that needs to be incremented after we add the rtp atom + MP4Integer32Property* pStsdCountProperty; + FindIntegerProperty( + MakeTrackName(trackId, "mdia.minf.stbl.stsd.entryCount"), + (MP4Property**)&pStsdCountProperty); + pStsdCountProperty->IncrementValue(); + + SetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.rtp .tims.timeScale", + GetTrackTimeScale(trackId)); + + (void)AddDescendantAtoms(MakeTrackName(trackId, NULL), "tref.hint"); + + AddTrackReference(MakeTrackName(trackId, "tref.hint"), refTrackId); + + (void)AddDescendantAtoms(MakeTrackName(trackId, NULL), "udta.hnti.sdp "); + + (void)AddDescendantAtoms(MakeTrackName(trackId, NULL), "udta.hinf"); + + return trackId; +} + +MP4TrackId MP4File::AddTextTrack(MP4TrackId refTrackId) +{ + // validate reference track id + (void)FindTrackIndex(refTrackId); + + MP4TrackId trackId = + AddTrack(MP4_TEXT_TRACK_TYPE, GetTrackTimeScale(refTrackId)); + + (void)InsertChildAtom(MakeTrackName(trackId, "mdia.minf"), "gmhd", 0); + + (void)AddChildAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd"), "text"); + + // stsd is a unique beast in that it has a count of the number + // of child atoms that needs to be incremented after we add the text atom + MP4Integer32Property* pStsdCountProperty; + FindIntegerProperty( + MakeTrackName(trackId, "mdia.minf.stbl.stsd.entryCount"), + (MP4Property**)&pStsdCountProperty); + pStsdCountProperty->IncrementValue(); + + return trackId; +} + +MP4TrackId MP4File::AddSubtitleTrack(uint32_t timescale, + uint16_t width, + uint16_t height) +{ + MP4TrackId trackId = + AddTrack(MP4_SUBTITLE_TRACK_TYPE, timescale); + + InsertChildAtom(MakeTrackName(trackId, "mdia.minf"), "nmhd", 0); + + AddChildAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd"), "tx3g"); + + SetTrackFloatProperty(trackId, "tkhd.width", width); + SetTrackFloatProperty(trackId, "tkhd.height", height); + + // Hardcoded crap... add the ftab atom and add one font entry + MP4Atom* pFtabAtom = AddChildAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd.tx3g"), "ftab"); + + ((MP4Integer16Property*)pFtabAtom->GetProperty(0))->IncrementValue(); + + MP4Integer16Property* pfontID = (MP4Integer16Property*)((MP4TableProperty*)pFtabAtom->GetProperty(1))->GetProperty(0); + pfontID->AddValue(1); + + MP4StringProperty* pName = (MP4StringProperty*)((MP4TableProperty*)pFtabAtom->GetProperty(1))->GetProperty(1); + pName->AddValue("Arial"); + + SetTrackIntegerProperty(trackId, "mdia.minf.stbl.stsd.tx3g.fontID", 1); + + // stsd is a unique beast in that it has a count of the number + // of child atoms that needs to be incremented after we add the tx3g atom + MP4Integer32Property* pStsdCountProperty; + FindIntegerProperty( + MakeTrackName(trackId, "mdia.minf.stbl.stsd.entryCount"), + (MP4Property**)&pStsdCountProperty); + pStsdCountProperty->IncrementValue(); + + return trackId; +} + +MP4TrackId MP4File::AddChapterTextTrack(MP4TrackId refTrackId, uint32_t timescale) +{ + // validate reference track id + (void)FindTrackIndex(refTrackId); + + if (0 == timescale) + { + timescale = GetTrackTimeScale(refTrackId); + } + + MP4TrackId trackId = AddTrack(MP4_TEXT_TRACK_TYPE, timescale); + + (void)InsertChildAtom(MakeTrackName(trackId, "mdia.minf"), "gmhd", 0); + + (void)AddChildAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd"), "text"); + + // stsd is a unique beast in that it has a count of the number + // of child atoms that needs to be incremented after we add the text atom + MP4Integer32Property* pStsdCountProperty; + FindIntegerProperty( + MakeTrackName(trackId, "mdia.minf.stbl.stsd.entryCount"), + (MP4Property**)&pStsdCountProperty); + pStsdCountProperty->IncrementValue(); + + // add a "text" atom to the generic media header + // this is different to the stsd "text" atom added above + // truth be told, it's not clear what this second "text" atom does, + // but all iTunes Store movies (with chapter markers) have it, + // as do all movies with chapter tracks made by hand in QuickTime Pro + (void)AddChildAtom(MakeTrackName(trackId, "mdia.minf.gmhd"), "text"); + + // disable the chapter text track + // it won't display anyway, as it has zero display size, + // but nonetheless it's good to disable it + // the track still operates as a chapter track when disabled + MP4Atom *pTkhdAtom = FindAtom(MakeTrackName(trackId, "tkhd")); + if (pTkhdAtom) { + pTkhdAtom->SetFlags(0xE); + } + + // add a "chapter" track reference to our reference track, + // pointing to this new chapter track + (void)AddDescendantAtoms(MakeTrackName(refTrackId, NULL), "tref.chap"); + AddTrackReference(MakeTrackName(refTrackId, "tref.chap"), trackId); + + return trackId; +} + +MP4TrackId MP4File::AddPixelAspectRatio(MP4TrackId trackId, uint32_t hSpacing, uint32_t vSpacing) +{ + // validate reference track id + (void)FindTrackIndex(trackId); + const char *format = GetTrackMediaDataName (trackId); + + if (!strcasecmp(format, "avc1")) + { + (void)AddChildAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd.avc1"), "pasp"); + SetTrackIntegerProperty(trackId, "mdia.minf.stbl.stsd.avc1.pasp.hSpacing", hSpacing); + SetTrackIntegerProperty(trackId, "mdia.minf.stbl.stsd.avc1.pasp.vSpacing", vSpacing); + } + else if (!strcasecmp(format, "mp4v")) + { + (void)AddChildAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd.mp4v"), "pasp"); + SetTrackIntegerProperty(trackId, "mdia.minf.stbl.stsd.mp4v.pasp.hSpacing", hSpacing); + SetTrackIntegerProperty(trackId, "mdia.minf.stbl.stsd.mp4v.pasp.vSpacing", vSpacing); + } + + return trackId; +} + +MP4TrackId MP4File::AddColr(MP4TrackId trackId, + uint16_t primariesIndex, + uint16_t transferFunctionIndex, + uint16_t matrixIndex) +{ + // validate reference track id + (void)FindTrackIndex(trackId); + const char *format = GetTrackMediaDataName (trackId); + + if (!strcasecmp(format, "avc1")) + { + AddChildAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd.avc1"), "colr"); + SetTrackIntegerProperty(trackId, "mdia.minf.stbl.stsd.avc1.colr.primariesIndex", primariesIndex); + SetTrackIntegerProperty(trackId, "mdia.minf.stbl.stsd.avc1.colr.transferFunctionIndex", transferFunctionIndex); + SetTrackIntegerProperty(trackId, "mdia.minf.stbl.stsd.avc1.colr.matrixIndex", matrixIndex); + } + else if (!strcasecmp(format, "mp4v")) + { + AddChildAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd.mp4v"), "colr"); + SetTrackIntegerProperty(trackId, "mdia.minf.stbl.stsd.mp4v.colr.primariesIndex", primariesIndex); + SetTrackIntegerProperty(trackId, "mdia.minf.stbl.stsd.mp4v.colr.transferFunctionIndex", transferFunctionIndex); + SetTrackIntegerProperty(trackId, "mdia.minf.stbl.stsd.mp4v.colr.matrixIndex", matrixIndex); + } + + return trackId; +} + + +void MP4File::AddChapter(MP4TrackId chapterTrackId, MP4Duration chapterDuration, const char *chapterTitle) +{ + if (MP4_INVALID_TRACK_ID == chapterTrackId) + { + throw new MP4Error("No chapter track given","AddChapter"); + } + + uint32_t sampleLength = 0; + uint8_t sample[1040] = {0}; + int textLen = 0; + char *text = (char *)&(sample[2]); + + if(chapterTitle != NULL) + { + textLen = min((uint32_t)strlen(chapterTitle), (uint32_t)MP4V2_CHAPTER_TITLE_MAX); + if (0 < textLen) + { + strncpy(text, chapterTitle, textLen); + } + } + else + { + MP4Track * pChapterTrack = GetTrack(chapterTrackId); + snprintf( text, 1023, "Chapter %03d", pChapterTrack->GetNumberOfSamples() + 1 ); + textLen = strlen(text); + } + + sampleLength = textLen + 2 + 12; // Account for text length code and other marker + + // 2-byte length marker + sample[0] = (textLen >> 8) & 0xff; + sample[1] = textLen & 0xff; + + int x = 2 + textLen; + + // Modifier Length Marker + sample[x] = 0x00; + sample[x+1] = 0x00; + sample[x+2] = 0x00; + sample[x+3] = 0x0C; + + // Modifier Type Code + sample[x+4] = 'e'; + sample[x+5] = 'n'; + sample[x+6] = 'c'; + sample[x+7] = 'd'; + + // Modifier Value + sample[x+8] = 0x00; + sample[x+9] = 0x00; + sample[x+10] = (256 >> 8) & 0xff; + sample[x+11] = 256 & 0xff; + + WriteSample(chapterTrackId, sample, sampleLength, chapterDuration); +} + +void MP4File::AddNeroChapter(MP4Timestamp chapterStart, const char * chapterTitle) +{ + MP4Atom * pChpl = FindAtom("moov.udta.chpl"); + if (!pChpl) + { + pChpl = AddDescendantAtoms("", "moov.udta.chpl"); + } + + MP4Integer32Property * pCount = (MP4Integer32Property*)pChpl->GetProperty(3); + pCount->IncrementValue(); + + char buffer[256]; + + if (0 == chapterTitle) + { + snprintf( buffer, 255, "Chapter %03d", pCount->GetValue() ); + } + else + { + int len = min((uint32_t)strlen(chapterTitle), (uint32_t)255); + strncpy( buffer, chapterTitle, len ); + buffer[len] = 0; + } + + MP4TableProperty * pTable; + if (pChpl->FindProperty("chpl.chapters", (MP4Property **)&pTable)) + { + MP4Integer64Property * pStartTime = (MP4Integer64Property *) pTable->GetProperty(0); + MP4StringProperty * pName = (MP4StringProperty *) pTable->GetProperty(1); + if (pStartTime && pTable) + { + pStartTime->AddValue(chapterStart); + pName->AddValue(buffer); + } + } +} + +MP4TrackId MP4File::FindChapterReferenceTrack(MP4TrackId chapterTrackId, char * trackName, int trackNameSize) +{ + for (uint32_t i = 0; i < m_pTracks.Size(); i++) + { + if( MP4_IS_VIDEO_TRACK_TYPE( m_pTracks[i]->GetType() ) || + MP4_IS_AUDIO_TRACK_TYPE( m_pTracks[i]->GetType() ) ) + { + MP4TrackId refTrackId = m_pTracks[i]->GetId(); + char *name = MakeTrackName(refTrackId, "tref.chap"); + if( FindTrackReference( name, chapterTrackId ) ) + { + if( 0 != trackName ) + { + int nameLen = min((uint32_t)strlen(name), (uint32_t)trackNameSize); + strncpy(trackName, name, nameLen); + trackName[nameLen] = 0; + } + + return m_pTracks[i]->GetId(); + } + } + } + + return MP4_INVALID_TRACK_ID; +} + +MP4TrackId MP4File::FindChapterTrack(char * trackName, int trackNameSize) +{ + for (uint32_t i = 0; i < m_pTracks.Size(); i++) + { + if( !strcasecmp(MP4_TEXT_TRACK_TYPE, m_pTracks[i]->GetType()) ) + { + MP4TrackId refTrackId = FindChapterReferenceTrack(m_pTracks[i]->GetId(), trackName, trackNameSize); + if (MP4_INVALID_TRACK_ID != refTrackId) + { + return m_pTracks[i]->GetId(); + } + } + } + + return MP4_INVALID_TRACK_ID; +} + +MP4ChapterType MP4File::DeleteChapters(MP4ChapterType chapterType, MP4TrackId chapterTrackId) +{ + MP4ChapterType deletedType = MP4ChapterTypeNone; + + if (MP4ChapterTypeAny == chapterType || MP4ChapterTypeNero == chapterType) + { + MP4Atom * pChpl = FindAtom("moov.udta.chpl"); + if (pChpl) + { + MP4Atom * pParent = pChpl->GetParentAtom(); + pParent->DeleteChildAtom(pChpl); + deletedType = MP4ChapterTypeNero; + } + } + + if (MP4ChapterTypeAny == chapterType || MP4ChapterTypeQt == chapterType) + { + char trackName[128] = {0}; + + // no text track given, find a suitable + if (MP4_INVALID_TRACK_ID == chapterTrackId) + { + chapterTrackId = FindChapterTrack(trackName, 127); + } + + if (MP4_INVALID_TRACK_ID != chapterTrackId) + { + FindChapterReferenceTrack(chapterTrackId, trackName, 127); + } + + if (MP4_INVALID_TRACK_ID != chapterTrackId && 0 != trackName[0]) + { + // remove the reference + MP4Atom * pChap = FindAtom( trackName ); + if( pChap ) + { + MP4Atom * pTref = pChap->GetParentAtom(); + if( pTref ) + { + pTref->DeleteChildAtom( pChap ); + + MP4Atom* pParent = pTref->GetParentAtom(); + pParent->DeleteChildAtom( pTref ); + } + } + + // remove the chapter track + DeleteTrack(chapterTrackId); + deletedType = MP4ChapterTypeNone == deletedType ? MP4ChapterTypeQt : MP4ChapterTypeAny; + } + } + return deletedType; +} + +MP4ChapterType MP4File::GetChapters(MP4Chapter_t ** chapterList, uint32_t * chapterCount, MP4ChapterType fromChapterType) +{ + *chapterList = 0; + *chapterCount = 0; + + if (MP4ChapterTypeAny == fromChapterType || MP4ChapterTypeQt == fromChapterType) + { + uint8_t * sample = 0; + uint32_t sampleSize = 0; + MP4Timestamp startTime = 0; + MP4Duration duration = 0; + + // get the chapter track + MP4TrackId chapterTrackId = FindChapterTrack(); + if (MP4_INVALID_TRACK_ID == chapterTrackId) + { + if (MP4ChapterTypeQt == fromChapterType) + { + return MP4ChapterTypeNone; + } + } + else + { + // get infos about the chapters + MP4Track * pChapterTrack = GetTrack(chapterTrackId); + uint32_t counter = pChapterTrack->GetNumberOfSamples(); + + if (0 < counter) + { + uint32_t timescale = pChapterTrack->GetTimeScale(); + MP4Chapter_t * chapters = (MP4Chapter_t*)MP4Malloc(sizeof(MP4Chapter_t) * counter); + + // process all chapter sample + for (uint32_t i = 0; i < counter; ++i) + { + // get the sample corresponding to the starttime + MP4SampleId sampleId = pChapterTrack->GetSampleIdFromTime(startTime + duration, true); + pChapterTrack->ReadSample(sampleId, &sample, &sampleSize); + + // get the starttime and duration + pChapterTrack->GetSampleTimes(sampleId, &startTime, &duration); + + // we know that sample+2 contains the title (sample[0] and sample[1] is the length) + const char * title = (const char *)&(sample[2]); + int titleLen = min((uint32_t)((sample[0] << 8) | sample[1]), (uint32_t)MP4V2_CHAPTER_TITLE_MAX); + strncpy(chapters[i].title, title, titleLen); + chapters[i].title[titleLen] = 0; + + // write the duration (in milliseconds) + chapters[i].duration = MP4ConvertTime(duration, timescale, MP4_MILLISECONDS_TIME_SCALE); + + // we're done with this sample + MP4Free(sample); + sample = 0; + } + + *chapterList = chapters; + *chapterCount = counter; + + // we got chapters so we are done + return MP4ChapterTypeQt; + } + } + } + + if (MP4ChapterTypeAny == fromChapterType || MP4ChapterTypeNero == fromChapterType) + { + MP4Atom * pChpl = FindAtom("moov.udta.chpl"); + if (!pChpl) + { + return MP4ChapterTypeNone; + } + + MP4Integer32Property * pCounter = 0; + if (!pChpl->FindProperty("chpl.chaptercount", (MP4Property **)&pCounter)) + { + VERBOSE_WARNING(GetVerbosity(), printf("Nero chapter count does not exist")); + return MP4ChapterTypeNone; + } + + uint32_t counter = pCounter->GetValue(); + if (0 == counter) + { + VERBOSE_WARNING(GetVerbosity(), printf("No Nero chapters available")); + return MP4ChapterTypeNone; + } + + MP4TableProperty * pTable = 0; + MP4Integer64Property * pStartTime = 0; + MP4StringProperty * pName = 0; + MP4Duration chapterDurationSum = 0; + const char * name = 0; + + if (!pChpl->FindProperty("chpl.chapters", (MP4Property **)&pTable)) + { + VERBOSE_WARNING(GetVerbosity(), printf("Nero chapter list does not exist")); + return MP4ChapterTypeNone; + } + + if (0 == (pStartTime = (MP4Integer64Property *) pTable->GetProperty(0))) + { + VERBOSE_WARNING(GetVerbosity(), printf("List of Chapter starttimes does not exist")); + return MP4ChapterTypeNone; + } + if (0 == (pName = (MP4StringProperty *) pTable->GetProperty(1))) + { + VERBOSE_WARNING(GetVerbosity(), printf("List of Chapter titles does not exist")); + return MP4ChapterTypeNone; + } + + MP4Chapter_t * chapters = (MP4Chapter_t*)MP4Malloc(sizeof(MP4Chapter_t) * counter); + + // get the name of the first chapter + name = pName->GetValue(); + + // process remaining chapters + uint32_t i, j; + for (i = 0, j = 1; i < counter; ++i, ++j) + { + // insert the chapter title + uint32_t len = min((uint32_t)strlen(name), (uint32_t)MP4V2_CHAPTER_TITLE_MAX); + strncpy(chapters[i].title, name, len); + chapters[i].title[len] = 0; + + // calculate the duration + MP4Duration duration = 0; + if (j < counter) + { + duration = MP4ConvertTime(pStartTime->GetValue(j), + (MP4_NANOSECONDS_TIME_SCALE / 100), + MP4_MILLISECONDS_TIME_SCALE) - chapterDurationSum; + + // now get the name of the chapter (to be written next) + name = pName->GetValue(j); + } + else + { + // last chapter + duration = MP4ConvertTime(GetDuration(), GetTimeScale(), MP4_MILLISECONDS_TIME_SCALE) - chapterDurationSum; + } + + // sum up the chapter duration + chapterDurationSum += duration; + + // insert the chapter duration + chapters[i].duration = duration; + } + + *chapterList = chapters; + *chapterCount = counter; + + return MP4ChapterTypeNero; + } + + return MP4ChapterTypeNone; +} + +MP4ChapterType MP4File::SetChapters(MP4Chapter_t * chapterList, uint32_t chapterCount, MP4ChapterType toChapterType) +{ + MP4ChapterType setType = MP4ChapterTypeNone; + + // first remove any existing chapters + DeleteChapters(toChapterType, MP4_INVALID_TRACK_ID); + + if( MP4ChapterTypeAny == toChapterType || MP4ChapterTypeNero == toChapterType ) + { + MP4Duration duration = 0; + for( uint32_t i = 0; i < chapterCount; ++i ) + { + AddNeroChapter(duration, chapterList[i].title); + duration += 10 * MP4_MILLISECONDS_TIME_SCALE * chapterList[i].duration; + } + + setType = MP4ChapterTypeNero; + } + + if (MP4ChapterTypeAny == toChapterType || MP4ChapterTypeQt == toChapterType) + { + // find the first video or audio track + MP4TrackId refTrack = MP4_INVALID_TRACK_ID; + for( uint32_t i = 0; i < m_pTracks.Size(); i++ ) + { + if( MP4_IS_VIDEO_TRACK_TYPE( m_pTracks[i]->GetType() ) || + MP4_IS_AUDIO_TRACK_TYPE( m_pTracks[i]->GetType() ) ) + { + refTrack = m_pTracks[i]->GetId(); + break; + } + } + + if( refTrack == MP4_INVALID_TRACK_ID ) + { + return setType; + } + + // create the chapter track + MP4TrackId chapterTrack = AddChapterTextTrack(refTrack, MP4_MILLISECONDS_TIME_SCALE); + + for( uint32_t i = 0 ; i < chapterCount; ++i ) + { + // create and write the chapter track sample + AddChapter( chapterTrack, chapterList[i].duration, chapterList[i].title ); + } + + setType = MP4ChapterTypeNone == setType ? MP4ChapterTypeQt : MP4ChapterTypeAny; + } + + return setType; +} + +MP4ChapterType MP4File::ConvertChapters(MP4ChapterType toChapterType) +{ + MP4ChapterType sourceType = MP4ChapterTypeNone; + const char* errMsg = 0; + + if( MP4ChapterTypeQt == toChapterType ) + { + sourceType = MP4ChapterTypeNero; + errMsg = "Could not find Nero chapter markers"; + } + else if( MP4ChapterTypeNero == toChapterType ) + { + sourceType = MP4ChapterTypeQt; + errMsg = "Could not find QuickTime chapter markers"; + } + else + { + return MP4ChapterTypeNone; + } + + MP4Chapter_t * chapters = 0; + uint32_t chapterCount = 0; + + GetChapters(&chapters, &chapterCount, sourceType); + if (0 == chapterCount) + { + VERBOSE_READ(GetVerbosity(), printf(errMsg)); + return MP4ChapterTypeNone; + } + + SetChapters(chapters, chapterCount, toChapterType); + + MP4Free(chapters); + + return toChapterType; +} + +void MP4File::ChangeMovieTimeScale(uint32_t timescale) +{ + uint32_t origTimeScale = GetTimeScale(); + if (timescale == origTimeScale) { + // already done + return; + } + + MP4Duration movieDuration = GetDuration(); + + // set movie header timescale and duration + SetTimeScale(timescale); + SetDuration(MP4ConvertTime(movieDuration, origTimeScale, timescale)); + + // set track header duration (calculated with movie header timescale) + uint32_t trackCount = GetNumberOfTracks(); + for (uint32_t i = 0; i < trackCount; ++i) + { + MP4Track * track = GetTrack(FindTrackId(i)); + MP4Atom * trackAtom = track->GetTrakAtom(); + MP4IntegerProperty * duration; + + if (trackAtom->FindProperty("trak.tkhd.duration", (MP4Property**)&duration)) + { + duration->SetValue(MP4ConvertTime(duration->GetValue(), origTimeScale, timescale)); + } + } +} + + +void MP4File::DeleteTrack(MP4TrackId trackId) +{ + ProtectWriteOperation("MP4DeleteTrack"); + + uint32_t trakIndex = FindTrakAtomIndex(trackId); + uint16_t trackIndex = FindTrackIndex(trackId); + MP4Track* pTrack = m_pTracks[trackIndex]; + + MP4Atom* pTrakAtom = pTrack->GetTrakAtom(); + ASSERT(pTrakAtom); + + MP4Atom* pMoovAtom = FindAtom("moov"); + ASSERT(pMoovAtom); + + RemoveTrackFromIod(trackId, ShallHaveIods()); + RemoveTrackFromOd(trackId); + + if (trackId == m_odTrackId) { + m_odTrackId = 0; + } + + pMoovAtom->DeleteChildAtom(pTrakAtom); + + m_trakIds.Delete(trakIndex); + + m_pTracks.Delete(trackIndex); + + delete pTrack; + delete pTrakAtom; +} + +uint32_t MP4File::GetNumberOfTracks(const char* type, uint8_t subType) +{ + if (type == NULL) { + return m_pTracks.Size(); + } + + uint32_t typeSeen = 0; + const char* normType = MP4NormalizeTrackType(type, m_verbosity); + + for (uint32_t i = 0; i < m_pTracks.Size(); i++) { + if (!strcmp(normType, m_pTracks[i]->GetType())) { + if (subType) { + if (strcmp(normType, MP4_AUDIO_TRACK_TYPE) == 0) { + if (subType != GetTrackEsdsObjectTypeId(m_pTracks[i]->GetId())) { + continue; + } + } else if (strcmp(normType, MP4_VIDEO_TRACK_TYPE)) { + if (subType != GetTrackEsdsObjectTypeId(m_pTracks[i]->GetId())) { + continue; + } + } + // else unknown subtype, ignore it + } + typeSeen++; + } + } + return typeSeen; +} + +MP4TrackId MP4File::AllocTrackId() +{ + MP4TrackId trackId = + GetIntegerProperty("moov.mvhd.nextTrackId"); + + if (trackId <= 0xFFFF) { + // check that nextTrackid is correct + try { + (void)FindTrackIndex(trackId); + // ERROR, this trackId is in use + } + catch (MP4Error* e) { + // OK, this trackId is not in use, proceed + delete e; + SetIntegerProperty("moov.mvhd.nextTrackId", trackId + 1); + return trackId; + } + } + + // we need to search for a track id + for (trackId = 1; trackId <= 0xFFFF; trackId++) { + try { + (void)FindTrackIndex(trackId); + // KEEP LOOKING, this trackId is in use + } + catch (MP4Error* e) { + // OK, this trackId is not in use, proceed + delete e; + return trackId; + } + } + + // extreme case where mp4 file has 2^16 tracks in it + throw new MP4Error("too many existing tracks", "AddTrack"); + return MP4_INVALID_TRACK_ID; // to keep MSVC happy +} + +MP4TrackId MP4File::FindTrackId(uint16_t trackIndex, + const char* type, uint8_t subType) +{ + if (type == NULL) { + return m_pTracks[trackIndex]->GetId(); + } + + uint32_t typeSeen = 0; + const char* normType = MP4NormalizeTrackType(type, m_verbosity); + + for (uint32_t i = 0; i < m_pTracks.Size(); i++) { + if (!strcmp(normType, m_pTracks[i]->GetType())) { + if (subType) { + if (strcmp(normType, MP4_AUDIO_TRACK_TYPE) == 0) { + if (subType != GetTrackEsdsObjectTypeId(m_pTracks[i]->GetId())) { + continue; + } + } else if (strcmp(normType, MP4_VIDEO_TRACK_TYPE) == 0) { + if (subType != GetTrackEsdsObjectTypeId(m_pTracks[i]->GetId())) { + continue; + } + } + // else unknown subtype, ignore it + } + + if (trackIndex == typeSeen) { + return m_pTracks[i]->GetId(); + } + + typeSeen++; + } + } + + throw new MP4Error("Track index doesn't exist - track %d type %s", + "FindTrackId", + trackIndex, type); + return MP4_INVALID_TRACK_ID; // satisfy MS compiler +} + +uint16_t MP4File::FindTrackIndex(MP4TrackId trackId) +{ + for (uint32_t i = 0; i < m_pTracks.Size() && i <= 0xFFFF; i++) { + if (m_pTracks[i]->GetId() == trackId) { + return (uint16_t)i; + } + } + + throw new MP4Error("Track id %d doesn't exist", "FindTrackIndex", trackId); + return (uint16_t)-1; // satisfy MS compiler +} + +uint16_t MP4File::FindTrakAtomIndex(MP4TrackId trackId) +{ + if (trackId) { + for (uint32_t i = 0; i < m_trakIds.Size(); i++) { + if (m_trakIds[i] == trackId) { + return i; + } + } + } + + throw new MP4Error("Track id %d doesn't exist", "FindTrakAtomIndex", + trackId); + return (uint16_t)-1; // satisfy MS compiler +} + +uint32_t MP4File::GetSampleSize(MP4TrackId trackId, MP4SampleId sampleId) +{ + return m_pTracks[FindTrackIndex(trackId)]->GetSampleSize(sampleId); +} + +uint32_t MP4File::GetTrackMaxSampleSize(MP4TrackId trackId) +{ + return m_pTracks[FindTrackIndex(trackId)]->GetMaxSampleSize(); +} + +MP4SampleId MP4File::GetSampleIdFromTime(MP4TrackId trackId, + MP4Timestamp when, bool wantSyncSample) +{ + return m_pTracks[FindTrackIndex(trackId)]-> + GetSampleIdFromTime(when, wantSyncSample); +} + +MP4Timestamp MP4File::GetSampleTime( + MP4TrackId trackId, MP4SampleId sampleId) +{ + MP4Timestamp timestamp; + m_pTracks[FindTrackIndex(trackId)]-> + GetSampleTimes(sampleId, ×tamp, NULL); + return timestamp; +} + +MP4Duration MP4File::GetSampleDuration( + MP4TrackId trackId, MP4SampleId sampleId) +{ + MP4Duration duration; + m_pTracks[FindTrackIndex(trackId)]-> + GetSampleTimes(sampleId, NULL, &duration); + return duration; +} + +MP4Duration MP4File::GetSampleRenderingOffset( + MP4TrackId trackId, MP4SampleId sampleId) +{ + return m_pTracks[FindTrackIndex(trackId)]-> + GetSampleRenderingOffset(sampleId); +} + +bool MP4File::GetSampleSync(MP4TrackId trackId, MP4SampleId sampleId) +{ + return m_pTracks[FindTrackIndex(trackId)]->IsSyncSample(sampleId); +} + +void MP4File::ReadSample(MP4TrackId trackId, MP4SampleId sampleId, + uint8_t** ppBytes, uint32_t* pNumBytes, + MP4Timestamp* pStartTime, MP4Duration* pDuration, + MP4Duration* pRenderingOffset, bool* pIsSyncSample) +{ + m_pTracks[FindTrackIndex(trackId)]-> + ReadSample(sampleId, ppBytes, pNumBytes, + pStartTime, pDuration, pRenderingOffset, pIsSyncSample); +} + +void MP4File::WriteSample( + MP4TrackId trackId, + const uint8_t* pBytes, + uint32_t numBytes, + MP4Duration duration, + MP4Duration renderingOffset, + bool isSyncSample ) +{ + ProtectWriteOperation( "MP4WriteSample" ); + m_pTracks[FindTrackIndex(trackId)]->WriteSample( + pBytes, numBytes, duration, renderingOffset, isSyncSample ); + m_pModificationProperty->SetValue( MP4GetAbsTimestamp() ); +} + +void MP4File::WriteSampleDependency( + MP4TrackId trackId, + const uint8_t* pBytes, + uint32_t numBytes, + MP4Duration duration, + MP4Duration renderingOffset, + bool isSyncSample, + uint32_t dependencyFlags ) +{ + ProtectWriteOperation( "MP4WriteH264Sample" ); + m_pTracks[FindTrackIndex(trackId)]->WriteSampleDependency( + pBytes, numBytes, duration, renderingOffset, isSyncSample, dependencyFlags ); + m_pModificationProperty->SetValue( MP4GetAbsTimestamp() ); +} + +void MP4File::SetSampleRenderingOffset(MP4TrackId trackId, + MP4SampleId sampleId, MP4Duration renderingOffset) +{ + ProtectWriteOperation("MP4SetSampleRenderingOffset"); + + m_pTracks[FindTrackIndex(trackId)]-> + SetSampleRenderingOffset(sampleId, renderingOffset); + + m_pModificationProperty->SetValue(MP4GetAbsTimestamp()); +} + +void MP4File::MakeFtypAtom( + char* majorBrand, + uint32_t minorVersion, + char** compatibleBrands, + uint32_t compatibleBrandsCount) +{ + MP4FtypAtom* ftyp = (MP4FtypAtom*)m_pRootAtom->FindAtom( "ftyp" ); + if (ftyp == NULL) + ftyp = (MP4FtypAtom*)InsertChildAtom( m_pRootAtom, "ftyp", 0 ); + + // bail if majorbrand is not specified; defaults suffice. + if (majorBrand == NULL) + return; + + ftyp->majorBrand.SetValue( majorBrand ); + ftyp->minorVersion.SetValue( minorVersion ); + + ftyp->compatibleBrands.SetCount( compatibleBrandsCount ); + for( uint32_t i = 0; i < compatibleBrandsCount; i++ ) + ftyp->compatibleBrands.SetValue( compatibleBrands[i] ); +} + +char* MP4File::MakeTrackName(MP4TrackId trackId, const char* name) +{ + uint16_t trakIndex = FindTrakAtomIndex(trackId); + + if (name == NULL || name[0] == '\0') { + snprintf(m_trakName, sizeof(m_trakName), + "moov.trak[%u]", trakIndex); + } else { + snprintf(m_trakName, sizeof(m_trakName), + "moov.trak[%u].%s", trakIndex, name); + } + return m_trakName; +} + +MP4Atom *MP4File::FindTrackAtom (MP4TrackId trackId, const char *name) +{ + return FindAtom(MakeTrackName(trackId, name)); +} + +uint64_t MP4File::GetTrackIntegerProperty(MP4TrackId trackId, const char* name) +{ + return GetIntegerProperty(MakeTrackName(trackId, name)); +} + +void MP4File::SetTrackIntegerProperty(MP4TrackId trackId, const char* name, + int64_t value) +{ + SetIntegerProperty(MakeTrackName(trackId, name), value); +} + +float MP4File::GetTrackFloatProperty(MP4TrackId trackId, const char* name) +{ + return GetFloatProperty(MakeTrackName(trackId, name)); +} + +void MP4File::SetTrackFloatProperty(MP4TrackId trackId, const char* name, + float value) +{ + SetFloatProperty(MakeTrackName(trackId, name), value); +} + +const char* MP4File::GetTrackStringProperty(MP4TrackId trackId, const char* name) +{ + return GetStringProperty(MakeTrackName(trackId, name)); +} + +void MP4File::SetTrackStringProperty(MP4TrackId trackId, const char* name, + const char* value) +{ + SetStringProperty(MakeTrackName(trackId, name), value); +} + +void MP4File::GetTrackBytesProperty(MP4TrackId trackId, const char* name, + uint8_t** ppValue, uint32_t* pValueSize) +{ + GetBytesProperty(MakeTrackName(trackId, name), ppValue, pValueSize); +} + +void MP4File::SetTrackBytesProperty(MP4TrackId trackId, const char* name, + const uint8_t* pValue, uint32_t valueSize) +{ + SetBytesProperty(MakeTrackName(trackId, name), pValue, valueSize); +} + +bool MP4File::GetTrackLanguage( MP4TrackId trackId, char* code ) +{ + ostringstream oss; + oss << "moov.trak[" << FindTrakAtomIndex(trackId) << "].mdia.mdhd.language"; + + MP4Property* prop; + if( !m_pRootAtom->FindProperty( oss.str().c_str(), &prop )) + return false; + + if( prop->GetType() != LanguageCodeProperty ) + return false; + + MP4LanguageCodeProperty& lang = *static_cast<MP4LanguageCodeProperty*>(prop); + string slang; + bmff::enumLanguageCode.toString( lang.GetValue(), slang ); + if( slang.length() != 3 ) { + memset( code, '\0', 4 ); + } + else { + memcpy( code, slang.c_str(), 3 ); + code[3] = '\0'; + } + + return true; +} + +bool MP4File::SetTrackLanguage( MP4TrackId trackId, const char* code ) +{ + ProtectWriteOperation( "SetTrackLanguage" ); + + ostringstream oss; + oss << "moov.trak[" << FindTrakAtomIndex(trackId) << "].mdia.mdhd.language"; + + MP4Property* prop; + if( !m_pRootAtom->FindProperty( oss.str().c_str(), &prop )) + return false; + + if( prop->GetType() != LanguageCodeProperty ) + return false; + + MP4LanguageCodeProperty& lang = *static_cast<MP4LanguageCodeProperty*>(prop); + lang.SetValue( bmff::enumLanguageCode.toType( code )); + + return true; +} + + +bool MP4File::GetTrackName( MP4TrackId trackId, char** name ) +{ + unsigned char *val = NULL; + uint32_t valSize = 0; + MP4Atom *pMetaAtom; + + pMetaAtom = m_pRootAtom->FindAtom(MakeTrackName(trackId,"udta.name")); + + if (pMetaAtom) + { + GetBytesProperty(MakeTrackName(trackId,"udta.name.value"), (uint8_t**)&val, &valSize); + } + if (valSize > 0) + { + *name = (char*)malloc((valSize+1)*sizeof(char)); + if (*name == NULL) { + free(val); + return false; + } + memcpy(*name, val, valSize*sizeof(unsigned char)); + free(val); + (*name)[valSize] = '\0'; + return true; + } + + return false; +} + +bool MP4File::SetTrackName( MP4TrackId trackId, const char* name ) +{ + ProtectWriteOperation( "SetTrackName" ); + char atomstring[40]; + MP4Atom *pMetaAtom; + MP4BytesProperty *pMetadataProperty = NULL; + snprintf(atomstring, 40, "%s", MakeTrackName(trackId,"udta.name")); + + pMetaAtom = m_pRootAtom->FindAtom(atomstring); + + if (!pMetaAtom) + { + if (!AddDescendantAtoms(MakeTrackName(trackId, NULL), "udta.name")) + return false; + + pMetaAtom = m_pRootAtom->FindAtom(atomstring); + if (pMetaAtom == NULL) return false; + } + + ASSERT(pMetaAtom->FindProperty("name.value", + (MP4Property**)&pMetadataProperty)); + ASSERT(pMetadataProperty); + + pMetadataProperty->SetValue((uint8_t*)name, strlen(name)); + + return true; +} + +// file level convenience functions + +MP4Duration MP4File::GetDuration() +{ + return m_pDurationProperty->GetValue(); +} + +void MP4File::SetDuration(MP4Duration value) +{ + m_pDurationProperty->SetValue(value); +} + +uint32_t MP4File::GetTimeScale() +{ + return m_pTimeScaleProperty->GetValue(); +} + +void MP4File::SetTimeScale(uint32_t value) +{ + if (value == 0) { + throw new MP4Error("invalid value", "SetTimeScale"); + } + m_pTimeScaleProperty->SetValue(value); +} + +uint8_t MP4File::GetODProfileLevel() +{ + return GetIntegerProperty("moov.iods.ODProfileLevelId"); +} + +void MP4File::SetODProfileLevel(uint8_t value) +{ + SetIntegerProperty("moov.iods.ODProfileLevelId", value); +} + +uint8_t MP4File::GetSceneProfileLevel() +{ + return GetIntegerProperty("moov.iods.sceneProfileLevelId"); +} + +void MP4File::SetSceneProfileLevel(uint8_t value) +{ + SetIntegerProperty("moov.iods.sceneProfileLevelId", value); +} + +uint8_t MP4File::GetVideoProfileLevel() +{ + return GetIntegerProperty("moov.iods.visualProfileLevelId"); +} + +void MP4File::SetVideoProfileLevel(uint8_t value) +{ + SetIntegerProperty("moov.iods.visualProfileLevelId", value); +} + +uint8_t MP4File::GetAudioProfileLevel() +{ + return GetIntegerProperty("moov.iods.audioProfileLevelId"); +} + +void MP4File::SetAudioProfileLevel(uint8_t value) +{ + SetIntegerProperty("moov.iods.audioProfileLevelId", value); +} + +uint8_t MP4File::GetGraphicsProfileLevel() +{ + return GetIntegerProperty("moov.iods.graphicsProfileLevelId"); +} + +void MP4File::SetGraphicsProfileLevel(uint8_t value) +{ + SetIntegerProperty("moov.iods.graphicsProfileLevelId", value); +} + +const char* MP4File::GetSessionSdp() +{ + return GetStringProperty("moov.udta.hnti.rtp .sdpText"); +} + +void MP4File::SetSessionSdp(const char* sdpString) +{ + (void)AddDescendantAtoms("moov", "udta.hnti.rtp "); + + SetStringProperty("moov.udta.hnti.rtp .sdpText", sdpString); +} + +void MP4File::AppendSessionSdp(const char* sdpFragment) +{ + const char* oldSdpString = NULL; + try { + oldSdpString = GetSessionSdp(); + } + catch (MP4Error* e) { + delete e; + SetSessionSdp(sdpFragment); + return; + } + + char* newSdpString = + (char*)MP4Malloc(strlen(oldSdpString) + strlen(sdpFragment) + 1); + strcpy(newSdpString, oldSdpString); + strcat(newSdpString, sdpFragment); + SetSessionSdp(newSdpString); + MP4Free(newSdpString); +} + +// +// ismacrypt API - retrieve OriginalFormatBox +// +// parameters are assumed to have been sanity tested in mp4.cpp +// don't call this unless media data name is 'encv', +// results may otherwise be unpredictable. +// +// input: +// trackID - valid encv track ID for this file +// buflen - length of oFormat, minimum is 5 (4cc plus null terminator) +// +// output: +// oFormat - buffer to return null terminated string containing +// track original format +// return: +// 0 - original format returned OK +// 1 - buffer length error or problem retrieving track property +// +// +bool MP4File::GetTrackMediaDataOriginalFormat(MP4TrackId trackId, + char *originalFormat, uint32_t buflen) +{ + uint32_t format; + + if (buflen < 5) + return false; + + format = GetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.*.sinf.frma.data-format"); + + IDATOM(format, originalFormat); + return true; + +} + + +// track level convenience functions + +MP4SampleId MP4File::GetTrackNumberOfSamples(MP4TrackId trackId) +{ + return m_pTracks[FindTrackIndex(trackId)]->GetNumberOfSamples(); +} + +const char* MP4File::GetTrackType(MP4TrackId trackId) +{ + return m_pTracks[FindTrackIndex(trackId)]->GetType(); +} + +const char *MP4File::GetTrackMediaDataName (MP4TrackId trackId) +{ + MP4Atom *pChild; + MP4Atom *pAtom = + FindAtom(MakeTrackName(trackId, + "mdia.minf.stbl.stsd")); + if (pAtom->GetNumberOfChildAtoms() != 1) { + VERBOSE_ERROR(m_verbosity, + fprintf(stderr, "track %d has more than 1 child atoms in stsd\n", trackId)); + return NULL; + } + pChild = pAtom->GetChildAtom(0); + return pChild->GetType(); +} + + +uint32_t MP4File::GetTrackTimeScale(MP4TrackId trackId) +{ + return m_pTracks[FindTrackIndex(trackId)]->GetTimeScale(); +} + +void MP4File::SetTrackTimeScale(MP4TrackId trackId, uint32_t value) +{ + if (value == 0) { + throw new MP4Error("invalid value", "SetTrackTimeScale"); + } + SetTrackIntegerProperty(trackId, "mdia.mdhd.timeScale", value); +} + +MP4Duration MP4File::GetTrackDuration(MP4TrackId trackId) +{ + return GetTrackIntegerProperty(trackId, "mdia.mdhd.duration"); +} + +uint8_t MP4File::GetTrackEsdsObjectTypeId(MP4TrackId trackId) +{ + // changed mp4a to * to handle enca case + try { + return GetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.*.esds.decConfigDescr.objectTypeId"); + } catch (MP4Error *e) { + delete e; + return GetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.*.*.esds.decConfigDescr.objectTypeId"); + } +} + +uint8_t MP4File::GetTrackAudioMpeg4Type(MP4TrackId trackId) +{ + // verify that track is an MPEG-4 audio track + if (GetTrackEsdsObjectTypeId(trackId) != MP4_MPEG4_AUDIO_TYPE) { + return MP4_MPEG4_INVALID_AUDIO_TYPE; + } + + uint8_t* pEsConfig = NULL; + uint32_t esConfigSize; + + // The Mpeg4 audio type (AAC, CELP, HXVC, ...) + // is the first 5 bits of the ES configuration + + GetTrackESConfiguration(trackId, &pEsConfig, &esConfigSize); + + if (esConfigSize < 1) { + free(pEsConfig); + return MP4_MPEG4_INVALID_AUDIO_TYPE; + } + + uint8_t mpeg4Type = ((pEsConfig[0] >> 3) & 0x1f); + // TTTT TXXX XXX potentially 6 bits of extension. + if (mpeg4Type == 0x1f) { + if (esConfigSize < 2) { + free(pEsConfig); + return MP4_MPEG4_INVALID_AUDIO_TYPE; + } + mpeg4Type = 32 + + (((pEsConfig[0] & 0x7) << 3) | ((pEsConfig[1] >> 5) & 0x7)); + } + + free(pEsConfig); + + return mpeg4Type; +} + + +MP4Duration MP4File::GetTrackFixedSampleDuration(MP4TrackId trackId) +{ + return m_pTracks[FindTrackIndex(trackId)]->GetFixedSampleDuration(); +} + +double MP4File::GetTrackVideoFrameRate(MP4TrackId trackId) +{ + MP4SampleId numSamples = + GetTrackNumberOfSamples(trackId); + uint64_t + msDuration = + ConvertFromTrackDuration(trackId, + GetTrackDuration(trackId), MP4_MSECS_TIME_SCALE); + + if (msDuration == 0) { + return 0.0; + } + + return ((double)numSamples / double(msDuration)) * MP4_MSECS_TIME_SCALE; +} + +int MP4File::GetTrackAudioChannels (MP4TrackId trackId) +{ + return GetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.*[0].channels"); +} + +// true if media track encrypted according to ismacryp +bool MP4File::IsIsmaCrypMediaTrack(MP4TrackId trackId) +{ + if (GetTrackIntegerProperty(trackId, + "mdia.minf.stbl.stsd.*.sinf.frma.data-format") + != (uint64_t)-1) { + return true; + } + return false; +} + +bool MP4File::IsWriteMode() +{ + if( !m_file ) + return false; + + switch( m_file->mode ) { + case File::MODE_READ: + return false; + + case File::MODE_MODIFY: + case File::MODE_CREATE: + default: + break; + } + + return true; +} + +void MP4File::GetTrackESConfiguration(MP4TrackId trackId, + uint8_t** ppConfig, uint32_t* pConfigSize) +{ + try { + GetTrackBytesProperty(trackId, + "mdia.minf.stbl.stsd.*[0].esds.decConfigDescr.decSpecificInfo[0].info", + ppConfig, pConfigSize); + } catch (MP4Error *e) { + delete e; + GetTrackBytesProperty(trackId, + "mdia.minf.stbl.stsd.*[0].*.esds.decConfigDescr.decSpecificInfo[0].info", + ppConfig, pConfigSize); + } +} + +void MP4File::GetTrackVideoMetadata(MP4TrackId trackId, + uint8_t** ppConfig, uint32_t* pConfigSize) +{ + GetTrackBytesProperty(trackId, + "mdia.minf.stbl.stsd.*[0].*.metadata", + ppConfig, pConfigSize); +} + +void MP4File::SetTrackESConfiguration(MP4TrackId trackId, + const uint8_t* pConfig, uint32_t configSize) +{ + // get a handle on the track decoder config descriptor + MP4DescriptorProperty* pConfigDescrProperty = NULL; + if (FindProperty(MakeTrackName(trackId, + "mdia.minf.stbl.stsd.*[0].esds.decConfigDescr.decSpecificInfo"), + (MP4Property**)&pConfigDescrProperty) == false || + pConfigDescrProperty == NULL) { + // probably trackId refers to a hint track + throw new MP4Error("no such property", "MP4SetTrackESConfiguration"); + } + + // lookup the property to store the configuration + MP4BytesProperty* pInfoProperty = NULL; + (void)pConfigDescrProperty->FindProperty("decSpecificInfo[0].info", + (MP4Property**)&pInfoProperty); + + // configuration being set for the first time + if (pInfoProperty == NULL) { + // need to create a new descriptor to hold it + MP4Descriptor* pConfigDescr = + pConfigDescrProperty->AddDescriptor(MP4DecSpecificDescrTag); + pConfigDescr->Generate(); + + (void)pConfigDescrProperty->FindProperty( + "decSpecificInfo[0].info", + (MP4Property**)&pInfoProperty); + ASSERT(pInfoProperty); + } + + // set the value + pInfoProperty->SetValue(pConfig, configSize); +} + + +void MP4File::GetTrackH264SeqPictHeaders (MP4TrackId trackId, + uint8_t ***pppSeqHeader, + uint32_t **ppSeqHeaderSize, + uint8_t ***pppPictHeader, + uint32_t **ppPictHeaderSize) +{ + uint32_t count; + const char *format; + MP4Atom *avcCAtom; + + *pppSeqHeader = NULL; + *pppPictHeader = NULL; + *ppSeqHeaderSize = NULL; + *ppPictHeaderSize = NULL; + + // get 4cc media format - can be avc1 or encv for ismacrypted track + format = GetTrackMediaDataName (trackId); + + if (!strcasecmp(format, "avc1")) + avcCAtom = FindAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd.avc1.avcC")); + else if (!strcasecmp(format, "encv")) + avcCAtom = FindAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd.encv.avcC")); + else + // huh? unknown track format + return; + + MP4BitfieldProperty *pSeqCount; + MP4IntegerProperty *pSeqLen, *pPictCount, *pPictLen; + MP4BytesProperty *pSeqVal, *pPictVal; + + if ((avcCAtom->FindProperty("avcC.numOfSequenceParameterSets", + (MP4Property **)&pSeqCount) == false) || + (avcCAtom->FindProperty("avcC.sequenceEntries.sequenceParameterSetLength", + (MP4Property **)&pSeqLen) == false) || + (avcCAtom->FindProperty("avcC.sequenceEntries.sequenceParameterSetNALUnit", + (MP4Property **)&pSeqVal) == false)) { + VERBOSE_ERROR(m_verbosity, WARNING("Could not find avcC properties")); + return ; + } + uint8_t **ppSeqHeader = + (uint8_t **)malloc((pSeqCount->GetValue() + 1) * sizeof(uint8_t *)); + if (ppSeqHeader == NULL) return; + *pppSeqHeader = ppSeqHeader; + + uint32_t *pSeqHeaderSize = + (uint32_t *)malloc((pSeqCount->GetValue() + 1) * sizeof(uint32_t *)); + + if (pSeqHeaderSize == NULL) return; + + *ppSeqHeaderSize = pSeqHeaderSize; + for (count = 0; count < pSeqCount->GetValue(); count++) { + pSeqVal->GetValue(&(ppSeqHeader[count]), &(pSeqHeaderSize[count]), + count); + } + ppSeqHeader[count] = NULL; + pSeqHeaderSize[count] = 0; + + if ((avcCAtom->FindProperty("avcC.numOfPictureParameterSets", + (MP4Property **)&pPictCount) == false) || + (avcCAtom->FindProperty("avcC.pictureEntries.pictureParameterSetLength", + (MP4Property **)&pPictLen) == false) || + (avcCAtom->FindProperty("avcC.pictureEntries.pictureParameterSetNALUnit", + (MP4Property **)&pPictVal) == false)) { + VERBOSE_ERROR(m_verbosity, + WARNING("Could not find avcC picture table properties")); + return ; + } + uint8_t + **ppPictHeader = + (uint8_t **)malloc((pPictCount->GetValue() + 1) * sizeof(uint8_t *)); + if (ppPictHeader == NULL) return; + uint32_t *pPictHeaderSize = + (uint32_t *)malloc((pPictCount->GetValue() + 1)* sizeof(uint32_t *)); + if (pPictHeaderSize == NULL) { + free(ppPictHeader); + return; + } + *pppPictHeader = ppPictHeader; + *ppPictHeaderSize = pPictHeaderSize; + + for (count = 0; count < pPictCount->GetValue(); count++) { + pPictVal->GetValue(&(ppPictHeader[count]), &(pPictHeaderSize[count]), + count); + } + ppPictHeader[count] = NULL; + pPictHeaderSize[count] = 0; + return ; +} + + + +const char* MP4File::GetHintTrackSdp(MP4TrackId hintTrackId) +{ + return GetTrackStringProperty(hintTrackId, "udta.hnti.sdp .sdpText"); +} + +void MP4File::SetHintTrackSdp(MP4TrackId hintTrackId, const char* sdpString) +{ + MP4Track* pTrack = m_pTracks[FindTrackIndex(hintTrackId)]; + + if (strcmp(pTrack->GetType(), MP4_HINT_TRACK_TYPE)) { + throw new MP4Error("track is not a hint track", + "MP4SetHintTrackSdp"); + } + + (void)AddDescendantAtoms( + MakeTrackName(hintTrackId, NULL), "udta.hnti.sdp "); + + SetTrackStringProperty(hintTrackId, "udta.hnti.sdp .sdpText", sdpString); +} + +void MP4File::AppendHintTrackSdp(MP4TrackId hintTrackId, + const char* sdpFragment) +{ + const char* oldSdpString = NULL; + try { + oldSdpString = GetHintTrackSdp(hintTrackId); + } + catch (MP4Error* e) { + delete e; + SetHintTrackSdp(hintTrackId, sdpFragment); + return; + } + + char* newSdpString = + (char*)MP4Malloc(strlen(oldSdpString) + strlen(sdpFragment) + 1); + strcpy(newSdpString, oldSdpString); + strcat(newSdpString, sdpFragment); + SetHintTrackSdp(hintTrackId, newSdpString); + MP4Free(newSdpString); +} + +void MP4File::GetHintTrackRtpPayload( + MP4TrackId hintTrackId, + char** ppPayloadName, + uint8_t* pPayloadNumber, + uint16_t* pMaxPayloadSize, + char **ppEncodingParams) +{ + MP4Track* pTrack = m_pTracks[FindTrackIndex(hintTrackId)]; + + if (strcmp(pTrack->GetType(), MP4_HINT_TRACK_TYPE)) { + throw new MP4Error("track is not a hint track", + "MP4GetHintTrackRtpPayload"); + } + + ((MP4RtpHintTrack*)pTrack)->GetPayload( + ppPayloadName, pPayloadNumber, pMaxPayloadSize, ppEncodingParams); +} + +void MP4File::SetHintTrackRtpPayload(MP4TrackId hintTrackId, + const char* payloadName, uint8_t* pPayloadNumber, uint16_t maxPayloadSize, + const char *encoding_params, + bool include_rtp_map, + bool include_mpeg4_esid) +{ + MP4Track* pTrack = m_pTracks[FindTrackIndex(hintTrackId)]; + + if (strcmp(pTrack->GetType(), MP4_HINT_TRACK_TYPE)) { + throw new MP4Error("track is not a hint track", + "MP4SetHintTrackRtpPayload"); + } + + uint8_t payloadNumber; + if (pPayloadNumber && *pPayloadNumber != MP4_SET_DYNAMIC_PAYLOAD) { + payloadNumber = *pPayloadNumber; + } else { + payloadNumber = AllocRtpPayloadNumber(); + if (pPayloadNumber) { + *pPayloadNumber = payloadNumber; + } + } + + ((MP4RtpHintTrack*)pTrack)->SetPayload( + payloadName, payloadNumber, maxPayloadSize, encoding_params, + include_rtp_map, include_mpeg4_esid); +} + +uint8_t MP4File::AllocRtpPayloadNumber() +{ + MP4Integer32Array usedPayloads; + uint32_t i; + + // collect rtp payload numbers in use by existing tracks + for (i = 0; i < m_pTracks.Size(); i++) { + MP4Atom* pTrakAtom = m_pTracks[i]->GetTrakAtom(); + + MP4Integer32Property* pPayloadProperty = NULL; + if (pTrakAtom->FindProperty("trak.udta.hinf.payt.payloadNumber", + (MP4Property**)&pPayloadProperty) && + pPayloadProperty) { + usedPayloads.Add(pPayloadProperty->GetValue()); + } + } + + // search dynamic payload range for an available slot + uint8_t payload; + for (payload = 96; payload < 128; payload++) { + for (i = 0; i < usedPayloads.Size(); i++) { + if (payload == usedPayloads[i]) { + break; + } + } + if (i == usedPayloads.Size()) { + break; + } + } + + if (payload >= 128) { + throw new MP4Error("no more available rtp payload numbers", + "AllocRtpPayloadNumber"); + } + + return payload; +} + +MP4TrackId MP4File::GetHintTrackReferenceTrackId( + MP4TrackId hintTrackId) +{ + MP4Track* pTrack = m_pTracks[FindTrackIndex(hintTrackId)]; + + if (strcmp(pTrack->GetType(), MP4_HINT_TRACK_TYPE)) { + throw new MP4Error("track is not a hint track", + "MP4GetHintTrackReferenceTrackId"); + } + + MP4Track* pRefTrack = ((MP4RtpHintTrack*)pTrack)->GetRefTrack(); + + if (pRefTrack == NULL) { + return MP4_INVALID_TRACK_ID; + } + return pRefTrack->GetId(); +} + +void MP4File::ReadRtpHint( + MP4TrackId hintTrackId, + MP4SampleId hintSampleId, + uint16_t* pNumPackets) +{ + MP4Track* pTrack = m_pTracks[FindTrackIndex(hintTrackId)]; + + if (strcmp(pTrack->GetType(), MP4_HINT_TRACK_TYPE)) { + throw new MP4Error("track is not a hint track", "MP4ReadRtpHint"); + } + ((MP4RtpHintTrack*)pTrack)-> + ReadHint(hintSampleId, pNumPackets); +} + +uint16_t MP4File::GetRtpHintNumberOfPackets( + MP4TrackId hintTrackId) +{ + MP4Track* pTrack = m_pTracks[FindTrackIndex(hintTrackId)]; + + if (strcmp(pTrack->GetType(), MP4_HINT_TRACK_TYPE)) { + throw new MP4Error("track is not a hint track", + "MP4GetRtpHintNumberOfPackets"); + } + return ((MP4RtpHintTrack*)pTrack)->GetHintNumberOfPackets(); +} + +int8_t MP4File::GetRtpPacketBFrame( + MP4TrackId hintTrackId, + uint16_t packetIndex) +{ + MP4Track* pTrack = m_pTracks[FindTrackIndex(hintTrackId)]; + + if (strcmp(pTrack->GetType(), MP4_HINT_TRACK_TYPE)) { + throw new MP4Error("track is not a hint track", + "MP4GetRtpHintBFrame"); + } + return ((MP4RtpHintTrack*)pTrack)->GetPacketBFrame(packetIndex); +} + +int32_t MP4File::GetRtpPacketTransmitOffset( + MP4TrackId hintTrackId, + uint16_t packetIndex) +{ + MP4Track* pTrack = m_pTracks[FindTrackIndex(hintTrackId)]; + + if (strcmp(pTrack->GetType(), MP4_HINT_TRACK_TYPE)) { + throw new MP4Error("track is not a hint track", + "MP4GetRtpPacketTransmitOffset"); + } + return ((MP4RtpHintTrack*)pTrack)->GetPacketTransmitOffset(packetIndex); +} + +void MP4File::ReadRtpPacket( + MP4TrackId hintTrackId, + uint16_t packetIndex, + uint8_t** ppBytes, + uint32_t* pNumBytes, + uint32_t ssrc, + bool includeHeader, + bool includePayload) +{ + MP4Track* pTrack = m_pTracks[FindTrackIndex(hintTrackId)]; + + if (strcmp(pTrack->GetType(), MP4_HINT_TRACK_TYPE)) { + throw new MP4Error("track is not a hint track", "MP4ReadPacket"); + } + ((MP4RtpHintTrack*)pTrack)->ReadPacket( + packetIndex, ppBytes, pNumBytes, + ssrc, includeHeader, includePayload); +} + +MP4Timestamp MP4File::GetRtpTimestampStart( + MP4TrackId hintTrackId) +{ + MP4Track* pTrack = m_pTracks[FindTrackIndex(hintTrackId)]; + + if (strcmp(pTrack->GetType(), MP4_HINT_TRACK_TYPE)) { + throw new MP4Error("track is not a hint track", + "MP4GetRtpTimestampStart"); + } + return ((MP4RtpHintTrack*)pTrack)->GetRtpTimestampStart(); +} + +void MP4File::SetRtpTimestampStart( + MP4TrackId hintTrackId, + MP4Timestamp rtpStart) +{ + MP4Track* pTrack = m_pTracks[FindTrackIndex(hintTrackId)]; + + if (strcmp(pTrack->GetType(), MP4_HINT_TRACK_TYPE)) { + throw new MP4Error("track is not a hint track", + "MP4SetRtpTimestampStart"); + } + ((MP4RtpHintTrack*)pTrack)->SetRtpTimestampStart(rtpStart); +} + +void MP4File::AddRtpHint(MP4TrackId hintTrackId, + bool isBframe, uint32_t timestampOffset) +{ + ProtectWriteOperation("MP4AddRtpHint"); + + MP4Track* pTrack = m_pTracks[FindTrackIndex(hintTrackId)]; + + if (strcmp(pTrack->GetType(), MP4_HINT_TRACK_TYPE)) { + throw new MP4Error("track is not a hint track", "MP4AddRtpHint"); + } + ((MP4RtpHintTrack*)pTrack)->AddHint(isBframe, timestampOffset); +} + +void MP4File::AddRtpPacket( + MP4TrackId hintTrackId, bool setMbit, int32_t transmitOffset) +{ + ProtectWriteOperation("MP4AddRtpPacket"); + + MP4Track* pTrack = m_pTracks[FindTrackIndex(hintTrackId)]; + + if (strcmp(pTrack->GetType(), MP4_HINT_TRACK_TYPE)) { + throw new MP4Error("track is not a hint track", "MP4AddRtpPacket"); + } + ((MP4RtpHintTrack*)pTrack)->AddPacket(setMbit, transmitOffset); +} + +void MP4File::AddRtpImmediateData(MP4TrackId hintTrackId, + const uint8_t* pBytes, uint32_t numBytes) +{ + ProtectWriteOperation("MP4AddRtpImmediateData"); + + MP4Track* pTrack = m_pTracks[FindTrackIndex(hintTrackId)]; + + if (strcmp(pTrack->GetType(), MP4_HINT_TRACK_TYPE)) { + throw new MP4Error("track is not a hint track", + "MP4AddRtpImmediateData"); + } + ((MP4RtpHintTrack*)pTrack)->AddImmediateData(pBytes, numBytes); +} + +void MP4File::AddRtpSampleData(MP4TrackId hintTrackId, + MP4SampleId sampleId, uint32_t dataOffset, uint32_t dataLength) +{ + ProtectWriteOperation("MP4AddRtpSampleData"); + + MP4Track* pTrack = m_pTracks[FindTrackIndex(hintTrackId)]; + + if (strcmp(pTrack->GetType(), MP4_HINT_TRACK_TYPE)) { + throw new MP4Error("track is not a hint track", + "MP4AddRtpSampleData"); + } + ((MP4RtpHintTrack*)pTrack)->AddSampleData( + sampleId, dataOffset, dataLength); +} + +void MP4File::AddRtpESConfigurationPacket(MP4TrackId hintTrackId) +{ + ProtectWriteOperation("MP4AddRtpESConfigurationPacket"); + + MP4Track* pTrack = m_pTracks[FindTrackIndex(hintTrackId)]; + + if (strcmp(pTrack->GetType(), MP4_HINT_TRACK_TYPE)) { + throw new MP4Error("track is not a hint track", + "MP4AddRtpESConfigurationPacket"); + } + ((MP4RtpHintTrack*)pTrack)->AddESConfigurationPacket(); +} + +void MP4File::WriteRtpHint(MP4TrackId hintTrackId, + MP4Duration duration, bool isSyncSample) +{ + ProtectWriteOperation("MP4WriteRtpHint"); + + MP4Track* pTrack = m_pTracks[FindTrackIndex(hintTrackId)]; + + if (strcmp(pTrack->GetType(), MP4_HINT_TRACK_TYPE)) { + throw new MP4Error("track is not a hint track", + "MP4WriteRtpHint"); + } + ((MP4RtpHintTrack*)pTrack)->WriteHint(duration, isSyncSample); +} + +uint64_t MP4File::ConvertFromMovieDuration( + MP4Duration duration, + uint32_t timeScale) +{ + return MP4ConvertTime((uint64_t)duration, + GetTimeScale(), timeScale); +} + +uint64_t MP4File::ConvertFromTrackTimestamp( + MP4TrackId trackId, + MP4Timestamp timeStamp, + uint32_t timeScale) +{ + return MP4ConvertTime(timeStamp, + GetTrackTimeScale(trackId), timeScale); +} + +MP4Timestamp MP4File::ConvertToTrackTimestamp( + MP4TrackId trackId, + uint64_t timeStamp, + uint32_t timeScale) +{ + return (MP4Timestamp)MP4ConvertTime(timeStamp, + timeScale, GetTrackTimeScale(trackId)); +} + +uint64_t MP4File::ConvertFromTrackDuration( + MP4TrackId trackId, + MP4Duration duration, + uint32_t timeScale) +{ + return MP4ConvertTime((uint64_t)duration, + GetTrackTimeScale(trackId), timeScale); +} + +MP4Duration MP4File::ConvertToTrackDuration( + MP4TrackId trackId, + uint64_t duration, + uint32_t timeScale) +{ + return (MP4Duration)MP4ConvertTime(duration, + timeScale, GetTrackTimeScale(trackId)); +} + +uint8_t MP4File::ConvertTrackTypeToStreamType(const char* trackType) +{ + uint8_t streamType; + + if (!strcmp(trackType, MP4_OD_TRACK_TYPE)) { + streamType = MP4ObjectDescriptionStreamType; + } else if (!strcmp(trackType, MP4_SCENE_TRACK_TYPE)) { + streamType = MP4SceneDescriptionStreamType; + } else if (!strcmp(trackType, MP4_CLOCK_TRACK_TYPE)) { + streamType = MP4ClockReferenceStreamType; + } else if (!strcmp(trackType, MP4_MPEG7_TRACK_TYPE)) { + streamType = MP4Mpeg7StreamType; + } else if (!strcmp(trackType, MP4_OCI_TRACK_TYPE)) { + streamType = MP4OCIStreamType; + } else if (!strcmp(trackType, MP4_IPMP_TRACK_TYPE)) { + streamType = MP4IPMPStreamType; + } else if (!strcmp(trackType, MP4_MPEGJ_TRACK_TYPE)) { + streamType = MP4MPEGJStreamType; + } else { + streamType = MP4UserPrivateStreamType; + } + + return streamType; +} + +// edit list + +char* MP4File::MakeTrackEditName( + MP4TrackId trackId, + MP4EditId editId, + const char* name) +{ + char* trakName = MakeTrackName(trackId, NULL); + + if (m_editName == NULL) { + m_editName = (char *)malloc(1024); + if (m_editName == NULL) return NULL; + } + snprintf(m_editName, 1024, + "%s.edts.elst.entries[%u].%s", + trakName, editId - 1, name); + return m_editName; +} + +MP4EditId MP4File::AddTrackEdit( + MP4TrackId trackId, + MP4EditId editId) +{ + ProtectWriteOperation("AddTrackEdit"); + return m_pTracks[FindTrackIndex(trackId)]->AddEdit(editId); +} + +void MP4File::DeleteTrackEdit( + MP4TrackId trackId, + MP4EditId editId) +{ + ProtectWriteOperation("DeleteTrackEdit"); + m_pTracks[FindTrackIndex(trackId)]->DeleteEdit(editId); +} + +uint32_t MP4File::GetTrackNumberOfEdits( + MP4TrackId trackId) +{ + return GetTrackIntegerProperty(trackId, "edts.elst.entryCount"); +} + +MP4Duration MP4File::GetTrackEditTotalDuration( + MP4TrackId trackId, + MP4EditId editId) +{ + return m_pTracks[FindTrackIndex(trackId)]->GetEditTotalDuration(editId); +} + +MP4Timestamp MP4File::GetTrackEditStart( + MP4TrackId trackId, + MP4EditId editId) +{ + return m_pTracks[FindTrackIndex(trackId)]->GetEditStart(editId); +} + +MP4Timestamp MP4File::GetTrackEditMediaStart( + MP4TrackId trackId, + MP4EditId editId) +{ + return GetIntegerProperty( + MakeTrackEditName(trackId, editId, "mediaTime")); +} + +void MP4File::SetTrackEditMediaStart( + MP4TrackId trackId, + MP4EditId editId, + MP4Timestamp startTime) +{ + SetIntegerProperty( + MakeTrackEditName(trackId, editId, "mediaTime"), + startTime); +} + +MP4Duration MP4File::GetTrackEditDuration( + MP4TrackId trackId, + MP4EditId editId) +{ + return GetIntegerProperty( + MakeTrackEditName(trackId, editId, "segmentDuration")); +} + +void MP4File::SetTrackEditDuration( + MP4TrackId trackId, + MP4EditId editId, + MP4Duration duration) +{ + SetIntegerProperty( + MakeTrackEditName(trackId, editId, "segmentDuration"), + duration); +} + +bool MP4File::GetTrackEditDwell( + MP4TrackId trackId, + MP4EditId editId) +{ + return (GetIntegerProperty( + MakeTrackEditName(trackId, editId, "mediaRate")) == 0); +} + +void MP4File::SetTrackEditDwell( + MP4TrackId trackId, + MP4EditId editId, + bool dwell) +{ + SetIntegerProperty( + MakeTrackEditName(trackId, editId, "mediaRate"), + (dwell ? 0 : 1)); +} + +MP4SampleId MP4File::GetSampleIdFromEditTime( + MP4TrackId trackId, + MP4Timestamp when, + MP4Timestamp* pStartTime, + MP4Duration* pDuration) +{ + return m_pTracks[FindTrackIndex(trackId)]->GetSampleIdFromEditTime( + when, pStartTime, pDuration); +} + +MP4Duration MP4File::GetTrackDurationPerChunk( MP4TrackId trackId ) +{ + return m_pTracks[FindTrackIndex(trackId)]->GetDurationPerChunk(); +} + +void MP4File::SetTrackDurationPerChunk( MP4TrackId trackId, MP4Duration duration ) +{ + m_pTracks[FindTrackIndex(trackId)]->SetDurationPerChunk( duration ); +} + +/////////////////////////////////////////////////////////////////////////////// + +}} // namespace mp4v2::impl diff --git a/src/mp4file.h b/src/mp4file.h new file mode 100644 index 0000000..45a60a6 --- /dev/null +++ b/src/mp4file.h @@ -0,0 +1,1018 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is MPEG4IP. +// +// The Initial Developer of the Original Code is Cisco Systems Inc. +// Portions created by Cisco Systems Inc. are +// Copyright (C) Cisco Systems Inc. 2001 - 2005. All Rights Reserved. +// +// 3GPP features implementation is based on 3GPP's TS26.234-v5.60, +// and was contributed by Ximpo Group Ltd. +// +// Portions created by Ximpo Group Ltd. are +// Copyright (C) Ximpo Group Ltd. 2003, 2004. All Rights Reserved. +// +// Contributors: +// Dave Mackie, dmackie@cisco.com +// Alix Marchandise-Franquet, alix@cisco.com +// Ximpo Group Ltd., mp4v2@ximpo.com +// Kona Blend, kona8lend@@gmail.com +// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef MP4V2_IMPL_MP4FILE_H +#define MP4V2_IMPL_MP4FILE_H + +namespace mp4v2 { namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +class MP4Atom; +class MP4Property; +class MP4Float32Property; +class MP4StringProperty; +class MP4BytesProperty; +class MP4Descriptor; +class MP4DescriptorProperty; + +class MP4File +{ +public: + MP4File( uint32_t verbosity = 0 ); + ~MP4File(); + + /////////////////////////////////////////////////////////////////////////// + // file ops + /////////////////////////////////////////////////////////////////////////// + + void Create( const char* fileName, + uint32_t flags, + int add_ftyp = 1, + int add_iods = 1, + char* majorBrand = NULL, + uint32_t minorVersion = 0, + char** supportedBrands = NULL, + uint32_t supportedBrandsCount = 0 ); + + void Read( const char* name, const MP4FileProvider* provider ); + bool Modify( const char* fileName ); + void Optimize( const char* srcFileName, const char* dstFileName = NULL ); + bool CopyClose( const string& copyFileName ); + void Dump( FILE* fout = NULL, bool dumpImplicits = false ); + void Close(); + + /* library property per file */ + + uint32_t GetVerbosity() { + return m_verbosity; + } + void SetVerbosity(uint32_t verbosity) { + m_verbosity = verbosity; + } + + bool Use64Bits(const char *atomName); + void Check64BitStatus(const char *atomName); + /* file properties */ + + uint64_t GetIntegerProperty(const char* name); + float GetFloatProperty(const char* name); + const char* GetStringProperty(const char* name); + void GetBytesProperty(const char* name, + uint8_t** ppValue, uint32_t* pValueSize); + + void SetIntegerProperty(const char* name, uint64_t value); + void SetFloatProperty(const char* name, float value); + void SetStringProperty(const char* name, const char* value); + void SetBytesProperty(const char* name, + const uint8_t* pValue, uint32_t valueSize); + + // file level convenience functions + + MP4Duration GetDuration(); + void SetDuration(MP4Duration value); + + uint32_t GetTimeScale(); + void SetTimeScale(uint32_t value); + + uint8_t GetODProfileLevel(); + void SetODProfileLevel(uint8_t value); + + uint8_t GetSceneProfileLevel(); + void SetSceneProfileLevel(uint8_t value); + + uint8_t GetVideoProfileLevel(); + void SetVideoProfileLevel(uint8_t value); + + uint8_t GetAudioProfileLevel(); + void SetAudioProfileLevel(uint8_t value); + + uint8_t GetGraphicsProfileLevel(); + void SetGraphicsProfileLevel(uint8_t value); + + const char* GetSessionSdp(); + void SetSessionSdp(const char* sdpString); + void AppendSessionSdp(const char* sdpString); + + /* track operations */ + + MP4TrackId AddTrack(const char* type, uint32_t timeScale = 1000); + void DeleteTrack(MP4TrackId trackId); + + uint32_t GetNumberOfTracks(const char* type = NULL, uint8_t subType = 0); + + MP4TrackId AllocTrackId(); + MP4TrackId FindTrackId(uint16_t trackIndex, + const char* type = NULL, uint8_t subType = 0); + uint16_t FindTrackIndex(MP4TrackId trackId); + uint16_t FindTrakAtomIndex(MP4TrackId trackId); + + /* track properties */ + MP4Atom *FindTrackAtom(MP4TrackId trackId, const char *name); + uint64_t GetTrackIntegerProperty( + MP4TrackId trackId, const char* name); + float GetTrackFloatProperty( + MP4TrackId trackId, const char* name); + const char* GetTrackStringProperty( + MP4TrackId trackId, const char* name); + void GetTrackBytesProperty( + MP4TrackId trackId, const char* name, + uint8_t** ppValue, uint32_t* pValueSize); + + void SetTrackIntegerProperty( + MP4TrackId trackId, const char* name, int64_t value); + void SetTrackFloatProperty( + MP4TrackId trackId, const char* name, float value); + void SetTrackStringProperty( + MP4TrackId trackId, const char* name, const char* value); + void SetTrackBytesProperty( + MP4TrackId trackId, const char* name, + const uint8_t* pValue, uint32_t valueSize); + + bool GetTrackLanguage( MP4TrackId, char* ); + bool SetTrackLanguage( MP4TrackId, const char* ); + bool GetTrackName( MP4TrackId trackId, char** name ); + bool SetTrackName( MP4TrackId trackId, const char* name); + + /* sample operations */ + + uint32_t GetSampleSize(MP4TrackId trackId, MP4SampleId sampleId); + + uint32_t GetTrackMaxSampleSize(MP4TrackId trackId); + + MP4SampleId GetSampleIdFromTime(MP4TrackId trackId, + MP4Timestamp when, bool wantSyncSample = false); + + MP4Timestamp GetSampleTime( + MP4TrackId trackId, MP4SampleId sampleId); + + MP4Duration GetSampleDuration( + MP4TrackId trackId, MP4SampleId sampleId); + + MP4Duration GetSampleRenderingOffset( + MP4TrackId trackId, MP4SampleId sampleId); + + bool GetSampleSync( + MP4TrackId trackId, MP4SampleId sampleId); + + void ReadSample( + // input parameters + MP4TrackId trackId, + MP4SampleId sampleId, + // output parameters + uint8_t** ppBytes, + uint32_t* pNumBytes, + MP4Timestamp* pStartTime = NULL, + MP4Duration* pDuration = NULL, + MP4Duration* pRenderingOffset = NULL, + bool* pIsSyncSample = NULL); + + void WriteSample( + MP4TrackId trackId, + const uint8_t* pBytes, + uint32_t numBytes, + MP4Duration duration = 0, + MP4Duration renderingOffset = 0, + bool isSyncSample = true ); + + void WriteSampleDependency( + MP4TrackId trackId, + const uint8_t* pBytes, + uint32_t numBytes, + MP4Duration duration, + MP4Duration renderingOffset, + bool isSyncSample, + uint32_t dependencyFlags ); + + void SetSampleRenderingOffset( + MP4TrackId trackId, + MP4SampleId sampleId, + MP4Duration renderingOffset); + + MP4Duration GetTrackDurationPerChunk( MP4TrackId ); + void SetTrackDurationPerChunk( MP4TrackId, MP4Duration ); + + /* track level convenience functions */ + + MP4TrackId AddSystemsTrack(const char* type); + + MP4TrackId AddODTrack(); + + MP4TrackId AddSceneTrack(); + + MP4TrackId AddAudioTrack( + uint32_t timeScale, + MP4Duration sampleDuration, + uint8_t audioType); + + MP4TrackId AddAC3AudioTrack( + uint32_t samplingRate, + uint8_t fscod, + uint8_t bsid, + uint8_t bsmod, + uint8_t acmod, + uint8_t lfeon, + uint8_t bit_rate_code); + + MP4TrackId AddEncAudioTrack( // ismacryp + uint32_t timeScale, + MP4Duration sampleDuration, + uint8_t audioType, + uint32_t scheme_type, + uint16_t scheme_version, + uint8_t key_ind_len, + uint8_t iv_len, + bool selective_enc, + const char *kms_uri, + bool use_ismacryp); + + void SetAmrVendor( + MP4TrackId trackId, + uint32_t vendor); + + void SetAmrDecoderVersion( + MP4TrackId trackId, + uint8_t decoderVersion); + + void SetAmrModeSet( + MP4TrackId trackId, + uint16_t modeSet); + uint16_t GetAmrModeSet(MP4TrackId trackId); + + MP4TrackId AddAmrAudioTrack( + uint32_t timeScale, + uint16_t modeSet, + uint8_t modeChangePeriod, + uint8_t framesPerSample, + bool isAmrWB); + + MP4TrackId AddHrefTrack(uint32_t timeScale, + MP4Duration sampleDuration, + const char *base_url); + + MP4TrackId AddMP4VideoTrack( + uint32_t timeScale, + MP4Duration sampleDuration, + uint16_t width, + uint16_t height, + uint8_t videoType); + + MP4TrackId AddEncVideoTrack( // ismacryp + uint32_t timeScale, + MP4Duration sampleDuration, + uint16_t width, + uint16_t height, + uint8_t videoType, + mp4v2_ismacrypParams *icPp, + const char *oFormat); + + void SetH263Vendor( + MP4TrackId trackId, + uint32_t vendor); + + void SetH263DecoderVersion( + MP4TrackId trackId, + uint8_t decoderVersion); + + void SetH263Bitrates( + MP4TrackId, + uint32_t avgBitrate, + uint32_t maxBitrate); + + MP4TrackId AddH263VideoTrack( + uint32_t timeScale, + MP4Duration sampleDuration, + uint16_t width, + uint16_t height, + uint8_t h263Level, + uint8_t h263Profile, + uint32_t avgBitrate, + uint32_t maxBitrate); + + MP4TrackId AddH264VideoTrack( + uint32_t timeScale, + MP4Duration sampleDuration, + uint16_t width, + uint16_t height, + uint8_t AVCProfileIndication, + uint8_t profile_compat, + uint8_t AVCLevelIndication, + uint8_t sampleLenFieldSizeMinusOne); + + MP4TrackId AddEncH264VideoTrack( + uint32_t timeScale, + MP4Duration sampleDuration, + uint16_t width, + uint16_t height, + MP4Atom *srcAtom, + mp4v2_ismacrypParams *icPp); + + void AddH264SequenceParameterSet(MP4TrackId trackId, + const uint8_t *pSequence, + uint16_t sequenceLen); + void AddH264PictureParameterSet(MP4TrackId trackId, + const uint8_t *pPicture, + uint16_t pictureLen); + MP4TrackId AddHintTrack(MP4TrackId refTrackId); + + MP4TrackId AddTextTrack(MP4TrackId refTrackId); + + /** Add a QuickTime chapter track. + * + * This function adds a chapter (text) track. + * The optional parameter <b>timescale</b> may be supplied to give the new + * chapter a specific timescale. Otherwise the chapter track will have + * the same timescale as the reference track defined in parameter refTrackId. + * + * @param refTrackId ID of the track that will reference the chapter track. + * @param timescale the timescale of the chapter track or 0 to use the + * timescale of track specified by <b>refTrackId</b>. + * + * @return ID of the created chapter track. + */ + MP4TrackId AddChapterTextTrack( + MP4TrackId refTrackId, + uint32_t timescale = 0 ); + + MP4TrackId AddSubtitleTrack(uint32_t timescale, + uint16_t width, + uint16_t height); + + MP4TrackId AddPixelAspectRatio(MP4TrackId trackId, uint32_t hSpacing, uint32_t vSpacing); + MP4TrackId AddColr(MP4TrackId trackId, uint16_t pri, uint16_t tran, uint16_t mat); + + /** Add a QuickTime chapter. + * + * @param chapterTrackId ID of chapter track or #MP4_INVALID_TRACK_ID + * if unknown. + * @param chapterDuration duration (in the timescale of the chapter track). + * @param chapterTitle title text for the chapter or NULL to use default + * title format ("Chapter %03d", n) where n is the chapter number. + */ + void AddChapter( + MP4TrackId chapterTrackId, + MP4Duration chapterDuration, + const char* chapterTitle = 0 ); + + /** Add a Nero chapter. + * + * @param chapterStart the start time of the chapter in 100 nanosecond units + * @param chapterTitle title text for the chapter or NULL to use default + * title format ("Chapter %03d", n) where n is the chapter number. + */ + void AddNeroChapter( + MP4Timestamp chapterStart, + const char* chapterTitle = 0 ); + + /*! Returns the ID of the track referencing the chapter track chapterTrackId. + * This function searches for a track of type MP4_AUDIO_TRACK_TYPE that references + * the track chapterTrackId through the atom "tref.chap". + * + * @param chapterTrackId the ID of the chapter track + * @param trackName receives the name of the referencing track if not null + * @param trackNameSize the size of the memory pointed to by trackName + * @return the ID if the track referencing the chapter track or MP4_INVALID_TRACK_ID + */ + MP4TrackId FindChapterReferenceTrack(MP4TrackId chapterTrackId, + char *trackName = 0, + int trackNameSize = 0); + + /*! Find the QuickTime chapter track in the current file. + * This function searches for a track of type text. + * + * @param trackName receives the name of the chapter track if not null + * @param trackNameSize the size of the memory pointed to by trackName + * @return the ID of the chapter track or MP4_INVALID_TRACK_ID + */ + MP4TrackId FindChapterTrack(char *trackName = 0, int trackNameSize = 0); + + /** Delete chapters. + * + * @param chapterType the type of chapters to delete: + * @li #MP4ChapterTypeAny (delete all known chapter types) + * @li #MP4ChapterTypeQt + * @li #MP4ChapterTypeNero + * @param chapterTrackId ID of the chapter track if known, + * or #MP4_INVALID_TRACK_ID. + * Only applies when <b>chapterType</b>=#MP4ChapterTypeQt. + * + * @return the type of deleted chapters + */ + MP4ChapterType DeleteChapters( + MP4ChapterType chapterType = MP4ChapterTypeQt, + MP4TrackId chapterTrackId = 0 ); + + /** Get list of chapters. + * + * @param chapterList address receiving array of chapter items. + * If a non-NULL is received the caller is responsible for freeing the + * memory with MP4Free(). + * @param chapterCount address receiving count of items in array. + * @param chapterType the type of chapters to read: + * @li #MP4ChapterTypeAny (any chapters, searched in order of Qt, Nero) + * @li #MP4ChapterTypeQt + * @li #MP4ChapterTypeNero + * + * @result the first type of chapters found. + */ + + MP4ChapterType GetChapters( + MP4Chapter_t** chapterList, + uint32_t* chapterCount, + MP4ChapterType fromChapterType = MP4ChapterTypeQt ); + + /** Set list of chapters. + * + * This functions sets the complete chapter list. + * If any chapters of the same type already exist they will first + * be deleted. + * + * @param chapterList array of chapters items. + * @param chapterCount count of items in array. + * @param chapterType type of chapters to write: + * @li #MP4ChapterTypeAny (chapters of all types are written) + * @li #MP4ChapterTypeQt + * @li #MP4ChapterTypeNero + * + * @return the type of chapters written. + */ + MP4ChapterType SetChapters( + MP4Chapter_t* chapterList, + uint32_t chapterCount, + MP4ChapterType toChapterType = MP4ChapterTypeQt ); + + /** Convert chapters to another type. + * + * This function converts existing chapters + * from one type to another type. + * Conversion from Nero to QuickTime or QuickTime to Nero is supported. + * + * @param toChapterType the chapter type to convert to: + * @li #MP4ChapterTypeQt (convert from Nero to Qt) + * @li #MP4ChapterTypeNero (convert from Qt to Nero) + * + * @return the chapter type before conversion or #MP4ChapterTypeNone + * if the source chapters do not exist + * or invalid <b>toChapterType</b> was specified. + */ + MP4ChapterType ConvertChapters(MP4ChapterType toChapterType = MP4ChapterTypeQt); + + /** Change the general timescale. + * + * This function changes the general timescale to the new timescale + * <b>value</b> by recalculating all values that depend on the timescale + * in "moov.mvhd". + * + * If the timescale is already equal to value nothing is done. + * + * @param value the new timescale. + */ + void ChangeMovieTimeScale(uint32_t timescale); + + MP4SampleId GetTrackNumberOfSamples(MP4TrackId trackId); + + const char* GetTrackType(MP4TrackId trackId); + + const char *GetTrackMediaDataName(MP4TrackId trackId); + bool GetTrackMediaDataOriginalFormat(MP4TrackId trackId, + char *originalFormat, uint32_t buflen); + MP4Duration GetTrackDuration(MP4TrackId trackId); + + uint32_t GetTrackTimeScale(MP4TrackId trackId); + void SetTrackTimeScale(MP4TrackId trackId, uint32_t value); + + // replacement to GetTrackAudioType and GetTrackVideoType + uint8_t GetTrackEsdsObjectTypeId(MP4TrackId trackId); + + uint8_t GetTrackAudioMpeg4Type(MP4TrackId trackId); + + MP4Duration GetTrackFixedSampleDuration(MP4TrackId trackId); + + double GetTrackVideoFrameRate(MP4TrackId trackId); + + int GetTrackAudioChannels(MP4TrackId trackId); + void GetTrackESConfiguration(MP4TrackId trackId, + uint8_t** ppConfig, uint32_t* pConfigSize); + void SetTrackESConfiguration(MP4TrackId trackId, + const uint8_t* pConfig, uint32_t configSize); + + void GetTrackVideoMetadata(MP4TrackId trackId, + uint8_t** ppConfig, uint32_t* pConfigSize); + void GetTrackH264SeqPictHeaders(MP4TrackId trackId, + uint8_t ***pSeqHeader, + uint32_t **pSeqHeaderSize, + uint8_t ***pPictHeader, + uint32_t **pPictHeaderSize); + const char* GetHintTrackSdp(MP4TrackId hintTrackId); + void SetHintTrackSdp(MP4TrackId hintTrackId, const char* sdpString); + void AppendHintTrackSdp(MP4TrackId hintTrackId, const char* sdpString); + + void MakeFtypAtom( + char* majorBrand, + uint32_t minorVersion, + char** compatibleBrands, + uint32_t compatibleBrandsCount ); + + // 3GPP specific functions + void Make3GPCompliant(const char* fileName, + char* majorBrand, + uint32_t minorVersion, + char** supportedBrands, + uint32_t supportedBrandsCount, + bool deleteIodsAtom); + + // ISMA specific functions + + // true if media track encrypted according to ismacryp + bool IsIsmaCrypMediaTrack(MP4TrackId trackId); + + void MakeIsmaCompliant(bool addIsmaComplianceSdp = true); + + void CreateIsmaIodFromParams( + uint8_t videoProfile, + uint32_t videoBitrate, + uint8_t* videoConfig, + uint32_t videoConfigLength, + uint8_t audioProfile, + uint32_t audioBitrate, + uint8_t* audioConfig, + uint32_t audioConfigLength, + uint8_t** ppBytes, + uint64_t* pNumBytes); + + // time convenience functions + + uint64_t ConvertFromMovieDuration( + MP4Duration duration, + uint32_t timeScale); + + uint64_t ConvertFromTrackTimestamp( + MP4TrackId trackId, + MP4Timestamp timeStamp, + uint32_t timeScale); + + MP4Timestamp ConvertToTrackTimestamp( + MP4TrackId trackId, + uint64_t timeStamp, + uint32_t timeScale); + + uint64_t ConvertFromTrackDuration( + MP4TrackId trackId, + MP4Duration duration, + uint32_t timeScale); + + MP4Duration ConvertToTrackDuration( + MP4TrackId trackId, + uint64_t duration, + uint32_t timeScale); + + // specialized operations + + void GetHintTrackRtpPayload( + MP4TrackId hintTrackId, + char** ppPayloadName = NULL, + uint8_t* pPayloadNumber = NULL, + uint16_t* pMaxPayloadSize = NULL, + char **ppEncodingParams = NULL); + + void SetHintTrackRtpPayload( + MP4TrackId hintTrackId, + const char* payloadName, + uint8_t* pPayloadNumber, + uint16_t maxPayloadSize, + const char *encoding_params, + bool include_rtp_map, + bool include_mpeg4_esid); + + MP4TrackId GetHintTrackReferenceTrackId( + MP4TrackId hintTrackId); + + void ReadRtpHint( + MP4TrackId hintTrackId, + MP4SampleId hintSampleId, + uint16_t* pNumPackets = NULL); + + uint16_t GetRtpHintNumberOfPackets( + MP4TrackId hintTrackId); + + int8_t GetRtpPacketBFrame( + MP4TrackId hintTrackId, + uint16_t packetIndex); + + int32_t GetRtpPacketTransmitOffset( + MP4TrackId hintTrackId, + uint16_t packetIndex); + + void ReadRtpPacket( + MP4TrackId hintTrackId, + uint16_t packetIndex, + uint8_t** ppBytes, + uint32_t* pNumBytes, + uint32_t ssrc = 0, + bool includeHeader = true, + bool includePayload = true); + + MP4Timestamp GetRtpTimestampStart( + MP4TrackId hintTrackId); + + void SetRtpTimestampStart( + MP4TrackId hintTrackId, + MP4Timestamp rtpStart); + + void AddRtpHint( + MP4TrackId hintTrackId, + bool isBframe, + uint32_t timestampOffset); + + void AddRtpPacket( + MP4TrackId hintTrackId, + bool setMbit, + int32_t transmitOffset); + + void AddRtpImmediateData( + MP4TrackId hintTrackId, + const uint8_t* pBytes, + uint32_t numBytes); + + void AddRtpSampleData( + MP4TrackId hintTrackId, + MP4SampleId sampleId, + uint32_t dataOffset, + uint32_t dataLength); + + void AddRtpESConfigurationPacket( + MP4TrackId hintTrackId); + + void WriteRtpHint( + MP4TrackId hintTrackId, + MP4Duration duration, + bool isSyncSample); + + uint8_t AllocRtpPayloadNumber(); + + // edit list related + + char* MakeTrackEditName( + MP4TrackId trackId, + MP4EditId editId, + const char* name); + + MP4EditId AddTrackEdit( + MP4TrackId trackId, + MP4EditId editId = MP4_INVALID_EDIT_ID); + + void DeleteTrackEdit( + MP4TrackId trackId, + MP4EditId editId); + + uint32_t GetTrackNumberOfEdits( + MP4TrackId trackId); + + MP4Timestamp GetTrackEditStart( + MP4TrackId trackId, + MP4EditId editId); + + MP4Duration GetTrackEditTotalDuration( + MP4TrackId trackId, + MP4EditId editId); + + MP4Timestamp GetTrackEditMediaStart( + MP4TrackId trackId, + MP4EditId editId); + + void SetTrackEditMediaStart( + MP4TrackId trackId, + MP4EditId editId, + MP4Timestamp startTime); + + MP4Duration GetTrackEditDuration( + MP4TrackId trackId, + MP4EditId editId); + + void SetTrackEditDuration( + MP4TrackId trackId, + MP4EditId editId, + MP4Duration duration); + + bool GetTrackEditDwell( + MP4TrackId trackId, + MP4EditId editId); + + void SetTrackEditDwell( + MP4TrackId trackId, + MP4EditId editId, + bool dwell); + + MP4SampleId GetSampleIdFromEditTime( + MP4TrackId trackId, + MP4Timestamp when, + MP4Timestamp* pStartTime = NULL, + MP4Duration* pDuration = NULL); + + /* iTunes metadata handling */ +protected: + bool CreateMetadataAtom(const char* name, itmf::BasicType typeCode); +public: + // these are public to remove a lot of unnecessary routines + bool DeleteMetadataAtom(const char* name, bool try_udta = false); + bool GetMetadataString(const char *atom, char **value, bool try_udta = false); + bool SetMetadataString(const char *atom, const char *value); + bool MetadataDelete(void); + + bool SetMetadataUint8(const char *atom, uint8_t value); + bool GetMetadataUint8(const char *atom, uint8_t* retvalue); + + bool SetMetadataUint16(const char *atom, uint16_t value); + bool GetMetadataUint16(const char *atom, uint16_t* retvalue); + + bool SetMetadataUint32(const char *atom, uint32_t value); + bool GetMetadataUint32(const char *atom, uint32_t* retvalue); + + /* set metadata */ + bool SetMetadataTrack(uint16_t track, uint16_t totalTracks); + bool SetMetadataDisk(uint16_t disk, uint16_t totalDisks); + bool SetMetadataGenre(const char *value); + bool SetMetadataCoverArt(uint8_t *coverArt, uint32_t size); + bool SetMetadataFreeForm(const char *name, + const uint8_t* pValue, + uint32_t valueSize, + const char *owner = NULL); + + /* get metadata */ + bool GetMetadataByIndex(uint32_t index, + char** ppName, // free memory when done + uint8_t** ppValue, // free memory when done + uint32_t* pValueSize); + bool GetMetadataTrack(uint16_t* track, uint16_t* totalTracks); + bool GetMetadataDisk(uint16_t* disk, uint16_t* totalDisks); + bool GetMetadataGenre(char **value); + + bool GetMetadataCoverArt(uint8_t **coverArt, uint32_t* size, + uint32_t index = 0); + uint32_t GetMetadataCoverArtCount(void); + bool GetMetadataFreeForm(const char *name, + uint8_t** pValue, + uint32_t* valueSize, + const char *owner = NULL); + bool GetMetadataCoverArtPosition(uint32_t *start, uint32_t* size, + uint32_t index); + /* delete metadata */ + bool DeleteMetadataGenre(); + bool DeleteMetadataFreeForm(const char *name, const char *owner = NULL); + + /* end of MP4 API */ + + /* "protected" interface to be used only by friends in library */ + + uint64_t GetPosition( File* file = NULL ); + void SetPosition( uint64_t pos, File* file = NULL ); + uint64_t GetSize( File* file = NULL ); + + void ReadBytes( uint8_t* buf, uint32_t bufsiz, File* file = NULL ); + void PeekBytes( uint8_t* buf, uint32_t bufsiz, File* file = NULL ); + + uint64_t ReadUInt(uint8_t size); + uint8_t ReadUInt8(); + uint16_t ReadUInt16(); + uint32_t ReadUInt24(); + uint32_t ReadUInt32(); + uint64_t ReadUInt64(); + float ReadFixed16(); + float ReadFixed32(); + float ReadFloat(); + char* ReadString(); + char* ReadCountedString( + uint8_t charSize = 1, bool allowExpandedCount = false, uint8_t fixedLength = 0); + uint64_t ReadBits(uint8_t numBits); + void FlushReadBits(); + uint32_t ReadMpegLength(); + + + void WriteBytes( uint8_t* buf, uint32_t bufsiz, File* file = NULL ); + void WriteUInt8(uint8_t value); + void WriteUInt16(uint16_t value); + void WriteUInt24(uint32_t value); + void WriteUInt32(uint32_t value); + void WriteUInt64(uint64_t value); + void WriteFixed16(float value); + void WriteFixed32(float value); + void WriteFloat(float value); + void WriteString(char* string); + void WriteCountedString(char* string, + uint8_t charSize = 1, + bool allowExpandedCount = false, + uint32_t fixedLength = 0); + void WriteBits(uint64_t bits, uint8_t numBits); + void PadWriteBits(uint8_t pad = 0); + void FlushWriteBits(); + void WriteMpegLength(uint32_t value, bool compact = false); + + void EnableMemoryBuffer( + uint8_t* pBytes = NULL, uint64_t numBytes = 0); + void DisableMemoryBuffer( + uint8_t** ppBytes = NULL, uint64_t* pNumBytes = NULL); + + bool IsWriteMode(); + + MP4Track* GetTrack(MP4TrackId trackId); + + void UpdateDuration(MP4Duration duration); + + MP4Atom* FindAtom(const char* name); + + MP4Atom* AddChildAtom( + const char* parentName, + const char* childName); + + MP4Atom* AddChildAtom( + MP4Atom* pParentAtom, + const char* childName); + + MP4Atom* InsertChildAtom( + const char* parentName, + const char* childName, + uint32_t index); + + MP4Atom* InsertChildAtom( + MP4Atom* pParentAtom, + const char* childName, + uint32_t index); + + MP4Atom* AddDescendantAtoms( + const char* ancestorName, + const char* childName); + + MP4Atom* AddDescendantAtoms( + MP4Atom* pAncestorAtom, + const char* childName); + +protected: + void Open( const char* name, File::Mode mode, const MP4FileProvider* provider ); + void ReadFromFile(); + void GenerateTracks(); + void BeginWrite(); + void FinishWrite(); + void CacheProperties(); + void RewriteMdat( File& src, File& dst ); + bool ShallHaveIods(); + + void Rename(const char* existingFileName, const char* newFileName); + + void ProtectWriteOperation(const char* where); + + void FindIntegerProperty(const char* name, + MP4Property** ppProperty, uint32_t* pIndex = NULL); + void FindFloatProperty(const char* name, + MP4Property** ppProperty, uint32_t* pIndex = NULL); + void FindStringProperty(const char* name, + MP4Property** ppProperty, uint32_t* pIndex = NULL); + void FindBytesProperty(const char* name, + MP4Property** ppProperty, uint32_t* pIndex = NULL); + + bool FindProperty(const char* name, + MP4Property** ppProperty, uint32_t* pIndex = NULL); + + MP4TrackId AddVideoTrackDefault( + uint32_t timeScale, + MP4Duration sampleDuration, + uint16_t width, + uint16_t height, + const char *videoType); + MP4TrackId AddCntlTrackDefault( + uint32_t timeScale, + MP4Duration sampleDuration, + const char *videoType); + void AddTrackToIod(MP4TrackId trackId); + + void RemoveTrackFromIod(MP4TrackId trackId, bool shallHaveIods = true); + + void AddTrackToOd(MP4TrackId trackId); + + void RemoveTrackFromOd(MP4TrackId trackId); + + void GetTrackReferenceProperties(const char* trefName, + MP4Property** ppCountProperty, MP4Property** ppTrackIdProperty); + + void AddTrackReference(const char* trefName, MP4TrackId refTrackId); + + uint32_t FindTrackReference(const char* trefName, MP4TrackId refTrackId); + + void RemoveTrackReference(const char* trefName, MP4TrackId refTrackId); + + void AddDataReference(MP4TrackId trackId, const char* url); + + char* MakeTrackName(MP4TrackId trackId, const char* name); + + uint8_t ConvertTrackTypeToStreamType(const char* trackType); + + void CreateIsmaIodFromFile( + MP4TrackId odTrackId, + MP4TrackId sceneTrackId, + MP4TrackId audioTrackId, + MP4TrackId videoTrackId, + uint8_t** ppBytes, + uint64_t* pNumBytes); + + void CreateESD( + MP4DescriptorProperty* pEsProperty, + uint32_t esid, + uint8_t objectType, + uint8_t streamType, + uint32_t bufferSize, + uint32_t bitrate, + const uint8_t* pConfig, + uint32_t configLength, + char* url); + + void CreateIsmaODUpdateCommandFromFileForFile( + MP4TrackId odTrackId, + MP4TrackId audioTrackId, + MP4TrackId videoTrackId, + uint8_t** ppBytes, + uint64_t* pNumBytes); + + void CreateIsmaODUpdateCommandFromFileForStream( + MP4TrackId audioTrackId, + MP4TrackId videoTrackId, + uint8_t** ppBytes, + uint64_t* pNumBytes); + + void CreateIsmaODUpdateCommandForStream( + MP4DescriptorProperty* pAudioEsdProperty, + MP4DescriptorProperty* pVideoEsdProperty, + uint8_t** ppBytes, + uint64_t* pNumBytes); + + void CreateIsmaSceneCommand( + bool hasAudio, + bool hasVideo, + uint8_t** ppBytes, + uint64_t* pNumBytes); + +protected: + File* m_file; + uint64_t m_fileOriginalSize; + uint32_t m_verbosity; + uint32_t m_createFlags; + + MP4Atom* m_pRootAtom; + MP4Integer32Array m_trakIds; + MP4TrackArray m_pTracks; + MP4TrackId m_odTrackId; + bool m_useIsma; + + // cached properties + MP4IntegerProperty* m_pModificationProperty; + MP4Integer32Property* m_pTimeScaleProperty; + MP4IntegerProperty* m_pDurationProperty; + + // read/write in memory + uint8_t* m_memoryBuffer; + uint64_t m_memoryBufferPosition; + uint64_t m_memoryBufferSize; + + // bit read/write buffering + uint8_t m_numReadBits; + uint8_t m_bufReadBits; + uint8_t m_numWriteBits; + uint8_t m_bufWriteBits; + + char m_tempFileName[MP4V2_PATH_MAX]; + char m_trakName[1024]; + char *m_editName; +}; + +/////////////////////////////////////////////////////////////////////////////// + +}} // namespace mp4v2::impl + +#endif // MP4V2_IMPL_MP4FILE_H diff --git a/src/mp4file_io.cpp b/src/mp4file_io.cpp new file mode 100644 index 0000000..973af83 --- /dev/null +++ b/src/mp4file_io.cpp @@ -0,0 +1,593 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +// MP4File low level IO support + +uint64_t MP4File::GetPosition( File* file ) +{ + if( m_memoryBuffer ) + return m_memoryBufferPosition; + + if( !file ) + file = m_file; + + ASSERT( file ); + return file->position; +} + +void MP4File::SetPosition( uint64_t pos, File* file ) +{ + if( m_memoryBuffer ) { + if( pos >= m_memoryBufferSize ) + throw new MP4Error( "position out of range", "MP4SetPosition" ); + m_memoryBufferPosition = pos; + return; + } + + if( !file ) + file = m_file; + + ASSERT( file ); + if( file->seek( pos )) + throw new MP4Error( sys::getLastError(), "MP4SetPosition" ); +} + +uint64_t MP4File::GetSize( File* file ) +{ + if( m_memoryBuffer ) + return m_memoryBufferSize; + + if( !file ) + file = m_file; + + ASSERT( file ); + return file->size; +} + +void MP4File::ReadBytes( uint8_t* buf, uint32_t bufsiz, File* file ) +{ + if( bufsiz == 0 ) + return; + + ASSERT( buf ); + WARNING( m_numReadBits > 0 ); + + if( m_memoryBuffer ) { + if( m_memoryBufferPosition + bufsiz > m_memoryBufferSize ) + throw new MP4Error( "not enough bytes, reached end-of-memory", "MP4ReadBytes" ); + memcpy( buf, &m_memoryBuffer[m_memoryBufferPosition], bufsiz ); + m_memoryBufferPosition += bufsiz; + return; + } + + if( !file ) + file = m_file; + + ASSERT( file ); + File::Size nin; + if( file->read( buf, bufsiz, nin )) + throw new MP4Error( sys::getLastError(), "MP4ReadBytes" ); + if( nin != bufsiz ) + throw new MP4Error( "not enough bytes, reached end-of-file", "MP4ReadBytes" ); +} + +void MP4File::PeekBytes( uint8_t* buf, uint32_t bufsiz, File* file ) +{ + const uint64_t pos = GetPosition( file ); + ReadBytes( buf, bufsiz, file ); + SetPosition( pos, file ); +} + +void MP4File::EnableMemoryBuffer( uint8_t* pBytes, uint64_t numBytes ) +{ + ASSERT( !m_memoryBuffer ); + + if (pBytes) { + m_memoryBuffer = pBytes; + m_memoryBufferSize = numBytes; + } else { + if (numBytes) { + m_memoryBufferSize = numBytes; + } else { + m_memoryBufferSize = 4096; + } + m_memoryBuffer = (uint8_t*)MP4Malloc(m_memoryBufferSize); + } + m_memoryBufferPosition = 0; +} + +void MP4File::DisableMemoryBuffer( uint8_t** ppBytes, uint64_t* pNumBytes ) +{ + ASSERT(m_memoryBuffer != NULL); + + if (ppBytes) { + *ppBytes = m_memoryBuffer; + } + if (pNumBytes) { + *pNumBytes = m_memoryBufferPosition; + } + + m_memoryBuffer = NULL; + m_memoryBufferSize = 0; + m_memoryBufferPosition = 0; +} + +void MP4File::WriteBytes( uint8_t* buf, uint32_t bufsiz, File* file ) +{ + ASSERT( m_numWriteBits == 0 || m_numWriteBits >= 8 ); + + if( !buf || bufsiz == 0 ) + return; + + if( m_memoryBuffer ) { + if( m_memoryBufferPosition + bufsiz > m_memoryBufferSize ) { + m_memoryBufferSize = 2 * (m_memoryBufferSize + bufsiz); + m_memoryBuffer = (uint8_t*)MP4Realloc( m_memoryBuffer, m_memoryBufferSize ); + } + memcpy( &m_memoryBuffer[m_memoryBufferPosition], buf, bufsiz ); + m_memoryBufferPosition += bufsiz; + return; + } + + if( !file ) + file = m_file; + + ASSERT( file ); + File::Size nout; + if( file->write( buf, bufsiz, nout )) + throw new MP4Error( sys::getLastError(), "MP4WriteBytes" ); + if( nout != bufsiz ) + throw new MP4Error( "not all bytes written", "MP4WriteBytes" ); +} + +uint64_t MP4File::ReadUInt(uint8_t size) +{ + switch (size) { + case 1: + return ReadUInt8(); + case 2: + return ReadUInt16(); + case 3: + return ReadUInt24(); + case 4: + return ReadUInt32(); + case 8: + return ReadUInt64(); + default: + ASSERT(false); + return 0; + } +} + +#if 0 +void MP4File::WriteUInt(uint64_t value, uint8_t size) +{ + switch (size) { + case 1: + WriteUInt8(value); + case 2: + WriteUInt16(value); + case 3: + WriteUInt24(value); + case 4: + WriteUInt32(value); + case 8: + WriteUInt64(value); + default: + ASSERT(false); + } +} +#endif + +uint8_t MP4File::ReadUInt8() +{ + uint8_t data; + ReadBytes(&data, 1); + return data; +} + +void MP4File::WriteUInt8(uint8_t value) +{ + WriteBytes(&value, 1); +} + +uint16_t MP4File::ReadUInt16() +{ + uint8_t data[2]; + ReadBytes(&data[0], 2); + return ((data[0] << 8) | data[1]); +} + +void MP4File::WriteUInt16(uint16_t value) +{ + uint8_t data[2]; + data[0] = (value >> 8) & 0xFF; + data[1] = value & 0xFF; + WriteBytes(data, 2); +} + +uint32_t MP4File::ReadUInt24() +{ + uint8_t data[3]; + ReadBytes(&data[0], 3); + return ((data[0] << 16) | (data[1] << 8) | data[2]); +} + +void MP4File::WriteUInt24(uint32_t value) +{ + uint8_t data[3]; + data[0] = (value >> 16) & 0xFF; + data[1] = (value >> 8) & 0xFF; + data[2] = value & 0xFF; + WriteBytes(data, 3); +} + +uint32_t MP4File::ReadUInt32() +{ + uint8_t data[4]; + ReadBytes(&data[0], 4); + return ((data[0] << 24) | (data[1] << 16) | (data[2] << 8) | data[3]); +} + +void MP4File::WriteUInt32(uint32_t value) +{ + uint8_t data[4]; + data[0] = (value >> 24) & 0xFF; + data[1] = (value >> 16) & 0xFF; + data[2] = (value >> 8) & 0xFF; + data[3] = value & 0xFF; + WriteBytes(data, 4); +} + +uint64_t MP4File::ReadUInt64() +{ + uint8_t data[8]; + uint64_t result = 0; + uint64_t temp; + + ReadBytes(&data[0], 8); + + for (int i = 0; i < 8; i++) { + temp = data[i]; + result |= temp << ((7 - i) * 8); + } + return result; +} + +void MP4File::WriteUInt64(uint64_t value) +{ + uint8_t data[8]; + + for (int i = 7; i >= 0; i--) { + data[i] = value & 0xFF; + value >>= 8; + } + WriteBytes(data, 8); +} + +float MP4File::ReadFixed16() +{ + uint8_t iPart = ReadUInt8(); + uint8_t fPart = ReadUInt8(); + + return iPart + (((float)fPart) / 0x100); +} + +void MP4File::WriteFixed16(float value) +{ + if (value >= 0x100) { + throw new MP4Error(ERANGE, "MP4WriteFixed16"); + } + + uint8_t iPart = (uint8_t)value; + uint8_t fPart = (uint8_t)((value - iPart) * 0x100); + + WriteUInt8(iPart); + WriteUInt8(fPart); +} + +float MP4File::ReadFixed32() +{ + uint16_t iPart = ReadUInt16(); + uint16_t fPart = ReadUInt16(); + + return iPart + (((float)fPart) / 0x10000); +} + +void MP4File::WriteFixed32(float value) +{ + if (value >= 0x10000) { + throw new MP4Error(ERANGE, "MP4WriteFixed32"); + } + + uint16_t iPart = (uint16_t)value; + uint16_t fPart = (uint16_t)((value - iPart) * 0x10000); + + WriteUInt16(iPart); + WriteUInt16(fPart); +} + +float MP4File::ReadFloat() +{ + union { + float f; + uint32_t i; + } u; + + u.i = ReadUInt32(); + return u.f; +} + +void MP4File::WriteFloat(float value) +{ + union { + float f; + uint32_t i; + } u; + + u.f = value; + WriteUInt32(u.i); +} + +char* MP4File::ReadString() +{ + uint32_t length = 0; + uint32_t alloced = 64; + char* data = (char*)MP4Malloc(alloced); + + do { + if (length == alloced) { + data = (char*)MP4Realloc(data, alloced * 2); + if (data == NULL) return NULL; + alloced *= 2; + } + ReadBytes((uint8_t*)&data[length], 1); + length++; + } while (data[length - 1] != 0); + + data = (char*)MP4Realloc(data, length); + return data; +} + +void MP4File::WriteString(char* string) +{ + if (string == NULL) { + uint8_t zero = 0; + WriteBytes(&zero, 1); + } else { + WriteBytes((uint8_t*)string, strlen(string) + 1); + } +} + +char* MP4File::ReadCountedString(uint8_t charSize, bool allowExpandedCount, uint8_t fixedLength) +{ + uint32_t charLength; + if (allowExpandedCount) { + uint8_t b; + uint32_t ix = 0; + charLength = 0; + do { + b = ReadUInt8(); + charLength += b; + ix++; + if (ix > 25) + throw new MP4Error(ERANGE, + "Counted string too long 25 * 255"); + } while (b == 255); + } else { + charLength = ReadUInt8(); + } + + if (fixedLength && (charLength > fixedLength)) { + /* + * The counted length of this string is greater than the + * maxiumum fixed length, so truncate the string to the + * maximum fixed length amount (take 1 byte away from the + * fixedlength since we've already sacrificed one byte for + * reading the counted length, and there has been a bug where + * a non counted string has been used in the place of a + * counted string). + */ + WARNING(charLength > fixedLength); + charLength = fixedLength - 1U; + } + + uint32_t byteLength = charLength * charSize; + char* data = (char*)MP4Malloc(byteLength + 1); + if (byteLength > 0) { + ReadBytes((uint8_t*)data, byteLength); + } + data[byteLength] = '\0'; + + // read padding + if (fixedLength) { + const uint8_t padsize = fixedLength - byteLength -1U; + if( padsize ) { + uint8_t* padbuf = (uint8_t*)malloc( padsize ); + ReadBytes( padbuf, padsize ); + free( padbuf ); + } + } + + return data; +} + +void MP4File::WriteCountedString(char* string, + uint8_t charSize, bool allowExpandedCount, + uint32_t fixedLength) +{ + uint32_t byteLength; + uint8_t zero[1]; + + if (string) { + byteLength = strlen(string); + if (fixedLength && (byteLength >= fixedLength)) { + byteLength = fixedLength-1; + } + } + else { + byteLength = 0; + } + uint32_t charLength = byteLength / charSize; + + if (allowExpandedCount) { + while (charLength >= 0xFF) { + WriteUInt8(0xFF); + charLength -= 0xFF; + } + // Write the count + WriteUInt8(charLength); + } else { + if (charLength > 255) { + throw new MP4Error(ERANGE, "Length is %d", "MP4WriteCountedString", charLength); + } + // Write the count + WriteUInt8(charLength); + } + + if (byteLength > 0) { + // Write the string (or the portion that we want to write) + WriteBytes((uint8_t*)string, byteLength); + } + + // Write any padding if this is a fixed length counted string + if (fixedLength) { + zero[0] = 0; + while (byteLength < fixedLength-1U) { + WriteBytes(zero, 1); + byteLength++; + } + } +} + +uint64_t MP4File::ReadBits(uint8_t numBits) +{ + ASSERT(numBits > 0); + ASSERT(numBits <= 64); + + uint64_t bits = 0; + + for (uint8_t i = numBits; i > 0; i--) { + if (m_numReadBits == 0) { + ReadBytes(&m_bufReadBits, 1); + m_numReadBits = 8; + } + bits = (bits << 1) | ((m_bufReadBits >> (--m_numReadBits)) & 1); + } + + return bits; +} + +void MP4File::FlushReadBits() +{ + // eat any remaining bits in the read buffer + m_numReadBits = 0; +} + +void MP4File::WriteBits(uint64_t bits, uint8_t numBits) +{ + ASSERT(numBits <= 64); + + for (uint8_t i = numBits; i > 0; i--) { + m_bufWriteBits |= + (((bits >> (i - 1)) & 1) << (8 - ++m_numWriteBits)); + + if (m_numWriteBits == 8) { + FlushWriteBits(); + } + } +} + +void MP4File::PadWriteBits(uint8_t pad) +{ + if (m_numWriteBits) { + WriteBits(pad ? 0xFF : 0x00, 8 - m_numWriteBits); + } +} + +void MP4File::FlushWriteBits() +{ + if (m_numWriteBits > 0) { + WriteBytes(&m_bufWriteBits, 1); + m_numWriteBits = 0; + m_bufWriteBits = 0; + } +} + +uint32_t MP4File::ReadMpegLength() +{ + uint32_t length = 0; + uint8_t numBytes = 0; + uint8_t b; + + do { + b = ReadUInt8(); + length = (length << 7) | (b & 0x7F); + numBytes++; + } while ((b & 0x80) && numBytes < 4); + + return length; +} + +void MP4File::WriteMpegLength(uint32_t value, bool compact) +{ + if (value > 0x0FFFFFFF) { + throw new MP4Error(ERANGE, "MP4WriteMpegLength"); + } + + int8_t numBytes; + + if (compact) { + if (value <= 0x7F) { + numBytes = 1; + } else if (value <= 0x3FFF) { + numBytes = 2; + } else if (value <= 0x1FFFFF) { + numBytes = 3; + } else { + numBytes = 4; + } + } else { + numBytes = 4; + } + + int8_t i = numBytes; + do { + i--; + uint8_t b = (value >> (i * 7)) & 0x7F; + if (i > 0) { + b |= 0x80; + } + WriteUInt8(b); + } while (i > 0); +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/mp4info.cpp b/src/mp4info.cpp new file mode 100644 index 0000000..29a4729 --- /dev/null +++ b/src/mp4info.cpp @@ -0,0 +1,624 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001-2002. All Rights Reserved. + * + * Portions created by Ximpo Group Ltd. are + * Copyright (C) Ximpo Group Ltd. 2003, 2004. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + * Bill May wmay@cisco.com + * Alix Marchandise-Franquet alix@cisco.com + * Ximpo Group Ltd. mp4v2@ximpo.com + */ + +#include "src/impl.h" + +namespace mp4v2 { namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +static char* PrintAudioInfo( + MP4FileHandle mp4File, + MP4TrackId trackId) +{ + static const char* mpeg4AudioNames[] = { + "MPEG-4 AAC main", + "MPEG-4 AAC LC", + "MPEG-4 AAC SSR", + "MPEG-4 AAC LTP", + "MPEG-4 AAC HE", + "MPEG-4 AAC Scalable", + "MPEG-4 TwinVQ", + "MPEG-4 CELP", + "MPEG-4 HVXC", + NULL, NULL, + "MPEG-4 TTSI", + "MPEG-4 Main Synthetic", + "MPEG-4 Wavetable Syn", + "MPEG-4 General MIDI", + "MPEG-4 Algo Syn and Audio FX", + "MPEG-4 ER AAC LC", + NULL, + "MPEG-4 ER AAC LTP", + "MPEG-4 ER AAC Scalable", + "MPEG-4 ER TwinVQ", + "MPEG-4 ER BSAC", + "MPEG-4 ER ACC LD", + "MPEG-4 ER CELP", + "MPEG-4 ER HVXC", + "MPEG-4 ER HILN", + "MPEG-4 ER Parametric", + "MPEG-4 SSC", + "MPEG-4 PS", + "MPEG-4 MPEG Surround", + NULL, + "MPEG-4 Layer-1", + "MPEG-4 Layer-2", + "MPEG-4 Layer-3", + "MPEG-4 DST", + "MPEG-4 Audio Lossless", + "MPEG-4 SLS", + "MPEG-4 SLS non-core", + }; + + static const uint8_t mpegAudioTypes[] = { + MP4_MPEG2_AAC_MAIN_AUDIO_TYPE, // 0x66 + MP4_MPEG2_AAC_LC_AUDIO_TYPE, // 0x67 + MP4_MPEG2_AAC_SSR_AUDIO_TYPE, // 0x68 + MP4_MPEG2_AUDIO_TYPE, // 0x69 + MP4_MPEG1_AUDIO_TYPE, // 0x6B + // private types + MP4_PCM16_LITTLE_ENDIAN_AUDIO_TYPE, + MP4_VORBIS_AUDIO_TYPE, + MP4_ALAW_AUDIO_TYPE, + MP4_ULAW_AUDIO_TYPE, + MP4_G723_AUDIO_TYPE, + MP4_PCM16_BIG_ENDIAN_AUDIO_TYPE, + }; + static const char* mpegAudioNames[] = { + "MPEG-2 AAC Main", + "MPEG-2 AAC LC", + "MPEG-2 AAC SSR", + "MPEG-2 Audio (13818-3)", + "MPEG-1 Audio (11172-3)", + // private types + "PCM16 (little endian)", + "Vorbis", + "G.711 aLaw", + "G.711 uLaw", + "G.723.1", + "PCM16 (big endian)", + }; + uint8_t numMpegAudioTypes = + sizeof(mpegAudioTypes) / sizeof(uint8_t); + + const char* typeName = "Unknown"; + bool foundType = false; + uint8_t type = 0; + const char *media_data_name; + + media_data_name = MP4GetTrackMediaDataName(mp4File, trackId); + + if (media_data_name == NULL) { + typeName = "Unknown - no media data name"; + } else if (strcasecmp(media_data_name, "samr") == 0) { + typeName = "AMR"; + foundType = true; + } else if (strcasecmp(media_data_name, "sawb") == 0) { + typeName = "AMR-WB"; + foundType = true; + } else if (strcasecmp(media_data_name, "mp4a") == 0) { + + type = MP4GetTrackEsdsObjectTypeId(mp4File, trackId); + switch (type) { + case MP4_INVALID_AUDIO_TYPE: + typeName = "AAC from .mov"; + foundType = true; + break; + case MP4_MPEG4_AUDIO_TYPE: { + + type = MP4GetTrackAudioMpeg4Type(mp4File, trackId); + if (type == MP4_MPEG4_INVALID_AUDIO_TYPE || + type > NUM_ELEMENTS_IN_ARRAY(mpeg4AudioNames) || + mpeg4AudioNames[type - 1] == NULL) { + typeName = "MPEG-4 Unknown Profile"; + } else { + typeName = mpeg4AudioNames[type - 1]; + foundType = true; + } + break; + } + // fall through + default: + for (uint8_t i = 0; i < numMpegAudioTypes; i++) { + if (type == mpegAudioTypes[i]) { + typeName = mpegAudioNames[i]; + foundType = true; + break; + } + } + } + } else { + typeName = media_data_name; + foundType = true; + } + + uint32_t timeScale = + MP4GetTrackTimeScale(mp4File, trackId); + + MP4Duration trackDuration = + MP4GetTrackDuration(mp4File, trackId); + + double msDuration = + double(MP4ConvertFromTrackDuration(mp4File, trackId, + trackDuration, MP4_MSECS_TIME_SCALE)); + + uint32_t avgBitRate = + MP4GetTrackBitRate(mp4File, trackId); + + char *sInfo = (char*)MP4Malloc(256); + + // type duration avgBitrate samplingFrequency + if (foundType) + snprintf(sInfo, 256, + "%u\taudio\t%s%s, %.3f secs, %u kbps, %u Hz\n", + trackId, + MP4IsIsmaCrypMediaTrack(mp4File, trackId) ? "enca - " : "", + typeName, + msDuration / 1000.0, + (avgBitRate + 500) / 1000, + timeScale); + else + snprintf(sInfo, 256, + "%u\taudio\t%s%s(%u), %.3f secs, %u kbps, %u Hz\n", + trackId, + MP4IsIsmaCrypMediaTrack(mp4File, trackId) ? "enca - " : "", + typeName, + type, + msDuration / 1000.0, + (avgBitRate + 500) / 1000, + timeScale); + + return sInfo; +} +static const struct { + uint8_t profile; + const char *name; +} VisualProfileToName[] = { + { MPEG4_SP_L1, "MPEG-4 Simple @ L1"}, + { MPEG4_SP_L2, "MPEG-4 Simple @ L2" }, + { MPEG4_SP_L3, "MPEG-4 Simple @ L3" }, + { MPEG4_SP_L0, "MPEG-4 Simple @ L0" }, + { MPEG4_SSP_L1, "MPEG-4 Simple Scalable @ L1"}, + { MPEG4_SSP_L2, "MPEG-4 Simple Scalable @ L2" }, + { MPEG4_CP_L1, "MPEG-4 Core @ L1"}, + { MPEG4_CP_L2, "MPEG-4 Core @ L2"}, + { MPEG4_MP_L2, "MPEG-4 Main @ L2"}, + { MPEG4_MP_L3, "MPEG-4 Main @ L3"}, + { MPEG4_MP_L4, "MPEG-4 Main @ L4"}, + { MPEG4_NBP_L2, "MPEG-4 N-bit @ L2"}, + { MPEG4_STP_L1, "MPEG-4 Scalable Texture @ L1"}, + { MPEG4_SFAP_L1, "MPEG-4 Simple Face Anim @ L1"}, + { MPEG4_SFAP_L2, "MPEG-4 Simple Face Anim @ L2"}, + { MPEG4_SFBAP_L1, "MPEG-4 Simple FBA @ L1"}, + { MPEG4_SFBAP_L2, "MPEG-4 Simple FBA @ L2"}, + { MPEG4_BATP_L1, "MPEG-4 Basic Anim Text @ L1"}, + { MPEG4_BATP_L2, "MPEG-4 Basic Anim Text @ L2"}, + { MPEG4_HP_L1, "MPEG-4 Hybrid @ L1"}, + { MPEG4_HP_L2, "MPEG-4 Hybrid @ L2"}, + { MPEG4_ARTSP_L1, "MPEG-4 Adv RT Simple @ L1"}, + { MPEG4_ARTSP_L2, "MPEG-4 Adv RT Simple @ L2"}, + { MPEG4_ARTSP_L3, "MPEG-4 Adv RT Simple @ L3"}, + { MPEG4_ARTSP_L4, "MPEG-4 Adv RT Simple @ L4"}, + { MPEG4_CSP_L1, "MPEG-4 Core Scalable @ L1"}, + { MPEG4_CSP_L2, "MPEG-4 Core Scalable @ L2"}, + { MPEG4_CSP_L3, "MPEG-4 Core Scalable @ L3"}, + { MPEG4_ACEP_L1, "MPEG-4 Adv Coding Efficieny @ L1"}, + { MPEG4_ACEP_L2, "MPEG-4 Adv Coding Efficieny @ L2"}, + { MPEG4_ACEP_L3, "MPEG-4 Adv Coding Efficieny @ L3"}, + { MPEG4_ACEP_L4, "MPEG-4 Adv Coding Efficieny @ L4"}, + { MPEG4_ACP_L1, "MPEG-4 Adv Core Profile @ L1"}, + { MPEG4_ACP_L2, "MPEG-4 Adv Core Profile @ L2"}, + { MPEG4_AST_L1, "MPEG-4 Adv Scalable Texture @ L1"}, + { MPEG4_AST_L2, "MPEG-4 Adv Scalable Texture @ L2"}, + { MPEG4_AST_L3, "MPEG-4 Adv Scalable Texture @ L3"}, + { MPEG4_S_STUDIO_P_L1, "MPEG-4 Simple Studio @ L1"}, + { MPEG4_S_STUDIO_P_L2, "MPEG-4 Simple Studio @ L2"}, + { MPEG4_S_STUDIO_P_L3, "MPEG-4 Simple Studio @ L3"}, + { MPEG4_S_STUDIO_P_L4, "MPEG-4 Simple Studio @ L4"}, + { MPEG4_C_STUDIO_P_L1, "MPEG-4 Core Studio @ L1"}, + { MPEG4_C_STUDIO_P_L2, "MPEG-4 Core Studio @ L2"}, + { MPEG4_C_STUDIO_P_L3, "MPEG-4 Core Studio @ L3"}, + { MPEG4_C_STUDIO_P_L4, "MPEG-4 Core Studio @ L4"}, + { MPEG4_ASP_L0, "MPEG-4 Adv Simple@L0"}, + { MPEG4_ASP_L1, "MPEG-4 Adv Simple@L1"}, + { MPEG4_ASP_L2, "MPEG-4 Adv Simple@L2"}, + { MPEG4_ASP_L3, "MPEG-4 Adv Simple@L3"}, + { MPEG4_ASP_L4, "MPEG-4 Adv Simple@L4"}, + { MPEG4_ASP_L5, "MPEG-4 Adv Simple@L5"}, + { MPEG4_ASP_L3B, "MPEG-4 Adv Simple@L3b"}, + { MPEG4_FGSP_L0, "MPEG-4 FGS @ L0" }, + { MPEG4_FGSP_L1, "MPEG-4 FGS @ L1" }, + { MPEG4_FGSP_L2, "MPEG-4 FGS @ L2" }, + { MPEG4_FGSP_L3, "MPEG-4 FGS @ L3" }, + { MPEG4_FGSP_L4, "MPEG-4 FGS @ L4" }, + { MPEG4_FGSP_L5, "MPEG-4 FGS @ L5" } +}; + +static const char *Mpeg4VisualProfileName (uint8_t visual_profile) +{ + size_t size = sizeof(VisualProfileToName) / sizeof(*VisualProfileToName); + + for (size_t ix = 0; ix < size; ix++) { + if (visual_profile == VisualProfileToName[ix].profile) { + return (VisualProfileToName[ix].name); + } + } + return (NULL); +} +static char* PrintVideoInfo( + MP4FileHandle mp4File, + MP4TrackId trackId) +{ + + static const uint8_t mpegVideoTypes[] = { + MP4_MPEG2_SIMPLE_VIDEO_TYPE, // 0x60 + MP4_MPEG2_MAIN_VIDEO_TYPE, // 0x61 + MP4_MPEG2_SNR_VIDEO_TYPE, // 0x62 + MP4_MPEG2_SPATIAL_VIDEO_TYPE, // 0x63 + MP4_MPEG2_HIGH_VIDEO_TYPE, // 0x64 + MP4_MPEG2_442_VIDEO_TYPE, // 0x65 + MP4_MPEG1_VIDEO_TYPE, // 0x6A + MP4_JPEG_VIDEO_TYPE, // 0x6C + MP4_YUV12_VIDEO_TYPE, + MP4_H263_VIDEO_TYPE, + MP4_H261_VIDEO_TYPE, + }; + static const char* mpegVideoNames[] = { + "MPEG-2 Simple", + "MPEG-2 Main", + "MPEG-2 SNR", + "MPEG-2 Spatial", + "MPEG-2 High", + "MPEG-2 4:2:2", + "MPEG-1", + "JPEG", + "YUV12", + "H.263", + "H.261", + }; + uint8_t numMpegVideoTypes = + sizeof(mpegVideoTypes) / sizeof(uint8_t); + bool foundTypeName = false; + const char* typeName = "Unknown"; + + const char *media_data_name; + char originalFormat[8]; + char oformatbuffer[32]; + originalFormat[0] = 0; + *oformatbuffer = 0; + uint8_t type = 0; + + media_data_name = MP4GetTrackMediaDataName(mp4File, trackId); + // encv 264b + if (strcasecmp(media_data_name, "encv") == 0) { + if (MP4GetTrackMediaDataOriginalFormat(mp4File, + trackId, + originalFormat, + sizeof(originalFormat)) == false) + media_data_name = NULL; + + } + + char typebuffer[80]; + if (media_data_name == NULL) { + typeName = "Unknown - no media data name"; + foundTypeName = true; + } else if ((strcasecmp(media_data_name, "avc1") == 0) || + (strcasecmp(originalFormat, "264b") == 0)) { + // avc + uint8_t profile, level; + char profileb[20], levelb[20]; + if (MP4GetTrackH264ProfileLevel(mp4File, trackId, + &profile, &level)) { + if (profile == 66) { + strcpy(profileb, "Baseline"); + } else if (profile == 77) { + strcpy(profileb, "Main"); + } else if (profile == 88) { + strcpy(profileb, "Extended"); + } else if (profile == 100) { + strcpy(profileb, "High"); + } else if (profile == 110) { + strcpy(profileb, "High 10"); + } else if (profile == 122) { + strcpy(profileb, "High 4:2:2"); + } else if (profile == 144) { + strcpy(profileb, "High 4:4:4"); + } else { + snprintf(profileb, 20, "Unknown Profile %x", profile); + } + switch (level) { + case 10: + case 20: + case 30: + case 40: + case 50: + snprintf(levelb, 20, "%u", level / 10); + break; + case 11: + case 12: + case 13: + case 21: + case 22: + case 31: + case 32: + case 41: + case 42: + case 51: + snprintf(levelb, 20, "%u.%u", level / 10, level % 10); + break; + default: + snprintf(levelb, 20, "unknown level %x", level); + break; + } + if (originalFormat != NULL && originalFormat[0] != '\0') + snprintf(oformatbuffer, 32, "(%s) ", originalFormat); + snprintf(typebuffer, sizeof(typebuffer), "H264 %s%s@%s", + oformatbuffer, profileb, levelb); + typeName = typebuffer; + } else { + typeName = "H.264 - profile/level error"; + } + foundTypeName = true; + } else if (strcasecmp(media_data_name, "s263") == 0) { + // 3gp h.263 + typeName = "H.263"; + foundTypeName = true; + } else if ((strcasecmp(media_data_name, "mp4v") == 0) || + (strcasecmp(media_data_name, "encv") == 0)) { + // note encv might needs it's own field eventually. + type = MP4GetTrackEsdsObjectTypeId(mp4File, trackId); + if (type == MP4_MPEG4_VIDEO_TYPE) { + type = MP4GetVideoProfileLevel(mp4File, trackId); + typeName = Mpeg4VisualProfileName(type); + if (typeName == NULL) { + typeName = "MPEG-4 Unknown Profile"; + } else { + foundTypeName = true; + } + } else { + for (uint8_t i = 0; i < numMpegVideoTypes; i++) { + if (type == mpegVideoTypes[i]) { + typeName = mpegVideoNames[i]; + foundTypeName = true; + break; + } + } + } + } else { + typeName = media_data_name; + foundTypeName = true; // we don't have a type value to display + } + + MP4Duration trackDuration = + MP4GetTrackDuration(mp4File, trackId); + + double msDuration = + double(MP4ConvertFromTrackDuration(mp4File, trackId, + trackDuration, MP4_MSECS_TIME_SCALE)); + + uint32_t avgBitRate = + MP4GetTrackBitRate(mp4File, trackId); + + // Note not all mp4 implementations set width and height correctly + // The real answer can be buried inside the ES configuration info + uint16_t width = MP4GetTrackVideoWidth(mp4File, trackId); + + uint16_t height = MP4GetTrackVideoHeight(mp4File, trackId); + + double fps = MP4GetTrackVideoFrameRate(mp4File, trackId); + + char *sInfo = (char*)MP4Malloc(256); + + // type duration avgBitrate frameSize frameRate + if (foundTypeName) { + sprintf(sInfo, + "%u\tvideo\t%s%s, %.3f secs, %u kbps, %ux%u @ %f fps\n", + trackId, + MP4IsIsmaCrypMediaTrack(mp4File, trackId) ? "encv - " : "", + typeName, + msDuration / 1000.0, + (avgBitRate + 500) / 1000, + width, + height, + fps + ); + } else { + sprintf(sInfo, + "%u\tvideo\t%s(%u), %.3f secs, %u kbps, %ux%u @ %f fps\n", + trackId, + typeName, + type, + msDuration / 1000.0, + (avgBitRate + 500) / 1000, + width, + height, + fps + ); + } + + return sInfo; +} +static char* PrintCntlInfo( + MP4FileHandle mp4File, + MP4TrackId trackId) +{ + const char *media_data_name = MP4GetTrackMediaDataName(mp4File, trackId); + const char *typeName = "Unknown"; + + if (media_data_name == NULL) { + typeName = "Unknown - no media data name"; + } else if (strcasecmp(media_data_name, "href") == 0) { + typeName = "ISMA Href"; + } else { + typeName = media_data_name; + } + + MP4Duration trackDuration = + MP4GetTrackDuration(mp4File, trackId); + + double msDuration = + double(MP4ConvertFromTrackDuration(mp4File, trackId, + trackDuration, MP4_MSECS_TIME_SCALE)); + char *sInfo = (char *)MP4Malloc(256); + + snprintf(sInfo, 256, + "%u\tcontrol\t%s, %.3f secs\n", + trackId, + typeName, + msDuration / 1000.0); + return sInfo; +} + + +static char* PrintHintInfo( + MP4FileHandle mp4File, + MP4TrackId trackId) +{ + MP4TrackId referenceTrackId = + MP4GetHintTrackReferenceTrackId(mp4File, trackId); + + char* payloadName = NULL; + if (!MP4GetHintTrackRtpPayload(mp4File, trackId, &payloadName)) + return NULL; + + char *sInfo = (char*)MP4Malloc(256); + + snprintf(sInfo, 256, + "%u\thint\tPayload %s for track %u\n", + trackId, + payloadName, + referenceTrackId); + + free(payloadName); + + return sInfo; +} + +static char* PrintTrackInfo( + MP4FileHandle mp4File, + MP4TrackId trackId) +{ + char* trackInfo = NULL; + + const char* trackType = + MP4GetTrackType(mp4File, trackId); + if (trackType == NULL) return NULL; + + if (!strcmp(trackType, MP4_AUDIO_TRACK_TYPE)) { + trackInfo = PrintAudioInfo(mp4File, trackId); + } else if (!strcmp(trackType, MP4_VIDEO_TRACK_TYPE)) { + trackInfo = PrintVideoInfo(mp4File, trackId); + } else if (!strcmp(trackType, MP4_HINT_TRACK_TYPE)) { + trackInfo = PrintHintInfo(mp4File, trackId); + } else if (strcmp(trackType, MP4_CNTL_TRACK_TYPE) == 0) { + trackInfo = PrintCntlInfo(mp4File, trackId); + } else { + trackInfo = (char*)MP4Malloc(256); + if (!strcmp(trackType, MP4_OD_TRACK_TYPE)) { + snprintf(trackInfo, 256, + "%u\tod\tObject Descriptors\n", + trackId); + } else if (!strcmp(trackType, MP4_SCENE_TRACK_TYPE)) { + snprintf(trackInfo, 256, + "%u\tscene\tBIFS\n", + trackId); + } else { + snprintf(trackInfo, 256, + "%u\t%s\n", + trackId, trackType); + } + } + + return trackInfo; +} + +/////////////////////////////////////////////////////////////////////////////// + +}} // namespace mp4v2::impl + +/////////////////////////////////////////////////////////////////////////////// + +using namespace mp4v2::impl; + +extern "C" +char* MP4Info( + MP4FileHandle mp4File, + MP4TrackId trackId ) +{ + char* info = NULL; + + if (MP4_IS_VALID_FILE_HANDLE(mp4File)) { + try { + if (trackId == MP4_INVALID_TRACK_ID) { + uint32_t buflen = 4 * 1024; + info = (char*)MP4Calloc(buflen); + + buflen -= snprintf(info, buflen, + "Track\tType\tInfo\n"); + + uint32_t numTracks = MP4GetNumberOfTracks(mp4File); + + for (uint32_t i = 0; i < numTracks; i++) { + trackId = MP4FindTrackId(mp4File, i); + char* trackInfo = PrintTrackInfo(mp4File, trackId); + strncat(info, trackInfo, buflen); + uint32_t newlen = strlen(trackInfo); + if (newlen > buflen) buflen = 0; + else buflen -= newlen; + MP4Free(trackInfo); + } + } else { + info = PrintTrackInfo(mp4File, trackId); + } + } + catch (MP4Error* e) { + delete e; + } + } + + return info; +} + +extern "C" +char* MP4FileInfo( + const char* fileName, + MP4TrackId trackId ) +{ + MP4FileHandle mp4File = MP4Read(fileName); + + if (!mp4File) { + return NULL; + } + + char* info = MP4Info(mp4File, trackId); + + MP4Close(mp4File); + + return info; // caller should free this +} diff --git a/src/mp4meta.cpp b/src/mp4meta.cpp new file mode 100644 index 0000000..52d5909 --- /dev/null +++ b/src/mp4meta.cpp @@ -0,0 +1,1065 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * Contributor(s): + * M. Bakker mbakker at nero.com + * + * Apple iTunes Metadata handling + */ + +/** + + The iTunes tagging seems to support any tag field name + but there are some predefined fields, also known from the QuickTime format + + predefined fields (the ones I know of until now): + - nam : Name of the song/movie (string) + - ART : Name of the artist/performer (string) + - ART : Album artist + - wrt : Name of the writer (string) + - alb : Name of the album (string) + - day : Year (4 bytes, e.g. "2003") (string) + - too : Tool(s) used to create the file (string) + - cmt : Comment (string) + - gen : Custom genre (string) + - grp : Grouping (string) + - trkn : Tracknumber (8 byte string) + 16 bit: empty + 16 bit: tracknumber + 16 bit: total tracks on album + 16 bit: empty + - disk : Disknumber (8 byte string) + 16 bit: empty + 16 bit: disknumber + 16 bit: total number of disks + 16 bit: empty + - gnre : Genre (16 bit genre) (ID3v1 index + 1) + - cpil : Part of a compilation (1 byte, 1 or 0) + - tmpo : Tempo in BPM (16 bit) + - covr : Cover art (xx bytes binary data) + - ---- : Free form metadata, can have any name and any data + - pgap : gapless - 8 bit boolean + + - apID : purchaser name. + - cprt : copyright + - purd : purchase date. + +**/ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +bool MP4File::GetMetadataByIndex(uint32_t index, + char** ppName, + uint8_t** ppValue, uint32_t* pValueSize) +{ + char s[256]; + + snprintf(s, 256, "moov.udta.meta.ilst.*[%u].data.metadata", index); + GetBytesProperty(s, ppValue, pValueSize); + + snprintf(s, 256, "moov.udta.meta.ilst.*[%u]", index); + MP4Atom* pParent = m_pRootAtom->FindAtom(s); + if (pParent == NULL) return false; + + /* check for free form tagfield */ + if (memcmp(*ppName, "----", 4) == 0) + { + uint8_t* pV; + uint32_t VSize = 0; + char *pN; + + snprintf(s, 256, "moov.udta.meta.ilst.*[%u].name.metadata", index); + GetBytesProperty(s, &pV, &VSize); + + pN = (char*)malloc((VSize+1)*sizeof(char)); + if (pN != NULL) { + memset(pN, 0, (VSize+1)*sizeof(char)); + memcpy(pN, pV, VSize*sizeof(char)); + } + free(pV); + *ppName = pN; + } else { + *ppName = strdup(pParent->GetType()); + } + + return true; +} + +bool MP4File::CreateMetadataAtom(const char* name, itmf::BasicType typeCode) +{ + char s[256]; + char t[256]; + + snprintf(t, 256, "udta.meta.ilst.%s.data", name); + snprintf(s, 256, "moov.udta.meta.ilst.%s.data", name); + (void)AddDescendantAtoms("moov", t); + MP4Atom *pMetaAtom = m_pRootAtom->FindAtom(s); + + if (!pMetaAtom) + return false; + + MP4DataAtom& data = *(MP4DataAtom*)pMetaAtom; + data.typeCode.SetValue( typeCode ); + + MP4Atom *pHdlrAtom = m_pRootAtom->FindAtom("moov.udta.meta.hdlr"); + MP4StringProperty *pStringProperty = NULL; + MP4BytesProperty *pBytesProperty = NULL; + ASSERT(pHdlrAtom); + + ASSERT(pHdlrAtom->FindProperty("hdlr.handlerType", + (MP4Property**)&pStringProperty)); + ASSERT(pStringProperty); + pStringProperty->SetValue("mdir"); + + uint8_t val[12]; + memset(val, 0, 12*sizeof(uint8_t)); + val[0] = 0x61; + val[1] = 0x70; + val[2] = 0x70; + val[3] = 0x6c; + ASSERT(pHdlrAtom->FindProperty("hdlr.reserved2", + (MP4Property**)&pBytesProperty)); + ASSERT(pBytesProperty); + pBytesProperty->SetReadOnly(false); + pBytesProperty->SetValue(val, 12); + pBytesProperty->SetReadOnly(true); + + return true; +} + +bool MP4File::DeleteMetadataAtom(const char* name, bool try_udta) +{ + MP4Atom *pMetaAtom = NULL; + char s[256]; + + snprintf(s, 256, "moov.udta.meta.ilst.%s", name); + pMetaAtom = m_pRootAtom->FindAtom(s); + + if (pMetaAtom == NULL && try_udta) { + snprintf(s, 256, "moov.udta.%s", name); + pMetaAtom = m_pRootAtom->FindAtom(s); + } + /* if it exists, delete it */ + if (pMetaAtom) + { + MP4Atom *pParent = pMetaAtom->GetParentAtom(); + + pParent->DeleteChildAtom(pMetaAtom); + + delete pMetaAtom; + + return true; + } + + return false; +} + +bool MP4File::SetMetadataString (const char *atom, const char *value) +{ + char atomstring[40]; + MP4Atom *pMetaAtom; + MP4BytesProperty *pMetadataProperty = NULL; + snprintf(atomstring, 40, "moov.udta.meta.ilst.%s.data", atom); + + pMetaAtom = m_pRootAtom->FindAtom(atomstring); + + if (!pMetaAtom) + { + if (!CreateMetadataAtom(atom, itmf::BT_UTF8)) + return false; + + pMetaAtom = m_pRootAtom->FindAtom(atomstring); + if (pMetaAtom == NULL) return false; + } + + ASSERT(pMetaAtom->FindProperty("data.metadata", + (MP4Property**)&pMetadataProperty)); + ASSERT(pMetadataProperty); + + pMetadataProperty->SetValue((uint8_t*)value, strlen(value)); + + return true; +} + +bool MP4File::GetMetadataString (const char *atom, char **value, bool try_udta) +{ + unsigned char *val = NULL; + uint32_t valSize = 0; + char atomstring[60]; + snprintf(atomstring, 60, "moov.udta.meta.ilst.%s.data.metadata", atom); + + *value = NULL; + if (try_udta == false) { + GetBytesProperty(atomstring, (uint8_t**)&val, &valSize); + } else { + bool got_it = false; + try { + GetBytesProperty(atomstring, (uint8_t**)&val, &valSize); + got_it = true; + } + catch (MP4Error* e) { + delete e; + } + if (got_it == false) { + snprintf(atomstring, 60, "moov.udta.%s.metadata", atom); + GetBytesProperty(atomstring, (uint8_t**)&val, &valSize); + } + } + if (valSize > 0) + { + *value = (char*)malloc((valSize+1)*sizeof(char)); + if (*value == NULL) { + free(val); + return false; + } + memcpy(*value, val, valSize*sizeof(unsigned char)); + free(val); + (*value)[valSize] = '\0'; + return true; + } + return false; +} + +bool MP4File::SetMetadataTrack(uint16_t track, uint16_t totalTracks) +{ + unsigned char t[9]; + const char *s = "moov.udta.meta.ilst.trkn.data"; + MP4BytesProperty *pMetadataProperty = NULL; + MP4Atom *pMetaAtom = NULL; + + pMetaAtom = m_pRootAtom->FindAtom(s); + + if (!pMetaAtom) + { + if (!CreateMetadataAtom("trkn", itmf::BT_IMPLICIT)) + return false; + + pMetaAtom = m_pRootAtom->FindAtom(s); + if (pMetaAtom == NULL) return false; + } + + memset(t, 0, 9*sizeof(unsigned char)); + t[2] = (unsigned char)(track>>8)&0xFF; + t[3] = (unsigned char)(track)&0xFF; + t[4] = (unsigned char)(totalTracks>>8)&0xFF; + t[5] = (unsigned char)(totalTracks)&0xFF; + + ASSERT(pMetaAtom->FindProperty("data.metadata", + (MP4Property**)&pMetadataProperty)); + ASSERT(pMetadataProperty); + + pMetadataProperty->SetValue((uint8_t*)t, 8); + + return true; +} + +bool MP4File::GetMetadataTrack(uint16_t* track, uint16_t* totalTracks) +{ + unsigned char *val = NULL; + uint32_t valSize = 0; + const char *s = "moov.udta.meta.ilst.trkn.data.metadata"; + + *track = 0; + *totalTracks = 0; + + GetBytesProperty(s, (uint8_t**)&val, &valSize); + + if (valSize == 8) { + *track = (uint16_t)(val[3]); + *track += (uint16_t)(val[2]<<8); + *totalTracks = (uint16_t)(val[5]); + *totalTracks += (uint16_t)(val[4]<<8); + CHECK_AND_FREE(val); + return true; + } + CHECK_AND_FREE(val); + return false; +} + +bool MP4File::SetMetadataDisk(uint16_t disk, uint16_t totalDisks) +{ + unsigned char t[7]; + const char *s = "moov.udta.meta.ilst.disk.data"; + MP4BytesProperty *pMetadataProperty = NULL; + MP4Atom *pMetaAtom = NULL; + + pMetaAtom = m_pRootAtom->FindAtom(s); + + if (!pMetaAtom) + { + if (!CreateMetadataAtom("disk", itmf::BT_IMPLICIT)) + return false; + + pMetaAtom = m_pRootAtom->FindAtom(s); + if (pMetaAtom == NULL) return false; + } + + memset(t, 0, 7*sizeof(unsigned char)); + t[2] = (unsigned char)(disk>>8)&0xFF; + t[3] = (unsigned char)(disk)&0xFF; + t[4] = (unsigned char)(totalDisks>>8)&0xFF; + t[5] = (unsigned char)(totalDisks)&0xFF; + + ASSERT(pMetaAtom->FindProperty("data.metadata", + (MP4Property**)&pMetadataProperty)); + ASSERT(pMetadataProperty); + + pMetadataProperty->SetValue((uint8_t*)t, 6); + + return true; +} + +bool MP4File::GetMetadataDisk(uint16_t* disk, uint16_t* totalDisks) +{ + unsigned char *val = NULL; + uint32_t valSize = 0; + const char *s = "moov.udta.meta.ilst.disk.data.metadata"; + + *disk = 0; + *totalDisks = 0; + + GetBytesProperty(s, (uint8_t**)&val, &valSize); + + if (valSize == 6 || valSize == 8) { + *disk = (uint16_t)(val[3]); + *disk += (uint16_t)(val[2]<<8); + *totalDisks = (uint16_t)(val[5]); + *totalDisks += (uint16_t)(val[4]<<8); + free(val); + return true; + } + CHECK_AND_FREE(val); + return true; +} + +static const char* ID3v1GenreList[] = { + "Blues", "Classic Rock", "Country", "Dance", "Disco", "Funk", + "Grunge", "Hip-Hop", "Jazz", "Metal", "New Age", "Oldies", + "Other", "Pop", "R&B", "Rap", "Reggae", "Rock", + "Techno", "Industrial", "Alternative", "Ska", "Death Metal", "Pranks", + "Soundtrack", "Euro-Techno", "Ambient", "Trip-Hop", "Vocal", "Jazz+Funk", + "Fusion", "Trance", "Classical", "Instrumental", "Acid", "House", + "Game", "Sound Clip", "Gospel", "Noise", "AlternRock", "Bass", + "Soul", "Punk", "Space", "Meditative", "Instrumental Pop", "Instrumental Rock", + "Ethnic", "Gothic", "Darkwave", "Techno-Industrial", "Electronic", "Pop-Folk", + "Eurodance", "Dream", "Southern Rock", "Comedy", "Cult", "Gangsta", + "Top 40", "Christian Rap", "Pop/Funk", "Jungle", "Native American", "Cabaret", + "New Wave", "Psychedelic", "Rave", "Showtunes", "Trailer", "Lo-Fi", + "Tribal", "Acid Punk", "Acid Jazz", "Polka", "Retro", "Musical", + "Rock & Roll", "Hard Rock", "Folk", "Folk/Rock", "National Folk", "Swing", + "Fast-Fusion", "Bebob", "Latin", "Revival", "Celtic", "Bluegrass", "Avantgarde", + "Gothic Rock", "Progressive Rock", "Psychedelic Rock", "Symphonic Rock", "Slow Rock", "Big Band", + "Chorus", "Easy Listening", "Acoustic", "Humour", "Speech", "Chanson", + "Opera", "Chamber Music", "Sonata", "Symphony", "Booty Bass", "Primus", + "Porn Groove", "Satire", "Slow Jam", "Club", "Tango", "Samba", + "Folklore", "Ballad", "Power Ballad", "Rhythmic Soul", "Freestyle", "Duet", + "Punk Rock", "Drum Solo", "A capella", "Euro-House", "Dance Hall", + "Goa", "Drum & Bass", "Club House", "Hardcore", "Terror", + "Indie", "BritPop", "NegerPunk", "Polsk Punk", "Beat", + "Christian Gangsta", "Heavy Metal", "Black Metal", "Crossover", "Contemporary C", + "Christian Rock", "Merengue", "Salsa", "Thrash Metal", "Anime", "JPop", + "SynthPop", +}; + +void GenreToString(char** GenreStr, const int genre) +{ + if (genre > 0 && + genre <= (int)(sizeof(ID3v1GenreList)/sizeof(*ID3v1GenreList))) + { + uint32_t len = strlen(ID3v1GenreList[genre-1])+1; + *GenreStr = (char*)malloc(len); + if (*GenreStr == NULL) return; + // no need for strncpy; enough was malloced + strcpy(*GenreStr, ID3v1GenreList[genre-1]); + return; + } + *GenreStr = (char*)malloc(2*sizeof(char)); + if (*GenreStr == NULL) return; + memset(*GenreStr, 0, 2*sizeof(char)); + return; +} + +bool MP4File::SetMetadataGenre(const char* value) +{ + uint16_t genreIndex = 0; + unsigned char t[3]; + MP4BytesProperty *pMetadataProperty = NULL; + MP4Atom *pMetaAtom = NULL; + + genreIndex = static_cast<uint16_t>( itmf::enumGenreType.toType(value) ); + + const char *s = "moov.udta.meta.ilst.gnre.data"; + const char *sroot = "moov.udta.meta.ilst.gnre"; + const char *s2 = "moov.udta.meta.ilst.\251gen.data"; + const char *s2root = "moov.udta.meta.ilst.\251gen"; + if (genreIndex != 0) + { + pMetaAtom = m_pRootAtom->FindAtom(s); + if (!pMetaAtom) + { + if (!CreateMetadataAtom("gnre", itmf::BT_GENRES)) + return false; + + pMetaAtom = m_pRootAtom->FindAtom(s); + if (pMetaAtom == NULL) return false; + } + + memset(t, 0, 3*sizeof(unsigned char)); + t[0] = (unsigned char)(genreIndex>>8)&0xFF; + t[1] = (unsigned char)(genreIndex)&0xFF; + + ASSERT(pMetaAtom->FindProperty("data.metadata", + (MP4Property**)&pMetadataProperty)); + ASSERT(pMetadataProperty); + + pMetadataProperty->SetValue((uint8_t*)t, 2); + + // remove other style of genre atom, if this one is added + pMetaAtom = m_pRootAtom->FindAtom(s2root); + if (pMetaAtom != NULL) { + MP4Atom *pParent = pMetaAtom->GetParentAtom(); + if (pParent != NULL) { + pParent->DeleteChildAtom(pMetaAtom); + delete pMetaAtom; + } + } + + + (void)DeleteMetadataAtom( "\251gen" ); + + return true; + } else { + pMetaAtom = m_pRootAtom->FindAtom(s2); + + if (!pMetaAtom) + { + if (!CreateMetadataAtom("\251gen", itmf::BT_GENRES)) + return false; + + pMetaAtom = m_pRootAtom->FindAtom(s2); + } + + ASSERT(pMetaAtom->FindProperty("data.metadata", + (MP4Property**)&pMetadataProperty)); + ASSERT(pMetadataProperty); + + pMetadataProperty->SetValue((uint8_t*)value, strlen(value)); + + // remove other gnre atom if this one is entered + pMetaAtom = m_pRootAtom->FindAtom(sroot); + if (pMetaAtom != NULL) { + MP4Atom *pParent = pMetaAtom->GetParentAtom(); + pParent->DeleteChildAtom(pMetaAtom); + delete pMetaAtom; + } + return true; + } + + return false; +} + +bool MP4File::GetMetadataGenre(char** value) +{ + uint16_t genreIndex = 0; + unsigned char *val = NULL; + uint32_t valSize = 0; + const char *t = "moov.udta.meta.ilst.gnre"; + const char *t2 = "moov.udta.meta.ilst.\251gen"; + + *value = NULL; + + MP4Atom *gnre = FindAtom(t); + MP4Atom *cgen = FindAtom(t2); + + if (gnre) + { + const char *s = "moov.udta.meta.ilst.gnre.data.metadata"; + + GetBytesProperty(s, (uint8_t**)&val, &valSize); + + if (valSize != 2) { + CHECK_AND_FREE(val); + return false; + } + + genreIndex = (uint16_t)(val[1]); + genreIndex += (uint16_t)(val[0]<<8); + + GenreToString(value, genreIndex); + + (void)DeleteMetadataAtom( "gnre" ); + free(val); + return true; + } else if (cgen) { + const char *s2 = "moov.udta.meta.ilst.\251gen.data.metadata"; + + val = NULL; + valSize = 0; + + GetBytesProperty(s2, (uint8_t**)&val, &valSize); + + if (valSize > 0) + { + *value = (char*)malloc((valSize+1)*sizeof(unsigned char)); + if (*value != NULL) { + memset(*value, 0, (valSize+1)*sizeof(unsigned char)); + memcpy(*value, val, valSize*sizeof(unsigned char)); + } + free(val); + return true; + } + } + CHECK_AND_FREE(val); + return false; +} + +bool MP4File::DeleteMetadataGenre() +{ + bool val1 = DeleteMetadataAtom("\251gen"); + bool val2 = DeleteMetadataAtom("gnre"); + return val1 || val2; +} + +bool MP4File::SetMetadataUint8 (const char *atom, uint8_t value) +{ + char atompath[36]; + MP4BytesProperty *pMetadataProperty = NULL; + MP4Atom *pMetaAtom = NULL; + + snprintf(atompath, 36, "moov.udta.meta.ilst.%s.data", atom); + + pMetaAtom = m_pRootAtom->FindAtom(atompath); + + if (pMetaAtom == NULL) { + if (!CreateMetadataAtom(atom, itmf::BT_INTEGER)) + return false; + + pMetaAtom = m_pRootAtom->FindAtom(atompath); + if (pMetaAtom == NULL) return false; + } + + ASSERT(pMetaAtom->FindProperty("data.metadata", + (MP4Property**)&pMetadataProperty)); + ASSERT(pMetadataProperty); + + pMetadataProperty->SetValue(&value, 1); + + return true; +} + + +bool MP4File::GetMetadataUint8(const char *atom, uint8_t* retvalue) +{ + unsigned char *val = NULL; + uint32_t valSize = 0; + char atompath[80]; + snprintf(atompath, 80, "moov.udta.meta.ilst.%s.data.metadata", atom); + + *retvalue = 0; + + GetBytesProperty(atompath, (uint8_t**)&val, &valSize); + + if (valSize != 1) { + CHECK_AND_FREE(val); + return false; + } + + *retvalue = val[0]; + free(val); + return true; +} + +bool MP4File::SetMetadataUint16(const char *atom, uint16_t value) +{ + char atompath[36]; + unsigned char t[3]; + MP4BytesProperty *pMetadataProperty = NULL; + MP4Atom *pMetaAtom = NULL; + + snprintf(atompath, 36, "moov.udta.meta.ilst.%s.data", atom); + + pMetaAtom = m_pRootAtom->FindAtom(atompath); + + if (!pMetaAtom) + { + if (!CreateMetadataAtom(atom, itmf::BT_INTEGER)) + return false; + + pMetaAtom = m_pRootAtom->FindAtom(atompath); + if (pMetaAtom == NULL) return false; + } + + memset(t, 0, 3*sizeof(unsigned char)); + t[0] = (unsigned char)(value>>8)&0xFF; + t[1] = (unsigned char)(value)&0xFF; + + ASSERT(pMetaAtom->FindProperty("data.metadata", + (MP4Property**)&pMetadataProperty)); + ASSERT(pMetadataProperty); + + pMetadataProperty->SetValue((uint8_t*)t, 2); + + return true; +} + +bool MP4File::GetMetadataUint16(const char *atom, uint16_t* retvalue) +{ + unsigned char *val = NULL; + uint32_t valSize = 0; + char atompath[80]; + snprintf(atompath, 80, "moov.udta.meta.ilst.%s.data.metadata", atom); + + *retvalue = 0; + + GetBytesProperty(atompath, (uint8_t**)&val, &valSize); + + if (valSize != 2) { + CHECK_AND_FREE(val); + return false; + } + + *retvalue = (uint16_t)(val[1]); + *retvalue += (uint16_t)(val[0]<<8); + free(val); + return true; +} + + +bool MP4File::SetMetadataUint32(const char *atom, uint32_t value) +{ + char atompath[36]; + unsigned char t[5]; + MP4BytesProperty *pMetadataProperty = NULL; + MP4Atom *pMetaAtom = NULL; + + snprintf(atompath, 36, "moov.udta.meta.ilst.%s.data", atom); + + pMetaAtom = m_pRootAtom->FindAtom(atompath); + + if (pMetaAtom == NULL) { + if (!CreateMetadataAtom(atom, itmf::BT_INTEGER)) + return false; + + pMetaAtom = m_pRootAtom->FindAtom(atompath); + if (pMetaAtom == NULL) return false; + } + + memset(t, 0, 5*sizeof(unsigned char)); + t[0] = (unsigned char)(value>>24)&0xFF; + t[1] = (unsigned char)(value>>16)&0xFF; + t[2] = (unsigned char)(value>>8)&0xFF; + t[3] = (unsigned char)(value)&0xFF; + + + ASSERT(pMetaAtom->FindProperty("data.metadata", + (MP4Property**)&pMetadataProperty)); + ASSERT(pMetadataProperty); + + pMetadataProperty->SetValue((uint8_t*)t, 4); + + return true; +} + +bool MP4File::GetMetadataUint32(const char *atom, uint32_t* retvalue) +{ + unsigned char *val = NULL; + uint32_t valSize = 0; + char atompath[80]; + snprintf(atompath, 80, "moov.udta.meta.ilst.%s.data.metadata", atom); + + *retvalue = 0; + + GetBytesProperty(atompath, (uint8_t**)&val, &valSize); + + if (valSize != 4) { + CHECK_AND_FREE(val); + return false; + } + + *retvalue = val[3]; + *retvalue += (uint32_t)(val[2]<<8); + *retvalue += (uint32_t)(val[1]<<16); + *retvalue += (uint32_t)(val[0]<<24); + free(val); + return true; +} + +bool MP4File::SetMetadataCoverArt(uint8_t *coverArt, uint32_t size) +{ + const char *s = "moov.udta.meta.ilst.covr.data"; + MP4BytesProperty *pMetadataProperty = NULL; + MP4Atom *pMetaAtom = NULL; + + pMetaAtom = m_pRootAtom->FindAtom(s); + + if (!pMetaAtom) + { + if (!CreateMetadataAtom("covr", itmf::BT_IMPLICIT)) + return false; + + pMetaAtom = m_pRootAtom->FindAtom(s); + if (pMetaAtom == NULL) return false; + } + + ASSERT(pMetaAtom->FindProperty("data.metadata", + (MP4Property**)&pMetadataProperty)); + ASSERT(pMetadataProperty); + + pMetadataProperty->SetValue(coverArt, size); + + return true; +} + +bool MP4File::GetMetadataCoverArtPosition(uint32_t *start, uint32_t* size, + uint32_t index) +{ + char buffer[256]; + if (start == NULL || size == NULL) return false; + + if (index > 0 && index > GetMetadataCoverArtCount()) return false; + + snprintf(buffer, 256, "moov.udta.meta.ilst.covr.data[%d].metadata", index); + + *start = 0; + *size = 0; + + MP4Property* pProperty = NULL; + + FindBytesProperty(buffer, &pProperty, size); + + if (size == 0 || pProperty == NULL) + return false; + + *start = ((MP4BytesProperty*)pProperty)->GetValueStart(index); + *size = ((MP4BytesProperty*)pProperty)->GetValueSize(0, index); + + return true; +} + +bool MP4File::GetMetadataCoverArt(uint8_t **coverArt, uint32_t *size, + uint32_t index) +{ + char buffer[256]; + if (size == NULL || coverArt == NULL) return false; + + if (index > 0 && index > GetMetadataCoverArtCount()) return false; + + snprintf(buffer, 256, "moov.udta.meta.ilst.covr.data[%d].metadata", index); + + *coverArt = NULL; + *size = 0; + + GetBytesProperty(buffer, coverArt, size); + + if (size == 0) + return false; + + return true; +} + +uint32_t MP4File::GetMetadataCoverArtCount (void) +{ + MP4Atom *pMetaAtom = m_pRootAtom->FindAtom("moov.udta.meta.ilst.covr"); + if (!pMetaAtom) + return 0; + + return pMetaAtom->GetNumberOfChildAtoms(); +} + +bool MP4File::SetMetadataFreeForm (const char *name, + const uint8_t* pValue, + uint32_t valueSize, + const char *owner) +{ + MP4Atom *pMetaAtom = NULL; + MP4BytesProperty *pMetadataProperty = NULL; + char s[256]; + int i = 0; + size_t nameLen = strlen(name); + size_t ownerLen = owner != NULL ? strlen(owner) : 0; + + while (1) + { + snprintf(s, 256, "moov.udta.meta.ilst.----[%u].name", i); + + MP4Atom *pTagAtom = m_pRootAtom->FindAtom(s); + + if (!pTagAtom) + break; + + snprintf(s, 256, "moov.udta.meta.ilst.----[%u].mean", i); + + MP4Atom *pMeanAtom = m_pRootAtom->FindAtom(s); + + if (pTagAtom->FindProperty("name.metadata", + (MP4Property**)&pMetadataProperty) && + pMetadataProperty) { + uint8_t* pV; + uint32_t VSize = 0; + + pMetadataProperty->GetValue(&pV, &VSize); + + if (VSize == nameLen && memcmp(pV, name, VSize) == 0) { + uint8_t* pOwner=0; + uint32_t ownerSize = 0; + + if (pMeanAtom && + pMeanAtom->FindProperty("mean.metadata", + (MP4Property**)&pMetadataProperty) && + pMetadataProperty) { + pMetadataProperty->GetValue(&pOwner, &ownerSize); + } + + if (owner == NULL|| + (pOwner && + ownerLen == ownerSize && + memcmp(owner, pOwner, ownerSize))) { + snprintf(s, 256, "moov.udta.meta.ilst.----[%u].data.metadata", i); + SetBytesProperty(s, pValue, valueSize); + CHECK_AND_FREE(pV); + CHECK_AND_FREE(pOwner); + + return true; + } + CHECK_AND_FREE(pOwner); + } + CHECK_AND_FREE(pV); + } + + i++; + } + + /* doesn't exist yet, create it */ + char t[256]; + + snprintf(t, 256, "udta.meta.ilst.----[%u]", i); + snprintf(s, 256, "moov.udta.meta.ilst.----[%u].data", i); + (void)AddDescendantAtoms("moov", t); + + pMetaAtom = m_pRootAtom->FindAtom(s); + + if (!pMetaAtom) + return false; + + // all ilst data atoms are of MP4DataAtom type. + ((MP4DataAtom*)pMetaAtom)->typeCode.SetValue( itmf::BT_UTF8 ); + + MP4Atom *pHdlrAtom = m_pRootAtom->FindAtom("moov.udta.meta.hdlr"); + MP4StringProperty *pStringProperty = NULL; + MP4BytesProperty *pBytesProperty = NULL; + ASSERT(pHdlrAtom); + + ASSERT(pHdlrAtom->FindProperty("hdlr.handlerType", + (MP4Property**)&pStringProperty)); + ASSERT(pStringProperty); + pStringProperty->SetValue("mdir"); + + uint8_t val[12]; + memset(val, 0, 12*sizeof(uint8_t)); + val[0] = 0x61; + val[1] = 0x70; + val[2] = 0x70; + val[3] = 0x6c; + ASSERT(pHdlrAtom->FindProperty("hdlr.reserved2", + (MP4Property**)&pBytesProperty)); + ASSERT(pBytesProperty); + pBytesProperty->SetReadOnly(false); + pBytesProperty->SetValue(val, 12); + pBytesProperty->SetReadOnly(true); + + pMetaAtom = m_pRootAtom->FindAtom(s); + ASSERT(pMetaAtom); + ASSERT(pMetaAtom->FindProperty("data.metadata", + (MP4Property**)&pMetadataProperty)); + ASSERT(pMetadataProperty); + pMetadataProperty->SetValue(pValue, valueSize); + + snprintf(s, 256, "moov.udta.meta.ilst.----[%u].name", i); + pMetaAtom = m_pRootAtom->FindAtom(s); + ASSERT(pMetaAtom->FindProperty("name.metadata", + (MP4Property**)&pMetadataProperty)); + ASSERT(pMetadataProperty); + pMetadataProperty->SetValue((const uint8_t*)name, strlen(name)); + + snprintf(s, 256, "moov.udta.meta.ilst.----[%u].mean", i); + pMetaAtom = m_pRootAtom->FindAtom(s); + ASSERT(pMetaAtom->FindProperty("mean.metadata", + (MP4Property**)&pMetadataProperty)); + ASSERT(pMetadataProperty); + if (!owner || !*owner) + pMetadataProperty->SetValue((uint8_t*)"com.apple.iTunes", 16); /* com.apple.iTunes is the default*/ + else + pMetadataProperty->SetValue((const uint8_t*)owner, strlen((const char *)owner)); + + return true; +} + +bool MP4File::GetMetadataFreeForm(const char *name, + uint8_t** ppValue, + uint32_t *pValueSize, + const char *owner) +{ + char s[256]; + int i = 0; + + *ppValue = NULL; + *pValueSize = 0; + + size_t nameLen = strlen(name); + size_t ownerLen = owner?strlen(owner):0; + + while (1) + { + MP4BytesProperty *pMetadataProperty; + + snprintf(s, 256,"moov.udta.meta.ilst.----[%u].name", i); + MP4Atom *pTagAtom = m_pRootAtom->FindAtom(s); + + snprintf(s, 256,"moov.udta.meta.ilst.----[%u].mean", i); + MP4Atom *pMeanAtom = m_pRootAtom->FindAtom(s); + + if (!pTagAtom) + return false; + + if (pTagAtom->FindProperty("name.metadata", + (MP4Property**)&pMetadataProperty) && + pMetadataProperty) { + uint8_t* pV; + uint32_t VSize = 0; + + pMetadataProperty->GetValue(&pV, &VSize); + + if (VSize == nameLen && memcmp(pV, name, VSize) == 0) { + uint8_t* pOwner=0; + uint32_t ownerSize = 0; + + if (pMeanAtom && pMeanAtom->FindProperty("mean.metadata", + (MP4Property**)&pMetadataProperty) && + pMetadataProperty) { + pMetadataProperty->GetValue(&pOwner, &ownerSize); + } + + if (!owner || (pOwner && ownerLen == ownerSize && memcmp(owner, pOwner, ownerSize))) { + snprintf(s, 256, "moov.udta.meta.ilst.----[%u].data.metadata", i); + GetBytesProperty(s, ppValue, pValueSize); + CHECK_AND_FREE(pV); + CHECK_AND_FREE(pOwner); + return true; + } + CHECK_AND_FREE(pOwner); + } + CHECK_AND_FREE(pV); + } + + i++; + } +} + +bool MP4File::DeleteMetadataFreeForm(const char *name, const char *owner) +{ + char s[256]; + int i = 0; + + size_t nameLen = strlen(name); + size_t ownerLen = owner?strlen(owner):0; + + while (1) + { + MP4BytesProperty *pMetadataProperty; + + snprintf(s, 256, "moov.udta.meta.ilst.----[%u].name", i); + MP4Atom *pTagAtom = m_pRootAtom->FindAtom(s); + + snprintf(s, 256,"moov.udta.meta.ilst.----[%u].mean", i); + MP4Atom *pMeanAtom = m_pRootAtom->FindAtom(s); + + + if (!pTagAtom) + return false; + + if (pTagAtom->FindProperty("name.metadata", + (MP4Property**)&pMetadataProperty) && + pMetadataProperty) { + uint8_t* pV; + uint32_t VSize = 0; + + pMetadataProperty->GetValue(&pV, &VSize); + + if (VSize != 0) + { + if (VSize == nameLen && memcmp(pV, name, VSize) == 0) + { + uint8_t* pOwner=0; + uint32_t ownerSize = 0; + + if (pMeanAtom && pMeanAtom->FindProperty("mean.metadata", + (MP4Property**)&pMetadataProperty) && + pMetadataProperty) + { + pMetadataProperty->GetValue(&pOwner, &ownerSize); + } + + if (!owner || (pOwner && ownerLen == ownerSize && memcmp(owner, pOwner, ownerSize))) + { + snprintf(s, 256, "----[%u]", i); + CHECK_AND_FREE(pOwner); + CHECK_AND_FREE(pV); + return DeleteMetadataAtom(s); + } + CHECK_AND_FREE(pOwner); + + } + } + CHECK_AND_FREE(pV); + } + + i++; + } +} + +bool MP4File::MetadataDelete() +{ + MP4Atom *pMetaAtom = NULL; + char s[256]; + + snprintf(s, 256, "moov.udta.meta"); + pMetaAtom = m_pRootAtom->FindAtom(s); + + /* if it exists, delete it */ + if (pMetaAtom) + { + MP4Atom *pParent = pMetaAtom->GetParentAtom(); + + pParent->DeleteChildAtom(pMetaAtom); + + delete pMetaAtom; + + return true; + } + + return false; +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/mp4property.cpp b/src/mp4property.cpp new file mode 100644 index 0000000..063a273 --- /dev/null +++ b/src/mp4property.cpp @@ -0,0 +1,1237 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + * Kona Blend kona8lend@@gmail.com + */ + +#include "src/impl.h" + +namespace mp4v2 { namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4Property::MP4Property(const char* name) +{ + m_name = name; + m_pParentAtom = NULL; + m_readOnly = false; + m_implicit = false; +} + +bool MP4Property::FindProperty(const char* name, + MP4Property** ppProperty, uint32_t* pIndex) +{ + if (name == NULL) { + return false; + } + + if (!strcasecmp(m_name, name)) { + if (m_pParentAtom) { + VERBOSE_FIND(m_pParentAtom->GetFile()->GetVerbosity(), + printf("FindProperty: matched %s\n", name)); + } + + *ppProperty = this; + return true; + } + return false; +} + +// Integer Property + +uint64_t MP4IntegerProperty::GetValue(uint32_t index) +{ + switch (this->GetType()) { + case Integer8Property: + return ((MP4Integer8Property*)this)->GetValue(index); + case Integer16Property: + return ((MP4Integer16Property*)this)->GetValue(index); + case Integer24Property: + return ((MP4Integer24Property*)this)->GetValue(index); + case Integer32Property: + return ((MP4Integer32Property*)this)->GetValue(index); + case Integer64Property: + return ((MP4Integer64Property*)this)->GetValue(index); + default: + ASSERT(false); + } + return (0); +} + +void MP4IntegerProperty::SetValue(uint64_t value, uint32_t index) +{ + switch (this->GetType()) { + case Integer8Property: + ((MP4Integer8Property*)this)->SetValue(value, index); + break; + case Integer16Property: + ((MP4Integer16Property*)this)->SetValue(value, index); + break; + case Integer24Property: + ((MP4Integer24Property*)this)->SetValue(value, index); + break; + case Integer32Property: + ((MP4Integer32Property*)this)->SetValue(value, index); + break; + case Integer64Property: + ((MP4Integer64Property*)this)->SetValue(value, index); + break; + default: + ASSERT(false); + } +} + +void MP4IntegerProperty::InsertValue(uint64_t value, uint32_t index) +{ + switch (this->GetType()) { + case Integer8Property: + ((MP4Integer8Property*)this)->InsertValue(value, index); + break; + case Integer16Property: + ((MP4Integer16Property*)this)->InsertValue(value, index); + break; + case Integer24Property: + ((MP4Integer24Property*)this)->InsertValue(value, index); + break; + case Integer32Property: + ((MP4Integer32Property*)this)->InsertValue(value, index); + break; + case Integer64Property: + ((MP4Integer64Property*)this)->InsertValue(value, index); + break; + default: + ASSERT(false); + } +} + +void MP4IntegerProperty::DeleteValue(uint32_t index) +{ + switch (this->GetType()) { + case Integer8Property: + ((MP4Integer8Property*)this)->DeleteValue(index); + break; + case Integer16Property: + ((MP4Integer16Property*)this)->DeleteValue(index); + break; + case Integer24Property: + ((MP4Integer24Property*)this)->DeleteValue(index); + break; + case Integer32Property: + ((MP4Integer32Property*)this)->DeleteValue(index); + break; + case Integer64Property: + ((MP4Integer64Property*)this)->DeleteValue(index); + break; + default: + ASSERT(false); + } +} + +void MP4IntegerProperty::IncrementValue(int32_t increment, uint32_t index) +{ + SetValue(GetValue() + increment); +} + +void MP4Integer8Property::Dump(FILE* pFile, uint8_t indent, + bool dumpImplicits, uint32_t index) +{ + if (m_implicit && !dumpImplicits) { + return; + } + Indent(pFile, indent); + if (index != 0) + fprintf(pFile, "%s[%u] = %u (0x%02x)\n", + m_name, index, m_values[index], m_values[index]); + else + fprintf(pFile, "%s = %u (0x%02x)\n", + m_name, m_values[index], m_values[index]); + fflush(pFile); +} + +void MP4Integer16Property::Dump(FILE* pFile, uint8_t indent, + bool dumpImplicits, uint32_t index) +{ + if (m_implicit && !dumpImplicits) { + return; + } + Indent(pFile, indent); + if (index != 0) + fprintf(pFile, "%s[%u] = %u (0x%04x)\n", + m_name, index, m_values[index], m_values[index]); + else + fprintf(pFile, "%s = %u (0x%04x)\n", + m_name, m_values[index], m_values[index]); + fflush(pFile); +} + +void MP4Integer24Property::Dump(FILE* pFile, uint8_t indent, + bool dumpImplicits, uint32_t index) +{ + if (m_implicit && !dumpImplicits) { + return; + } + Indent(pFile, indent); + if (index != 0) + fprintf(pFile, "%s[%u] = %u (0x%06x)\n", + m_name, index, m_values[index], m_values[index]); + else + fprintf(pFile, "%s = %u (0x%06x)\n", + m_name, m_values[index], m_values[index]); + fflush(pFile); +} + +void MP4Integer32Property::Dump(FILE* pFile, uint8_t indent, + bool dumpImplicits, uint32_t index) +{ + if (m_implicit && !dumpImplicits) { + return; + } + Indent(pFile, indent); + if (index != 0) + fprintf(pFile, "%s[%u] = %u (0x%08x)\n", + m_name, index, m_values[index], m_values[index]); + else + fprintf(pFile, "%s = %u (0x%08x)\n", + m_name, m_values[index], m_values[index]); + fflush(pFile); +} + +void MP4Integer64Property::Dump(FILE* pFile, uint8_t indent, + bool dumpImplicits, uint32_t index) +{ + if (m_implicit && !dumpImplicits) { + return; + } + Indent(pFile, indent); + if (index != 0) + fprintf(pFile, "%s[%u] = %" PRIu64 " (0x%016" PRIx64 ")\n", + m_name, index, m_values[index], m_values[index]); + else + fprintf(pFile, + "%s = %" PRIu64 " (0x%016" PRIx64 ")\n", + m_name, m_values[index], m_values[index]); + fflush(pFile); +} + +// MP4BitfieldProperty + +void MP4BitfieldProperty::Read(MP4File* pFile, uint32_t index) +{ + if (m_implicit) { + return; + } + m_values[index] = pFile->ReadBits(m_numBits); +} + +void MP4BitfieldProperty::Write(MP4File* pFile, uint32_t index) +{ + if (m_implicit) { + return; + } + pFile->WriteBits(m_values[index], m_numBits); +} + +void MP4BitfieldProperty::Dump(FILE* pFile, uint8_t indent, + bool dumpImplicits, uint32_t index) +{ + if (m_implicit && !dumpImplicits) { + return; + } + Indent(pFile, indent); + + uint8_t hexWidth = m_numBits / 4; + if (hexWidth == 0 || (m_numBits % 4)) { + hexWidth++; + } + if (index != 0) + fprintf(pFile, + "%s[%u] = %" PRIu64 " (0x%0*" PRIx64 ") <%u bits>\n", + m_name, index, m_values[index], (int)hexWidth, m_values[index], m_numBits); + else + fprintf(pFile, + "%s = %" PRIu64 " (0x%0*" PRIx64 ") <%u bits>\n", + m_name, m_values[index], (int)hexWidth, m_values[index], m_numBits); + fflush(pFile); +} + +// MP4Float32Property + +void MP4Float32Property::Read(MP4File* pFile, uint32_t index) +{ + if (m_implicit) { + return; + } + if (m_useFixed16Format) { + m_values[index] = pFile->ReadFixed16(); + } else if (m_useFixed32Format) { + m_values[index] = pFile->ReadFixed32(); + } else { + m_values[index] = pFile->ReadFloat(); + } +} + +void MP4Float32Property::Write(MP4File* pFile, uint32_t index) +{ + if (m_implicit) { + return; + } + if (m_useFixed16Format) { + pFile->WriteFixed16(m_values[index]); + } else if (m_useFixed32Format) { + pFile->WriteFixed32(m_values[index]); + } else { + pFile->WriteFloat(m_values[index]); + } +} + +void MP4Float32Property::Dump(FILE* pFile, uint8_t indent, + bool dumpImplicits, uint32_t index) +{ + if (m_implicit && !dumpImplicits) { + return; + } + Indent(pFile, indent); + if (index != 0) + fprintf(pFile, "%s[%u] = %f\n", + m_name, index, m_values[index]); + else + fprintf(pFile, "%s = %f\n", + m_name, m_values[index]); + fflush(pFile); +} + +// MP4StringProperty + +MP4StringProperty::MP4StringProperty( + const char* name, + bool useCountedFormat, + bool useUnicode, + bool arrayMode ) + + : MP4Property( name ) + , m_arrayMode ( arrayMode ) + , m_useCountedFormat ( useCountedFormat ) + , m_useExpandedCount ( false ) + , m_useUnicode ( useUnicode ) + , m_fixedLength ( 0 ) + , m_fixedLengthSet ( false ) +{ + SetCount( 1 ); + m_values[0] = NULL; +} + +MP4StringProperty::~MP4StringProperty() +{ + uint32_t count = GetCount(); + for (uint32_t i = 0; i < count; i++) { + MP4Free(m_values[i]); + } +} + +void MP4StringProperty::SetCount(uint32_t count) +{ + uint32_t oldCount = m_values.Size(); + + m_values.Resize(count); + + for (uint32_t i = oldCount; i < count; i++) { + m_values[i] = NULL; + } +} + +void MP4StringProperty::SetValue(const char* value, uint32_t index) +{ + if (m_readOnly) { + throw new MP4Error(EACCES, "property is read-only", m_name); + } + + MP4Free(m_values[index]); + + if (m_fixedLengthSet) { + m_values[index] = (char*)MP4Calloc(m_fixedLength + 1); + if (value) { + strncpy(m_values[index], value, m_fixedLength); + } + } else { + if (value) { + m_values[index] = MP4Stralloc(value); + } else { + m_values[index] = NULL; + } + } +} + +void MP4StringProperty::Read( MP4File* pFile, uint32_t index ) +{ + if( m_implicit ) + return; + + uint32_t begin = index; + uint32_t max = index + 1; + + if( m_arrayMode ) { + begin = 0; + max = GetCount(); + } + + for( uint32_t i = begin; i < max; i++ ) { + char*& value = m_values[i]; + + if( m_useCountedFormat ) { + value = pFile->ReadCountedString( (m_useUnicode ? 2 : 1), m_useExpandedCount, m_fixedLength ); + } + else if( m_fixedLengthSet ) { + // gfinlayson + // Handle the case where a fixed length of 0 was set, in as defensive a way + // as possible + MP4Free( value ); + value = (char*)MP4Calloc( m_fixedLength + 1 ); + if ( m_fixedLength ) { + pFile->ReadBytes( (uint8_t*)value, m_fixedLength ); + } + } + else { + value = pFile->ReadString(); + } + } +} + +void MP4StringProperty::Write( MP4File* pFile, uint32_t index ) +{ + if( m_implicit ) + return; + + uint32_t begin = index; + uint32_t max = index + 1; + + if( m_arrayMode ) { + begin = 0; + max = GetCount(); + } + + for( uint32_t i = begin; i < max; i++ ) { + char*& value = m_values[i]; + + if( m_useCountedFormat ) { + pFile->WriteCountedString( value, (m_useUnicode ? 2 : 1), m_useExpandedCount, m_fixedLength ); + } + else if( m_fixedLength ) { + pFile->WriteBytes( (uint8_t*)value, m_fixedLength ); + } + else { + pFile->WriteString( value ); + } + } +} + +void MP4StringProperty::Dump( FILE* pFile, uint8_t indent, bool dumpImplicits, uint32_t index ) +{ + if( m_implicit && !dumpImplicits ) + return; + + if( !m_arrayMode ) { + char indexd[32]; + if( index != 0 ) + snprintf( indexd, 32, "[%u]", index ); + else + indexd[0] = '\0'; + + Indent( pFile, indent ); + if( m_useUnicode ) + fprintf( pFile, "%s%s = %ls\n", m_name, indexd, (wchar_t*)m_values[index] ); + else + fprintf( pFile, "%s%s = %s\n", m_name, indexd, m_values[index] ); + } + else if( !m_pParentAtom || + !m_pParentAtom->GetFile() || + (m_pParentAtom->GetFile()->GetVerbosity() & MP4_DETAILS_TABLE) ) + { + const uint32_t max = GetCount(); + + Indent( pFile, indent ); + fprintf( pFile, "%s (size=%u)\n", m_name, max ); + + for( uint32_t i = 0; i < max; i++ ) { + char*& value = m_values[i]; + + Indent( pFile, indent ); + if( m_useUnicode ) + fprintf( pFile, "%s[%u] = %ls\n", m_name, i, (wchar_t*)value ); + else + fprintf( pFile, "%s[%u] = %s\n", m_name, i, value ); + } + } + else { + Indent( pFile, indent ); + fprintf( pFile, "<table entries suppressed>\n" ); + } + + fflush( pFile ); +} + +// MP4BytesProperty + +MP4BytesProperty::MP4BytesProperty(const char* name, uint32_t valueSize, + uint32_t defaultValueSize) + : MP4Property(name) + , m_fixedValueSize(0) + , m_defaultValueSize(defaultValueSize) +{ + SetCount(1); + m_values[0] = (uint8_t*)MP4Calloc(valueSize); + m_valueSizes[0] = valueSize; +} + +MP4BytesProperty::~MP4BytesProperty() +{ + uint32_t count = GetCount(); + for (uint32_t i = 0; i < count; i++) { + MP4Free(m_values[i]); + } +} + +void MP4BytesProperty::SetCount(uint32_t count) +{ + uint32_t oldCount = m_values.Size(); + + m_values.Resize(count); + m_valueSizes.Resize(count); + m_valueStart.Resize(count); + + for (uint32_t i = oldCount; i < count; i++) { + m_values[i] = NULL; + m_valueSizes[i] = m_defaultValueSize; + } +} + +void MP4BytesProperty::SetValue(const uint8_t* pValue, uint32_t valueSize, + uint32_t index) +{ + if (m_readOnly) { + throw new MP4Error(EACCES, "property is read-only", m_name); + } + if (m_fixedValueSize) { + if (valueSize > m_fixedValueSize) { + throw new MP4Error("%s.%s value size %d exceeds fixed value size %d", + "MP4BytesProperty::SetValue", + GetParentAtom()->GetType(), + GetName(), + valueSize, + m_fixedValueSize); + } + if (m_values[index] == NULL) { + m_values[index] = (uint8_t*)MP4Calloc(m_fixedValueSize); + m_valueSizes[index] = m_fixedValueSize; + } + if (pValue) { + memcpy(m_values[index], pValue, valueSize); + } + } else { + MP4Free(m_values[index]); + if (pValue) { + m_values[index] = (uint8_t*)MP4Malloc(valueSize); + memcpy(m_values[index], pValue, valueSize); + m_valueSizes[index] = valueSize; + } else { + m_values[index] = NULL; + m_valueSizes[index] = 0; + } + } +} + +void MP4BytesProperty::SetValueSize(uint32_t valueSize, uint32_t index) +{ + if (m_fixedValueSize) { + throw new MP4Error("can't change size of fixed sized property", + "MP4BytesProperty::SetValueSize"); + } + if (m_values[index] != NULL) { + m_values[index] = (uint8_t*)MP4Realloc(m_values[index], valueSize); + } + m_valueSizes[index] = valueSize; +} + +void MP4BytesProperty::SetFixedSize(uint32_t fixedSize) +{ + m_fixedValueSize = 0; + for (uint32_t i = 0; i < GetCount(); i++) { + SetValueSize(fixedSize, i); + } + m_fixedValueSize = fixedSize; +} + +void MP4BytesProperty::Read(MP4File* pFile, uint32_t index) +{ + if (m_implicit) { + return; + } + MP4Free(m_values[index]); + m_valueStart[index] = pFile->GetPosition(); + m_values[index] = (uint8_t*)MP4Malloc(m_valueSizes[index]); + pFile->ReadBytes(m_values[index], m_valueSizes[index]); +} + +void MP4BytesProperty::Write(MP4File* pFile, uint32_t index) +{ + if (m_implicit) { + return; + } + pFile->WriteBytes(m_values[index], m_valueSizes[index]); +} + +void MP4BytesProperty::Dump(FILE* pFile, uint8_t indent, + bool dumpImplicits, uint32_t index) +{ + if( m_implicit && !dumpImplicits ) + return; + + const uint32_t size = m_valueSizes[index]; + const uint8_t* const value = m_values[index]; + + Indent( pFile, indent ); + fprintf( pFile, "%s = <%u bytes>", m_name, size ); + + if( size == 0 ) { + fprintf( pFile, "\n" ); + fflush( pFile ); + return; + } + + if( size <= 16 ) { + ostringstream oss; + ostringstream text; + + oss << " "; + for( uint32_t i = 0; i < size; i++ ) { + if( i ) + oss << ' '; + oss << hex << setw(2) << setfill('0') << right << static_cast<uint32_t>(value[i]); + text << (isprint( static_cast<int>(value[i]) ) ? static_cast<char>(value[i]) : '.'); + } + + oss << " |" << text.str() << "|\n"; + + fprintf( pFile, oss.str().c_str() ); + fflush( pFile ); + return; + } + + uint32_t adjsize; + bool supressed; + + if( size < 128 || + !m_pParentAtom || + !m_pParentAtom->GetFile() || + (m_pParentAtom->GetFile()->GetVerbosity() & MP4_DETAILS_TABLE) ) + { + adjsize = size; + supressed = false; + } + else { + adjsize = 128; + supressed = true; + } + + ostringstream oss; + ostringstream text; + + string s; + for( uint32_t i = 0; i < adjsize; i++ ) { + if( i % 16 == 0 ) { + // not safe to use format because bytes may contain format specifies + s = oss.str(); + fwrite( s.c_str(), s.length(), 1, pFile ); + + oss.str( "" ); + oss << '\n' + << setw(indent) << setfill(' ') << "" + << hex << setw(8) << setfill('0') << right << i; + + if( i > 0 ) { + fprintf( pFile, " |" ); + + // not safe to use format because bytes may contain format specifies + s = text.str(); + fwrite( s.c_str(), s.length(), 1, pFile ); + + fprintf( pFile, "|" ); + text.str( "" ); + } + + fflush( pFile ); + } + + if( i % 8 == 0 ) + oss << ' '; + + oss << ' ' << hex << setw(2) << setfill('0') << right << static_cast<uint32_t>(value[i]); + text << (isprint( static_cast<int>(value[i]) ) ? static_cast<char>(value[i]) : '.'); + } + + const string stext = text.str(); + if( !stext.empty() ) { + const string::size_type deficit = 16 - stext.length(); + if( deficit > 7 ) + oss << ' '; + + oss << setfill(' ') << setw( deficit*3 ) << "" << " |" << stext << '|'; + } + + oss << "\n"; + + if( supressed ) { + oss << setw(indent) << setfill(' ') << "" + << "<remaining bytes supressed>\n"; + } + + // not safe to use format because bytes may contain format specifies + s = oss.str(); + fwrite( s.c_str(), s.length(), 1, pFile ); + + fflush( pFile ); +} + +// MP4TableProperty + +MP4TableProperty::MP4TableProperty(const char* name, MP4IntegerProperty* pCountProperty) + : MP4Property(name) +{ + m_pCountProperty = pCountProperty; + m_pCountProperty->SetReadOnly(); +} + +MP4TableProperty::~MP4TableProperty() +{ + for (uint32_t i = 0; i < m_pProperties.Size(); i++) { + delete m_pProperties[i]; + } +} + +void MP4TableProperty::AddProperty(MP4Property* pProperty) +{ + ASSERT(pProperty); + ASSERT(pProperty->GetType() != TableProperty); + ASSERT(pProperty->GetType() != DescriptorProperty); + m_pProperties.Add(pProperty); + pProperty->SetParentAtom(m_pParentAtom); + pProperty->SetCount(0); +} + +bool MP4TableProperty::FindProperty(const char *name, + MP4Property** ppProperty, uint32_t* pIndex) +{ + ASSERT(m_name); + + // check if first component of name matches ourselves + if (!MP4NameFirstMatches(m_name, name)) { + return false; + } + + // check if the specified table entry exists + uint32_t index; + bool haveIndex = MP4NameFirstIndex(name, &index); + if (haveIndex) { + if (index >= GetCount()) { + return false; + } + if (pIndex) { + *pIndex = index; + } + } + + VERBOSE_FIND(m_pParentAtom->GetFile()->GetVerbosity(), + printf("FindProperty: matched %s\n", name)); + + // get name of table property + const char *tablePropName = MP4NameAfterFirst(name); + if (tablePropName == NULL) { + if (!haveIndex) { + *ppProperty = this; + return true; + } + return false; + } + + // check if this table property exists + return FindContainedProperty(tablePropName, ppProperty, pIndex); +} + +bool MP4TableProperty::FindContainedProperty(const char *name, + MP4Property** ppProperty, uint32_t* pIndex) +{ + uint32_t numProperties = m_pProperties.Size(); + + for (uint32_t i = 0; i < numProperties; i++) { + if (m_pProperties[i]->FindProperty(name, ppProperty, pIndex)) { + return true; + } + } + return false; +} + +void MP4TableProperty::Read(MP4File* pFile, uint32_t index) +{ + ASSERT(index == 0); + + if (m_implicit) { + return; + } + + uint32_t numProperties = m_pProperties.Size(); + + if (numProperties == 0) { + WARNING(numProperties == 0); + return; + } + + uint32_t numEntries = GetCount(); + + /* for each property set size */ + for (uint32_t j = 0; j < numProperties; j++) { + m_pProperties[j]->SetCount(numEntries); + } + + for (uint32_t i = 0; i < numEntries; i++) { + ReadEntry(pFile, i); + } +} + +void MP4TableProperty::ReadEntry(MP4File* pFile, uint32_t index) +{ + for (uint32_t j = 0; j < m_pProperties.Size(); j++) { + m_pProperties[j]->Read(pFile, index); + } +} + +void MP4TableProperty::Write(MP4File* pFile, uint32_t index) +{ + ASSERT(index == 0); + + if (m_implicit) { + return; + } + + uint32_t numProperties = m_pProperties.Size(); + + if (numProperties == 0) { + WARNING(numProperties == 0); + return; + } + + uint32_t numEntries = GetCount(); + + if (m_pProperties[0]->GetCount() != numEntries) { + fprintf(stderr, "%s %s \"%s\"table entries %u doesn't match count %u\n", + GetParentAtom() != NULL ? GetParentAtom()->GetType() : "", + GetName(), m_pProperties[0]->GetName(), + m_pProperties[0]->GetCount(), numEntries); + + ASSERT(m_pProperties[0]->GetCount() == numEntries); + } + + for (uint32_t i = 0; i < numEntries; i++) { + WriteEntry(pFile, i); + } +} + +void MP4TableProperty::WriteEntry(MP4File* pFile, uint32_t index) +{ + for (uint32_t j = 0; j < m_pProperties.Size(); j++) { + m_pProperties[j]->Write(pFile, index); + } +} + +void MP4TableProperty::Dump(FILE* pFile, uint8_t indent, + bool dumpImplicits, uint32_t index) +{ + ASSERT(index == 0); + + // implicit tables just can't be dumped + if (m_implicit) { + return; + } + + uint32_t numProperties = m_pProperties.Size(); + + if (numProperties == 0) { + WARNING(numProperties == 0); + return; + } + + uint32_t numEntries = GetCount(); + + for (uint32_t i = 0; i < numEntries; i++) { + for (uint32_t j = 0; j < numProperties; j++) { + m_pProperties[j]->Dump(pFile, indent + 1, dumpImplicits, i); + } + } +} + +// MP4DescriptorProperty + +MP4DescriptorProperty::MP4DescriptorProperty(const char* name, + uint8_t tagsStart, uint8_t tagsEnd, bool mandatory, bool onlyOne) + : MP4Property(name) +{ + SetTags(tagsStart, tagsEnd); + m_sizeLimit = 0; + m_mandatory = mandatory; + m_onlyOne = onlyOne; +} + +MP4DescriptorProperty::~MP4DescriptorProperty() +{ + for (uint32_t i = 0; i < m_pDescriptors.Size(); i++) { + delete m_pDescriptors[i]; + } +} + +void MP4DescriptorProperty::SetParentAtom(MP4Atom* pParentAtom) { + m_pParentAtom = pParentAtom; + for (uint32_t i = 0; i < m_pDescriptors.Size(); i++) { + m_pDescriptors[i]->SetParentAtom(pParentAtom); + } +} + +MP4Descriptor* MP4DescriptorProperty::AddDescriptor(uint8_t tag) +{ + // check that tag is in expected range + ASSERT(tag >= m_tagsStart && tag <= m_tagsEnd); + + MP4Descriptor* pDescriptor = CreateDescriptor(tag); + ASSERT(pDescriptor); + + m_pDescriptors.Add(pDescriptor); + pDescriptor->SetParentAtom(m_pParentAtom); + + return pDescriptor; +} + +void MP4DescriptorProperty::DeleteDescriptor(uint32_t index) +{ + delete m_pDescriptors[index]; + m_pDescriptors.Delete(index); +} + +void MP4DescriptorProperty::Generate() +{ + // generate a default descriptor + // if it is mandatory, and single + if (m_mandatory && m_onlyOne) { + MP4Descriptor* pDescriptor = + AddDescriptor(m_tagsStart); + pDescriptor->Generate(); + } +} + +bool MP4DescriptorProperty::FindProperty(const char *name, + MP4Property** ppProperty, uint32_t* pIndex) +{ + // we're unnamed, so just check contained properties + if (m_name == NULL || !strcmp(m_name, "")) { + return FindContainedProperty(name, ppProperty, pIndex); + } + + // check if first component of name matches ourselves + if (!MP4NameFirstMatches(m_name, name)) { + return false; + } + + // check if the specific descriptor entry exists + uint32_t descrIndex; + bool haveDescrIndex = MP4NameFirstIndex(name, &descrIndex); + + if (haveDescrIndex && descrIndex >= GetCount()) { + return false; + } + + if (m_pParentAtom) { + VERBOSE_FIND(m_pParentAtom->GetFile()->GetVerbosity(), + printf("FindProperty: matched %s\n", name)); + } + + // get name of descriptor property + name = MP4NameAfterFirst(name); + if (name == NULL) { + if (!haveDescrIndex) { + *ppProperty = this; + return true; + } + return false; + } + + /* check rest of name */ + if (haveDescrIndex) { + return m_pDescriptors[descrIndex]->FindProperty(name, + ppProperty, pIndex); + } else { + return FindContainedProperty(name, ppProperty, pIndex); + } +} + +bool MP4DescriptorProperty::FindContainedProperty(const char *name, + MP4Property** ppProperty, uint32_t* pIndex) +{ + for (uint32_t i = 0; i < m_pDescriptors.Size(); i++) { + if (m_pDescriptors[i]->FindProperty(name, ppProperty, pIndex)) { + return true; + } + } + return false; +} + +void MP4DescriptorProperty::Read(MP4File* pFile, uint32_t index) +{ + ASSERT(index == 0); + + if (m_implicit) { + return; + } + + uint64_t start = pFile->GetPosition(); + + while (true) { + // enforce size limitation + if (m_sizeLimit && pFile->GetPosition() >= start + m_sizeLimit) { + break; + } + + uint8_t tag; + try { + pFile->PeekBytes(&tag, 1); + } + catch (MP4Error* e) { + if (pFile->GetPosition() >= pFile->GetSize()) { + // EOF + delete e; + break; + } + throw e; + } + + // check if tag is in desired range + if (tag < m_tagsStart || tag > m_tagsEnd) { + break; + } + + MP4Descriptor* pDescriptor = + AddDescriptor(tag); + + pDescriptor->Read(pFile); + } + + // warnings + if (m_mandatory && m_pDescriptors.Size() == 0) { + VERBOSE_READ(pFile->GetVerbosity(), + printf("Warning: Mandatory descriptor 0x%02x missing\n", + m_tagsStart)); + } else if (m_onlyOne && m_pDescriptors.Size() > 1) { + VERBOSE_READ(pFile->GetVerbosity(), + printf("Warning: Descriptor 0x%02x has more than one instance\n", + m_tagsStart)); + } +} + +void MP4DescriptorProperty::Write(MP4File* pFile, uint32_t index) +{ + ASSERT(index == 0); + + if (m_implicit) { + return; + } + + for (uint32_t i = 0; i < m_pDescriptors.Size(); i++) { + m_pDescriptors[i]->Write(pFile); + } +} + +void MP4DescriptorProperty::Dump(FILE* pFile, uint8_t indent, + bool dumpImplicits, uint32_t index) +{ + ASSERT(index == 0); + + if (m_implicit && !dumpImplicits) { + return; + } + + if (m_name) { + Indent(pFile, indent); + if (index != 0) + fprintf(pFile, "%s[%u]\n", m_name, index); + else + fprintf(pFile, "%s\n", m_name); + indent++; + } + + for (uint32_t i = 0; i < m_pDescriptors.Size(); i++) { + m_pDescriptors[i]->Dump(pFile, indent, dumpImplicits); + } +} + +/////////////////////////////////////////////////////////////////////////////// + +MP4LanguageCodeProperty::MP4LanguageCodeProperty( const char* name, bmff::LanguageCode value ) + : MP4Property( name ) +{ + SetValue( value ); +} + +MP4LanguageCodeProperty::MP4LanguageCodeProperty( const char* name, const string& code ) + : MP4Property( name ) +{ + SetValue( bmff::enumLanguageCode.toType( code )); +} + +void +MP4LanguageCodeProperty::Dump( FILE* file, uint8_t indent, bool dumpImplicits, uint32_t index ) +{ + Indent( file, indent ); + + uint16_t data = 0; + + string svalue; + bmff::enumLanguageCode.toString( _value, svalue ); + if( svalue.length() == 3 ) { + data = (((svalue[0] - 0x60) & 0x001f) << 10) + | (((svalue[1] - 0x60) & 0x001f) << 5) + | (((svalue[2] - 0x60) & 0x001f) ); + } + + fprintf( file, "%s = %s (0x%04x)\n", m_name, bmff::enumLanguageCode.toString( _value, true ).c_str(), data ); +} + +uint32_t +MP4LanguageCodeProperty::GetCount() +{ + return 1; +} + +MP4PropertyType +MP4LanguageCodeProperty::GetType() +{ + return LanguageCodeProperty; +} + +bmff::LanguageCode +MP4LanguageCodeProperty::GetValue() +{ + return _value; +} + +void +MP4LanguageCodeProperty::Read( MP4File* file, uint32_t index ) +{ + uint16_t data = file->ReadBits( 16 ); + + char code[3]; + code[0] = ((data & 0x7c00) >> 10) + 0x60; + code[1] = ((data & 0x03e0) >> 5) + 0x60; + code[2] = ((data & 0x001f) ) + 0x60; + + SetValue( bmff::enumLanguageCode.toType( string( code, sizeof(code) ))); +} + +void +MP4LanguageCodeProperty::SetCount( uint32_t count ) +{ + // do nothing; count is always 1 +} + +void +MP4LanguageCodeProperty::SetValue( bmff::LanguageCode value ) +{ + _value = value; +} + +void +MP4LanguageCodeProperty::Write( MP4File* file, uint32_t index ) +{ + uint16_t data = 0; + + string svalue; + bmff::enumLanguageCode.toString( _value, svalue ); + if( svalue.length() == 3 ) { + data = (((svalue[0] - 0x60) & 0x001f) << 10) + | (((svalue[1] - 0x60) & 0x001f) << 5) + | (((svalue[2] - 0x60) & 0x001f) ); + } + + file->WriteBits( data, 16 ); +} + +/////////////////////////////////////////////////////////////////////////////// + +MP4BasicTypeProperty::MP4BasicTypeProperty( const char* name, itmf::BasicType type ) + : MP4Property( name ) +{ + SetValue( type ); +} + +void +MP4BasicTypeProperty::Dump( FILE* file, uint8_t indent, bool dumpImplicits, uint32_t index ) +{ + Indent( file, indent ); + fprintf( file, "%s = %s (0x%02x)\n", m_name, itmf::enumBasicType.toString( _value, true ).c_str(), _value ); +} + +uint32_t +MP4BasicTypeProperty::GetCount() +{ + return 1; +} + +MP4PropertyType +MP4BasicTypeProperty::GetType() +{ + return BasicTypeProperty; +} + +itmf::BasicType +MP4BasicTypeProperty::GetValue() +{ + return _value; +} + +void +MP4BasicTypeProperty::Read( MP4File* file, uint32_t index ) +{ + SetValue( static_cast<itmf::BasicType>( file->ReadBits( 8 ))); +} + +void +MP4BasicTypeProperty::SetCount( uint32_t count ) +{ + // do nothing; count is always 1 +} + +void +MP4BasicTypeProperty::SetValue( itmf::BasicType value ) +{ + _value = value; +} + +void +MP4BasicTypeProperty::Write( MP4File* file, uint32_t index ) +{ + file->WriteBits( _value, 8 ); +} + +/////////////////////////////////////////////////////////////////////////////// + +}} // namespace mp4v2::impl diff --git a/src/mp4property.h b/src/mp4property.h new file mode 100644 index 0000000..fc76282 --- /dev/null +++ b/src/mp4property.h @@ -0,0 +1,606 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + */ + +#ifndef MP4V2_IMPL_MP4PROPERTY_H +#define MP4V2_IMPL_MP4PROPERTY_H + +namespace mp4v2 { namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +// forward declarations +class MP4Atom; + +class MP4Descriptor; +MP4ARRAY_DECL(MP4Descriptor, MP4Descriptor*); + +enum MP4PropertyType { + Integer8Property, + Integer16Property, + Integer24Property, + Integer32Property, + Integer64Property, + Float32Property, + StringProperty, + BytesProperty, + TableProperty, + DescriptorProperty, + LanguageCodeProperty, + BasicTypeProperty, +}; + +class MP4Property { +public: + MP4Property(const char *name = NULL); + + virtual ~MP4Property() { } + + MP4Atom* GetParentAtom() { + return m_pParentAtom; + } + virtual void SetParentAtom(MP4Atom* pParentAtom) { + m_pParentAtom = pParentAtom; + } + + const char *GetName() { + return m_name; + } + + virtual MP4PropertyType GetType() = 0; + + bool IsReadOnly() { + return m_readOnly; + } + void SetReadOnly(bool value = true) { + m_readOnly = value; + } + + bool IsImplicit() { + return m_implicit; + } + void SetImplicit(bool value = true) { + m_implicit = value; + } + + virtual uint32_t GetCount() = 0; + virtual void SetCount(uint32_t count) = 0; + + virtual void Generate() { /* default is a no-op */ }; + + virtual void Read(MP4File* pFile, uint32_t index = 0) = 0; + + virtual void Write(MP4File* pFile, uint32_t index = 0) = 0; + + virtual void Dump(FILE* pFile, uint8_t indent, + bool dumpImplicits, uint32_t index = 0) = 0; + + virtual bool FindProperty(const char* name, + MP4Property** ppProperty, uint32_t* pIndex = NULL); + +protected: + MP4Atom* m_pParentAtom; + const char* m_name; + bool m_readOnly; + bool m_implicit; +}; + +MP4ARRAY_DECL(MP4Property, MP4Property*); + +class MP4IntegerProperty : public MP4Property { +protected: + MP4IntegerProperty(const char* name) + : MP4Property(name) { }; + +public: + uint64_t GetValue(uint32_t index = 0); + + void SetValue(uint64_t value, uint32_t index = 0); + + void InsertValue(uint64_t value, uint32_t index = 0); + + void DeleteValue(uint32_t index = 0); + + void IncrementValue(int32_t increment = 1, uint32_t index = 0); +}; + +#define MP4INTEGER_PROPERTY_DECL2(isize, xsize) \ + class MP4Integer##xsize##Property : public MP4IntegerProperty { \ + public: \ + MP4Integer##xsize##Property(const char* name) \ + : MP4IntegerProperty(name) { \ + SetCount(1); \ + m_values[0] = 0; \ + } \ + \ + MP4PropertyType GetType() { \ + return Integer##xsize##Property; \ + } \ + \ + uint32_t GetCount() { \ + return m_values.Size(); \ + } \ + void SetCount(uint32_t count) { \ + m_values.Resize(count); \ + } \ + \ + uint##isize##_t GetValue(uint32_t index = 0) { \ + return m_values[index]; \ + } \ + \ + void SetValue(uint##isize##_t value, uint32_t index = 0) { \ + if (m_readOnly) { \ + throw new MP4Error(EACCES, "property is read-only", m_name); \ + } \ + m_values[index] = value; \ + } \ + void AddValue(uint##isize##_t value) { \ + m_values.Add(value); \ + } \ + void InsertValue(uint##isize##_t value, uint32_t index) { \ + m_values.Insert(value, index); \ + } \ + void DeleteValue(uint32_t index) { \ + m_values.Delete(index); \ + } \ + void IncrementValue(int32_t increment = 1, uint32_t index = 0) { \ + m_values[index] += increment; \ + } \ + void Read(MP4File* pFile, uint32_t index = 0) { \ + if (m_implicit) { \ + return; \ + } \ + m_values[index] = pFile->ReadUInt##xsize(); \ + } \ + \ + void Write(MP4File* pFile, uint32_t index = 0) { \ + if (m_implicit) { \ + return; \ + } \ + pFile->WriteUInt##xsize(m_values[index]); \ + } \ + void Dump(FILE* pFile, uint8_t indent, \ + bool dumpImplicits, uint32_t index = 0); \ + \ + protected: \ + MP4Integer##isize##Array m_values; \ + }; + +#define MP4INTEGER_PROPERTY_DECL(size) \ + MP4INTEGER_PROPERTY_DECL2(size, size) + +MP4INTEGER_PROPERTY_DECL(8); +MP4INTEGER_PROPERTY_DECL(16); +MP4INTEGER_PROPERTY_DECL2(32, 24); +MP4INTEGER_PROPERTY_DECL(32); +MP4INTEGER_PROPERTY_DECL(64); + +class MP4BitfieldProperty : public MP4Integer64Property { +public: + MP4BitfieldProperty(const char* name, uint8_t numBits) + : MP4Integer64Property(name) { + ASSERT(numBits != 0); + ASSERT(numBits <= 64); + m_numBits = numBits; + } + + uint8_t GetNumBits() { + return m_numBits; + } + void SetNumBits(uint8_t numBits) { + m_numBits = numBits; + } + + void Read(MP4File* pFile, uint32_t index = 0); + void Write(MP4File* pFile, uint32_t index = 0); + void Dump(FILE* pFile, uint8_t indent, + bool dumpImplicits, uint32_t index = 0); + +protected: + uint8_t m_numBits; +}; + +class MP4Float32Property : public MP4Property { +public: + MP4Float32Property(const char* name) + : MP4Property(name) { + m_useFixed16Format = false; + m_useFixed32Format = false; + SetCount(1); + m_values[0] = 0.0; + } + + MP4PropertyType GetType() { + return Float32Property; + } + + uint32_t GetCount() { + return m_values.Size(); + } + void SetCount(uint32_t count) { + m_values.Resize(count); + } + + float GetValue(uint32_t index = 0) { + return m_values[index]; + } + + void SetValue(float value, uint32_t index = 0) { + if (m_readOnly) { + throw new MP4Error(EACCES, "property is read-only", m_name); + } + m_values[index] = value; + } + + void AddValue(float value) { + m_values.Add(value); + } + + void InsertValue(float value, uint32_t index) { + m_values.Insert(value, index); + } + + bool IsFixed16Format() { + return m_useFixed16Format; + } + + void SetFixed16Format(bool useFixed16Format = true) { + m_useFixed16Format = useFixed16Format; + } + + bool IsFixed32Format() { + return m_useFixed32Format; + } + + void SetFixed32Format(bool useFixed32Format = true) { + m_useFixed32Format = useFixed32Format; + } + + void Read(MP4File* pFile, uint32_t index = 0); + void Write(MP4File* pFile, uint32_t index = 0); + void Dump(FILE* pFile, uint8_t indent, + bool dumpImplicits, uint32_t index = 0); + +protected: + bool m_useFixed16Format; + bool m_useFixed32Format; + MP4Float32Array m_values; +}; + +class MP4StringProperty : public MP4Property { +public: + MP4StringProperty(const char* name, + bool useCountedFormat = false, bool useUnicode = false, bool arrayMode = false); + + ~MP4StringProperty(); + + MP4PropertyType GetType() { + return StringProperty; + } + + uint32_t GetCount() { + return m_values.Size(); + } + + void SetCount(uint32_t count); + + const char* GetValue(uint32_t index = 0) { + return m_values[index]; + } + + void SetValue(const char* value, uint32_t index = 0); + + void AddValue(const char* value) { + uint32_t count = GetCount(); + SetCount(count + 1); + SetValue(value, count); + } + + bool IsCountedFormat() { + return m_useCountedFormat; + } + + void SetCountedFormat(bool useCountedFormat) { + m_useCountedFormat = useCountedFormat; + } + + bool IsExpandedCountedFormat() { + return m_useExpandedCount; + } + + void SetExpandedCountedFormat(bool useExpandedCount) { + m_useExpandedCount = useExpandedCount; + } + + bool IsUnicode() { + return m_useUnicode; + } + + void SetUnicode(bool useUnicode) { + m_useUnicode = useUnicode; + } + + uint32_t GetFixedLength() { + return m_fixedLength; + } + + void SetFixedLength(uint32_t fixedLength) { + m_fixedLength = fixedLength; + m_fixedLengthSet = true; + } + + void Read(MP4File* pFile, uint32_t index = 0); + void Write(MP4File* pFile, uint32_t index = 0); + void Dump(FILE* pFile, uint8_t indent, + bool dumpImplicits, uint32_t index = 0); + +protected: + bool m_arrayMode; // during read/write ignore index and read/write full array + bool m_useCountedFormat; + bool m_useExpandedCount; + bool m_useUnicode; + uint32_t m_fixedLength; + bool m_fixedLengthSet; + + MP4StringArray m_values; +}; + +class MP4BytesProperty : public MP4Property { +public: + MP4BytesProperty(const char* name, uint32_t valueSize = 0, + uint32_t defaultValueSize = 0); + + ~MP4BytesProperty(); + + MP4PropertyType GetType() { + return BytesProperty; + } + + uint32_t GetCount() { + return m_values.Size(); + } + + void SetCount(uint32_t count); + + void GetValue(uint8_t** ppValue, uint32_t* pValueSize, + uint32_t index = 0) { + // N.B. caller must free memory + *ppValue = (uint8_t*)MP4Malloc(m_valueSizes[index]); + memcpy(*ppValue, m_values[index], m_valueSizes[index]); + *pValueSize = m_valueSizes[index]; + } + + void CopyValue(uint8_t* pValue, uint32_t index = 0) { + // N.B. caller takes responsbility for valid pointer + // and sufficient memory at the destination + memcpy(pValue, m_values[index], m_valueSizes[index]); + } + + void SetValue(const uint8_t* pValue, uint32_t valueSize, + uint32_t index = 0); + + void AddValue(const uint8_t* pValue, uint32_t valueSize) { + uint32_t count = GetCount(); + SetCount(count + 1); + SetValue(pValue, valueSize, count); + } + + uint32_t GetValueStart(uint32_t index = 0) { + return m_valueStart[index]; + } + + uint32_t GetValueSize(uint32_t valueSize, uint32_t index = 0) { + return m_valueSizes[index]; + } + + void SetValueSize(uint32_t valueSize, uint32_t index = 0); + + uint32_t GetFixedSize() { + return m_fixedValueSize; + } + + void SetFixedSize(uint32_t fixedSize); + + void Read(MP4File* pFile, uint32_t index = 0); + void Write(MP4File* pFile, uint32_t index = 0); + void Dump(FILE* pFile, uint8_t indent, + bool dumpImplicits, uint32_t index = 0); + +protected: + uint32_t m_fixedValueSize; + uint32_t m_defaultValueSize; + MP4Integer32Array m_valueSizes; + MP4Integer32Array m_valueStart; + MP4BytesArray m_values; +}; + +class MP4TableProperty : public MP4Property { +public: + MP4TableProperty(const char* name, MP4IntegerProperty* pCountProperty); + + ~MP4TableProperty(); + + MP4PropertyType GetType() { + return TableProperty; + } + + void SetParentAtom(MP4Atom* pParentAtom) { + m_pParentAtom = pParentAtom; + for (uint32_t i = 0; i < m_pProperties.Size(); i++) { + m_pProperties[i]->SetParentAtom(pParentAtom); + } + } + + void AddProperty(MP4Property* pProperty); + + MP4Property* GetProperty(uint32_t index) { + return m_pProperties[index]; + } + + virtual uint32_t GetCount() { + return m_pCountProperty->GetValue(); + } + virtual void SetCount(uint32_t count) { + m_pCountProperty->SetValue(count); + } + + void Read(MP4File* pFile, uint32_t index = 0); + void Write(MP4File* pFile, uint32_t index = 0); + void Dump(FILE* pFile, uint8_t indent, + bool dumpImplicits, uint32_t index = 0); + + bool FindProperty(const char* name, + MP4Property** ppProperty, uint32_t* pIndex = NULL); + +protected: + virtual void ReadEntry(MP4File* pFile, uint32_t index); + virtual void WriteEntry(MP4File* pFile, uint32_t index); + + bool FindContainedProperty(const char* name, + MP4Property** ppProperty, uint32_t* pIndex); + +protected: + MP4IntegerProperty* m_pCountProperty; + MP4PropertyArray m_pProperties; +}; + +class MP4DescriptorProperty : public MP4Property { +public: + MP4DescriptorProperty(const char* name = NULL, + uint8_t tagsStart = 0, uint8_t tagsEnd = 0, + bool mandatory = false, bool onlyOne = false); + + ~MP4DescriptorProperty(); + + MP4PropertyType GetType() { + return DescriptorProperty; + } + + void SetParentAtom(MP4Atom* pParentAtom); + + void SetSizeLimit(uint64_t sizeLimit) { + m_sizeLimit = sizeLimit; + } + + uint32_t GetCount() { + return m_pDescriptors.Size(); + } + void SetCount(uint32_t count) { + m_pDescriptors.Resize(count); + } + + void SetTags(uint8_t tagsStart, uint8_t tagsEnd = 0) { + m_tagsStart = tagsStart; + m_tagsEnd = tagsEnd ? tagsEnd : tagsStart; + } + + MP4Descriptor* AddDescriptor(uint8_t tag); + + void AppendDescriptor(MP4Descriptor* pDescriptor) { + m_pDescriptors.Add(pDescriptor); + } + + void DeleteDescriptor(uint32_t index); + + void Generate(); + void Read(MP4File* pFile, uint32_t index = 0); + void Write(MP4File* pFile, uint32_t index = 0); + void Dump(FILE* pFile, uint8_t indent, + bool dumpImplicits, uint32_t index = 0); + + bool FindProperty(const char* name, + MP4Property** ppProperty, uint32_t* pIndex = NULL); + +protected: + virtual MP4Descriptor* CreateDescriptor(uint8_t tag); + + bool FindContainedProperty(const char* name, + MP4Property** ppProperty, uint32_t* pIndex); + +protected: + uint8_t m_tagsStart; + uint8_t m_tagsEnd; + uint64_t m_sizeLimit; + bool m_mandatory; + bool m_onlyOne; + MP4DescriptorArray m_pDescriptors; +}; + +class MP4QosQualifierProperty : public MP4DescriptorProperty { +public: + MP4QosQualifierProperty(const char* name = NULL, + uint8_t tagsStart = 0, uint8_t tagsEnd = 0, + bool mandatory = false, bool onlyOne = false) : + MP4DescriptorProperty(name, tagsStart, tagsEnd, mandatory, onlyOne) { } + +protected: + MP4Descriptor* CreateDescriptor(uint8_t tag); +}; + +/////////////////////////////////////////////////////////////////////////////// + +/// ISO-639-2/T langauge code. +/// Language codes are 3-alpha (always lowercase) codes which are then +/// offset using 0x60 and packed as 5-bit values into 16-bits, most +/// significant bit is zero-padding. + +class MP4LanguageCodeProperty : public MP4Property { +private: + bmff::LanguageCode _value; + +public: + explicit MP4LanguageCodeProperty( const char* , bmff::LanguageCode = bmff::ILC_UND ); + MP4LanguageCodeProperty( const char* , const string& ); + + MP4PropertyType GetType(); + uint32_t GetCount(); + void SetCount( uint32_t ); + void Read( MP4File*, uint32_t = 0 ); + void Write( MP4File*, uint32_t = 0 ); + void Dump( FILE*, uint8_t, bool, uint32_t = 0 ); + + bmff::LanguageCode GetValue(); + void SetValue( bmff::LanguageCode ); +}; + +/////////////////////////////////////////////////////////////////////////////// + +class MP4BasicTypeProperty : public MP4Property { +private: + itmf::BasicType _value; + +public: + explicit MP4BasicTypeProperty( const char* , itmf::BasicType = itmf::BT_UNDEFINED ); + + MP4PropertyType GetType(); + uint32_t GetCount(); + void SetCount( uint32_t ); + void Read( MP4File*, uint32_t = 0 ); + void Write( MP4File*, uint32_t = 0 ); + void Dump( FILE*, uint8_t, bool, uint32_t = 0 ); + itmf::BasicType GetValue(); + void SetValue( itmf::BasicType ); +}; + +/////////////////////////////////////////////////////////////////////////////// + +}} // namespace mp4v2::impl + +#endif // MP4V2_IMPL_MP4PROPERTY_H diff --git a/src/mp4track.cpp b/src/mp4track.cpp new file mode 100644 index 0000000..b672a3b --- /dev/null +++ b/src/mp4track.cpp @@ -0,0 +1,1856 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001 - 2004. All Rights Reserved. + * + * 3GPP features implementation is based on 3GPP's TS26.234-v5.60, + * and was contributed by Ximpo Group Ltd. + * + * Portions created by Ximpo Group Ltd. are + * Copyright (C) Ximpo Group Ltd. 2003, 2004. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + * Alix Marchandise-Franquet alix@cisco.com + * Ximpo Group Ltd. mp4v2@ximpo.com + */ + +#include "src/impl.h" + +namespace mp4v2 { namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +#define AMR_UNINITIALIZED -1 +#define AMR_TRUE 0 +#define AMR_FALSE 1 + +MP4Track::MP4Track(MP4File* pFile, MP4Atom* pTrakAtom) +{ + m_pFile = pFile; + m_pTrakAtom = pTrakAtom; + + m_lastStsdIndex = 0; + m_lastSampleFile = NULL; + + m_cachedReadSampleId = MP4_INVALID_SAMPLE_ID; + m_pCachedReadSample = NULL; + m_cachedReadSampleSize = 0; + + m_writeSampleId = 1; + m_fixedSampleDuration = 0; + m_pChunkBuffer = NULL; + m_chunkBufferSize = 0; + m_chunkSamples = 0; + m_chunkDuration = 0; + + // m_bytesPerSample should be set to 1, except for the + // quicktime audio constant bit rate samples, which have non-1 values + m_bytesPerSample = 1; + m_samplesPerChunk = 0; + m_durationPerChunk = 0; + m_isAmr = AMR_UNINITIALIZED; + m_curMode = 0; + + m_cachedSttsSid = MP4_INVALID_SAMPLE_ID; + + bool success = true; + + MP4Integer32Property* pTrackIdProperty; + success &= m_pTrakAtom->FindProperty( + "trak.tkhd.trackId", + (MP4Property**)&pTrackIdProperty); + if (success) { + m_trackId = pTrackIdProperty->GetValue(); + } + + success &= m_pTrakAtom->FindProperty( + "trak.mdia.mdhd.timeScale", + (MP4Property**)&m_pTimeScaleProperty); + if (success) { + // default chunking is 1 second of samples + m_durationPerChunk = m_pTimeScaleProperty->GetValue(); + } + + success &= m_pTrakAtom->FindProperty( + "trak.tkhd.duration", + (MP4Property**)&m_pTrackDurationProperty); + + success &= m_pTrakAtom->FindProperty( + "trak.mdia.mdhd.duration", + (MP4Property**)&m_pMediaDurationProperty); + + success &= m_pTrakAtom->FindProperty( + "trak.tkhd.modificationTime", + (MP4Property**)&m_pTrackModificationProperty); + + success &= m_pTrakAtom->FindProperty( + "trak.mdia.mdhd.modificationTime", + (MP4Property**)&m_pMediaModificationProperty); + + success &= m_pTrakAtom->FindProperty( + "trak.mdia.hdlr.handlerType", + (MP4Property**)&m_pTypeProperty); + + // get handles on sample size information + + + m_pStszFixedSampleSizeProperty = NULL; + bool have_stsz = + m_pTrakAtom->FindProperty("trak.mdia.minf.stbl.stsz.sampleSize", + (MP4Property**)&m_pStszFixedSampleSizeProperty); + + if (have_stsz) { + success &= m_pTrakAtom->FindProperty( + "trak.mdia.minf.stbl.stsz.sampleCount", + (MP4Property**)&m_pStszSampleCountProperty); + + success &= m_pTrakAtom->FindProperty( + "trak.mdia.minf.stbl.stsz.entries.entrySize", + (MP4Property**)&m_pStszSampleSizeProperty); + m_stsz_sample_bits = 32; + } else { + success &= m_pTrakAtom->FindProperty( + "trak.mdia.minf.stbl.stz2.sampleCount", + (MP4Property**)&m_pStszSampleCountProperty); + success &= m_pTrakAtom->FindProperty( + "trak.mdia.minf.stbl.stz2.entries.entrySize", + (MP4Property**)&m_pStszSampleSizeProperty); + MP4Integer8Property *stz2_field_size; + if (m_pTrakAtom->FindProperty( + "trak.mdia.minf.stbl.stz2.fieldSize", + (MP4Property **)&stz2_field_size)) { + m_stsz_sample_bits = stz2_field_size->GetValue(); + m_have_stz2_4bit_sample = false; + } else success = false; + } + + // get handles on information needed to map sample id's to file offsets + + success &= m_pTrakAtom->FindProperty( + "trak.mdia.minf.stbl.stsc.entryCount", + (MP4Property**)&m_pStscCountProperty); + + success &= m_pTrakAtom->FindProperty( + "trak.mdia.minf.stbl.stsc.entries.firstChunk", + (MP4Property**)&m_pStscFirstChunkProperty); + + success &= m_pTrakAtom->FindProperty( + "trak.mdia.minf.stbl.stsc.entries.samplesPerChunk", + (MP4Property**)&m_pStscSamplesPerChunkProperty); + + success &= m_pTrakAtom->FindProperty( + "trak.mdia.minf.stbl.stsc.entries.sampleDescriptionIndex", + (MP4Property**)&m_pStscSampleDescrIndexProperty); + + success &= m_pTrakAtom->FindProperty( + "trak.mdia.minf.stbl.stsc.entries.firstSample", + (MP4Property**)&m_pStscFirstSampleProperty); + + bool haveStco = m_pTrakAtom->FindProperty( + "trak.mdia.minf.stbl.stco.entryCount", + (MP4Property**)&m_pChunkCountProperty); + + if (haveStco) { + success &= m_pTrakAtom->FindProperty( + "trak.mdia.minf.stbl.stco.entries.chunkOffset", + (MP4Property**)&m_pChunkOffsetProperty); + } else { + success &= m_pTrakAtom->FindProperty( + "trak.mdia.minf.stbl.co64.entryCount", + (MP4Property**)&m_pChunkCountProperty); + + success &= m_pTrakAtom->FindProperty( + "trak.mdia.minf.stbl.co64.entries.chunkOffset", + (MP4Property**)&m_pChunkOffsetProperty); + } + + // get handles on sample timing info + + success &= m_pTrakAtom->FindProperty( + "trak.mdia.minf.stbl.stts.entryCount", + (MP4Property**)&m_pSttsCountProperty); + + success &= m_pTrakAtom->FindProperty( + "trak.mdia.minf.stbl.stts.entries.sampleCount", + (MP4Property**)&m_pSttsSampleCountProperty); + + success &= m_pTrakAtom->FindProperty( + "trak.mdia.minf.stbl.stts.entries.sampleDelta", + (MP4Property**)&m_pSttsSampleDeltaProperty); + + // get handles on rendering offset info if it exists + + m_pCttsCountProperty = NULL; + m_pCttsSampleCountProperty = NULL; + m_pCttsSampleOffsetProperty = NULL; + + bool haveCtts = m_pTrakAtom->FindProperty( + "trak.mdia.minf.stbl.ctts.entryCount", + (MP4Property**)&m_pCttsCountProperty); + + if (haveCtts) { + success &= m_pTrakAtom->FindProperty( + "trak.mdia.minf.stbl.ctts.entries.sampleCount", + (MP4Property**)&m_pCttsSampleCountProperty); + + success &= m_pTrakAtom->FindProperty( + "trak.mdia.minf.stbl.ctts.entries.sampleOffset", + (MP4Property**)&m_pCttsSampleOffsetProperty); + } + + // get handles on sync sample info if it exists + + m_pStssCountProperty = NULL; + m_pStssSampleProperty = NULL; + + bool haveStss = m_pTrakAtom->FindProperty( + "trak.mdia.minf.stbl.stss.entryCount", + (MP4Property**)&m_pStssCountProperty); + + if (haveStss) { + success &= m_pTrakAtom->FindProperty( + "trak.mdia.minf.stbl.stss.entries.sampleNumber", + (MP4Property**)&m_pStssSampleProperty); + } + + // edit list + (void)InitEditListProperties(); + + // was everything found? + if (!success) { + throw new MP4Error("invalid track", "MP4Track::MP4Track"); + } + CalculateBytesPerSample(); +} + +MP4Track::~MP4Track() +{ + MP4Free(m_pCachedReadSample); + MP4Free(m_pChunkBuffer); +} + +const char* MP4Track::GetType() +{ + return m_pTypeProperty->GetValue(); +} + +void MP4Track::SetType(const char* type) +{ + m_pTypeProperty->SetValue(MP4NormalizeTrackType(type, + m_pFile->GetVerbosity())); +} + +void MP4Track::ReadSample( + MP4SampleId sampleId, + uint8_t** ppBytes, + uint32_t* pNumBytes, + MP4Timestamp* pStartTime, + MP4Duration* pDuration, + MP4Duration* pRenderingOffset, + bool* pIsSyncSample) +{ + if (sampleId == MP4_INVALID_SAMPLE_ID) { + throw new MP4Error("sample id can't be zero", + "MP4Track::ReadSample"); + } + + // handle unusual case of wanting to read a sample + // that is still sitting in the write chunk buffer + if (m_pChunkBuffer && sampleId >= m_writeSampleId - m_chunkSamples) { + WriteChunkBuffer(); + } + + File* fin = GetSampleFile( sampleId ); + if( fin == (File*)-1 ) + throw new MP4Error( "sample is located in an inaccessible file", "MP4Track::ReadSample" ); + + uint64_t fileOffset = GetSampleFileOffset(sampleId); + + uint32_t sampleSize = GetSampleSize(sampleId); + if (*ppBytes != NULL && *pNumBytes < sampleSize) { + throw new MP4Error("sample buffer is too small", + "MP4Track::ReadSample"); + } + *pNumBytes = sampleSize; + + VERBOSE_READ_SAMPLE(m_pFile->GetVerbosity(), + printf("ReadSample: track %u id %u offset 0x%" PRIx64 " size %u (0x%x)\n", + m_trackId, sampleId, fileOffset, *pNumBytes, *pNumBytes)); + + bool bufferMalloc = false; + if (*ppBytes == NULL) { + *ppBytes = (uint8_t*)MP4Malloc(*pNumBytes); + bufferMalloc = true; + } + + uint64_t oldPos = m_pFile->GetPosition( fin ); // only used in mode == 'w' + try { + m_pFile->SetPosition( fileOffset, fin ); + m_pFile->ReadBytes( *ppBytes, *pNumBytes, fin ); + + if (pStartTime || pDuration) { + GetSampleTimes(sampleId, pStartTime, pDuration); + + VERBOSE_READ_SAMPLE(m_pFile->GetVerbosity(), + printf("ReadSample: start %" PRIu64 " duration %" PRId64 "\n", + (pStartTime ? *pStartTime : 0), + (pDuration ? *pDuration : 0))); + } + if (pRenderingOffset) { + *pRenderingOffset = GetSampleRenderingOffset(sampleId); + + VERBOSE_READ_SAMPLE(m_pFile->GetVerbosity(), + printf("ReadSample: renderingOffset %" PRId64 "\n", + *pRenderingOffset)); + } + if (pIsSyncSample) { + *pIsSyncSample = IsSyncSample(sampleId); + + VERBOSE_READ_SAMPLE(m_pFile->GetVerbosity(), + printf("ReadSample: isSyncSample %u\n", + *pIsSyncSample)); + } + } + + catch (MP4Error* e) { + if( bufferMalloc ) { + MP4Free( *ppBytes ); + *ppBytes = NULL; + } + + if( m_pFile->IsWriteMode() ) + m_pFile->SetPosition( oldPos, fin ); + + throw e; + } + + if( m_pFile->IsWriteMode() ) + m_pFile->SetPosition( oldPos, fin ); +} + +void MP4Track::ReadSampleFragment( + MP4SampleId sampleId, + uint32_t sampleOffset, + uint16_t sampleLength, + uint8_t* pDest) +{ + if (sampleId == MP4_INVALID_SAMPLE_ID) { + throw new MP4Error("invalid sample id", + "MP4Track::ReadSampleFragment"); + } + + if (sampleId != m_cachedReadSampleId) { + MP4Free(m_pCachedReadSample); + m_pCachedReadSample = NULL; + m_cachedReadSampleSize = 0; + m_cachedReadSampleId = MP4_INVALID_SAMPLE_ID; + + ReadSample( + sampleId, + &m_pCachedReadSample, + &m_cachedReadSampleSize); + + m_cachedReadSampleId = sampleId; + } + + if (sampleOffset + sampleLength > m_cachedReadSampleSize) { + throw new MP4Error("offset and/or length are too large", + "MP4Track::ReadSampleFragment"); + } + + memcpy(pDest, &m_pCachedReadSample[sampleOffset], sampleLength); +} + +void MP4Track::WriteSample( + const uint8_t* pBytes, + uint32_t numBytes, + MP4Duration duration, + MP4Duration renderingOffset, + bool isSyncSample ) +{ + uint8_t curMode = 0; + + VERBOSE_WRITE_SAMPLE(m_pFile->GetVerbosity(), + printf("WriteSample: track %u id %u size %u (0x%x) ", + m_trackId, m_writeSampleId, numBytes, numBytes)); + + if (pBytes == NULL && numBytes > 0) { + throw new MP4Error("no sample data", "MP4WriteSample"); + } + + if (m_isAmr == AMR_UNINITIALIZED ) { + // figure out if this is an AMR audio track + if (m_pTrakAtom->FindAtom("trak.mdia.minf.stbl.stsd.samr") || + m_pTrakAtom->FindAtom("trak.mdia.minf.stbl.stsd.sawb")) { + m_isAmr = AMR_TRUE; + m_curMode = (pBytes[0] >> 3) & 0x000F; + } else { + m_isAmr = AMR_FALSE; + } + } + + if (m_isAmr == AMR_TRUE) { + curMode = (pBytes[0] >> 3) &0x000F; // The mode is in the first byte + } + + if (duration == MP4_INVALID_DURATION) { + duration = GetFixedSampleDuration(); + } + + VERBOSE_WRITE_SAMPLE(m_pFile->GetVerbosity(), + printf("duration %" PRIu64 "\n", duration)); + + if ((m_isAmr == AMR_TRUE) && + (m_curMode != curMode)) { + WriteChunkBuffer(); + m_curMode = curMode; + } + + // append sample bytes to chunk buffer + m_pChunkBuffer = (uint8_t*)MP4Realloc(m_pChunkBuffer, + m_chunkBufferSize + numBytes); + if (m_pChunkBuffer == NULL) return; + memcpy(&m_pChunkBuffer[m_chunkBufferSize], pBytes, numBytes); + m_chunkBufferSize += numBytes; + m_chunkSamples++; + m_chunkDuration += duration; + + UpdateSampleSizes(m_writeSampleId, numBytes); + + UpdateSampleTimes(duration); + + UpdateRenderingOffsets(m_writeSampleId, renderingOffset); + + UpdateSyncSamples(m_writeSampleId, isSyncSample); + + if (IsChunkFull(m_writeSampleId)) { + WriteChunkBuffer(); + m_curMode = curMode; + } + + UpdateDurations(duration); + + UpdateModificationTimes(); + + m_writeSampleId++; +} + +void MP4Track::WriteSampleDependency( + const uint8_t* pBytes, + uint32_t numBytes, + MP4Duration duration, + MP4Duration renderingOffset, + bool isSyncSample, + uint32_t dependencyFlags ) +{ + m_sdtpLog.push_back( dependencyFlags ); // record dependency flags for processing at finish + WriteSample( pBytes, numBytes, duration, renderingOffset, isSyncSample ); +} + +void MP4Track::WriteChunkBuffer() +{ + if (m_chunkBufferSize == 0) { + return; + } + + uint64_t chunkOffset = m_pFile->GetPosition(); + + // write chunk buffer + m_pFile->WriteBytes(m_pChunkBuffer, m_chunkBufferSize); + + VERBOSE_WRITE_SAMPLE(m_pFile->GetVerbosity(), + printf("WriteChunk: track %u offset 0x%" PRIx64 " size %u (0x%x) numSamples %u\n", + m_trackId, chunkOffset, m_chunkBufferSize, + m_chunkBufferSize, m_chunkSamples)); + + UpdateSampleToChunk(m_writeSampleId, + m_pChunkCountProperty->GetValue() + 1, + m_chunkSamples); + + UpdateChunkOffsets(chunkOffset); + + // clean up chunk buffer + MP4Free(m_pChunkBuffer); + m_pChunkBuffer = NULL; + m_chunkBufferSize = 0; + m_chunkSamples = 0; + m_chunkDuration = 0; +} + +void MP4Track::FinishWrite() +{ + FinishSdtp(); + + // write out any remaining samples in chunk buffer + WriteChunkBuffer(); + + if (m_pStszFixedSampleSizeProperty == NULL && + m_stsz_sample_bits == 4) { + if (m_have_stz2_4bit_sample) { + ((MP4Integer8Property *)m_pStszSampleSizeProperty)->AddValue(m_stz2_4bit_sample_value); + m_pStszSampleSizeProperty->IncrementValue(); + } + } + + // record buffer size and bitrates + MP4BitfieldProperty* pBufferSizeProperty; + + if (m_pTrakAtom->FindProperty( + "trak.mdia.minf.stbl.stsd.*.esds.decConfigDescr.bufferSizeDB", + (MP4Property**)&pBufferSizeProperty)) { + pBufferSizeProperty->SetValue(GetMaxSampleSize()); + } + + MP4Integer32Property* pBitrateProperty; + + if (m_pTrakAtom->FindProperty( + "trak.mdia.minf.stbl.stsd.*.esds.decConfigDescr.maxBitrate", + (MP4Property**)&pBitrateProperty)) { + pBitrateProperty->SetValue(GetMaxBitrate()); + } + + if (m_pTrakAtom->FindProperty( + "trak.mdia.minf.stbl.stsd.*.esds.decConfigDescr.avgBitrate", + (MP4Property**)&pBitrateProperty)) { + pBitrateProperty->SetValue(GetAvgBitrate()); + } +} + +// Process sdtp log and add sdtp atom. +// +// Testing (subjective) showed a marked improvement with QuickTime +// player on Mac OS X when scrubbing. Best results were obtained +// from encodings using low number of bframes. It's expected sdtp may help +// other QT-based players. +// +void MP4Track::FinishSdtp() +{ + // bail if log is empty -- indicates dependency information was not written + if( m_sdtpLog.empty() ) + return; + + MP4SdtpAtom& sdtp = *(MP4SdtpAtom*)AddAtom( "trak.mdia.minf.stbl", "sdtp" ); + sdtp.data.SetValue( (const uint8_t*)m_sdtpLog.data(), m_sdtpLog.size() ); + + // add avc1 compatibility indicator if not present + MP4FtypAtom* ftyp = (MP4FtypAtom*)m_pFile->FindAtom( "ftyp" ); + if( ftyp ) { + bool found = false; + const uint32_t max = ftyp->compatibleBrands.GetCount(); + for( uint32_t i = 0; i < max; i++ ) { + if( !strcmp( ftyp->compatibleBrands.GetValue( i ), "avc1" )) { + found = true; + break; + } + } + + if( !found ) + ftyp->compatibleBrands.AddValue( "avc1" ); + } +} + +bool MP4Track::IsChunkFull(MP4SampleId sampleId) +{ + if (m_samplesPerChunk) { + return m_chunkSamples >= m_samplesPerChunk; + } + + ASSERT(m_durationPerChunk); + return m_chunkDuration >= m_durationPerChunk; +} + +uint32_t MP4Track::GetNumberOfSamples() +{ + return m_pStszSampleCountProperty->GetValue(); +} + +uint32_t MP4Track::GetSampleSize(MP4SampleId sampleId) +{ + if (m_pStszFixedSampleSizeProperty != NULL) { + uint32_t fixedSampleSize = + m_pStszFixedSampleSizeProperty->GetValue(); + + if (fixedSampleSize != 0) { + return fixedSampleSize * m_bytesPerSample; + } + } + // will have to check for 4 bit sample size here + if (m_stsz_sample_bits == 4) { + uint8_t value = m_pStszSampleSizeProperty->GetValue((sampleId - 1) / 2); + if ((sampleId - 1) / 2 == 0) { + value >>= 4; + } else value &= 0xf; + return m_bytesPerSample * value; + } + return m_bytesPerSample * + m_pStszSampleSizeProperty->GetValue(sampleId - 1); +} + +uint32_t MP4Track::GetMaxSampleSize() +{ + if (m_pStszFixedSampleSizeProperty != NULL) { + uint32_t fixedSampleSize = + m_pStszFixedSampleSizeProperty->GetValue(); + + if (fixedSampleSize != 0) { + return fixedSampleSize * m_bytesPerSample; + } + } + + uint32_t maxSampleSize = 0; + uint32_t numSamples = m_pStszSampleSizeProperty->GetCount(); + for (MP4SampleId sid = 1; sid <= numSamples; sid++) { + uint32_t sampleSize = + m_pStszSampleSizeProperty->GetValue(sid - 1); + if (sampleSize > maxSampleSize) { + maxSampleSize = sampleSize; + } + } + return maxSampleSize * m_bytesPerSample; +} + +uint64_t MP4Track::GetTotalOfSampleSizes() +{ + uint64_t retval; + if (m_pStszFixedSampleSizeProperty != NULL) { + uint32_t fixedSampleSize = + m_pStszFixedSampleSizeProperty->GetValue(); + + // if fixed sample size, just need to multiply by number of samples + if (fixedSampleSize != 0) { + retval = m_bytesPerSample; + retval *= fixedSampleSize; + retval *= GetNumberOfSamples(); + return retval; + } + } + + // else non-fixed sample size, sum them + uint64_t totalSampleSizes = 0; + uint32_t numSamples = m_pStszSampleSizeProperty->GetCount(); + for (MP4SampleId sid = 1; sid <= numSamples; sid++) { + uint32_t sampleSize = + m_pStszSampleSizeProperty->GetValue(sid - 1); + totalSampleSizes += sampleSize; + } + return totalSampleSizes * m_bytesPerSample; +} + +void MP4Track::SampleSizePropertyAddValue (uint32_t size) +{ + // this has to deal with different sample size values + switch (m_pStszSampleSizeProperty->GetType()) { + case Integer32Property: + ((MP4Integer32Property *)m_pStszSampleSizeProperty)->AddValue(size); + break; + case Integer16Property: + ((MP4Integer16Property *)m_pStszSampleSizeProperty)->AddValue(size); + break; + case Integer8Property: + if (m_stsz_sample_bits == 4) { + if (m_have_stz2_4bit_sample == false) { + m_have_stz2_4bit_sample = true; + m_stz2_4bit_sample_value = size << 4; + return; + } else { + m_have_stz2_4bit_sample = false; + size &= 0xf; + size |= m_stz2_4bit_sample_value; + } + } + ((MP4Integer8Property *)m_pStszSampleSizeProperty)->AddValue(size); + break; + default: + break; + } + + + // m_pStszSampleSizeProperty->IncrementValue(); +} + +void MP4Track::UpdateSampleSizes(MP4SampleId sampleId, uint32_t numBytes) +{ + if (m_bytesPerSample > 1) { + if ((numBytes % m_bytesPerSample) != 0) { + // error + VERBOSE_ERROR(m_pFile->GetVerbosity(), + printf("UpdateSampleSize: numBytes %u not divisible by bytesPerSample %u sampleId %u\n", + numBytes, m_bytesPerSample, sampleId); + ); + } + numBytes /= m_bytesPerSample; + } + // for first sample + // wmay - if we are adding, we want to make sure that + // we don't inadvertently set up the fixed size again. + // so, we check the number of samples + if (sampleId == 1 && GetNumberOfSamples() == 0) { + if (m_pStszFixedSampleSizeProperty == NULL || + numBytes == 0) { + // special case of first sample is zero bytes in length + // leave m_pStszFixedSampleSizeProperty at 0 + // start recording variable sample sizes + if (m_pStszFixedSampleSizeProperty != NULL) + m_pStszFixedSampleSizeProperty->SetValue(0); + SampleSizePropertyAddValue(0); + } else { + // presume sample size is fixed + m_pStszFixedSampleSizeProperty->SetValue(numBytes); + } + } else { // sampleId > 1 + + uint32_t fixedSampleSize = 0; + if (m_pStszFixedSampleSizeProperty != NULL) { + fixedSampleSize = m_pStszFixedSampleSizeProperty->GetValue(); + } + + // if we don't have a fixed size, or the current sample size + // doesn't match our sample size, we need to write the current + // sample size into the table + if (fixedSampleSize == 0 || numBytes != fixedSampleSize) { + if (fixedSampleSize != 0) { + // fixed size was set; we need to clear fixed sample size + m_pStszFixedSampleSizeProperty->SetValue(0); + + // and create sizes for all previous samples + // use GetNumberOfSamples due to needing the total number + // not just the appended part of the file + uint32_t samples = GetNumberOfSamples(); + for (MP4SampleId sid = 1; sid <= samples; sid++) { + SampleSizePropertyAddValue(fixedSampleSize); + } + } + // add size value for this sample + SampleSizePropertyAddValue(numBytes); + } + } + // either way, we increment the number of samples. + m_pStszSampleCountProperty->IncrementValue(); +#if 0 + printf("track %u sample id %u bytes %u fixed %u count %u prop %u\n", + m_trackId, sampleId, numBytes, + m_pStszFixedSampleSizeProperty->GetValue(), + m_pStszSampleSizeProperty->GetCount(), + m_pStszSampleCountProperty->GetValue()); +#endif +} + +uint32_t MP4Track::GetAvgBitrate() +{ + if (GetDuration() == 0) { + return 0; + } + + double calc = double(GetTotalOfSampleSizes()); + // this is a bit better - we use the whole duration + calc *= 8.0; + calc *= GetTimeScale(); + calc /= double(GetDuration()); + // we might want to think about rounding to the next 100 or 1000 + return (uint32_t) ceil(calc); +} + +uint32_t MP4Track::GetMaxBitrate() +{ + uint32_t timeScale = GetTimeScale(); + MP4SampleId numSamples = GetNumberOfSamples(); + uint32_t maxBytesPerSec = 0; + uint32_t bytesThisSec = 0; + MP4Timestamp thisSecStart = 0; + MP4Timestamp lastSampleTime = 0; + uint32_t lastSampleSize = 0; + + MP4SampleId thisSecStartSid = 1; + for (MP4SampleId sid = 1; sid <= numSamples; sid++) { + uint32_t sampleSize; + MP4Timestamp sampleTime; + + sampleSize = GetSampleSize(sid); + GetSampleTimes(sid, &sampleTime, NULL); + + if (sampleTime < thisSecStart + timeScale) { + bytesThisSec += sampleSize; + lastSampleSize = sampleSize; + lastSampleTime = sampleTime; + } else { + // we've already written the last sample and sampleSize. + // this means that we've probably overflowed the last second + // calculate the time we've overflowed + MP4Duration overflow_dur = + (thisSecStart + timeScale) - lastSampleTime; + // calculate the duration of the last sample + MP4Duration lastSampleDur = sampleTime - lastSampleTime; + uint32_t overflow_bytes; + // now, calculate the number of bytes we overflowed. Round up. + overflow_bytes = + ((lastSampleSize * overflow_dur) + (lastSampleDur - 1)) / lastSampleDur; + + if (bytesThisSec - overflow_bytes > maxBytesPerSec) { + maxBytesPerSec = bytesThisSec - overflow_bytes; + } + + // now adjust the values for this sample. Remove the bytes + // from the first sample in this time frame + lastSampleTime = sampleTime; + lastSampleSize = sampleSize; + bytesThisSec += sampleSize; + bytesThisSec -= GetSampleSize(thisSecStartSid); + thisSecStartSid++; + GetSampleTimes(thisSecStartSid, &thisSecStart, NULL); + } + } + + return maxBytesPerSec * 8; +} + +uint32_t MP4Track::GetSampleStscIndex(MP4SampleId sampleId) +{ + uint32_t stscIndex; + uint32_t numStscs = m_pStscCountProperty->GetValue(); + + if (numStscs == 0) { + throw new MP4Error("No data chunks exist", "GetSampleStscIndex"); + } + + for (stscIndex = 0; stscIndex < numStscs; stscIndex++) { + if (sampleId < m_pStscFirstSampleProperty->GetValue(stscIndex)) { + ASSERT(stscIndex != 0); + stscIndex -= 1; + break; + } + } + if (stscIndex == numStscs) { + ASSERT(stscIndex != 0); + stscIndex -= 1; + } + + return stscIndex; +} + +File* MP4Track::GetSampleFile( MP4SampleId sampleId ) +{ + uint32_t stscIndex = GetSampleStscIndex( sampleId ); + uint32_t stsdIndex = m_pStscSampleDescrIndexProperty->GetValue( stscIndex ); + + // check if the answer will be the same as last time + if( m_lastStsdIndex && stsdIndex == m_lastStsdIndex ) + return m_lastSampleFile; + + MP4Atom* pStsdAtom = m_pTrakAtom->FindAtom( "trak.mdia.minf.stbl.stsd" ); + ASSERT( pStsdAtom ); + + MP4Atom* pStsdEntryAtom = pStsdAtom->GetChildAtom( stsdIndex - 1 ); + ASSERT( pStsdEntryAtom ); + + MP4Integer16Property* pDrefIndexProperty = NULL; + if( !pStsdEntryAtom->FindProperty( "*.dataReferenceIndex", (MP4Property**)&pDrefIndexProperty ) || + pDrefIndexProperty == NULL ) + { + throw new MP4Error( "invalid stsd entry", "GetSampleFile" ); + } + + uint32_t drefIndex = pDrefIndexProperty->GetValue(); + + MP4Atom* pDrefAtom = m_pTrakAtom->FindAtom( "trak.mdia.minf.dinf.dref" ); + ASSERT(pDrefAtom); + + MP4Atom* pUrlAtom = pDrefAtom->GetChildAtom( drefIndex - 1 ); + ASSERT( pUrlAtom ); + + File* file; + + if( pUrlAtom->GetFlags() & 1 ) { + file = NULL; // self-contained + } + else { + MP4StringProperty* pLocationProperty = NULL; + ASSERT( pUrlAtom->FindProperty( "*.location", (MP4Property**)&pLocationProperty) ); + ASSERT( pLocationProperty ); + + const char* url = pLocationProperty->GetValue(); + + VERBOSE_READ_SAMPLE( m_pFile->GetVerbosity(), printf( "dref url = %s\n", url) ); + + file = (File*)-1; + + // attempt to open url if it's a file url + // currently this is the only thing we understand + if( !strncmp( url, "file:", 5 )) { + const char* fileName = url + 5; + + if( !strncmp(fileName, "//", 2 )) + fileName = strchr( fileName + 2, '/' ); + + if( fileName ) { + file = new File( fileName, File::MODE_READ ); + if( !file->open() ) { + delete file; + file = (File*)-1; + } + } + } + } + + if( m_lastSampleFile ) + m_lastSampleFile->close(); + + // cache the answer + m_lastStsdIndex = stsdIndex; + m_lastSampleFile = file; + + return file; +} + +uint64_t MP4Track::GetSampleFileOffset(MP4SampleId sampleId) +{ + uint32_t stscIndex = + GetSampleStscIndex(sampleId); + + // firstChunk is the chunk index of the first chunk with + // samplesPerChunk samples in the chunk. There may be multiples - + // ie: several chunks with the same number of samples per chunk. + uint32_t firstChunk = + m_pStscFirstChunkProperty->GetValue(stscIndex); + + MP4SampleId firstSample = + m_pStscFirstSampleProperty->GetValue(stscIndex); + + uint32_t samplesPerChunk = + m_pStscSamplesPerChunkProperty->GetValue(stscIndex); + + // chunkId tells which is the absolute chunk number that this sample + // is stored in. + MP4ChunkId chunkId = firstChunk + + ((sampleId - firstSample) / samplesPerChunk); + + // chunkOffset is the file offset (absolute) for the start of the chunk + uint64_t chunkOffset = m_pChunkOffsetProperty->GetValue(chunkId - 1); + + MP4SampleId firstSampleInChunk = + sampleId - ((sampleId - firstSample) % samplesPerChunk); + + // need cumulative samples sizes from firstSample to sampleId - 1 + uint32_t sampleOffset = 0; + for (MP4SampleId i = firstSampleInChunk; i < sampleId; i++) { + sampleOffset += GetSampleSize(i); + } + + return chunkOffset + sampleOffset; +} + +void MP4Track::UpdateSampleToChunk(MP4SampleId sampleId, + MP4ChunkId chunkId, uint32_t samplesPerChunk) +{ + uint32_t numStsc = m_pStscCountProperty->GetValue(); + + // if samplesPerChunk == samplesPerChunk of last entry + if (numStsc && samplesPerChunk == + m_pStscSamplesPerChunkProperty->GetValue(numStsc-1)) { + + // nothing to do + + } else { + // add stsc entry + m_pStscFirstChunkProperty->AddValue(chunkId); + m_pStscSamplesPerChunkProperty->AddValue(samplesPerChunk); + m_pStscSampleDescrIndexProperty->AddValue(1); + m_pStscFirstSampleProperty->AddValue(sampleId - samplesPerChunk + 1); + + m_pStscCountProperty->IncrementValue(); + } +} + +void MP4Track::UpdateChunkOffsets(uint64_t chunkOffset) +{ + if (m_pChunkOffsetProperty->GetType() == Integer32Property) { + ((MP4Integer32Property*)m_pChunkOffsetProperty)->AddValue(chunkOffset); + } else { + ((MP4Integer64Property*)m_pChunkOffsetProperty)->AddValue(chunkOffset); + } + m_pChunkCountProperty->IncrementValue(); +} + +MP4Duration MP4Track::GetFixedSampleDuration() +{ + uint32_t numStts = m_pSttsCountProperty->GetValue(); + + if (numStts == 0) { + return m_fixedSampleDuration; + } + if (numStts != 1) { + return MP4_INVALID_DURATION; // sample duration is not fixed + } + return m_pSttsSampleDeltaProperty->GetValue(0); +} + +void MP4Track::SetFixedSampleDuration(MP4Duration duration) +{ + uint32_t numStts = m_pSttsCountProperty->GetValue(); + + // setting this is only allowed before samples have been written + if (numStts != 0) { + return; + } + m_fixedSampleDuration = duration; + return; +} + +void MP4Track::GetSampleTimes(MP4SampleId sampleId, + MP4Timestamp* pStartTime, MP4Duration* pDuration) +{ + uint32_t numStts = m_pSttsCountProperty->GetValue(); + MP4SampleId sid; + MP4Duration elapsed; + + + if (m_cachedSttsSid != MP4_INVALID_SAMPLE_ID && sampleId >= m_cachedSttsSid) { + sid = m_cachedSttsSid; + elapsed = m_cachedSttsElapsed; + } else { + m_cachedSttsIndex = 0; + sid = 1; + elapsed = 0; + } + + for (uint32_t sttsIndex = m_cachedSttsIndex; sttsIndex < numStts; sttsIndex++) { + uint32_t sampleCount = + m_pSttsSampleCountProperty->GetValue(sttsIndex); + uint32_t sampleDelta = + m_pSttsSampleDeltaProperty->GetValue(sttsIndex); + + if (sampleId <= sid + sampleCount - 1) { + if (pStartTime) { + *pStartTime = (sampleId - sid); + *pStartTime *= sampleDelta; + *pStartTime += elapsed; + } + if (pDuration) { + *pDuration = sampleDelta; + } + + m_cachedSttsIndex = sttsIndex; + m_cachedSttsSid = sid; + m_cachedSttsElapsed = elapsed; + + return; + } + sid += sampleCount; + elapsed += sampleCount * sampleDelta; + } + + throw new MP4Error("sample id out of range", + "MP4Track::GetSampleTimes"); +} + +MP4SampleId MP4Track::GetSampleIdFromTime( + MP4Timestamp when, + bool wantSyncSample) +{ + uint32_t numStts = m_pSttsCountProperty->GetValue(); + MP4SampleId sid = 1; + MP4Duration elapsed = 0; + + for (uint32_t sttsIndex = 0; sttsIndex < numStts; sttsIndex++) { + uint32_t sampleCount = + m_pSttsSampleCountProperty->GetValue(sttsIndex); + uint32_t sampleDelta = + m_pSttsSampleDeltaProperty->GetValue(sttsIndex); + + if (sampleDelta == 0 && sttsIndex < numStts - 1) { + VERBOSE_READ(m_pFile->GetVerbosity(), + printf("Warning: Zero sample duration, stts entry %u\n", + sttsIndex)); + } + + MP4Duration d = when - elapsed; + + if (d <= sampleCount * sampleDelta) { + MP4SampleId sampleId = sid; + if (sampleDelta) { + sampleId += (d / sampleDelta); + } + + if (wantSyncSample) { + return GetNextSyncSample(sampleId); + } + return sampleId; + } + + sid += sampleCount; + elapsed += sampleCount * sampleDelta; + } + + throw new MP4Error("time out of range", + "MP4Track::GetSampleIdFromTime"); + + return 0; // satisfy MS compiler +} + +void MP4Track::UpdateSampleTimes(MP4Duration duration) +{ + uint32_t numStts = m_pSttsCountProperty->GetValue(); + + // if duration == duration of last entry + if (numStts + && duration == m_pSttsSampleDeltaProperty->GetValue(numStts-1)) { + // increment last entry sampleCount + m_pSttsSampleCountProperty->IncrementValue(1, numStts-1); + + } else { + // add stts entry, sampleCount = 1, sampleDuration = duration + m_pSttsSampleCountProperty->AddValue(1); + m_pSttsSampleDeltaProperty->AddValue(duration); + m_pSttsCountProperty->IncrementValue();; + } +} + +uint32_t MP4Track::GetSampleCttsIndex(MP4SampleId sampleId, + MP4SampleId* pFirstSampleId) +{ + uint32_t numCtts = m_pCttsCountProperty->GetValue(); + + MP4SampleId sid = 1; + + for (uint32_t cttsIndex = 0; cttsIndex < numCtts; cttsIndex++) { + uint32_t sampleCount = + m_pCttsSampleCountProperty->GetValue(cttsIndex); + + if (sampleId <= sid + sampleCount - 1) { + if (pFirstSampleId) { + *pFirstSampleId = sid; + } + return cttsIndex; + } + sid += sampleCount; + } + + throw new MP4Error("sample id out of range", + "MP4Track::GetSampleCttsIndex"); + return 0; // satisfy MS compiler +} + +MP4Duration MP4Track::GetSampleRenderingOffset(MP4SampleId sampleId) +{ + if (m_pCttsCountProperty == NULL) { + return 0; + } + if (m_pCttsCountProperty->GetValue() == 0) { + return 0; + } + + uint32_t cttsIndex = GetSampleCttsIndex(sampleId); + + return m_pCttsSampleOffsetProperty->GetValue(cttsIndex); +} + +void MP4Track::UpdateRenderingOffsets(MP4SampleId sampleId, + MP4Duration renderingOffset) +{ + // if ctts atom doesn't exist + if (m_pCttsCountProperty == NULL) { + + // no rendering offset, so nothing to do + if (renderingOffset == 0) { + return; + } + + // else create a ctts atom + MP4Atom* pCttsAtom = AddAtom("trak.mdia.minf.stbl", "ctts"); + + // and get handles on the properties + ASSERT(pCttsAtom->FindProperty( + "ctts.entryCount", + (MP4Property**)&m_pCttsCountProperty)); + + ASSERT(pCttsAtom->FindProperty( + "ctts.entries.sampleCount", + (MP4Property**)&m_pCttsSampleCountProperty)); + + ASSERT(pCttsAtom->FindProperty( + "ctts.entries.sampleOffset", + (MP4Property**)&m_pCttsSampleOffsetProperty)); + + // if this is not the first sample + if (sampleId > 1) { + // add a ctts entry for all previous samples + // with rendering offset equal to zero + m_pCttsSampleCountProperty->AddValue(sampleId - 1); + m_pCttsSampleOffsetProperty->AddValue(0); + m_pCttsCountProperty->IncrementValue();; + } + } + + // ctts atom exists (now) + + uint32_t numCtts = m_pCttsCountProperty->GetValue(); + + // if renderingOffset == renderingOffset of last entry + if (numCtts && renderingOffset + == m_pCttsSampleOffsetProperty->GetValue(numCtts-1)) { + + // increment last entry sampleCount + m_pCttsSampleCountProperty->IncrementValue(1, numCtts-1); + + } else { + // add ctts entry, sampleCount = 1, sampleOffset = renderingOffset + m_pCttsSampleCountProperty->AddValue(1); + m_pCttsSampleOffsetProperty->AddValue(renderingOffset); + m_pCttsCountProperty->IncrementValue(); + } +} + +void MP4Track::SetSampleRenderingOffset(MP4SampleId sampleId, + MP4Duration renderingOffset) +{ + // check if any ctts entries exist + if (m_pCttsCountProperty == NULL + || m_pCttsCountProperty->GetValue() == 0) { + // if not then Update routine can be used + // to create a ctts entry for samples before this one + // and a ctts entry for this sample + UpdateRenderingOffsets(sampleId, renderingOffset); + + // but we also need a ctts entry + // for all samples after this one + uint32_t afterSamples = GetNumberOfSamples() - sampleId; + + if (afterSamples) { + m_pCttsSampleCountProperty->AddValue(afterSamples); + m_pCttsSampleOffsetProperty->AddValue(0); + m_pCttsCountProperty->IncrementValue();; + } + + return; + } + + MP4SampleId firstSampleId; + uint32_t cttsIndex = GetSampleCttsIndex(sampleId, &firstSampleId); + + // do nothing in the degenerate case + if (renderingOffset == + m_pCttsSampleOffsetProperty->GetValue(cttsIndex)) { + return; + } + + uint32_t sampleCount = + m_pCttsSampleCountProperty->GetValue(cttsIndex); + + // if this sample has it's own ctts entry + if (sampleCount == 1) { + // then just set the value, + // note we don't attempt to collapse entries + m_pCttsSampleOffsetProperty->SetValue(renderingOffset, cttsIndex); + return; + } + + MP4SampleId lastSampleId = firstSampleId + sampleCount - 1; + + // else we share this entry with other samples + // we need to insert our own entry + if (sampleId == firstSampleId) { + // our sample is the first one + m_pCttsSampleCountProperty-> + InsertValue(1, cttsIndex); + m_pCttsSampleOffsetProperty-> + InsertValue(renderingOffset, cttsIndex); + + m_pCttsSampleCountProperty-> + SetValue(sampleCount - 1, cttsIndex + 1); + + m_pCttsCountProperty->IncrementValue(); + + } else if (sampleId == lastSampleId) { + // our sample is the last one + m_pCttsSampleCountProperty-> + InsertValue(1, cttsIndex + 1); + m_pCttsSampleOffsetProperty-> + InsertValue(renderingOffset, cttsIndex + 1); + + m_pCttsSampleCountProperty-> + SetValue(sampleCount - 1, cttsIndex); + + m_pCttsCountProperty->IncrementValue(); + + } else { + // our sample is in the middle, UGH! + + // insert our new entry + m_pCttsSampleCountProperty-> + InsertValue(1, cttsIndex + 1); + m_pCttsSampleOffsetProperty-> + InsertValue(renderingOffset, cttsIndex + 1); + + // adjust count of previous entry + m_pCttsSampleCountProperty-> + SetValue(sampleId - firstSampleId, cttsIndex); + + // insert new entry for those samples beyond our sample + m_pCttsSampleCountProperty-> + InsertValue(lastSampleId - sampleId, cttsIndex + 2); + uint32_t oldRenderingOffset = + m_pCttsSampleOffsetProperty->GetValue(cttsIndex); + m_pCttsSampleOffsetProperty-> + InsertValue(oldRenderingOffset, cttsIndex + 2); + + m_pCttsCountProperty->IncrementValue(2); + } +} + +bool MP4Track::IsSyncSample(MP4SampleId sampleId) +{ + if (m_pStssCountProperty == NULL) { + return true; + } + + uint32_t numStss = m_pStssCountProperty->GetValue(); + uint32_t stssLIndex = 0; + uint32_t stssRIndex = numStss - 1; + + while (stssRIndex >= stssLIndex) { + uint32_t stssIndex = (stssRIndex + stssLIndex) >> 1; + MP4SampleId syncSampleId = + m_pStssSampleProperty->GetValue(stssIndex); + + if (sampleId == syncSampleId) { + return true; + } + + if (sampleId > syncSampleId) { + stssLIndex = stssIndex + 1; + } else { + stssRIndex = stssIndex - 1; + } + } + + return false; +} + +// N.B. "next" is inclusive of this sample id +MP4SampleId MP4Track::GetNextSyncSample(MP4SampleId sampleId) +{ + if (m_pStssCountProperty == NULL) { + return sampleId; + } + + uint32_t numStss = m_pStssCountProperty->GetValue(); + + for (uint32_t stssIndex = 0; stssIndex < numStss; stssIndex++) { + MP4SampleId syncSampleId = + m_pStssSampleProperty->GetValue(stssIndex); + + if (sampleId > syncSampleId) { + continue; + } + return syncSampleId; + } + + // LATER check stsh for alternate sample + + return MP4_INVALID_SAMPLE_ID; +} + +void MP4Track::UpdateSyncSamples(MP4SampleId sampleId, bool isSyncSample) +{ + if (isSyncSample) { + // if stss atom exists, add entry + if (m_pStssCountProperty) { + m_pStssSampleProperty->AddValue(sampleId); + m_pStssCountProperty->IncrementValue(); + } // else nothing to do (yet) + + } else { // !isSyncSample + // if stss atom doesn't exist, create one + if (m_pStssCountProperty == NULL) { + + MP4Atom* pStssAtom = AddAtom("trak.mdia.minf.stbl", "stss"); + + ASSERT(pStssAtom->FindProperty( + "stss.entryCount", + (MP4Property**)&m_pStssCountProperty)); + + ASSERT(pStssAtom->FindProperty( + "stss.entries.sampleNumber", + (MP4Property**)&m_pStssSampleProperty)); + + // set values for all samples that came before this one + uint32_t samples = GetNumberOfSamples(); + for (MP4SampleId sid = 1; sid < samples; sid++) { + m_pStssSampleProperty->AddValue(sid); + m_pStssCountProperty->IncrementValue(); + } + } // else nothing to do + } +} + +MP4Atom* MP4Track::AddAtom(const char* parentName, const char* childName) +{ + MP4Atom* pParentAtom = m_pTrakAtom->FindAtom(parentName); + ASSERT(pParentAtom); + + MP4Atom* pChildAtom = MP4Atom::CreateAtom(pParentAtom, childName); + + pParentAtom->AddChildAtom(pChildAtom); + + pChildAtom->Generate(); + + return pChildAtom; +} + +uint64_t MP4Track::GetDuration() +{ + return m_pMediaDurationProperty->GetValue(); +} + +uint32_t MP4Track::GetTimeScale() +{ + return m_pTimeScaleProperty->GetValue(); +} + +void MP4Track::UpdateDurations(MP4Duration duration) +{ + // update media, track, and movie durations + m_pMediaDurationProperty->SetValue( + m_pMediaDurationProperty->GetValue() + duration); + + MP4Duration movieDuration = ToMovieDuration( + m_pMediaDurationProperty->GetValue()); + m_pTrackDurationProperty->SetValue(movieDuration); + + m_pFile->UpdateDuration(m_pTrackDurationProperty->GetValue()); +} + +MP4Duration MP4Track::ToMovieDuration(MP4Duration trackDuration) +{ + return (trackDuration * m_pFile->GetTimeScale()) + / m_pTimeScaleProperty->GetValue(); +} + +void MP4Track::UpdateModificationTimes() +{ + // update media and track modification times + MP4Timestamp now = MP4GetAbsTimestamp(); + m_pMediaModificationProperty->SetValue(now); + m_pTrackModificationProperty->SetValue(now); +} + +uint32_t MP4Track::GetNumberOfChunks() +{ + return m_pChunkOffsetProperty->GetCount(); +} + +uint32_t MP4Track::GetChunkStscIndex(MP4ChunkId chunkId) +{ + uint32_t stscIndex; + uint32_t numStscs = m_pStscCountProperty->GetValue(); + + ASSERT(chunkId); + ASSERT(numStscs > 0); + + for (stscIndex = 0; stscIndex < numStscs; stscIndex++) { + if (chunkId < m_pStscFirstChunkProperty->GetValue(stscIndex)) { + ASSERT(stscIndex != 0); + break; + } + } + return stscIndex - 1; +} + +MP4Timestamp MP4Track::GetChunkTime(MP4ChunkId chunkId) +{ + uint32_t stscIndex = GetChunkStscIndex(chunkId); + + MP4ChunkId firstChunkId = + m_pStscFirstChunkProperty->GetValue(stscIndex); + + MP4SampleId firstSample = + m_pStscFirstSampleProperty->GetValue(stscIndex); + + uint32_t samplesPerChunk = + m_pStscSamplesPerChunkProperty->GetValue(stscIndex); + + MP4SampleId firstSampleInChunk = + firstSample + ((chunkId - firstChunkId) * samplesPerChunk); + + MP4Timestamp chunkTime; + + GetSampleTimes(firstSampleInChunk, &chunkTime, NULL); + + return chunkTime; +} + +uint32_t MP4Track::GetChunkSize(MP4ChunkId chunkId) +{ + uint32_t stscIndex = GetChunkStscIndex(chunkId); + + MP4ChunkId firstChunkId = + m_pStscFirstChunkProperty->GetValue(stscIndex); + + MP4SampleId firstSample = + m_pStscFirstSampleProperty->GetValue(stscIndex); + + uint32_t samplesPerChunk = + m_pStscSamplesPerChunkProperty->GetValue(stscIndex); + + MP4SampleId firstSampleInChunk = + firstSample + ((chunkId - firstChunkId) * samplesPerChunk); + + // need cumulative sizes of samples in chunk + uint32_t chunkSize = 0; + for (uint32_t i = 0; i < samplesPerChunk; i++) { + chunkSize += GetSampleSize(firstSampleInChunk + i); + } + + return chunkSize; +} + +void MP4Track::ReadChunk(MP4ChunkId chunkId, + uint8_t** ppChunk, uint32_t* pChunkSize) +{ + ASSERT(chunkId); + ASSERT(ppChunk); + ASSERT(pChunkSize); + + uint64_t chunkOffset = + m_pChunkOffsetProperty->GetValue(chunkId - 1); + + *pChunkSize = GetChunkSize(chunkId); + *ppChunk = (uint8_t*)MP4Malloc(*pChunkSize); + + VERBOSE_READ_SAMPLE(m_pFile->GetVerbosity(), + printf("ReadChunk: track %u id %u offset 0x%" PRIx64 " size %u (0x%x)\n", + m_trackId, chunkId, chunkOffset, *pChunkSize, *pChunkSize)); + + uint64_t oldPos = m_pFile->GetPosition(); // only used in mode == 'w' + try { + m_pFile->SetPosition( chunkOffset ); + m_pFile->ReadBytes( *ppChunk, *pChunkSize ); + } + catch( MP4Error* e ) { + MP4Free( *ppChunk ); + *ppChunk = NULL; + + if( m_pFile->IsWriteMode() ) + m_pFile->SetPosition( oldPos ); + + throw e; + } + + if( m_pFile->IsWriteMode() ) + m_pFile->SetPosition( oldPos ); +} + +void MP4Track::RewriteChunk(MP4ChunkId chunkId, + uint8_t* pChunk, uint32_t chunkSize) +{ + uint64_t chunkOffset = m_pFile->GetPosition(); + + m_pFile->WriteBytes(pChunk, chunkSize); + + m_pChunkOffsetProperty->SetValue(chunkOffset, chunkId - 1); + + VERBOSE_WRITE_SAMPLE(m_pFile->GetVerbosity(), + printf("RewriteChunk: track %u id %u offset 0x%" PRIx64 " size %u (0x%x)\n", + m_trackId, chunkId, chunkOffset, chunkSize, chunkSize)); +} + +// map track type name aliases to official names + + +bool MP4Track::InitEditListProperties() +{ + m_pElstCountProperty = NULL; + m_pElstMediaTimeProperty = NULL; + m_pElstDurationProperty = NULL; + m_pElstRateProperty = NULL; + m_pElstReservedProperty = NULL; + + MP4Atom* pElstAtom = + m_pTrakAtom->FindAtom("trak.edts.elst"); + + if (!pElstAtom) { + return false; + } + + (void)pElstAtom->FindProperty( + "elst.entryCount", + (MP4Property**)&m_pElstCountProperty); + (void)pElstAtom->FindProperty( + "elst.entries.mediaTime", + (MP4Property**)&m_pElstMediaTimeProperty); + (void)pElstAtom->FindProperty( + "elst.entries.segmentDuration", + (MP4Property**)&m_pElstDurationProperty); + (void)pElstAtom->FindProperty( + "elst.entries.mediaRate", + (MP4Property**)&m_pElstRateProperty); + + (void)pElstAtom->FindProperty( + "elst.entries.reserved", + (MP4Property**)&m_pElstReservedProperty); + + return m_pElstCountProperty + && m_pElstMediaTimeProperty + && m_pElstDurationProperty + && m_pElstRateProperty + && m_pElstReservedProperty; +} + +MP4EditId MP4Track::AddEdit(MP4EditId editId) +{ + if (!m_pElstCountProperty) { + (void)m_pFile->AddDescendantAtoms(m_pTrakAtom, "edts.elst"); + if (InitEditListProperties() == false) return MP4_INVALID_EDIT_ID; + } + + if (editId == MP4_INVALID_EDIT_ID) { + editId = m_pElstCountProperty->GetValue() + 1; + } + + m_pElstMediaTimeProperty->InsertValue(0, editId - 1); + m_pElstDurationProperty->InsertValue(0, editId - 1); + m_pElstRateProperty->InsertValue(1, editId - 1); + m_pElstReservedProperty->InsertValue(0, editId - 1); + + m_pElstCountProperty->IncrementValue(); + + return editId; +} + +void MP4Track::DeleteEdit(MP4EditId editId) +{ + if (editId == MP4_INVALID_EDIT_ID) { + throw new MP4Error("edit id can't be zero", + "MP4Track::DeleteEdit"); + } + + if (!m_pElstCountProperty + || m_pElstCountProperty->GetValue() == 0) { + throw new MP4Error("no edits exist", + "MP4Track::DeleteEdit"); + } + + m_pElstMediaTimeProperty->DeleteValue(editId - 1); + m_pElstDurationProperty->DeleteValue(editId - 1); + m_pElstRateProperty->DeleteValue(editId - 1); + m_pElstReservedProperty->DeleteValue(editId - 1); + + m_pElstCountProperty->IncrementValue(-1); + + // clean up if last edit is deleted + if (m_pElstCountProperty->GetValue() == 0) { + m_pElstCountProperty = NULL; + m_pElstMediaTimeProperty = NULL; + m_pElstDurationProperty = NULL; + m_pElstRateProperty = NULL; + m_pElstReservedProperty = NULL; + + m_pTrakAtom->DeleteChildAtom( + m_pTrakAtom->FindAtom("trak.edts")); + } +} + +MP4Timestamp MP4Track::GetEditStart( + MP4EditId editId) +{ + if (editId == MP4_INVALID_EDIT_ID) { + return MP4_INVALID_TIMESTAMP; + } else if (editId == 1) { + return 0; + } + return (MP4Timestamp)GetEditTotalDuration(editId - 1); +} + +MP4Duration MP4Track::GetEditTotalDuration( + MP4EditId editId) +{ + uint32_t numEdits = 0; + + if (m_pElstCountProperty) { + numEdits = m_pElstCountProperty->GetValue(); + } + + if (editId == MP4_INVALID_EDIT_ID) { + editId = numEdits; + } + + if (numEdits == 0 || editId > numEdits) { + return MP4_INVALID_DURATION; + } + + MP4Duration totalDuration = 0; + + for (MP4EditId eid = 1; eid <= editId; eid++) { + totalDuration += + m_pElstDurationProperty->GetValue(eid - 1); + } + + return totalDuration; +} + +MP4SampleId MP4Track::GetSampleIdFromEditTime( + MP4Timestamp editWhen, + MP4Timestamp* pStartTime, + MP4Duration* pDuration) +{ + MP4SampleId sampleId = MP4_INVALID_SAMPLE_ID; + uint32_t numEdits = 0; + + if (m_pElstCountProperty) { + numEdits = m_pElstCountProperty->GetValue(); + } + + if (numEdits) { + MP4Duration editElapsedDuration = 0; + + for (MP4EditId editId = 1; editId <= numEdits; editId++) { + // remember edit segment's start time (in edit timeline) + MP4Timestamp editStartTime = + (MP4Timestamp)editElapsedDuration; + + // accumulate edit segment's duration + editElapsedDuration += + m_pElstDurationProperty->GetValue(editId - 1); + + // calculate difference between the specified edit time + // and the end of this edit segment + if (editElapsedDuration - editWhen <= 0) { + // the specified time has not yet been reached + continue; + } + + // 'editWhen' is within this edit segment + + // calculate the specified edit time + // relative to just this edit segment + MP4Duration editOffset = + editWhen - editStartTime; + + // calculate the media (track) time that corresponds + // to the specified edit time based on the edit list + MP4Timestamp mediaWhen = + m_pElstMediaTimeProperty->GetValue(editId - 1) + + editOffset; + + // lookup the sample id for the media time + sampleId = GetSampleIdFromTime(mediaWhen, false); + + // lookup the sample's media start time and duration + MP4Timestamp sampleStartTime; + MP4Duration sampleDuration; + + GetSampleTimes(sampleId, &sampleStartTime, &sampleDuration); + + // calculate the difference if any between when the sample + // would naturally start and when it starts in the edit timeline + MP4Duration sampleStartOffset = + mediaWhen - sampleStartTime; + + // calculate the start time for the sample in the edit time line + MP4Timestamp editSampleStartTime = + editWhen - min(editOffset, sampleStartOffset); + + MP4Duration editSampleDuration = 0; + + // calculate how long this sample lasts in the edit list timeline + if (m_pElstRateProperty->GetValue(editId - 1) == 0) { + // edit segment is a "dwell" + // so sample duration is that of the edit segment + editSampleDuration = + m_pElstDurationProperty->GetValue(editId - 1); + + } else { + // begin with the natural sample duration + editSampleDuration = sampleDuration; + + // now shorten that if the edit segment starts + // after the sample would naturally start + if (editOffset < sampleStartOffset) { + editSampleDuration -= sampleStartOffset - editOffset; + } + + // now shorten that if the edit segment ends + // before the sample would naturally end + if (editElapsedDuration + < editSampleStartTime + sampleDuration) { + editSampleDuration -= (editSampleStartTime + sampleDuration) + - editElapsedDuration; + } + } + + if (pStartTime) { + *pStartTime = editSampleStartTime; + } + + if (pDuration) { + *pDuration = editSampleDuration; + } + + VERBOSE_EDIT(m_pFile->GetVerbosity(), + printf("GetSampleIdFromEditTime: when %" PRIu64 " " + "sampleId %u start %" PRIu64 " duration %" PRId64 "\n", + editWhen, sampleId, + editSampleStartTime, editSampleDuration)); + + return sampleId; + } + + throw new MP4Error("time out of range", + "MP4Track::GetSampleIdFromEditTime"); + + } else { // no edit list + sampleId = GetSampleIdFromTime(editWhen, false); + + if (pStartTime || pDuration) { + GetSampleTimes(sampleId, pStartTime, pDuration); + } + } + + return sampleId; +} + +void MP4Track::CalculateBytesPerSample () +{ + MP4Atom *pMedia = m_pTrakAtom->FindAtom("trak.mdia.minf.stbl.stsd"); + MP4Atom *pMediaData; + const char *media_data_name; + if (pMedia == NULL) return; + + if (pMedia->GetNumberOfChildAtoms() != 1) return; + + pMediaData = pMedia->GetChildAtom(0); + media_data_name = pMediaData->GetType(); + if ((ATOMID(media_data_name) == ATOMID("twos")) || + (ATOMID(media_data_name) == ATOMID("sowt"))) { + MP4IntegerProperty *chan, *sampleSize; + chan = (MP4IntegerProperty *)pMediaData->GetProperty(4); + sampleSize = (MP4IntegerProperty *)pMediaData->GetProperty(5); + m_bytesPerSample = chan->GetValue() * (sampleSize->GetValue() / 8); + } +} + +MP4Duration MP4Track::GetDurationPerChunk() +{ + return m_durationPerChunk; +} + +void MP4Track::SetDurationPerChunk( MP4Duration duration ) +{ + m_durationPerChunk = duration; +} + +/////////////////////////////////////////////////////////////////////////////// + +}} // namespace mp4v2::impl diff --git a/src/mp4track.h b/src/mp4track.h new file mode 100644 index 0000000..dc103e1 --- /dev/null +++ b/src/mp4track.h @@ -0,0 +1,288 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001 - 2004. All Rights Reserved. + * + * 3GPP features implementation is based on 3GPP's TS26.234-v5.60, + * and was contributed by Ximpo Group Ltd. + * + * Portions created by Ximpo Group Ltd. are + * Copyright (C) Ximpo Group Ltd. 2003, 2004. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + * Ximpo Group Ltd. mp4v2@ximpo.com + */ + +#ifndef MP4V2_IMPL_MP4TRACK_H +#define MP4V2_IMPL_MP4TRACK_H + +namespace mp4v2 { namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +typedef uint32_t MP4ChunkId; + +// forward declarations +class MP4File; +class MP4Atom; +class MP4Property; +class MP4IntegerProperty; +class MP4Integer8Property; +class MP4Integer16Property; +class MP4Integer32Property; +class MP4Integer64Property; +class MP4StringProperty; + +class MP4Track +{ +public: + MP4Track(MP4File* pFile, MP4Atom* pTrakAtom); + + virtual ~MP4Track(); + + MP4TrackId GetId() { + return m_trackId; + } + + const char* GetType(); + + void SetType(const char* type); + + MP4File* GetFile() { + return m_pFile; + } + + MP4Atom* GetTrakAtom() { + return m_pTrakAtom; + } + + void ReadSample( + // input parameters + MP4SampleId sampleId, + // output parameters + uint8_t** ppBytes, + uint32_t* pNumBytes, + MP4Timestamp* pStartTime = NULL, + MP4Duration* pDuration = NULL, + MP4Duration* pRenderingOffset = NULL, + bool* pIsSyncSample = NULL); + + void WriteSample( + const uint8_t* pBytes, + uint32_t numBytes, + MP4Duration duration = 0, + MP4Duration renderingOffset = 0, + bool isSyncSample = true); + + void WriteSampleDependency( + const uint8_t* pBytes, + uint32_t numBytes, + MP4Duration duration, + MP4Duration renderingOffset, + bool isSyncSample, + uint32_t dependencyFlags ); + + virtual void FinishWrite(); + + uint64_t GetDuration(); // in track timeScale units + uint32_t GetTimeScale(); + uint32_t GetNumberOfSamples(); + uint32_t GetSampleSize(MP4SampleId sampleId); + uint32_t GetMaxSampleSize(); + uint64_t GetTotalOfSampleSizes(); + uint32_t GetAvgBitrate(); // in bps + uint32_t GetMaxBitrate(); // in bps + + MP4Duration GetFixedSampleDuration(); + void SetFixedSampleDuration(MP4Duration duration); + + void GetSampleTimes(MP4SampleId sampleId, + MP4Timestamp* pStartTime, MP4Duration* pDuration); + + bool IsSyncSample(MP4SampleId sampleId); + + MP4SampleId GetSampleIdFromTime( + MP4Timestamp when, + bool wantSyncSample = false); + + MP4Duration GetSampleRenderingOffset(MP4SampleId sampleId); + void SetSampleRenderingOffset(MP4SampleId sampleId, + MP4Duration renderingOffset); + + MP4EditId AddEdit( + MP4EditId editId = MP4_INVALID_EDIT_ID); + + void DeleteEdit( + MP4EditId editId); + + MP4Timestamp GetEditStart( + MP4EditId editId); + + MP4Timestamp GetEditTotalDuration( + MP4EditId editId); + + MP4SampleId GetSampleIdFromEditTime( + MP4Timestamp editWhen, + MP4Timestamp* pStartTime = NULL, + MP4Duration* pDuration = NULL); + + // special operation for use during hint track packet assembly + void ReadSampleFragment( + MP4SampleId sampleId, + uint32_t sampleOffset, + uint16_t sampleLength, + uint8_t* pDest); + + // special operations for use during optimization + + uint32_t GetNumberOfChunks(); + + MP4Timestamp GetChunkTime(MP4ChunkId chunkId); + + void ReadChunk(MP4ChunkId chunkId, + uint8_t** ppChunk, uint32_t* pChunkSize); + + void RewriteChunk(MP4ChunkId chunkId, + uint8_t* pChunk, uint32_t chunkSize); + + MP4Duration GetDurationPerChunk(); + void SetDurationPerChunk( MP4Duration ); + +protected: + bool InitEditListProperties(); + + File* GetSampleFile( MP4SampleId sampleId ); + uint64_t GetSampleFileOffset(MP4SampleId sampleId); + uint32_t GetSampleStscIndex(MP4SampleId sampleId); + uint32_t GetChunkStscIndex(MP4ChunkId chunkId); + uint32_t GetChunkSize(MP4ChunkId chunkId); + uint32_t GetSampleCttsIndex(MP4SampleId sampleId, + MP4SampleId* pFirstSampleId = NULL); + MP4SampleId GetNextSyncSample(MP4SampleId sampleId); + + void UpdateSampleSizes(MP4SampleId sampleId, + uint32_t numBytes); + bool IsChunkFull(MP4SampleId sampleId); + void UpdateSampleToChunk(MP4SampleId sampleId, + MP4ChunkId chunkId, uint32_t samplesPerChunk); + void UpdateChunkOffsets(uint64_t chunkOffset); + void UpdateSampleTimes(MP4Duration duration); + void UpdateRenderingOffsets(MP4SampleId sampleId, + MP4Duration renderingOffset); + void UpdateSyncSamples(MP4SampleId sampleId, + bool isSyncSample); + + MP4Atom* AddAtom(const char* parentName, const char* childName); + + void UpdateDurations(MP4Duration duration); + MP4Duration ToMovieDuration(MP4Duration trackDuration); + + void UpdateModificationTimes(); + + void WriteChunkBuffer(); + + void CalculateBytesPerSample(); + + void FinishSdtp(); + +protected: + MP4File* m_pFile; + MP4Atom* m_pTrakAtom; // moov.trak[] + MP4TrackId m_trackId; // moov.trak[].tkhd.trackId + MP4StringProperty* m_pTypeProperty; // moov.trak[].mdia.hdlr.handlerType + + uint32_t m_lastStsdIndex; + File* m_lastSampleFile; + + // for efficient construction of hint track packets + MP4SampleId m_cachedReadSampleId; + uint8_t* m_pCachedReadSample; + uint32_t m_cachedReadSampleSize; + + // for writing + MP4SampleId m_writeSampleId; + MP4Duration m_fixedSampleDuration; + uint8_t* m_pChunkBuffer; + uint32_t m_chunkBufferSize; + uint32_t m_chunkSamples; + MP4Duration m_chunkDuration; + + // controls for chunking + uint32_t m_samplesPerChunk; + MP4Duration m_durationPerChunk; + + uint32_t m_bytesPerSample; + + // controls for AMR chunking + int m_isAmr; + uint8_t m_curMode; + + MP4Integer32Property* m_pTimeScaleProperty; + MP4IntegerProperty* m_pTrackDurationProperty; // 32 or 64 bits + MP4IntegerProperty* m_pMediaDurationProperty; // 32 or 64 bits + MP4IntegerProperty* m_pTrackModificationProperty; // 32 or 64 bits + MP4IntegerProperty* m_pMediaModificationProperty; // 32 or 64 bits + + MP4Integer32Property* m_pStszFixedSampleSizeProperty; + MP4Integer32Property* m_pStszSampleCountProperty; + + void SampleSizePropertyAddValue(uint32_t bytes); + uint8_t m_stsz_sample_bits; + bool m_have_stz2_4bit_sample; + uint8_t m_stz2_4bit_sample_value; + MP4IntegerProperty* m_pStszSampleSizeProperty; + + MP4Integer32Property* m_pStscCountProperty; + MP4Integer32Property* m_pStscFirstChunkProperty; + MP4Integer32Property* m_pStscSamplesPerChunkProperty; + MP4Integer32Property* m_pStscSampleDescrIndexProperty; + MP4Integer32Property* m_pStscFirstSampleProperty; + + MP4Integer32Property* m_pChunkCountProperty; + MP4IntegerProperty* m_pChunkOffsetProperty; // 32 or 64 bits + + MP4Integer32Property* m_pSttsCountProperty; + MP4Integer32Property* m_pSttsSampleCountProperty; + MP4Integer32Property* m_pSttsSampleDeltaProperty; + + // for improve sequental timestamp index access + uint32_t m_cachedSttsIndex; + MP4SampleId m_cachedSttsSid; + MP4Timestamp m_cachedSttsElapsed; + + MP4Integer32Property* m_pCttsCountProperty; + MP4Integer32Property* m_pCttsSampleCountProperty; + MP4Integer32Property* m_pCttsSampleOffsetProperty; + + MP4Integer32Property* m_pStssCountProperty; + MP4Integer32Property* m_pStssSampleProperty; + + MP4Integer32Property* m_pElstCountProperty; + MP4IntegerProperty* m_pElstMediaTimeProperty; // 32 or 64 bits + MP4IntegerProperty* m_pElstDurationProperty; // 32 or 64 bits + MP4Integer16Property* m_pElstRateProperty; + MP4Integer16Property* m_pElstReservedProperty; + + string m_sdtpLog; // records frame types for H264 samples +}; + +MP4ARRAY_DECL(MP4Track, MP4Track*); + +/////////////////////////////////////////////////////////////////////////////// + +}} // namespace mp4v2::impl + +#endif // MP4V2_IMPL_MP4TRACK_H diff --git a/src/mp4util.cpp b/src/mp4util.cpp new file mode 100644 index 0000000..46b2f17 --- /dev/null +++ b/src/mp4util.cpp @@ -0,0 +1,494 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001-2005. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + * Bill May wmay@cisco.com + */ + +#include "src/impl.h" + +namespace mp4v2 { namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +namespace { + lib_message_func_t libfunc = NULL; +} + +/////////////////////////////////////////////////////////////////////////////// + +enum LogLevel { + _LOGLEVEL_UNDEFINED = -1, + + LOGLEVEL_EMERG, + LOGLEVEL_ALERT, + LOGLEVEL_CRIT, + LOGLEVEL_ERR, + LOGLEVEL_WARNING, + LOGLEVEL_NOTICE, + LOGLEVEL_INFO, + LOGLEVEL_DEBUG, + + _LOGLEVEL_MAX, +}; + +/////////////////////////////////////////////////////////////////////////////// + +MP4Error::MP4Error() + : m_errno ( 0 ) + , m_errstring ( NULL ) + , m_where ( NULL ) + , m_free ( false ) +{ +} + +MP4Error::MP4Error( int err, const char* where ) + : m_errno ( err ) + , m_errstring ( NULL ) + , m_where ( where ) + , m_free ( false ) +{ +} + +MP4Error::MP4Error(const char *format, const char *where, ...) + : m_errno ( 0 ) + , m_errstring ( format ) + , m_where ( where ) + , m_free ( false ) +{ + char* text = (char*)malloc( 512 ); + if( !text ) + return; + + va_list ap; + va_start( ap, where ); + vsnprintf( text, 512, format, ap ); + va_end( ap ); + m_errstring = text; + m_free = true; +} + +MP4Error::MP4Error( int err, const char* format, const char* where, ... ) + : m_errno ( err ) + , m_errstring ( format ) + , m_where ( where ) + , m_free ( false ) +{ + char* text = (char*)malloc( 512 ); + if( !text ) + return; + + va_list ap; + va_start( ap, where ); + vsnprintf( text, 512, format, ap ); + va_end( ap ); + m_errstring = text; + m_free = true; +} + +MP4Error::~MP4Error() +{ + if( m_free && m_errstring ) + free( (void*)m_errstring ); +} + +void +MP4Error::Print( FILE* pFile ) +{ + if (libfunc != NULL) { + (libfunc)(LOGLEVEL_ERR, "MP4ERROR", "%s:%s:%s", + m_where == NULL ? "" : m_where, + m_errstring == NULL ? "" : m_errstring, + m_errno ? strerror(m_errno) : ""); + return; + } + fprintf(pFile, "MP4ERROR: "); + if (m_where) { + fprintf(pFile, "%s", m_where); + } + if (m_errstring) { + if (m_where) { + fprintf(pFile, ": "); + } + fprintf(pFile, "%s", m_errstring); + } + if (m_errno) { + if (m_where || m_errstring) { + fprintf(pFile, ": "); + } + fprintf(pFile, "%s", strerror(m_errno)); + } + fprintf(pFile, "\n"); +} + +/////////////////////////////////////////////////////////////////////////////// + +void MP4HexDump( + uint8_t* pBytes, uint32_t numBytes, + FILE* pFile, uint8_t indent) +{ + if (pFile == NULL) { + pFile = stdout; + } + Indent(pFile, indent); + fprintf(pFile, "<%u bytes> ", numBytes); + for (uint32_t i = 0; i < numBytes; i++) { + if ((i % 16) == 0 && numBytes > 16) { + fprintf(pFile, "\n"); + Indent(pFile, indent); + } + fprintf(pFile, "%02x ", pBytes[i]); + } + fprintf(pFile, "\n"); +} + +bool MP4NameFirstMatches(const char* s1, const char* s2) +{ + if (s1 == NULL || *s1 == '\0' || s2 == NULL || *s2 == '\0') { + return false; + } + + if (*s2 == '*') { + return true; + } + + while (*s1 != '\0') { + if (*s2 == '\0' || strchr("[.", *s2)) { + break; + } + if (tolower((unsigned char)*s1) != tolower((unsigned char)*s2)) { + return false; + } + s1++; + s2++; + } + return true; +} + +bool MP4NameFirstIndex(const char* s, uint32_t* pIndex) +{ + if (s == NULL) { + return false; + } + + while (*s != '\0' && *s != '.') { + if (*s == '[') { + s++; + ASSERT(pIndex); + if (sscanf(s, "%u", pIndex) != 1) { + return false; + } + return true; + } + s++; + } + return false; +} + +char* MP4NameFirst(const char *s) +{ + if (s == NULL) { + return NULL; + } + + const char* end = s; + + while (*end != '\0' && *end != '.') { + end++; + } + + char* first = (char*)MP4Calloc((end - s) + 1); + + if (first) { + strncpy(first, s, end - s); + } + + return first; +} + +const char* MP4NameAfterFirst(const char *s) +{ + if (s == NULL) { + return NULL; + } + + while (*s != '\0') { + if (*s == '.') { + s++; + if (*s == '\0') { + return NULL; + } + return s; + } + s++; + } + return NULL; +} + +char* MP4ToBase16(const uint8_t* pData, uint32_t dataSize) +{ + if (dataSize) { + ASSERT(pData); + } + uint32_t size = 2 * dataSize + 1; + char* s = (char*)MP4Calloc(size); + + uint32_t i, j; + for (i = 0, j = 0; i < dataSize; i++) { + size -= snprintf(&s[j], size, "%02x", pData[i]); + j += 2; + } + + return s; /* N.B. caller is responsible for free'ing s */ +} + +char* MP4ToBase64(const uint8_t* pData, uint32_t dataSize) +{ + if (pData == NULL || dataSize == 0) return NULL; + + static const char encoding[64] = { + 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P', + 'Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f', + 'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v', + 'w','x','y','z','0','1','2','3','4','5','6','7','8','9','+','/' + }; + + char* s = (char*)MP4Calloc((((dataSize + 2) * 4) / 3) + 1); + + const uint8_t* src = pData; + if (pData == NULL) return NULL; + char* dest = s; + uint32_t numGroups = dataSize / 3; + + for (uint32_t i = 0; i < numGroups; i++) { + *dest++ = encoding[src[0] >> 2]; + *dest++ = encoding[((src[0] & 0x03) << 4) | (src[1] >> 4)]; + *dest++ = encoding[((src[1] & 0x0F) << 2) | (src[2] >> 6)]; + *dest++ = encoding[src[2] & 0x3F]; + src += 3; + } + + if (dataSize % 3 == 1) { + *dest++ = encoding[src[0] >> 2]; + *dest++ = encoding[((src[0] & 0x03) << 4)]; + *dest++ = '='; + *dest++ = '='; + } else if (dataSize % 3 == 2) { + *dest++ = encoding[src[0] >> 2]; + *dest++ = encoding[((src[0] & 0x03) << 4) | (src[1] >> 4)]; + *dest++ = encoding[((src[1] & 0x0F) << 2)]; + *dest++ = '='; + } + *dest = '\0'; + return s; /* N.B. caller is responsible for free'ing s */ +} + +static bool convertBase64 (const char data, uint8_t *value) +{ + static const uint8_t decodingarr64[128] = { + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0x3e, 0xff, 0xff, 0xff, 0x3f, + 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, + 0x3c, 0x3d, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, + 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, + 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, + 0x17, 0x18, 0x19, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, + 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, + 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, + 0x31, 0x32, 0x33, 0xff, 0xff, 0xff, 0xff, 0xff, + }; + uint8_t index = (uint8_t)data; + if ((index & 0x80) != 0) return false; + + if (decodingarr64[index] == 0xff) return false; + *value = decodingarr64[index]; + return true; +} + +uint8_t *Base64ToBinary (const char *pData, uint32_t decodeSize, uint32_t *pDataSize) +{ + uint8_t *ret; + uint32_t size, ix, groups; + if (pData == NULL || decodeSize == 0 || pDataSize == NULL) + return NULL; + + if ((decodeSize % 4) != 0) { + // must be multiples of 4 characters + return NULL; + } + size = (decodeSize * 3) / 4; + groups = decodeSize / 4; + ret = (uint8_t *)MP4Calloc(size); + if (ret == NULL) return NULL; + for (ix = 0; ix < groups; ix++) { + uint8_t value[4]; + for (uint8_t jx = 0; jx < 4; jx++) { + if (pData[jx] == '=') { + if (ix != (groups - 1)) { + free(ret); + return NULL; + } + size--; + value[jx] = 0; + } else if (convertBase64(pData[jx], &value[jx]) == false) { + free(ret); + return NULL; + } + } + ret[(ix * 3)] = value[0] << 2 | ((value[1] >> 4) & 0x3); + ret[(ix * 3) + 1] = (value[1] << 4) | (value[2] >> 2 & 0xf); + ret[(ix * 3) + 2] = ((value[2] & 0x3) << 6) | value[3]; + pData += 4; + } + *pDataSize = size; + return ret; +} + +// log2 of value, rounded up +static uint8_t ilog2(uint64_t value) +{ + uint64_t powerOf2 = 1; + for (uint8_t i = 0; i < 64; i++) { + if (value <= powerOf2) { + return i; + } + powerOf2 <<= 1; + } + return 64; +} + +uint64_t MP4ConvertTime(uint64_t t, + uint32_t oldTimeScale, uint32_t newTimeScale) +{ + // avoid float point exception + if (oldTimeScale == 0) { + throw new MP4Error("division by zero", "MP4ConvertTime"); + } + + if (oldTimeScale == newTimeScale) return t; + + // check if we can safely use integer operations + if (ilog2(t) + ilog2(newTimeScale) <= 64) { + return (t * newTimeScale) / oldTimeScale; + } + + // final resort is to use floating point + double d = (double)newTimeScale; + d *= double(t); + d /= (double)oldTimeScale; + d += 0.5; // round up. + + return (uint64_t)d; +} + +const char* MP4NormalizeTrackType (const char* type, + uint32_t verbosity) +{ + if (!strcasecmp(type, "vide") + || !strcasecmp(type, "video") + || !strcasecmp(type, "mp4v") + || !strcasecmp(type, "avc1") + || !strcasecmp(type, "s263") // 3GPP H.263 + || !strcasecmp(type, "encv")) { + return MP4_VIDEO_TRACK_TYPE; + } + + if (!strcasecmp(type, "soun") + || !strcasecmp(type, "sound") + || !strcasecmp(type, "audio") + || !strcasecmp(type, "enca") + || !strcasecmp(type, "samr") // 3GPP AMR + || !strcasecmp(type, "sawb") // 3GPP AMR/WB + || !strcasecmp(type, "mp4a")) { + return MP4_AUDIO_TRACK_TYPE; + } + + if (!strcasecmp(type, "sdsm") + || !strcasecmp(type, "scene") + || !strcasecmp(type, "bifs")) { + return MP4_SCENE_TRACK_TYPE; + } + + if (!strcasecmp(type, "odsm") + || !strcasecmp(type, "od")) { + return MP4_OD_TRACK_TYPE; + } + if (strcasecmp(type, "cntl") == 0) { + return MP4_CNTL_TRACK_TYPE; + } + VERBOSE_WARNING(verbosity, + printf("Attempt to normalize %s did not match\n", + type)); + return type; +} + +MP4Timestamp MP4GetAbsTimestamp() { + /* MP4 epoch is midnight, January 1, 1904 + * offset from midnight, January 1, 1970 is 2082844800 seconds + * 208284480 is (((1970 - 1904) * 365) + 17) * 24 * 60 * 60 + */ + return time::getLocalTimeSeconds() + 2082844800; +} + +/////////////////////////////////////////////////////////////////////////////// + +uint32_t STRTOINT32( const char* s ) +{ +#if defined( MP4V2_INTSTRING_ALIGNMENT ) + // it seems ARM integer instructions require 4-byte alignment so we + // manually copy string-data into the integer before performing ops + uint32_t tmp; + memcpy( &tmp, s, sizeof(tmp) ); + return MP4V2_NTOHL( tmp ); +#else + return MP4V2_NTOHL(*(uint32_t *)s); +#endif +} + +void INT32TOSTR( uint32_t i, char* s ) +{ +#if defined( MP4V2_INTSTRING_ALIGNMENT ) + // it seems ARM integer instructions require 4-byte alignment so we + // manually copy string-data into the integer before performing ops + uint32_t tmp = MP4V2_HTONL( i ); + memcpy( s, &tmp, sizeof(tmp) ); +#else + *(uint32_t *)s = MP4V2_HTONL(i); +#endif + s[4] = 0; +} + +/////////////////////////////////////////////////////////////////////////////// + +}} // namespace mp4v2::impl + +/////////////////////////////////////////////////////////////////////////////// + +using namespace mp4v2::impl; + +extern "C" +void MP4SetLibFunc( lib_message_func_t libf ) +{ + libfunc = libf; +} diff --git a/src/mp4util.h b/src/mp4util.h new file mode 100644 index 0000000..299c161 --- /dev/null +++ b/src/mp4util.h @@ -0,0 +1,175 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + */ + +#ifndef MP4V2_IMPL_MP4UTIL_H +#define MP4V2_IMPL_MP4UTIL_H + +namespace mp4v2 { namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +#include <assert.h> + +#define LIBMPV42_STRINGIFY(x) #x + +#ifndef ASSERT +# define ASSERT(expr) \ + if (!(expr)) { \ + throw new MP4Error("assert failure", LIBMPV42_STRINGIFY((expr))); \ + } +#endif + +#define WARNING(expr) \ + if (expr) { \ + fflush(stdout); \ + fprintf(stderr, "Warning (%s) in %s at line %u\n", \ + LIBMPV42_STRINGIFY(expr), __FILE__, __LINE__); \ + } + +#define VERBOSE(exprverbosity, verbosity, expr) \ + if (((exprverbosity) & (verbosity)) == (exprverbosity)) { expr; } + +#define VERBOSE_ERROR(verbosity, expr) \ + VERBOSE(MP4_DETAILS_ERROR, verbosity, expr) + +#define VERBOSE_WARNING(verbosity, expr) \ + VERBOSE(MP4_DETAILS_WARNING, verbosity, expr) + +#define VERBOSE_READ(verbosity, expr) \ + VERBOSE(MP4_DETAILS_READ, verbosity, expr) + +#define VERBOSE_READ_TABLE(verbosity, expr) \ + VERBOSE((MP4_DETAILS_READ | MP4_DETAILS_TABLE), verbosity, expr) + +#define VERBOSE_READ_SAMPLE(verbosity, expr) \ + VERBOSE((MP4_DETAILS_READ | MP4_DETAILS_SAMPLE), verbosity, expr) + +#define VERBOSE_READ_HINT(verbosity, expr) \ + VERBOSE((MP4_DETAILS_READ | MP4_DETAILS_HINT), verbosity, expr) + +#define VERBOSE_WRITE(verbosity, expr) \ + VERBOSE(MP4_DETAILS_WRITE, verbosity, expr) + +#define VERBOSE_WRITE_TABLE(verbosity, expr) \ + VERBOSE((MP4_DETAILS_WRITE | MP4_DETAILS_TABLE), verbosity, expr) + +#define VERBOSE_WRITE_SAMPLE(verbosity, expr) \ + VERBOSE((MP4_DETAILS_WRITE | MP4_DETAILS_SAMPLE), verbosity, expr) + +#define VERBOSE_WRITE_HINT(verbosity, expr) \ + VERBOSE((MP4_DETAILS_WRITE | MP4_DETAILS_HINT), verbosity, expr) + +#define VERBOSE_FIND(verbosity, expr) \ + VERBOSE(MP4_DETAILS_FIND, verbosity, expr) + +#define VERBOSE_ISMA(verbosity, expr) \ + VERBOSE(MP4_DETAILS_ISMA, verbosity, expr) + +#define VERBOSE_EDIT(verbosity, expr) \ + VERBOSE(MP4_DETAILS_EDIT, verbosity, expr) + +/////////////////////////////////////////////////////////////////////////////// + +#define CHECK_AND_FREE(a) if ((a) != NULL) { free((void *)(a)); (a) = NULL;} + +#define NUM_ELEMENTS_IN_ARRAY(name) ((sizeof((name))) / (sizeof(*(name)))) + +/////////////////////////////////////////////////////////////////////////////// + +inline void Indent(FILE* pFile, uint8_t depth) { + fprintf(pFile, "%*c", depth, ' '); +} + +static inline void MP4Printf(const char* fmt, ...) MP4V2_WFORMAT_PRINTF(1,2); + +static inline void MP4Printf(const char* fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + // TBD API call to set error_msg_func instead of just printf + vprintf(fmt, ap); + va_end(ap); +} + +void MP4HexDump( + uint8_t* pBytes, uint32_t numBytes, + FILE* pFile = stdout, uint8_t indent = 0); + +inline void* MP4Malloc(size_t size) { + if (size == 0) return NULL; + void* p = malloc(size); + if (p == NULL && size > 0) { + throw new MP4Error(errno); + } + return p; +} + +inline void* MP4Calloc(size_t size) { + if (size == 0) return NULL; + return memset(MP4Malloc(size), 0, size); +} + +inline char* MP4Stralloc(const char* s1) { + char* s2 = (char*)MP4Malloc(strlen(s1) + 1); + strcpy(s2, s1); + return s2; +} + +inline void* MP4Realloc(void* p, uint32_t newSize) { + // workaround library bug + if (p == NULL && newSize == 0) { + return NULL; + } + p = realloc(p, newSize); + if (p == NULL && newSize > 0) { + throw new MP4Error(errno); + } + return p; +} + +uint32_t STRTOINT32( const char* ); +void INT32TOSTR( uint32_t, char* ); + +MP4Timestamp MP4GetAbsTimestamp(); + +uint64_t MP4ConvertTime(uint64_t t, + uint32_t oldTimeScale, uint32_t newTimeScale); + +bool MP4NameFirstMatches(const char* s1, const char* s2); + +bool MP4NameFirstIndex(const char* s, uint32_t* pIndex); + +char* MP4NameFirst(const char *s); + +const char* MP4NameAfterFirst(const char *s); + +char* MP4ToBase16(const uint8_t* pData, uint32_t dataSize); + +char* MP4ToBase64(const uint8_t* pData, uint32_t dataSize); + +const char* MP4NormalizeTrackType(const char* type, + uint32_t verbosity); + +/////////////////////////////////////////////////////////////////////////////// + +}} // namespace mp4v2::impl + +#endif // MP4V2_IMPL_MP4UTIL_H diff --git a/src/ocidescriptors.cpp b/src/ocidescriptors.cpp new file mode 100644 index 0000000..ec9255b --- /dev/null +++ b/src/ocidescriptors.cpp @@ -0,0 +1,316 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4ContentClassDescriptor::MP4ContentClassDescriptor() + : MP4Descriptor() +{ + AddProperty( /* 0 */ + new MP4Integer32Property("classificationEntity")); + AddProperty( /* 1 */ + new MP4Integer16Property("classificationTable")); + AddProperty( /* 2 */ + new MP4BytesProperty("contentClassificationData")); +} + +void MP4ContentClassDescriptor::Read(MP4File* pFile) +{ + ReadHeader(pFile); + + /* byte properties need to know how long they are before reading */ + ((MP4BytesProperty*)m_pProperties[2])->SetValueSize(m_size - 6); + + ReadProperties(pFile); +} + +MP4KeywordDescriptor::MP4KeywordDescriptor() + : MP4Descriptor() +{ + AddProperty( /* 0 */ + new MP4BytesProperty("languageCode", 3)); + AddProperty( /* 1 */ + new MP4BitfieldProperty("isUTF8String", 1)); + AddProperty( /* 2 */ + new MP4BitfieldProperty("reserved", 7)); + MP4Integer8Property* pCount = + new MP4Integer8Property("keywordCount"); + AddProperty(pCount); /* 3 */ + + MP4TableProperty* pTable = new MP4TableProperty("keywords", pCount); + AddProperty(pTable); /* 4 */ + + pTable->AddProperty( /* 4, 0 */ + new MP4StringProperty("string", Counted)); + + SetReadMutate(2); +} + +void MP4KeywordDescriptor::Mutate() +{ + bool utf8Flag = ((MP4BitfieldProperty*)m_pProperties[1])->GetValue(); + MP4Property* pProperty = + ((MP4TableProperty*)m_pProperties[4])->GetProperty(0); + ASSERT(pProperty); + ((MP4StringProperty*)pProperty)->SetUnicode(!utf8Flag); +} + +MP4RatingDescriptor::MP4RatingDescriptor() + : MP4Descriptor() +{ + AddProperty( /* 0 */ + new MP4Integer32Property("ratingEntity")); + AddProperty( /* 1 */ + new MP4Integer16Property("ratingCriteria")); + AddProperty( /* 2 */ + new MP4BytesProperty("ratingInfo")); +} + +void MP4RatingDescriptor::Read(MP4File* pFile) +{ + ReadHeader(pFile); + + /* byte properties need to know how long they are before reading */ + ((MP4BytesProperty*)m_pProperties[2])->SetValueSize(m_size - 6); + + ReadProperties(pFile); +} + +MP4LanguageDescriptor::MP4LanguageDescriptor() + : MP4Descriptor() +{ + AddProperty( /* 0 */ + new MP4BytesProperty("languageCode", 3)); +} + +MP4ShortTextDescriptor::MP4ShortTextDescriptor() + : MP4Descriptor() +{ + AddProperty( /* 0 */ + new MP4BytesProperty("languageCode", 3)); + AddProperty( /* 1 */ + new MP4BitfieldProperty("isUTF8String", 1)); + AddProperty( /* 2 */ + new MP4BitfieldProperty("reserved", 7)); + AddProperty( /* 3 */ + new MP4StringProperty("eventName", Counted)); + AddProperty( /* 4 */ + new MP4StringProperty("eventText", Counted)); + + SetReadMutate(2); +} + +void MP4ShortTextDescriptor::Mutate() +{ + bool utf8Flag = ((MP4BitfieldProperty*)m_pProperties[1])->GetValue(); + ((MP4StringProperty*)m_pProperties[3])->SetUnicode(!utf8Flag); + ((MP4StringProperty*)m_pProperties[4])->SetUnicode(!utf8Flag); +} + +MP4ExpandedTextDescriptor::MP4ExpandedTextDescriptor() + : MP4Descriptor() +{ + AddProperty( /* 0 */ + new MP4BytesProperty("languageCode", 3)); + AddProperty( /* 1 */ + new MP4BitfieldProperty("isUTF8String", 1)); + AddProperty( /* 2 */ + new MP4BitfieldProperty("reserved", 7)); + MP4Integer8Property* pCount = + new MP4Integer8Property("itemCount"); + AddProperty(pCount); /* 3 */ + + MP4TableProperty* pTable = new MP4TableProperty("items", pCount); + AddProperty(pTable); /* 4 */ + + pTable->AddProperty( /* Table 0 */ + new MP4StringProperty("itemDescription", Counted)); + pTable->AddProperty( /* Table 1 */ + new MP4StringProperty("itemText", Counted)); + + AddProperty( /* 5 */ + new MP4StringProperty("nonItemText")); + ((MP4StringProperty*)m_pProperties[5])->SetExpandedCountedFormat(true); + + SetReadMutate(2); +} + +void MP4ExpandedTextDescriptor::Mutate() +{ + bool utf8Flag = ((MP4BitfieldProperty*)m_pProperties[1])->GetValue(); + + MP4Property* pProperty = + ((MP4TableProperty*)m_pProperties[4])->GetProperty(0); + ASSERT(pProperty); + ((MP4StringProperty*)pProperty)->SetUnicode(!utf8Flag); + + pProperty = ((MP4TableProperty*)m_pProperties[4])->GetProperty(1); + ASSERT(pProperty); + ((MP4StringProperty*)pProperty)->SetUnicode(!utf8Flag); + + ((MP4StringProperty*)m_pProperties[5])->SetUnicode(!utf8Flag); +} + +class MP4CreatorTableProperty : public MP4TableProperty { +public: + MP4CreatorTableProperty(const char* name, MP4Integer8Property* pCountProperty) : + MP4TableProperty(name, pCountProperty) { + }; +protected: + void ReadEntry(MP4File* pFile, uint32_t index); + void WriteEntry(MP4File* pFile, uint32_t index); +}; + +MP4CreatorDescriptor::MP4CreatorDescriptor(uint8_t tag) + : MP4Descriptor(tag) +{ + MP4Integer8Property* pCount = + new MP4Integer8Property("creatorCount"); + AddProperty(pCount); /* 0 */ + + MP4TableProperty* pTable = new MP4CreatorTableProperty("creators", pCount); + AddProperty(pTable); /* 1 */ + + pTable->AddProperty( /* Table 0 */ + new MP4BytesProperty("languageCode", 3, 3)); + pTable->AddProperty( /* Table 1 */ + new MP4BitfieldProperty("isUTF8String", 1)); + pTable->AddProperty( /* Table 2 */ + new MP4BitfieldProperty("reserved", 7)); + pTable->AddProperty( /* Table 3 */ + new MP4StringProperty("name", Counted)); +} + +void MP4CreatorTableProperty::ReadEntry(MP4File* pFile, uint32_t index) +{ + m_pProperties[0]->Read(pFile, index); + m_pProperties[1]->Read(pFile, index); + + bool utf8Flag = ((MP4BitfieldProperty*)m_pProperties[1])->GetValue(index); + ((MP4StringProperty*)m_pProperties[3])->SetUnicode(!utf8Flag); + + m_pProperties[2]->Read(pFile, index); + m_pProperties[3]->Read(pFile, index); +} + +void MP4CreatorTableProperty::WriteEntry(MP4File* pFile, uint32_t index) +{ + bool utf8Flag = ((MP4BitfieldProperty*)m_pProperties[1])->GetValue(index); + ((MP4StringProperty*)m_pProperties[3])->SetUnicode(!utf8Flag); + + MP4TableProperty::WriteEntry(pFile, index); +} + +MP4CreationDescriptor::MP4CreationDescriptor(uint8_t tag) + : MP4Descriptor(tag) +{ + AddProperty( /* 0 */ + new MP4BitfieldProperty("contentCreationDate", 40)); +} + +MP4SmpteCameraDescriptor::MP4SmpteCameraDescriptor() + : MP4Descriptor() +{ + MP4Integer8Property* pCount = + new MP4Integer8Property("parameterCount"); + AddProperty(pCount); + + MP4TableProperty* pTable = new MP4TableProperty("parameters", pCount); + AddProperty(pTable); + + pTable->AddProperty( + new MP4Integer8Property("id")); + pTable->AddProperty( + new MP4Integer32Property("value")); +} + +MP4UnknownOCIDescriptor::MP4UnknownOCIDescriptor() + : MP4Descriptor() +{ + AddProperty( /* 0 */ + new MP4BytesProperty("data")); +} + +void MP4UnknownOCIDescriptor::Read(MP4File* pFile) +{ + ReadHeader(pFile); + + /* byte properties need to know how long they are before reading */ + ((MP4BytesProperty*)m_pProperties[0])->SetValueSize(m_size); + + ReadProperties(pFile); +} + +MP4Descriptor* CreateOCIDescriptor(uint8_t tag) +{ + MP4Descriptor* pDescriptor = NULL; + + switch (tag) { + case MP4ContentClassDescrTag: + pDescriptor = new MP4ContentClassDescriptor(); + break; + case MP4KeywordDescrTag: + pDescriptor = new MP4KeywordDescriptor(); + break; + case MP4RatingDescrTag: + pDescriptor = new MP4RatingDescriptor(); + break; + case MP4LanguageDescrTag: + pDescriptor = new MP4LanguageDescriptor(); + break; + case MP4ShortTextDescrTag: + pDescriptor = new MP4ShortTextDescriptor(); + break; + case MP4ExpandedTextDescrTag: + pDescriptor = new MP4ExpandedTextDescriptor(); + break; + case MP4ContentCreatorDescrTag: + case MP4OCICreatorDescrTag: + pDescriptor = new MP4CreatorDescriptor(tag); + break; + case MP4ContentCreationDescrTag: + case MP4OCICreationDescrTag: + pDescriptor = new MP4CreationDescriptor(tag); + break; + case MP4SmpteCameraDescrTag: + pDescriptor = new MP4SmpteCameraDescriptor(); + break; + } + + if (pDescriptor == NULL) { + if (tag >= MP4OCIDescrTagsStart && tag <= MP4OCIDescrTagsEnd) { + pDescriptor = new MP4UnknownOCIDescriptor(); + pDescriptor->SetTag(tag); + } + } + + return pDescriptor; +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/ocidescriptors.h b/src/ocidescriptors.h new file mode 100644 index 0000000..1174aa1 --- /dev/null +++ b/src/ocidescriptors.h @@ -0,0 +1,111 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + */ + +#ifndef MP4V2_IMPL_OCIDESCRIPTORS_H +#define MP4V2_IMPL_OCIDESCRIPTORS_H + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +const uint8_t MP4OCIDescrTagsStart = 0x40; +const uint8_t MP4ContentClassDescrTag = 0x40; +const uint8_t MP4KeywordDescrTag = 0x41; +const uint8_t MP4RatingDescrTag = 0x42; +const uint8_t MP4LanguageDescrTag = 0x43; +const uint8_t MP4ShortTextDescrTag = 0x44; +const uint8_t MP4ExpandedTextDescrTag = 0x45; +const uint8_t MP4ContentCreatorDescrTag = 0x46; +const uint8_t MP4ContentCreationDescrTag = 0x47; +const uint8_t MP4OCICreatorDescrTag = 0x48; +const uint8_t MP4OCICreationDescrTag = 0x49; +const uint8_t MP4SmpteCameraDescrTag = 0x4A; +const uint8_t MP4OCIDescrTagsEnd = 0x5F; + +class MP4ContentClassDescriptor : public MP4Descriptor { +public: + MP4ContentClassDescriptor(); + void Read(MP4File* pFile); +}; + +class MP4KeywordDescriptor : public MP4Descriptor { +public: + MP4KeywordDescriptor(); +protected: + void Mutate(); +}; + +class MP4RatingDescriptor : public MP4Descriptor { +public: + MP4RatingDescriptor(); + void Read(MP4File* pFile); +}; + +class MP4LanguageDescriptor : public MP4Descriptor { +public: + MP4LanguageDescriptor(); +}; + +class MP4ShortTextDescriptor : public MP4Descriptor { +public: + MP4ShortTextDescriptor(); +protected: + void Mutate(); +}; + +class MP4ExpandedTextDescriptor : public MP4Descriptor { +public: + MP4ExpandedTextDescriptor(); +protected: + void Mutate(); +}; + +class MP4CreatorDescriptor : public MP4Descriptor { +public: + MP4CreatorDescriptor(uint8_t tag); +}; + +class MP4CreationDescriptor : public MP4Descriptor { +public: + MP4CreationDescriptor(uint8_t tag); +}; + +class MP4SmpteCameraDescriptor : public MP4Descriptor { +public: + MP4SmpteCameraDescriptor(); +}; + +class MP4UnknownOCIDescriptor : public MP4Descriptor { +public: + MP4UnknownOCIDescriptor(); + void Read(MP4File* pFile); +}; + + +extern MP4Descriptor *CreateOCIDescriptor(uint8_t tag); + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl + +#endif // MP4V2_IMPL_OCIDESCRIPTORS_H diff --git a/src/odcommands.cpp b/src/odcommands.cpp new file mode 100644 index 0000000..4bfd69c --- /dev/null +++ b/src/odcommands.cpp @@ -0,0 +1,113 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +MP4ODUpdateDescriptor::MP4ODUpdateDescriptor() + : MP4Descriptor(MP4ODUpdateODCommandTag) +{ + // just a container for ObjectDescriptors + AddProperty( /* 0 */ + new MP4DescriptorProperty(NULL, + MP4FileODescrTag, 0, Required, Many)); +} + +MP4ODRemoveDescriptor::MP4ODRemoveDescriptor() + : MP4Descriptor(MP4ODRemoveODCommandTag) +{ + MP4Integer32Property* pCount = + new MP4Integer32Property("entryCount"); + pCount->SetImplicit(); + AddProperty(pCount); /* 0 */ + + MP4TableProperty* pTable = + new MP4TableProperty("entries", pCount); + AddProperty(pTable); /* 1 */ + + pTable->AddProperty( /* 1, 0 */ + new MP4BitfieldProperty("objectDescriptorId", 10)); +} + +void MP4ODRemoveDescriptor::Read(MP4File* pFile) +{ + // table entry count computed from descriptor size + ((MP4Integer32Property*)m_pProperties[0])->SetReadOnly(false); + ((MP4Integer32Property*)m_pProperties[0])->SetValue((m_size * 8) / 10); + ((MP4Integer32Property*)m_pProperties[0])->SetReadOnly(true); + + MP4Descriptor::Read(pFile); +} + +MP4ESUpdateDescriptor::MP4ESUpdateDescriptor() + : MP4Descriptor(MP4ESUpdateODCommandTag) +{ + AddProperty( /* 0 */ + new MP4BitfieldProperty("objectDescriptorId", 10)); + AddProperty( /* 1 */ + new MP4BitfieldProperty("pad", 6)); + AddProperty( /* 2 */ + new MP4DescriptorProperty("esIdRefs", + MP4ESIDRefDescrTag, 0, Required, Many)); +} + +// LATER might be able to combine with ESUpdateDescriptor +MP4ESRemoveDescriptor::MP4ESRemoveDescriptor() + : MP4Descriptor(MP4ESRemoveODCommandTag) +{ + AddProperty( /* 0 */ + new MP4BitfieldProperty("objectDescriptorId", 10)); + AddProperty( /* 1 */ + new MP4BitfieldProperty("pad", 6)); + AddProperty( /* 2 */ + new MP4DescriptorProperty("esIdRefs", + MP4ESIDRefDescrTag, 0, Required, Many)); +} + +MP4Descriptor* CreateODCommand(uint8_t tag) +{ + MP4Descriptor* pDescriptor = NULL; + + switch (tag) { + case MP4ODUpdateODCommandTag: + pDescriptor = new MP4ODUpdateDescriptor(); + break; + case MP4ODRemoveODCommandTag: + pDescriptor = new MP4ODRemoveDescriptor(); + break; + case MP4ESUpdateODCommandTag: + pDescriptor = new MP4ESUpdateDescriptor(); + break; + case MP4ESRemoveODCommandTag: + pDescriptor = new MP4ESRemoveDescriptor(); + break; + } + return pDescriptor; +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/odcommands.h b/src/odcommands.h new file mode 100644 index 0000000..27f6b93 --- /dev/null +++ b/src/odcommands.h @@ -0,0 +1,67 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + */ + +#ifndef MP4V2_IMPL_ODCOMMANDS_H +#define MP4V2_IMPL_ODCOMMANDS_H + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +// OD stream command descriptors +const uint8_t MP4ODUpdateODCommandTag = 0x01; +const uint8_t MP4ODRemoveODCommandTag = 0x02; +const uint8_t MP4ESUpdateODCommandTag = 0x03; +const uint8_t MP4ESRemoveODCommandTag = 0x04; +const uint8_t MP4IPMPUpdateODCommandTag = 0x05; +const uint8_t MP4IPMPRemoveODCommandTag = 0x06; +const uint8_t MP4ESRemoveRefODCommandTag = 0x07; + +class MP4ODUpdateDescriptor : public MP4Descriptor { +public: + MP4ODUpdateDescriptor(); +}; + +class MP4ODRemoveDescriptor : public MP4Descriptor { +public: + MP4ODRemoveDescriptor(); + void Read(MP4File* pFile); +}; + +class MP4ESUpdateDescriptor : public MP4Descriptor { +public: + MP4ESUpdateDescriptor(); +}; + +class MP4ESRemoveDescriptor : public MP4Descriptor { +public: + MP4ESRemoveDescriptor(); +}; + +MP4Descriptor* CreateODCommand(uint8_t tag); + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl + +#endif // MP4V2_IMPL_ODCOMMANDS_H diff --git a/src/qosqualifiers.cpp b/src/qosqualifiers.cpp new file mode 100644 index 0000000..2514e3a --- /dev/null +++ b/src/qosqualifiers.cpp @@ -0,0 +1,198 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +#if 1 +MP4QosDescriptorBase::MP4QosDescriptorBase (uint8_t tag) + : MP4Descriptor(tag) +{ + switch (tag) { + case MP4QosDescrTag: + AddProperty( /* 0 */ + new MP4Integer8Property("predefined")); + AddProperty( /* 1 */ + new MP4QosQualifierProperty("qualifiers", + MP4QosTagsStart, + MP4QosTagsEnd, Optional, Many)); + break; + case MP4MaxDelayQosTag: + AddProperty( /* 0 */ + new MP4Integer32Property("maxDelay")); + break; + case MP4PrefMaxDelayQosTag: + AddProperty( /* 0 */ + new MP4Integer32Property("prefMaxDelay")); + break; + case MP4LossProbQosTag: + AddProperty( /* 0 */ + new MP4Float32Property("lossProb")); + break; + case MP4MaxGapLossQosTag: + AddProperty( /* 0 */ + new MP4Integer32Property("maxGapLoss")); + break; + case MP4MaxAUSizeQosTag: + AddProperty( /* 0 */ + new MP4Integer32Property("maxAUSize")); + break; + case MP4AvgAUSizeQosTag: + AddProperty( /* 0 */ + new MP4Integer32Property("avgAUSize")); + break; + case MP4MaxAURateQosTag: + AddProperty( /* 0 */ + new MP4Integer32Property("maxAURate")); + break; + } +} + +#else +MP4QosDescriptor::MP4QosDescriptor() + : MP4Descriptor(MP4QosDescrTag) +{ + AddProperty( /* 0 */ + new MP4Integer8Property("predefined")); + AddProperty( /* 1 */ + new MP4QosQualifierProperty("qualifiers", + MP4QosTagsStart, MP4QosTagsEnd, Optional, Many)); +} + +MP4MaxDelayQosQualifier::MP4MaxDelayQosQualifier() + : MP4QosQualifier(MP4MaxDelayQosTag) +{ + AddProperty( /* 0 */ + new MP4Integer32Property("maxDelay")); +} + +MP4PrefMaxDelayQosQualifier::MP4PrefMaxDelayQosQualifier() + : MP4QosQualifier(MP4PrefMaxDelayQosTag) +{ + AddProperty( /* 0 */ + new MP4Integer32Property("prefMaxDelay")); +} + +MP4LossProbQosQualifier::MP4LossProbQosQualifier() + : MP4QosQualifier(MP4LossProbQosTag) +{ + AddProperty( /* 0 */ + new MP4Float32Property("lossProb")); +} + +MP4MaxGapLossQosQualifier::MP4MaxGapLossQosQualifier() + : MP4QosQualifier(MP4MaxGapLossQosTag) +{ + AddProperty( /* 0 */ + new MP4Integer32Property("maxGapLoss")); +} + +MP4MaxAUSizeQosQualifier::MP4MaxAUSizeQosQualifier() + : MP4QosQualifier(MP4MaxAUSizeQosTag) +{ + AddProperty( /* 0 */ + new MP4Integer32Property("maxAUSize")); +} + +MP4AvgAUSizeQosQualifier::MP4AvgAUSizeQosQualifier() + : MP4QosQualifier(MP4AvgAUSizeQosTag) +{ + AddProperty( /* 0 */ + new MP4Integer32Property("avgAUSize")); +} + +MP4MaxAURateQosQualifier::MP4MaxAURateQosQualifier() + : MP4QosQualifier(MP4MaxAURateQosTag) +{ + AddProperty( /* 0 */ + new MP4Integer32Property("maxAURate")); +} +#endif +MP4UnknownQosQualifier::MP4UnknownQosQualifier() + : MP4Descriptor() +{ + AddProperty( /* 0 */ + new MP4BytesProperty("data")); +} + +void MP4UnknownQosQualifier::Read(MP4File* pFile) +{ + ReadHeader(pFile); + + /* byte properties need to know how long they are before reading */ + ((MP4BytesProperty*)m_pProperties[0])->SetValueSize(m_size); + + ReadProperties(pFile); +} + +MP4Descriptor* MP4QosQualifierProperty::CreateDescriptor(uint8_t tag) +{ + MP4Descriptor* pDescriptor = NULL; + switch (tag) { +#if 0 + case MP4MaxDelayQosTag: + pDescriptor = new MP4MaxDelayQosQualifier(); + break; + case MP4PrefMaxDelayQosTag: + pDescriptor = new MP4PrefMaxDelayQosQualifier(); + break; + case MP4LossProbQosTag: + pDescriptor = new MP4LossProbQosQualifier(); + break; + case MP4MaxGapLossQosTag: + pDescriptor = new MP4MaxGapLossQosQualifier(); + break; + case MP4MaxAUSizeQosTag: + pDescriptor = new MP4MaxAUSizeQosQualifier(); + break; + case MP4AvgAUSizeQosTag: + pDescriptor = new MP4AvgAUSizeQosQualifier(); + break; + case MP4MaxAURateQosTag: + pDescriptor = new MP4MaxAURateQosQualifier(); + break; +#else + case MP4MaxDelayQosTag: + case MP4PrefMaxDelayQosTag: + case MP4LossProbQosTag: + case MP4MaxGapLossQosTag: + case MP4MaxAUSizeQosTag: + case MP4AvgAUSizeQosTag: + case MP4MaxAURateQosTag: + pDescriptor = new MP4QosDescriptorBase(tag); + break; +#endif + default: + pDescriptor = new MP4UnknownQosQualifier(); + pDescriptor->SetTag(tag); + } + + return pDescriptor; +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/qosqualifiers.h b/src/qosqualifiers.h new file mode 100644 index 0000000..5fb0ec1 --- /dev/null +++ b/src/qosqualifiers.h @@ -0,0 +1,104 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + */ + +#ifndef MP4V2_IMPL_QOSQUALIFIERS_H +#define MP4V2_IMPL_QOSQUALIFIERS_H + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +const uint8_t MP4QosDescrTag = 0x0C; + +#if 0 +class MP4QosDescriptor : public MP4Descriptor { +public: + MP4QosDescriptor(); +}; + +typedef MP4Descriptor MP4QosQualifier; +#endif + +const uint8_t MP4QosTagsStart = 0x01; +const uint8_t MP4MaxDelayQosTag = 0x01; +const uint8_t MP4PrefMaxDelayQosTag = 0x02; +const uint8_t MP4LossProbQosTag = 0x03; +const uint8_t MP4MaxGapLossQosTag = 0x04; +const uint8_t MP4MaxAUSizeQosTag = 0x41; +const uint8_t MP4AvgAUSizeQosTag = 0x42; +const uint8_t MP4MaxAURateQosTag = 0x43; +const uint8_t MP4QosTagsEnd = 0xFF; + +#if 0 +class MP4MaxDelayQosQualifier : public MP4QosQualifier { +public: + MP4MaxDelayQosQualifier(); +}; + +class MP4PrefMaxDelayQosQualifier : public MP4QosQualifier { +public: + MP4PrefMaxDelayQosQualifier(); +}; + +class MP4LossProbQosQualifier : public MP4QosQualifier { +public: + MP4LossProbQosQualifier(); +}; + +class MP4MaxGapLossQosQualifier : public MP4QosQualifier { +public: + MP4MaxGapLossQosQualifier(); +}; + +class MP4MaxAUSizeQosQualifier : public MP4QosQualifier { +public: + MP4MaxAUSizeQosQualifier(); +}; + +class MP4AvgAUSizeQosQualifier : public MP4QosQualifier { +public: + MP4AvgAUSizeQosQualifier(); +}; + +class MP4MaxAURateQosQualifier : public MP4QosQualifier { +public: + MP4MaxAURateQosQualifier(); +}; +#else +class MP4QosDescriptorBase : public MP4Descriptor { +public: + MP4QosDescriptorBase(uint8_t tag); +}; + +#endif +class MP4UnknownQosQualifier : public MP4Descriptor { +public: + MP4UnknownQosQualifier(); + void Read(MP4File* pFile); +}; + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl + +#endif // MP4V2_IMPL_QOSQUALIFIERS_H diff --git a/src/qtff/ColorParameterBox.cpp b/src/qtff/ColorParameterBox.cpp new file mode 100644 index 0000000..54a85a4 --- /dev/null +++ b/src/qtff/ColorParameterBox.cpp @@ -0,0 +1,341 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is MP4v2. +// +// The Initial Developer of the Original Code is Kona Blend. +// Portions created by Kona Blend are Copyright (C) 2008. +// All Rights Reserved. +// +// Contributors: +// Kona Blend, kona8lend@@gmail.com +// +/////////////////////////////////////////////////////////////////////////////// + +#include "impl.h" + +namespace mp4v2 { namespace impl { namespace qtff { + +/////////////////////////////////////////////////////////////////////////////// + +namespace { + const string BOX_CODE = "colr"; + + bool findColorParameterBox( MP4FileHandle file, MP4Atom& coding, MP4Atom*& colr ); +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +ColorParameterBox::add( MP4FileHandle file, uint16_t trackIndex, const Item& item ) +{ + MP4Atom* coding; + if( findCoding( file, trackIndex, coding )) + throw new MP4Exception( "supported coding not found" ); + + MP4Atom* colr; + if( !findColorParameterBox( file, *coding, colr )) + throw new MP4Exception( "colr-box already exists" ); + + colr = MP4Atom::CreateAtom( coding, BOX_CODE.c_str() ); + coding->AddChildAtom( colr ); + colr->Generate(); + + MP4StringProperty* type; + MP4Integer16Property* primariesIndex; + MP4Integer16Property* transferFunctionIndex; + MP4Integer16Property* matrixIndex; + + if( colr->FindProperty( "colr.colorParameterType", (MP4Property**)&type )) + type->SetValue( "nclc" ); + + if( colr->FindProperty( "colr.primariesIndex", (MP4Property**)&primariesIndex )) + primariesIndex->SetValue( item.primariesIndex ); + + if( colr->FindProperty( "colr.transferFunctionIndex", (MP4Property**)&transferFunctionIndex )) + transferFunctionIndex->SetValue( item.transferFunctionIndex ); + + if( colr->FindProperty( "colr.matrixIndex", (MP4Property**)&matrixIndex )) + matrixIndex->SetValue( item.matrixIndex ); + + return false; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +ColorParameterBox::add( MP4FileHandle file, MP4TrackId trackId, const Item& item ) +{ + MP4File& mp4 = *((MP4File*)file); + return add( file, mp4.FindTrackIndex( trackId ), item ); +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +ColorParameterBox::get( MP4FileHandle file, uint16_t trackIndex, Item& item ) +{ + item.reset(); + + MP4Atom* coding; + if( findCoding( file, trackIndex, coding )) + throw new MP4Exception( "supported coding not found" ); + + MP4Atom* colr; + if( findColorParameterBox( file, *coding, colr )) + throw new MP4Exception( "colr-box not found" ); + + MP4Integer16Property* primariesIndex; + MP4Integer16Property* transferFunctionIndex; + MP4Integer16Property* matrixIndex; + + if( colr->FindProperty( "colr.primariesIndex", (MP4Property**)&primariesIndex )) + item.primariesIndex = primariesIndex->GetValue(); + + if( colr->FindProperty( "colr.transferFunctionIndex", (MP4Property**)&transferFunctionIndex )) + item.transferFunctionIndex = transferFunctionIndex->GetValue(); + + if( colr->FindProperty( "colr.matrixIndex", (MP4Property**)&matrixIndex )) + item.matrixIndex = matrixIndex->GetValue(); + + return false; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +ColorParameterBox::get( MP4FileHandle file, MP4TrackId trackId, Item& item ) +{ + MP4File& mp4 = *((MP4File*)file); + return get( file, mp4.FindTrackIndex( trackId ), item ); +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +ColorParameterBox::list( MP4FileHandle file, ItemList& itemList ) +{ + itemList.clear(); + MP4File& mp4 = *((MP4File*)file); + + const uint16_t trackc = mp4.GetNumberOfTracks(); + for( uint16_t i = 0; i < trackc; i++) { + MP4TrackId id = mp4.FindTrackId( i ); + if( id == MP4_INVALID_TRACK_ID ) + continue; + + const char* type = mp4.GetTrackType( id ); + if( !type ) + continue; + + itemList.resize( itemList.size() + 1 ); + IndexedItem& xitem = itemList[itemList.size()-1]; + + xitem.trackIndex = i; + xitem.trackId = id; + + bool success = false; + try { + success = !get( file, i, xitem.item ); + } + catch( MP4Exception* x ) { + delete x; + } + + if( !success ) { + itemList.resize( itemList.size() - 1 ); + continue; + } + } + + return false; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +ColorParameterBox::remove( MP4FileHandle file, uint16_t trackIndex ) +{ + MP4Atom* coding; + if( findCoding( file, trackIndex, coding )) + throw new MP4Exception( "supported coding not found" ); + + MP4Atom* colr; + if( findColorParameterBox( file, *coding, colr )) + throw new MP4Exception( "colr-box not found" ); + + coding->DeleteChildAtom( colr ); + delete colr; + + return false; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +ColorParameterBox::remove( MP4FileHandle file, MP4TrackId trackId ) +{ + MP4File& mp4 = *((MP4File*)file); + return remove( file, mp4.FindTrackIndex( trackId )); +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +ColorParameterBox::set( MP4FileHandle file, uint16_t trackIndex, const Item& item ) +{ + MP4Atom* coding; + if( findCoding( file, trackIndex, coding )) + throw new MP4Exception( "supported coding not found" ); + + MP4Atom* colr; + if( findColorParameterBox( file, *coding, colr )) + throw new MP4Exception( "colr-box not found" ); + + MP4Integer16Property* primariesIndex; + MP4Integer16Property* transferFunctionIndex; + MP4Integer16Property* matrixIndex; + + if( colr->FindProperty( "colr.primariesIndex", (MP4Property**)&primariesIndex )) + primariesIndex->SetValue( item.primariesIndex ); + + if( colr->FindProperty( "colr.transferFunctionIndex", (MP4Property**)&transferFunctionIndex )) + transferFunctionIndex->SetValue( item.transferFunctionIndex ); + + if( colr->FindProperty( "colr.matrixIndex", (MP4Property**)&matrixIndex )) + matrixIndex->SetValue( item.matrixIndex ); + + return false; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +ColorParameterBox::set( MP4FileHandle file, MP4TrackId trackId, const Item& item ) +{ + MP4File& mp4 = *((MP4File*)file); + return set( file, mp4.FindTrackIndex( trackId ), item ); +} + +/////////////////////////////////////////////////////////////////////////////// + +ColorParameterBox::IndexedItem::IndexedItem() + : trackIndex ( numeric_limits<uint16_t>::max() ) + , trackId ( MP4_INVALID_TRACK_ID ) +{ +} + +/////////////////////////////////////////////////////////////////////////////// + +ColorParameterBox::Item::Item() + : primariesIndex ( 6 ) + , transferFunctionIndex ( 1 ) + , matrixIndex ( 6 ) +{ +} + +/////////////////////////////////////////////////////////////////////////////// + +void +ColorParameterBox::Item::convertFromCSV( const string& text ) +{ + istringstream iss( text ); + char delim; + + iss >> primariesIndex; + iss >> delim; + iss >> transferFunctionIndex; + iss >> delim; + iss >> matrixIndex; + + // input was good if we end up with only eofbit set + if( iss.rdstate() != ios::eofbit ) { + reset(); + ostringstream xss; + xss << "invalid ColorParameterBox format" + << " (expecting: INDEX1,INDEX2,INDEX3)" + << " got: " << text; + throw new MP4Exception( xss ); + } +} + +/////////////////////////////////////////////////////////////////////////////// + +string +ColorParameterBox::Item::convertToCSV() const +{ + string buffer; + return convertToCSV( buffer ); +} + +/////////////////////////////////////////////////////////////////////////////// + +string& +ColorParameterBox::Item::convertToCSV( string& buffer ) const +{ + ostringstream oss; + oss << primariesIndex << ',' << transferFunctionIndex << ',' << matrixIndex; + buffer = oss.str(); + return buffer; +} + +/////////////////////////////////////////////////////////////////////////////// + +void +ColorParameterBox::Item::reset() +{ + primariesIndex = 6; + transferFunctionIndex = 1; + matrixIndex = 6; +} + +/////////////////////////////////////////////////////////////////////////////// + +namespace { + +/////////////////////////////////////////////////////////////////////////////// + +bool +findColorParameterBox( MP4FileHandle file, MP4Atom& coding, MP4Atom*& colr ) +{ + colr = NULL; + + MP4Atom* found = NULL; + const uint32_t atomc = coding.GetNumberOfChildAtoms(); + for( uint32_t i = 0; i < atomc; i++ ) { + MP4Atom* atom = coding.GetChildAtom( i ); + if( BOX_CODE != atom->GetType() ) + continue; + found = atom; + } + if( !found ) + return true; + + MP4StringProperty* type; + if( !found->FindProperty( "colr.colorParameterType", (MP4Property**)&type )) + return true; + + const string type_nclc = "nclc"; + if( type_nclc != type->GetValue() ) + return true; + + colr = found; + return false; +} + +/////////////////////////////////////////////////////////////////////////////// + +} // anonymous + +/////////////////////////////////////////////////////////////////////////////// + +}}} // namespace mp4v2::impl::qtff diff --git a/src/qtff/ColorParameterBox.h b/src/qtff/ColorParameterBox.h new file mode 100644 index 0000000..9a27fcd --- /dev/null +++ b/src/qtff/ColorParameterBox.h @@ -0,0 +1,207 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is MP4v2. +// +// The Initial Developer of the Original Code is Kona Blend. +// Portions created by Kona Blend are Copyright (C) 2008. +// All Rights Reserved. +// +// Contributors: +// Kona Blend, kona8lend@@gmail.com +// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef MP4V2_IMPL_QTFF_COLORPARAMETERBOX_H +#define MP4V2_IMPL_QTFF_COLORPARAMETERBOX_H + +namespace mp4v2 { namespace impl { namespace qtff { + +/////////////////////////////////////////////////////////////////////////////// + +/// Functional class for colr-box (Color Parameter Box) support. +/// +/// A colr-box is expected to be contained in a video track which is one of +/// the following coding types: +/// @li avc1 +/// @li mp4v +/// +/// This implementation assumes a maximum count of <b>1</b> for +/// VideoSampleEntry of the supported codings. +/// +/// This implementation supports parameter-type 'nclc' only. +/// +class MP4V2_EXPORT ColorParameterBox +{ +public: + /// Data object for colr-box item. + /// This object correlates to one colr-box (Color Parameter Box). + /// + class MP4V2_EXPORT Item + { + public: + Item(); + + /// reset to state of newly constructed object. + void reset(); + + // convert from string CSV format. + void convertFromCSV( const string& csv ); + + // convert to string CSV format. + string convertToCSV() const; + + // convert to string CSV format with buffer. + string& convertToCSV( string& buffer ) const; + + public: + /// a 16-bit unsigned integer index. + /// Specifies an index into a table specifying the CIE 1931 xy + /// chromaticity coordinates of the white point and the red, green, and + /// blue primaries. The table of primaries specifies the white point and + /// the red, green, and blue primary color points for a video system. + uint16_t primariesIndex; + + /// a 16-bit unsigned integer index. + /// Specifies an an index into a table specifying the nonlinear transfer + /// function coefficients used to translate between RGB color space values + /// and Y′CbCr values. The table of transfer function coefficients + /// specifies the nonlinear function coefficients used to translate + /// between the stored Y′CbCr values and a video capture or display + /// system. + uint16_t transferFunctionIndex; + + /// a 16-bit unsigned integer index. + /// Specifies an index into a table specifying the transformation matrix + /// coefficients used to translate between RGB color space values and + /// Y′CbCr values. The table of matrixes specifies the matrix used during + /// the translation. + uint16_t matrixIndex; + }; + + class MP4V2_EXPORT IndexedItem { + public: + IndexedItem(); + + uint16_t trackIndex; + uint16_t trackId; + Item item; + }; + + typedef vector<IndexedItem> ItemList; + + static bool list( MP4FileHandle file, ItemList& itemList ); + + /// Add colr-box by track-index. + /// + /// This function adds a colr-box to <b>trackId</b> of <b>file</b>. + /// The track must be a video-track and match one of the supporting + /// codings. + /// + /// @param file on which to operate. + /// @param trackIndex on which to operate. + /// @param item colr-box properties to set. + /// + /// @return <b>true</b> on failure, <b>false</b> on success. + /// + static bool add( MP4FileHandle file, uint16_t trackIndex, const Item& item ); + + /// Add colr-box by track-id. + /// + /// This function adds a colr-box to <b>trackId</b> of <b>file</b>. + /// The track must be a video-track and match one of the supporting + /// codings. + /// + /// @param file on which to operate. + /// @param trackId on which to operate. + /// @param item colr-box properties to set. + /// + /// @return <b>true</b> on failure, <b>false</b> on success. + /// + static bool add( MP4FileHandle file, MP4TrackId trackId, const Item& item ); + + /// Store colr-box (Color Parameter Box) properties by track-index. + /// + /// This function sets the properties of a <b>colr-box</b> + /// (Color Parameter Box). + /// + /// @param file on which to operate. + /// @param trackIndex on which to operate. + /// @param item colr-box properties to set. + /// + /// @return <b>true</b> on failure, <b>false</b> on success. + /// + static bool set( MP4FileHandle file, uint16_t trackIndex, const Item& item ); + + /// Store colr-box (Color Parameter Box) properties by track-id. + /// + /// This function sets the properties of a <b>colr-box</b> + /// (Color Parameter Box). + /// + /// @param file on which to operate. + /// @param trackId on which to operate. + /// @param item colr-box properties to set. + /// + /// @return <b>true</b> on failure, <b>false</b> on success. + /// + static bool set( MP4FileHandle file, MP4TrackId trackId, const Item& item ); + + /// Fetch colr-box (Color Parameter Box) properties by track-index. + /// + /// This function gets the properties of a <b>colr-box</b> + /// (Color Parameter Box). + /// + /// @param file on which to operate. + /// @param trackIndex on which to operate. + /// @param item colr-box properties to set. + /// + /// @return <b>true</b> on failure, <b>false</b> on success. + /// + static bool get( MP4FileHandle file, uint16_t trackIndex, Item& item ); + + /// Fetch colr-box (Color Parameter Box) properties by track-id. + /// + /// This function gets the properties of a <b>colr-box</b> + /// (Color Parameter Box). + /// + /// @param file on which to operate. + /// @param trackId on which to operate. + /// @param item colr-box properties to set. + /// + /// @return <b>true</b> on failure, <b>false</b> on success. + /// + static bool get( MP4FileHandle file, MP4TrackId trackId, Item& item ); + + /// Remove colr-box (Color Parameter Box) by track-index. + /// + /// @param file on which to operate. + /// @param trackIndex on which to operate. + /// + /// @return <b>true</b> on failure, <b>false</b> on success. + /// + static bool remove( MP4FileHandle file, uint16_t trackIndex ); + + /// Remove colr-box (Color Parameter Box) by track-id. + /// + /// @param file on which to operate. + /// @param trackId on which to operate. + /// + /// @return <b>true</b> on failure, <b>false</b> on success. + /// + static bool remove( MP4FileHandle file, MP4TrackId trackId ); +}; + +/////////////////////////////////////////////////////////////////////////////// + +}}} // namespace mp4v2::impl::qtff + +#endif // MP4V2_IMPL_QTTF_COLORPARAMETERBOX_H diff --git a/src/qtff/PictureAspectRatioBox.cpp b/src/qtff/PictureAspectRatioBox.cpp new file mode 100644 index 0000000..3be710c --- /dev/null +++ b/src/qtff/PictureAspectRatioBox.cpp @@ -0,0 +1,309 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is MP4v2. +// +// The Initial Developer of the Original Code is Kona Blend. +// Portions created by Kona Blend are Copyright (C) 2008. +// All Rights Reserved. +// +// Contributors: +// Kona Blend, kona8lend@@gmail.com +// +/////////////////////////////////////////////////////////////////////////////// + +#include "impl.h" + +namespace mp4v2 { namespace impl { namespace qtff { + +/////////////////////////////////////////////////////////////////////////////// + +namespace { + const string BOX_CODE = "pasp"; + + bool findPictureAspectRatioBox( MP4FileHandle file, MP4Atom& coding, MP4Atom*& pasp ); +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +PictureAspectRatioBox::add( MP4FileHandle file, uint16_t trackIndex, const Item& item ) +{ + MP4Atom* coding; + if( findCoding( file, trackIndex, coding )) + throw new MP4Exception( "supported coding not found" ); + + MP4Atom* pasp; + if( !findPictureAspectRatioBox( file, *coding, pasp )) + throw new MP4Exception( "pasp-box already exists" ); + + pasp = MP4Atom::CreateAtom( coding, BOX_CODE.c_str() ); + coding->AddChildAtom( pasp ); + pasp->Generate(); + + MP4Integer16Property* hSpacing; + MP4Integer16Property* vSpacing; + + if( pasp->FindProperty( "pasp.hSpacing", (MP4Property**)&hSpacing )) + hSpacing->SetValue( item.hSpacing ); + + if( pasp->FindProperty( "pasp.vSpacing", (MP4Property**)&vSpacing )) + vSpacing->SetValue( item.vSpacing ); + + return false; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +PictureAspectRatioBox::add( MP4FileHandle file, MP4TrackId trackId, const Item& item ) +{ + MP4File& mp4 = *((MP4File*)file); + return add( file, mp4.FindTrackIndex( trackId ), item ); +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +PictureAspectRatioBox::get( MP4FileHandle file, uint16_t trackIndex, Item& item ) +{ + item.reset(); + + MP4Atom* coding; + if( findCoding( file, trackIndex, coding )) + throw new MP4Exception( "supported coding not found" ); + + MP4Atom* pasp; + if( findPictureAspectRatioBox( file, *coding, pasp )) + throw new MP4Exception( "pasp-box not found" ); + + MP4Integer16Property* hSpacing; + MP4Integer16Property* vSpacing; + + if( pasp->FindProperty( "pasp.hSpacing", (MP4Property**)&hSpacing )) + item.hSpacing = hSpacing->GetValue(); + + if( pasp->FindProperty( "pasp.vSpacing", (MP4Property**)&vSpacing )) + item.vSpacing = vSpacing->GetValue(); + + return false; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +PictureAspectRatioBox::get( MP4FileHandle file, MP4TrackId trackId, Item& item ) +{ + MP4File& mp4 = *((MP4File*)file); + return get( file, mp4.FindTrackIndex( trackId ), item ); +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +PictureAspectRatioBox::list( MP4FileHandle file, ItemList& itemList ) +{ + itemList.clear(); + MP4File& mp4 = *((MP4File*)file); + + const uint16_t trackc = mp4.GetNumberOfTracks(); + for( uint16_t i = 0; i < trackc; i++) { + MP4TrackId id = mp4.FindTrackId( i ); + if( id == MP4_INVALID_TRACK_ID ) + continue; + + const char* type = mp4.GetTrackType( id ); + if( !type ) + continue; + + itemList.resize( itemList.size() + 1 ); + IndexedItem& xitem = itemList[itemList.size()-1]; + + xitem.trackIndex = i; + xitem.trackId = id; + + bool success = false; + try { + success = !get( file, i, xitem.item ); + } + catch( MP4Exception* x ) { + delete x; + } + + if( !success ) { + itemList.resize( itemList.size() - 1 ); + continue; + } + } + + return false; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +PictureAspectRatioBox::remove( MP4FileHandle file, uint16_t trackIndex ) +{ + MP4Atom* coding; + if( findCoding( file, trackIndex, coding )) + throw new MP4Exception( "supported coding not found" ); + + MP4Atom* pasp; + if( findPictureAspectRatioBox( file, *coding, pasp )) + throw new MP4Exception( "pasp-box not found" ); + + coding->DeleteChildAtom( pasp ); + delete pasp; + + return false; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +PictureAspectRatioBox::remove( MP4FileHandle file, MP4TrackId trackId ) +{ + MP4File& mp4 = *((MP4File*)file); + return remove( file, mp4.FindTrackIndex( trackId )); +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +PictureAspectRatioBox::set( MP4FileHandle file, uint16_t trackIndex, const Item& item ) +{ + MP4Atom* coding; + if( findCoding( file, trackIndex, coding )) + throw new MP4Exception( "supported coding not found" ); + + MP4Atom* pasp; + if( findPictureAspectRatioBox( file, *coding, pasp )) + throw new MP4Exception( "pasp-box not found" ); + + MP4Integer16Property* hSpacing; + MP4Integer16Property* vSpacing; + + if( pasp->FindProperty( "pasp.hSpacing", (MP4Property**)&hSpacing )) + hSpacing->SetValue( item.hSpacing ); + + if( pasp->FindProperty( "pasp.vSpacing", (MP4Property**)&vSpacing )) + vSpacing->SetValue( item.vSpacing ); + + return false; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +PictureAspectRatioBox::set( MP4FileHandle file, MP4TrackId trackId, const Item& item ) +{ + MP4File& mp4 = *((MP4File*)file); + return set( file, mp4.FindTrackIndex( trackId ), item ); +} + +/////////////////////////////////////////////////////////////////////////////// + +PictureAspectRatioBox::IndexedItem::IndexedItem() + : trackIndex ( numeric_limits<uint16_t>::max() ) + , trackId ( MP4_INVALID_TRACK_ID ) +{ +} + +/////////////////////////////////////////////////////////////////////////////// + +PictureAspectRatioBox::Item::Item() + : hSpacing ( 1 ) + , vSpacing ( 1 ) +{ +} + +/////////////////////////////////////////////////////////////////////////////// + +void +PictureAspectRatioBox::Item::reset() +{ + hSpacing = 1; + vSpacing = 1; +} + +/////////////////////////////////////////////////////////////////////////////// + +void +PictureAspectRatioBox::Item::convertFromCSV( const string& text ) +{ + istringstream iss( text ); + char delim; + + iss >> hSpacing; + iss >> delim; + iss >> vSpacing; + + // input was good if we end up with only eofbit set + if( iss.rdstate() != ios::eofbit ) { + reset(); + ostringstream xss; + xss << "invalid PcitureAspectRatioBox format" + << " (expecting: hSpacing,vSpacing)" + << " got: " << text; + throw new MP4Exception( xss ); + } +} + +/////////////////////////////////////////////////////////////////////////////// + +string +PictureAspectRatioBox::Item::convertToCSV() const +{ + string buffer; + return convertToCSV( buffer ); +} + +/////////////////////////////////////////////////////////////////////////////// + +string& +PictureAspectRatioBox::Item::convertToCSV( string& buffer ) const +{ + ostringstream oss; + oss << hSpacing << ',' << vSpacing; + buffer = oss.str(); + return buffer; +} + +/////////////////////////////////////////////////////////////////////////////// + +namespace { + +/////////////////////////////////////////////////////////////////////////////// + +bool +findPictureAspectRatioBox( MP4FileHandle file, MP4Atom& coding, MP4Atom*& pasp ) +{ + pasp = NULL; + + MP4Atom* found = NULL; + const uint32_t atomc = coding.GetNumberOfChildAtoms(); + for( uint32_t i = 0; i < atomc; i++ ) { + MP4Atom* atom = coding.GetChildAtom( i ); + if( BOX_CODE != atom->GetType() ) + continue; + found = atom; + } + if( !found ) + return true; + + pasp = found; + return false; +} + +/////////////////////////////////////////////////////////////////////////////// + +}}}} // namespace mp4v2::impl::qtff::anonymous diff --git a/src/qtff/PictureAspectRatioBox.h b/src/qtff/PictureAspectRatioBox.h new file mode 100644 index 0000000..75e4c8f --- /dev/null +++ b/src/qtff/PictureAspectRatioBox.h @@ -0,0 +1,188 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is MP4v2. +// +// The Initial Developer of the Original Code is Kona Blend. +// Portions created by Kona Blend are Copyright (C) 2008. +// All Rights Reserved. +// +// Contributors: +// Kona Blend, kona8lend@@gmail.com +// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef MP4V2_IMPL_QTFF_PICTUREAPSECTRATIOBOX_H +#define MP4V2_IMPL_QTFF_PICTUREAPSECTRATIOBOX_H + +namespace mp4v2 { namespace impl { namespace qtff { + using namespace std; + +/////////////////////////////////////////////////////////////////////////////// + +/// Functional class for pasp-box (Picture Aspect Ratio Box) support. +/// +/// A pasp-box is expected to be contained in a video track which is one of +/// the following coding types: +/// @li avc1 +/// @li mp4v +/// +/// This implementation assumes a maximum count of <b>1</b> for +/// VideoSampleEntry of the supported codings. +/// +class MP4V2_EXPORT PictureAspectRatioBox +{ +public: + /// Data object for pasp-box item. + /// This object correlates to one pasp-box (Picture Aspect Ratio Box). + class MP4V2_EXPORT Item + { + public: + Item (); + + /// reset to state of newly constructed object. + void reset(); + + // convert from string CSV format. + void convertFromCSV( const string& csv ); + + // convert to string CSV format. + string convertToCSV() const; + + // convert to string CSV format with buffer. + string& convertToCSV( string& buffer ) const; + + public: + /// an unsigned 32-bit integer specifying the vertical spacing of pixels. + uint32_t hSpacing; + + /// an unsigned 32-bit integer specifying the horizontal spacing of pixels. + uint32_t vSpacing; + }; + + class MP4V2_EXPORT IndexedItem { + public: + IndexedItem(); + + uint16_t trackIndex; + uint16_t trackId; + Item item; + }; + + typedef vector<IndexedItem> ItemList; + + static bool list( MP4FileHandle file, ItemList& itemList ); + + /// Add pasp-box by track-index. + /// + /// This function adds a pasp-box to <b>trackId</b> of <b>file</b>. + /// The track must be a video-track and match one of the supporting + /// codings. + /// + /// @param file on which to operate. + /// @param trackIndex on which to operate. + /// @param item pasp-box properties to set. + /// + /// @return <b>true</b> on failure, <b>false</b> on success. + /// + static bool add( MP4FileHandle file, uint16_t trackIndex, const Item& item ); + + /// Add pasp-box by track-id. + /// + /// This function adds a pasp-box to <b>trackId</b> of <b>file</b>. + /// The track must be a video-track and match one of the supporting + /// codings. + /// + /// @param file on which to operate. + /// @param trackId on which to operate. + /// @param item pasp-box properties to set. + /// + /// @return <b>true</b> on failure, <b>false</b> on success. + /// + static bool add( MP4FileHandle file, MP4TrackId trackId, const Item& item ); + + /// Store pasp-box (Color Parameter Box) properties by track-index. + /// + /// This function sets the properties of a <b>pasp-box</b> + /// (Color Parameter Box). + /// + /// @param file on which to operate. + /// @param trackIndex on which to operate. + /// @param item pasp-box properties to set. + /// + /// @return <b>true</b> on failure, <b>false</b> on success. + /// + static bool set( MP4FileHandle file, uint16_t trackIndex, const Item& item ); + + /// Store pasp-box (Color Parameter Box) properties by track-id. + /// + /// This function sets the properties of a <b>pasp-box</b> + /// (Color Parameter Box). + /// + /// @param file on which to operate. + /// @param trackId on which to operate. + /// @param item pasp-box properties to set. + /// + /// @return <b>true</b> on failure, <b>false</b> on success. + /// + static bool set( MP4FileHandle file, MP4TrackId trackId, const Item& item ); + + /// Fetch pasp-box (Color Parameter Box) properties by track-index. + /// + /// This function gets the properties of a <b>pasp-box</b> + /// (Color Parameter Box). + /// + /// @param file on which to operate. + /// @param trackIndex on which to operate. + /// @param item pasp-box properties to set. + /// + /// @return <b>true</b> on failure, <b>false</b> on success. + /// + static bool get( MP4FileHandle file, uint16_t trackIndex, Item& item ); + + /// Fetch pasp-box (Color Parameter Box) properties by track-id. + /// + /// This function gets the properties of a <b>pasp-box</b> + /// (Color Parameter Box). + /// + /// @param file on which to operate. + /// @param trackId on which to operate. + /// @param item pasp-box properties to set. + /// + /// @return <b>true</b> on failure, <b>false</b> on success. + /// + static bool get( MP4FileHandle file, MP4TrackId trackId, Item& item ); + + /// Remove pasp-box (Color Parameter Box) by track-index. + /// + /// @param file on which to operate. + /// @param trackIndex on which to operate. + /// + /// @return <b>true</b> on failure, <b>false</b> on success. + /// + static bool remove( MP4FileHandle file, uint16_t trackIndex ); + + /// Remove pasp-box (Color Parameter Box) by track-id. + /// + /// @param file on which to operate. + /// @param trackId on which to operate. + /// + /// @return <b>true</b> on failure, <b>false</b> on success. + /// + static bool remove( MP4FileHandle file, MP4TrackId trackId ); +}; + +/////////////////////////////////////////////////////////////////////////////// + +}}} // namespace mp4v2::impl::qtff + +#endif // MP4V2_IMPL_QTTF_PICTUREAPSECTRATIOBOX_H diff --git a/src/qtff/coding.cpp b/src/qtff/coding.cpp new file mode 100644 index 0000000..697d8f4 --- /dev/null +++ b/src/qtff/coding.cpp @@ -0,0 +1,95 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is MP4v2. +// +// The Initial Developer of the Original Code is Kona Blend. +// Portions created by Kona Blend are Copyright (C) 2008. +// All Rights Reserved. +// +// Contributors: +// Kona Blend, kona8lend@@gmail.com +// +/////////////////////////////////////////////////////////////////////////////// + +#include "impl.h" + +namespace mp4v2 { namespace impl { namespace qtff { + +/////////////////////////////////////////////////////////////////////////////// + +namespace { + class StaticData + { + public: + StaticData() + { + supportedCodings.insert( "avc1" ); + supportedCodings.insert( "mp4v" ); + } + + set<string> supportedCodings; + }; + + const StaticData STATIC_DATA; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +findCoding( MP4FileHandle file, uint16_t trackIndex, MP4Atom*& coding ) +{ + coding = NULL; + MP4File& mp4 = *((MP4File*)file); + + if( trackIndex == numeric_limits<uint16_t>::max() ) { + ostringstream xss; + xss << "invalid track-index: " << trackIndex; + throw new MP4Exception( xss ); + } + + ostringstream oss; + oss << "moov.trak[" << trackIndex << "].mdia.hdlr"; + MP4Atom* hdlr = mp4.FindAtom( oss.str().c_str() ); + if( !hdlr ) + throw new MP4Exception( "media handler not found" ); + + MP4StringProperty* handlerType; + if( !hdlr->FindProperty( "hdlr.handlerType", (MP4Property**)&handlerType )) + throw new MP4Exception( "media handler type-property not found" ); + + const string video = "vide"; + if( video != handlerType->GetValue() ) + throw new MP4Exception( "video-track required" ); + + oss.str( "" ); + oss.clear(); + oss << "moov.trak[" << trackIndex << "].mdia.minf.stbl.stsd"; + MP4Atom* stsd = mp4.FindAtom( oss.str().c_str() ); + if( !stsd ) + throw new MP4Exception( "media handler type-property not found" ); + + // find first atom which is a supported coding + const uint32_t atomc = stsd->GetNumberOfChildAtoms(); + for( uint32_t i = 0; i < atomc; i++ ) { + MP4Atom* atom = stsd->GetChildAtom( i ); + if( STATIC_DATA.supportedCodings.find( atom->GetType() ) == STATIC_DATA.supportedCodings.end() ) + continue; + coding = atom; + } + + return coding == NULL; +} + +/////////////////////////////////////////////////////////////////////////////// + +}}} // namespace mp4v2::impl::qtff diff --git a/src/qtff/coding.h b/src/qtff/coding.h new file mode 100644 index 0000000..819c5cc --- /dev/null +++ b/src/qtff/coding.h @@ -0,0 +1,37 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is MP4v2. +// +// The Initial Developer of the Original Code is Kona Blend. +// Portions created by Kona Blend are Copyright (C) 2008. +// All Rights Reserved. +// +// Contributors: +// Kona Blend, kona8lend@@gmail.com +// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef MP4V2_IMPL_QTFF_CODING_H +#define MP4V2_IMPL_QTFF_CODING_H + +namespace mp4v2 { namespace impl { namespace qtff { + +/////////////////////////////////////////////////////////////////////////////// + +bool findCoding( MP4FileHandle file, uint16_t trackIndex, MP4Atom*& coding ); + +/////////////////////////////////////////////////////////////////////////////// + +}}} // namespace mp4v2::impl::qtff + +#endif // MP4V2_IMPL_QTTF_CODING_H diff --git a/src/qtff/impl.h b/src/qtff/impl.h new file mode 100644 index 0000000..27c7edb --- /dev/null +++ b/src/qtff/impl.h @@ -0,0 +1,34 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is MP4v2. +// +// The Initial Developer of the Original Code is Kona Blend. +// Portions created by Kona Blend are Copyright (C) 2008. +// All Rights Reserved. +// +// Contributors: +// Kona Blend, kona8lend@@gmail.com +// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef MP4V2_IMPL_QTFF_IMPL_H +#define MP4V2_IMPL_QTFF_IMPL_H + +/////////////////////////////////////////////////////////////////////////////// + +#include "src/impl.h" +#include "qtff.h" + +/////////////////////////////////////////////////////////////////////////////// + +#endif // MP4V2_IMPL_QTFF_IMPL_H diff --git a/src/qtff/qtff.h b/src/qtff/qtff.h new file mode 100644 index 0000000..6403821 --- /dev/null +++ b/src/qtff/qtff.h @@ -0,0 +1,45 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is MP4v2. +// +// The Initial Developer of the Original Code is Kona Blend. +// Portions created by Kona Blend are Copyright (C) 2008. +// All Rights Reserved. +// +// Contributors: +// Kona Blend, kona8lend@@gmail.com +// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef MP4V2_IMPL_QTFF_QTFF_H +#define MP4V2_IMPL_QTFF_QTFF_H + +/// @namespace mp4v2::impl::qtff (private) QuickTime File Format. +/// <b>WARNING: THIS IS A PRIVATE NAMESPACE. NOT FOR PUBLIC CONSUMPTION.</b> +/// +/// This namespace implements some features that are specified by the +/// QuickTime File Format Specification, revision 2007-09-04. +/// +namespace mp4v2 { namespace impl { namespace qtff { + ; +}}} + +/////////////////////////////////////////////////////////////////////////////// + +#include "ColorParameterBox.h" +#include "PictureAspectRatioBox.h" +#include "coding.h" + +/////////////////////////////////////////////////////////////////////////////// + +#endif // MP4V2_IMPL_QTTF_QTFF_H diff --git a/src/rtphint.cpp b/src/rtphint.cpp new file mode 100644 index 0000000..ec3071c --- /dev/null +++ b/src/rtphint.cpp @@ -0,0 +1,1371 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + */ + +#include "src/impl.h" + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +/* rtp hint track operations */ + +MP4RtpHintTrack::MP4RtpHintTrack(MP4File* pFile, MP4Atom* pTrakAtom) + : MP4Track(pFile, pTrakAtom) +{ + m_pRefTrack = NULL; + + m_pRtpMapProperty = NULL; + m_pPayloadNumberProperty = NULL; + m_pMaxPacketSizeProperty = NULL; + m_pSnroProperty = NULL; + m_pTsroProperty = NULL; + + m_pReadHint = NULL; + m_pReadHintSample = NULL; + m_readHintSampleSize = 0; + + m_pWriteHint = NULL; + m_writeHintId = MP4_INVALID_SAMPLE_ID; + m_writePacketId = 0; + + m_pTrpy = NULL; + m_pNump = NULL; + m_pTpyl = NULL; + m_pMaxr = NULL; + m_pDmed = NULL; + m_pDimm = NULL; + m_pPmax = NULL; + m_pDmax = NULL; + + m_pMaxPdu = NULL; + m_pAvgPdu = NULL; + m_pMaxBitRate = NULL; + m_pAvgBitRate = NULL; + + m_thisSec = 0; + m_bytesThisSec = 0; + m_bytesThisHint = 0; + m_bytesThisPacket = 0; +} + +MP4RtpHintTrack::~MP4RtpHintTrack() +{ + delete m_pReadHint; + delete m_pReadHintSample; + delete m_pWriteHint; +} + +void MP4RtpHintTrack::InitRefTrack() +{ + if (m_pRefTrack == NULL) { + MP4Integer32Property* pRefTrackIdProperty = NULL; + (void)m_pTrakAtom->FindProperty( + "trak.tref.hint.entries[0].trackId", + (MP4Property**)&pRefTrackIdProperty); + ASSERT(pRefTrackIdProperty); + + m_pRefTrack = m_pFile->GetTrack(pRefTrackIdProperty->GetValue()); + } +} + +void MP4RtpHintTrack::InitRtpStart() +{ + number::srandom( time::getLocalTimeMilliseconds() ); + + ASSERT(m_pTrakAtom); + + (void)m_pTrakAtom->FindProperty( + "trak.udta.hnti.rtp .snro.offset", + (MP4Property**)&m_pSnroProperty); + + if (m_pSnroProperty) { + m_rtpSequenceStart = m_pSnroProperty->GetValue(); + } else { + m_rtpSequenceStart = number::random32(); + } + + (void)m_pTrakAtom->FindProperty( + "trak.udta.hnti.rtp .tsro.offset", + (MP4Property**)&m_pTsroProperty); + + if (m_pTsroProperty) { + m_rtpTimestampStart = m_pTsroProperty->GetValue(); + } else { + m_rtpTimestampStart = number::random32(); + } +} + +void MP4RtpHintTrack::ReadHint( + MP4SampleId hintSampleId, + uint16_t* pNumPackets) +{ + if (m_pRefTrack == NULL) { + InitRefTrack(); + InitRtpStart(); + } + + // dispose of any old hint + delete m_pReadHint; + m_pReadHint = NULL; + delete m_pReadHintSample; + m_pReadHintSample = NULL; + m_readHintSampleSize = 0; + + // read the desired hint sample into memory + ReadSample( + hintSampleId, + &m_pReadHintSample, + &m_readHintSampleSize, + &m_readHintTimestamp); + + m_pFile->EnableMemoryBuffer(m_pReadHintSample, m_readHintSampleSize); + + m_pReadHint = new MP4RtpHint(this); + m_pReadHint->Read(m_pFile); + + m_pFile->DisableMemoryBuffer(); + + if (pNumPackets) { + *pNumPackets = GetHintNumberOfPackets(); + } +} + +uint16_t MP4RtpHintTrack::GetHintNumberOfPackets() +{ + if (m_pReadHint == NULL) { + throw new MP4Error("no hint has been read", + "MP4GetRtpHintNumberOfPackets"); + } + return m_pReadHint->GetNumberOfPackets(); +} + +bool MP4RtpHintTrack::GetPacketBFrame(uint16_t packetIndex) +{ + if (m_pReadHint == NULL) { + throw new MP4Error("no hint has been read", + "MP4GetRtpPacketBFrame"); + } + MP4RtpPacket* pPacket = + m_pReadHint->GetPacket(packetIndex); + + return pPacket->IsBFrame(); +} + +uint16_t MP4RtpHintTrack::GetPacketTransmitOffset(uint16_t packetIndex) +{ + if (m_pReadHint == NULL) { + throw new MP4Error("no hint has been read", + "MP4GetRtpPacketTransmitOffset"); + } + + MP4RtpPacket* pPacket = + m_pReadHint->GetPacket(packetIndex); + + return pPacket->GetTransmitOffset(); +} + +void MP4RtpHintTrack::ReadPacket( + uint16_t packetIndex, + uint8_t** ppBytes, + uint32_t* pNumBytes, + uint32_t ssrc, + bool addHeader, + bool addPayload) +{ + if (m_pReadHint == NULL) { + throw new MP4Error("no hint has been read", + "MP4ReadRtpPacket"); + } + if (!addHeader && !addPayload) { + throw new MP4Error("no data requested", + "MP4ReadRtpPacket"); + } + + MP4RtpPacket* pPacket = + m_pReadHint->GetPacket(packetIndex); + + *pNumBytes = 0; + if (addHeader) { + *pNumBytes += 12; + } + if (addPayload) { + *pNumBytes += pPacket->GetDataSize(); + } + + // if needed, allocate the packet memory + bool buffer_malloc = false; + + if (*ppBytes == NULL) { + *ppBytes = (uint8_t*)MP4Malloc(*pNumBytes); + buffer_malloc = true; + } + + try { + uint8_t* pDest = *ppBytes; + + if (addHeader) { + *pDest++ = + 0x80 | (pPacket->GetPBit() << 5) | (pPacket->GetXBit() << 4); + + *pDest++ = + (pPacket->GetMBit() << 7) | pPacket->GetPayload(); + + *((uint16_t*)pDest) = + MP4V2_HTONS(m_rtpSequenceStart + pPacket->GetSequenceNumber()); + pDest += 2; + + *((uint32_t*)pDest) = + MP4V2_HTONL(m_rtpTimestampStart + (uint32_t)m_readHintTimestamp); + pDest += 4; + + *((uint32_t*)pDest) = + MP4V2_HTONL(ssrc); + pDest += 4; + } + + if (addPayload) { + pPacket->GetData(pDest); + } + } + catch (MP4Error* e) { + if (buffer_malloc) { + MP4Free(*ppBytes); + *ppBytes = NULL; + } + throw e; + } + + VERBOSE_READ_HINT(m_pFile->GetVerbosity(), + printf("ReadPacket: %u ", packetIndex); + MP4HexDump(*ppBytes, *pNumBytes);); +} + +MP4Timestamp MP4RtpHintTrack::GetRtpTimestampStart() +{ + if (m_pRefTrack == NULL) { + InitRefTrack(); + InitRtpStart(); + } + + return m_rtpTimestampStart; +} + +void MP4RtpHintTrack::SetRtpTimestampStart(MP4Timestamp start) +{ + if (!m_pTsroProperty) { + MP4Atom* pTsroAtom = + m_pFile->AddDescendantAtoms(m_pTrakAtom, "udta.hnti.rtp .tsro"); + + ASSERT(pTsroAtom); + + (void)pTsroAtom->FindProperty("offset", + (MP4Property**)&m_pTsroProperty); + + ASSERT(m_pTsroProperty); + } + + m_pTsroProperty->SetValue(start); + m_rtpTimestampStart = start; +} + +void MP4RtpHintTrack::InitPayload() +{ + ASSERT(m_pTrakAtom); + + if (m_pRtpMapProperty == NULL) { + (void)m_pTrakAtom->FindProperty( + "trak.udta.hinf.payt.rtpMap", + (MP4Property**)&m_pRtpMapProperty); + } + + if (m_pPayloadNumberProperty == NULL) { + (void)m_pTrakAtom->FindProperty( + "trak.udta.hinf.payt.payloadNumber", + (MP4Property**)&m_pPayloadNumberProperty); + } + + if (m_pMaxPacketSizeProperty == NULL) { + (void)m_pTrakAtom->FindProperty( + "trak.mdia.minf.stbl.stsd.rtp .maxPacketSize", + (MP4Property**)&m_pMaxPacketSizeProperty); + } +} + +void MP4RtpHintTrack::GetPayload( + char** ppPayloadName, + uint8_t* pPayloadNumber, + uint16_t* pMaxPayloadSize, + char **ppEncodingParams) +{ + const char* pRtpMap; + const char* pSlash; + uint32_t length; + InitPayload(); + + if (ppPayloadName || ppEncodingParams) { + if (ppPayloadName) + *ppPayloadName = NULL; + if (ppEncodingParams) + *ppEncodingParams = NULL; + if (m_pRtpMapProperty) { + pRtpMap = m_pRtpMapProperty->GetValue(); + pSlash = strchr(pRtpMap, '/'); + + if (pSlash) { + length = pSlash - pRtpMap; + } else { + length = strlen(pRtpMap); + } + + if (ppPayloadName) { + *ppPayloadName = (char*)MP4Calloc(length + 1); + strncpy(*ppPayloadName, pRtpMap, length); + } + if (pSlash && ppEncodingParams) { + pSlash++; + pSlash = strchr(pSlash, '/'); + if (pSlash != NULL) { + pSlash++; + if (pSlash != '\0') { + length = strlen(pRtpMap) - (pSlash - pRtpMap); + *ppEncodingParams = (char *)MP4Calloc(length + 1); + strncpy(*ppEncodingParams, pSlash, length); + } + } + } + } + } + + if (pPayloadNumber) { + if (m_pPayloadNumberProperty) { + *pPayloadNumber = m_pPayloadNumberProperty->GetValue(); + } else { + *pPayloadNumber = 0; + } + } + + if (pMaxPayloadSize) { + if (m_pMaxPacketSizeProperty) { + *pMaxPayloadSize = m_pMaxPacketSizeProperty->GetValue(); + } else { + *pMaxPayloadSize = 0; + } + } +} + +void MP4RtpHintTrack::SetPayload( + const char* payloadName, + uint8_t payloadNumber, + uint16_t maxPayloadSize, + const char *encoding_parms, + bool include_rtp_map, + bool include_mpeg4_esid) +{ + InitRefTrack(); + InitPayload(); + + ASSERT(m_pRtpMapProperty); + ASSERT(m_pPayloadNumberProperty); + ASSERT(m_pMaxPacketSizeProperty); + + size_t len = strlen(payloadName) + 16; + if (encoding_parms != NULL) { + size_t temp = strlen(encoding_parms); + if (temp == 0) { + encoding_parms = NULL; + } else { + len += temp; + } + } + + char* rtpMapBuf = (char*)MP4Malloc(len); + snprintf(rtpMapBuf, len, "%s/%u%c%s", + payloadName, + GetTimeScale(), + encoding_parms != NULL ? '/' : '\0', + encoding_parms == NULL ? "" : encoding_parms); + m_pRtpMapProperty->SetValue(rtpMapBuf); + + m_pPayloadNumberProperty->SetValue(payloadNumber); + + if (maxPayloadSize == 0) { + maxPayloadSize = 1460; + } + m_pMaxPacketSizeProperty->SetValue(maxPayloadSize); + + // set sdp media type + const char* sdpMediaType; + if (!strcmp(m_pRefTrack->GetType(), MP4_AUDIO_TRACK_TYPE)) { + sdpMediaType = "audio"; + } else if (!strcmp(m_pRefTrack->GetType(), MP4_VIDEO_TRACK_TYPE)) { + sdpMediaType = "video"; + } else if (!strcmp(m_pRefTrack->GetType(), MP4_CNTL_TRACK_TYPE)) { + sdpMediaType = "control"; + } else { + sdpMediaType = "application"; + } + + uint32_t maxlen = + strlen(sdpMediaType) + strlen(rtpMapBuf) + 256; + char* sdpBuf = (char*)MP4Malloc(maxlen); + uint32_t buflen; + buflen = snprintf(sdpBuf, maxlen, + "m=%s 0 RTP/AVP %u\015\012" + "a=control:trackID=%u\015\012", + sdpMediaType, payloadNumber, + m_trackId); + if (include_rtp_map) { + buflen += snprintf(sdpBuf + buflen, maxlen - buflen, + "a=rtpmap:%u %s\015\012", + payloadNumber, rtpMapBuf); + } + if (include_mpeg4_esid) { + snprintf(sdpBuf + buflen, maxlen - buflen, + "a=mpeg4-esid:%u\015\012", + m_pRefTrack->GetId()); + } + + MP4StringProperty* pSdpProperty = NULL; + (void)m_pTrakAtom->FindProperty("trak.udta.hnti.sdp .sdpText", + (MP4Property**)&pSdpProperty); + ASSERT(pSdpProperty); + pSdpProperty->SetValue(sdpBuf); + + // cleanup + MP4Free(rtpMapBuf); + MP4Free(sdpBuf); +} + +void MP4RtpHintTrack::AddHint(bool isBFrame, uint32_t timestampOffset) +{ + // on first hint, need to lookup the reference track + if (m_writeHintId == MP4_INVALID_SAMPLE_ID) { + InitRefTrack(); + InitStats(); + } + + if (m_pWriteHint) { + throw new MP4Error("unwritten hint is still pending", "MP4AddRtpHint"); + } + + m_pWriteHint = new MP4RtpHint(this); + m_pWriteHint->SetBFrame(isBFrame); + m_pWriteHint->SetTimestampOffset(timestampOffset); + + m_bytesThisHint = 0; + m_writeHintId++; +} + +void MP4RtpHintTrack::AddPacket(bool setMbit, int32_t transmitOffset) +{ + if (m_pWriteHint == NULL) { + throw new MP4Error("no hint pending", "MP4RtpAddPacket"); + } + + MP4RtpPacket* pPacket = m_pWriteHint->AddPacket(); + + ASSERT(m_pPayloadNumberProperty); + + pPacket->Set( + m_pPayloadNumberProperty->GetValue(), + m_writePacketId++, + setMbit); + pPacket->SetTransmitOffset(transmitOffset); + + m_bytesThisHint += 12; + if (m_bytesThisPacket > m_pPmax->GetValue()) { + m_pPmax->SetValue(m_bytesThisPacket); + } + m_bytesThisPacket = 12; + m_pNump->IncrementValue(); + m_pTrpy->IncrementValue(12); // RTP packet header size +} + +void MP4RtpHintTrack::AddImmediateData( + const uint8_t* pBytes, + uint32_t numBytes) +{ + if (m_pWriteHint == NULL) { + throw new MP4Error("no hint pending", "MP4RtpAddImmediateData"); + } + + MP4RtpPacket* pPacket = m_pWriteHint->GetCurrentPacket(); + if (pPacket == NULL) { + throw new MP4Error("no packet pending", "MP4RtpAddImmediateData"); + } + + if (pBytes == NULL || numBytes == 0) { + throw new MP4Error("no data", + "AddImmediateData"); + } + if (numBytes > 14) { + throw new MP4Error("data size is larger than 14 bytes", + "AddImmediateData"); + } + + MP4RtpImmediateData* pData = new MP4RtpImmediateData(pPacket); + pData->Set(pBytes, numBytes); + + pPacket->AddData(pData); + + m_bytesThisHint += numBytes; + m_bytesThisPacket += numBytes; + m_pDimm->IncrementValue(numBytes); + m_pTpyl->IncrementValue(numBytes); + m_pTrpy->IncrementValue(numBytes); +} + +void MP4RtpHintTrack::AddSampleData( + MP4SampleId sampleId, + uint32_t dataOffset, + uint32_t dataLength) +{ + if (m_pWriteHint == NULL) { + throw new MP4Error("no hint pending", "MP4RtpAddSampleData"); + } + + MP4RtpPacket* pPacket = m_pWriteHint->GetCurrentPacket(); + if (pPacket == NULL) { + throw new MP4Error("no packet pending", "MP4RtpAddSampleData"); + } + + MP4RtpSampleData* pData = new MP4RtpSampleData(pPacket); + + pData->SetReferenceSample(sampleId, dataOffset, dataLength); + + pPacket->AddData(pData); + + m_bytesThisHint += dataLength; + m_bytesThisPacket += dataLength; + m_pDmed->IncrementValue(dataLength); + m_pTpyl->IncrementValue(dataLength); + m_pTrpy->IncrementValue(dataLength); +} + +void MP4RtpHintTrack::AddESConfigurationPacket() +{ + if (m_pWriteHint == NULL) { + throw new MP4Error("no hint pending", + "MP4RtpAddESConfigurationPacket"); + } + + uint8_t* pConfig = NULL; + uint32_t configSize = 0; + + m_pFile->GetTrackESConfiguration(m_pRefTrack->GetId(), + &pConfig, &configSize); + + if (pConfig == NULL) { + return; + } + + ASSERT(m_pMaxPacketSizeProperty); + + if (configSize > m_pMaxPacketSizeProperty->GetValue()) { + throw new MP4Error("ES configuration is too large for RTP payload", + "MP4RtpAddESConfigurationPacket"); + } + + AddPacket(false); + + MP4RtpPacket* pPacket = m_pWriteHint->GetCurrentPacket(); + ASSERT(pPacket); + + // This is ugly! + // To get the ES configuration data somewhere known + // we create a sample data reference that points to + // this hint track (not the media track) + // and this sample of the hint track + // the offset into this sample is filled in during the write process + MP4RtpSampleData* pData = new MP4RtpSampleData(pPacket); + + pData->SetEmbeddedImmediate(m_writeSampleId, pConfig, configSize); + + pPacket->AddData(pData); + + m_bytesThisHint += configSize; + m_bytesThisPacket += configSize; + m_pTpyl->IncrementValue(configSize); + m_pTrpy->IncrementValue(configSize); +} + +void MP4RtpHintTrack::WriteHint(MP4Duration duration, bool isSyncSample) +{ + if (m_pWriteHint == NULL) { + throw new MP4Error("no hint pending", "MP4WriteRtpHint"); + } + + uint8_t* pBytes; + uint64_t numBytes; + + m_pFile->EnableMemoryBuffer(); + + m_pWriteHint->Write(m_pFile); + + m_pFile->DisableMemoryBuffer(&pBytes, &numBytes); + + WriteSample(pBytes, numBytes, duration, 0, isSyncSample); + + MP4Free(pBytes); + + // update statistics + if (m_bytesThisPacket > m_pPmax->GetValue()) { + m_pPmax->SetValue(m_bytesThisPacket); + } + + if (duration > m_pDmax->GetValue()) { + m_pDmax->SetValue(duration); + } + + MP4Timestamp startTime; + + GetSampleTimes(m_writeHintId, &startTime, NULL); + + if (startTime < m_thisSec + GetTimeScale()) { + m_bytesThisSec += m_bytesThisHint; + } else { + if (m_bytesThisSec > m_pMaxr->GetValue()) { + m_pMaxr->SetValue(m_bytesThisSec); + } + m_thisSec = startTime - (startTime % GetTimeScale()); + m_bytesThisSec = m_bytesThisHint; + } + + // cleanup + delete m_pWriteHint; + m_pWriteHint = NULL; +} + +void MP4RtpHintTrack::FinishWrite() +{ + if (m_writeHintId != MP4_INVALID_SAMPLE_ID) { + m_pMaxPdu->SetValue(m_pPmax->GetValue()); + if (m_pNump->GetValue()) { + m_pAvgPdu->SetValue(m_pTrpy->GetValue() / m_pNump->GetValue()); + } + + m_pMaxBitRate->SetValue(m_pMaxr->GetValue() * 8); + if (GetDuration()) { + m_pAvgBitRate->SetValue( + m_pTrpy->GetValue() * 8 * GetTimeScale() / GetDuration()); + } + } + + MP4Track::FinishWrite(); +} + +void MP4RtpHintTrack::InitStats() +{ + MP4Atom* pHinfAtom = m_pTrakAtom->FindAtom("trak.udta.hinf"); + + ASSERT(pHinfAtom); + + (void)pHinfAtom->FindProperty("hinf.trpy.bytes", (MP4Property**)&m_pTrpy); + (void)pHinfAtom->FindProperty("hinf.nump.packets", (MP4Property**)&m_pNump); + (void)pHinfAtom->FindProperty("hinf.tpyl.bytes", (MP4Property**)&m_pTpyl); + (void)pHinfAtom->FindProperty("hinf.maxr.bytes", (MP4Property**)&m_pMaxr); + (void)pHinfAtom->FindProperty("hinf.dmed.bytes", (MP4Property**)&m_pDmed); + (void)pHinfAtom->FindProperty("hinf.dimm.bytes", (MP4Property**)&m_pDimm); + (void)pHinfAtom->FindProperty("hinf.pmax.bytes", (MP4Property**)&m_pPmax); + (void)pHinfAtom->FindProperty("hinf.dmax.milliSecs", (MP4Property**)&m_pDmax); + + MP4Atom* pHmhdAtom = m_pTrakAtom->FindAtom("trak.mdia.minf.hmhd"); + + ASSERT(pHmhdAtom); + + (void)pHmhdAtom->FindProperty("hmhd.maxPduSize", (MP4Property**)&m_pMaxPdu); + (void)pHmhdAtom->FindProperty("hmhd.avgPduSize", (MP4Property**)&m_pAvgPdu); + (void)pHmhdAtom->FindProperty("hmhd.maxBitRate", (MP4Property**)&m_pMaxBitRate); + (void)pHmhdAtom->FindProperty("hmhd.avgBitRate", (MP4Property**)&m_pAvgBitRate); + + MP4Integer32Property* pMaxrPeriod = NULL; + (void)pHinfAtom->FindProperty("hinf.maxr.granularity", + (MP4Property**)&pMaxrPeriod); + if (pMaxrPeriod) { + pMaxrPeriod->SetValue(1000); // 1 second + } +} + + +MP4RtpHint::MP4RtpHint(MP4RtpHintTrack* pTrack) +{ + m_pTrack = pTrack; + + AddProperty( /* 0 */ + new MP4Integer16Property("packetCount")); + AddProperty( /* 1 */ + new MP4Integer16Property("reserved")); +} + +MP4RtpHint::~MP4RtpHint() +{ + for (uint32_t i = 0; i < m_rtpPackets.Size(); i++) { + delete m_rtpPackets[i]; + } +} + +MP4RtpPacket* MP4RtpHint::AddPacket() +{ + MP4RtpPacket* pPacket = new MP4RtpPacket(this); + m_rtpPackets.Add(pPacket); + + // packetCount property + ((MP4Integer16Property*)m_pProperties[0])->IncrementValue(); + + pPacket->SetBFrame(m_isBFrame); + pPacket->SetTimestampOffset(m_timestampOffset); + + return pPacket; +} + +void MP4RtpHint::Read(MP4File* pFile) +{ + // call base class Read for required properties + MP4Container::Read(pFile); + + uint16_t numPackets = + ((MP4Integer16Property*)m_pProperties[0])->GetValue(); + + for (uint16_t i = 0; i < numPackets; i++) { + MP4RtpPacket* pPacket = new MP4RtpPacket(this); + + m_rtpPackets.Add(pPacket); + + pPacket->Read(pFile); + } + + VERBOSE_READ_HINT(pFile->GetVerbosity(), + printf("ReadHint:\n"); Dump(stdout, 10, false);); +} + +void MP4RtpHint::Write(MP4File* pFile) +{ + uint64_t hintStartPos = pFile->GetPosition(); + + MP4Container::Write(pFile); + + uint64_t packetStartPos = pFile->GetPosition(); + + uint32_t i; + + // first write out packet (and data) entries + for (i = 0; i < m_rtpPackets.Size(); i++) { + m_rtpPackets[i]->Write(pFile); + } + + // now let packets write their extra data into the hint sample + for (i = 0; i < m_rtpPackets.Size(); i++) { + m_rtpPackets[i]->WriteEmbeddedData(pFile, hintStartPos); + } + + uint64_t endPos = pFile->GetPosition(); + + pFile->SetPosition(packetStartPos); + + // finally rewrite the packet and data entries + // which now contain the correct offsets for the embedded data + for (i = 0; i < m_rtpPackets.Size(); i++) { + m_rtpPackets[i]->Write(pFile); + } + + pFile->SetPosition(endPos); + + VERBOSE_WRITE_HINT(pFile->GetVerbosity(), + printf("WriteRtpHint:\n"); Dump(stdout, 14, false)); +} + +void MP4RtpHint::Dump(FILE* pFile, uint8_t indent, bool dumpImplicits) +{ + MP4Container::Dump(pFile, indent, dumpImplicits); + + for (uint32_t i = 0; i < m_rtpPackets.Size(); i++) { + Indent(pFile, indent); + fprintf(pFile, "RtpPacket: %u\n", i); + m_rtpPackets[i]->Dump(pFile, indent + 1, dumpImplicits); + } +} + +MP4RtpPacket::MP4RtpPacket(MP4RtpHint* pHint) +{ + m_pHint = pHint; + + AddProperty( /* 0 */ + new MP4Integer32Property("relativeXmitTime")); + AddProperty( /* 1 */ + new MP4BitfieldProperty("reserved1", 2)); + AddProperty( /* 2 */ + new MP4BitfieldProperty("Pbit", 1)); + AddProperty( /* 3 */ + new MP4BitfieldProperty("Xbit", 1)); + AddProperty( /* 4 */ + new MP4BitfieldProperty("reserved2", 4)); + AddProperty( /* 5 */ + new MP4BitfieldProperty("Mbit", 1)); + AddProperty( /* 6 */ + new MP4BitfieldProperty("payloadType", 7)); + AddProperty( /* 7 */ + new MP4Integer16Property("sequenceNumber")); + AddProperty( /* 8 */ + new MP4BitfieldProperty("reserved3", 13)); + AddProperty( /* 9 */ + new MP4BitfieldProperty("extraFlag", 1)); + AddProperty( /* 10 */ + new MP4BitfieldProperty("bFrameFlag", 1)); + AddProperty( /* 11 */ + new MP4BitfieldProperty("repeatFlag", 1)); + AddProperty( /* 12 */ + new MP4Integer16Property("entryCount")); +} + +MP4RtpPacket::~MP4RtpPacket() +{ + for (uint32_t i = 0; i < m_rtpData.Size(); i++) { + delete m_rtpData[i]; + } +} + +void MP4RtpPacket::AddExtraProperties() +{ + AddProperty( /* 13 */ + new MP4Integer32Property("extraInformationLength")); + + // This is a bit of a hack, since the tlv entries are really defined + // as atoms but there is only one type defined now, rtpo, and getting + // our atom code hooked up here would be a major pain with little gain + + AddProperty( /* 14 */ + new MP4Integer32Property("tlvLength")); + AddProperty( /* 15 */ + new MP4StringProperty("tlvType")); + AddProperty( /* 16 */ + new MP4Integer32Property("timestampOffset")); + + ((MP4Integer32Property*)m_pProperties[13])->SetValue(16); + ((MP4Integer32Property*)m_pProperties[14])->SetValue(12); + ((MP4StringProperty*)m_pProperties[15])->SetFixedLength(4); + ((MP4StringProperty*)m_pProperties[15])->SetValue("rtpo"); +} + +void MP4RtpPacket::Read(MP4File* pFile) +{ + // call base class Read for required properties + MP4Container::Read(pFile); + + // read extra info if present + // we only support the rtpo field! + if (((MP4BitfieldProperty*)m_pProperties[9])->GetValue() == 1) { + ReadExtra(pFile); + } + + uint16_t numDataEntries = + ((MP4Integer16Property*)m_pProperties[12])->GetValue(); + + // read data entries + for (uint16_t i = 0; i < numDataEntries; i++) { + uint8_t dataType; + pFile->PeekBytes(&dataType, 1); + + MP4RtpData* pData; + + switch (dataType) { + case 0: + pData = new MP4RtpNullData(this); + break; + case 1: + pData = new MP4RtpImmediateData(this); + break; + case 2: + pData = new MP4RtpSampleData(this); + break; + case 3: + pData = new MP4RtpSampleDescriptionData(this); + break; + default: + throw new MP4Error("unknown packet data entry type", + "MP4ReadHint"); + } + + m_rtpData.Add(pData); + + // read data entry's properties + pData->Read(pFile); + } +} + +void MP4RtpPacket::ReadExtra(MP4File* pFile) +{ + AddExtraProperties(); + + int32_t extraLength = (int32_t)pFile->ReadUInt32(); + + if (extraLength < 4) { + throw new MP4Error("bad packet extra info length", + "MP4RtpPacket::ReadExtra"); + } + extraLength -= 4; + + while (extraLength > 0) { + uint32_t entryLength = pFile->ReadUInt32(); + uint32_t entryTag = pFile->ReadUInt32(); + + if (entryLength < 8) { + throw new MP4Error("bad packet extra info entry length", + "MP4RtpPacket::ReadExtra"); + } + + if (entryTag == STRTOINT32("rtpo") && entryLength == 12) { + // read the rtp timestamp offset + m_pProperties[16]->Read(pFile); + } else { + // ignore it, LATER carry it along + pFile->SetPosition(pFile->GetPosition() + entryLength - 8); + } + + extraLength -= entryLength; + } + + if (extraLength < 0) { + throw new MP4Error("invalid packet extra info length", + "MP4RtpPacket::ReadExtra"); + } +} + +void MP4RtpPacket::Set(uint8_t payloadNumber, + uint32_t packetId, bool setMbit) +{ + ((MP4BitfieldProperty*)m_pProperties[5])->SetValue(setMbit); + ((MP4BitfieldProperty*)m_pProperties[6])->SetValue(payloadNumber); + ((MP4Integer16Property*)m_pProperties[7])->SetValue(packetId); +} + +int32_t MP4RtpPacket::GetTransmitOffset() +{ + return ((MP4Integer32Property*)m_pProperties[0])->GetValue(); +} + +void MP4RtpPacket::SetTransmitOffset(int32_t transmitOffset) +{ + ((MP4Integer32Property*)m_pProperties[0])->SetValue(transmitOffset); +} + +bool MP4RtpPacket::GetPBit() +{ + return ((MP4BitfieldProperty*)m_pProperties[2])->GetValue(); +} + +bool MP4RtpPacket::GetXBit() +{ + return ((MP4BitfieldProperty*)m_pProperties[3])->GetValue(); +} + +bool MP4RtpPacket::GetMBit() +{ + return ((MP4BitfieldProperty*)m_pProperties[5])->GetValue(); +} + +uint8_t MP4RtpPacket::GetPayload() +{ + return ((MP4BitfieldProperty*)m_pProperties[6])->GetValue(); +} + +uint16_t MP4RtpPacket::GetSequenceNumber() +{ + return ((MP4Integer16Property*)m_pProperties[7])->GetValue(); +} + +bool MP4RtpPacket::IsBFrame() +{ + return ((MP4BitfieldProperty*)m_pProperties[10])->GetValue(); +} + +void MP4RtpPacket::SetBFrame(bool isBFrame) +{ + ((MP4BitfieldProperty*)m_pProperties[10])->SetValue(isBFrame); +} + +void MP4RtpPacket::SetTimestampOffset(uint32_t timestampOffset) +{ + if (timestampOffset == 0) { + return; + } + + ASSERT(((MP4BitfieldProperty*)m_pProperties[9])->GetValue() == 0); + + // set X bit + ((MP4BitfieldProperty*)m_pProperties[9])->SetValue(1); + + AddExtraProperties(); + + ((MP4Integer32Property*)m_pProperties[16])->SetValue(timestampOffset); +} + +void MP4RtpPacket::AddData(MP4RtpData* pData) +{ + m_rtpData.Add(pData); + + // increment entry count property + ((MP4Integer16Property*)m_pProperties[12])->IncrementValue(); +} + +uint32_t MP4RtpPacket::GetDataSize() +{ + uint32_t totalDataSize = 0; + + for (uint32_t i = 0; i < m_rtpData.Size(); i++) { + totalDataSize += m_rtpData[i]->GetDataSize(); + } + + return totalDataSize; +} + +void MP4RtpPacket::GetData(uint8_t* pDest) +{ + for (uint32_t i = 0; i < m_rtpData.Size(); i++) { + m_rtpData[i]->GetData(pDest); + pDest += m_rtpData[i]->GetDataSize(); + } +} + +void MP4RtpPacket::Write(MP4File* pFile) +{ + MP4Container::Write(pFile); + + for (uint32_t i = 0; i < m_rtpData.Size(); i++) { + m_rtpData[i]->Write(pFile); + } +} + +void MP4RtpPacket::WriteEmbeddedData(MP4File* pFile, uint64_t startPos) +{ + for (uint32_t i = 0; i < m_rtpData.Size(); i++) { + m_rtpData[i]->WriteEmbeddedData(pFile, startPos); + } +} + +void MP4RtpPacket::Dump(FILE* pFile, uint8_t indent, bool dumpImplicits) +{ + MP4Container::Dump(pFile, indent, dumpImplicits); + + for (uint32_t i = 0; i < m_rtpData.Size(); i++) { + Indent(pFile, indent); + fprintf(pFile, "RtpData: %u\n", i); + m_rtpData[i]->Dump(pFile, indent + 1, dumpImplicits); + } +} + +MP4RtpData::MP4RtpData(MP4RtpPacket* pPacket) +{ + m_pPacket = pPacket; + + AddProperty( /* 0 */ + new MP4Integer8Property("type")); +} + +MP4Track* MP4RtpData::FindTrackFromRefIndex(uint8_t refIndex) +{ + MP4Track* pTrack; + + if (refIndex == (uint8_t)-1) { + // ourselves + pTrack = GetPacket()->GetHint()->GetTrack(); + } else if (refIndex == 0) { + // our reference track + pTrack = GetPacket()->GetHint()->GetTrack()->GetRefTrack(); + } else { + // some other track + MP4RtpHintTrack* pHintTrack = + GetPacket()->GetHint()->GetTrack(); + + MP4Atom* pTrakAtom = pHintTrack->GetTrakAtom(); + ASSERT(pTrakAtom); + + MP4Integer32Property* pTrackIdProperty = NULL; + (void)pTrakAtom->FindProperty( + "trak.tref.hint.entries", + (MP4Property**)&pTrackIdProperty); + ASSERT(pTrackIdProperty); + + uint32_t refTrackId = + pTrackIdProperty->GetValue(refIndex - 1); + + pTrack = pHintTrack->GetFile()->GetTrack(refTrackId); + } + + return pTrack; +} + +MP4RtpNullData::MP4RtpNullData(MP4RtpPacket* pPacket) + : MP4RtpData(pPacket) +{ + ((MP4Integer8Property*)m_pProperties[0])->SetValue(0); + + AddProperty( /* 1 */ + new MP4BytesProperty("pad", 15)); + + ((MP4BytesProperty*)m_pProperties[1])->SetFixedSize(15); +} + +MP4RtpImmediateData::MP4RtpImmediateData(MP4RtpPacket* pPacket) + : MP4RtpData(pPacket) +{ + ((MP4Integer8Property*)m_pProperties[0])->SetValue(1); + + AddProperty( /* 1 */ + new MP4Integer8Property("count")); + AddProperty( /* 2 */ + new MP4BytesProperty("data", 14)); + + ((MP4BytesProperty*)m_pProperties[2])->SetFixedSize(14); +} + +void MP4RtpImmediateData::Set(const uint8_t* pBytes, uint8_t numBytes) +{ + ((MP4Integer8Property*)m_pProperties[1])->SetValue(numBytes); + ((MP4BytesProperty*)m_pProperties[2])->SetValue(pBytes, numBytes); +} + +uint16_t MP4RtpImmediateData::GetDataSize() +{ + return ((MP4Integer8Property*)m_pProperties[1])->GetValue(); +} + +void MP4RtpImmediateData::GetData(uint8_t* pDest) +{ + uint8_t* pValue; + uint32_t valueSize; + ((MP4BytesProperty*)m_pProperties[2])->GetValue(&pValue, &valueSize); + + memcpy(pDest, pValue, GetDataSize()); + MP4Free(pValue); +} + +MP4RtpSampleData::MP4RtpSampleData(MP4RtpPacket* pPacket) + : MP4RtpData(pPacket) +{ + ((MP4Integer8Property*)m_pProperties[0])->SetValue(2); + + AddProperty( /* 1 */ + new MP4Integer8Property("trackRefIndex")); + AddProperty( /* 2 */ + new MP4Integer16Property("length")); + AddProperty( /* 3 */ + new MP4Integer32Property("sampleNumber")); + AddProperty( /* 4 */ + new MP4Integer32Property("sampleOffset")); + AddProperty( /* 5 */ + new MP4Integer16Property("bytesPerBlock")); + AddProperty( /* 6 */ + new MP4Integer16Property("samplesPerBlock")); + + ((MP4Integer16Property*)m_pProperties[5])->SetValue(1); + ((MP4Integer16Property*)m_pProperties[6])->SetValue(1); + + m_pRefData = NULL; + m_pRefTrack = NULL; + m_refSampleId = MP4_INVALID_SAMPLE_ID; + m_refSampleOffset = 0; +} + +void MP4RtpSampleData::SetEmbeddedImmediate(MP4SampleId sampleId, + uint8_t* pData, uint16_t dataLength) +{ + ((MP4Integer8Property*)m_pProperties[1])->SetValue((uint8_t)-1); + ((MP4Integer16Property*)m_pProperties[2])->SetValue(dataLength); + ((MP4Integer32Property*)m_pProperties[3])->SetValue(sampleId); + ((MP4Integer32Property*)m_pProperties[4])->SetValue(0); + CHECK_AND_FREE(m_pRefData); + m_pRefData = pData; +} + +void MP4RtpSampleData::SetReferenceSample( + MP4SampleId refSampleId, uint32_t refSampleOffset, + uint16_t sampleLength) +{ + ((MP4Integer8Property*)m_pProperties[1])->SetValue(0); + ((MP4Integer16Property*)m_pProperties[2])->SetValue(sampleLength); + ((MP4Integer32Property*)m_pProperties[3])->SetValue(refSampleId); + ((MP4Integer32Property*)m_pProperties[4])->SetValue(refSampleOffset); +} + +void MP4RtpSampleData::SetEmbeddedSample( + MP4SampleId sampleId, MP4Track* pRefTrack, + MP4SampleId refSampleId, uint32_t refSampleOffset, + uint16_t sampleLength) +{ + ((MP4Integer8Property*)m_pProperties[1])->SetValue((uint8_t)-1); + ((MP4Integer16Property*)m_pProperties[2])->SetValue(sampleLength); + ((MP4Integer32Property*)m_pProperties[3])->SetValue(sampleId); + ((MP4Integer32Property*)m_pProperties[4])->SetValue(0); + m_pRefTrack = pRefTrack; + m_refSampleId = refSampleId; + m_refSampleOffset = refSampleOffset; +} + +uint16_t MP4RtpSampleData::GetDataSize() +{ + return ((MP4Integer16Property*)m_pProperties[2])->GetValue(); +} + +void MP4RtpSampleData::GetData(uint8_t* pDest) +{ + uint8_t trackRefIndex = + ((MP4Integer8Property*)m_pProperties[1])->GetValue(); + + MP4Track* pSampleTrack = + FindTrackFromRefIndex(trackRefIndex); + + pSampleTrack->ReadSampleFragment( + ((MP4Integer32Property*)m_pProperties[3])->GetValue(), // sampleId + ((MP4Integer32Property*)m_pProperties[4])->GetValue(), // sampleOffset + ((MP4Integer16Property*)m_pProperties[2])->GetValue(), // sampleLength + pDest); +} + +void MP4RtpSampleData::WriteEmbeddedData(MP4File* pFile, uint64_t startPos) +{ + // if not using embedded data, nothing to do + if (((MP4Integer8Property*)m_pProperties[1])->GetValue() != (uint8_t)-1) { + return; + } + + // figure out the offset within this hint sample for this embedded data + uint64_t offset = pFile->GetPosition() - startPos; + ASSERT(offset <= 0xFFFFFFFF); + ((MP4Integer32Property*)m_pProperties[4])->SetValue((uint32_t)offset); + + uint16_t length = ((MP4Integer16Property*)m_pProperties[2])->GetValue(); + + if (m_pRefData) { + pFile->WriteBytes(m_pRefData, length); + return; + } + + if (m_refSampleId != MP4_INVALID_SAMPLE_ID) { + uint8_t* pSample = NULL; + uint32_t sampleSize = 0; + + ASSERT(m_pRefTrack); + m_pRefTrack->ReadSample(m_refSampleId, &pSample, &sampleSize); + + ASSERT(m_refSampleOffset + length <= sampleSize); + + pFile->WriteBytes(&pSample[m_refSampleOffset], length); + + MP4Free(pSample); + return; + } +} + +MP4RtpSampleDescriptionData::MP4RtpSampleDescriptionData(MP4RtpPacket* pPacket) + : MP4RtpData(pPacket) +{ + ((MP4Integer8Property*)m_pProperties[0])->SetValue(3); + + AddProperty( /* 1 */ + new MP4Integer8Property("trackRefIndex")); + AddProperty( /* 2 */ + new MP4Integer16Property("length")); + AddProperty( /* 3 */ + new MP4Integer32Property("sampleDescriptionIndex")); + AddProperty( /* 4 */ + new MP4Integer32Property("sampleDescriptionOffset")); + AddProperty( /* 5 */ + new MP4Integer32Property("reserved")); +} + +void MP4RtpSampleDescriptionData::Set(uint32_t sampleDescrIndex, + uint32_t offset, uint16_t length) +{ + ((MP4Integer16Property*)m_pProperties[2])->SetValue(length); + ((MP4Integer32Property*)m_pProperties[3])->SetValue(sampleDescrIndex); + ((MP4Integer32Property*)m_pProperties[4])->SetValue(offset); +} + +uint16_t MP4RtpSampleDescriptionData::GetDataSize() +{ + return ((MP4Integer16Property*)m_pProperties[2])->GetValue(); +} + +void MP4RtpSampleDescriptionData::GetData(uint8_t* pDest) +{ + // we start with the index into our track references + uint8_t trackRefIndex = + ((MP4Integer8Property*)m_pProperties[1])->GetValue(); + + // from which we can find the track structure + MP4Track* pSampleTrack = + FindTrackFromRefIndex(trackRefIndex); + + // next find the desired atom in the track's sample description table + uint32_t sampleDescrIndex = + ((MP4Integer32Property*)m_pProperties[3])->GetValue(); + + MP4Atom* pTrakAtom = + pSampleTrack->GetTrakAtom(); + + char sdName[64]; + snprintf(sdName, 64, "trak.mdia.minf.stbl.stsd.*[%u]", sampleDescrIndex); + + MP4Atom* pSdAtom = + pTrakAtom->FindAtom(sdName); + + // bad reference + if (pSdAtom == NULL) { + throw new MP4Error("invalid sample description index", + "MP4RtpSampleDescriptionData::GetData"); + } + + // check validity of the upcoming copy + uint16_t length = + ((MP4Integer16Property*)m_pProperties[2])->GetValue(); + uint32_t offset = + ((MP4Integer32Property*)m_pProperties[4])->GetValue(); + + if (offset + length > pSdAtom->GetSize()) { + throw new MP4Error("offset and/or length are too large", + "MP4RtpSampleDescriptionData::GetData"); + } + + // now we use the raw file to get the desired bytes + + MP4File* pFile = GetPacket()->GetHint()->GetTrack()->GetFile(); + + uint64_t orgPos = pFile->GetPosition(); + + // It's not entirely clear from the spec whether the offset is from + // the start of the sample descirption atom, or the start of the atom's + // data. I believe it is the former, but the commented out code will + // realize the latter interpretation if I turn out to be wrong. + uint64_t dataPos = pSdAtom->GetStart(); + //uint64_t dataPos = pSdAtom->GetEnd() - pSdAtom->GetSize(); + + pFile->SetPosition(dataPos + offset); + + pFile->ReadBytes(pDest, length); + + pFile->SetPosition(orgPos); +} + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl diff --git a/src/rtphint.h b/src/rtphint.h new file mode 100644 index 0000000..7096995 --- /dev/null +++ b/src/rtphint.h @@ -0,0 +1,362 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + */ + +#ifndef MP4V2_IMPL_RTPHINT_H +#define MP4V2_IMPL_RTPHINT_H + +namespace mp4v2 { +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +// forward declarations +class MP4RtpHintTrack; +class MP4RtpHint; +class MP4RtpPacket; + +class MP4RtpData : public MP4Container { +public: + MP4RtpData(MP4RtpPacket* pPacket); + + MP4RtpPacket* GetPacket() { + return m_pPacket; + } + + virtual uint16_t GetDataSize() = 0; + virtual void GetData(uint8_t* pDest) = 0; + + MP4Track* FindTrackFromRefIndex(uint8_t refIndex); + + virtual void WriteEmbeddedData(MP4File* pFile, uint64_t startPos) { + // default is no-op + } + +protected: + MP4RtpPacket* m_pPacket; +}; + +MP4ARRAY_DECL(MP4RtpData, MP4RtpData*) + +class MP4RtpNullData : public MP4RtpData { +public: + MP4RtpNullData(MP4RtpPacket* pPacket); + + uint16_t GetDataSize() { + return 0; + } + + void GetData(uint8_t* pDest) { + // no-op + } +}; + +class MP4RtpImmediateData : public MP4RtpData { +public: + MP4RtpImmediateData(MP4RtpPacket* pPacket); + + void Set(const uint8_t* pBytes, uint8_t numBytes); + + uint16_t GetDataSize(); + + void GetData(uint8_t* pDest); +}; + +class MP4RtpSampleData : public MP4RtpData { +public: + MP4RtpSampleData(MP4RtpPacket* pPacket); + + ~MP4RtpSampleData(void) { + CHECK_AND_FREE(m_pRefData); + }; + + void SetEmbeddedImmediate( + MP4SampleId sampleId, + uint8_t* pData, uint16_t dataLength); + + void SetReferenceSample( + MP4SampleId refSampleId, uint32_t refSampleOffset, + uint16_t sampleLength); + + void SetEmbeddedSample( + MP4SampleId sampleId, MP4Track* pRefTrack, + MP4SampleId refSampleId, uint32_t refSampleOffset, + uint16_t sampleLength); + + uint16_t GetDataSize(); + + void GetData(uint8_t* pDest); + + void WriteEmbeddedData(MP4File* pFile, uint64_t startPos); + +protected: + uint8_t* m_pRefData; + + MP4Track* m_pRefTrack; + MP4SampleId m_refSampleId; + uint32_t m_refSampleOffset; +}; + +class MP4RtpSampleDescriptionData : public MP4RtpData { +public: + MP4RtpSampleDescriptionData(MP4RtpPacket* pPacket); + + void Set(uint32_t sampleDescrIndex, + uint32_t offset, uint16_t length); + + uint16_t GetDataSize(); + + void GetData(uint8_t* pDest); +}; + +class MP4RtpPacket : public MP4Container { +public: + MP4RtpPacket(MP4RtpHint* pHint); + + ~MP4RtpPacket(); + + void AddExtraProperties(); + + MP4RtpHint* GetHint() { + return m_pHint; + } + + void Set(uint8_t payloadNumber, uint32_t packetId, bool setMbit); + + int32_t GetTransmitOffset(); + + bool GetPBit(); + + bool GetXBit(); + + bool GetMBit(); + + uint8_t GetPayload(); + + uint16_t GetSequenceNumber(); + + void SetTransmitOffset(int32_t transmitOffset); + + bool IsBFrame(); + + void SetBFrame(bool isBFrame); + + void SetTimestampOffset(uint32_t timestampOffset); + + void AddData(MP4RtpData* pData); + + uint32_t GetDataSize(); + + void GetData(uint8_t* pDest); + + void Read(MP4File* pFile); + + void ReadExtra(MP4File* pFile); + + void Write(MP4File* pFile); + + void WriteEmbeddedData(MP4File* pFile, uint64_t startPos); + + void Dump(FILE* pFile, uint8_t indent, bool dumpImplicits); + +protected: + MP4RtpHint* m_pHint; + MP4RtpDataArray m_rtpData; +}; + +MP4ARRAY_DECL(MP4RtpPacket, MP4RtpPacket*) + +class MP4RtpHint : public MP4Container { +public: + MP4RtpHint(MP4RtpHintTrack* pTrack); + + ~MP4RtpHint(); + + MP4RtpHintTrack* GetTrack() { + return m_pTrack; + } + + uint16_t GetNumberOfPackets() { + return m_rtpPackets.Size(); + } + + bool IsBFrame() { + return m_isBFrame; + } + void SetBFrame(bool isBFrame) { + m_isBFrame = isBFrame; + } + + uint32_t GetTimestampOffset() { + return m_timestampOffset; + } + void SetTimestampOffset(uint32_t timestampOffset) { + m_timestampOffset = timestampOffset; + } + + MP4RtpPacket* AddPacket(); + + MP4RtpPacket* GetPacket(uint16_t index) { + return m_rtpPackets[index]; + } + + MP4RtpPacket* GetCurrentPacket() { + if (m_rtpPackets.Size() == 0) { + return NULL; + } + return m_rtpPackets[m_rtpPackets.Size() - 1]; + } + + void Read(MP4File* pFile); + + void Write(MP4File* pFile); + + void Dump(FILE* pFile, uint8_t indent, bool dumpImplicits); + +protected: + MP4RtpHintTrack* m_pTrack; + MP4RtpPacketArray m_rtpPackets; + + // values when adding packets to a hint (write mode) + bool m_isBFrame; + uint32_t m_timestampOffset; +}; + +class MP4RtpHintTrack : public MP4Track { +public: + MP4RtpHintTrack(MP4File* pFile, MP4Atom* pTrakAtom); + + ~MP4RtpHintTrack(); + + void InitRefTrack(); + + void InitPayload(); + + void InitRtpStart(); + + void InitStats(); + + MP4Track* GetRefTrack() { + InitRefTrack(); + return m_pRefTrack; + } + + void GetPayload( + char** ppPayloadName = NULL, + uint8_t* pPayloadNumber = NULL, + uint16_t* pMaxPayloadSize = NULL, + char **ppEncodingParams = NULL); + + void SetPayload( + const char* payloadName, + uint8_t payloadNumber, + uint16_t maxPayloadSize, + const char *encoding_parms, + bool add_rtpmap, + bool add_mpeg4_esid); + + void ReadHint( + MP4SampleId hintSampleId, + uint16_t* pNumPackets = NULL); + + uint16_t GetHintNumberOfPackets(); + + bool GetPacketBFrame(uint16_t packetIndex); + + uint16_t GetPacketTransmitOffset(uint16_t packetIndex); + + void ReadPacket( + uint16_t packetIndex, + uint8_t** ppBytes, + uint32_t* pNumBytes, + uint32_t ssrc, + bool includeHeader = true, + bool includePayload = true); + + MP4Timestamp GetRtpTimestampStart(); + + void SetRtpTimestampStart(MP4Timestamp start); + + void AddHint(bool isBFrame, uint32_t timestampOffset); + + void AddPacket(bool setMbit, int32_t transmitOffset = 0); + + void AddImmediateData(const uint8_t* pBytes, uint32_t numBytes); + + void AddSampleData(MP4SampleId sampleId, + uint32_t dataOffset, uint32_t dataLength); + + void AddESConfigurationPacket(); + + void WriteHint(MP4Duration duration, bool isSyncSample); + + void FinishWrite(); + +protected: + MP4Track* m_pRefTrack; + + MP4StringProperty* m_pRtpMapProperty; + MP4Integer32Property* m_pPayloadNumberProperty; + MP4Integer32Property* m_pMaxPacketSizeProperty; + MP4Integer32Property* m_pSnroProperty; + MP4Integer32Property* m_pTsroProperty; + uint32_t m_rtpSequenceStart; + uint32_t m_rtpTimestampStart; + + // reading + MP4RtpHint* m_pReadHint; + uint8_t* m_pReadHintSample; + uint32_t m_readHintSampleSize; + MP4Timestamp m_readHintTimestamp; + + // writing + MP4RtpHint* m_pWriteHint; + MP4SampleId m_writeHintId; + uint32_t m_writePacketId; + + // statistics + // in trak.udta.hinf + MP4Integer64Property* m_pTrpy; + MP4Integer64Property* m_pNump; + MP4Integer64Property* m_pTpyl; + MP4Integer32Property* m_pMaxr; + MP4Integer64Property* m_pDmed; + MP4Integer64Property* m_pDimm; + MP4Integer32Property* m_pPmax; + MP4Integer32Property* m_pDmax; + + // in trak.mdia.minf.hmhd + MP4Integer16Property* m_pMaxPdu; + MP4Integer16Property* m_pAvgPdu; + MP4Integer32Property* m_pMaxBitRate; + MP4Integer32Property* m_pAvgBitRate; + + MP4Timestamp m_thisSec; + uint32_t m_bytesThisSec; + uint32_t m_bytesThisHint; + uint32_t m_bytesThisPacket; +}; + +/////////////////////////////////////////////////////////////////////////////// + +} +} // namespace mp4v2::impl + +#endif // MP4V2_IMPL_RTPHINT_H diff --git a/src/src.h b/src/src.h new file mode 100644 index 0000000..39be5ce --- /dev/null +++ b/src/src.h @@ -0,0 +1,52 @@ +#ifndef MP4V2_IMPL_SRC_H +#define MP4V2_IMPL_SRC_H + +/////////////////////////////////////////////////////////////////////////////// + +#include "libplatform/platform.h" +#include <mp4v2/mp4v2.h> + +/////////////////////////////////////////////////////////////////////////////// + +namespace mp4v2 { namespace impl { + using namespace mp4v2::platform; + using io::File; + using io::FileSystem; +}} // namspace mp4v2::impl + +/////////////////////////////////////////////////////////////////////////////// + +#include "text.h" +#include "enum.h" +#include "exception.h" + +#include "bmff/typebmff.h" +#include "itmf/type.h" + +#include "util.h" +#include "mp4error.h" +#include "mp4util.h" +#include "mp4array.h" +#include "mp4track.h" +#include "mp4file.h" +#include "mp4property.h" +#include "mp4container.h" + +#include "mp4atom.h" +#include "atoms.h" + +#include "bmff/bmff.h" +#include "itmf/itmf.h" +#include "qtff/qtff.h" + +#include "mp4descriptor.h" +#include "descriptors.h" +#include "ocidescriptors.h" + +#include "qosqualifiers.h" +#include "odcommands.h" +#include "rtphint.h" + +/////////////////////////////////////////////////////////////////////////////// + +#endif // MP4V2_IMPL_SRC_H diff --git a/src/text.cpp b/src/text.cpp new file mode 100644 index 0000000..5790f96 --- /dev/null +++ b/src/text.cpp @@ -0,0 +1,41 @@ +#include "src/impl.h" + +namespace mp4v2 { namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +bool +LessIgnoreCase::operator()( const string& xstr, const string& ystr ) const +{ + const string::size_type xlen = xstr.length(); + const string::size_type ylen = ystr.length(); + + if( xlen < ylen ) { + for( string::size_type i = 0; i < xlen; i++ ) { + const char x = std::toupper( xstr[i] ); + const char y = std::toupper( ystr[i] ); + + if( x < y ) + return true; + else if ( x > y ) + return false; + } + return true; + } + else { + for( string::size_type i = 0; i < ylen; i++ ) { + const char x = std::toupper( xstr[i] ); + const char y = std::toupper( ystr[i] ); + + if( x < y ) + return true; + else if ( x > y ) + return false; + } + return false; + } +} + +/////////////////////////////////////////////////////////////////////////////// + +}} // namespace mp4v2::impl diff --git a/src/text.h b/src/text.h new file mode 100644 index 0000000..4afd336 --- /dev/null +++ b/src/text.h @@ -0,0 +1,17 @@ +#ifndef MP4V2_IMPL_TEXT_H +#define MP4V2_IMPL_TEXT_H + +namespace mp4v2 { namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +struct MP4V2_EXPORT LessIgnoreCase : less<string> +{ + bool operator()( const string&, const string& ) const; +}; + +/////////////////////////////////////////////////////////////////////////////// + +}} // namespace mp4v2::impl + +#endif // MP4V2_IMPL_TEXT_H diff --git a/src/util.h b/src/util.h new file mode 100644 index 0000000..aa3aba6 --- /dev/null +++ b/src/util.h @@ -0,0 +1,82 @@ +#ifndef MP4V2_IMPL_UTIL_H +#define MP4V2_IMPL_UTIL_H + +namespace mp4v2 { namespace impl { + +/////////////////////////////////////////////////////////////////////////////// + +inline int8_t max( int8_t a, int8_t b ) { + return ( a > b ) ? a : b; +} + +inline int16_t max( int16_t a, int16_t b ) { + return ( a > b ) ? a : b; +} + +inline int32_t max( int32_t a, int32_t b ) { + return ( a > b ) ? a : b; +} + +inline int64_t max( int64_t a, int64_t b ) { + return ( a > b ) ? a : b; +} + +/////////////////////////////////////////////////////////////////////////////// + +inline uint8_t max( uint8_t a, uint8_t b ) { + return ( a > b ) ? a : b; +} + +inline uint16_t max( uint16_t a, uint16_t b ) { + return ( a > b ) ? a : b; +} + +inline uint32_t max( uint32_t a, uint32_t b ) { + return ( a > b ) ? a : b; +} + +inline uint64_t max( uint64_t a, uint64_t b ) { + return ( a > b ) ? a : b; +} + +/////////////////////////////////////////////////////////////////////////////// + +inline int8_t min( int8_t a, int8_t b ) { + return ( a < b ) ? a : b; +} + +inline int16_t min( int16_t a, int16_t b ) { + return ( a < b ) ? a : b; +} + +inline int32_t min( int32_t a, int32_t b ) { + return ( a < b ) ? a : b; +} + +inline int64_t min( int64_t a, int64_t b ) { + return ( a < b ) ? a : b; +} + +/////////////////////////////////////////////////////////////////////////////// + +inline uint8_t min( uint8_t a, uint8_t b ) { + return ( a < b ) ? a : b; +} + +inline uint16_t min( uint16_t a, uint16_t b ) { + return ( a < b ) ? a : b; +} + +inline uint32_t min( uint32_t a, uint32_t b ) { + return ( a < b ) ? a : b; +} + +inline uint64_t min( uint64_t a, uint64_t b ) { + return ( a < b ) ? a : b; +} + +/////////////////////////////////////////////////////////////////////////////// + +}} // namespace mp4v2::impl + +#endif // MP4V2_IMPL_UTIL_H diff --git a/util/impl.h b/util/impl.h new file mode 100644 index 0000000..9daa297 --- /dev/null +++ b/util/impl.h @@ -0,0 +1,10 @@ +#ifndef MP4V2_UTIL_IMPL_H +#define MP4V2_UTIL_IMPL_H + +/////////////////////////////////////////////////////////////////////////////// + +#include "libutil/util.h" + +/////////////////////////////////////////////////////////////////////////////// + +#endif // MP4V2_UTIL_IMPL_H diff --git a/util/mp4art.cpp b/util/mp4art.cpp new file mode 100644 index 0000000..3dc29af --- /dev/null +++ b/util/mp4art.cpp @@ -0,0 +1,436 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is MP4v2. +// +// The Initial Developer of the Original Code is Kona Blend. +// Portions created by Kona Blend are Copyright (C) 2008. +// All Rights Reserved. +// +// Contributors: +// Kona Blend, kona8lend@@gmail.com +// +/////////////////////////////////////////////////////////////////////////////// + +#include "util/impl.h" + +namespace mp4v2 { namespace util { + using namespace itmf; + +/////////////////////////////////////////////////////////////////////////////// + +class ArtUtility : public Utility +{ +private: + enum ArtLongCode { + LC_ART_ANY = _LC_MAX, + LC_ART_INDEX, + LC_LIST, + LC_ADD, + LC_REMOVE, + LC_REPLACE, + LC_EXTRACT, + }; + +public: + ArtUtility( int, char** ); + +protected: + // delegates implementation + bool utility_option( int, bool& ); + bool utility_job( JobContext& ); + +private: + struct ArtType { + string name; + string ext; + vector<string> cwarns; // compatibility warnings + string cerror; // compatibility error + }; + + bool actionList ( JobContext& ); + bool actionAdd ( JobContext& ); + bool actionRemove ( JobContext& ); + bool actionReplace ( JobContext& ); + bool actionExtract ( JobContext& ); + + bool extractSingle( JobContext&, const CoverArtBox::Item&, uint32_t ); + +private: + Group _actionGroup; + Group _parmGroup; + + bool (ArtUtility::*_action)( JobContext& ); + + string _artImageFile; + uint32_t _artFilter; +}; + +/////////////////////////////////////////////////////////////////////////////// + +ArtUtility::ArtUtility( int argc, char** argv ) + : Utility ( "mp4art", argc, argv ) + , _actionGroup ( "ACTIONS" ) + , _parmGroup ( "ACTION PARAMETERS" ) + , _action ( NULL ) + , _artFilter ( numeric_limits<uint32_t>::max() ) +{ + // add standard options which make sense for this utility + _group.add( STD_OPTIMIZE ); + _group.add( STD_DRYRUN ); + _group.add( STD_KEEPGOING ); + _group.add( STD_OVERWRITE ); + _group.add( STD_FORCE ); + _group.add( STD_QUIET ); + _group.add( STD_DEBUG ); + _group.add( STD_VERBOSE ); + _group.add( STD_HELP ); + _group.add( STD_VERSION ); + _group.add( STD_VERSIONX ); + + _parmGroup.add( "art-any", false, LC_ART_ANY, "act on all covr-boxes (default)" ); + _parmGroup.add( "art-index", true, LC_ART_INDEX, "act on covr-box index IDX", "IDX" ); + _groups.push_back( &_parmGroup ); + + _actionGroup.add( "list", false, LC_LIST, "list all covr-boxes" ); + _actionGroup.add( "add", true, LC_ADD, "add covr-box from IMG file", "IMG" ); + _actionGroup.add( "replace", true, LC_REPLACE, "replace covr-box with IMG file", "IMG" ); + _actionGroup.add( "remove", false, LC_REMOVE, "remove covr-box" ); + _actionGroup.add( "extract", false, LC_EXTRACT, "extract covr-box" ); + _groups.push_back( &_actionGroup ); + + _usage = "[OPTION]... ACTION file..."; + _description = + // 79-cols, inclusive, max desired width + // |----------------------------------------------------------------------------| + "\nFor each mp4 (m4a) file specified, perform the specified ACTION. An action" + "\nmust be specified. Some options are not applicable for some actions."; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +ArtUtility::actionAdd( JobContext& job ) +{ + File in( _artImageFile, File::MODE_READ ); + if( in.open() ) + return herrf( "unable to open %s for read: %s\n", _artImageFile.c_str(), sys::getLastErrorStr() ); + + const uint32_t max = numeric_limits<uint32_t>::max(); + if( in.size > max ) + return herrf( "file too large: %s (exceeds %u bytes)\n", _artImageFile.c_str(), max ); + + CoverArtBox::Item item; + item.size = static_cast<uint32_t>( in.size ); + item.buffer = static_cast<uint8_t*>( malloc( item.size )); + item.autofree = true; + + File::Size nin; + if( in.read( item.buffer, item.size, nin )) + return herrf( "read failed: %s\n", _artImageFile.c_str() ); + + in.close(); + + verbose1f( "adding %s -> %s\n", _artImageFile.c_str(), job.file.c_str() ); + if( dryrunAbort() ) + return SUCCESS; + + job.fileHandle = MP4Modify( job.file.c_str(), _debugVerbosity ); + if( job.fileHandle == MP4_INVALID_FILE_HANDLE ) + return herrf( "unable to open for write: %s\n", job.file.c_str() ); + + if( CoverArtBox::add( job.fileHandle, item )) + return herrf( "unable to add covr-box\n" ); + + return SUCCESS; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +ArtUtility::actionExtract( JobContext& job ) +{ + job.fileHandle = MP4Read( job.file.c_str(), _debugVerbosity ); + if( job.fileHandle == MP4_INVALID_FILE_HANDLE ) + return herrf( "unable to open for read: %s\n", job.file.c_str() ); + + // single-mode + if( _artFilter != numeric_limits<uint32_t>::max() ) { + CoverArtBox::Item item; + if( CoverArtBox::get( job.fileHandle, item, _artFilter )) + return herrf( "unable to retrieve covr-box (index=%d): %s\n", _artFilter, job.file.c_str() ); + + return extractSingle( job, item, _artFilter ); + } + + // wildcard-mode + CoverArtBox::ItemList items; + if( CoverArtBox::list( job.fileHandle, items )) + return herrf( "unable to fetch list of covr-box: %s\n", job.file.c_str() ); + + bool onesuccess = false; + const CoverArtBox::ItemList::size_type max = items.size(); + for( CoverArtBox::ItemList::size_type i = 0; i < max; i++ ) { + bool rv = extractSingle( job, items[i], i ); + if( !rv ) + onesuccess = true; + if( !_keepgoing && rv ) + return FAILURE; + } + + return _keepgoing ? onesuccess : SUCCESS; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +ArtUtility::actionList( JobContext& job ) +{ + ostringstream report; + + const int widx = 3; + const int wsize = 8; + const int wtype = 9; + const string sep = " "; + + if( _jobCount == 0 ) { + report << setw(widx) << right << "IDX" << left + << sep << setw(wsize) << right << "BYTES" << left + << sep << setw(8) << "CRC32" + << sep << setw(wtype) << "TYPE" + << sep << setw(0) << "FILE" + << '\n'; + + report << setfill('-') << setw(70) << "" << setfill(' ') << '\n'; + } + + job.fileHandle = MP4Read( job.file.c_str(), _debugVerbosity ); + if( job.fileHandle == MP4_INVALID_FILE_HANDLE ) + return herrf( "unable to open for read: %s\n", job.file.c_str() ); + + CoverArtBox::ItemList items; + if( CoverArtBox::list( job.fileHandle, items )) + return herrf( "unable to get list of covr-box: %s\n", job.file.c_str() ); + + int line = 0; + const CoverArtBox::ItemList::size_type max = items.size(); + for( CoverArtBox::ItemList::size_type i = 0; i < max; i++ ) { + if( _artFilter != numeric_limits<uint32_t>::max() && _artFilter != i ) + continue; + + CoverArtBox::Item& item = items[i]; + const uint32_t crc = crc32( item.buffer, item.size ); + + report << setw(widx) << right << i + << sep << setw(wsize) << item.size + << sep << setw(8) << setfill('0') << hex << crc << setfill(' ') << dec + << sep << setw(wtype) << left << enumBasicType.toString( item.type ); + + if( line++ == 0 ) + report << sep << setw(0) << job.file; + + report << '\n'; + } + + verbose1f( "%s", report.str().c_str() ); + return SUCCESS; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +ArtUtility::actionRemove( JobContext& job ) +{ + job.fileHandle = MP4Modify( job.file.c_str(), _debugVerbosity ); + if( job.fileHandle == MP4_INVALID_FILE_HANDLE ) + return herrf( "unable to open for write: %s\n", job.file.c_str() ); + + if( _artFilter == numeric_limits<uint32_t>::max() ) + verbose1f( "removing covr-box (all) from %s\n", job.file.c_str() ); + else + verbose1f( "removing covr-box (index=%d) from %s\n", _artFilter, job.file.c_str() ); + + if( dryrunAbort() ) + return SUCCESS; + + if( CoverArtBox::remove( job.fileHandle, _artFilter )) + return herrf( "remove failed\n" ); + + return SUCCESS; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +ArtUtility::actionReplace( JobContext& job ) +{ + File in( _artImageFile, File::MODE_READ ); + if( in.open() ) + return herrf( "unable to open %s for read: %s\n", _artImageFile.c_str(), sys::getLastErrorStr() ); + + const uint32_t max = numeric_limits<uint32_t>::max(); + if( in.size > max ) + return herrf( "file too large: %s (exceeds %u bytes)\n", _artImageFile.c_str(), max ); + + CoverArtBox::Item item; + item.size = static_cast<uint32_t>( in.size ); + item.buffer = static_cast<uint8_t*>( malloc( item.size )); + item.autofree = true; + + File::Size nin; + if( in.read( item.buffer, item.size, nin )) + return herrf( "read failed: %s\n", _artImageFile.c_str() ); + + in.close(); + + if( _artFilter == numeric_limits<uint32_t>::max() ) + verbose1f( "replacing %s -> %s (all)\n", _artImageFile.c_str(), job.file.c_str() ); + else + verbose1f( "replacing %s -> %s (index=%d)\n", _artImageFile.c_str(), job.file.c_str(), _artFilter ); + + if( dryrunAbort() ) + return SUCCESS; + + job.fileHandle = MP4Modify( job.file.c_str(), _debugVerbosity ); + if( job.fileHandle == MP4_INVALID_FILE_HANDLE ) + return herrf( "unable to open for write: %s\n", job.file.c_str() ); + + if( CoverArtBox::set( job.fileHandle, item, _artFilter )) + return herrf( "unable to add covr-box: %s\n", job.file.c_str() ); + + return SUCCESS; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +ArtUtility::extractSingle( JobContext& job, const CoverArtBox::Item& item, uint32_t index ) +{ + // compute out filename + string out_name = job.file; + FileSystem::pathnameStripExtension( out_name ); + + ostringstream oss; + oss << out_name << ".art[" << index << ']'; + + // if implicit we try to determine type by inspecting data + BasicType bt = item.type; + if( bt == BT_IMPLICIT ) + bt = computeBasicType( item.buffer, item.size ); + + // add file extension appropriate for known covr-box types + switch( bt ) { + case BT_GIF: oss << ".gif"; break; + case BT_JPEG: oss << ".jpg"; break; + case BT_PNG: oss << ".png"; break; + case BT_BMP: oss << ".bmp"; break; + + default: + oss << ".dat"; + break; + } + + out_name = oss.str(); + verbose1f( "extracting %s (index=%d) -> %s\n", job.file.c_str(), index, out_name.c_str() ); + if( dryrunAbort() ) + return SUCCESS; + + File out( out_name, File::MODE_CREATE ); + if( openFileForWriting( out )) + return FAILURE; + + File::Size nout; + if( out.write( item.buffer, item.size, nout )) + return herrf( "write failed: %s\n", out_name.c_str() ); + + out.close(); + return SUCCESS; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +ArtUtility::utility_job( JobContext& job ) +{ + if( !_action ) + return herrf( "no action specified\n" ); + + return (this->*_action)( job ); +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +ArtUtility::utility_option( int code, bool& handled ) +{ + handled = true; + + switch( code ) { + case LC_ART_ANY: + _artFilter = numeric_limits<uint32_t>::max(); + break; + + case LC_ART_INDEX: + { + istringstream iss( prog::optarg ); + iss >> _artFilter; + if( iss.rdstate() != ios::eofbit ) + return herrf( "invalid cover-art index: %s\n", prog::optarg ); + break; + } + + case LC_LIST: + _action = &ArtUtility::actionList; + break; + + case LC_ADD: + _action = &ArtUtility::actionAdd; + _artImageFile = prog::optarg; + if( _artImageFile.empty() ) + return herrf( "invalid image file: empty-string\n" ); + break; + + case LC_REMOVE: + _action = &ArtUtility::actionRemove; + break; + + case LC_REPLACE: + _action = &ArtUtility::actionReplace; + _artImageFile = prog::optarg; + if( _artImageFile.empty() ) + return herrf( "invalid image file: empty-string\n" ); + break; + + case LC_EXTRACT: + _action = &ArtUtility::actionExtract; + break; + + default: + handled = false; + break; + } + + return SUCCESS; +} + +/////////////////////////////////////////////////////////////////////////////// + +}} // namespace mp4v2::util + +/////////////////////////////////////////////////////////////////////////////// + +extern "C" +int main( int argc, char** argv ) +{ + mp4v2::util::ArtUtility util( argc, argv ); + return util.process(); +} diff --git a/util/mp4chaps.cpp b/util/mp4chaps.cpp new file mode 100644 index 0000000..9008940 --- /dev/null +++ b/util/mp4chaps.cpp @@ -0,0 +1,1159 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is MP4v2. +// +// The Initial Developer of the Original Code is Ullrich Pollaehne. +// Portions created by Kona Blend are Copyright (C) 2008. +// All Rights Reserved. +// +// Contributors: +// Kona Blend, kona8lend@@gmail.com +// Ullrich Pollaehne, u.pollaehne@@gmail.com +// +/////////////////////////////////////////////////////////////////////////////// +#include "util/impl.h" + +namespace mp4v2 { namespace util { + +/////////////////////////////////////////////////////////////////////////////// +/// +/// Chapter utility program class. +/// +/// This class provides an implementation for a QuickTime/Nero chapter utility which +/// allows to add, delete, convert export or import QuickTime and Nero chapters +/// in MP4 container files. +/// +/// +/// @see Utility +/// +/////////////////////////////////////////////////////////////////////////////// +class ChapterUtility : public Utility +{ +private: + static const double CHAPTERTIMESCALE; //!< the timescale used for chapter tracks (1000) + + enum FileLongCode { + LC_CHPT_ANY = _LC_MAX, + LC_CHPT_QT, + LC_CHPT_NERO, + LC_CHPT_COMMON, + LC_CHP_LIST, + LC_CHP_CONVERT, + LC_CHP_EVERY, + LC_CHP_EXPORT, + LC_CHP_IMPORT, + LC_CHP_REMOVE + }; + + enum ChapterFormat { + CHPT_FMT_NATIVE, + CHPT_FMT_COMMON + }; + + enum FormatState { + FMT_STATE_INITIAL, + FMT_STATE_TIME_LINE, + FMT_STATE_TITLE_LINE, + FMT_STATE_FINISH + }; + +public: + ChapterUtility( int, char** ); + +protected: + // delegates implementation + bool utility_option( int, bool& ); + bool utility_job( JobContext& ); + +private: + bool actionList ( JobContext& ); + bool actionConvert ( JobContext& ); + bool actionEvery ( JobContext& ); + bool actionExport ( JobContext& ); + bool actionImport ( JobContext& ); + bool actionRemove ( JobContext& ); + +private: + Group _actionGroup; + Group _parmGroup; + + bool (ChapterUtility::*_action)( JobContext& ); + void fixQtScale(MP4FileHandle ); + MP4TrackId getReferencingTrack( MP4FileHandle, bool& ); + string getChapterTypeName( MP4ChapterType ) const; + bool parseChapterFile( const string, vector<MP4Chapter_t>&, Timecode::Format& ); + bool readChapterFile( const string, char**, File::Size& ); + MP4Duration convertFrameToMillis( MP4Duration, uint32_t ); + + MP4ChapterType _ChapterType; + ChapterFormat _ChapterFormat; + uint32_t _ChaptersEvery; + string _ChapterFile; +}; + +/////////////////////////////////////////////////////////////////////////////// + +const double ChapterUtility::CHAPTERTIMESCALE = 1000.0; + +/////////////////////////////////////////////////////////////////////////////// + +ChapterUtility::ChapterUtility( int argc, char** argv ) + : Utility ( "mp4chaps", argc, argv ) + , _actionGroup ( "ACTIONS" ) + , _parmGroup ( "ACTION PARAMETERS" ) + , _action ( NULL ) + , _ChapterType ( MP4ChapterTypeAny ) + , _ChapterFormat ( CHPT_FMT_NATIVE ) + , _ChaptersEvery ( 0 ) +{ + // add standard options which make sense for this utility + _group.add( STD_OPTIMIZE ); + _group.add( STD_DRYRUN ); + _group.add( STD_KEEPGOING ); + _group.add( STD_OVERWRITE ); + _group.add( STD_FORCE ); + _group.add( STD_QUIET ); + _group.add( STD_DEBUG ); + _group.add( STD_VERBOSE ); + _group.add( STD_HELP ); + _group.add( STD_VERSION ); + _group.add( STD_VERSIONX ); + + _parmGroup.add( 'A', false, "chapter-any", false, LC_CHPT_ANY, "act on any chapter type (default)" ); + _parmGroup.add( 'Q', false, "chapter-qt", false, LC_CHPT_QT, "act on QuickTime chapters" ); + _parmGroup.add( 'N', false, "chapter-nero", false, LC_CHPT_NERO, "act on Nero chapters" ); + _parmGroup.add( 'C', false, "format-common", false, LC_CHPT_COMMON, "export chapters in common format" ); + _groups.push_back( &_parmGroup ); + + _actionGroup.add( 'l', false, "list", false, LC_CHP_LIST, "list available chapters" ); + _actionGroup.add( 'c', false, "convert", false, LC_CHP_CONVERT, "convert available chapters" ); + _actionGroup.add( 'e', true, "every", true, LC_CHP_EVERY, "create chapters every NUM seconds", "NUM" ); + _actionGroup.add( 'x', false, "export", false, LC_CHP_EXPORT, "export chapters to mp4file.chapters.txt", "TXT" ); + _actionGroup.add( 'i', false, "import", false, LC_CHP_IMPORT, "import chapters from mp4file.chapters.txt", "TXT" ); + _actionGroup.add( 'r', false, "remove", false, LC_CHP_REMOVE, "remove all chapters" ); + _groups.push_back( &_actionGroup ); + + _usage = "[OPTION]... ACTION [ACTION PARAMETERS] mp4file..."; + _description = + // 79-cols, inclusive, max desired width + // |----------------------------------------------------------------------------| + "\nFor each mp4 file specified, perform the specified ACTION. An action must be" + "\nspecified. Some options are not applicable to some actions."; +} + +/////////////////////////////////////////////////////////////////////////////// + +/** Action for listing chapters from <b>job.file</b> + * + * + * @param job the job to process + * @return mp4v2::util::SUCCESS if successful, mp4v2::util::FAILURE otherwise + */ +bool +ChapterUtility::actionList( JobContext& job ) +{ + job.fileHandle = MP4Read( job.file.c_str(), _debugVerbosity ); + if( job.fileHandle == MP4_INVALID_FILE_HANDLE ) + { + return herrf( "unable to open for read: %s\n", job.file.c_str() ); + } + + MP4Chapter_t * chapters = 0; + uint32_t chapterCount = 0; + + // get the list of chapters + MP4ChapterType chtp = MP4GetChapters(job.fileHandle, &chapters, &chapterCount, _ChapterType); + if (0 == chapterCount) + { + verbose1f( "File \"%s\" does not contain chapters of type %s\n", job.file.c_str(), + getChapterTypeName( _ChapterType ).c_str() ); + return SUCCESS; + } + + // start output (more or less like mp4box does) + ostringstream report; + report << getChapterTypeName( chtp ) << ' ' << "Chapters of " << '"' << job.file << '"' << endl; + + Timecode duration(0, CHAPTERTIMESCALE); + duration.setFormat( Timecode::DECIMAL ); + for (uint32_t i = 0; i < chapterCount; ++i) + { + // print the infos + report << '\t' << "Chapter #" << setw( 3 ) << setfill( '0' ) << i+1 + << " - " << duration.svalue << " - " << '"' << chapters[i].title << '"' << endl; + + // add the duration of this chapter to the sum (is the start time of the next chapter) + duration += Timecode(chapters[i].duration, CHAPTERTIMESCALE); + } + + verbose1f( "%s", report.str().c_str() ); + + // free up the memory + MP4Free(chapters); + + return SUCCESS; +} + +/////////////////////////////////////////////////////////////////////////////// + +/** Action for converting chapters in <b>job.file</b> + * + * + * @param job the job to process + * @return mp4v2::util::SUCCESS if successful, mp4v2::util::FAILURE otherwise + */ +bool +ChapterUtility::actionConvert( JobContext& job ) +{ + MP4ChapterType sourceType; + + switch( _ChapterType ) + { + case MP4ChapterTypeNero: + sourceType = MP4ChapterTypeQt; + break; + case MP4ChapterTypeQt: + sourceType = MP4ChapterTypeNero; + break; + default: + return herrf( "invalid chapter type \"%s\" define the chapter type to convert to\n", + getChapterTypeName( _ChapterType ).c_str() ); + } + + ostringstream oss; + oss << "converting chapters in file " << '"' << job.file << '"' + << " from " << getChapterTypeName( sourceType ) << " to " << getChapterTypeName( _ChapterType ) << endl; + + verbose1f( "%s", oss.str().c_str() ); + if( dryrunAbort() ) + { + return SUCCESS; + } + + job.fileHandle = MP4Modify( job.file.c_str(), _debugVerbosity ); + if( job.fileHandle == MP4_INVALID_FILE_HANDLE ) + { + return herrf( "unable to open for write: %s\n", job.file.c_str() ); + } + + MP4ChapterType chtp = MP4ConvertChapters( job.fileHandle, _ChapterType ); + if( MP4ChapterTypeNone == chtp ) + { + return herrf( "File %s does not contain chapters of type %s\n", job.file.c_str(), + getChapterTypeName( sourceType ).c_str() ); + } + + fixQtScale( job.fileHandle ); + job.optimizeApplicable = true; + + return SUCCESS; +} + +/////////////////////////////////////////////////////////////////////////////// + +/** Action for setting chapters every n second in <b>job.file</b> + * + * + * @param job the job to process + * @return mp4v2::util::SUCCESS if successful, mp4v2::util::FAILURE otherwise + */ +bool +ChapterUtility::actionEvery( JobContext& job ) +{ + ostringstream oss; + oss << "Setting " << getChapterTypeName( _ChapterType ) << " chapters every " + << _ChaptersEvery << " seconds in file " << '"' << job.file << '"' << endl; + + verbose1f( "%s", oss.str().c_str() ); + if( dryrunAbort() ) + { + return SUCCESS; + } + + job.fileHandle = MP4Modify( job.file.c_str(), _debugVerbosity ); + if( job.fileHandle == MP4_INVALID_FILE_HANDLE ) + { + return herrf( "unable to open for write: %s\n", job.file.c_str() ); + } + + bool isVideoTrack = false; + MP4TrackId refTrackId = getReferencingTrack( job.fileHandle, isVideoTrack ); + if( !MP4_IS_VALID_TRACK_ID(refTrackId) ) + { + return herrf( "unable to find a video or audio track in file %s\n", job.file.c_str() ); + } + + Timecode refTrackDuration( MP4GetTrackDuration( job.fileHandle, refTrackId ), MP4GetTrackTimeScale( job.fileHandle, refTrackId ) ); + refTrackDuration.setScale( CHAPTERTIMESCALE ); + + Timecode chapterDuration( _ChaptersEvery * 1000, CHAPTERTIMESCALE ); + chapterDuration.setFormat( Timecode::DECIMAL ); + Timecode durationSum( 0, CHAPTERTIMESCALE ); + durationSum.setFormat( Timecode::DECIMAL ); + vector<MP4Chapter_t> chapters; + + while( durationSum + chapterDuration < refTrackDuration ) + { + MP4Chapter_t chap; + chap.duration = chapterDuration.duration; + sprintf(chap.title, "Chapter %lu", chapters.size()+1); + + chapters.push_back( chap ); + + durationSum += chapterDuration; + } + + if( 0 < chapters.size() ) + { + chapters.back().duration = (refTrackDuration - (durationSum - chapterDuration)).duration; + + MP4SetChapters(job.fileHandle, &chapters[0], chapters.size(), _ChapterType); + } + + fixQtScale( job.fileHandle ); + job.optimizeApplicable = true; + + return SUCCESS; +} + +/////////////////////////////////////////////////////////////////////////////// + +/** Action for exporting chapters from the <b>job.file</b> + * + * + * @param job the job to process + * @return mp4v2::util::SUCCESS if successful, mp4v2::util::FAILURE otherwise + */ +bool +ChapterUtility::actionExport( JobContext& job ) +{ + job.fileHandle = MP4Read( job.file.c_str(), _debugVerbosity ); + if( job.fileHandle == MP4_INVALID_FILE_HANDLE ) + { + return herrf( "unable to open for read: %s\n", job.file.c_str() ); + } + + // get the list of chapters + MP4Chapter_t* chapters = 0; + uint32_t chapterCount = 0; + MP4ChapterType chtp = MP4GetChapters( job.fileHandle, &chapters, &chapterCount, _ChapterType ); + if (0 == chapterCount) + { + return herrf( "File \"%s\" does not contain chapters of type %s\n", job.file.c_str(), + getChapterTypeName( chtp ).c_str() ); + } + + // build the filename + string outName = job.file; + if( _ChapterFile.empty() ) + { + FileSystem::pathnameStripExtension( outName ); + outName.append( ".chapters.txt" ); + } + else + { + outName = _ChapterFile; + } + + ostringstream oss; + oss << "Exporting " << chapterCount << " " << getChapterTypeName( chtp ); + oss << " chapters from file " << '"' << job.file << '"' << " into chapter file " << '"' << outName << '"' << endl; + + verbose1f( "%s", oss.str().c_str() ); + if( dryrunAbort() ) + { + // free up the memory + MP4Free(chapters); + + return SUCCESS; + } + + // open the file + File out( outName, File::MODE_CREATE ); + if( openFileForWriting( out ) ) + { + // free up the memory + MP4Free(chapters); + + return FAILURE; + } + + // write the chapters +#if defined( _WIN32 ) + static const char* LINEND = "\r\n"; +#else + static const char* LINEND = "\n"; +#endif + File::Size nout; + bool failure = SUCCESS; + int width = 2; + if( CHPT_FMT_COMMON == _ChapterFormat && (chapterCount / 100) >= 1 ) + { + width = 3; + } + Timecode duration( 0, CHAPTERTIMESCALE ); + duration.setFormat( Timecode::DECIMAL ); + for( uint32_t i = 0; i < chapterCount; ++i ) + { + // print the infos + ostringstream oss; + switch( _ChapterFormat ) + { + case CHPT_FMT_COMMON: + oss << "CHAPTER" << setw( width ) << setfill( '0' ) << i+1 << '=' << duration.svalue << LINEND + << "CHAPTER" << setw( width ) << setfill( '0' ) << i+1 << "NAME=" << chapters[i].title << LINEND; + break; + case CHPT_FMT_NATIVE: + default: + oss << duration.svalue << ' ' << chapters[i].title << LINEND; + } + + string str = oss.str(); + if( out.write( str.c_str(), str.size(), nout ) ) + { + failure = herrf( "write to %s failed: %s\n", outName.c_str(), sys::getLastErrorStr() ); + break; + } + + // add the duration of this chapter to the sum (the start time of the next chapter) + duration += Timecode(chapters[i].duration, CHAPTERTIMESCALE); + } + out.close(); + if( failure ) + { + verbose1f( "removing file %s\n", outName.c_str() ); + ::remove( outName.c_str() ); + } + + // free up the memory + MP4Free(chapters); + + return SUCCESS; +} + +/////////////////////////////////////////////////////////////////////////////// + +/** Action for importing chapters into the <b>job.file</b> + * + * + * @param job the job to process + * @return mp4v2::util::SUCCESS if successful, mp4v2::util::FAILURE otherwise + */ +bool +ChapterUtility::actionImport( JobContext& job ) +{ + vector<MP4Chapter_t> chapters; + Timecode::Format format; + + // create the chapter file name + string inName = job.file; + if( _ChapterFile.empty() ) + { + FileSystem::pathnameStripExtension( inName ); + inName.append( ".chapters.txt" ); + } + else + { + inName = _ChapterFile; + } + + if( parseChapterFile( inName, chapters, format ) ) + { + return FAILURE; + } + + ostringstream oss; + oss << "Importing " << chapters.size() << " " << getChapterTypeName( _ChapterType ); + oss << " chapters from file " << inName << " into file " << '"' << job.file << '"' << endl; + + verbose1f( "%s", oss.str().c_str() ); + if( dryrunAbort() ) + { + return SUCCESS; + } + + if( 0 == chapters.size() ) + { + return herrf( "No chapters found in file %s\n", inName.c_str() ); + } + + job.fileHandle = MP4Modify( job.file.c_str(), _debugVerbosity ); + if( job.fileHandle == MP4_INVALID_FILE_HANDLE ) + { + return herrf( "unable to open for write: %s\n", job.file.c_str() ); + } + + bool isVideoTrack = false; + MP4TrackId refTrackId = getReferencingTrack( job.fileHandle, isVideoTrack ); + if( !MP4_IS_VALID_TRACK_ID(refTrackId) ) + { + return herrf( "unable to find a video or audio track in file %s\n", job.file.c_str() ); + } + if( Timecode::FRAME == format && !isVideoTrack ) + { + // we need a video track for this + return herrf( "unable to find a video track in file %s but chapter file contains frame timestamps\n", job.file.c_str() ); + } + + // get duration and recalculate scale + Timecode refTrackDuration( MP4GetTrackDuration( job.fileHandle, refTrackId ), + MP4GetTrackTimeScale( job.fileHandle, refTrackId ) ); + refTrackDuration.setScale( CHAPTERTIMESCALE ); + + // check for chapters starting after duration of reftrack + for( vector<MP4Chapter_t>::iterator it = chapters.begin(); it != chapters.end(); ) + { + Timecode curr( (*it).duration, CHAPTERTIMESCALE ); + if( refTrackDuration <= curr ) + { + hwarnf( "Chapter '%s' start: %s, playlength of file: %s, chapter cannot be set\n", + (*it).title, curr.svalue.c_str(), refTrackDuration.svalue.c_str() ); + it = chapters.erase( it ); + } + else + { + ++it; + } + } + if( 0 == chapters.size() ) + { + return SUCCESS; + } + + // convert start time into duration + uint64_t framerate = CHAPTERTIMESCALE; + if( Timecode::FRAME == format ) + { + // get the framerate + MP4SampleId sampleCount = MP4GetTrackNumberOfSamples( job.fileHandle, refTrackId ); + Timecode tmpcd( refTrackDuration.svalue, CHAPTERTIMESCALE ); + framerate = std::ceil( ((double)sampleCount / (double)tmpcd.duration) * CHAPTERTIMESCALE ); + } + + for( vector<MP4Chapter_t>::iterator it = chapters.begin(); it != chapters.end(); ++it ) + { + MP4Duration currDur = (*it).duration; + MP4Duration nextDur = chapters.end() == it+1 ? refTrackDuration.duration : (*(it+1)).duration; + + if( Timecode::FRAME == format ) + { + // convert from frame nr to milliseconds + currDur = convertFrameToMillis( (*it).duration, framerate ); + + if( chapters.end() != it+1 ) + { + nextDur = convertFrameToMillis( (*(it+1)).duration, framerate ); + } + } + + (*it).duration = nextDur - currDur; + } + + // now set the chapters + MP4SetChapters( job.fileHandle, &chapters[0], chapters.size(), _ChapterType ); + + fixQtScale( job.fileHandle ); + job.optimizeApplicable = true; + + return SUCCESS; +} + +/////////////////////////////////////////////////////////////////////////////// + +/** Action for removing chapters from the <b>job.file</b> + * + * + * @param job the job to process + * @return mp4v2::util::SUCCESS if successful, mp4v2::util::FAILURE otherwise + */ +bool +ChapterUtility::actionRemove( JobContext& job ) +{ + ostringstream oss; + oss << "Deleting " << getChapterTypeName( _ChapterType ) << " chapters from file " << '"' << job.file << '"' << endl; + + verbose1f( "%s", oss.str().c_str() ); + if( dryrunAbort() ) + { + return SUCCESS; + } + + job.fileHandle = MP4Modify( job.file.c_str(), _debugVerbosity ); + if( job.fileHandle == MP4_INVALID_FILE_HANDLE ) + { + return herrf( "unable to open for write: %s\n", job.file.c_str() ); + } + + MP4ChapterType chtp = MP4DeleteChapters( job.fileHandle, _ChapterType ); + if( MP4ChapterTypeNone == chtp ) + { + return FAILURE; + } + + fixQtScale( job.fileHandle ); + job.optimizeApplicable = true; + + return SUCCESS; +} + +/////////////////////////////////////////////////////////////////////////////// + +/** process positional argument + * + * @see Utility::utility_job( JobContext& ) + */ +bool +ChapterUtility::utility_job( JobContext& job ) +{ + if( !_action ) + { + return herrf( "no action specified\n" ); + } + + return (this->*_action)( job ); +} + +/////////////////////////////////////////////////////////////////////////////// + +/** process command-line option + * + * @see Utility::utility_option( int, bool& ) + */ +bool +ChapterUtility::utility_option( int code, bool& handled ) +{ + handled = true; + + switch( code ) { + case 'A': + case LC_CHPT_ANY: + _ChapterType = MP4ChapterTypeAny; + break; + + case 'Q': + case LC_CHPT_QT: + _ChapterType = MP4ChapterTypeQt; + break; + + case 'N': + case LC_CHPT_NERO: + _ChapterType = MP4ChapterTypeNero; + break; + + case 'C': + case LC_CHPT_COMMON: + _ChapterFormat = CHPT_FMT_COMMON; + break; + + case 'l': + case LC_CHP_LIST: + _action = &ChapterUtility::actionList; + break; + + case 'e': + case LC_CHP_EVERY: + { + istringstream iss( prog::optarg ); + iss >> _ChaptersEvery; + if( iss.rdstate() != ios::eofbit ) + { + return herrf( "invalid number of seconds: %s\n", prog::optarg ); + } + _action = &ChapterUtility::actionEvery; + break; + } + + case 'x': + _action = &ChapterUtility::actionExport; + break; + + case LC_CHP_EXPORT: + _action = &ChapterUtility::actionExport; + /* currently not supported since the chapters of n input files would be written to one chapter file + _ChapterFile = prog::optarg; + if( _ChapterFile.empty() ) + { + return herrf( "invalid TXT file: empty-string\n" ); + } + */ + break; + + case 'i': + _action = &ChapterUtility::actionImport; + break; + + case LC_CHP_IMPORT: + _action = &ChapterUtility::actionImport; + /* currently not supported since the chapters of n input files would be read from one chapter file + _ChapterFile = prog::optarg; + if( _ChapterFile.empty() ) + { + return herrf( "invalid TXT file: empty-string\n" ); + } + */ + break; + + case 'c': + case LC_CHP_CONVERT: + _action = &ChapterUtility::actionConvert; + break; + + case 'r': + case LC_CHP_REMOVE: + _action = &ChapterUtility::actionRemove; + break; + + default: + handled = false; + break; + } + + return SUCCESS; +} + +/////////////////////////////////////////////////////////////////////////////// + +/** Fix a QuickTime/iPod issue with long audio files. + * + * This function checks if the <b>file</b> is a long audio file (more than + * about 6 1/2 hours) and modifies the timescale if necessary to allow + * playback of the file in QuickTime player and on some iPod models. + * + * @param file the opened MP4 file + */ +void +ChapterUtility::fixQtScale(MP4FileHandle file) +{ + // get around a QuickTime/iPod issue with storing the number of samples in a signed 32Bit value + if( INT_MAX < (MP4GetDuration(file) * MP4GetTimeScale(file)) ) + { + bool isVideoTrack = false; + if( MP4_IS_VALID_TRACK_ID(getReferencingTrack( file, isVideoTrack )) & isVideoTrack ) + { + // if it is a video, everything is different + return; + } + + // timescale too high, lower it + MP4ChangeMovieTimeScale(file, 1000); + } +} + +/////////////////////////////////////////////////////////////////////////////// + +/** Finds a suitable track that can reference a chapter track. + * + * This function returns the first video or audio track that is found + * in the <b>file</b>. + * This track ca be used to reference the QuickTime chapter track. + * + * @param file the opened MP4 file + * @param isVideoTrack receives true if the found track is video, false otherwise + * @return the <b>MP4TrackId</b> of the found track + */ +MP4TrackId +ChapterUtility::getReferencingTrack( MP4FileHandle file, bool& isVideoTrack ) +{ + isVideoTrack = false; + + uint32_t trackCount = MP4GetNumberOfTracks( file ); + if( 0 == trackCount ) + { + return MP4_INVALID_TRACK_ID; + } + + MP4TrackId refTrackId = MP4_INVALID_TRACK_ID; + for( uint32_t i = 0; i < trackCount; ++i ) + { + MP4TrackId id = MP4FindTrackId( file, i ); + const char* type = MP4GetTrackType( file, id ); + if( MP4_IS_VIDEO_TRACK_TYPE( type ) ) + { + refTrackId = id; + isVideoTrack = true; + break; + } + else if( MP4_IS_AUDIO_TRACK_TYPE( type ) ) + { + refTrackId = id; + break; + } + } + + return refTrackId; +} + +/////////////////////////////////////////////////////////////////////////////// + +/** Return a human readable representation of a <b>MP4ChapterType</b>. + * + * @param chapterType the chapter type + * @return a string representing the chapter type + */ +string +ChapterUtility::getChapterTypeName( MP4ChapterType chapterType) const +{ + switch( chapterType ) + { + case MP4ChapterTypeQt: + return string( "QuickTime" ); + break; + + case MP4ChapterTypeNero: + return string( "Nero" ); + break; + + case MP4ChapterTypeAny: + return string( "QuickTime and Nero" ); + break; + + default: + return string( "Unknown" ); + } +} + +/////////////////////////////////////////////////////////////////////////////// + +/** Read a file into a buffer. + * + * This function reads the file named by <b>filename</b> into a buffer allocated + * by malloc and returns the pointer to this buffer in <b>buffer</b> and the size + * of this buffer in <b>fileSize</b>. + * + * @param filename the name of the file. + * @param buffer receives a pointer to the created buffer + * @param fileSize reference to a <b>io::StdioFile::Size</b> that receives the size of the file + * @return true if there was an error, false otherwise + */ +bool +ChapterUtility::readChapterFile( const string filename, char** buffer, File::Size& fileSize ) +{ + // open the file + File in( filename, File::MODE_READ ); + File::Size nin; + if( in.open() ) { + return herrf( "opening chapter file '%s' failed: %s\n", filename.c_str(), sys::getLastErrorStr() ); + } + + // get the file size + fileSize = in.size; + if( 0 >= fileSize ) + { + in.close(); + return herrf( "getting size of chapter file '%s' failed: %s\n", filename.c_str(), sys::getLastErrorStr() ); + } + + // allocate a buffer for the file and read the content + char* inBuf = static_cast<char*>( malloc( fileSize+1 ) ); + if( in.read( inBuf, fileSize, nin ) ) + { + in.close(); + return herrf( "reading chapter file '%s' failed: %s\n", filename.c_str(), sys::getLastErrorStr() ); + } + in.close(); + inBuf[fileSize] = 0; + + *buffer = inBuf; + + return SUCCESS; +} + +/////////////////////////////////////////////////////////////////////////////// + +/** Read and parse a chapter file. + * + * This function reads and parses a chapter file and returns a vector of + * <b>MP4Chapter_t</b> elements. + * + * @param filename the name of the file. + * @param vector receives a vector of chapters + * @param format receives the <b>Timecode::Format</b> of the timestamps + * @return true if there was an error, false otherwise + */ +bool +ChapterUtility::parseChapterFile( const string filename, vector<MP4Chapter_t>& chapters, Timecode::Format& format ) +{ + // get the content + char * inBuf; + File::Size fileSize; + if( readChapterFile( filename, &inBuf, fileSize ) ) + { + return FAILURE; + } + + // separate the text lines + char* pos = inBuf; + while (pos < inBuf + fileSize) + { + if (*pos == '\n' || *pos == '\r') + { + *pos = 0; + if (pos > inBuf) + { + // remove trailing whitespace + char* tmp = pos-1; + while ((*tmp == ' ' || *tmp == '\t') && tmp > inBuf) + { + *tmp = 0; + tmp--; + } + } + } + pos++; + } + pos = inBuf; + + // check for a BOM + char bom[5] = {0}; + int bomLen = 0; + const unsigned char* uPos = reinterpret_cast<unsigned char*>( pos ); + if( 0xEF == *uPos && 0xBB == *(uPos+1) && 0xBF == *(uPos+2) ) + { + // UTF-8 (we do not need the BOM) + pos += 3; + } + else if( ( 0xFE == *uPos && 0xFF == *(uPos+1) ) // UTF-16 big endian + || ( 0xFF == *uPos && 0xFE == *(uPos+1) ) ) // UTF-16 little endian + { + // store the BOM to prepend the title strings + bom[0] = *pos++; + bom[1] = *pos++; + bomLen = 2; + return herrf( "chapter file '%s' has UTF-16 encoding which is not supported (only UTF-8 is allowed)\n", + filename.c_str() ); + } + else if( ( 0x0 == *uPos && 0x0 == *(uPos+1) && 0xFE == *(uPos+2) && 0xFF == *(uPos+3) ) // UTF-32 big endian + || ( 0xFF == *uPos && *(uPos+1) == 0xFE && *(uPos+2) == 0x0 && 0x0 == *(uPos+3) ) ) // UTF-32 little endian + { + // store the BOM to prepend the title strings + bom[0] = *pos++; + bom[1] = *pos++; + bom[2] = *pos++; + bom[3] = *pos++; + bomLen = 4; + return herrf( "chapter file '%s' has UTF-32 encoding which is not supported (only UTF-8 is allowed)\n", + filename.c_str() ); + } + + // parse the lines + bool failure = false; + uint32_t currentChapter = 0; + FormatState formatState = FMT_STATE_INITIAL; + char* titleStart = 0; + uint32_t titleLen = 0; + char* timeStart = 0; + while( pos < inBuf + fileSize ) + { + if( 0 == *pos || ' ' == *pos || '\t' == *pos ) + { + // uninteresting chars + pos++; + continue; + } + else if( '#' == *pos ) + { + // comment line + pos += strlen( pos ); + continue; + } + else if( isdigit( *pos ) ) + { + // mp4chaps native format: hh:mm:ss.sss <title> + + timeStart = pos; + + // read the title if there is one + titleStart = strchr( timeStart, ' ' ); + if( NULL == titleStart ) + { + titleStart = strchr( timeStart, '\t' ); + } + + if( NULL != titleStart ) + { + *titleStart = 0; + pos = ++titleStart; + + while( ' ' == *titleStart || '\t' == *titleStart ) + { + titleStart++; + } + + titleLen = strlen( titleStart ); + + // advance to the end of the line + pos = titleStart + 1 + titleLen; + } + else + { + // advance to the end of the line + pos += strlen( pos ); + } + + formatState = FMT_STATE_FINISH; + } +#if defined( _MSC_VER ) + else if( 0 == strnicmp( pos, "CHAPTER", 7 ) ) +#else + else if( 0 == strncasecmp( pos, "CHAPTER", 7 ) ) +#endif + { + // common format: CHAPTERxx=hh:mm:ss.sss\nCHAPTERxxNAME=<title> + + char* equalsPos = strchr( pos+7, '=' ); + if( NULL == equalsPos ) + { + herrf( "Unable to parse line \"%s\"\n", pos ); + failure = true; + break; + } + + *equalsPos = 0; + + char* tlwr = pos; + while( equalsPos != tlwr ) + { + *tlwr = tolower( *tlwr ); + tlwr++; + } + + if( NULL != strstr( pos, "name" ) ) + { + // mark the chapter title + uint32_t chNr = 0; + sscanf( pos, "chapter%dname", &chNr ); + if( chNr != currentChapter ) + { + // different chapter number => different chapter definition pair + if( FMT_STATE_INITIAL != formatState ) + { + herrf( "Chapter lines are not consecutive before line \"%s\"\n", pos ); + failure = true; + break; + } + + currentChapter = chNr; + } + formatState = FMT_STATE_TIME_LINE == formatState ? FMT_STATE_FINISH + : FMT_STATE_TITLE_LINE; + + titleStart = equalsPos + 1; + titleLen = strlen( titleStart ); + + // advance to the end of the line + pos = titleStart + titleLen; + } + else + { + // mark the chapter start time + uint32_t chNr = 0; + sscanf( pos, "chapter%d", &chNr ); + if( chNr != currentChapter ) + { + // different chapter number => different chapter definition pair + if( FMT_STATE_INITIAL != formatState ) + { + herrf( "Chapter lines are not consecutive at line \"%s\"\n", pos ); + failure = true; + break; + } + + currentChapter = chNr; + } + formatState = FMT_STATE_TITLE_LINE == formatState ? FMT_STATE_FINISH + : FMT_STATE_TIME_LINE; + + timeStart = equalsPos + 1; + + // advance to the end of the line + pos = timeStart + strlen( timeStart ); + } + } + + if( FMT_STATE_FINISH == formatState ) + { + // now we have title and start time + MP4Chapter_t chap; + + strncpy( chap.title, titleStart, min( titleLen, (uint32_t)MP4V2_CHAPTER_TITLE_MAX ) ); + chap.title[titleLen] = 0; + + Timecode tc( 0, CHAPTERTIMESCALE ); + string tm( timeStart ); + if( tc.parse( tm ) ) + { + herrf( "Unable to parse time code from \"%s\"\n", tm.c_str() ); + failure = true; + break; + } + chap.duration = tc.duration; + format = tc.format; + + // ad the chapter to the list + chapters.push_back( chap ); + + // re-initialize + formatState = FMT_STATE_INITIAL; + titleStart = timeStart = NULL; + titleLen = 0; + } + } + free( inBuf ); + if( failure ) + { + return failure; + } + + return SUCCESS; +} + +/////////////////////////////////////////////////////////////////////////////// + +/** Convert from frame to millisecond timestamp. + * + * This function converts a timestamp from hh:mm:ss:ff to hh:mm:ss.sss + * + * @param duration the timestamp in hours:minutes:seconds:frames. + * @param framerate the frames per second + * @return the timestamp in milliseconds + */ +MP4Duration +ChapterUtility::convertFrameToMillis( MP4Duration duration, uint32_t framerate ) +{ + Timecode tc( duration, CHAPTERTIMESCALE ); + if( framerate < tc.subseconds ) + { + uint64_t seconds = tc.subseconds / framerate; + tc.setSeconds( tc.seconds + seconds ); + tc.setSubseconds( (tc.subseconds - (seconds * framerate)) * framerate ); + } + else + { + tc.setSubseconds( tc.subseconds * framerate ); + } + + return tc.duration; +} + +/////////////////////////////////////////////////////////////////////////////// + +}} // namespace mp4v2::util + +/////////////////////////////////////////////////////////////////////////////// + +extern "C" +int main( int argc, char** argv ) +{ + mp4v2::util::ChapterUtility util( argc, argv ); + return util.process(); +} diff --git a/util/mp4extract.cpp b/util/mp4extract.cpp new file mode 100644 index 0000000..c4dc5eb --- /dev/null +++ b/util/mp4extract.cpp @@ -0,0 +1,253 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + */ + +// N.B. mp4extract just extracts tracks/samples from an mp4 file +// For many track types this is insufficient to reconsruct a valid +// elementary stream (ES). Use "mp4creator -extract=<trackId>" if +// you need the ES reconstructed. + +#include "util/impl.h" + +using namespace mp4v2::util; + +char* ProgName; +char* Mp4PathName; +char* Mp4FileName; + +// forward declaration +void ExtractTrack( MP4FileHandle mp4File, MP4TrackId trackId, + bool sampleMode, MP4SampleId sampleId, char* dstFileName = NULL ); + +extern "C" int main( int argc, char** argv ) +{ + const char* const usageString = + "[-l] [-t <track-id>] [-s <sample-id>] [-v [<level>]] <file-name>"; + bool doList = false; + bool doSamples = false; + MP4TrackId trackId = MP4_INVALID_TRACK_ID; + MP4SampleId sampleId = MP4_INVALID_SAMPLE_ID; + char* dstFileName = NULL; + uint32_t verbosity = MP4_DETAILS_ERROR; + +#if 0 + fprintf( stderr, "You don't want to use this utility - use mp4creator --extract instead\n" ); + fprintf( stderr, "If you really want to use it, remove this warning and the exit call\n" ); + fprintf( stderr, "from the source file\n" ); + exit( -1 ); +#endif + + /* begin processing command line */ + ProgName = argv[0]; + while ( true ) { + int c = -1; + int option_index = 0; + static const prog::Option long_options[] = { + { "list", prog::Option::NO_ARG, 0, 'l' }, + { "track", prog::Option::REQUIRED_ARG, 0, 't' }, + { "sample", prog::Option::OPTIONAL_ARG, 0, 's' }, + { "verbose", prog::Option::OPTIONAL_ARG, 0, 'v' }, + { "version", prog::Option::NO_ARG, 0, 'V' }, + { NULL, prog::Option::NO_ARG, 0, 0 } + }; + + c = prog::getOptionSingle( argc, argv, "lt:s::v::V", long_options, &option_index ); + + if ( c == -1 ) + break; + + switch ( c ) { + case 'l': + doList = true; + break; + case 's': + doSamples = true; + if ( prog::optarg ) { + if ( sscanf( prog::optarg, "%u", &sampleId ) != 1 ) { + fprintf( stderr, + "%s: bad sample-id specified: %s\n", + ProgName, prog::optarg ); + } + } + break; + case 't': + if ( sscanf( prog::optarg, "%u", &trackId ) != 1 ) { + fprintf( stderr, + "%s: bad track-id specified: %s\n", + ProgName, prog::optarg ); + exit( 1 ); + } + break; + case 'v': + verbosity |= MP4_DETAILS_READ; + if ( prog::optarg ) { + uint32_t level; + if ( sscanf( prog::optarg, "%u", &level ) == 1 ) { + if ( level >= 2 ) { + verbosity |= MP4_DETAILS_TABLE; + } + if ( level >= 3 ) { + verbosity |= MP4_DETAILS_SAMPLE; + } + if ( level >= 4 ) { + verbosity = MP4_DETAILS_ALL; + } + } + } + break; + case '?': + fprintf( stderr, "usage: %s %s\n", ProgName, usageString ); + exit( 0 ); + case 'V': + fprintf( stderr, "%s - %s\n", ProgName, MP4V2_PROJECT_name_formal ); + exit( 0 ); + default: + fprintf( stderr, "%s: unknown option specified, ignoring: %c\n", + ProgName, c ); + } + } + + /* check that we have at least one non-option argument */ + if ( ( argc - prog::optind ) < 1 ) { + fprintf( stderr, "usage: %s %s\n", ProgName, usageString ); + exit( 1 ); + } + + if ( verbosity ) { + fprintf( stderr, "%s version %s\n", ProgName, MP4V2_PROJECT_version ); + } + + /* point to the specified file names */ + Mp4PathName = argv[prog::optind++]; + + /* get dest file name for a single track */ + if ( trackId && ( argc - prog::optind ) > 0 ) { + dstFileName = argv[prog::optind++]; + } + + char* lastSlash = strrchr( Mp4PathName, '/' ); + if ( lastSlash ) { + Mp4FileName = lastSlash + 1; + } + else { + Mp4FileName = Mp4PathName; + } + + /* warn about extraneous non-option arguments */ + if ( prog::optind < argc ) { + fprintf( stderr, "%s: unknown options specified, ignoring: ", ProgName ); + while ( prog::optind < argc ) { + fprintf( stderr, "%s ", argv[prog::optind++] ); + } + fprintf( stderr, "\n" ); + } + + /* end processing of command line */ + + + MP4FileHandle mp4File = MP4Read( Mp4PathName, verbosity ); + + if ( !mp4File ) { + exit( 1 ); + } + + if ( doList ) { + MP4Info( mp4File ); + exit( 0 ); + } + + if ( trackId == 0 ) { + uint32_t numTracks = MP4GetNumberOfTracks( mp4File ); + + for ( uint32_t i = 0; i < numTracks; i++ ) { + trackId = MP4FindTrackId( mp4File, i ); + ExtractTrack( mp4File, trackId, doSamples, sampleId ); + } + } + else { + ExtractTrack( mp4File, trackId, doSamples, sampleId, dstFileName ); + } + + MP4Close( mp4File ); + + return( 0 ); +} + +void ExtractTrack( MP4FileHandle mp4File, MP4TrackId trackId, + bool sampleMode, MP4SampleId sampleId, char* dstFileName ) +{ + char outName[MP4V2_PATH_MAX]; + File out; + + if( !sampleMode ) { + if( !dstFileName ) + snprintf( outName, sizeof( outName ), "%s.t%u", Mp4FileName, trackId ); + else + snprintf( outName, sizeof( outName ), "%s", dstFileName ); + + if( out.open( outName, File::MODE_CREATE )) { + fprintf( stderr, "%s: can't open %s: %s\n", ProgName, outName, sys::getLastErrorStr() ); + return; + } + } + + MP4SampleId numSamples; + + if ( sampleMode && sampleId != MP4_INVALID_SAMPLE_ID ) { + numSamples = sampleId; + } + else { + sampleId = 1; + numSamples = MP4GetTrackNumberOfSamples( mp4File, trackId ); + } + + for ( ; sampleId <= numSamples; sampleId++ ) { + // signals to ReadSample() that it should malloc a buffer for us + uint8_t* pSample = NULL; + uint32_t sampleSize = 0; + + if( !MP4ReadSample( mp4File, trackId, sampleId, &pSample, &sampleSize )) { + fprintf( stderr, "%s: read sample %u for %s failed\n", ProgName, sampleId, outName ); + break; + } + + if ( sampleMode ) { + snprintf( outName, sizeof( outName ), "%s.t%u.s%u", Mp4FileName, trackId, sampleId ); + + if( out.open( outName, File::MODE_CREATE )) { + fprintf( stderr, "%s: can't open %s: %s\n", ProgName, outName, sys::getLastErrorStr() ); + break; + } + } + + File::Size nout; + if( out.write( pSample, sampleSize, nout )) { + fprintf( stderr, "%s: write to %s failed: %s\n", ProgName, outName, sys::getLastErrorStr() ); + break; + } + + free( pSample ); + + if( sampleMode ) + out.close(); + } + + out.close(); +} diff --git a/util/mp4file.cpp b/util/mp4file.cpp new file mode 100644 index 0000000..e3a72c8 --- /dev/null +++ b/util/mp4file.cpp @@ -0,0 +1,229 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is MP4v2. +// +// The Initial Developer of the Original Code is Kona Blend. +// Portions created by Kona Blend are Copyright (C) 2008. +// All Rights Reserved. +// +// Contributors: +// Kona Blend, kona8lend@@gmail.com +// +/////////////////////////////////////////////////////////////////////////////// + +#include "util/impl.h" + +namespace mp4v2 { namespace util { + +/////////////////////////////////////////////////////////////////////////////// + +class FileUtility : public Utility +{ +private: + enum FileLongCode { + LC_LIST = _LC_MAX, + LC_OPTIMIZE, + LC_DUMP, + }; + +public: + FileUtility( int, char** ); + +protected: + // delegates implementation + bool utility_option( int, bool& ); + bool utility_job( JobContext& ); + +private: + bool actionList ( JobContext& ); + bool actionOptimize ( JobContext& ); + bool actionDump ( JobContext& ); + +private: + Group _actionGroup; + + bool (FileUtility::*_action)( JobContext& ); +}; + +/////////////////////////////////////////////////////////////////////////////// + +FileUtility::FileUtility( int argc, char** argv ) + : Utility ( "mp4file", argc, argv ) + , _actionGroup ( "ACTIONS" ) + , _action ( NULL ) +{ + // add standard options which make sense for this utility + _group.add( STD_DRYRUN ); + _group.add( STD_KEEPGOING ); + _group.add( STD_QUIET ); + _group.add( STD_DEBUG ); + _group.add( STD_VERBOSE ); + _group.add( STD_HELP ); + _group.add( STD_VERSION ); + _group.add( STD_VERSIONX ); + + _actionGroup.add( "list", false, LC_LIST, "list (summary information)" ); + _actionGroup.add( "optimize", false, LC_OPTIMIZE, "optimize mp4 structure" ); + _actionGroup.add( "dump", false, LC_DUMP, "dump mp4 structure in human-readable format" ); + _groups.push_back( &_actionGroup ); + + _usage = "[OPTION]... ACTION file..."; + _description = + // 79-cols, inclusive, max desired width + // |----------------------------------------------------------------------------| + "\nFor each mp4 file specified, perform the specified ACTION. An action must be" + "\nspecified. Some options are not applicable to some actions."; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +FileUtility::actionDump( JobContext& job ) +{ + job.fileHandle = MP4Read( job.file.c_str(), _debugVerbosity ); + if( job.fileHandle == MP4_INVALID_FILE_HANDLE ) + return herrf( "unable to open for read: %s\n", job.file.c_str() ); + + if( !MP4Dump( job.fileHandle, stdout, _debugImplicits )) + return herrf( "dump failed: %s\n", job.file.c_str() ); + + return SUCCESS; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +FileUtility::actionList( JobContext& job ) +{ + ostringstream report; + + const int wbrand = 5; + const int wcompat = 18; + const int wsizing = 6; + const string sep = " "; + + if( _jobCount == 0 ) { + report << setw(wbrand) << left << "BRAND" + << sep << setw(wcompat) << left << "COMPAT" + << sep << setw(wsizing) << left << "SIZING" + << sep << setw(0) << "FILE" + << '\n'; + + report << setfill('-') << setw(70) << "" << setfill(' ') << '\n'; + } + + job.fileHandle = MP4Read( job.file.c_str(), _debugVerbosity ); + if( job.fileHandle == MP4_INVALID_FILE_HANDLE ) + return herrf( "unable to open for read: %s\n", job.file.c_str() ); + + FileSummaryInfo info; + if( fileFetchSummaryInfo( job.fileHandle, info )) + return herrf( "unable to fetch file summary info" ); + + string compat; + { + const FileSummaryInfo::BrandSet::iterator ie = info.compatible_brands.end(); + int count = 0; + for( FileSummaryInfo::BrandSet::iterator it = info.compatible_brands.begin(); it != ie; it++, count++ ) { + if( count > 0 ) + compat += ','; + compat += *it; + } + } + + const bool sizing = info.nlargesize | info.nversion1 | info.nspecial; + + report << setw(wbrand) << left << info.major_brand + << sep << setw(wcompat) << left << compat + << sep << setw(wsizing) << left << (sizing ? "64-bit" : "32-bit") + << sep << job.file + << '\n'; + + verbose1f( "%s", report.str().c_str() ); + return SUCCESS; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +FileUtility::actionOptimize( JobContext& job ) +{ + verbose1f( "optimizing %s\n", job.file.c_str() ); + + if( dryrunAbort() ) + return SUCCESS; + + string tfile = job.file; + tfile += ".tmp"; + + if( !MP4Optimize( job.file.c_str(), tfile.c_str(), _debugVerbosity )) + return herrf( "optimize failed: %s\n", job.file.c_str() ); + + verbose2f( "renaming %s -> %s\n", tfile.c_str(), job.file.c_str() ); + if( io::FileSystem::rename( tfile, job.file )) + hwarnf( "rename failed: %s -> %s\n", tfile.c_str(), job.file.c_str() ); + + return SUCCESS; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +FileUtility::utility_job( JobContext& job ) +{ + if( !_action ) + return herrf( "no action specified\n" ); + + return (this->*_action)( job ); +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +FileUtility::utility_option( int code, bool& handled ) +{ + handled = true; + + switch( code ) { + case LC_LIST: + _action = &FileUtility::actionList; + break; + + case LC_OPTIMIZE: + _action = &FileUtility::actionOptimize; + break; + + case LC_DUMP: + _action = &FileUtility::actionDump; + break; + + default: + handled = false; + break; + } + + return SUCCESS; +} + +/////////////////////////////////////////////////////////////////////////////// + +}} // namespace mp4v2::util + +/////////////////////////////////////////////////////////////////////////////// + +extern "C" +int main( int argc, char** argv ) +{ + mp4v2::util::FileUtility util( argc, argv ); + return util.process(); +} diff --git a/util/mp4info.cpp b/util/mp4info.cpp new file mode 100644 index 0000000..f021071 --- /dev/null +++ b/util/mp4info.cpp @@ -0,0 +1,239 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001-2002. All Rights Reserved. + * + * Portions created by Rouven Wessling are + * Copyright (C) 2008-2009. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + * Rouven Wessling mp4v2@rouvenwessling.de + */ + +#include "util/impl.h" + +using namespace mp4v2::util; + +extern "C" int main( int argc, char** argv ) +{ + const char* const usageString = + "<file-name>"; + + /* begin processing command line */ + char* ProgName = argv[0]; + while ( true ) { + int c = -1; + int option_index = 0; + static const prog::Option long_options[] = { + { "version", prog::Option::NO_ARG, 0, 'V' }, + { NULL, prog::Option::NO_ARG, 0, 0 } + }; + + c = prog::getOptionSingle( argc, argv, "V", long_options, &option_index ); + + if ( c == -1 ) + break; + + switch ( c ) { + case '?': + fprintf( stderr, "usage: %s %s\n", ProgName, usageString ); + exit( 0 ); + case 'V': + fprintf( stderr, "%s - %s\n", ProgName, MP4V2_PROJECT_name_formal ); + exit( 0 ); + default: + fprintf( stderr, "%s: unknown option specified, ignoring: %c\n", + ProgName, c ); + } + } + + /* check that we have at least one non-option argument */ + if ( ( argc - prog::optind ) < 1 ) { + fprintf( stderr, "usage: %s %s\n", ProgName, usageString ); + exit( 1 ); + } + + /* end processing of command line */ + printf( "%s version %s\n", ProgName, MP4V2_PROJECT_version ); + + while ( prog::optind < argc ) { + char *mp4FileName = argv[prog::optind++]; + + printf( "%s:\n", mp4FileName ); + + char* info = MP4FileInfo( mp4FileName ); + + if ( !info ) { + fprintf( stderr, + "%s: can't open %s\n", + ProgName, mp4FileName ); + continue; + } + + fputs( info, stdout ); + MP4FileHandle mp4file = MP4Read( mp4FileName ); //, MP4_DETAILS_ERROR); + if ( mp4file != MP4_INVALID_FILE_HANDLE ) { + const MP4Tags* tags = MP4TagsAlloc(); + MP4TagsFetch( tags, mp4file ); + if ( tags->name ) { + fprintf( stdout, " Name: %s\n", tags->name ); + } + if ( tags->sortName ) { + fprintf( stdout, " Sort Name: %s\n", tags->sortName ); + } + if ( tags->artist ) { + fprintf( stdout, " Artist: %s\n", tags->artist ); + } + if ( tags->sortArtist ) { + fprintf( stdout, " Sort Artist: %s\n", tags->sortArtist ); + } + if ( tags->composer ) { + fprintf( stdout, " Composer: %s\n", tags->composer ); + } + if ( tags->sortComposer ) { + fprintf( stdout, " Sort Composer: %s\n", tags->sortComposer ); + } + if ( tags->encodingTool ) { + fprintf( stdout, " Encoded with: %s\n", tags->encodingTool ); + } + if ( tags->encodedBy ) { + fprintf( stdout, " Encoded by: %s\n", tags->encodedBy ); + } + if ( tags->releaseDate ) { + fprintf( stdout, " Release Date: %s\n", tags->releaseDate ); + } + if ( tags->album ) { + fprintf( stdout, " Album: %s\n", tags->album ); + } + if ( tags->sortAlbum ) { + fprintf( stdout, " Sort Album: %s\n", tags->sortAlbum ); + } + if ( tags->track ) { + fprintf( stdout, " Track: %u of %u\n", tags->track->index, tags->track->total ); + } + if ( tags->disk ) { + fprintf( stdout, " Disk: %u of %u\n", tags->disk->index, tags->disk->total ); + } + if ( tags->genre ) { + fprintf( stdout, " Genre: %s\n", tags->genre ); + } + if ( tags->grouping ) { + fprintf( stdout, " Grouping: %s\n", tags->grouping ); + } + if ( tags->tempo ) { + fprintf( stdout, " BPM: %u\n", *tags->tempo ); + } + if ( tags->comments ) { + fprintf( stdout, " Comments: %s\n", tags->comments ); + } + if ( tags->compilation ) { + fprintf( stdout, " Part of Compilation: %s\n", *tags->compilation ? "yes" : "no" ); + } + if ( tags->gapless ) { + fprintf( stdout, " Part of Gapless Album: %s\n", *tags->gapless ? "yes" : "no" ); + } + if ( tags->artworkCount ) { + fprintf( stdout, " Cover Art pieces: %u\n", tags->artworkCount ); + } + if ( tags->albumArtist ) { + fprintf( stdout, " Album Artist: %s\n", tags->albumArtist ); + } + if ( tags->sortAlbumArtist ) { + fprintf( stdout, " Sort Album Artist: %s\n", tags->sortAlbumArtist ); + } + if ( tags->copyright ) { + fprintf( stdout, " Copyright: %s\n", tags->copyright ); + } + if ( tags->contentRating ) { + string s = itmf::enumContentRating.toString( static_cast<itmf::ContentRating>( *tags->contentRating ), true ); + fprintf( stdout, " Content Rating: %s\n", s.c_str() ); + } + if ( tags->hdVideo ) { + fprintf( stdout, " HD Video: %s\n", *tags->hdVideo ? "yes" : "no"); + } + if ( tags->mediaType ) { + string s = itmf::enumStikType.toString( static_cast<itmf::StikType>( *tags->mediaType ), true ); + fprintf( stdout, " Media Type: %s\n", s.c_str() ); + } + if ( tags->tvShow ) { + fprintf( stdout, " TV Show: %s\n", tags->tvShow ); + } + if ( tags->sortTVShow ) { + fprintf( stdout, " Sort TV Show: %s\n", tags->sortTVShow ); + } + if ( tags->tvNetwork ) { + fprintf( stdout, " TV Network: %s\n", tags->tvNetwork ); + } + if ( tags->tvEpisodeID ) { + fprintf( stdout, " TV Episode Number: %s\n", tags->tvEpisodeID ); + } + if ( tags->description ) { + fprintf( stdout, " Short Description: %s\n", tags->description ); + } + if ( tags->longDescription ) { + fprintf( stdout, " Long Description: %s\n", tags->longDescription ); + } + if ( tags->lyrics ) { + fprintf( stdout, " Lyrics: \n %s\n", tags->lyrics ); + } + if ( tags->tvEpisode ) { + fprintf( stdout, " TV Episode: %u\n", *tags->tvEpisode ); + } + if ( tags->tvSeason ) { + fprintf( stdout, " TV Season: %u\n", *tags->tvSeason ); + } + if ( tags->podcast) { + fprintf( stdout, " Podcast: %s\n", *tags->podcast ? "yes" : "no" ); + } + if ( tags->keywords ) { + fprintf( stdout, " Keywords: %s\n", tags->keywords ); + } + if ( tags->category ) { + fprintf( stdout, " Category: %s\n", tags->category ); + } + if ( tags->cnID ) { + fprintf( stdout, " cnID: %u\n", *tags->cnID ); + } + if ( tags->iTunesAccount ) { + fprintf( stdout, " iTunes Account: %s\n", tags->iTunesAccount ); + } + if ( tags->iTunesAccountType ) { + string s = itmf::enumAccountType.toString( static_cast<itmf::AccountType>( *tags->iTunesAccountType ), true ); + fprintf( stdout, " iTunes Account Type: %s\n", s.c_str() ); + } + if ( tags->purchaseDate ) { + fprintf( stdout, " Purchase Date: %s\n", tags->purchaseDate ); + } + if ( tags->iTunesCountry ) { + string s = itmf::enumCountryCode.toString( static_cast<itmf::CountryCode>( *tags->iTunesCountry ), true ); + fprintf( stdout, " iTunes Store Country: %s\n", s.c_str() ); + } + if ( tags->atID ) { + fprintf( stdout, " atID: %u\n", *tags->atID ); + } + if ( tags->plID ) { + fprintf( stdout, " plID: %llu\n", *tags->plID ); + } + if ( tags->geID ) { + fprintf( stdout, " geID: %u\n", *tags->geID ); + } + MP4TagsFree( tags ); + MP4Close( mp4file ); + } + free( info ); + } + return( 0 ); +} diff --git a/util/mp4subtitle.cpp b/util/mp4subtitle.cpp new file mode 100644 index 0000000..ec87e67 --- /dev/null +++ b/util/mp4subtitle.cpp @@ -0,0 +1,209 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is MP4v2. +// +// The Initial Developer of the Original Code is Kona Blend. +// Portions created by Kona Blend are Copyright (C) 2008. +// All Rights Reserved. +// +// Contributors: +// Kona Blend, kona8lend@@gmail.com +// Edward Groenendaal, egroenen@@cisco.com +// +/////////////////////////////////////////////////////////////////////////////// + +#include "util/impl.h" + +namespace mp4v2 { namespace util { + +/////////////////////////////////////////////////////////////////////////////// + +class SubtitleUtility : public Utility +{ +private: + enum SubtitleLongCode { + LC_LIST = _LC_MAX, + LC_EXPORT, + LC_IMPORT, + LC_REMOVE, + }; + +public: + SubtitleUtility( int, char** ); + +protected: + // delegates implementation + bool utility_option( int, bool& ); + bool utility_job( JobContext& ); + +private: + bool actionList ( JobContext& ); + bool actionExport ( JobContext& ); + bool actionImport ( JobContext& ); + bool actionRemove ( JobContext& ); + +private: + Group _actionGroup; + + bool (SubtitleUtility::*_action)( JobContext& ); + + string _stTextFile; +}; + +/////////////////////////////////////////////////////////////////////////////// + +SubtitleUtility::SubtitleUtility( int argc, char** argv ) + : Utility ( "mp4subtitle", argc, argv ) + , _actionGroup ( "ACTIONS" ) + , _action ( NULL ) +{ + // add standard options which make sense for this utility + _group.add( STD_OPTIMIZE ); + _group.add( STD_DRYRUN ); + _group.add( STD_KEEPGOING ); + _group.add( STD_OVERWRITE ); + _group.add( STD_FORCE ); + _group.add( STD_QUIET ); + _group.add( STD_DEBUG ); + _group.add( STD_VERBOSE ); + _group.add( STD_HELP ); + _group.add( STD_VERSION ); + _group.add( STD_VERSIONX ); + + _actionGroup.add( "list", false, LC_LIST, "list available subtitles" ); + _actionGroup.add( "export", true, LC_EXPORT, "export subtitles to TXT", "TXT" ); + _actionGroup.add( "import", true, LC_IMPORT, "import subtitles from TXT", "TXT" ); + _actionGroup.add( "remove", false, LC_REMOVE, "remove all subtitles" ); + _groups.push_back( &_actionGroup ); + + _usage = "[OPTION]... ACTION file..."; + _description = + // 79-cols, inclusive, max desired width + // |----------------------------------------------------------------------------| + "\nFor each mp4 file specified, perform the specified ACTION. An action must be" + "\nspecified. Some options are not applicable to some actions."; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +SubtitleUtility::actionExport( JobContext& job ) +{ + job.fileHandle = MP4Read( job.file.c_str(), _debugVerbosity ); + if( job.fileHandle == MP4_INVALID_FILE_HANDLE ) + return herrf( "unable to open for read: %s\n", job.file.c_str() ); + + verbose1f( "NOT IMPLEMENTED\n" ); + return FAILURE; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +SubtitleUtility::actionImport( JobContext& job ) +{ + job.fileHandle = MP4Modify( job.file.c_str() ); + if( job.fileHandle == MP4_INVALID_FILE_HANDLE ) + return herrf( "unable to open for write: %s\n", job.file.c_str() ); + + verbose1f( "NOT IMPLEMENTED\n" ); + return FAILURE; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +SubtitleUtility::actionList( JobContext& job ) +{ + job.fileHandle = MP4Read( job.file.c_str(), _debugVerbosity ); + if( job.fileHandle == MP4_INVALID_FILE_HANDLE ) + return herrf( "unable to open for read: %s\n", job.file.c_str() ); + + verbose1f( "NOT IMPLEMENTED\n" ); + return FAILURE; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +SubtitleUtility::actionRemove( JobContext& job ) +{ + job.fileHandle = MP4Modify( job.file.c_str() ); + if( job.fileHandle == MP4_INVALID_FILE_HANDLE ) + return herrf( "unable to open for write: %s\n", job.file.c_str() ); + + verbose1f( "NOT IMPLEMENTED" ); + return FAILURE; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +SubtitleUtility::utility_job( JobContext& job ) +{ + if( !_action ) + return herrf( "no action specified\n" ); + + return (this->*_action)( job ); +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +SubtitleUtility::utility_option( int code, bool& handled ) +{ + handled = true; + + switch( code ) { + case LC_LIST: + _action = &SubtitleUtility::actionList; + break; + + case LC_EXPORT: + _action = &SubtitleUtility::actionExport; + _stTextFile = prog::optarg; + if( _stTextFile.empty() ) + return herrf( "invalid TXT file: empty-string\n" ); + break; + + case LC_IMPORT: + _action = &SubtitleUtility::actionImport; + _stTextFile = prog::optarg; + if( _stTextFile.empty() ) + return herrf( "invalid TXT file: empty-string\n" ); + break; + + case LC_REMOVE: + _action = &SubtitleUtility::actionRemove; + break; + + default: + handled = false; + break; + } + + return SUCCESS; +} + +/////////////////////////////////////////////////////////////////////////////// + +}} // namespace mp4v2::util + +/////////////////////////////////////////////////////////////////////////////// + +extern "C" +int main( int argc, char** argv ) +{ + mp4v2::util::SubtitleUtility util( argc, argv ); + return util.process(); +} diff --git a/util/mp4tags.cpp b/util/mp4tags.cpp new file mode 100644 index 0000000..04e712e --- /dev/null +++ b/util/mp4tags.cpp @@ -0,0 +1,493 @@ +/* mp4tags -- tool to set iTunes-compatible metadata tags + * + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * Contributed to MPEG4IP + * by Christopher League <league@contrapunctus.net> + */ + +#include "util/impl.h" + +using namespace mp4v2::util; + +/////////////////////////////////////////////////////////////////////////////// + +/* One-letter options -- if you want to rearrange these, change them + here, immediately below in OPT_STRING, and in the help text. */ +#define OPT_HELP 0x01ff +#define OPT_VERSION 0x02ff +#define OPT_ALBUM 'A' +#define OPT_ARTIST 'a' +#define OPT_TEMPO 'b' +#define OPT_COMMENT 'c' +#define OPT_COPYRIGHT 'C' +#define OPT_DISK 'd' +#define OPT_DISKS 'D' +#define OPT_ENCODEDBY 'e' +#define OPT_TOOL 'E' +#define OPT_GENRE 'g' +#define OPT_GROUPING 'G' +#define OPT_HD 'H' +#define OPT_MEDIA_TYPE 'i' +#define OPT_CNID 'I' +#define OPT_LONGDESC 'l' +#define OPT_LYRICS 'L' +#define OPT_DESCRIPTION 'm' +#define OPT_TVEPISODE 'M' +#define OPT_TVSEASON 'n' +#define OPT_TVNETWORK 'N' +#define OPT_TVEPISODEID 'o' +#define OPT_PICTURE 'P' +#define OPT_NAME 's' +#define OPT_TVSHOW 'S' +#define OPT_TRACK 't' +#define OPT_TRACKS 'T' +#define OPT_COMPOSER 'w' +#define OPT_RELEASEDATE 'y' +#define OPT_REMOVE 'r' +#define OPT_ALBUM_ARTIST 'R' + +#define OPT_STRING "A:a:b:c:C:d:D:e:E:g:G:H:i:I:l:L:m:M:n:N:o:P:s:S:t:T:w:y:r:R:" + +#define ELEMENT_OF(x,i) x[int(i)] + +static const char* const help_text = + "OPTION... FILE...\n" + "Adds or modifies iTunes-compatible tags on MP4 files.\n" + "\n" + " -help Display this help text and exit\n" + " -version Display version information and exit\n" + " -A, -album STR Set the album title\n" + " -a, -artist STR Set the artist information\n" + " -b, -tempo NUM Set the tempo (beats per minute)\n" + " -c, -comment STR Set a general comment\n" + " -C, -copyright STR Set the copyright information\n" + " -d, -disk NUM Set the disk number\n" + " -D, -disks NUM Set the number of disks\n" + " -e, -encodedby STR Set the name of the person or company who encoded the file\n" + " -E, -tool STR Set the software used for encoding\n" + " -g, -genre STR Set the genre name\n" + " -G, -grouping STR Set the grouping name\n" + " -H, -hdvideo NUM Set the HD flag (1\\0)\n" + " -i, -type STR Set the Media Type(tvshow, movie, music, ...)\n" + " -I, -cnid NUM Set the cnID\n" + " -l, -longdesc NUM Set the short description\n" + " -L, -lyrics NUM Set the lyrics\n" + " -m, -description STR Set the short description\n" + " -M, -episode NUM Set the episode number\n" + " -n, -season NUM Set the season number\n" + " -N, -network STR Set the TV network\n" + " -o, -episodeid STR Set the TV episode ID\n" + " -P, -picture PTH Set the picture as a .png\n" + " -s, -song STR Set the song title\n" + " -S -show STR Set the TV show\n" + " -t, -track NUM Set the track number\n" + " -T, -tracks NUM Set the number of tracks\n" + " -w, -writer STR Set the composer information\n" + " -y, -year NUM Set the release date\n" + " -R, -albumartist STR Set the album artist\n" + " -r, -remove STR Remove tags by code (e.g. \"-r cs\"\n" + " removes the comment and song tags)"; + +extern "C" int + main( int argc, char** argv ) +{ + const prog::Option long_options[] = { + { "help", prog::Option::NO_ARG, 0, OPT_HELP }, + { "version", prog::Option::NO_ARG, 0, OPT_VERSION }, + { "album", prog::Option::REQUIRED_ARG, 0, OPT_ALBUM }, + { "artist", prog::Option::REQUIRED_ARG, 0, OPT_ARTIST }, + { "comment", prog::Option::REQUIRED_ARG, 0, OPT_COMMENT }, + { "copyright", prog::Option::REQUIRED_ARG, 0, OPT_COPYRIGHT }, + { "disk", prog::Option::REQUIRED_ARG, 0, OPT_DISK }, + { "disks", prog::Option::REQUIRED_ARG, 0, OPT_DISKS }, + { "encodedby", prog::Option::REQUIRED_ARG, 0, OPT_ENCODEDBY }, + { "tool", prog::Option::REQUIRED_ARG, 0, OPT_TOOL }, + { "genre", prog::Option::REQUIRED_ARG, 0, OPT_GENRE }, + { "grouping", prog::Option::REQUIRED_ARG, 0, OPT_GROUPING }, + { "hdvideo", prog::Option::REQUIRED_ARG, 0, OPT_HD }, + { "type", prog::Option::REQUIRED_ARG, 0, OPT_MEDIA_TYPE }, + { "cnid", prog::Option::REQUIRED_ARG, 0, OPT_CNID }, + { "longdesc", prog::Option::REQUIRED_ARG, 0, OPT_LONGDESC }, + { "lyrics", prog::Option::REQUIRED_ARG, 0, OPT_LYRICS }, + { "description", prog::Option::REQUIRED_ARG, 0, OPT_DESCRIPTION }, + { "episode", prog::Option::REQUIRED_ARG, 0, OPT_TVEPISODE }, + { "season", prog::Option::REQUIRED_ARG, 0, OPT_TVSEASON }, + { "network", prog::Option::REQUIRED_ARG, 0, OPT_TVNETWORK }, + { "episodeid", prog::Option::REQUIRED_ARG, 0, OPT_TVEPISODEID }, + { "picture", prog::Option::REQUIRED_ARG, 0, OPT_PICTURE }, + { "song", prog::Option::REQUIRED_ARG, 0, OPT_NAME }, + { "show", prog::Option::REQUIRED_ARG, 0, OPT_TVSHOW }, + { "tempo", prog::Option::REQUIRED_ARG, 0, OPT_TEMPO }, + { "track", prog::Option::REQUIRED_ARG, 0, OPT_TRACK }, + { "tracks", prog::Option::REQUIRED_ARG, 0, OPT_TRACKS }, + { "writer", prog::Option::REQUIRED_ARG, 0, OPT_COMPOSER }, + { "year", prog::Option::REQUIRED_ARG, 0, OPT_RELEASEDATE }, + { "remove", prog::Option::REQUIRED_ARG, 0, OPT_REMOVE }, + { "albumartist", prog::Option::REQUIRED_ARG, 0, OPT_ALBUM_ARTIST }, + { NULL, prog::Option::NO_ARG, 0, 0 } + }; + + /* Sparse arrays of tag data: some space is wasted, but it's more + convenient to say tags[OPT_SONG] than to enumerate all the + metadata types (again) as a struct. */ + const char *tags[UCHAR_MAX]; + int nums[UCHAR_MAX]; + + memset( tags, 0, sizeof( tags ) ); + memset( nums, 0, sizeof( nums ) ); + + /* Any modifications requested? */ + int mods = 0; + + /* Option-processing loop. */ + int c = prog::getOptionSingle( argc, argv, OPT_STRING, long_options, NULL ); + while ( c != -1 ) { + int r = 2; + switch ( c ) { + /* getopt() returns '?' if there was an error. It already + printed the error message, so just return. */ + case '?': + return 1; + + /* Help and version requests handled here. */ + case OPT_HELP: + fprintf( stderr, "usage %s %s\n", argv[0], help_text ); + return 0; + case OPT_VERSION: + fprintf( stderr, "%s - %s\n", argv[0], MP4V2_PROJECT_name_formal ); + return 0; + + /* Numeric arguments: convert them using sscanf(). */ + case OPT_DISK: + case OPT_DISKS: + case OPT_TRACK: + case OPT_TRACKS: + case OPT_HD: + case OPT_CNID: + case OPT_TVEPISODE: + case OPT_TVSEASON: + case OPT_TEMPO: + r = sscanf( prog::optarg, "%d", &nums[c] ); + if ( r < 1 ) { + fprintf( stderr, "%s: option requires numeric argument -- %c\n", + argv[0], c ); + return 2; + } + /* Break not, lest ye be broken. :) */ + /* All arguments: all valid options end up here, and we just + stuff the string pointer into the tags[] array. */ + default: + tags[c] = prog::optarg; + mods++; + } /* end switch */ + + c = prog::getOptionSingle( argc, argv, OPT_STRING, long_options, NULL ); + } /* end while */ + + /* Check that we have at least one non-option argument */ + if ( ( argc - prog::optind ) < 1 ) { + fprintf( stderr, + "%s: You must specify at least one MP4 file.\n", + argv[0] ); + fprintf( stderr, "usage %s %s\n", argv[0], help_text ); + return 3; + } + + /* Check that we have at least one requested modification. Probably + it's useful instead to print the metadata if no modifications are + requested? */ + if ( !mods ) { + fprintf( stderr, + "%s: You must specify at least one tag modification.\n", + argv[0] ); + fprintf( stderr, "usage %s %s\n", argv[0], help_text ); + return 4; + } + + /* Loop through the non-option arguments, and modify the tags as + requested. */ + while ( prog::optind < argc ) { + char *mp4 = argv[prog::optind++]; + + MP4FileHandle h = MP4Modify( mp4 ); + if ( h == MP4_INVALID_FILE_HANDLE ) { + fprintf( stderr, "Could not open '%s'... aborting\n", mp4 ); + return 5; + } + /* Read out the existing metadata */ + const MP4Tags* mdata = MP4TagsAlloc(); + MP4TagsFetch( mdata, h ); + + /* Remove any tags */ + if ( ELEMENT_OF(tags,OPT_REMOVE) ) { + for ( const char *p = ELEMENT_OF(tags,OPT_REMOVE); *p; p++ ) { + switch ( *p ) { + case OPT_ALBUM: + MP4TagsSetAlbum( mdata, NULL ); + break; + case OPT_ARTIST: + MP4TagsSetArtist( mdata, NULL ); + break; + case OPT_COMMENT: + MP4TagsSetComments( mdata, NULL ); + break; + case OPT_COPYRIGHT: + MP4TagsSetCopyright( mdata, NULL ); + break; + case OPT_DISK: + MP4TagsSetDisk( mdata, NULL ); + break; + case OPT_DISKS: + MP4TagsSetDisk( mdata, NULL ); + break; + case OPT_ENCODEDBY: + MP4TagsSetEncodedBy( mdata, NULL ); + break; + case OPT_TOOL: + MP4TagsSetEncodingTool( mdata, NULL ); + break; + case OPT_GENRE: + MP4TagsSetGenre( mdata, NULL ); + break; + case OPT_GROUPING: + MP4TagsSetGrouping( mdata, NULL ); + break; + case OPT_HD: + MP4TagsSetHDVideo( mdata, NULL ); + break; + case OPT_CNID: + MP4TagsSetCNID( mdata, NULL ); + break; + case OPT_LONGDESC: + MP4TagsSetLongDescription( mdata, NULL ); + break; + case OPT_LYRICS: + MP4TagsSetLyrics( mdata, NULL ); + break; + case OPT_MEDIA_TYPE: + MP4TagsSetMediaType( mdata, NULL ); + break; + case OPT_DESCRIPTION: + MP4TagsSetDescription( mdata, NULL ); + break; + case OPT_TVEPISODE: + MP4TagsSetTVEpisode( mdata, NULL ); + break; + case OPT_TVSEASON: + MP4TagsSetTVSeason( mdata, NULL ); + break; + case OPT_TVNETWORK: + MP4TagsSetTVNetwork( mdata, NULL ); + break; + case OPT_TVEPISODEID: + MP4TagsSetTVEpisodeID( mdata, NULL ); + break; + case OPT_NAME: + MP4TagsSetName( mdata, NULL ); + break; + case OPT_TVSHOW: + MP4TagsSetTVShow( mdata, NULL ); + break; + case OPT_COMPOSER: + MP4TagsSetComposer( mdata, NULL ); + break; + case OPT_RELEASEDATE: + MP4TagsSetReleaseDate( mdata, NULL ); + break; + case OPT_TEMPO: + MP4TagsSetTempo( mdata, NULL ); + break; + case OPT_TRACK: + MP4TagsSetTrack( mdata, NULL ); + break; + case OPT_TRACKS: + MP4TagsSetTrack( mdata, NULL ); + break; + case OPT_PICTURE: + if( mdata->artworkCount ) + MP4TagsRemoveArtwork( mdata, 0 ); + break; + case OPT_ALBUM_ARTIST: + MP4TagsSetAlbumArtist( mdata, NULL ); + break ; + } + } + } + + /* Track/disk numbers need to be set all at once, but we'd like to + allow users to just specify -T 12 to indicate that all existing + track numbers are out of 12. This means we need to look up the + current info if it is not being set. */ + + if ( ELEMENT_OF(tags,OPT_TRACK) || ELEMENT_OF(tags,OPT_TRACKS) ) { + MP4TagTrack tt; + tt.index = 0; + tt.total = 0; + + if( mdata->track ) { + tt.index = mdata->track->index; + tt.total = mdata->track->total; + } + + if( ELEMENT_OF(tags,OPT_TRACK) ) + tt.index = ELEMENT_OF(nums,OPT_TRACK); + if( ELEMENT_OF(tags,OPT_TRACKS) ) + tt.total = ELEMENT_OF(nums,OPT_TRACKS); + + MP4TagsSetTrack( mdata, &tt ); + } + + if ( ELEMENT_OF(tags,OPT_TRACK) || ELEMENT_OF(tags,OPT_TRACKS) ) { + MP4TagDisk td; + td.index = 0; + td.total = 0; + + if( mdata->disk ) { + td.index = mdata->disk->index; + td.total = mdata->disk->total; + } + + if( ELEMENT_OF(tags,OPT_DISK) ) + td.index = ELEMENT_OF(nums,OPT_DISK); + if( ELEMENT_OF(tags,OPT_DISKS) ) + td.total = ELEMENT_OF(nums,OPT_DISKS); + + MP4TagsSetDisk( mdata, &td ); + } + + /* Set the other relevant attributes */ + for ( int i = 0; i < UCHAR_MAX; i++ ) { + if ( tags[i] ) { + switch ( i ) { + case OPT_ALBUM: + MP4TagsSetAlbum( mdata, tags[i] ); + break; + case OPT_ARTIST: + MP4TagsSetArtist( mdata, tags[i] ); + break; + case OPT_COMMENT: + MP4TagsSetComments( mdata, tags[i] ); + break; + case OPT_COPYRIGHT: + MP4TagsSetCopyright( mdata, tags[i] ); + break; + case OPT_ENCODEDBY: + MP4TagsSetEncodedBy( mdata, tags[i] ); + break; + case OPT_TOOL: + MP4TagsSetEncodingTool( mdata, tags[i] ); + break; + case OPT_GENRE: + MP4TagsSetGenre( mdata, tags[i] ); + break; + case OPT_GROUPING: + MP4TagsSetGrouping( mdata, tags[i] ); + break; + case OPT_HD: + { + uint8_t value = static_cast<uint8_t>( nums[i] ); + MP4TagsSetHDVideo( mdata, &value ); + break; + } + case OPT_CNID: + { + uint32_t value = static_cast<uint32_t>( nums[i] ); + MP4TagsSetCNID( mdata, &value ); + break; + } + case OPT_LONGDESC: + MP4TagsSetLongDescription( mdata, tags[i] ); + break; + case OPT_LYRICS: + MP4TagsSetLyrics( mdata, tags[i] ); + break; + case OPT_MEDIA_TYPE: + { + uint8_t st = static_cast<uint8_t>( itmf::enumStikType.toType( tags[i] ) ) ; + MP4TagsSetMediaType( mdata, &st ); + break; + } + case OPT_DESCRIPTION: + MP4TagsSetDescription( mdata, tags[i] ); + break; + case OPT_TVEPISODE: + { + uint32_t value = static_cast<uint32_t>( nums[i] ); + MP4TagsSetTVEpisode( mdata, &value ); + break; + } + case OPT_TVSEASON: + { + uint32_t value = static_cast<uint32_t>( nums[i] ); + MP4TagsSetTVSeason( mdata, &value ); + break; + } + case OPT_TVNETWORK: + MP4TagsSetTVNetwork( mdata, tags[i] ); + break; + case OPT_TVEPISODEID: + MP4TagsSetTVEpisodeID( mdata, tags[i] ); + break; + case OPT_NAME: + MP4TagsSetName( mdata, tags[i] ); + break; + case OPT_TVSHOW: + MP4TagsSetTVShow( mdata, tags[i] ); + break; + case OPT_COMPOSER: + MP4TagsSetComposer( mdata, tags[i] ); + break; + case OPT_RELEASEDATE: + MP4TagsSetReleaseDate( mdata, tags[i] ); + break; + case OPT_TEMPO: + { + uint16_t value = static_cast<uint16_t>( nums[i] ); + MP4TagsSetTempo( mdata, &value ); + break; + } + case OPT_ALBUM_ARTIST: + MP4TagsSetAlbumArtist( mdata, tags[i] ); + break; + case OPT_PICTURE: + { + File in( tags[i], File::MODE_READ ); + if( !in.open() ) { + MP4TagArtwork art; + art.size = (uint32_t)in.size; + art.data = malloc( art.size ); + art.type = MP4_ART_UNDEFINED; + + File::Size nin; + if( in.read( (void*)art.data, art.size, nin ) && nin == art.size ) { + if( mdata->artworkCount ) + MP4TagsRemoveArtwork( mdata, 0 ); + MP4TagsAddArtwork( mdata, &art ); + } + + free( (void*)art.data ); + in.close(); + } + else { + fprintf( stderr, "Art file %s not found\n", tags[i] ); + } + } + } + } + } + /* Write out all tag modifications, free and close */ + MP4TagsStore( mdata, h ); + MP4TagsFree( mdata ); + MP4Close( h ); + } /* end while optind < argc */ + return 0; +} diff --git a/util/mp4track.cpp b/util/mp4track.cpp new file mode 100644 index 0000000..bc27b01 --- /dev/null +++ b/util/mp4track.cpp @@ -0,0 +1,995 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is MP4v2. +// +// The Initial Developer of the Original Code is Kona Blend. +// Portions created by Kona Blend are Copyright (C) 2008. +// All Rights Reserved. +// +// Contributors: +// Kona Blend, kona8lend@@gmail.com +// +/////////////////////////////////////////////////////////////////////////////// + +#include "util/impl.h" + +namespace mp4v2 { namespace util { + +/////////////////////////////////////////////////////////////////////////////// + +class TrackUtility : public Utility +{ +private: + enum TrackLongAction { + LC_TRACK_WILDCARD = _LC_MAX, + LC_TRACK_ID, + LC_TRACK_INDEX, + + LC_SAMPLE_WILDCARD, + LC_SAMPLE_ID, + LC_SAMPLE_INDEX, + + LC_LIST, + + LC_ENABLED, + LC_INMOVIE, + LC_INPREVIEW, + LC_LAYER, + LC_ALTGROUP, + LC_VOLUME, + LC_WIDTH, + LC_HEIGHT, + LC_LANGUAGE, + LC_HDLRNAME, + LC_UDTANAME, + LC_UDTANAME_R, + + LC_COLR_PARMS, + LC_COLR_PARM_HD, + LC_COLR_PARM_SD, + + LC_COLR_LIST, + LC_COLR_ADD, + LC_COLR_SET, + LC_COLR_REMOVE, + + LC_PASP_PARMS, + + LC_PASP_LIST, + LC_PASP_ADD, + LC_PASP_SET, + LC_PASP_REMOVE, + }; + +public: + TrackUtility( int, char** ); + +protected: + // delegates implementation + bool utility_option( int, bool& ); + bool utility_job( JobContext& ); + +private: + bool actionList( JobContext& ); + bool actionListSingle( JobContext&, uint16_t ); + + bool actionColorParameterList ( JobContext& ); + bool actionColorParameterAdd ( JobContext& ); + bool actionColorParameterSet ( JobContext& ); + bool actionColorParameterRemove ( JobContext& ); + + bool actionPictureAspectRatioList ( JobContext& ); + bool actionPictureAspectRatioAdd ( JobContext& ); + bool actionPictureAspectRatioSet ( JobContext& ); + bool actionPictureAspectRatioRemove ( JobContext& ); + + bool actionTrackModifierSet ( JobContext& ); + bool actionTrackModifierRemove ( JobContext& ); + +private: + enum TrackMode { + TM_UNDEFINED, + TM_INDEX, + TM_ID, + TM_WILDCARD, + }; + + enum SampleMode { + SM_UNDEFINED, + SM_INDEX, + SM_ID, + SM_WILDCARD, + }; + + Group _actionGroup; + Group _parmGroup; + + bool (TrackUtility::*_action)( JobContext& ); + + TrackMode _trackMode; + uint16_t _trackIndex; + uint32_t _trackId; + + SampleMode _sampleMode; + uint16_t _sampleIndex; + uint32_t _sampleId; + + qtff::ColorParameterBox::Item _colorParameterItem; + qtff::PictureAspectRatioBox::Item _pictureAspectRatioItem; + + void (TrackModifier::*_actionTrackModifierSet_function)( const string& ); + string _actionTrackModifierSet_name; + string _actionTrackModifierSet_value; + + void (TrackModifier::*_actionTrackModifierRemove_function)(); + string _actionTrackModifierRemove_name; +}; + +/////////////////////////////////////////////////////////////////////////////// + +string toStringTrackType( string ); + +/////////////////////////////////////////////////////////////////////////////// + +TrackUtility::TrackUtility( int argc, char** argv ) + : Utility ( "mp4track", argc, argv ) + , _actionGroup ( "ACTIONS" ) + , _parmGroup ( "PARAMETERS" ) + , _action ( NULL ) + , _trackMode ( TM_UNDEFINED ) + , _trackIndex ( 0 ) + , _trackId ( MP4_INVALID_TRACK_ID ) + , _sampleMode ( SM_UNDEFINED ) + , _sampleIndex ( 0 ) + , _sampleId ( MP4_INVALID_SAMPLE_ID ) +{ + // add standard options which make sense for this utility + _group.add( STD_OPTIMIZE ); + _group.add( STD_DRYRUN ); + _group.add( STD_KEEPGOING ); + _group.add( STD_OVERWRITE ); + _group.add( STD_FORCE ); + _group.add( STD_QUIET ); + _group.add( STD_DEBUG ); + _group.add( STD_VERBOSE ); + _group.add( STD_HELP ); + _group.add( STD_VERSION ); + _group.add( STD_VERSIONX ); + + _parmGroup.add( "track-any", false, LC_TRACK_WILDCARD, "act on any/all tracks" ); + _parmGroup.add( "track-index", true, LC_TRACK_INDEX, "act on track index IDX", "IDX" ); + _parmGroup.add( "track-id", true, LC_TRACK_ID, "act on track id ID", "ID" ); +/* + _parmGroup.add( "sample-any", false, LC_SAMPLE_WILDCARD, "act on any sample (default)" ); + _parmGroup.add( "sample-index", true, LC_SAMPLE_INDEX, "act on sample index IDX" ); + _parmGroup.add( "sample-id", true, LC_SAMPLE_ID, "act on sample id ID" ); +*/ + _parmGroup.add( "colr-parms", true, LC_COLR_PARMS, "where CSV is IDX1,IDX2,IDX3", "CSV" ); + _parmGroup.add( "colr-parm-hd", false, LC_COLR_PARM_HD, "equivalent to --colr-parms=1,1,1" ); + _parmGroup.add( "colr-parm-sd", false, LC_COLR_PARM_SD, "equivalent to --colr-parms=6,1,6" ); + _parmGroup.add( "pasp-parms", true, LC_PASP_PARMS, "where CSV is hSPACING,vSPACING", "CSV" ); + _groups.push_back( &_parmGroup ); + + _actionGroup.add( "list", false, LC_LIST, "list all tracks in mp4" ); + + _actionGroup.add( "enabled", true, LC_ENABLED, "set trak.tkhd.flags (enabled bit)", "BOOL" ); + _actionGroup.add( "inmovie", true, LC_INMOVIE, "set trak.tkhd.flags (inMovie bit)", "BOOL" ); + _actionGroup.add( "inpreview", true, LC_INPREVIEW, "set trak.tkhd.flags (inPreview bit)", "BOOL" ); + _actionGroup.add( "layer", true, LC_LAYER, "set trak.tkhd.layer", "NUM" ); + _actionGroup.add( "altgroup", true, LC_ALTGROUP, "set trak.tkhd.alternate_group", "NUM" ); + _actionGroup.add( "volume", true, LC_VOLUME, "set trak.tkhd.volume", "FLOAT" ); + _actionGroup.add( "width", true, LC_WIDTH, "set trak.tkhd.width", "FLOAT" ); + _actionGroup.add( "height", true, LC_HEIGHT, "set trak.tkhd.height", "FLOAT" ); + _actionGroup.add( "language", true, LC_LANGUAGE, "set trak.mdia.mdhd.language", "CODE" ); + _actionGroup.add( "hdlrname", true, LC_HDLRNAME, "set trak.mdia.hdlr.name", "STR" ); + _actionGroup.add( "udtaname", true, LC_UDTANAME, "set trak.udta.name.value", "STR" ); + _actionGroup.add( "udtaname-remove", false, LC_UDTANAME_R, "remove trak.udta.name atom" ); + + _actionGroup.add( "colr-list", false, LC_COLR_LIST, "list all colr-boxes in mp4" ); + _actionGroup.add( "colr-add", false, LC_COLR_ADD, "add colr-box to a video track" ); + _actionGroup.add( "colr-set", false, LC_COLR_SET, "set colr-box parms" ); + _actionGroup.add( "colr-remove", false, LC_COLR_REMOVE, "remove colr-box from track" ); + _actionGroup.add( "pasp-list", false, LC_PASP_LIST, "list all pasp-boxes in mp4" ); + _actionGroup.add( "pasp-add", false, LC_PASP_ADD, "add pasp-box to a video track" ); + _actionGroup.add( "pasp-set", false, LC_PASP_SET, "set pasp-box parms" ); + _actionGroup.add( "pasp-remove", false, LC_PASP_REMOVE, "remove pasp-box from track" ); + + _groups.push_back( &_actionGroup ); + + _usage = "[OPTION]... [PARAMETERS]... ACTION file..."; + _description = + // 79-cols, inclusive, max desired width + // |----------------------------------------------------------------------------| + "\nFor each mp4 file specified, perform the specified ACTION. An action must be" + "\nspecified. Some options are not applicable to some actions."; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +TrackUtility::actionColorParameterAdd( JobContext& job ) +{ + ostringstream oss; + oss << "adding colr-box(" << _colorParameterItem.convertToCSV() << ") -> " << job.file; + + switch( _trackMode ) { + case TM_INDEX: + oss << " (track index=" << _trackIndex << ')'; + break; + + case TM_ID: + oss << " (track id=" << _trackId << ')'; + break; + + default: + case TM_WILDCARD: + return herrf( "track not specified\n" ); + } + + verbose1f( "%s\n", oss.str().c_str() ); + if( dryrunAbort() ) + return SUCCESS; + + job.fileHandle = MP4Modify( job.file.c_str(), _debugVerbosity ); + if( job.fileHandle == MP4_INVALID_FILE_HANDLE ) + return herrf( "unable to open for write: %s\n", job.file.c_str() ); + + switch( _trackMode ) { + default: + case TM_INDEX: + if( qtff::ColorParameterBox::add( job.fileHandle, _trackIndex, _colorParameterItem )) + return herrf( "unable to add colr-box\n" ); + break; + + case TM_ID: + if( qtff::ColorParameterBox::add( job.fileHandle, _trackId, _colorParameterItem )) + return herrf( "unable to add colr-box\n" ); + break; + } + + return SUCCESS; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +TrackUtility::actionColorParameterList( JobContext& job ) +{ + job.fileHandle = MP4Read( job.file.c_str(), _debugVerbosity ); + if( job.fileHandle == MP4_INVALID_FILE_HANDLE ) + return herrf( "unable to open for read: %s\n", job.file.c_str() ); + + ostringstream report; + + const int widx = 3; + const int wid = 3; + const int wtype = 8; + const int wparm = 6; + const string sep = " "; + + if( _jobCount == 0 ) { + report << setw(widx) << right << "IDX" + << sep << setw(wid) << "ID" + << sep << setw(wtype) << left << "TYPE" + << sep << setw(wparm) << right << "PRIMRY" + << sep << setw(wparm) << right << "XFERFN" + << sep << setw(wparm) << right << "MATRIX" + << sep << setw(0) << "FILE" + << '\n'; + + report << setfill('-') << setw(70) << "" << setfill(' ') << '\n'; + } + + qtff::ColorParameterBox::ItemList itemList; + if( qtff::ColorParameterBox::list( job.fileHandle, itemList )) + return herrf( "unable to fetch list of colr-boxes" ); + + const qtff::ColorParameterBox::ItemList::size_type max = itemList.size(); + for( qtff::ColorParameterBox::ItemList::size_type i = 0; i < max; i++ ) { + const qtff::ColorParameterBox::IndexedItem& xitem = itemList[i]; + + const char* type = MP4GetTrackType( job.fileHandle, xitem.trackId ); + if( !type) + type = "unknown"; + + report << right << setw(widx) << xitem.trackIndex + << sep << setw(wid) << xitem.trackId + << sep << setw(wtype) << left << toStringTrackType( type ) + << sep << setw(wparm) << right << xitem.item.primariesIndex + << sep << setw(wparm) << right << xitem.item.transferFunctionIndex + << sep << setw(wparm) << right << xitem.item.matrixIndex; + + if( i == 0 ) + report << sep << setw(0) << job.file; + + report << '\n'; + } + + verbose1f( "%s", report.str().c_str() ); + return SUCCESS; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +TrackUtility::actionColorParameterRemove( JobContext& job ) +{ + ostringstream oss; + oss << "removing colr-box from " << job.file; + + switch( _trackMode ) { + case TM_INDEX: + oss << " (track index=" << _trackIndex << ')'; + break; + + case TM_ID: + oss << " (track id=" << _trackId << ')'; + break; + + case TM_WILDCARD: + oss << " (all tracks)"; + break; + + default: + return herrf( "track(s) not specified\n" ); + } + + verbose1f( "%s\n", oss.str().c_str() ); + if( dryrunAbort() ) + return SUCCESS; + + job.fileHandle = MP4Modify( job.file.c_str(), _debugVerbosity ); + if( job.fileHandle == MP4_INVALID_FILE_HANDLE ) + return herrf( "unable to open for write: %s\n", job.file.c_str() ); + + switch( _trackMode ) { + case TM_INDEX: + if( qtff::ColorParameterBox::remove( job.fileHandle, _trackIndex )) + return herrf( "unable to remove colr-box\n" ); + break; + + case TM_ID: + if( qtff::ColorParameterBox::remove( job.fileHandle, _trackId )) + return herrf( "unable to remove colr-box\n" ); + break; + + default: + case TM_WILDCARD: + { + qtff::ColorParameterBox::ItemList itemList; + if( qtff::ColorParameterBox::list( job.fileHandle, itemList )) + return herrf( "unable to fetch list of colr-boxes" ); + + _trackMode = TM_INDEX; + const qtff::ColorParameterBox::ItemList::size_type max = itemList.size(); + for( qtff::ColorParameterBox::ItemList::size_type i = 0; i < max; i++ ) { + const qtff::ColorParameterBox::IndexedItem& xitem = itemList[i]; + _trackIndex = xitem.trackIndex; + actionColorParameterRemove( job ); + } + break; + } + } + + return SUCCESS; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +TrackUtility::actionColorParameterSet( JobContext& job ) +{ + ostringstream oss; + oss << "setting colr-box(" << _colorParameterItem.convertToCSV() << ") -> " << job.file; + + switch( _trackMode ) { + case TM_INDEX: + oss << " (track index=" << _trackIndex << ')'; + break; + + case TM_ID: + oss << " (track id=" << _trackId << ')'; + break; + + default: + case TM_WILDCARD: + return herrf( "track not specified\n" ); + } + + verbose1f( "%s\n", oss.str().c_str() ); + if( dryrunAbort() ) + return SUCCESS; + + job.fileHandle = MP4Modify( job.file.c_str(), _debugVerbosity ); + if( job.fileHandle == MP4_INVALID_FILE_HANDLE ) + return herrf( "unable to open for write: %s\n", job.file.c_str() ); + + switch( _trackMode ) { + default: + case TM_INDEX: + if( qtff::ColorParameterBox::set( job.fileHandle, _trackIndex, _colorParameterItem )) + return herrf( "unable to set colr-box\n" ); + break; + + case TM_ID: + if( qtff::ColorParameterBox::set( job.fileHandle, _trackId, _colorParameterItem )) + return herrf( "unable to set colr-box\n" ); + break; + } + + return SUCCESS; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +TrackUtility::actionList( JobContext& job ) +{ + if( _jobTotal > 1 ) + verbose1f( "file %u of %u: %s\n", _jobCount+1, _jobTotal, job.file.c_str() ); + + ostringstream report; + + job.fileHandle = MP4Read( job.file.c_str(), _debugVerbosity ); + if( job.fileHandle == MP4_INVALID_FILE_HANDLE ) + return herrf( "unable to open for read: %s\n", job.file.c_str() ); + + switch( _trackMode ) { + case TM_INDEX: + return actionListSingle( job, _trackIndex ); + + case TM_ID: + return actionListSingle( job, MP4FindTrackIndex( job.fileHandle, _trackId )); + + case TM_WILDCARD: + default: + { + bool result = SUCCESS; + const uint16_t trackc = static_cast<uint16_t>( MP4GetNumberOfTracks( job.fileHandle )); + for( uint16_t i = 0; i < trackc; i++ ) { + if( actionListSingle( job, i )) + result = FAILURE; + } + return result; + } + } +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +TrackUtility::actionListSingle( JobContext& job, uint16_t index ) +{ + TrackModifier tm( job.fileHandle, index ); + + ostringstream report; + tm.dump( report, ( _jobTotal > 1 ? " " : "" )); + + verbose1f( "%s", report.str().c_str() ); + return false; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +TrackUtility::actionPictureAspectRatioAdd( JobContext& job ) +{ + ostringstream oss; + oss << "adding pasp-box(" << _pictureAspectRatioItem.convertToCSV() << ") -> " << job.file; + + switch( _trackMode ) { + case TM_INDEX: + oss << " (track index=" << _trackIndex << ')'; + break; + + case TM_ID: + oss << " (track id=" << _trackId << ')'; + break; + + default: + case TM_WILDCARD: + return herrf( "track not specified\n" ); + } + + verbose1f( "%s\n", oss.str().c_str() ); + if( dryrunAbort() ) + return SUCCESS; + + job.fileHandle = MP4Modify( job.file.c_str(), _debugVerbosity ); + if( job.fileHandle == MP4_INVALID_FILE_HANDLE ) + return herrf( "unable to open for write: %s\n", job.file.c_str() ); + + switch( _trackMode ) { + default: + case TM_INDEX: + if( qtff::PictureAspectRatioBox::add( job.fileHandle, _trackIndex, _pictureAspectRatioItem )) + return herrf( "unable to add pasp-box\n" ); + break; + + case TM_ID: + if( qtff::PictureAspectRatioBox::add( job.fileHandle, _trackId, _pictureAspectRatioItem )) + return herrf( "unable to add pasp-box\n" ); + break; + } + + return SUCCESS; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +TrackUtility::actionPictureAspectRatioList( JobContext& job ) +{ + job.fileHandle = MP4Read( job.file.c_str(), _debugVerbosity ); + if( job.fileHandle == MP4_INVALID_FILE_HANDLE ) + return herrf( "unable to open for read: %s\n", job.file.c_str() ); + + ostringstream report; + + const int widx = 3; + const int wid = 3; + const int wtype = 8; + const int wparm = 6; + const string sep = " "; + + if( _jobCount == 0 ) { + report << setw(widx) << right << "IDX" + << sep << setw(wid) << "ID" + << sep << setw(wtype) << left << "TYPE" + << sep << setw(wparm) << right << "hSPACE" + << sep << setw(wparm) << right << "vSPACE" + << sep << setw(0) << "FILE" + << '\n'; + + report << setfill('-') << setw(70) << "" << setfill(' ') << '\n'; + } + + qtff::PictureAspectRatioBox::ItemList itemList; + if( qtff::PictureAspectRatioBox::list( job.fileHandle, itemList )) + return herrf( "unable to fetch list of pasp-boxes" ); + + const qtff::PictureAspectRatioBox::ItemList::size_type max = itemList.size(); + for( qtff::PictureAspectRatioBox::ItemList::size_type i = 0; i < max; i++ ) { + const qtff::PictureAspectRatioBox::IndexedItem& xitem = itemList[i]; + + const char* type = MP4GetTrackType( job.fileHandle, xitem.trackId ); + if( !type) + type = "unknown"; + + report << right << setw(widx) << xitem.trackIndex + << sep << setw(wid) << xitem.trackId + << sep << setw(wtype) << left << toStringTrackType( type ) + << sep << setw(wparm) << right << xitem.item.hSpacing + << sep << setw(wparm) << right << xitem.item.vSpacing; + + if( i == 0 ) + report << sep << setw(0) << job.file; + + report << '\n'; + } + + verbose1f( "%s", report.str().c_str() ); + return SUCCESS; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +TrackUtility::actionPictureAspectRatioRemove( JobContext& job ) +{ + ostringstream oss; + oss << "removing pasp-box from " << job.file; + + switch( _trackMode ) { + case TM_INDEX: + oss << " (track index=" << _trackIndex << ')'; + break; + + case TM_ID: + oss << " (track id=" << _trackId << ')'; + break; + + default: + case TM_WILDCARD: + oss << " (all tracks)"; + } + + verbose1f( "%s\n", oss.str().c_str() ); + if( dryrunAbort() ) + return SUCCESS; + + job.fileHandle = MP4Modify( job.file.c_str(), _debugVerbosity ); + if( job.fileHandle == MP4_INVALID_FILE_HANDLE ) + return herrf( "unable to open for write: %s\n", job.file.c_str() ); + + switch( _trackMode ) { + case TM_INDEX: + if( qtff::PictureAspectRatioBox::remove( job.fileHandle, _trackIndex )) + return herrf( "unable to remove pasp-box\n" ); + break; + + case TM_ID: + if( qtff::PictureAspectRatioBox::remove( job.fileHandle, _trackId )) + return herrf( "unable to remove pasp-box\n" ); + break; + + default: + case TM_WILDCARD: + { + qtff::PictureAspectRatioBox::ItemList itemList; + if( qtff::PictureAspectRatioBox::list( job.fileHandle, itemList )) + return herrf( "unable to fetch list of pasp-boxes" ); + + _trackMode = TM_INDEX; + const qtff::PictureAspectRatioBox::ItemList::size_type max = itemList.size(); + for( qtff::PictureAspectRatioBox::ItemList::size_type i = 0; i < max; i++ ) { + const qtff::PictureAspectRatioBox::IndexedItem& xitem = itemList[i]; + _trackIndex = xitem.trackIndex; + actionPictureAspectRatioRemove( job ); + } + break; + } + } + + return SUCCESS; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +TrackUtility::actionPictureAspectRatioSet( JobContext& job ) +{ + ostringstream oss; + oss << "setting pasp-box(" << _pictureAspectRatioItem.convertToCSV() << ") -> " << job.file; + + switch( _trackMode ) { + case TM_INDEX: + oss << " (track index=" << _trackIndex << ')'; + break; + + case TM_ID: + oss << " (track id=" << _trackId << ')'; + break; + + default: + case TM_WILDCARD: + return herrf( "track not specified\n" ); + } + + verbose1f( "%s\n", oss.str().c_str() ); + if( dryrunAbort() ) + return SUCCESS; + + job.fileHandle = MP4Modify( job.file.c_str(), _debugVerbosity ); + if( job.fileHandle == MP4_INVALID_FILE_HANDLE ) + return herrf( "unable to open for write: %s\n", job.file.c_str() ); + + switch( _trackMode ) { + default: + case TM_INDEX: + if( qtff::PictureAspectRatioBox::set( job.fileHandle, _trackIndex, _pictureAspectRatioItem )) + return herrf( "unable to set pasp-box\n" ); + break; + + case TM_ID: + if( qtff::PictureAspectRatioBox::set( job.fileHandle, _trackId, _pictureAspectRatioItem )) + return herrf( "unable to set pasp-box\n" ); + break; + } + + return SUCCESS; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +TrackUtility::actionTrackModifierRemove( JobContext& job ) +{ + ostringstream oss; + oss << "removing " << _actionTrackModifierRemove_name << " -> " << job.file; + + switch( _trackMode ) { + case TM_INDEX: + oss << " (track index=" << _trackIndex << ')'; + break; + + case TM_ID: + oss << " (track id=" << _trackId << ')'; + break; + + default: + case TM_WILDCARD: + return herrf( "track not specified\n" ); + } + + verbose1f( "%s\n", oss.str().c_str() ); + if( dryrunAbort() ) + return SUCCESS; + + job.fileHandle = MP4Modify( job.file.c_str(), _debugVerbosity ); + if( job.fileHandle == MP4_INVALID_FILE_HANDLE ) + return herrf( "unable to open for write: %s\n", job.file.c_str() ); + + if( _trackMode == TM_ID ) + _trackIndex = MP4FindTrackIndex( job.fileHandle, _trackId ); + + TrackModifier tm( job.fileHandle, _trackIndex ); + (tm.*_actionTrackModifierRemove_function)(); + + return SUCCESS; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +TrackUtility::actionTrackModifierSet( JobContext& job ) +{ + ostringstream oss; + oss << "setting " << _actionTrackModifierSet_name << "=" << _actionTrackModifierSet_value << " -> " << job.file; + + switch( _trackMode ) { + case TM_INDEX: + oss << " (track index=" << _trackIndex << ')'; + break; + + case TM_ID: + oss << " (track id=" << _trackId << ')'; + break; + + default: + case TM_WILDCARD: + return herrf( "track not specified\n" ); + } + + verbose1f( "%s\n", oss.str().c_str() ); + if( dryrunAbort() ) + return SUCCESS; + + job.fileHandle = MP4Modify( job.file.c_str(), _debugVerbosity ); + if( job.fileHandle == MP4_INVALID_FILE_HANDLE ) + return herrf( "unable to open for write: %s\n", job.file.c_str() ); + + if( _trackMode == TM_ID ) + _trackIndex = MP4FindTrackIndex( job.fileHandle, _trackId ); + + TrackModifier tm( job.fileHandle, _trackIndex ); + (tm.*_actionTrackModifierSet_function)( _actionTrackModifierSet_value ); + + return SUCCESS; +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +TrackUtility::utility_job( JobContext& job ) +{ + if( !_action ) + return herrf( "no action specified\n" ); + + return (this->*_action)( job ); +} + +/////////////////////////////////////////////////////////////////////////////// + +bool +TrackUtility::utility_option( int code, bool& handled ) +{ + handled = true; + + switch( code ) { + case LC_TRACK_WILDCARD: + _trackMode = TM_WILDCARD; + break; + + case LC_TRACK_INDEX: + { + _trackMode = TM_INDEX; + istringstream iss( prog::optarg ); + iss >> _trackIndex; + if( iss.rdstate() != ios::eofbit ) + return herrf( "invalid track index: %s\n", prog::optarg ); + break; + } + + case LC_TRACK_ID: + { + _trackMode = TM_ID; + istringstream iss( prog::optarg ); + iss >> _trackId; + if( iss.rdstate() != ios::eofbit ) + return herrf( "invalid track id: %s\n", prog::optarg ); + break; + } + + case LC_LIST: + _action = &TrackUtility::actionList; + break; + + case LC_COLR_PARMS: + _colorParameterItem.convertFromCSV( prog::optarg ); + break; + + case LC_COLR_PARM_HD: + _colorParameterItem.primariesIndex = 1; + _colorParameterItem.transferFunctionIndex = 1; + _colorParameterItem.matrixIndex = 1; + break; + + case LC_COLR_PARM_SD: + _colorParameterItem.primariesIndex = 6; + _colorParameterItem.transferFunctionIndex = 1; + _colorParameterItem.matrixIndex = 6; + break; + + case LC_COLR_LIST: + _action = &TrackUtility::actionColorParameterList; + break; + + case LC_ENABLED: + _action = &TrackUtility::actionTrackModifierSet; + _actionTrackModifierSet_function = &TrackModifier::setEnabled; + _actionTrackModifierSet_name = "enabled"; + _actionTrackModifierSet_value = prog::optarg; + break; + + case LC_INMOVIE: + _action = &TrackUtility::actionTrackModifierSet; + _actionTrackModifierSet_function = &TrackModifier::setInMovie; + _actionTrackModifierSet_name = "inMovie"; + _actionTrackModifierSet_value = prog::optarg; + break; + + case LC_INPREVIEW: + _action = &TrackUtility::actionTrackModifierSet; + _actionTrackModifierSet_function = &TrackModifier::setInPreview; + _actionTrackModifierSet_name = "inPreview"; + _actionTrackModifierSet_value = prog::optarg; + break; + + case LC_LAYER: + _action = &TrackUtility::actionTrackModifierSet; + _actionTrackModifierSet_function = &TrackModifier::setLayer; + _actionTrackModifierSet_name = "layer"; + _actionTrackModifierSet_value = prog::optarg; + break; + + case LC_ALTGROUP: + _action = &TrackUtility::actionTrackModifierSet; + _actionTrackModifierSet_function = &TrackModifier::setAlternateGroup; + _actionTrackModifierSet_name = "alternateGroup"; + _actionTrackModifierSet_value = prog::optarg; + break; + + case LC_VOLUME: + _action = &TrackUtility::actionTrackModifierSet; + _actionTrackModifierSet_function = &TrackModifier::setVolume; + _actionTrackModifierSet_name = "volume"; + _actionTrackModifierSet_value = prog::optarg; + break; + + case LC_WIDTH: + _action = &TrackUtility::actionTrackModifierSet; + _actionTrackModifierSet_function = &TrackModifier::setWidth; + _actionTrackModifierSet_name = "width"; + _actionTrackModifierSet_value = prog::optarg; + break; + + case LC_HEIGHT: + _action = &TrackUtility::actionTrackModifierSet; + _actionTrackModifierSet_function = &TrackModifier::setHeight; + _actionTrackModifierSet_name = "height"; + _actionTrackModifierSet_value = prog::optarg; + break; + + case LC_LANGUAGE: + _action = &TrackUtility::actionTrackModifierSet; + _actionTrackModifierSet_function = &TrackModifier::setLanguage; + _actionTrackModifierSet_name = "langauge"; + _actionTrackModifierSet_value = prog::optarg; + break; + + case LC_HDLRNAME: + _action = &TrackUtility::actionTrackModifierSet; + _actionTrackModifierSet_function = &TrackModifier::setHandlerName; + _actionTrackModifierSet_name = "handlerName"; + _actionTrackModifierSet_value = prog::optarg; + break; + + case LC_UDTANAME: + _action = &TrackUtility::actionTrackModifierSet; + _actionTrackModifierSet_function = &TrackModifier::setUserDataName; + _actionTrackModifierSet_name = "userDataName"; + _actionTrackModifierSet_value = prog::optarg; + break; + + case LC_UDTANAME_R: + _action = &TrackUtility::actionTrackModifierRemove; + _actionTrackModifierRemove_function = &TrackModifier::removeUserDataName; + _actionTrackModifierRemove_name = "userDataName"; + break; + + case LC_COLR_ADD: + _action = &TrackUtility::actionColorParameterAdd; + break; + + case LC_COLR_SET: + _action = &TrackUtility::actionColorParameterSet; + break; + + case LC_COLR_REMOVE: + _action = &TrackUtility::actionColorParameterRemove; + break; + + case LC_PASP_PARMS: + _pictureAspectRatioItem.convertFromCSV( prog::optarg ); + break; + + case LC_PASP_LIST: + _action = &TrackUtility::actionPictureAspectRatioList; + break; + + case LC_PASP_ADD: + _action = &TrackUtility::actionPictureAspectRatioAdd; + break; + + case LC_PASP_SET: + _action = &TrackUtility::actionPictureAspectRatioSet; + break; + + case LC_PASP_REMOVE: + _action = &TrackUtility::actionPictureAspectRatioRemove; + break; + + default: + handled = false; + break; + } + + return SUCCESS; +} + +/////////////////////////////////////////////////////////////////////////////// + +string +toStringTrackType( string code ) +{ + if( !code.compare( "vide" )) // 14496-12 + return "video"; + if( !code.compare( "soun" )) // 14496-12 + return "audio"; + if( !code.compare( "hint" )) // 14496-12 + return "hint"; + + if( !code.compare( "text" )) // QTFF + return "text"; + if( !code.compare( "tmcd" )) // QTFF + return "timecode"; + + if( !code.compare( "subt" )) // QTFF + return "subtitle"; + + return string( "(" ) + code + ")"; +} + +/////////////////////////////////////////////////////////////////////////////// + +}} // namespace mp4v2::util + +/////////////////////////////////////////////////////////////////////////////// + +extern "C" +int main( int argc, char** argv ) +{ + mp4v2::util::TrackUtility util( argc, argv ); + return util.process(); +} diff --git a/util/mp4trackdump.cpp b/util/mp4trackdump.cpp new file mode 100644 index 0000000..78085bf --- /dev/null +++ b/util/mp4trackdump.cpp @@ -0,0 +1,241 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MPEG4IP. + * + * The Initial Developer of the Original Code is Cisco Systems Inc. + * Portions created by Cisco Systems Inc. are + * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. + * + * Contributor(s): + * Dave Mackie dmackie@cisco.com + */ + +// N.B. mp4extract just extracts tracks/samples from an mp4 file +// For many track types this is insufficient to reconsruct a valid +// elementary stream (ES). Use "mp4creator -extract=<trackId>" if +// you need the ES reconstructed. + +#include "util/impl.h" + +using namespace mp4v2::util; + +char* ProgName; +char* Mp4PathName; +char* Mp4FileName; + +static void DumpTrack ( MP4FileHandle mp4file, MP4TrackId tid ) +{ + uint32_t numSamples; + MP4SampleId sid; + MP4Duration time; + uint32_t timescale; + uint64_t msectime; + + uint64_t sectime, mintime, hrtime; + + numSamples = MP4GetTrackNumberOfSamples( mp4file, tid ); + timescale = MP4GetTrackTimeScale( mp4file, tid ); + printf( "mp4file %s, track %d, samples %d, timescale %d\n", + Mp4FileName, tid, numSamples, timescale ); + + for ( sid = 1; sid <= numSamples; sid++ ) { + time = MP4GetSampleTime( mp4file, tid, sid ); + msectime = time; + msectime *= UINT64_C( 1000 ); + msectime /= timescale; + if ( msectime == 0 ) { + hrtime = mintime = sectime = UINT64_C( 0 ); + } + else { + hrtime = msectime / UINT64_C( 3600 * 1000 ); + msectime -= hrtime * UINT64_C( 3600 * 1000 ); + mintime = msectime / UINT64_C( 60 * 1000 ); + msectime -= ( mintime * UINT64_C( 60 * 1000 ) ); + sectime = msectime / UINT64_C( 1000 ); + msectime -= sectime * UINT64_C( 1000 ); + } + + printf( "sampleId %6d, size %5u duration %8" PRIu64 " time %8" PRIu64 " %02" PRIu64 ":%02" PRIu64 ":%02" PRIu64 ".%03" PRIu64 " %c\n", + sid, MP4GetSampleSize( mp4file, tid, sid ), + MP4GetSampleDuration( mp4file, tid, sid ), + time, hrtime, mintime, sectime, msectime, + MP4GetSampleSync( mp4file, tid, sid ) == 1 ? 'S' : ' ' ); + } +} + +extern "C" int main( int argc, char** argv ) +{ + const char* const usageString = + "[-l] [-t <track-id>] [-s <sample-id>] [-v [<level>]] <file-name>"; + MP4TrackId trackId = MP4_INVALID_TRACK_ID; + MP4SampleId sampleId = MP4_INVALID_SAMPLE_ID; + uint32_t verbosity = MP4_DETAILS_ERROR; + + /* begin processing command line */ + ProgName = argv[0]; + while ( true ) { + int c = -1; + int option_index = 0; + static const prog::Option long_options[] = { + { "track", prog::Option::REQUIRED_ARG, 0, 't' }, + { "sample", prog::Option::REQUIRED_ARG, 0, 's' }, + { "verbose", prog::Option::OPTIONAL_ARG, 0, 'v' }, + { "version", prog::Option::NO_ARG, 0, 'V' }, + { NULL, prog::Option::NO_ARG, 0, 0 } + }; + + c = prog::getOptionSingle( argc, argv, "t:v::V", long_options, &option_index ); + + if ( c == -1 ) + break; + + switch ( c ) { + case 's': + if ( sscanf( prog::optarg, "%u", &sampleId ) != 1 ) { + fprintf( stderr, "%s: bad sample-id specified: %s\n", + ProgName, prog::optarg ); + exit( 1 ); + } + break; + case 't': + if ( sscanf( prog::optarg, "%u", &trackId ) != 1 ) { + fprintf( stderr, + "%s: bad track-id specified: %s\n", + ProgName, prog::optarg ); + exit( 1 ); + } + break; + case 'v': + verbosity |= MP4_DETAILS_READ; + if ( prog::optarg ) { + uint32_t level; + if ( sscanf( prog::optarg, "%u", &level ) == 1 ) { + if ( level >= 2 ) { + verbosity |= MP4_DETAILS_TABLE; + } + if ( level >= 3 ) { + verbosity |= MP4_DETAILS_SAMPLE; + } + if ( level >= 4 ) { + verbosity = MP4_DETAILS_ALL; + } + } + } + break; + case '?': + fprintf( stderr, "usage: %s %s\n", ProgName, usageString ); + exit( 0 ); + case 'V': + fprintf( stderr, "%s - %s\n", + ProgName, MP4V2_PROJECT_name_formal ); + exit( 0 ); + default: + fprintf( stderr, "%s: unknown option specified, ignoring: %c\n", + ProgName, c ); + } + } + + /* check that we have at least one non-option argument */ + if ( ( argc - prog::optind ) < 1 ) { + fprintf( stderr, "usage: %s %s\n", ProgName, usageString ); + exit( 1 ); + } + + if ( verbosity ) { + fprintf( stderr, "%s version %s\n", ProgName, MP4V2_PROJECT_version ); + } + + /* point to the specified file names */ + Mp4PathName = argv[prog::optind++]; + + char* lastSlash = strrchr( Mp4PathName, '/' ); + if ( lastSlash ) { + Mp4FileName = lastSlash + 1; + } + else { + Mp4FileName = Mp4PathName; + } + + /* warn about extraneous non-option arguments */ + if ( prog::optind < argc ) { + fprintf( stderr, "%s: unknown options specified, ignoring: ", ProgName ); + while ( prog::optind < argc ) { + fprintf( stderr, "%s ", argv[prog::optind++] ); + } + fprintf( stderr, "\n" ); + } + + /* end processing of command line */ + + + MP4FileHandle mp4File = MP4Read( Mp4PathName, verbosity ); + + if ( !mp4File ) { + exit( 1 ); + } + + if ( sampleId != MP4_INVALID_SAMPLE_ID ) { + if ( trackId == 0 ) { + fprintf( stderr, "%s: Must specify track for sample\n", ProgName ); + return -1; + } + if ( sampleId > MP4GetTrackNumberOfSamples( mp4File, trackId ) ) { + fprintf( stderr, "%s: Sample number %u is past end %u\n", + ProgName, sampleId, MP4GetTrackNumberOfSamples( mp4File, trackId ) ); + return -1; + } + uint32_t sample_size = MP4GetTrackMaxSampleSize( mp4File, trackId ); + uint8_t *sample = ( uint8_t * )malloc( sample_size ); + MP4Timestamp sampleTime; + MP4Duration sampleDuration, sampleRenderingOffset; + uint32_t this_size = sample_size; + bool isSyncSample; + bool ret = MP4ReadSample( mp4File, + trackId, + sampleId, + &sample, + &this_size, + &sampleTime, + &sampleDuration, + &sampleRenderingOffset, + &isSyncSample ); + if ( ret == false ) { + fprintf( stderr, "Sample read error\n" ); + return -1; + } + printf( "Track %u, Sample %u, Length %u\n", + trackId, sampleId, this_size ); + + for ( uint32_t ix = 0; ix < this_size; ix++ ) { + if ( ( ix % 16 ) == 0 ) printf( "\n%04u ", ix ); + printf( "%02x ", sample[ix] ); + } + printf( "\n" ); + } + else { + if ( trackId == 0 ) { + uint32_t numTracks = MP4GetNumberOfTracks( mp4File ); + + for ( uint32_t i = 0; i < numTracks; i++ ) { + trackId = MP4FindTrackId( mp4File, i ); + DumpTrack( mp4File, trackId ); + } + } + else { + DumpTrack( mp4File, trackId ); + } + } + + MP4Close( mp4File ); + + return( 0 ); +} diff --git a/vstudio9.0/include/mp4v2/project.h b/vstudio9.0/include/mp4v2/project.h new file mode 100644 index 0000000..8141382 --- /dev/null +++ b/vstudio9.0/include/mp4v2/project.h @@ -0,0 +1,30 @@ +#ifndef MP4V2_PROJECT_H +#define MP4V2_PROJECT_H + +/*****************************************************************************/ + +#define MP4V2_PROJECT_name "MP4v2" +#define MP4V2_PROJECT_name_lower "mp4v2" +#define MP4V2_PROJECT_name_upper "MP4V2" +#define MP4V2_PROJECT_name_formal "MP4v2 1.9.0" +#define MP4V2_PROJECT_url_website "http://code.google.com/p/mp4v2" +#define MP4V2_PROJECT_url_downloads "http://code.google.com/p/mp4v2/downloads/list" +#define MP4V2_PROJECT_url_discussion "http://groups.google.com/group/mp4v2" +#define MP4V2_PROJECT_irc "irc://irc.freenode.net/handbrake" +#define MP4V2_PROJECT_bugreport "<eddyg@myreflection.org>" +#define MP4V2_PROJECT_version "1.9.0" +#define MP4V2_PROJECT_version_hex 0x00010900 +#define MP4V2_PROJECT_version_major 1 +#define MP4V2_PROJECT_version_minor 9 +#define MP4V2_PROJECT_version_point 0 +#define MP4V2_PROJECT_repo_url "https://mp4v2.googlecode.com/svn/releases/1.9.0" +#define MP4V2_PROJECT_repo_root "https://mp4v2.googlecode.com/svn" +#define MP4V2_PROJECT_repo_uuid "6e6572fa-98a6-11dd-ad9f-f77439c74b79" +#define MP4V2_PROJECT_repo_rev 332 +#define MP4V2_PROJECT_repo_date "2009-05-21 14:39:25 -0400 (Thu, 21 May 2009)" +#define MP4V2_PROJECT_repo_type "stable" +#define MP4V2_PROJECT_build "Thu May 21 14:41:21 EDT 2009" + +/*****************************************************************************/ + +#endif /* MP4V2_PROJECT_H */ diff --git a/vstudio9.0/libmp4v2/libmp4v2.vcproj b/vstudio9.0/libmp4v2/libmp4v2.vcproj new file mode 100644 index 0000000..15fd1ae --- /dev/null +++ b/vstudio9.0/libmp4v2/libmp4v2.vcproj @@ -0,0 +1,910 @@ +<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9.00"
+ Name="libmp4v2"
+ ProjectGUID="{C49FF7C5-7F9C-49F0-AAE2-AC15FB3D9EBF}"
+ RootNamespace="libmp4v2"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="4"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""$(ProjectDir)\..\..\include";"$(ProjectDir)\..\include";"$(ProjectDir)\..\..""
+ PreprocessorDefinitions="_CRT_SECURE_NO_WARNINGS"
+ RuntimeLibrary="3"
+ EnableEnhancedInstructionSet="1"
+ UsePrecompiledHeader="0"
+ WarningLevel="1"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="4"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ EnableIntrinsicFunctions="true"
+ AdditionalIncludeDirectories=""$(ProjectDir)\..\..\include";"$(ProjectDir)\..\include";"$(ProjectDir)\..\..""
+ PreprocessorDefinitions="_CRT_SECURE_NO_WARNINGS"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="true"
+ EnableEnhancedInstructionSet="1"
+ UsePrecompiledHeader="0"
+ WarningLevel="1"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="include"
+ >
+ <File
+ RelativePath="..\..\include\mp4v2\chapter.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\include\mp4v2\file.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\include\mp4v2\file_prop.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\include\mp4v2\general.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\include\mp4v2\isma.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\include\mp4v2\itmf_generic.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\include\mp4v2\itmf_tags.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\include\mp4v2\meta.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\include\mp4v2\mp4v2.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\include\mp4v2\platform.h"
+ >
+ </File>
+ <File
+ RelativePath="..\include\mp4v2\project.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\include\mp4v2\sample.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\include\mp4v2\streaming.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\include\mp4v2\track.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\include\mp4v2\track_prop.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="impl"
+ >
+ <File
+ RelativePath="..\..\src\3gp.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_ac3.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_amr.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_avc1.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_avcC.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_chpl.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_colr.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_d263.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_dac3.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_damr.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_dref.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_elst.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_enca.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_encv.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_free.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_ftab.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_ftyp.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_gmin.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_hdlr.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_hinf.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_hnti.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_href.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_mdat.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_mdhd.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_meta.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_mp4s.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_mp4v.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_mvhd.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_nmhd.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_ohdr.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_pasp.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_root.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_rtp.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_s263.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_sdp.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_sdtp.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_smi.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_sound.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_standard.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_stbl.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_stdp.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_stsc.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_stsd.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_stsz.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_stz2.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_text.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_tfhd.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_tkhd.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_treftype.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_trun.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_tx3g.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_udta.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_url.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_urn.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_uuid.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_video.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atom_vmhd.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\atoms.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\cmeta.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\descriptors.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\descriptors.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\enum.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\enum.tcc"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\exception.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\exception.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\impl.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\isma.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\mp4.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\mp4array.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\mp4atom.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\mp4atom.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\mp4container.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\mp4container.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\mp4descriptor.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\mp4descriptor.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\mp4error.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\mp4file.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\mp4file.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\mp4file_io.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\mp4info.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\mp4meta.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\mp4property.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\mp4property.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\mp4track.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\mp4track.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\mp4util.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\mp4util.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\ocidescriptors.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\ocidescriptors.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\odcommands.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\odcommands.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\qosqualifiers.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\qosqualifiers.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\rtphint.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\rtphint.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\src.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\text.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\text.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\util.h"
+ >
+ </File>
+ <Filter
+ Name="bmff"
+ >
+ <File
+ RelativePath="..\..\src\bmff\bmff.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\bmff\impl.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\bmff\typebmff.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\bmff\typebmff.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="itmf"
+ >
+ <File
+ RelativePath="..\..\src\itmf\CoverArtBox.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\itmf\CoverArtBox.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\itmf\generic.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\itmf\generic.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\itmf\impl.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\itmf\itmf.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\itmf\Tags.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\itmf\Tags.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\itmf\type.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\itmf\type.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="qtff"
+ >
+ <File
+ RelativePath="..\..\src\qtff\coding.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\qtff\coding.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\qtff\ColorParameterBox.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\qtff\ColorParameterBox.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\qtff\impl.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\qtff\PictureAspectRatioBox.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\qtff\PictureAspectRatioBox.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\qtff\qtff.h"
+ >
+ </File>
+ </Filter>
+ </Filter>
+ <Filter
+ Name="platform"
+ >
+ <File
+ RelativePath="..\..\libplatform\endian.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\libplatform\impl.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\libplatform\platform.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\libplatform\platform_base.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\libplatform\platform_win32.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\libplatform\warning.h"
+ >
+ </File>
+ <Filter
+ Name="io"
+ >
+ <File
+ RelativePath="..\..\libplatform\io\File.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\libplatform\io\File.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\libplatform\io\File_win32.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\libplatform\io\FileSystem.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\libplatform\io\FileSystem.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\libplatform\io\FileSystem_win32.cpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="number"
+ >
+ <File
+ RelativePath="..\..\libplatform\number\random.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\libplatform\number\random_win32.cpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="process"
+ >
+ <File
+ RelativePath="..\..\libplatform\process\process.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\libplatform\process\process_win32.cpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="prog"
+ >
+ <File
+ RelativePath="..\..\libplatform\prog\option.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\libplatform\prog\option.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="sys"
+ >
+ <File
+ RelativePath="..\..\libplatform\sys\error.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\libplatform\sys\error.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="time"
+ >
+ <File
+ RelativePath="..\..\libplatform\time\time.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\libplatform\time\time.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\libplatform\time\time_win32.cpp"
+ >
+ </File>
+ </Filter>
+ </Filter>
+ <Filter
+ Name="util"
+ >
+ <File
+ RelativePath="..\..\libutil\crc.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\libutil\crc.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\libutil\Database.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\libutil\Database.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\libutil\impl.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\libutil\other.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\libutil\other.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\libutil\Timecode.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\libutil\Timecode.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\libutil\TrackModifier.cpp"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ DisableSpecificWarnings="4355"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ DisableSpecificWarnings="4355"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\..\libutil\TrackModifier.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\libutil\util.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\libutil\Utility.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\libutil\Utility.h"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/vstudio9.0/mp4art/mp4art.vcproj b/vstudio9.0/mp4art/mp4art.vcproj new file mode 100644 index 0000000..42d54ca --- /dev/null +++ b/vstudio9.0/mp4art/mp4art.vcproj @@ -0,0 +1,324 @@ +<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9.00"
+ Name="mp4art"
+ ProjectGUID="{E6E4F05D-BEDE-4FB4-9C68-ADA2605E1389}"
+ RootNamespace="mp4art"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""$(SolutionDir)\..\include";"$(SolutionDir)\include";"$(SolutionDir)\..""
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ AdditionalIncludeDirectories=""$(SolutionDir)\..\include";"$(SolutionDir)\include";"$(SolutionDir)\..""
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release Static|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ AdditionalIncludeDirectories=""$(SolutionDir)\..\include";"$(SolutionDir)\include";"$(SolutionDir)\..""
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Debug Static|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""$(SolutionDir)\..\include";"$(SolutionDir)\include";"$(SolutionDir)\..""
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <File
+ RelativePath="..\..\util\mp4art.cpp"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/vstudio9.0/mp4chaps/mp4chaps.vcproj b/vstudio9.0/mp4chaps/mp4chaps.vcproj new file mode 100644 index 0000000..0107b14 --- /dev/null +++ b/vstudio9.0/mp4chaps/mp4chaps.vcproj @@ -0,0 +1,324 @@ +<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9.00"
+ Name="mp4chaps"
+ ProjectGUID="{94C763EE-E990-4D5B-BF9D-148FF55DE1C1}"
+ RootNamespace="mp4chaps"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""$(SolutionDir)\..\include";"$(SolutionDir)\include";"$(SolutionDir)\..""
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ AdditionalIncludeDirectories=""$(SolutionDir)\..\include";"$(SolutionDir)\include";"$(SolutionDir)\..""
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release Static|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ AdditionalIncludeDirectories=""$(SolutionDir)\..\include";"$(SolutionDir)\include";"$(SolutionDir)\..""
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Debug Static|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""$(SolutionDir)\..\include";"$(SolutionDir)\include";"$(SolutionDir)\..""
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <File
+ RelativePath="..\..\util\mp4chaps.cpp"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/vstudio9.0/mp4extract/mp4extract.vcproj b/vstudio9.0/mp4extract/mp4extract.vcproj new file mode 100644 index 0000000..4661298 --- /dev/null +++ b/vstudio9.0/mp4extract/mp4extract.vcproj @@ -0,0 +1,324 @@ +<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9.00"
+ Name="mp4extract"
+ ProjectGUID="{7141244A-EB2F-4CAB-8025-BA1316A3C306}"
+ RootNamespace="mp4extract"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""$(SolutionDir)\..\include";"$(SolutionDir)\include";"$(SolutionDir)\..""
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ AdditionalIncludeDirectories=""$(SolutionDir)\..\include";"$(SolutionDir)\include";"$(SolutionDir)\..""
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release Static|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ AdditionalIncludeDirectories=""$(SolutionDir)\..\include";"$(SolutionDir)\include";"$(SolutionDir)\..""
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Debug Static|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""$(SolutionDir)\..\include";"$(SolutionDir)\include";"$(SolutionDir)\..""
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <File
+ RelativePath="..\..\util\mp4extract.cpp"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/vstudio9.0/mp4file/mp4file.vcproj b/vstudio9.0/mp4file/mp4file.vcproj new file mode 100644 index 0000000..d8c4660 --- /dev/null +++ b/vstudio9.0/mp4file/mp4file.vcproj @@ -0,0 +1,310 @@ +<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="mp4file"
+ ProjectGUID="{C97FBF72-8249-4782-A34A-BEA222E9A257}"
+ RootNamespace="mp4file"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""$(SolutionDir)\..\include";"$(SolutionDir)\include";"$(SolutionDir)\..""
+ PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ AdditionalIncludeDirectories=""$(SolutionDir)\..\include";"$(SolutionDir)\include";"$(SolutionDir)\..""
+ PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release Static|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ AdditionalIncludeDirectories=""$(SolutionDir)\..\include";"$(SolutionDir)\include";"$(SolutionDir)\..""
+ PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ GenerateDebugInformation="true"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Debug Static|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""$(SolutionDir)\..\include";"$(SolutionDir)\include";"$(SolutionDir)\..""
+ PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ GenerateDebugInformation="true"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <File
+ RelativePath="..\..\util\mp4file.cpp"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/vstudio9.0/mp4info/mp4info.vcproj b/vstudio9.0/mp4info/mp4info.vcproj new file mode 100644 index 0000000..b66d435 --- /dev/null +++ b/vstudio9.0/mp4info/mp4info.vcproj @@ -0,0 +1,324 @@ +<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9.00"
+ Name="mp4info"
+ ProjectGUID="{FBFE9653-0F23-4F83-B4C3-08D1DB1449B2}"
+ RootNamespace="mp4info"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""$(SolutionDir)\..\include";"$(SolutionDir)\include";"$(SolutionDir)\..""
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ AdditionalIncludeDirectories=""$(SolutionDir)\..\include";"$(SolutionDir)\include";"$(SolutionDir)\..""
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release Static|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ AdditionalIncludeDirectories=""$(SolutionDir)\..\include";"$(SolutionDir)\include";"$(SolutionDir)\..""
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Debug Static|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""$(SolutionDir)\..\include";"$(SolutionDir)\include";"$(SolutionDir)\..""
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <File
+ RelativePath="..\..\util\mp4info.cpp"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/vstudio9.0/mp4tags/mp4tags.vcproj b/vstudio9.0/mp4tags/mp4tags.vcproj new file mode 100644 index 0000000..fc4751c --- /dev/null +++ b/vstudio9.0/mp4tags/mp4tags.vcproj @@ -0,0 +1,324 @@ +<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9.00"
+ Name="mp4tags"
+ ProjectGUID="{3D0B35CE-7DA0-4339-B799-8C0FE9C78061}"
+ RootNamespace="mp4tags"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""$(SolutionDir)\..\include";"$(SolutionDir)\include";"$(SolutionDir)\..""
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ AdditionalIncludeDirectories=""$(SolutionDir)\..\include";"$(SolutionDir)\include";"$(SolutionDir)\..""
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release Static|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ AdditionalIncludeDirectories=""$(SolutionDir)\..\include";"$(SolutionDir)\include";"$(SolutionDir)\..""
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Debug Static|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""$(SolutionDir)\..\include";"$(SolutionDir)\include";"$(SolutionDir)\..""
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <File
+ RelativePath="..\..\util\mp4tags.cpp"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/vstudio9.0/mp4track/mp4track.vcproj b/vstudio9.0/mp4track/mp4track.vcproj new file mode 100644 index 0000000..bc17562 --- /dev/null +++ b/vstudio9.0/mp4track/mp4track.vcproj @@ -0,0 +1,324 @@ +<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9.00"
+ Name="mp4track"
+ ProjectGUID="{EC1C77A7-E226-4B23-B12E-B94016DFB9D3}"
+ RootNamespace="mp4track"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""$(SolutionDir)\..\include";"$(SolutionDir)\include";"$(SolutionDir)\..""
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ AdditionalIncludeDirectories=""$(SolutionDir)\..\include";"$(SolutionDir)\include";"$(SolutionDir)\..""
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release Static|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ AdditionalIncludeDirectories=""$(SolutionDir)\..\include";"$(SolutionDir)\include";"$(SolutionDir)\..""
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Debug Static|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""$(SolutionDir)\..\include";"$(SolutionDir)\include";"$(SolutionDir)\..""
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <File
+ RelativePath="..\..\util\mp4track.cpp"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/vstudio9.0/mp4trackdump/mp4trackdump.vcproj b/vstudio9.0/mp4trackdump/mp4trackdump.vcproj new file mode 100644 index 0000000..1cf0577 --- /dev/null +++ b/vstudio9.0/mp4trackdump/mp4trackdump.vcproj @@ -0,0 +1,324 @@ +<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9.00"
+ Name="mp4trackdump"
+ ProjectGUID="{0A901CF8-28F1-489A-968A-8D3A782730D9}"
+ RootNamespace="mp4trackdump"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""$(SolutionDir)\..\include";"$(SolutionDir)\include";"$(SolutionDir)\..""
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ AdditionalIncludeDirectories=""$(SolutionDir)\..\include";"$(SolutionDir)\include";"$(SolutionDir)\..""
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release Static|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ AdditionalIncludeDirectories=""$(SolutionDir)\..\include";"$(SolutionDir)\include";"$(SolutionDir)\..""
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Debug Static|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""$(SolutionDir)\..\include";"$(SolutionDir)\include";"$(SolutionDir)\..""
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <File
+ RelativePath="..\..\util\mp4trackdump.cpp"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/vstudio9.0/mp4v2.sln b/vstudio9.0/mp4v2.sln new file mode 100644 index 0000000..400cc64 --- /dev/null +++ b/vstudio9.0/mp4v2.sln @@ -0,0 +1,142 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libmp4v2", "libmp4v2\libmp4v2.vcproj", "{BDB97A37-90B8-4906-BCAB-663D983E33E3}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "util", "util", "{A7FD8B52-7D83-474D-8CE3-BBB9B72384EE}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mp4info", "mp4info\mp4info.vcproj", "{FBFE9653-0F23-4F83-B4C3-08D1DB1449B2}" + ProjectSection(ProjectDependencies) = postProject + {BDB97A37-90B8-4906-BCAB-663D983E33E3} = {BDB97A37-90B8-4906-BCAB-663D983E33E3} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mp4art", "mp4art\mp4art.vcproj", "{E6E4F05D-BEDE-4FB4-9C68-ADA2605E1389}" + ProjectSection(ProjectDependencies) = postProject + {BDB97A37-90B8-4906-BCAB-663D983E33E3} = {BDB97A37-90B8-4906-BCAB-663D983E33E3} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mp4extract", "mp4extract\mp4extract.vcproj", "{7141244A-EB2F-4CAB-8025-BA1316A3C306}" + ProjectSection(ProjectDependencies) = postProject + {BDB97A37-90B8-4906-BCAB-663D983E33E3} = {BDB97A37-90B8-4906-BCAB-663D983E33E3} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mp4tags", "mp4tags\mp4tags.vcproj", "{3D0B35CE-7DA0-4339-B799-8C0FE9C78061}" + ProjectSection(ProjectDependencies) = postProject + {BDB97A37-90B8-4906-BCAB-663D983E33E3} = {BDB97A37-90B8-4906-BCAB-663D983E33E3} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mp4trackdump", "mp4trackdump\mp4trackdump.vcproj", "{0A901CF8-28F1-489A-968A-8D3A782730D9}" + ProjectSection(ProjectDependencies) = postProject + {BDB97A37-90B8-4906-BCAB-663D983E33E3} = {BDB97A37-90B8-4906-BCAB-663D983E33E3} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mp4chaps", "mp4chaps\mp4chaps.vcproj", "{94C763EE-E990-4D5B-BF9D-148FF55DE1C1}" + ProjectSection(ProjectDependencies) = postProject + {BDB97A37-90B8-4906-BCAB-663D983E33E3} = {BDB97A37-90B8-4906-BCAB-663D983E33E3} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mp4file", "mp4file\mp4file.vcproj", "{C97FBF72-8249-4782-A34A-BEA222E9A257}" + ProjectSection(ProjectDependencies) = postProject + {BDB97A37-90B8-4906-BCAB-663D983E33E3} = {BDB97A37-90B8-4906-BCAB-663D983E33E3} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mp4track", "mp4track\mp4track.vcproj", "{EC1C77A7-E226-4B23-B12E-B94016DFB9D3}" + ProjectSection(ProjectDependencies) = postProject + {BDB97A37-90B8-4906-BCAB-663D983E33E3} = {BDB97A37-90B8-4906-BCAB-663D983E33E3} + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug Static|Win32 = Debug Static|Win32 + Debug|Win32 = Debug|Win32 + Release Static|Win32 = Release Static|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {BDB97A37-90B8-4906-BCAB-663D983E33E3}.Debug Static|Win32.ActiveCfg = Debug Static|Win32 + {BDB97A37-90B8-4906-BCAB-663D983E33E3}.Debug Static|Win32.Build.0 = Debug Static|Win32 + {BDB97A37-90B8-4906-BCAB-663D983E33E3}.Debug|Win32.ActiveCfg = Debug|Win32 + {BDB97A37-90B8-4906-BCAB-663D983E33E3}.Debug|Win32.Build.0 = Debug|Win32 + {BDB97A37-90B8-4906-BCAB-663D983E33E3}.Release Static|Win32.ActiveCfg = Release Static|Win32 + {BDB97A37-90B8-4906-BCAB-663D983E33E3}.Release Static|Win32.Build.0 = Release Static|Win32 + {BDB97A37-90B8-4906-BCAB-663D983E33E3}.Release|Win32.ActiveCfg = Release|Win32 + {BDB97A37-90B8-4906-BCAB-663D983E33E3}.Release|Win32.Build.0 = Release|Win32 + {FBFE9653-0F23-4F83-B4C3-08D1DB1449B2}.Debug Static|Win32.ActiveCfg = Debug Static|Win32 + {FBFE9653-0F23-4F83-B4C3-08D1DB1449B2}.Debug Static|Win32.Build.0 = Debug Static|Win32 + {FBFE9653-0F23-4F83-B4C3-08D1DB1449B2}.Debug|Win32.ActiveCfg = Debug|Win32 + {FBFE9653-0F23-4F83-B4C3-08D1DB1449B2}.Debug|Win32.Build.0 = Debug|Win32 + {FBFE9653-0F23-4F83-B4C3-08D1DB1449B2}.Release Static|Win32.ActiveCfg = Release Static|Win32 + {FBFE9653-0F23-4F83-B4C3-08D1DB1449B2}.Release Static|Win32.Build.0 = Release Static|Win32 + {FBFE9653-0F23-4F83-B4C3-08D1DB1449B2}.Release|Win32.ActiveCfg = Release|Win32 + {FBFE9653-0F23-4F83-B4C3-08D1DB1449B2}.Release|Win32.Build.0 = Release|Win32 + {E6E4F05D-BEDE-4FB4-9C68-ADA2605E1389}.Debug Static|Win32.ActiveCfg = Debug Static|Win32 + {E6E4F05D-BEDE-4FB4-9C68-ADA2605E1389}.Debug Static|Win32.Build.0 = Debug Static|Win32 + {E6E4F05D-BEDE-4FB4-9C68-ADA2605E1389}.Debug|Win32.ActiveCfg = Debug|Win32 + {E6E4F05D-BEDE-4FB4-9C68-ADA2605E1389}.Debug|Win32.Build.0 = Debug|Win32 + {E6E4F05D-BEDE-4FB4-9C68-ADA2605E1389}.Release Static|Win32.ActiveCfg = Release Static|Win32 + {E6E4F05D-BEDE-4FB4-9C68-ADA2605E1389}.Release Static|Win32.Build.0 = Release Static|Win32 + {E6E4F05D-BEDE-4FB4-9C68-ADA2605E1389}.Release|Win32.ActiveCfg = Release|Win32 + {E6E4F05D-BEDE-4FB4-9C68-ADA2605E1389}.Release|Win32.Build.0 = Release|Win32 + {7141244A-EB2F-4CAB-8025-BA1316A3C306}.Debug Static|Win32.ActiveCfg = Debug Static|Win32 + {7141244A-EB2F-4CAB-8025-BA1316A3C306}.Debug Static|Win32.Build.0 = Debug Static|Win32 + {7141244A-EB2F-4CAB-8025-BA1316A3C306}.Debug|Win32.ActiveCfg = Debug|Win32 + {7141244A-EB2F-4CAB-8025-BA1316A3C306}.Debug|Win32.Build.0 = Debug|Win32 + {7141244A-EB2F-4CAB-8025-BA1316A3C306}.Release Static|Win32.ActiveCfg = Release Static|Win32 + {7141244A-EB2F-4CAB-8025-BA1316A3C306}.Release Static|Win32.Build.0 = Release Static|Win32 + {7141244A-EB2F-4CAB-8025-BA1316A3C306}.Release|Win32.ActiveCfg = Release|Win32 + {7141244A-EB2F-4CAB-8025-BA1316A3C306}.Release|Win32.Build.0 = Release|Win32 + {3D0B35CE-7DA0-4339-B799-8C0FE9C78061}.Debug Static|Win32.ActiveCfg = Debug Static|Win32 + {3D0B35CE-7DA0-4339-B799-8C0FE9C78061}.Debug Static|Win32.Build.0 = Debug Static|Win32 + {3D0B35CE-7DA0-4339-B799-8C0FE9C78061}.Debug|Win32.ActiveCfg = Debug|Win32 + {3D0B35CE-7DA0-4339-B799-8C0FE9C78061}.Debug|Win32.Build.0 = Debug|Win32 + {3D0B35CE-7DA0-4339-B799-8C0FE9C78061}.Release Static|Win32.ActiveCfg = Release Static|Win32 + {3D0B35CE-7DA0-4339-B799-8C0FE9C78061}.Release Static|Win32.Build.0 = Release Static|Win32 + {3D0B35CE-7DA0-4339-B799-8C0FE9C78061}.Release|Win32.ActiveCfg = Release|Win32 + {3D0B35CE-7DA0-4339-B799-8C0FE9C78061}.Release|Win32.Build.0 = Release|Win32 + {0A901CF8-28F1-489A-968A-8D3A782730D9}.Debug Static|Win32.ActiveCfg = Debug Static|Win32 + {0A901CF8-28F1-489A-968A-8D3A782730D9}.Debug Static|Win32.Build.0 = Debug Static|Win32 + {0A901CF8-28F1-489A-968A-8D3A782730D9}.Debug|Win32.ActiveCfg = Debug|Win32 + {0A901CF8-28F1-489A-968A-8D3A782730D9}.Debug|Win32.Build.0 = Debug|Win32 + {0A901CF8-28F1-489A-968A-8D3A782730D9}.Release Static|Win32.ActiveCfg = Release Static|Win32 + {0A901CF8-28F1-489A-968A-8D3A782730D9}.Release Static|Win32.Build.0 = Release Static|Win32 + {0A901CF8-28F1-489A-968A-8D3A782730D9}.Release|Win32.ActiveCfg = Release|Win32 + {0A901CF8-28F1-489A-968A-8D3A782730D9}.Release|Win32.Build.0 = Release|Win32 + {94C763EE-E990-4D5B-BF9D-148FF55DE1C1}.Debug Static|Win32.ActiveCfg = Debug Static|Win32 + {94C763EE-E990-4D5B-BF9D-148FF55DE1C1}.Debug Static|Win32.Build.0 = Debug Static|Win32 + {94C763EE-E990-4D5B-BF9D-148FF55DE1C1}.Debug|Win32.ActiveCfg = Debug|Win32 + {94C763EE-E990-4D5B-BF9D-148FF55DE1C1}.Debug|Win32.Build.0 = Debug|Win32 + {94C763EE-E990-4D5B-BF9D-148FF55DE1C1}.Release Static|Win32.ActiveCfg = Release Static|Win32 + {94C763EE-E990-4D5B-BF9D-148FF55DE1C1}.Release Static|Win32.Build.0 = Release Static|Win32 + {94C763EE-E990-4D5B-BF9D-148FF55DE1C1}.Release|Win32.ActiveCfg = Release|Win32 + {94C763EE-E990-4D5B-BF9D-148FF55DE1C1}.Release|Win32.Build.0 = Release|Win32 + {C97FBF72-8249-4782-A34A-BEA222E9A257}.Debug Static|Win32.ActiveCfg = Debug Static|Win32 + {C97FBF72-8249-4782-A34A-BEA222E9A257}.Debug Static|Win32.Build.0 = Debug Static|Win32 + {C97FBF72-8249-4782-A34A-BEA222E9A257}.Debug|Win32.ActiveCfg = Debug|Win32 + {C97FBF72-8249-4782-A34A-BEA222E9A257}.Debug|Win32.Build.0 = Debug|Win32 + {C97FBF72-8249-4782-A34A-BEA222E9A257}.Release Static|Win32.ActiveCfg = Release Static|Win32 + {C97FBF72-8249-4782-A34A-BEA222E9A257}.Release Static|Win32.Build.0 = Release Static|Win32 + {C97FBF72-8249-4782-A34A-BEA222E9A257}.Release|Win32.ActiveCfg = Release|Win32 + {C97FBF72-8249-4782-A34A-BEA222E9A257}.Release|Win32.Build.0 = Release|Win32 + {EC1C77A7-E226-4B23-B12E-B94016DFB9D3}.Debug Static|Win32.ActiveCfg = Debug Static|Win32 + {EC1C77A7-E226-4B23-B12E-B94016DFB9D3}.Debug Static|Win32.Build.0 = Debug Static|Win32 + {EC1C77A7-E226-4B23-B12E-B94016DFB9D3}.Debug|Win32.ActiveCfg = Debug|Win32 + {EC1C77A7-E226-4B23-B12E-B94016DFB9D3}.Debug|Win32.Build.0 = Debug|Win32 + {EC1C77A7-E226-4B23-B12E-B94016DFB9D3}.Release Static|Win32.ActiveCfg = Release Static|Win32 + {EC1C77A7-E226-4B23-B12E-B94016DFB9D3}.Release Static|Win32.Build.0 = Release Static|Win32 + {EC1C77A7-E226-4B23-B12E-B94016DFB9D3}.Release|Win32.ActiveCfg = Release|Win32 + {EC1C77A7-E226-4B23-B12E-B94016DFB9D3}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {FBFE9653-0F23-4F83-B4C3-08D1DB1449B2} = {A7FD8B52-7D83-474D-8CE3-BBB9B72384EE} + {E6E4F05D-BEDE-4FB4-9C68-ADA2605E1389} = {A7FD8B52-7D83-474D-8CE3-BBB9B72384EE} + {7141244A-EB2F-4CAB-8025-BA1316A3C306} = {A7FD8B52-7D83-474D-8CE3-BBB9B72384EE} + {3D0B35CE-7DA0-4339-B799-8C0FE9C78061} = {A7FD8B52-7D83-474D-8CE3-BBB9B72384EE} + {0A901CF8-28F1-489A-968A-8D3A782730D9} = {A7FD8B52-7D83-474D-8CE3-BBB9B72384EE} + {94C763EE-E990-4D5B-BF9D-148FF55DE1C1} = {A7FD8B52-7D83-474D-8CE3-BBB9B72384EE} + {C97FBF72-8249-4782-A34A-BEA222E9A257} = {A7FD8B52-7D83-474D-8CE3-BBB9B72384EE} + {EC1C77A7-E226-4B23-B12E-B94016DFB9D3} = {A7FD8B52-7D83-474D-8CE3-BBB9B72384EE} + EndGlobalSection +EndGlobal |