# HG changeset patch # User renatofilho # Date 1178036540 -3600 # Node ID 81f031485b520bb15d7164d2575d69d8bf5cc1e5 # Parent aa1f309ec68689b52c9deafb79144f8c2ac30ae0 [svn r618] moved to gst-gmyth diff -r aa1f309ec686 -r 81f031485b52 gst-plugins-nuvdemux/COPYING --- a/gst-plugins-nuvdemux/COPYING Tue May 01 17:03:38 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,340 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, 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 software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, 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 redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -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 give any other recipients of the Program a copy of this License -along with the Program. - -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 Program or any portion -of it, thus forming a work based on the Program, 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) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -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 Program, 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 Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) 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; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, 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 executable. 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. - -If distribution of executable or 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 counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program 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. - - 5. 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 Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program 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. - - 7. 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 Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program 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 Program. - -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. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program 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. - - 9. The Free Software Foundation may publish revised and/or new versions -of the 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 Program -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 Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, 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 - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "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 PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. 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 PROGRAM 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 PROGRAM (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 PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), 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 Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. 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. - - - Copyright (C) - - 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff -r aa1f309ec686 -r 81f031485b52 gst-plugins-nuvdemux/INSTALL --- a/gst-plugins-nuvdemux/INSTALL Tue May 01 17:03:38 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,229 +0,0 @@ -Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002 Free Software -Foundation, Inc. - - This file is free documentation; the Free Software Foundation gives -unlimited permission to copy, distribute and modify it. - -Basic Installation -================== - - These are generic installation instructions. - - 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 only 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. If you're - using `csh' on an old version of System V, you might need to type - `sh ./configure' instead to prevent `csh' from trying to execute - `configure' itself. - - Running `configure' takes awhile. 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. - -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=c89 CFLAGS=-O2 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 must use a version of `make' that -supports the `VPATH' variable, such as 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 `..'. - - If you have to use a `make' that does not support the `VPATH' -variable, you have 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' will install the package's files in -`/usr/local/bin', `/usr/local/man', etc. You can specify an -installation prefix other than `/usr/local' by giving `configure' the -option `--prefix=PATH'. - - You can specify separate installation prefixes for -architecture-specific files and architecture-independent files. If you -give `configure' the option `--exec-prefix=PATH', the package will use -PATH as the prefix for installing programs and libraries. -Documentation and other data files will still use the regular prefix. - - In addition, if you use an unusual directory layout you can give -options like `--bindir=PATH' 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 `--target=TYPE' option 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 - -will cause the specified gcc to be used as the C compiler (unless it is -overridden in the site shell script). - -`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. - diff -r aa1f309ec686 -r 81f031485b52 gst-plugins-nuvdemux/Makefile.am --- a/gst-plugins-nuvdemux/Makefile.am Tue May 01 17:03:38 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,4 +0,0 @@ -ACLOCAL_AMFLAGS = -I m4 - -SUBDIRS = nuvdemux typefind -DIST_SUBDIRS = m4 diff -r aa1f309ec686 -r 81f031485b52 gst-plugins-nuvdemux/autogen.sh --- a/gst-plugins-nuvdemux/autogen.sh Tue May 01 17:03:38 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,115 +0,0 @@ -#!/bin/sh -# Run this to generate all the initial makefiles, etc. - -# Not all echo versions allow -n, so we check what is possible. This test is -# based on the one in autoconf. -case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in - *c*,-n*) ECHO_N= ;; - *c*,* ) ECHO_N=-n ;; - *) ECHO_N= ;; -esac - - -# some terminal codes ... -boldface="`tput bold 2>/dev/null`" -normal="`tput sgr0 2>/dev/null`" -printbold() { - echo $ECHO_N "$boldface" - echo "$@" - echo $ECHO_N "$normal" -} -printerr() { - echo "$@" >&2 -} - -# Usage: -# compare_versions MIN_VERSION ACTUAL_VERSION -# returns true if ACTUAL_VERSION >= MIN_VERSION -compare_versions() { - ch_min_version=$1 - ch_actual_version=$2 - ch_status=0 - IFS="${IFS= }"; ch_save_IFS="$IFS"; IFS="." - set $ch_actual_version - for ch_min in $ch_min_version; do - ch_cur=`echo $1 | sed 's/[^0-9].*$//'`; shift # remove letter suffixes - if [ -z "$ch_min" ]; then break; fi - if [ -z "$ch_cur" ]; then ch_status=1; break; fi - if [ $ch_cur -gt $ch_min ]; then break; fi - if [ $ch_cur -lt $ch_min ]; then ch_status=1; break; fi - done - IFS="$ch_save_IFS" - return $ch_status -} - -# Usage: -# version_check PACKAGE VARIABLE CHECKPROGS MIN_VERSION SOURCE -# checks to see if the package is available -version_check() { - vc_package=$1 - vc_variable=$2 - vc_checkprogs=$3 - vc_min_version=$4 - vc_source=$5 - vc_status=1 - - vc_checkprog=`eval echo "\\$$vc_variable"` - if [ -n "$vc_checkprog" ]; then - printbold "using $vc_checkprog for $vc_package" - return 0 - fi - - printbold "checking for $vc_package >= $vc_min_version..." - for vc_checkprog in $vc_checkprogs; do - echo $ECHO_N " testing $vc_checkprog... " - if $vc_checkprog --version < /dev/null > /dev/null 2>&1; then - vc_actual_version=`$vc_checkprog --version | head -n 1 | \ - sed 's/^.*[ ]\([0-9.]*[a-z]*\).*$/\1/'` - if compare_versions $vc_min_version $vc_actual_version; then - echo "found $vc_actual_version" - # set variable - eval "$vc_variable=$vc_checkprog" - vc_status=0 - break - else - echo "too old (found version $vc_actual_version)" - fi - else - echo "not found." - fi - done - if [ "$vc_status" != 0 ]; then - printerr "***Error***: You must have $vc_package >= $vc_min_version installed" - printerr " to build $PKG_NAME. Download the appropriate package for" - printerr " from your distribution or get the source tarball at" - printerr " $vc_source" - printerr - fi - return $vc_status -} - -#tell Mandrake autoconf wrapper we want autoconf 2.5x, not 2.13 -WANT_AUTOCONF_2_5=1 -export WANT_AUTOCONF_2_5 -version_check autoreconf AUTORECONF 'autoreconf' 2.50 \ - "http://ftp.gnu.org/pub/gnu/autoconf/autoconf-2.50.tar.gz" || DIE=1 - -automake_progs="automake automake-1.9 automake-1.8 automake-1.7 automake-1.6 automake-1.5" - -version_check automake AUTOMAKE "$automake_progs" 1.5 \ - "http://ftp.gnu.org/pub/gnu/automake/automake-1.5.tar.gz" || DIE=1 -ACLOCAL=`echo $AUTOMAKE | sed s/automake/aclocal/` - -export AUTOMAKE ACLOCAL -# gtkdocize -autoreconf --install --force || exit 1 - -#conf_flags="--enable-maintainer-mode" - -if test x$NOCONFIGURE = x; then - printbold Running $srcdir/configure $conf_flags "$@" ... - ./configure $conf_flags "$@" \ - && echo Now type \`make\' to compile $PKG_NAME || exit 1 -else - echo Skipping configure process. -fi diff -r aa1f309ec686 -r 81f031485b52 gst-plugins-nuvdemux/config.h.in --- a/gst-plugins-nuvdemux/config.h.in Tue May 01 17:03:38 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -/* config.h.in. Generated from configure.ac by autoheader. */ - -/* Define the version */ -#undef GST_PLUGINS_VERSION - -/* Define the release version */ -#undef GST_PLUGINS_VERSION_RELEASE - -/* Define to 1 if you have the header file. */ -#undef HAVE_DLFCN_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_INTTYPES_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_MEMORY_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDINT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDLIB_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRINGS_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRING_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_STAT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_TYPES_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_UNISTD_H - -/* 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 - -/* Define to `__inline__' or `__inline' if that's what the C compiler - calls it, or to nothing if 'inline' is not supported under any name. */ -#ifndef __cplusplus -#undef inline -#endif diff -r aa1f309ec686 -r 81f031485b52 gst-plugins-nuvdemux/configure.ac --- a/gst-plugins-nuvdemux/configure.ac Tue May 01 17:03:38 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,130 +0,0 @@ -dnl fill in your package name and version here -dnl autoconf configuration files for gst-plugins-dspbin -AC_INIT -AC_CANONICAL_TARGET - -AC_CONFIG_MACRO_DIR([m4]) -dnl We disable static building for development, for time savings -dnl this goes before AS_LIBTOOL to appease autoconf -dnl *NOTE*: dnl this line before release, so release does static too -AM_DISABLE_STATIC - -dnl AM_MAINTAINER_MODE only provides the option to configure to enable it -AM_MAINTAINER_MODE - -dnl when going to/from release please set the nano (fourth number) right ! -dnl releases only do Wall, cvs and prerelease does Werror too -AS_VERSION(gst-plugins-nuvdemux, GST_PLUGINS_VERSION, 0, 10, 0, 1, GST_CVS="no", GST_CVS="yes") - -AM_INIT_AUTOMAKE($PACKAGE, $VERSION) - -AM_PROG_LIBTOOL - -AM_CONFIG_HEADER(config.h) - -dnl make aclocal work in maintainer mode -AC_SUBST(ACLOCAL_AMFLAGS, "-I m4") - -dnl check for tools -AC_PROG_CC -AC_PROG_CC_STDC -AM_PROG_AS - -dnl decide on error flags -AS_COMPILER_FLAG(-Wall, GST_WALL="yes", GST_WALL="no") - -if test "x$GST_WALL" = "xyes"; then - ERROR_CFLAGS="$GST_ERROR -Wall" - - if test "x$GST_CVS" = "xyes"; then - AS_COMPILER_FLAG(-Werror,ERROR_CFLAGS="$ERROR_CFLAGS -Werror",ERROR_CFLAGS="$ERROR_CFLAGS") - fi -fi - -AC_SUBST(ERROR_CFLAGS) - -dnl determine c++ compiler -AC_PROG_CXX -dnl determine if c++ is available on this system -AC_CHECK_PROG(HAVE_CXX, $CXX, yes, no) -dnl determine c++ preprocessor -AC_PROG_CXXCPP -AC_ISC_POSIX - -AC_HEADER_STDC([]) -AC_C_INLINE - -dnl Check for pkgconfig first -AC_CHECK_PROG(HAVE_PKGCONFIG, pkg-config, yes, no) - -dnl Give error and exit if we don't have pkgconfig -if test "x$HAVE_PKGCONFIG" = "xno"; then - AC_MSG_ERROR(you need to have pkgconfig installed !) -fi - -dnl Now we're ready to ask for gstreamer libs and cflags -dnl And we can also ask for the right version of gstreamer - -GST_REQUIRED=0.10.3 -GST_MAJORMINOR=0.10 - -PKG_CHECK_MODULES(GST, \ - gstreamer-$GST_MAJORMINOR >= $GST_REQUIRED, - HAVE_GST=yes,HAVE_GST=no) - -dnl Give error and exit if we don't have gstreamer -if test "x$HAVE_GST" = "xno"; then - AC_MSG_ERROR(you need gstreamer development packages installed !) -fi - -if test "x$USE_DEBUG" = xyes; then - GST_CFLAGS="$GST_CFLAGS -g" -fi - -dnl added because of the i18n headers -GST_CFLAGS="-I\$(top_builddir)/gst-libs $GST_CFLAGS" - -dnl make GST_CFLAGS and GST_LIBS available -AC_SUBST(GST_CFLAGS) -AC_SUBST(GST_LIBS) - -dnl make GST_MAJORMINOR available in Makefile.am -AC_SUBST(GST_MAJORMINOR) - -dnl check for gstreamer-base; uninstalled is selected preferentially -PKG_CHECK_MODULES(GST_BASE, gstreamer-base-$GST_MAJORMINOR >= $GST_REQUIRED, - HAVE_GST_BASE="yes", HAVE_GST_BASE="no") - -if test "x$HAVE_GST_BASE" = "xno"; then - AC_MSG_ERROR(no GStreamer Base Libs found) -fi - -AC_SUBST(GST_BASE_LIBS) -AC_SUBST(GST_BASE_CFLAGS) - -dnl check for gstreamer-libs; uinstalled is selected preferentially -PKG_CHECK_MODULES(GST_PLUGINS_BASE, gstreamer-plugins-base-$GST_MAJORMINOR >= $GST_REQUIRED, - HAVE_GST_PLUGINS="yes", HAVE_GST_PLUGINS="no") - -if test "x$HAVE_GST_PLUGINS" = "xno"; then - AC_MSG_ERROR(no GStreamer Plugins Libs found) -fi - -AC_SUBST(GST_PLUGINS_BASE_LIBS) -AC_SUBST(GST_PLUGINS_BASE_CFLAGS) - -dnl set the plugindir where plugins should be installed -plugindir="\$(libdir)/gstreamer-$GST_MAJORMINOR" -AC_SUBST(plugindir) - -dnl set proper LDFLAGS for plugins -GST_PLUGIN_LDFLAGS='-module -avoid-version -export-symbols-regex [_]*\(gst_\|Gst\|GST_\).*' -AC_SUBST(GST_PLUGIN_LDFLAGS) - -AC_OUTPUT( \ - Makefile \ - nuvdemux/Makefile \ - typefind/Makefile \ - m4/Makefile -) - diff -r aa1f309ec686 -r 81f031485b52 gst-plugins-nuvdemux/debian/changelog --- a/gst-plugins-nuvdemux/debian/changelog Tue May 01 17:03:38 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,6 +0,0 @@ -gst-indt-nuvdemux (0.10.2.debian-1) unstable; urgency=low - - * Initial packaged; - - -- Renato Araujo Oliveira Filho Thu, 09 Nov 2006 15:58:00 -0300 - diff -r aa1f309ec686 -r 81f031485b52 gst-plugins-nuvdemux/debian/compat --- a/gst-plugins-nuvdemux/debian/compat Tue May 01 17:03:38 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -4 diff -r aa1f309ec686 -r 81f031485b52 gst-plugins-nuvdemux/debian/control --- a/gst-plugins-nuvdemux/debian/control Tue May 01 17:03:38 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,20 +0,0 @@ -Source: gst-indt-nuvdemux -Section: libs -Priority: optional -Maintainer: Renato Araujo Oliveira Filho -Build-Depends: debhelper (>= 4.1.0), cdbs (>= 0.4.8), autotools-dev, pkg-config (>= 0.11.0), libgstreamer0.10-dev (>= 0.10.0) -Standards-Version: 3.6.2 - -Package: gstreamer0.10-indt-nuvdemux -Architecture: any -Section: libs -Depends: ${misc:Depends}, ${shlibs:Depends} -Description: INdT nuv demux GStreamer plugin - This GStreamer plugin permits demux of Nuv streams. - -Package: maemo-nuvdemux -Architecture: all -Depends: gstreamer0.10-indt-nuvdemux -Description: enable support to nuvdemux on osso media server (meta-package) - This package is a meta-package that, when installed, guarantees that you - have support to nuv files on osso-media-server. diff -r aa1f309ec686 -r 81f031485b52 gst-plugins-nuvdemux/debian/copyright --- a/gst-plugins-nuvdemux/debian/copyright Tue May 01 17:03:38 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,23 +0,0 @@ -This package was debianized by Renato Araujo Oliveira Filho on -Thu, 09 Nov 2006 15:58:00 -0300. - -Copyright Holder: 2006 INdT - -License: - - This package 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; version 2 dated June, 1991. - - This package 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 package; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, - MA 02110-1301, USA. - -On Debian systems, the complete text of the GNU General -Public License can be found in `/usr/share/common-licenses/GPL'. diff -r aa1f309ec686 -r 81f031485b52 gst-plugins-nuvdemux/debian/files --- a/gst-plugins-nuvdemux/debian/files Tue May 01 17:03:38 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -maemo-nuvdemux_0.10.2.debian-1_all.deb libs optional -gstreamer0.10-indt-nuvdemux_0.10.2.debian-1_armel.deb libs optional diff -r aa1f309ec686 -r 81f031485b52 gst-plugins-nuvdemux/debian/gstreamer0.10-indt-nuvdemux.install --- a/gst-plugins-nuvdemux/debian/gstreamer0.10-indt-nuvdemux.install Tue May 01 17:03:38 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -debian/tmp/usr/lib/gstreamer-*/*.so diff -r aa1f309ec686 -r 81f031485b52 gst-plugins-nuvdemux/debian/maemo-nuvdemux.install --- a/gst-plugins-nuvdemux/debian/maemo-nuvdemux.install Tue May 01 17:03:38 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -debian/nuv.xml usr/share/mime/packages/ -debian/osso_media_server_nuv.schemas usr/share/gconf/schemas diff -r aa1f309ec686 -r 81f031485b52 gst-plugins-nuvdemux/debian/maemo-nuvdemux.postinst --- a/gst-plugins-nuvdemux/debian/maemo-nuvdemux.postinst Tue May 01 17:03:38 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,24 +0,0 @@ -#! /bin/sh -set -e - -#DEBHELPER# - -# Register our X Desktop Group Shared MIME-info Database info -if [ -x /usr/bin/update-mime-database ] ; then - /usr/bin/update-mime-database /usr/share/mime -fi - -# Register a new type on Osso Media Server -if [ -x /usr/bin/gconftool-2 ] ; then - /usr/bin/gconftool-2 --makefile-install-rule /usr/share/gconf/schemas/osso_media_server_nuv.schemas -fi - -#append nuv info on osso mediaplayer ui -data_file=/usr/share/applications/hildon/mp_ui.desktop -tmp_file=/tmp/mp_ui.desktop -cat $data_file | sed 's/X-Osso-URI-Actions=rtsp/X-Osso-URI-Actions=rtsp;myth/' | sed 's/MimeType=\(.*\)/MimeType=\1;video\/x-nuv/' > $tmp_file -echo -e "\n\n[X-Osso-URI-Action Handler myth] \nMethod=mime_open\nName=medi_ap_mediaplayer_name\nTranslationDomain=mediaplayer" >> $tmp_file -cat $tmp_file > $data_file -echo "FILE DESKTOP UPDATED" - -exit 0 diff -r aa1f309ec686 -r 81f031485b52 gst-plugins-nuvdemux/debian/nuv.xml --- a/gst-plugins-nuvdemux/debian/nuv.xml Tue May 01 17:03:38 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,11 +0,0 @@ - - - - Nuv File - Mythtv Nuv file container - - - - - - diff -r aa1f309ec686 -r 81f031485b52 gst-plugins-nuvdemux/debian/osso_media_server_nuv.schemas --- a/gst-plugins-nuvdemux/debian/osso_media_server_nuv.schemas Tue May 01 17:03:38 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,16 +0,0 @@ - - - - - /schemas/apps/osso/osso_media_server/demux_video/video_x-nuv - /apps/osso/osso_media_server/demux_video/video_x-nuv - osso_media_server - list - string - [video/x-nuv,nuvdemux] - - Play MYTHTV .nuv files. - - - - diff -r aa1f309ec686 -r 81f031485b52 gst-plugins-nuvdemux/debian/rules --- a/gst-plugins-nuvdemux/debian/rules Tue May 01 17:03:38 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,19 +0,0 @@ -#!/usr/bin/make -f - -include /usr/share/cdbs/1/rules/debhelper.mk -include /usr/share/cdbs/1/rules/simple-patchsys.mk -include /usr/share/cdbs/1/class/gnome.mk -include /usr/share/cdbs/1/rules/utils.mk - -# debian package version -version=$(shell dpkg-parsechangelog | grep ^Version: | cut -d ' ' -f 2) - -maint: debian/control - -binary-install/gstreamer0.10-indt-nuvdemux:: - rm -f debian/gstreamer0.10-indt-nuvdemux/usr/lib/gstreamer-0.10/libgstnuvdemux.la - rm -f debian/gstreamer0.10-indt-nuvdemux/usr/lib/gstreamer-0.10/libgstnuvdemux.a - rm -f debian/gstreamer0.10-indt-nuvdemux/usr/lib/gstreamer-0.10/libgsttypefindfunctions_indt.la - rm -f debian/gstreamer0.10-indt-nuvdemux/usr/lib/gstreamer-0.10/libgsttypefindfunctions_indt.a - -.PHONY: maint diff -r aa1f309ec686 -r 81f031485b52 gst-plugins-nuvdemux/m4/Makefile.am --- a/gst-plugins-nuvdemux/m4/Makefile.am Tue May 01 17:03:38 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ -EXTRA_DIST = \ -as-compiler-flag.m4 \ -as-version.m4 \ -gst-feature.m4 - diff -r aa1f309ec686 -r 81f031485b52 gst-plugins-nuvdemux/m4/as-compiler-flag.m4 --- a/gst-plugins-nuvdemux/m4/as-compiler-flag.m4 Tue May 01 17:03:38 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ -dnl as-compiler-flag.m4 0.1.0 - -dnl autostars m4 macro for detection of compiler flags - -dnl David Schleef - -dnl $Id: as-compiler-flag.m4,v 1.1 2005/06/18 18:02:46 burgerman Exp $ - -dnl AS_COMPILER_FLAG(CFLAGS, ACTION-IF-ACCEPTED, [ACTION-IF-NOT-ACCEPTED]) -dnl Tries to compile with the given CFLAGS. -dnl Runs ACTION-IF-ACCEPTED if the compiler can compile with the flags, -dnl and ACTION-IF-NOT-ACCEPTED otherwise. - -AC_DEFUN([AS_COMPILER_FLAG], -[ - AC_MSG_CHECKING([to see if compiler understands $1]) - - save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $1" - - AC_TRY_COMPILE([ ], [], [flag_ok=yes], [flag_ok=no]) - CFLAGS="$save_CFLAGS" - - if test "X$flag_ok" = Xyes ; then - $2 - true - else - $3 - true - fi - AC_MSG_RESULT([$flag_ok]) -]) diff -r aa1f309ec686 -r 81f031485b52 gst-plugins-nuvdemux/m4/as-version.m4 --- a/gst-plugins-nuvdemux/m4/as-version.m4 Tue May 01 17:03:38 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -dnl as-version.m4 0.1.0 - -dnl autostars m4 macro for versioning - -dnl Thomas Vander Stichele - -dnl $Id: as-version.m4,v 1.1 2005/06/18 18:02:46 burgerman Exp $ - -dnl AS_VERSION(PACKAGE, PREFIX, MAJOR, MINOR, MICRO, NANO, -dnl ACTION-IF-NO-NANO, [ACTION-IF-NANO]) - -dnl example -dnl AS_VERSION(gstreamer, GST_VERSION, 0, 3, 2,) -dnl for a 0.3.2 release version - -dnl this macro -dnl - defines [$PREFIX]_MAJOR, MINOR and MICRO -dnl - if NANO is empty, then we're in release mode, else in cvs/dev mode -dnl - defines [$PREFIX], VERSION, and [$PREFIX]_RELEASE -dnl - executes the relevant action -dnl - AC_SUBST's PACKAGE, VERSION, [$PREFIX] and [$PREFIX]_RELEASE -dnl as well as the little ones -dnl - doesn't call AM_INIT_AUTOMAKE anymore because it prevents -dnl maintainer mode from running ok -dnl -dnl don't forget to put #undef [$2] and [$2]_RELEASE in acconfig.h -dnl if you use acconfig.h - -AC_DEFUN([AS_VERSION], -[ - PACKAGE=[$1] - [$2]_MAJOR=[$3] - [$2]_MINOR=[$4] - [$2]_MICRO=[$5] - NANO=[$6] - [$2]_NANO=$NANO - if test "x$NANO" = "x" || test "x$NANO" = "x0"; - then - AC_MSG_NOTICE(configuring [$1] for release) - VERSION=[$3].[$4].[$5] - [$2]_RELEASE=1 - dnl execute action - ifelse([$7], , :, [$7]) - else - AC_MSG_NOTICE(configuring [$1] for development with nano $NANO) - VERSION=[$3].[$4].[$5].$NANO - [$2]_RELEASE=0.`date +%Y%m%d.%H%M%S` - dnl execute action - ifelse([$8], , :, [$8]) - fi - - [$2]=$VERSION - AC_DEFINE_UNQUOTED([$2], "$[$2]", [Define the version]) - AC_SUBST([$2]) - AC_DEFINE_UNQUOTED([$2]_RELEASE, "$[$2]_RELEASE", [Define the release version]) - AC_SUBST([$2]_RELEASE) - - AC_SUBST([$2]_MAJOR) - AC_SUBST([$2]_MINOR) - AC_SUBST([$2]_MICRO) - AC_SUBST([$2]_NANO) - AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Define the package name]) - AC_SUBST(PACKAGE) - AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Define the version]) - AC_SUBST(VERSION) -]) - diff -r aa1f309ec686 -r 81f031485b52 gst-plugins-nuvdemux/m4/gst-feature.m4 --- a/gst-plugins-nuvdemux/m4/gst-feature.m4 Tue May 01 17:03:38 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,211 +0,0 @@ -dnl Perform a check for a feature for GStreamer -dnl Richard Boulton -dnl Thomas Vander Stichele added useful stuff -dnl Last modification: 25/06/2001 -dnl GST_CHECK_FEATURE(FEATURE-NAME, FEATURE-DESCRIPTION, -dnl DEPENDENT-PLUGINS, TEST-FOR-FEATURE, -dnl DISABLE-BY-DEFAULT, ACTION-IF-USE, ACTION-IF-NOTUSE) -dnl -dnl This macro adds a command line argument to enable the user to enable -dnl or disable a feature, and if the feature is enabled, performs a supplied -dnl test to check if the feature is available. -dnl -dnl The test should define HAVE_ to "yes" or "no" depending -dnl on whether the feature is available. -dnl -dnl The macro will set USE_ to "yes" or "no" depending on -dnl whether the feature is to be used. -dnl Thomas changed this, so that when USE_ was already set -dnl to no, then it stays that way. -dnl -dnl The macro will call AM_CONDITIONAL(USE_<, ...) to allow -dnl the feature to control what is built in Makefile.ams. If you want -dnl additional actions resulting from the test, you can add them with the -dnl ACTION-IF-USE and ACTION-IF-NOTUSE parameters. -dnl -dnl FEATURE-NAME is the name of the feature, and should be in -dnl purely upper case characters. -dnl FEATURE-DESCRIPTION is used to describe the feature in help text for -dnl the command line argument. -dnl DEPENDENT-PLUGINS lists any plugins which depend on this feature. -dnl TEST-FOR-FEATURE is a test which sets HAVE_ to "yes" -dnl or "no" depending on whether the feature is -dnl available. -dnl DISABLE-BY-DEFAULT if "disabled", the feature is disabled by default, -dnl if any other value, the feature is enabled by default. -dnl ACTION-IF-USE any extra actions to perform if the feature is to be -dnl used. -dnl ACTION-IF-NOTUSE any extra actions to perform if the feature is not to -dnl be used. -dnl -dnl -dnl thomas : -dnl we also added a history. -dnl GST_PLUGINS_YES will contain all plugins to be built -dnl that were checked through GST_CHECK_FEATURE -dnl GST_PLUGINS_NO will contain those that won't be built - -AC_DEFUN([GST_CHECK_FEATURE], -AC_MSG_NOTICE(***) -AC_MSG_NOTICE(*** checking plugin: [$3] ***) -AC_MSG_NOTICE(***) -[dnl -builtin(define, [gst_endisable], ifelse($5, [disabled], [enable], [disable]))dnl -dnl if it is set to NO, then don't even consider it for building -NOUSE= -if test "x$USE_[$1]" = "xno"; then - NOUSE="yes" -fi -AC_ARG_ENABLE(translit([$1], A-Z, a-z), - [ ]builtin(format, --%-26s gst_endisable %s, gst_endisable-translit([$1], A-Z, a-z), [$2]ifelse([$3],,,: [$3])), - [ case "${enableval}" in - yes) USE_[$1]=yes;; - no) USE_[$1]=no;; - *) AC_MSG_ERROR(bad value ${enableval} for --enable-translit([$1], A-Z, a-z)) ;; - esac], - [ USE_$1=]ifelse($5, [disabled], [no], [yes])) dnl DEFAULT - -dnl *** set it back to no if it was preset to no -if test "x$NOUSE" = "xyes"; then - USE_[$1]="no" - AC_MSG_WARN(*** $3 pre-configured not to be built) -fi -NOUSE= - -dnl *** If it's enabled - -if test x$USE_[$1] = xyes; then - dnl save compile variables before the test - - gst_check_save_LIBS=$LIBS - gst_check_save_LDFLAGS=$LDFLAGS - gst_check_save_CFLAGS=$CFLAGS - gst_check_save_CPPFLAGS=$CPPFLAGS - gst_check_save_CXXFLAGS=$CXXFLAGS - - HAVE_[$1]=no - dnl TEST_FOR_FEATURE - $4 - - LIBS=$gst_check_save_LIBS - LDFLAGS=$gst_check_save_LDFLAGS - CFLAGS=$gst_check_save_CFLAGS - CPPFLAGS=$gst_check_save_CPPFLAGS - CXXFLAGS=$gst_check_save_CXXFLAGS - - dnl If it isn't found, unset USE_[$1] - if test x$HAVE_[$1] = xno; then - USE_[$1]=no - fi -fi -dnl *** Warn if it's disabled or not found -if test x$USE_[$1] = xyes; then - ifelse([$6], , :, [$6]) - if test "x$3" != "x"; then - GST_PLUGINS_YES="\t[$3]\n$GST_PLUGINS_YES" - fi - AC_DEFINE(HAVE_[$1], , [support for features: $3]) -else - ifelse([$3], , :, [AC_MSG_NOTICE(*** These plugins will not be built: [$3])]) - if test "x$3" != "x"; then - GST_PLUGINS_NO="\t[$3]\n$GST_PLUGINS_NO" - fi - ifelse([$7], , :, [$7]) -fi -dnl *** Define the conditional as appropriate -AM_CONDITIONAL(USE_[$1], test x$USE_[$1] = xyes) -]) - -dnl Use a -config program which accepts --cflags and --libs parameters -dnl to set *_CFLAGS and *_LIBS and check existence of a feature. -dnl Richard Boulton -dnl Last modification: 26/06/2001 -dnl GST_CHECK_CONFIGPROG(FEATURE-NAME, CONFIG-PROG-FILENAME, MODULES) -dnl -dnl This check was written for GStreamer: it should be renamed and checked -dnl for portability if you decide to use it elsewhere. -dnl -AC_DEFUN([GST_CHECK_CONFIGPROG], -[ - AC_PATH_PROG([$1]_CONFIG, [$2], no) - if test x$[$1]_CONFIG = xno; then - [$1]_LIBS= - [$1]_CFLAGS= - HAVE_[$1]=no - else - if [$2] --plugin-libs [$3] &> /dev/null; then - [$1]_LIBS=`[$2] --plugin-libs [$3]` - else - [$1]_LIBS=`[$2] --libs [$3]` - fi - [$1]_CFLAGS=`[$2] --cflags [$3]` - HAVE_[$1]=yes - fi - AC_SUBST([$1]_LIBS) - AC_SUBST([$1]_CFLAGS) -]) - -dnl Use AC_CHECK_LIB and AC_CHECK_HEADER to do both tests at once -dnl sets HAVE_module if we have it -dnl Richard Boulton -dnl Last modification: 26/06/2001 -dnl GST_CHECK_LIBHEADER(FEATURE-NAME, LIB NAME, LIB FUNCTION, EXTRA LD FLAGS, -dnl HEADER NAME, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND) -dnl -dnl This check was written for GStreamer: it should be renamed and checked -dnl for portability if you decide to use it elsewhere. -dnl -AC_DEFUN([GST_CHECK_LIBHEADER], -[ - AC_CHECK_LIB([$2], [$3], HAVE_[$1]=yes, HAVE_[$1]=no,[$4]) - if test "x$HAVE_[$1]" = "xyes"; then - AC_CHECK_HEADER([$5], :, HAVE_[$1]=no) - if test "x$HAVE_[$1]" = "xyes"; then - dnl execute what needs to be - ifelse([$6], , :, [$6]) - else - ifelse([$7], , :, [$7]) - fi - else - ifelse([$7], , :, [$7]) - fi - AC_SUBST(HAVE_[$1]) -] -) - -dnl 2004-02-14 Thomas - changed to get set properly and use proper output -dnl 2003-06-27 Benjamin Otte - changed to make this work with gstconfig.h -dnl -dnl Add a subsystem --disable flag and all the necessary symbols and substitions -dnl -dnl GST_CHECK_SUBSYSTEM_DISABLE(SYSNAME, [subsystem name]) -dnl -AC_DEFUN([GST_CHECK_SUBSYSTEM_DISABLE], -[ - dnl this define will replace each literal subsys_def occurrence with - dnl the lowercase hyphen-separated subsystem - dnl e.g. if $1 is GST_DEBUG then subsys_def will be a macro with gst-debug - define([subsys_def],translit([$1], _A-Z, -a-z)) - - AC_ARG_ENABLE(subsys_def, - AC_HELP_STRING(--disable-subsys_def, [disable $2]), - [ - case "${enableval}" in - yes) GST_DISABLE_[$1]=no ;; - no) GST_DISABLE_[$1]=yes ;; - *) AC_MSG_ERROR([bad value ${enableval} for --enable-subsys_def]) ;; - esac - ], - [GST_DISABLE_[$1]=no]) dnl Default value - - if test x$GST_DISABLE_[$1] = xyes; then - AC_MSG_NOTICE([disabled subsystem [$2]]) - GST_DISABLE_[$1]_DEFINE="#define GST_DISABLE_$1 1" - else - GST_DISABLE_[$1]_DEFINE="/* #undef GST_DISABLE_$1 */" - fi - AC_SUBST(GST_DISABLE_[$1]_DEFINE) - undefine([subsys_def]) -]) - - diff -r aa1f309ec686 -r 81f031485b52 gst-plugins-nuvdemux/nuvdemux/Makefile.am --- a/gst-plugins-nuvdemux/nuvdemux/Makefile.am Tue May 01 17:03:38 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,22 +0,0 @@ -plugin_LTLIBRARIES = libgstnuvdemux.la - -libgstnuvdemux_la_SOURCES = \ - gstnuvdemux.c - -libgstnuvdemux_la_CFLAGS = \ - $(GST_CFLAGS) \ - $(GST_BASE_CFLAGS) \ - $(GST_PLUGINS_BASE_CFLAGS) - -libgstnuvdemux_la_LIBADD = \ - $(GST_LIBS_LIBS) - -libgstnuvdemux_la_LDFLAGS = \ - $(GST_LIBS) \ - $(GST_PLUGIN_LDFLAGS) \ - $(GST_BASE_LIBS) \ - $(GST_PLUGINS_BASE_LIBS) - -noinst_HEADERS = \ - gstnuvdemux.h - diff -r aa1f309ec686 -r 81f031485b52 gst-plugins-nuvdemux/nuvdemux/gstnuvdemux.c --- a/gst-plugins-nuvdemux/nuvdemux/gstnuvdemux.c Tue May 01 17:03:38 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1654 +0,0 @@ -/* GStreamer - * Copyright (C) <2006> Renato Araujo Oliveira Filho - * Rosfran Borges - * - * 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 Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -/* Element-Checklist-Version: 5 */ - -/** - * SECTION:element-nuvdemux - * - * - * - * Demuxes an .nuv file into raw or compressed audio and/or video streams. - * - * - * This element currently only supports pull-based scheduling. - * - * Example launch line - * - * - * gst-launch filesrc test.nuv ! nuvdemux name=demux demux.audio_00 ! decodebin ! audioconvert ! audioresample ! autoaudiosink demux.video_00 ! queue ! decodebin ! ffmpegcolorspace ! videoscale ! autovideosink - * - * Play (parse and decode) an .nuv file and try to output it to - * an automatically detected soundcard and videosink. If the NUV file contains - * compressed audio or video data, this will only work if you have the - * right decoder elements/plugins installed. - * - * - * - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include -#include -#include - -#include "glib/gi18n.h" -#include "gstnuvdemux.h" - -#define GST_NUV_DEMUX_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GST_TYPE_NUV_DEMUX, GstNuvDemuxPrivate)) - -GST_DEBUG_CATEGORY_STATIC (nuvdemux_debug); -#define GST_CAT_DEFAULT nuvdemux_debug -#define GST_FLOW_ERROR_NO_DATA -101 -#define GST_FLOW_ERROR_EOS -102 - -enum -{ - NUV_PUSH_MODE = 0, - NUV_PULL_MODE -}; - -GST_DEBUG_CATEGORY_EXTERN (GST_CAT_EVENT); - -static const GstElementDetails gst_nuv_demux_details = -GST_ELEMENT_DETAILS ("Nuv demuxer", - "Codec/Demuxer", - "Demultiplex a .nuv file into audio and video", - "Renato Araujo Oliveira Filho ," - "Rosfran Borges "); - - -/* file header */ -typedef struct -{ - gchar id[12]; /* "NuppelVideo\0" or "MythTVVideo\0" */ - gchar version[5]; /* "x.xx\0" */ - - gint i_width; - gint i_height; - gint i_width_desired; - gint i_height_desired; - - gchar i_mode; /* P progressive, I interlaced */ - - gdouble d_aspect; /* 1.0 squared pixel */ - gdouble d_fps; - //fps num/denom - gint i_fpsn; - gint i_fpsd; - - gint i_video_blocks; /* 0 no video, -1 unknown */ - gint i_audio_blocks; - gint i_text_blocks; - - gint i_keyframe_distance; - -} nuv_header; - -/* frame header */ -typedef struct -{ - gchar i_type; /* A: audio, V: video, S: sync; T: test - R: Seekpoint (string:RTjjjjjjjj) - D: Extra data for codec */ - gchar i_compression; /* V: 0 uncompressed - 1 RTJpeg - 2 RTJpeg+lzo - N black frame - L copy last - A: 0 uncompressed (44100 1-bits, 2ch) - 1 lzo - 2 layer 2 - 3 layer 3 - F flac - S shorten - N null frame loudless - L copy last - S: B audio and vdeo sync point - A audio sync info (timecode == effective - dsp frequency*100) - V next video sync (timecode == next video - frame num) - S audio,video,text correlation */ - gchar i_keyframe; /* 0 keyframe, else no no key frame */ - guint8 i_filters; /* 0x01: gauss 5 pixel (8,2,2,2,2)/16 - 0x02: gauss 5 pixel (8,1,1,1,1)/12 - 0x04: cartoon filter */ - - gint32 i_timecode; /* ms */ - - gint i_length; /* V,A,T: length of following data - S: length of packet correl */ -} nuv_frame_header; - - -/* FIXME Not sure of this one */ -typedef struct -{ - gint i_version; - guint32 i_video_fcc; - - guint32 i_audio_fcc; - gint i_audio_sample_rate; - gint i_audio_bits_per_sample; - gint i_audio_channels; - gint i_audio_compression_ratio; - gint i_audio_quality; - gint i_rtjpeg_quality; - gint i_rtjpeg_luma_filter; - gint i_rtjpeg_chroma_filter; - gint i_lavc_bitrate; - gint i_lavc_qmin; - gint i_lavc_qmax; - gint i_lavc_maxqdiff; - gint64 i_seekable_offset; - gint64 i_keyframe_adjust_offset; - -} nuv_extended_header; - -typedef struct -{ - gint64 timecode; - gint64 offset; - -} frame_index_data; - -typedef enum { - GST_NUV_DEMUX_START, - GST_NUV_DEMUX_HEADER_DATA, - GST_NUV_DEMUX_EXTRA_DATA, - GST_NUV_DEMUX_MPEG_DATA, - GST_NUV_DEMUX_EXTEND_HEADER, - GST_NUV_DEMUX_EXTEND_HEADER_DATA, - GST_NUV_DEMUX_INDEX_CREATE, - GST_NUV_DEMUX_FRAME_HEADER, - GST_NUV_DEMUX_MOVI, - GST_NUV_DEMUX_INVALID_DATA -} GstNuvDemuxState; - -struct _GstNuvDemuxPrivate { - /* used for indicate the mode */ - guint mode; - - /* used on push mode */ - GstAdapter *adapter; - - /* pads */ - GstPad *sinkpad; - GstPad *src_video_pad; - GstPad *src_audio_pad; - - /* Flow control */ - GstFlowReturn last_video_return; - GstFlowReturn last_audio_return; - gboolean more_data; - gboolean eos; - - /* NUV decoding state */ - GstNuvDemuxState state; - guint64 offset; - - /* duration information */ - guint64 duration_bytes; - guint64 duration_time; - guint64 segment_stop; - guint64 segment_start; - - /* segment control info */ - gboolean new_audio_segment; - gboolean new_video_segment; - - /* Mpeg ExtraData */ - guint64 mpeg_data_size; - GstBuffer *mpeg_buffer; - - /* Headers */ - nuv_header h; - nuv_extended_header eh; - nuv_frame_header fh; - - /* anothers info */ - guint64 header_lengh; - gint64 time_start; - gint64 time_diff; - gint64 time_qos; - guint64 last_frame_time; - GSList *index; -}; - - -static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink", - GST_PAD_SINK, - GST_PAD_ALWAYS, - GST_STATIC_CAPS ("video/x-nuv")); - -static GstStaticPadTemplate audio_src_template = -GST_STATIC_PAD_TEMPLATE ("audio_src", - GST_PAD_SRC, - GST_PAD_SOMETIMES, - GST_STATIC_CAPS_ANY); - -static GstStaticPadTemplate video_src_template = -GST_STATIC_PAD_TEMPLATE ("video_src", - GST_PAD_SRC, - GST_PAD_SOMETIMES, - GST_STATIC_CAPS_ANY); - -static void gst_nuv_demux_dispose (GObject * object); -static void gst_nuv_demux_finalize (GObject * object); -static GstStateChangeReturn gst_nuv_demux_change_state (GstElement * element, - GstStateChange transition); -static void gst_nuv_demux_loop (GstPad * pad); -static GstFlowReturn gst_nuv_demux_chain (GstPad * pad, GstBuffer * buf); -static GstFlowReturn gst_nuv_demux_play (GstPad * pad); -static gboolean gst_nuv_demux_sink_activate_pull (GstPad * sinkpad, - gboolean active); -static gboolean gst_nuv_demux_sink_activate_push (GstPad * pad, - gboolean active); -static gboolean gst_nuv_demux_sink_activate (GstPad * sinkpad); -//static gboolean gst_nuv_demux_sink_event (GstPad *pad, GstEvent *event); -static gboolean gst_nuv_demux_srcpad_event (GstPad * pad, GstEvent * event); -static frame_index_data * gst_nuv_demux_do_seek_index (GstNuvDemux *nuv, gint64 seek_pos, - gint64 segment_stop, GstFormat format); - - - -static GstFlowReturn gst_nuv_demux_read_bytes (GstNuvDemux * nuv, guint64 size, - gboolean move, GstBuffer ** buffer); -static void gst_nuv_demux_reset (GstNuvDemux * nuv); -static void gst_nuv_demux_destoy_src_pad (GstNuvDemux * nuv); -static void gst_nuv_demux_send_eos (GstNuvDemux * nuv); -static void gst_nuv_demux_create_seek_index (GstNuvDemux * nuv); - - -#if (GST_VERSION_MINOR == 10) && (GST_VERSION_MICRO < 6) -GstBuffer * gst_adapter_take_buffer (GstAdapter * adapter, guint nbytes); -#endif - - -GST_BOILERPLATE (GstNuvDemux, gst_nuv_demux, GstElement, GST_TYPE_ELEMENT); - -/****************************************************************************** - * Utils function - ******************************************************************************/ -#if G_BYTE_ORDER == G_BIG_ENDIAN -static inline gdouble -_gdouble_swap_le_be (gdouble * d) -{ - union - { - guint64 i; - gdouble d; - } u; - - u.d = *d; - u.i = GUINT64_SWAP_LE_BE (u.i); - return u.d; -} - -#define READ_DOUBLE_FROM_LE(d) (_gdouble_swap_le_be((gdouble* ) d)) -#else /* G_BYTE_ORDER != G_BIG_ENDIAN */ -#define READ_DOUBLE_FROM_LE(d) *((gdouble* ) (d)) -#endif /* G_BYTE_ORDER != G_BIG_ENDIAN */ - -static void -double2fraction (double in, int *num, int *denom) -{ - if (in == 29.97) { - *num = 30000; - *denom = 1001; - } else if (in == 23.976) { - *num = 24000; - *denom = 1001; - } else { - *denom = 1; - while (in - floor(in) >= 0.1) { - *denom *= 10; - in *= 10.0; - } - *num = (int)floor(in); - } -} - -/* GObject Functions */ - -static void -gst_nuv_demux_base_init (gpointer klass) -{ - GstElementClass *element_class = GST_ELEMENT_CLASS (klass); - - gst_element_class_add_pad_template (element_class, - gst_static_pad_template_get (&audio_src_template)); - - gst_element_class_add_pad_template (element_class, - gst_static_pad_template_get (&video_src_template)); - - gst_element_class_add_pad_template (element_class, - gst_static_pad_template_get (&sink_template)); - gst_element_class_set_details (element_class, &gst_nuv_demux_details); -} - -static void -gst_nuv_demux_class_init (GstNuvDemuxClass * klass) -{ - GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass); - GObjectClass *gobject_class = (GObjectClass *) klass; - - GST_DEBUG_CATEGORY_INIT (nuvdemux_debug, "nuvdemux", - 0, "Demuxer for NUV streams"); - - parent_class = g_type_class_peek_parent (klass); - - gobject_class->dispose = gst_nuv_demux_dispose; - gobject_class->finalize = gst_nuv_demux_finalize; - gstelement_class->change_state = gst_nuv_demux_change_state; - - g_type_class_add_private (gobject_class, sizeof (GstNuvDemuxPrivate)); -} - -static void -gst_nuv_demux_init (GstNuvDemux * nuv, GstNuvDemuxClass * nuv_class) -{ - nuv->priv = GST_NUV_DEMUX_GET_PRIVATE (nuv); - nuv->priv->sinkpad = gst_pad_new_from_static_template (&sink_template, "sink"); - - /* creating adapter */ - nuv->priv->mode = NUV_PUSH_MODE; - nuv->priv->adapter = gst_adapter_new (); - - nuv->priv->new_audio_segment = TRUE; - nuv->priv->new_video_segment = TRUE; - - gst_pad_set_activate_function (nuv->priv->sinkpad, gst_nuv_demux_sink_activate); - gst_pad_set_activatepull_function (nuv->priv->sinkpad, - gst_nuv_demux_sink_activate_pull); - gst_pad_set_activatepush_function (nuv->priv->sinkpad, - gst_nuv_demux_sink_activate_push); - gst_pad_set_chain_function (nuv->priv->sinkpad, - GST_DEBUG_FUNCPTR (gst_nuv_demux_chain)); -/* - gst_pad_set_event_function (nuv->priv->sinkpad, - gst_nuv_demux_sink_event); -*/ - - gst_element_add_pad (GST_ELEMENT (nuv), nuv->priv->sinkpad); - -} - -static void -gst_nuv_demux_dispose (GObject * object) -{ - GstNuvDemux *nuv = GST_NUV_DEMUX (object); - - - if (nuv->priv->mpeg_buffer != NULL) { - gst_buffer_unref (nuv->priv->mpeg_buffer); - } - - gst_nuv_demux_reset (GST_NUV_DEMUX (object)); - gst_nuv_demux_destoy_src_pad (GST_NUV_DEMUX (object)); - - if (nuv->priv->adapter != NULL) { - gst_object_unref (nuv->priv->adapter); - } -} - -static void -gst_nuv_demux_finalize (GObject * object) -{ - G_OBJECT_CLASS (parent_class)->finalize (object); -} - - -/* HeaderLoad: - */ -static GstFlowReturn -gst_nuv_demux_header_load (GstNuvDemux * nuv, nuv_header *h) -{ - GstBuffer *buffer = NULL; - GstFlowReturn res = gst_nuv_demux_read_bytes (nuv, 72, TRUE, &buffer); - - if ((res != GST_FLOW_OK) || (buffer == NULL)) { - goto done; - } - - memcpy (h->id, buffer->data, 12); - memcpy (h->version, buffer->data + 12, 5); - h->i_width = GST_READ_UINT32_LE (&buffer->data[20]); - h->i_height = GST_READ_UINT32_LE (&buffer->data[24]); - h->i_width_desired = GST_READ_UINT32_LE (&buffer->data[28]); - h->i_height_desired = GST_READ_UINT32_LE (&buffer->data[32]); - h->i_mode = GPOINTER_TO_INT (buffer->data[36]); - h->d_aspect = READ_DOUBLE_FROM_LE (&buffer->data[40]); - h->d_fps = READ_DOUBLE_FROM_LE (&buffer->data[48]); - /* get the num and denom values from fps */ - double2fraction (h->d_fps, &h->i_fpsn, &h->i_fpsd); - h->i_video_blocks = GST_READ_UINT32_LE (&buffer->data[56]); - h->i_audio_blocks = GST_READ_UINT32_LE (&buffer->data[60]); - h->i_text_blocks = GST_READ_UINT32_LE (&buffer->data[64]); - h->i_keyframe_distance = GST_READ_UINT32_LE (&buffer->data[68]); - - GST_DEBUG_OBJECT (nuv, - "nuv: h=%s v=%s %dx%d a=%f fps=%f v=%d a=%d t=%d kfd=%d", h->id, - h->version, h->i_width, h->i_height, h->d_aspect, h->d_fps, - h->i_video_blocks, h->i_audio_blocks, h->i_text_blocks, - h->i_keyframe_distance); - -done: - if (buffer != NULL) { - gst_buffer_unref (buffer); - buffer = NULL; - } - return res; -} - -static GstFlowReturn -gst_nuv_demux_stream_header_data (GstNuvDemux * nuv) -{ - GstFlowReturn res; - - res = gst_nuv_demux_header_load (nuv, &nuv->priv->h); - if (res == GST_FLOW_OK) - nuv->priv->state = GST_NUV_DEMUX_EXTRA_DATA; - return res; -} - -/* - * Read NUV file tag - */ -static GstFlowReturn -gst_nuv_demux_stream_file_header (GstNuvDemux * nuv) -{ - GstFlowReturn res = GST_FLOW_OK; - GstBuffer *file_header = NULL; - - res = gst_nuv_demux_read_bytes (nuv, 12, FALSE, &file_header); - if (res == GST_FLOW_OK) { - if (strncmp ((gchar *) file_header->data, "MythTVVideo", 11) || - strncmp ((gchar *) file_header->data, "NuppelVideo", 11)) { - nuv->priv->state = GST_NUV_DEMUX_HEADER_DATA; - } else { - GST_DEBUG_OBJECT (nuv, "error parsing file header"); - nuv->priv->state = GST_NUV_DEMUX_INVALID_DATA; - res = GST_FLOW_ERROR; - } - } - - if (file_header != NULL) { - gst_buffer_unref (file_header); - file_header = NULL; - } - return res; -} - -/* FrameHeaderLoad: - */ -static GstFlowReturn -gst_nuv_demux_frame_header_load (GstNuvDemux * nuv, nuv_frame_header *h) -{ - unsigned char *data; - GstBuffer *buf = NULL; - - GstFlowReturn res = gst_nuv_demux_read_bytes (nuv, 12, TRUE, &buf); - - if ((res != GST_FLOW_OK) || (buf == NULL)) { - goto done; - } - - data = buf->data; - - h->i_type = GPOINTER_TO_INT (data[0]); - h->i_compression = GPOINTER_TO_INT (data[1]); - h->i_keyframe = GPOINTER_TO_INT (data[2]); - h->i_filters = GPOINTER_TO_INT (data[3]); - h->i_timecode = GST_READ_UINT32_LE (&data[4]); - h->i_length = GST_READ_UINT32_LE (&data[8]); - - GST_DEBUG_OBJECT (nuv, "frame hdr: t=%c c=%c k=%d f=0x%x timecode=%d l=%d", - h->i_type, - h->i_compression ? h->i_compression : ' ', - h->i_keyframe ? h->i_keyframe : ' ', - h->i_filters, h->i_timecode, h->i_length); - -done: - if (buf != NULL) { - gst_buffer_unref (buf); - buf = NULL; - } - - return res; -} - -static GstFlowReturn -gst_nuv_demux_extended_header_load (GstNuvDemux * nuv, - nuv_extended_header * h) -{ - unsigned char *data; - GstBuffer *buff = NULL; - - GstFlowReturn res = gst_nuv_demux_read_bytes (nuv, 512, TRUE, &buff); - - if ((res != GST_FLOW_OK) || (buff == NULL)) { - goto done; - } - - data = buff->data; - h->i_version = GST_READ_UINT32_LE (&data[0]); - h->i_video_fcc = GST_MAKE_FOURCC (data[4], data[5], data[6], data[7]); - h->i_audio_fcc = GST_MAKE_FOURCC (data[8], data[9], data[10], data[11]); - h->i_audio_sample_rate = GST_READ_UINT32_LE (&data[12]); - h->i_audio_bits_per_sample = GST_READ_UINT32_LE (&data[16]); - h->i_audio_channels = GST_READ_UINT32_LE (&data[20]); - h->i_audio_compression_ratio = GST_READ_UINT32_LE (&data[24]); - h->i_audio_quality = GST_READ_UINT32_LE (&data[28]); - h->i_rtjpeg_quality = GST_READ_UINT32_LE (&data[32]); - h->i_rtjpeg_luma_filter = GST_READ_UINT32_LE (&data[36]); - h->i_rtjpeg_chroma_filter = GST_READ_UINT32_LE (&data[40]); - h->i_lavc_bitrate = GST_READ_UINT32_LE (&data[44]); - h->i_lavc_qmin = GST_READ_UINT32_LE (&data[48]); - h->i_lavc_qmin = GST_READ_UINT32_LE (&data[52]); - h->i_lavc_maxqdiff = GST_READ_UINT32_LE (&data[56]); - h->i_seekable_offset = GST_READ_UINT64_LE (&data[60]); - h->i_keyframe_adjust_offset = GST_READ_UINT64_LE (&data[68]); - - GST_DEBUG_OBJECT (nuv, - "ex hdr: v=%d vffc=%4.4s afcc=%4.4s %dHz %dbits ach=%d acr=%d aq=%d" - "rtjpeg q=%d lf=%d lc=%d lavc br=%d qmin=%d qmax=%d maxqdiff=%d seekableoff=%lld keyfao=%lld", - h->i_version, (gchar *) & h->i_video_fcc, (gchar *) & h->i_audio_fcc, - h->i_audio_sample_rate, h->i_audio_bits_per_sample, h->i_audio_channels, - h->i_audio_compression_ratio, h->i_audio_quality, h->i_rtjpeg_quality, - h->i_rtjpeg_luma_filter, h->i_rtjpeg_chroma_filter, h->i_lavc_bitrate, - h->i_lavc_qmin, h->i_lavc_qmax, h->i_lavc_maxqdiff, h->i_seekable_offset, - h->i_keyframe_adjust_offset); - -done: - if (buff != NULL) { - gst_buffer_unref (buff); - buff = NULL; - } - return res; -} - - -/* Query Functions */ -static const GstQueryType * -gst_nuv_demux_get_src_query_types (GstPad * pad) -{ - static const GstQueryType src_types[] = { - GST_QUERY_POSITION, - GST_QUERY_DURATION, - 0 - }; - - return src_types; -} - -static gboolean -gst_nuv_demux_handle_src_query (GstPad * pad, GstQuery * query) -{ - gboolean res = FALSE; - GstNuvDemux *nuv = GST_NUV_DEMUX (gst_pad_get_parent (pad)); - - switch (GST_QUERY_TYPE (query)) { - case GST_QUERY_POSITION: - if (GST_CLOCK_TIME_IS_VALID (nuv->priv->last_frame_time)) { - gst_query_set_position (query, GST_FORMAT_TIME, nuv->priv->last_frame_time); - res = TRUE; - } - break; - case GST_QUERY_DURATION: - { - if (nuv->priv->duration_time != GST_CLOCK_TIME_NONE) { - gst_query_set_duration (query, GST_FORMAT_TIME, nuv->priv->duration_time); - res = TRUE; - } - } - break; - default: - res = FALSE; - break; - } - - gst_object_unref (nuv); - - return res; -} - -static GstPad* -gst_nuv_demux_create_pad (GstNuvDemux *nuv, GstCaps *caps, GstStaticPadTemplate *template, const gchar* name) -{ - GstPad *pad = NULL; - pad = gst_pad_new_from_static_template (template, name); - gst_pad_set_caps (pad, caps); - gst_pad_set_active (pad, TRUE); - gst_pad_use_fixed_caps (pad); - gst_element_add_pad (GST_ELEMENT (nuv), pad); - - gst_pad_set_event_function (pad, - GST_DEBUG_FUNCPTR (gst_nuv_demux_srcpad_event)); - - gst_pad_set_query_type_function (pad, - GST_DEBUG_FUNCPTR (gst_nuv_demux_get_src_query_types)); - - gst_pad_set_query_function (pad, - GST_DEBUG_FUNCPTR (gst_nuv_demux_handle_src_query)); - - - return pad; -} - -static void -gst_nuv_demux_create_pads (GstNuvDemux * nuv) -{ - if (nuv->priv->h.i_video_blocks != 0) { - GstCaps *video_caps = NULL; - - video_caps = gst_caps_new_simple ("video/x-divx", - "divxversion", G_TYPE_INT, 4, - "width", G_TYPE_INT, nuv->priv->h.i_width, - "height", G_TYPE_INT, nuv->priv->h.i_height, - "framerate", GST_TYPE_FRACTION, nuv->priv->h.i_fpsn, nuv->priv->h.i_fpsd, - "format", GST_TYPE_FOURCC, nuv->priv->eh.i_video_fcc, - "pixel-aspect-ratio", GST_TYPE_FRACTION, - (gint) (nuv->priv->h.d_aspect * 1000.0f), 1000, NULL); - - nuv->priv->src_video_pad = gst_nuv_demux_create_pad (nuv, video_caps, &video_src_template, "video_src"); - gst_caps_unref (video_caps); - } - - if (nuv->priv->h.i_audio_blocks != 0) { - GstCaps *audio_caps = NULL; - - audio_caps = gst_caps_new_simple ("audio/mpeg", - "rate", G_TYPE_INT, nuv->priv->eh.i_audio_sample_rate, - "format", GST_TYPE_FOURCC, nuv->priv->eh.i_audio_fcc, - "channels", G_TYPE_INT, nuv->priv->eh.i_audio_channels, - "layer", G_TYPE_INT, 3, // fixme: magic number - "mpegversion", G_TYPE_INT, nuv->priv->eh.i_version, NULL); - - nuv->priv->src_audio_pad = gst_nuv_demux_create_pad (nuv, audio_caps, &audio_src_template, "audio_src"); - gst_caps_unref (audio_caps); - } - - gst_element_no_more_pads (GST_ELEMENT (nuv)); -} - -static gboolean -gst_nuv_demux_validate_header (nuv_frame_header *h) -{ - gboolean valid = FALSE; - //g_usleep (1 * G_USEC_PER_SEC ); - switch (h->i_type) { -/* - case 'V': - if (h->i_compression == 0 || - h->i_compression == 1 || - h->i_compression == 2 || - h->i_compression == 'N' || - h->i_compression == 'L') { - valid = TRUE; - } - break; - case 'A': - if (h->i_compression == 0 || - h->i_compression == 1 || - h->i_compression == 2 || - h->i_compression == 3 || - h->i_compression == 'F' || - h->i_compression == 'S' || - h->i_compression == 'N' || - h->i_compression == 'L') { - valid = TRUE; - } - break; - case 'S': - if (h->i_compression == 'B' || - h->i_compression == 'A' || - h->i_compression == 'V' || - h->i_compression == 'S') { - valid = TRUE; - } - break; -*/ - case 'A': - case 'V': - case 'S': - case 'R': - case 'D': - case 'Q': - valid = TRUE; - break; - default: - valid = FALSE; - } - - return valid; -} - -static GstFlowReturn -gst_nuv_demux_read_head_frame (GstNuvDemux * nuv) -{ - GstFlowReturn ret = GST_FLOW_OK; - gboolean valid = FALSE; - - do { - ret = gst_nuv_demux_frame_header_load (nuv, &nuv->priv->fh); - if (ret != GST_FLOW_OK) { - return ret; - } - - if (gst_nuv_demux_validate_header (&nuv->priv->fh) == TRUE) - valid = TRUE; - - } while (valid == FALSE); - - nuv->priv->state = GST_NUV_DEMUX_MOVI; - return ret; -} - -static gboolean -gst_nuv_combine_flow (GstNuvDemux *nuv) -{ - GstFlowReturn ret_video = nuv->priv->last_video_return; - GstFlowReturn ret_audio = nuv->priv->last_audio_return; - - if ((ret_video != GST_FLOW_OK) && - (ret_audio != GST_FLOW_OK)) - return FALSE; - - if (GST_FLOW_IS_FATAL (ret_video)) - return FALSE; - - if (GST_FLOW_IS_FATAL (ret_audio)) - return FALSE; - - return TRUE; -} - -static GstFlowReturn -gst_nuv_demux_stream_data (GstNuvDemux * nuv) -{ - GstFlowReturn ret = GST_FLOW_OK; - GstPad *pad = NULL; - guint64 timestamp; - GstBuffer *buf = NULL; - nuv_frame_header h; - - h = nuv->priv->fh; - - if (h.i_type == 'R') { - goto done; - } - - if (h.i_length > 0) { - ret = gst_nuv_demux_read_bytes (nuv, h.i_length, TRUE, &buf); - if ((ret != GST_FLOW_OK) || (buf == NULL)) { - goto done; - } - - if ((h.i_timecode < 0)) { - h.i_timecode = 0; - //goto done; - } - - timestamp = h.i_timecode * GST_MSECOND; - GST_BUFFER_TIMESTAMP (buf) = timestamp; - } - else { - goto done; - } - - - switch (h.i_type) { - case 'V': - { - pad = nuv->priv->src_video_pad; - - if (nuv->priv->new_video_segment) { - - /* send new segment event*/ - gst_pad_push_event (nuv->priv->src_video_pad, - gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_TIME, 0, - GST_CLOCK_TIME_NONE, 0)); - - if (nuv->priv->time_start == GST_CLOCK_TIME_NONE) { - nuv->priv->time_start = timestamp; - } - nuv->priv->new_video_segment = FALSE; - } - - break; - } - case 'A': - { - pad = nuv->priv->src_audio_pad; - - if (nuv->priv->new_audio_segment) { - /* send new segment event*/ - gst_pad_push_event (nuv->priv->src_audio_pad, - gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_TIME, 0, - GST_CLOCK_TIME_NONE, 0)); - - if (nuv->priv->time_start == GST_CLOCK_TIME_NONE) { - nuv->priv->time_start = timestamp; - } - nuv->priv->new_audio_segment = FALSE; - } - - break; - } - case 'S': - { - switch (h.i_compression) { - case 'V': - GST_DEBUG_OBJECT (nuv, "sending new video segment: %d", h.i_timecode); - gst_pad_push_event (nuv->priv->src_video_pad, - gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_TIME, h.i_timecode * GST_MSECOND, - GST_CLOCK_TIME_NONE, 0)); - break; - case 'A': - GST_DEBUG_OBJECT (nuv, "sending new audio segment: %d", h.i_timecode); - gst_pad_push_event (nuv->priv->src_audio_pad, - gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_TIME, 0, - GST_CLOCK_TIME_NONE, 0)); - break; - default: - break; - } - goto done; - } - default: - break; - } - - if ((buf != NULL) && (pad != NULL)) { - /* pushing the buffer */ - gst_buffer_set_caps (buf, GST_PAD_CAPS (pad)); - ret = gst_pad_push (pad, buf); - buf = NULL; - - if (ret != GST_FLOW_OK) { - GST_WARNING_OBJECT (nuv, "error: %d pushing on srcpad %s", ret, gst_pad_get_name (pad)); - - if (pad == nuv->priv->src_video_pad) { - nuv->priv->last_video_return = ret; - } - else if (pad == nuv->priv->src_audio_pad) { - nuv->priv->last_audio_return = ret; - } - - /* verify anothers flow if is necessary stop task */ - if (gst_nuv_combine_flow (nuv) != FALSE) { - ret = GST_FLOW_OK; - } else { - GST_WARNING_OBJECT (nuv, "error: on push"); - } - - } - } - -done: - if (buf != NULL) { - gst_buffer_unref (buf); - buf = NULL; - } - if (ret == GST_FLOW_OK) { - nuv->priv->state = GST_NUV_DEMUX_FRAME_HEADER; - memset (&nuv->priv->fh, 0, sizeof (nuv->priv->fh)); - } - return ret; -} - -static GstFlowReturn -gst_nuv_demux_stream_mpeg_data (GstNuvDemux * nuv) -{ - GstFlowReturn ret = GST_FLOW_OK; - - /* ffmpeg extra data */ - ret = gst_nuv_demux_read_bytes (nuv, nuv->priv->mpeg_data_size, TRUE, - &nuv->priv->mpeg_buffer); - if ((ret != GST_FLOW_OK) || (nuv->priv->mpeg_buffer == NULL)) { - return ret; - } - - GST_BUFFER_SIZE (nuv->priv->mpeg_buffer) = nuv->priv->mpeg_data_size; - nuv->priv->state = GST_NUV_DEMUX_EXTEND_HEADER; - return ret; -} - -static GstFlowReturn -gst_nuv_demux_stream_extra_data (GstNuvDemux * nuv) -{ - GstFlowReturn ret = GST_FLOW_OK; - - /* Load 'D' */ - nuv_frame_header h; - - ret = gst_nuv_demux_frame_header_load (nuv, &h); - if (ret != GST_FLOW_OK) - return ret; - - if (h.i_type != 'D') { - GST_WARNING_OBJECT (nuv, "Unsuported rtjpeg"); - return GST_FLOW_NOT_SUPPORTED; - } - - if (h.i_length > 0) { - if (h.i_compression == 'F') { - nuv->priv->state = GST_NUV_DEMUX_MPEG_DATA; - } else { - GST_WARNING_OBJECT (nuv, "only file with extended chunk are supported"); - return GST_FLOW_NOT_SUPPORTED; - } - } else { - nuv->priv->state = GST_NUV_DEMUX_EXTEND_HEADER; - } - - return ret; -} - -static GstFlowReturn -gst_nuv_demux_stream_extend_header_data (GstNuvDemux * nuv) -{ - GstFlowReturn ret = GST_FLOW_OK; - - ret = gst_nuv_demux_extended_header_load (nuv, &nuv->priv->eh); - if (ret != GST_FLOW_OK) - return ret; - - gst_nuv_demux_create_pads (nuv); - nuv->priv->state = GST_NUV_DEMUX_INDEX_CREATE; - return ret; -} - -static GstFlowReturn -gst_nuv_demux_stream_extend_header (GstNuvDemux * nuv) -{ - GstBuffer *buf = NULL; - GstFlowReturn res = GST_FLOW_OK; - - res = gst_nuv_demux_read_bytes (nuv, 1, FALSE, &buf); - if ((res != GST_FLOW_OK) || (buf == NULL)) { - if (buf != NULL) { - gst_buffer_unref (buf); - } - return res; - } - - if (buf->data[0] == 'X') { - gst_buffer_unref (buf); - buf = NULL; - nuv_frame_header h; - - res = gst_nuv_demux_frame_header_load (nuv, &h); - if (res != GST_FLOW_OK) - return res; - - if (h.i_length != 512) { - return GST_FLOW_ERROR; - } - nuv->priv->state = GST_NUV_DEMUX_EXTEND_HEADER_DATA; - } else { - nuv->priv->state = GST_NUV_DEMUX_INVALID_DATA; - g_object_unref (buf); - GST_ELEMENT_WARNING (nuv, STREAM, FAILED, - (_("incomplete NUV support")), ("incomplete NUV support")); - return GST_FLOW_ERROR; - } - return res; -} - -static void -gst_nuv_demux_create_seek_index (GstNuvDemux * nuv) -{ - GstMessage *msg; - nuv_frame_header h; - - while (gst_nuv_demux_frame_header_load (nuv, &h) == GST_FLOW_OK) { - if ((h.i_type == 'V') && (h.i_keyframe == 0)) { - frame_index_data *f = g_new0 (frame_index_data, 1); - - f->offset = nuv->priv->offset - 12; - f->timecode = h.i_timecode * GST_MSECOND; - - nuv->priv->index = g_slist_append (nuv->priv->index, f); - } - if (h.i_type != 'R') { - nuv->priv->offset += h.i_length; - if (h.i_type == 'A' || h.i_type == 'V') - nuv->priv->duration_time = h.i_timecode * GST_MSECOND; - } - } - GST_DEBUG_OBJECT (nuv, "CREATING INDEX: DONE : DURATION Bytes/Sec: %" G_GUINT64_FORMAT "/%" G_GUINT64_FORMAT, - nuv->priv->offset, nuv->priv->duration_time); - - nuv->priv->duration_bytes = nuv->priv->offset; - nuv->priv->offset = nuv->priv->header_lengh; - - msg = gst_message_new_duration (GST_OBJECT (nuv), GST_FORMAT_TIME, nuv->priv->duration_time); - gst_element_post_message (GST_ELEMENT (nuv), msg); -} - -static GstFlowReturn -gst_nuv_demux_play (GstPad * pad) -{ - GstFlowReturn res = GST_FLOW_OK; - GstNuvDemux *nuv = GST_NUV_DEMUX (GST_PAD_PARENT (pad)); - - switch (nuv->priv->state) { - case GST_NUV_DEMUX_START: - res = gst_nuv_demux_stream_file_header (nuv); - if ((res != GST_FLOW_OK) && (res != GST_FLOW_ERROR_NO_DATA)) { - goto pause; - } - break; - - case GST_NUV_DEMUX_HEADER_DATA: - res = gst_nuv_demux_stream_header_data (nuv); - if ((res != GST_FLOW_OK) && (res != GST_FLOW_ERROR_NO_DATA)) { - goto pause; - } - break; - - case GST_NUV_DEMUX_EXTRA_DATA: - res = gst_nuv_demux_stream_extra_data (nuv); - if ((res != GST_FLOW_OK) && (res != GST_FLOW_ERROR_NO_DATA)) { - goto pause; - } - break; - - case GST_NUV_DEMUX_MPEG_DATA: - res = gst_nuv_demux_stream_mpeg_data (nuv); - if ((res != GST_FLOW_OK) && (res != GST_FLOW_ERROR_NO_DATA)) { - goto pause; - } - break; - - case GST_NUV_DEMUX_EXTEND_HEADER: - res = gst_nuv_demux_stream_extend_header (nuv); - if ((res != GST_FLOW_OK) && (res != GST_FLOW_ERROR_NO_DATA)) { - goto pause; - } - break; - - case GST_NUV_DEMUX_EXTEND_HEADER_DATA: - res = gst_nuv_demux_stream_extend_header_data (nuv); - if ((res != GST_FLOW_OK) && (res != GST_FLOW_ERROR_NO_DATA)) { - goto pause; - } - //store file header size - nuv->priv->header_lengh = nuv->priv->offset; - break; - - case GST_NUV_DEMUX_INDEX_CREATE: - if (nuv->priv->mode == NUV_PULL_MODE) { - gst_nuv_demux_create_seek_index (nuv); - } - - case GST_NUV_DEMUX_FRAME_HEADER: - res = gst_nuv_demux_read_head_frame (nuv); - if ((res != GST_FLOW_OK) && (res != GST_FLOW_ERROR_NO_DATA)) { - goto pause; - } - break; - - case GST_NUV_DEMUX_MOVI: - res = gst_nuv_demux_stream_data (nuv); - if ((res != GST_FLOW_OK) && (res != GST_FLOW_ERROR_NO_DATA)) { - goto pause; - } - break; - - case GST_NUV_DEMUX_INVALID_DATA: - goto pause; - break; - default: - g_assert_not_reached (); - } - - return GST_FLOW_OK; - -pause: - GST_LOG_OBJECT (nuv, "pausing task, reason %s", gst_flow_get_name (res)); - gst_pad_pause_task (nuv->priv->sinkpad); - - if (res == GST_FLOW_ERROR_EOS) { - gst_nuv_demux_send_eos (nuv); - nuv->priv->eos = TRUE; - res = GST_FLOW_OK; - } - - if (GST_FLOW_IS_FATAL (res)) { - GST_ELEMENT_ERROR (nuv, STREAM, FAILED, - (_("Internal data stream error.")), - ("streaming stopped, reason %s", gst_flow_get_name (res))); - - gst_nuv_demux_send_eos (nuv); - } - return res; -} - -static void -gst_nuv_demux_send_eos (GstNuvDemux * nuv) -{ - gst_element_post_message (GST_ELEMENT (nuv), - gst_message_new_segment_done (GST_OBJECT (nuv), GST_FORMAT_TIME, -1)); - - if (nuv->priv->src_video_pad) - gst_pad_push_event (nuv->priv->src_video_pad, gst_event_new_eos ()); - if (nuv->priv->src_audio_pad) - gst_pad_push_event (nuv->priv->src_audio_pad, gst_event_new_eos ()); -} - -static GstFlowReturn -gst_nuv_demux_read_bytes (GstNuvDemux * nuv, guint64 size, gboolean move, - GstBuffer ** buffer) -{ - GstFlowReturn ret = GST_FLOW_OK; - - if (size == 0) { - return ret; - } - - - if (nuv->priv->mode == NUV_PULL_MODE) { - ret = gst_pad_pull_range (nuv->priv->sinkpad, nuv->priv->offset, size, buffer); - if (ret == GST_FLOW_OK) { - if (move) { - nuv->priv->offset += size; - } - /* got eos */ - } else if (ret == GST_FLOW_UNEXPECTED) { - return GST_FLOW_ERROR_EOS; - } - } else { - if (gst_adapter_available (nuv->priv->adapter) < size) { - nuv->priv->more_data = TRUE; - return GST_FLOW_ERROR_NO_DATA; - } - if (move) { - *buffer = gst_adapter_take_buffer (nuv->priv->adapter, size); - } else { - guint8 *data = NULL; - data = (guint8 *) gst_adapter_peek (nuv->priv->adapter, size); - *buffer = gst_buffer_new (); - gst_buffer_set_data (*buffer, data, size); - } - } - return ret; -} - -static gboolean -gst_nuv_demux_sink_activate (GstPad * sinkpad) -{ - gboolean res = TRUE; - GstNuvDemux *nuv = GST_NUV_DEMUX (gst_pad_get_parent (sinkpad)); - - if (gst_pad_check_pull_range (sinkpad)) { - gst_adapter_clear (nuv->priv->adapter); - res = gst_pad_activate_pull (sinkpad, TRUE); - } else { - gst_adapter_clear (nuv->priv->adapter); - res = gst_pad_activate_push (sinkpad, TRUE); - } - - g_object_unref (nuv); - return res; -} - -static gboolean -gst_nuv_demux_sink_activate_pull (GstPad * sinkpad, gboolean active) -{ - GstNuvDemux *nuv = GST_NUV_DEMUX (gst_pad_get_parent (sinkpad)); - - if (active) { - GST_DEBUG_OBJECT (nuv, "activating pull function"); - nuv->priv->mode = NUV_PULL_MODE; - gst_adapter_clear (nuv->priv->adapter); - - gst_pad_start_task (sinkpad, (GstTaskFunction) gst_nuv_demux_loop, sinkpad); - } else { - GST_DEBUG_OBJECT (nuv, "deactivating pull function"); - gst_pad_stop_task (sinkpad); - } - gst_object_unref (nuv); - - return TRUE; -} - -static gboolean -gst_nuv_demux_sink_activate_push (GstPad * pad, gboolean active) -{ - GstNuvDemux *nuv = GST_NUV_DEMUX (gst_pad_get_parent (pad)); - - if (active) { - nuv->priv->mode = NUV_PUSH_MODE; - gst_adapter_clear (nuv->priv->adapter); - - GST_DEBUG_OBJECT (nuv, "activating push/chain function"); - } else { - GST_DEBUG_OBJECT (nuv, "deactivating push/chain function"); - } - - gst_object_unref (nuv); - - return TRUE; -} - -static frame_index_data * -gst_nuv_demux_do_seek_index (GstNuvDemux *nuv, gint64 seek_pos, - gint64 segment_stop, GstFormat format) -{ - GSList *l; - frame_index_data *ret = NULL; - - if (nuv->priv->index == NULL) { - return NULL; - } - - /* find keyframe closest to the requested position */ - for (l = nuv->priv->index; l != NULL; l = l->next) { - frame_index_data *f = (frame_index_data *) l->data; - gint64 pos = 0; - - if (format == GST_FORMAT_BYTES) { - pos = f->offset; - } else if (format == GST_FORMAT_TIME) { - pos = f->timecode; - } else { - return NULL; - } - - if (pos >= seek_pos) { - ret = f; - break; - } - - if ((segment_stop != -1) && (segment_stop != GST_CLOCK_TIME_NONE) && (pos > segment_stop)) { - break; - } - } - - return ret; -} - -static gboolean -gst_nuv_demux_do_seek (GstNuvDemux *nuv, GstEvent * event) -{ - gdouble rate; - GstFormat format; - GstSeekFlags flags; - GstSeekType cur_type; - gint64 cur; - GstSeekType stop_type; - gint64 stop; - gboolean flush; - frame_index_data *entry; - gint64 segment_start; - gint64 segment_stop; - GstEvent *newsegment_event; - - if (nuv->priv->eos) { - return FALSE; - } - - if (nuv->priv->mode == NUV_PUSH_MODE) { - return FALSE; - } - - - gst_event_parse_seek (event, &rate, &format, &flags, - &cur_type, &cur, &stop_type, &stop); - - - -/* - if (format == GST_FORMAT_TIME) { - GST_DEBUG_OBJECT (nuv, "Can only seek on BYTES"); - return FALSE; - } -*/ - - if (rate <= 0.0) { - GST_DEBUG_OBJECT (nuv, "Can only seek with positive rate"); - return FALSE; - } - - if (cur_type == GST_SEEK_TYPE_SET) { - GST_OBJECT_LOCK (nuv); - if (gst_nuv_demux_do_seek_index (nuv, cur, -1, format) == NULL) { - GST_DEBUG_OBJECT (nuv, "No matching seek entry in index"); - GST_OBJECT_UNLOCK (nuv); - return FALSE; - } - GST_OBJECT_UNLOCK (nuv); - } - - flush = !!(flags & GST_SEEK_FLAG_FLUSH); - - if (flush) { - gst_pad_push_event (nuv->priv->sinkpad, gst_event_new_flush_start ()); - if (nuv->priv->src_video_pad != NULL) { - gst_pad_push_event (nuv->priv->src_video_pad, gst_event_new_flush_start ()); - } - - if (nuv->priv->src_audio_pad != NULL) { - gst_pad_push_event (nuv->priv->src_audio_pad, gst_event_new_flush_start ()); - } - } - else { - gst_pad_pause_task (nuv->priv->sinkpad); - } - - GST_PAD_STREAM_LOCK (nuv->priv->sinkpad); - GST_OBJECT_LOCK (nuv); - - - if (cur == GST_CLOCK_TIME_NONE) - cur = 0; - if (stop == GST_CLOCK_TIME_NONE) - stop = nuv->priv->duration_time; - - if (cur_type == GST_SEEK_TYPE_SET) - segment_start = cur; - else if (cur_type == GST_SEEK_TYPE_CUR) - segment_start = nuv->priv->segment_start + cur; - else - segment_start = nuv->priv->segment_start; - - if (stop_type == GST_SEEK_TYPE_SET) - segment_stop = stop; - else if (stop_type == GST_SEEK_TYPE_CUR) - segment_stop = nuv->priv->segment_stop + stop; - else - segment_stop = nuv->priv->segment_stop; - - segment_start = CLAMP (segment_start, 0, nuv->priv->duration_time); - segment_stop = CLAMP (segment_stop, 0, nuv->priv->duration_time); - - entry = gst_nuv_demux_do_seek_index (nuv, segment_start, - segment_stop, format); - - if (entry == NULL) { - GST_DEBUG_OBJECT (nuv, "No matching seek entry in index"); - goto seek_error; - } - - segment_start = entry->timecode; - - nuv->priv->segment_start = segment_start; - nuv->priv->segment_stop = segment_stop; - - GST_OBJECT_UNLOCK (nuv); - - if (!nuv->priv->eos) { - GstMessage *msg; - msg = gst_message_new_segment_start (GST_OBJECT (nuv), GST_FORMAT_TIME, - nuv->priv->segment_start); - - gst_element_post_message (GST_ELEMENT (nuv), msg); - } - - GST_DEBUG_OBJECT (nuv, "NEW SEGMENT START %" G_GUINT64_FORMAT ", STOP %" G_GUINT64_FORMAT, - segment_start, segment_stop); - newsegment_event = gst_event_new_new_segment (FALSE, rate, - GST_FORMAT_TIME, segment_start, segment_stop, segment_start); - - - if (flush) { - if (nuv->priv->src_video_pad != NULL) { - gst_pad_push_event (nuv->priv->src_video_pad, gst_event_new_flush_stop ()); - } - - if (nuv->priv->src_audio_pad != NULL) { - gst_pad_push_event (nuv->priv->src_audio_pad, gst_event_new_flush_stop ()); - } - - gst_pad_push_event (nuv->priv->sinkpad, gst_event_new_flush_stop ()); - } - - - if (nuv->priv->src_video_pad != NULL) { - gst_pad_push_event (nuv->priv->src_video_pad, gst_event_ref (newsegment_event)); - } - if (nuv->priv->src_audio_pad != NULL) { - gst_pad_push_event (nuv->priv->src_audio_pad, gst_event_ref (newsegment_event)); - } - - gst_event_unref (newsegment_event); - - nuv->priv->state = GST_NUV_DEMUX_FRAME_HEADER; - nuv->priv->offset = entry->offset; - - gst_pad_start_task (nuv->priv->sinkpad, (GstTaskFunction) gst_nuv_demux_loop, - nuv->priv->sinkpad); - - GST_PAD_STREAM_UNLOCK (nuv->priv->sinkpad); - return TRUE; - -seek_error: - GST_DEBUG_OBJECT (nuv, "Got a seek error"); - GST_OBJECT_UNLOCK (nuv); - GST_PAD_STREAM_UNLOCK (nuv->priv->sinkpad); - return FALSE; - -} - -static gboolean -gst_nuv_demux_srcpad_event (GstPad * pad, GstEvent * event) -{ - gboolean res = FALSE; - GstNuvDemux *nuv; - - nuv = GST_NUV_DEMUX (gst_pad_get_parent (pad)); - - switch (GST_EVENT_TYPE (event)) { - case GST_EVENT_SEEK: - res = gst_nuv_demux_do_seek (nuv, event); - break; - default: - res = FALSE; - break; - } - - gst_object_unref (nuv); - return res; -} - -static GstFlowReturn -gst_nuv_demux_chain (GstPad * pad, GstBuffer * buf) -{ - GstFlowReturn ret = GST_FLOW_OK; - GstNuvDemux *nuv = GST_NUV_DEMUX (gst_pad_get_parent (pad)); - - if (nuv->priv->mode != NUV_PUSH_MODE) - return ret; - - gst_adapter_push (nuv->priv->adapter, buf); - - while ((ret == GST_FLOW_OK) && (nuv->priv->more_data == FALSE)) { - ret = gst_nuv_demux_play (pad); - } - - nuv->priv->more_data = FALSE; - gst_object_unref (nuv); - - return ret; -} - -static void -gst_nuv_demux_loop (GstPad * pad) -{ - gst_nuv_demux_play (pad); -} - -static void -gst_nuv_demux_index_free (gpointer data, gpointer user_data) -{ - g_free (data); -} - -static void -gst_nuv_demux_reset (GstNuvDemux * nuv) -{ - nuv->priv->eos = FALSE; - nuv->priv->more_data = FALSE; - nuv->priv->state = GST_NUV_DEMUX_START; - nuv->priv->mode = NUV_PUSH_MODE; - nuv->priv->offset = 0; - nuv->priv->time_start = 0; - nuv->priv->time_qos = GST_CLOCK_TIME_NONE; - nuv->priv->duration_bytes = GST_CLOCK_TIME_NONE; - nuv->priv->duration_time = GST_CLOCK_TIME_NONE; - nuv->priv->last_video_return = GST_FLOW_OK; - nuv->priv->last_audio_return = GST_FLOW_OK; - nuv->priv->header_lengh = 0; - nuv->priv->segment_stop = GST_CLOCK_TIME_NONE; - nuv->priv->segment_start = GST_CLOCK_TIME_NONE; - - //clear index list - g_slist_foreach (nuv->priv->index, gst_nuv_demux_index_free, NULL); - g_slist_free (nuv->priv->index); - nuv->priv->index = NULL; - - gst_adapter_clear (nuv->priv->adapter); - - if (nuv->priv->mpeg_buffer != NULL) { - gst_buffer_unref (nuv->priv->mpeg_buffer); - nuv->priv->mpeg_buffer = NULL; - } -} - -static void -gst_nuv_demux_destoy_src_pad (GstNuvDemux * nuv) -{ - if (nuv->priv->src_video_pad) { - gst_element_remove_pad (GST_ELEMENT (nuv), nuv->priv->src_video_pad); - nuv->priv->src_video_pad = NULL; - } - - if (nuv->priv->src_audio_pad) { - gst_element_remove_pad (GST_ELEMENT (nuv), nuv->priv->src_audio_pad); - nuv->priv->src_audio_pad = NULL; - } -} - -static GstStateChangeReturn -gst_nuv_demux_change_state (GstElement * element, GstStateChange transition) -{ - GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS; - - switch (transition) { - case GST_STATE_CHANGE_NULL_TO_READY: - gst_nuv_demux_reset (GST_NUV_DEMUX (element)); - gst_nuv_demux_destoy_src_pad (GST_NUV_DEMUX (element)); - break; - default: - break; - } - - ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition); - if (ret == GST_STATE_CHANGE_FAILURE) { - goto done; - } - - switch (transition) { - case GST_STATE_CHANGE_READY_TO_NULL: - gst_nuv_demux_reset (GST_NUV_DEMUX (element)); - gst_nuv_demux_destoy_src_pad (GST_NUV_DEMUX (element)); - break; - default: - break; - } - -done: - return ret; -} - -#if (GST_VERSION_MINOR == 10) && (GST_VERSION_MICRO < 6) -GstBuffer * -gst_adapter_take_buffer (GstAdapter * adapter, guint nbytes) -{ - GstBuffer *buffer; - GstBuffer *cur; - guint8 *data; - - g_return_val_if_fail (GST_IS_ADAPTER (adapter), NULL); - g_return_val_if_fail (nbytes > 0, NULL); - - GST_LOG_OBJECT (adapter, "taking buffer of %u bytes", nbytes); - - /* we don't have enough data, return NULL. This is unlikely - * as one usually does an _available() first instead of peeking a - * random size. */ - if (G_UNLIKELY (nbytes > adapter->size)) - return NULL; - - /* our head buffer has enough data left, return it */ - cur = adapter->buflist->data; - if (GST_BUFFER_SIZE (cur) >= nbytes + adapter->skip) { - GST_LOG_OBJECT (adapter, "providing buffer of %d bytes via sub-buffer", - nbytes); - buffer = gst_buffer_create_sub (cur, adapter->skip, nbytes); - - gst_adapter_flush (adapter, nbytes); - - return buffer; - } - - data = gst_adapter_take (adapter, nbytes); - if (data == NULL) - return NULL; - - buffer = gst_buffer_new (); - GST_BUFFER_DATA (buffer) = data; - GST_BUFFER_MALLOCDATA (buffer) = data; - GST_BUFFER_SIZE (buffer) = nbytes; - - return buffer; -} -#endif - - -static gboolean -plugin_init (GstPlugin * plugin) -{ -#ifdef ENABLE_NLS - setlocale (LC_ALL, ""); - bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); -#endif /* ENABLE_NLS */ - - if (!gst_element_register (plugin, "nuvdemux", GST_RANK_SECONDARY, - GST_TYPE_NUV_DEMUX)) { - return FALSE; - } - return TRUE; -} - -GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, - GST_VERSION_MINOR, - "nuvdemux", - "Demuxes and muxes audio and video", - plugin_init, VERSION, "LGPL", "NuvDemux", "") - diff -r aa1f309ec686 -r 81f031485b52 gst-plugins-nuvdemux/nuvdemux/gstnuvdemux.h --- a/gst-plugins-nuvdemux/nuvdemux/gstnuvdemux.h Tue May 01 17:03:38 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,55 +0,0 @@ -/* GStreamer - * Copyright (C) <2006> Renato Araujo Oliveira Filho - * Rosfran Borges - * - * 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 Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef __GST_NUV_DEMUX_H__ -#define __GST_NUV_DEMUX_H__ - -#include - -#include - -G_BEGIN_DECLS - -#define GST_TYPE_NUV_DEMUX \ - (gst_nuv_demux_get_type ()) -#define GST_NUV_DEMUX(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_NUV_DEMUX, GstNuvDemux)) -#define GST_NUV_DEMUX_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_NUV_DEMUX, GstNuvDemuxClass)) -#define GST_IS_NUV_DEMUX(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_NUV_DEMUX)) -#define GST_IS_NUV_DEMUX_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_NUV_DEMUX)) - -typedef struct _GstNuvDemuxPrivate GstNuvDemuxPrivate; -typedef struct _GstNuvDemux { - GstElement parent; - GstNuvDemuxPrivate *priv; -} GstNuvDemux; - -typedef struct _GstNuvDemuxClass { - GstElementClass parent_class; -} GstNuvDemuxClass; - -GType gst_nuv_demux_get_type (void); - -G_END_DECLS - -#endif /* __GST_NUV_DEMUX_H__ */ diff -r aa1f309ec686 -r 81f031485b52 gst-plugins-nuvdemux/typefind/Makefile.am --- a/gst-plugins-nuvdemux/typefind/Makefile.am Tue May 01 17:03:38 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ -plugin_LTLIBRARIES = libgsttypefindfunctions_indt.la - -libgsttypefindfunctions_indt_la_SOURCES = \ - gsttypefindfunctions.c - -libgsttypefindfunctions_indt_la_CFLAGS = \ - $(GST_CFLAGS) - -libgsttypefindfunctions_indt_la_LDFLAGS = \ - $(GST_PLUGIN_LDFLAGS) \ - $(GST_BASE_LIBS) - -libgsttypefindfunctions_indt_la_LIBADD = \ - $(GST_LIBS) diff -r aa1f309ec686 -r 81f031485b52 gst-plugins-nuvdemux/typefind/gsttypefindfunctions.c --- a/gst-plugins-nuvdemux/typefind/gsttypefindfunctions.c Tue May 01 17:03:38 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2808 +0,0 @@ -/* GStreamer - * Copyright (C) 2003 Benjamin Otte - * - * gsttypefindfunctions.c: collection of various typefind functions - * - * 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 Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include - -#include -#include -#include -#include -#include - -#include -#include - -GST_DEBUG_CATEGORY_STATIC (type_find_debug); -#define GST_CAT_DEFAULT type_find_debug - -/*** text/plain ***/ -static gboolean xml_check_first_element (GstTypeFind * tf, - const gchar * element, guint elen, gboolean strict); - - -static GstStaticCaps utf8_caps = GST_STATIC_CAPS ("text/plain"); - -#define UTF8_CAPS gst_static_caps_get(&utf8_caps) - -static gboolean -utf8_type_find_have_valid_utf8_at_offset (GstTypeFind * tf, guint64 offset, - GstTypeFindProbability * prob) -{ - guint8 *data; - - /* randomly decided values */ - guint min_size = 16; /* minimum size */ - guint size = 32 * 1024; /* starting size */ - guint probability = 95; /* starting probability */ - guint step = 10; /* how much we reduce probability in each - * iteration */ - - while (probability > step && size > min_size) { - data = gst_type_find_peek (tf, offset, size); - if (data) { - gchar *end; - gchar *start = (gchar *) data; - - if (g_utf8_validate (start, size, (const gchar **) &end) || (end - start + 4 > size)) { /* allow last char to be cut off */ - *prob = probability; - return TRUE; - } - *prob = 0; - return FALSE; - } - size /= 2; - probability -= step; - } - *prob = 0; - return FALSE; -} - -static void -utf8_type_find (GstTypeFind * tf, gpointer unused) -{ - GstTypeFindProbability start_prob, mid_prob; - guint64 length; - - /* leave xml to the xml typefinders */ - if (xml_check_first_element (tf, "", 0, TRUE)) - return; - - /* check beginning of stream */ - if (!utf8_type_find_have_valid_utf8_at_offset (tf, 0, &start_prob)) - return; - - GST_LOG ("start is plain text with probability of %u", start_prob); - - /* POSSIBLE is the highest probability we ever return if we can't - * probe into the middle of the file and don't know its length */ - - length = gst_type_find_get_length (tf); - if (length == 0 || length == (guint64) - 1) { - gst_type_find_suggest (tf, MIN (start_prob, GST_TYPE_FIND_POSSIBLE), - UTF8_CAPS); - return; - } - - if (length < 64 * 1024) { - gst_type_find_suggest (tf, start_prob, UTF8_CAPS); - return; - } - - /* check middle of stream */ - if (!utf8_type_find_have_valid_utf8_at_offset (tf, length / 2, &mid_prob)) - return; - - GST_LOG ("middle is plain text with probability of %u", mid_prob); - gst_type_find_suggest (tf, (start_prob + mid_prob) / 2, UTF8_CAPS); -} - -/*** text/uri-list ***/ - -static GstStaticCaps uri_caps = GST_STATIC_CAPS ("text/uri-list"); - -#define URI_CAPS (gst_static_caps_get(&uri_caps)) -#define BUFFER_SIZE 16 /* If the string is < 16 bytes we're screwed */ -#define INC_BUFFER { \ - pos++; \ - if (pos == BUFFER_SIZE) { \ - pos = 0; \ - offset += BUFFER_SIZE; \ - data = gst_type_find_peek (tf, offset, BUFFER_SIZE); \ - if (data == NULL) return; \ - } else { \ - data++; \ - } \ -} -static void -uri_type_find (GstTypeFind * tf, gpointer unused) -{ - guint8 *data = gst_type_find_peek (tf, 0, BUFFER_SIZE); - guint pos = 0; - guint offset = 0; - - if (data) { - /* Search for # comment lines */ - while (*data == '#') { - /* Goto end of line */ - while (*data != '\n') { - INC_BUFFER; - } - - INC_BUFFER; - } - - if (!g_ascii_isalpha (*data)) { - /* Had a non alpha char - can't be uri-list */ - return; - } - - INC_BUFFER; - - while (g_ascii_isalnum (*data)) { - INC_BUFFER; - } - - if (*data != ':') { - /* First non alpha char is not a : */ - return; - } - - /* Get the next 2 bytes as well */ - data = gst_type_find_peek (tf, offset + pos, 3); - if (data == NULL) - return; - - if (data[1] != '/' && data[2] != '/') { - return; - } - - gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, URI_CAPS); - } -} - - -/*** application/xml **********************************************************/ - -#define XML_BUFFER_SIZE 16 -#define XML_INC_BUFFER { \ - pos++; \ - if (pos == XML_BUFFER_SIZE) { \ - pos = 0; \ - offset += XML_BUFFER_SIZE; \ - data = gst_type_find_peek (tf, offset, XML_BUFFER_SIZE); \ - if (data == NULL) return FALSE; \ - } else { \ - data++; \ - } \ -} - -static gboolean -xml_check_first_element (GstTypeFind * tf, const gchar * element, guint elen, - gboolean strict) -{ - gboolean got_xmldec; - guint8 *data; - guint offset = 0; - guint pos = 0; - - data = gst_type_find_peek (tf, 0, XML_BUFFER_SIZE); - if (!data) - return FALSE; - - /* look for the XMLDec - * see XML spec 2.8, Prolog and Document Type Declaration - * http://www.w3.org/TR/2004/REC-xml-20040204/#sec-prolog-dtd */ - got_xmldec = (memcmp (data, "", 6) == 0) { - gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, HTML_CAPS); - } - } -} - -/*** video/x-fli ***/ - -static GstStaticCaps flx_caps = GST_STATIC_CAPS ("video/x-fli"); - -#define FLX_CAPS gst_static_caps_get(&flx_caps) -static void -flx_type_find (GstTypeFind * tf, gpointer unused) -{ - guint8 *data = gst_type_find_peek (tf, 0, 134); - - if (data) { - /* check magic and the frame type of the first frame */ - if ((data[4] == 0x11 || data[4] == 0x12 || - data[4] == 0x30 || data[4] == 0x44) && - data[5] == 0xaf && - ((data[132] == 0x00 || data[132] == 0xfa) && data[133] == 0xf1)) { - gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, FLX_CAPS); - } - return; - } - data = gst_type_find_peek (tf, 0, 6); - if (data) { - /* check magic only */ - if ((data[4] == 0x11 || data[4] == 0x12 || - data[4] == 0x30 || data[4] == 0x44) && data[5] == 0xaf) { - gst_type_find_suggest (tf, GST_TYPE_FIND_LIKELY, FLX_CAPS); - } - return; - } -} - -/*** application/x-id3 ***/ - -static GstStaticCaps id3_caps = GST_STATIC_CAPS ("application/x-id3"); - -#define ID3_CAPS gst_static_caps_get(&id3_caps) -static void -id3v2_type_find (GstTypeFind * tf, gpointer unused) -{ - guint8 *data = gst_type_find_peek (tf, 0, 10); - - if (data && memcmp (data, "ID3", 3) == 0 && - data[3] != 0xFF && data[4] != 0xFF && - (data[6] & 0x80) == 0 && (data[7] & 0x80) == 0 && - (data[8] & 0x80) == 0 && (data[9] & 0x80) == 0) { - gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, ID3_CAPS); - } -} - -static void -id3v1_type_find (GstTypeFind * tf, gpointer unused) -{ - guint8 *data = gst_type_find_peek (tf, -128, 3); - - if (data && memcmp (data, "TAG", 3) == 0) { - gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, ID3_CAPS); - } -} - -/*** application/x-ape ***/ - -static GstStaticCaps apetag_caps = GST_STATIC_CAPS ("application/x-apetag"); - -#define APETAG_CAPS gst_static_caps_get(&apetag_caps) -static void -apetag_type_find (GstTypeFind * tf, gpointer unused) -{ - guint8 *data; - - /* APEv1/2 at start of file */ - data = gst_type_find_peek (tf, 0, 8); - if (data && !memcmp (data, "APETAGEX", 8)) { - gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, APETAG_CAPS); - return; - } - - /* APEv1/2 at end of file */ - data = gst_type_find_peek (tf, -32, 8); - if (data && !memcmp (data, "APETAGEX", 8)) { - gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, APETAG_CAPS); - return; - } -} - -/*** audio/x-ttafile ***/ - -static GstStaticCaps tta_caps = GST_STATIC_CAPS ("audio/x-ttafile"); - -#define TTA_CAPS gst_static_caps_get(&tta_caps) -static void -tta_type_find (GstTypeFind * tf, gpointer unused) -{ - guint8 *data = gst_type_find_peek (tf, 0, 3); - - if (data) { - if (memcmp (data, "TTA", 3) == 0) { - gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, TTA_CAPS); - return; - } - } -} - -/*** audio/mpeg version 2, 4 ***/ - -static GstStaticCaps aac_caps = GST_STATIC_CAPS ("audio/mpeg, " - "mpegversion = (int) { 2, 4 }, framed = (bool) false"); -#define AAC_CAPS (gst_static_caps_get(&aac_caps)) -#define AAC_AMOUNT (4096) -static void -aac_type_find (GstTypeFind * tf, gpointer unused) -{ - guint8 *data = gst_type_find_peek (tf, 0, AAC_AMOUNT); - gint snc; - - /* detect adts header or adif header. - * The ADIF header is 4 bytes, that should be OK. The ADTS header, on - * the other hand, is 14 bits only, so we require one valid frame with - * again a valid syncpoint on the next one (28 bits) for certainty. We - * require 4 kB, which is quite a lot, since frames are generally 200-400 - * bytes. - */ - if (data) { - gint n; - - for (n = 0; n < AAC_AMOUNT - 3; n++) { - snc = GST_READ_UINT16_BE (&data[n]); - if ((snc & 0xfff6) == 0xfff0) { - /* ADTS header - find frame length */ - gint len; - - GST_DEBUG ("Found one ADTS syncpoint at offset 0x%x, tracing next...", - n); - if (AAC_AMOUNT - n < 5) { - GST_DEBUG ("Not enough data to parse ADTS header"); - break; - } - len = ((data[n + 3] & 0x03) << 11) | - (data[n + 4] << 3) | ((data[n + 5] & 0xe0) >> 5); - if (n + len + 2 >= AAC_AMOUNT) { - GST_DEBUG ("Next frame is not within reach"); - break; - } else if (len == 0) { - continue; - } - - snc = GST_READ_UINT16_BE (&data[n + len]); - if ((snc & 0xfff6) == 0xfff0) { - gint mpegversion = (data[n + 1] & 0x08) ? 2 : 4; - GstCaps *caps = gst_caps_new_simple ("audio/mpeg", - "framed", G_TYPE_BOOLEAN, FALSE, - "mpegversion", G_TYPE_INT, mpegversion, - NULL); - - gst_type_find_suggest (tf, GST_TYPE_FIND_LIKELY, caps); - gst_caps_unref (caps); - - GST_DEBUG ("Found ADTS-%d syncpoint at offset 0x%x (framelen %u)", - mpegversion, n, len); - break; - } - - GST_DEBUG ("No next frame found... (should be at 0x%x)", n + len); - } else if (!memcmp (&data[n], "ADIF", 4)) { - /* ADIF header */ - GstCaps *caps = gst_caps_new_simple ("audio/mpeg", - "framed", G_TYPE_BOOLEAN, FALSE, - "mpegversion", G_TYPE_INT, 4, - NULL); - - gst_type_find_suggest (tf, GST_TYPE_FIND_LIKELY, caps); - gst_caps_unref (caps); - } - } - } -} - -/*** audio/mpeg version 1 ***/ - -/* - * The chance that random data is identified as a valid mp3 header is 63 / 2^18 - * (0.024%) per try. This makes the function for calculating false positives - * 1 - (1 - ((63 / 2 ^18) ^ GST_MP3_TYPEFIND_MIN_HEADERS)) ^ buffersize) - * This has the following probabilities of false positives: - * datasize MIN_HEADERS - * (bytes) 1 2 3 4 - * 4096 62.6% 0.02% 0% 0% - * 16384 98% 0.09% 0% 0% - * 1 MiB 100% 5.88% 0% 0% - * 1 GiB 100% 100% 1.44% 0% - * 1 TiB 100% 100% 100% 0.35% - * This means that the current choice (3 headers by most of the time 4096 byte - * buffers is pretty safe for now. - * - * The max. size of each frame is 1440 bytes, which means that for N frames to - * be detected, we need 1440 * GST_MP3_TYPEFIND_MIN_HEADERS + 3 bytes of data. - * Assuming we step into the stream right after the frame header, this - * means we need 1440 * (GST_MP3_TYPEFIND_MIN_HEADERS + 1) - 1 + 3 bytes - * of data (5762) to always detect any mp3. - */ - -static const guint mp3types_bitrates[2][3][16] = - { {{0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448,}, - {0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384,}, - {0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320,}}, -{{0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256,}, - {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160,}, - {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160,}}, -}; - -static const guint mp3types_freqs[3][3] = { {11025, 12000, 8000}, -{22050, 24000, 16000}, -{44100, 48000, 32000} -}; - -static inline guint -mp3_type_frame_length_from_header (guint32 header, guint * put_layer, - guint * put_channels, guint * put_bitrate, guint * put_samplerate, - gboolean * may_be_free_format, gint possible_free_framelen) -{ - guint bitrate, layer, length, mode, samplerate, version, channels; - - if ((header & 0xffe00000) != 0xffe00000) - return 0; - - /* we don't need extension, copyright, original or - * emphasis for the frame length */ - header >>= 6; - - /* mode */ - mode = header & 0x3; - header >>= 3; - - /* padding */ - length = header & 0x1; - header >>= 1; - - /* sampling frequency */ - samplerate = header & 0x3; - if (samplerate == 3) - return 0; - header >>= 2; - - /* bitrate index */ - bitrate = header & 0xF; - if (bitrate == 0 && possible_free_framelen == -1) { - GST_LOG ("Possibly a free format mp3 - signalling"); - *may_be_free_format = TRUE; - } - if (bitrate == 15 || (bitrate == 0 && possible_free_framelen == -1)) - return 0; - - /* ignore error correction, too */ - header >>= 5; - - /* layer */ - layer = 4 - (header & 0x3); - if (layer == 4) - return 0; - header >>= 2; - - /* version 0=MPEG2.5; 2=MPEG2; 3=MPEG1 */ - version = header & 0x3; - if (version == 1) - return 0; - - /* lookup */ - channels = (mode == 3) ? 1 : 2; - samplerate = mp3types_freqs[version > 0 ? version - 1 : 0][samplerate]; - if (bitrate == 0) { - if (layer == 1) { - length *= 4; - length += possible_free_framelen; - bitrate = length * samplerate / 48000; - } else { - length += possible_free_framelen; - bitrate = length * samplerate / - ((layer == 3 && version != 3) ? 72000 : 144000); - } - } else { - /* calculating */ - bitrate = mp3types_bitrates[version == 3 ? 0 : 1][layer - 1][bitrate]; - if (layer == 1) { - length = ((12000 * bitrate / samplerate) + length) * 4; - } else { - length += ((layer == 3 - && version != 3) ? 72000 : 144000) * bitrate / samplerate; - } - } - - GST_LOG ("mp3typefind: calculated mp3 frame length of %u bytes", length); - GST_LOG - ("mp3typefind: samplerate = %u - bitrate = %u - layer = %u - version = %u" - " - channels = %u", samplerate, bitrate, layer, version, channels); - - if (put_layer) - *put_layer = layer; - if (put_channels) - *put_channels = channels; - if (put_bitrate) - *put_bitrate = bitrate; - if (put_samplerate) - *put_samplerate = samplerate; - - return length; -} - - -static GstStaticCaps mp3_caps = GST_STATIC_CAPS ("audio/mpeg, " - "mpegversion = (int) 1, layer = (int) [ 1, 3 ]"); -#define MP3_CAPS (gst_static_caps_get(&mp3_caps)) -/* - * random values for typefinding - * if no more data is available, we will return a probability of - * (found_headers/TRY_HEADERS) * (MAXIMUM * (TRY_SYNC - bytes_skipped) - * / TRY_SYNC) - * if found_headers >= MIN_HEADERS - */ -#define GST_MP3_TYPEFIND_MIN_HEADERS (2) -#define GST_MP3_TYPEFIND_TRY_HEADERS (5) -#define GST_MP3_TYPEFIND_TRY_SYNC (GST_TYPE_FIND_MAXIMUM * 100) /* 10kB */ -#define GST_MP3_TYPEFIND_SYNC_SIZE (2048) -#define GST_MP3_WRONG_HEADER (10) - -static void -mp3_type_find_at_offset (GstTypeFind * tf, guint64 start_off, - guint * found_layer, GstTypeFindProbability * found_prob) -{ - guint8 *data = NULL; - guint8 *data_end = NULL; - guint size; - guint64 skipped; - gint last_free_offset = -1; - gint last_free_framelen = -1; - gboolean headerstart = TRUE; - - *found_layer = 0; - *found_prob = 0; - - size = 0; - skipped = 0; - while (skipped < GST_MP3_TYPEFIND_TRY_SYNC) { - if (size <= 0) { - size = GST_MP3_TYPEFIND_SYNC_SIZE * 2; - do { - size /= 2; - data = gst_type_find_peek (tf, skipped + start_off, size); - } while (size > 10 && !data); - if (!data) - break; - data_end = data + size; - } - if (*data == 0xFF) { - guint8 *head_data = NULL; - guint layer = 0, bitrate, samplerate, channels; - guint found = 0; /* number of valid headers found */ - guint64 offset = skipped; - - while (found < GST_MP3_TYPEFIND_TRY_HEADERS) { - guint32 head; - guint length; - guint prev_layer = 0, prev_bitrate = 0; - guint prev_channels = 0, prev_samplerate = 0; - gboolean free = FALSE; - - if ((gint64) (offset - skipped + 4) >= 0 && - data + offset - skipped + 4 < data_end) { - head_data = data + offset - skipped; - } else { - head_data = gst_type_find_peek (tf, offset + start_off, 4); - } - if (!head_data) - break; - head = GST_READ_UINT32_BE (head_data); - if (!(length = mp3_type_frame_length_from_header (head, &layer, - &channels, &bitrate, &samplerate, &free, - last_free_framelen))) { - if (free) { - if (last_free_offset == -1) - last_free_offset = offset; - else { - last_free_framelen = offset - last_free_offset; - offset = last_free_offset; - continue; - } - } else { - last_free_framelen = -1; - } - - /* Mark the fact that we didn't find a valid header at the beginning */ - if (found == 0) - headerstart = FALSE; - - GST_LOG ("%d. header at offset %" G_GUINT64_FORMAT - " (0x%" G_GINT64_MODIFIER "x) was not an mp3 header " - "(possibly-free: %s)", found + 1, start_off + offset, - start_off + offset, free ? "yes" : "no"); - break; - } - if ((prev_layer && prev_layer != layer) || - /* (prev_bitrate && prev_bitrate != bitrate) || <-- VBR */ - (prev_samplerate && prev_samplerate != samplerate) || - (prev_channels && prev_channels != channels)) { - /* this means an invalid property, or a change, which might mean - * that this is not a mp3 but just a random bytestream. It could - * be a freaking funky encoded mp3 though. We'll just not count - * this header*/ - prev_layer = layer; - prev_bitrate = bitrate; - prev_channels = channels; - prev_samplerate = samplerate; - } else { - found++; - GST_LOG ("found %d. header at offset %" G_GUINT64_FORMAT " (0x%" - G_GINT64_MODIFIER "X)", found, start_off + offset, - start_off + offset); - } - offset += length; - } - g_assert (found <= GST_MP3_TYPEFIND_TRY_HEADERS); - if (found == GST_MP3_TYPEFIND_TRY_HEADERS || - (found >= GST_MP3_TYPEFIND_MIN_HEADERS && head_data == NULL)) { - /* we can make a valid guess */ - guint probability = found * GST_TYPE_FIND_MAXIMUM * - (GST_MP3_TYPEFIND_TRY_SYNC - skipped) / - GST_MP3_TYPEFIND_TRY_HEADERS / GST_MP3_TYPEFIND_TRY_SYNC; - - if (!headerstart - && ((probability - GST_MP3_WRONG_HEADER) > GST_TYPE_FIND_MINIMUM)) - probability -= GST_MP3_WRONG_HEADER; - if (probability < GST_TYPE_FIND_MINIMUM) - probability = GST_TYPE_FIND_MINIMUM; - if (start_off > 0) - probability /= 2; - - GST_INFO - ("audio/mpeg calculated %u = %u * %u / %u * (%u - %" - G_GUINT64_FORMAT ") / %u", probability, GST_TYPE_FIND_MAXIMUM, - found, GST_MP3_TYPEFIND_TRY_HEADERS, GST_MP3_TYPEFIND_TRY_SYNC, - (guint64) skipped, GST_MP3_TYPEFIND_TRY_SYNC); - /* make sure we're not id3 tagged */ - head_data = gst_type_find_peek (tf, -128, 3); - if (head_data && (memcmp (head_data, "TAG", 3) == 0)) { - probability = 0; - } - g_assert (probability <= GST_TYPE_FIND_MAXIMUM); - - *found_prob = probability; - if (probability > 0) - *found_layer = layer; - return; - } - } - data++; - skipped++; - size--; - } -} - -static void -mp3_type_find (GstTypeFind * tf, gpointer unused) -{ - GstTypeFindProbability prob, mid_prob; - guint8 *data; - guint layer, mid_layer; - guint64 length; - - mp3_type_find_at_offset (tf, 0, &layer, &prob); - length = gst_type_find_get_length (tf); - - if (length == 0 || length == (guint64) - 1) { - if (prob != 0) - goto suggest; - return; - } - - /* if we're pretty certain already, skip the additional check */ - if (prob >= GST_TYPE_FIND_LIKELY) - goto suggest; - - mp3_type_find_at_offset (tf, length / 2, &mid_layer, &mid_prob); - - if (mid_prob > 0) { - if (prob == 0) { - GST_LOG ("detected audio/mpeg only in the middle (p=%u)", mid_prob); - layer = mid_layer; - prob = mid_prob; - goto suggest; - } - - if (layer != mid_layer) { - GST_WARNING ("audio/mpeg layer discrepancy: %u vs. %u", layer, mid_layer); - return; /* FIXME: or should we just go with the one in the middle? */ - } - - /* detected mpeg audio both in middle of the file and at the start */ - prob = (prob + mid_prob) / 2; - goto suggest; - } - - /* let's see if there's a valid header right at the start */ - data = gst_type_find_peek (tf, 0, 4); /* use min. frame size? */ - if (data && mp3_type_frame_length_from_header (GST_READ_UINT32_BE (data), - &layer, NULL, NULL, NULL, NULL, 0) != 0) { - if (prob == 0) - prob = GST_TYPE_FIND_POSSIBLE - 10; - else - prob = MAX (GST_TYPE_FIND_POSSIBLE - 10, prob + 10); - } - - if (prob > 0) - goto suggest; - - return; - -suggest: - { - GstCaps *caps; - - g_assert (layer > 0); - - caps = gst_caps_make_writable (MP3_CAPS); - gst_structure_set (gst_caps_get_structure (caps, 0), "layer", - G_TYPE_INT, layer, NULL); - gst_type_find_suggest (tf, prob, caps); - gst_caps_unref (caps); - return; - } -} - -/*** audio/x-musepack ***/ - -static GstStaticCaps musepack_caps = GST_STATIC_CAPS ("audio/x-musepack"); - -#define MUSEPACK_CAPS (gst_static_caps_get(&musepack_caps)) -static void -musepack_type_find (GstTypeFind * tf, gpointer unused) -{ - guint8 *data = gst_type_find_peek (tf, 0, 4); - - if (data && memcmp (data, "MP+", 3) == 0) { - if ((data[3] & 0x7f) == 7) { - gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, MUSEPACK_CAPS); - } else { - gst_type_find_suggest (tf, GST_TYPE_FIND_LIKELY + 10, MUSEPACK_CAPS); - } - } -} - -/*** audio/x-ac3 ***/ -static GstStaticCaps ac3_caps = GST_STATIC_CAPS ("audio/x-ac3"); - -#define AC3_CAPS (gst_static_caps_get(&ac3_caps)) - -static void -ac3_type_find (GstTypeFind * tf, gpointer unused) -{ - guint8 *data = gst_type_find_peek (tf, 0, 2); - - if (data) { - /* pretty lame method... */ - if (data[0] == 0x0b && data[1] == 0x77) { - gst_type_find_suggest (tf, GST_TYPE_FIND_POSSIBLE, AC3_CAPS); - return; - } - } -} - -/*** wavpack ***/ - -static GstStaticCaps wavpack_caps = -GST_STATIC_CAPS ("audio/x-wavpack, framed = (boolean) false"); - -#define WAVPACK_CAPS (gst_static_caps_get(&wavpack_caps)) - -static GstStaticCaps wavpack_correction_caps = -GST_STATIC_CAPS ("audio/x-wavpack-correction, framed = (boolean) false"); - -#define WAVPACK_CORRECTION_CAPS (gst_static_caps_get(&wavpack_correction_caps)) - -static void -wavpack_type_find (GstTypeFind * tf, gpointer unused) -{ - guint64 offset; - guint32 blocksize; - guint8 *data; - - data = gst_type_find_peek (tf, 0, 32); - if (!data) - return; - - if (data[0] != 'w' || data[1] != 'v' || data[2] != 'p' || data[3] != 'k') - return; - - /* Note: wavpack blocks can be fairly large (easily 60-110k), possibly - * larger than the max. limits imposed by certain typefinding elements - * like id3demux or apedemux, so typefinding is most likely only going to - * work in pull-mode */ - blocksize = GST_READ_UINT32_LE (data + 4); - GST_LOG ("wavpack header, blocksize=0x%04x", blocksize); - offset = 32; - while (offset < 32 + blocksize) { - guint32 sublen; - - /* get chunk header */ - GST_LOG ("peeking at chunk at offset 0x%04x", (guint) offset); - data = gst_type_find_peek (tf, offset, 4); - if (data == NULL) - break; - sublen = ((guint32) data[1]) << 1; - if (data[0] & 0x80) { - sublen |= (((guint32) data[2]) << 9) | (((guint32) data[3]) << 17); - sublen += 1 + 3; /* id + length */ - } else { - sublen += 1 + 1; /* id + length */ - } - if (sublen > blocksize - offset + 32) { - GST_LOG ("chunk length too big (%u > %" G_GUINT64_FORMAT ")", sublen, - blocksize - offset); - break; - } - if ((data[0] & 0x20) == 0) { - switch (data[0] & 0x0f) { - case 0xa: /* ID_WV_BITSTREAM */ - case 0xc: /* ID_WVX_BITSTREAM */ - gst_type_find_suggest (tf, GST_TYPE_FIND_LIKELY, WAVPACK_CAPS); - return; - case 0xb: /* ID_WVC_BITSTREAM */ - gst_type_find_suggest (tf, GST_TYPE_FIND_LIKELY, - WAVPACK_CORRECTION_CAPS); - return; - default: - break; - } - } - offset += sublen; - } -} - -/*** multipart/x-mixed-replace mimestream ***/ - -static GstStaticCaps multipart_caps = -GST_STATIC_CAPS ("multipart/x-mixed-replace"); -#define MULTIPART_CAPS gst_static_caps_get(&multipart_caps) - -/* multipart/x-mixed replace is: - * --[\r]\n - * [\r]\nContent-type:[\r]\n */ -static void -multipart_type_find (GstTypeFind * tf, gpointer unused) -{ - guint8 *data; - guint8 *x; - -#define MULTIPART_MAX_BOUNDARY_OFFSET 16 - data = gst_type_find_peek (tf, 0, MULTIPART_MAX_BOUNDARY_OFFSET); - if (!data) - return; - - for (x = data; - x - data < MULTIPART_MAX_BOUNDARY_OFFSET - 2 && g_ascii_isspace (*x); - x++); - if (x[0] != '-' || x[1] != '-') - return; - - /* Could be okay, peek what should be enough for a complete header */ -#define MULTIPART_MAX_HEADER_SIZE 256 - data = gst_type_find_peek (tf, 0, MULTIPART_MAX_HEADER_SIZE); - if (!data) - return; - - for (x = data; x - data < MULTIPART_MAX_HEADER_SIZE - 14; x++) { - if (!isascii (*x)) { - return; - } - if (*x == '\n' && - !g_ascii_strncasecmp ("content-type:", (gchar *) x + 1, 13)) { - GstCaps *caps = gst_caps_copy (MULTIPART_CAPS); - - gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, caps); - gst_caps_unref (caps); - return; - } - } -} - -/*** video/mpeg systemstream ***/ -static GstStaticCaps mpeg_sys_caps = GST_STATIC_CAPS ("video/mpeg, " - "systemstream = (boolean) true, mpegversion = (int) [ 1, 2 ]"); - -#define MPEG_SYS_CAPS gst_static_caps_get(&mpeg_sys_caps) -#define IS_MPEG_HEADER(data) ((((guint8 *)(data))[0] == 0x00) && \ - (((guint8 *)(data))[1] == 0x00) && \ - (((guint8 *)(data))[2] == 0x01)) - -#define IS_MPEG_PACK_HEADER(data) (IS_MPEG_HEADER (data) && \ - (((guint8 *)(data))[3] == 0xBA)) - -#define IS_MPEG_SYSTEM_HEADER(data) (IS_MPEG_HEADER (data) && \ - (((guint8 *)(data))[3] == 0xBB)) -#define IS_MPEG_PACKET_HEADER(data) (IS_MPEG_HEADER (data) && \ - ((((guint8 *)(data))[3] & 0x80) == 0x80)) - -#define IS_MPEG_PES_HEADER(data) (IS_MPEG_HEADER (data) && \ - ((((guint8 *)(data))[3] == 0xE0) || \ - (((guint8 *)(data))[3] == 0xC0) || \ - (((guint8 *)(data))[3] == 0xBD))) - -static void -mpeg2_sys_type_find (GstTypeFind * tf, gpointer unused) -{ - guint8 *data = gst_type_find_peek (tf, 0, 5); - gint mpegversion; - - if (data && IS_MPEG_PACK_HEADER (data)) { - if ((data[4] & 0xC0) == 0x40) { - /* type 2 */ - mpegversion = 2; - goto suggest; - } else if ((data[4] & 0xF0) == 0x20) { - mpegversion = 1; - goto suggest; - } - } else if (data && IS_MPEG_PES_HEADER (data)) { - /* PES stream */ - mpegversion = 2; - goto suggest; - } - - return; -suggest: - { - GstCaps *caps = gst_caps_copy (MPEG_SYS_CAPS); - - gst_structure_set (gst_caps_get_structure (caps, 0), "mpegversion", - G_TYPE_INT, mpegversion, NULL); - gst_type_find_suggest (tf, GST_TYPE_FIND_POSSIBLE, caps); - gst_caps_unref (caps); - } -}; - -/* ATTENTION: ugly return value: - * 0 - invalid data - * 1 - not enough data - * anything else - size until next package - */ -static guint -mpeg1_parse_header (GstTypeFind * tf, guint64 offset) -{ - guint8 *data = gst_type_find_peek (tf, offset, 4); - guint size; - - if (!data) { - GST_LOG ("couldn't get MPEG header bytes"); - return 1; - } - - if (data[0] != 0 || data[1] != 0 || data[2] != 1) { - GST_LOG ("no sync"); - return 0; - } - offset += 4; - - GST_LOG ("sync %02x", data[3]); - - switch (data[3]) { - case 0xBA: /* pack header */ - data = gst_type_find_peek (tf, offset, 8); - if (!data) { - GST_LOG ("couldn't get MPEG pack header bytes"); - return 1; - } - size = 12; - /* check marker bits */ - if ((data[0] & 0xF1) != 0x21 || - (data[2] & 0x01) != 0x01 || - (data[4] & 0x01) != 0x01 || - (data[5] & 0x80) != 0x80 || (data[7] & 0x01) != 0x01) { - GST_LOG ("wrong marker bits"); - return 0; - } - break; - - case 0xB9: /* ISO end code */ - size = 4; - break; - - case 0xBB: /* system header */ - data = gst_type_find_peek (tf, offset, 2); - if (!data) { - GST_LOG ("couldn't get MPEG pack header bytes"); - return 1; - } - size = GST_READ_UINT16_BE (data) + 6; - offset += 2; - data = gst_type_find_peek (tf, offset, size - 6); - if (!data) { - GST_LOG ("couldn't get MPEG pack header bytes"); - return 1; - } - /* check marker bits */ - if ((data[0] & 0x80) != 0x80 || - (data[2] & 0x01) != 0x01 || (data[4] & 0x20) != 0x20) { - GST_LOG ("wrong marker bits"); - return 0; - } - /* check stream marker bits */ - for (offset = 6; offset < (size - 6); offset += 3) { - if (data[offset] <= 0xBB || (data[offset + 1] & 0xC0) != 0xC0) { - GST_LOG ("wrong marker bits"); - return 0; - } - } - break; - - default: - if (data[3] < 0xB9) - return 0; - data = gst_type_find_peek (tf, offset, 2); - if (!data) { - GST_LOG ("couldn't get MPEG pack header bytes"); - return 1; - } - size = GST_READ_UINT16_BE (data) + 6; - /* FIXME: we could check PTS/DTS marker bits here... (bit overkill) */ - break; - } - - return size; -} - -/* calculation of possibility to identify random data as mpeg systemstream: - * bits that must match in header detection: 32 (or more) - * chance that random data is identifed: 1/2^32 - * chance that GST_MPEG_TYPEFIND_TRY_HEADERS headers are identified: - * 1/2^(32*GST_MPEG_TYPEFIND_TRY_HEADERS) - * chance that this happens in GST_MPEG_TYPEFIND_TRY_SYNC bytes: - * 1-(1+1/2^(32*GST_MPEG_TYPEFIND_TRY_HEADERS)^GST_MPEG_TYPEFIND_TRY_SYNC) - * for current values: - * 1-(1+1/2^(32*4)^101024) - * = - */ -#define GST_MPEG_TYPEFIND_TRY_HEADERS 4 -#define GST_MPEG_TYPEFIND_TRY_SYNC (100 * 1024) /* 100kB */ -#define GST_MPEG_TYPEFIND_SYNC_SIZE 2048 -static void -mpeg1_sys_type_find (GstTypeFind * tf, gpointer unused) -{ - guint8 *data = NULL; - guint size = 0; - guint64 skipped = 0; - GstCaps *caps; - - while (skipped < GST_MPEG_TYPEFIND_TRY_SYNC) { - if (size < 4) { - data = gst_type_find_peek (tf, skipped, GST_MPEG_TYPEFIND_SYNC_SIZE); - if (!data) - break; - size = GST_MPEG_TYPEFIND_SYNC_SIZE; - } - if (IS_MPEG_PACK_HEADER (data)) { - /* found packet start code */ - guint found = 0; - guint packet_size = 0; - guint64 offset = skipped; - - while (found < GST_MPEG_TYPEFIND_TRY_HEADERS) { - packet_size = mpeg1_parse_header (tf, offset); - if (packet_size <= 1) - break; - offset += packet_size; - found++; - } - g_assert (found <= GST_MPEG_TYPEFIND_TRY_HEADERS); - if (found == GST_MPEG_TYPEFIND_TRY_HEADERS || packet_size == 1) { - GST_LOG ("suggesting mpeg1 system steeam"); - caps = gst_caps_copy (MPEG_SYS_CAPS); - gst_structure_set (gst_caps_get_structure (caps, 0), "mpegversion", - G_TYPE_INT, 1, NULL); - gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM - 1, caps); - gst_caps_unref (caps); - return; - } - } - data++; - skipped++; - size--; - } -} - -/** video/mpegts Transport Stream **/ -static GstStaticCaps mpegts_caps = GST_STATIC_CAPS ("video/mpegts, " - "systemstream = (boolean) true, packetsize = (int) [ 188, 208 ]"); -#define MPEGTS_CAPS gst_static_caps_get(&mpegts_caps) - -#define GST_MPEGTS_TYPEFIND_MIN_HEADERS 4 -#define GST_MPEGTS_TYPEFIND_MAX_HEADERS 10 -#define GST_MPEGTS_MAX_PACKET_SIZE 204 -#define GST_MPEGTS_TYPEFIND_SYNC_SIZE \ - (GST_MPEGTS_TYPEFIND_MIN_HEADERS * GST_MPEGTS_MAX_PACKET_SIZE) -#define GST_MPEGTS_TYPEFIND_MAX_SYNC \ - (GST_MPEGTS_TYPEFIND_MAX_HEADERS * GST_MPEGTS_MAX_PACKET_SIZE) - -#define MPEGTS_HDR_SIZE 4 -#define IS_MPEGTS_HEADER(data) (((data)[0] == 0x47) && \ - (((data)[1] & 0x80) == 0x00) && \ - (((data)[3] & 0x10) == 0x10)) - -/* Helper function to search ahead at intervals of packet_size for mpegts - * headers */ -gint -mpeg_ts_probe_headers (GstTypeFind * tf, guint64 offset, gint packet_size) -{ - /* We always enter this function having found at least one header already */ - gint found = 1; - guint8 *data = NULL; - - while (found < GST_MPEGTS_TYPEFIND_MAX_HEADERS) { - offset += packet_size; - - data = gst_type_find_peek (tf, offset, MPEGTS_HDR_SIZE); - if (data == NULL || !IS_MPEGTS_HEADER (data)) - return found; - - found++; - } - - return found; -} - -/* Try and detect at least 4 packets in at most 10 packets worth of - * data. Need to try several possible packet sizes */ -static void -mpeg_ts_type_find (GstTypeFind * tf, gpointer unused) -{ - /* TS packet sizes to test: normal, DVHS packet size and - * FEC with 16 or 20 byte codes packet size. */ - const gint pack_sizes[] = { 188, 192, 204, 208 }; - const gint n_pack_sizes = sizeof (pack_sizes) / sizeof (gint); - - guint8 *data = NULL; - guint size = 0; - guint64 skipped = 0; - - while (skipped < GST_MPEGTS_TYPEFIND_MAX_SYNC) { - if (size < MPEGTS_HDR_SIZE) { - data = gst_type_find_peek (tf, skipped, GST_MPEGTS_TYPEFIND_SYNC_SIZE); - if (!data) - break; - size = GST_MPEGTS_TYPEFIND_SYNC_SIZE; - } - - /* Have at least MPEGTS_HDR_SIZE bytes at this point */ - if (IS_MPEGTS_HEADER (data)) { - gint p; - - for (p = 0; p < n_pack_sizes; p++) { - gint found; - - /* Probe ahead at size pack_sizes[p] */ - found = mpeg_ts_probe_headers (tf, skipped, pack_sizes[p]); - if (found >= GST_MPEGTS_TYPEFIND_MIN_HEADERS) { - gint probability; - GstCaps *caps = gst_caps_copy (MPEGTS_CAPS); - - gst_structure_set (gst_caps_get_structure (caps, 0), "packetsize", - G_TYPE_INT, pack_sizes[p], NULL); - - /* found at least 4 headers. 10 headers = MAXIMUM probability. - * Arbitrarily, I assigned 10% probability for each header we - * found, 40% -> 100% */ - - probability = 10 * MIN (found, 10); - - gst_type_find_suggest (tf, probability, caps); - gst_caps_unref (caps); - return; - } - } - } - data++; - skipped++; - size--; - } -} - -/*** video/mpeg MPEG-4 elementary video stream ***/ - -static GstStaticCaps mpeg4_video_caps = GST_STATIC_CAPS ("video/mpeg, " - "systemstream = (boolean) false, mpegversion = 4"); -#define MPEG4_VIDEO_CAPS gst_static_caps_get(&mpeg4_video_caps) -static void -mpeg4_video_type_find (GstTypeFind * tf, gpointer unused) -{ - /* Header consists of: a series of start codes (00 00 01 xx), some with - * associated data. - * Optionally, we start with a visual_object_sequence_start_code, followed by - * (optionally) visual_object_start_code), then the mandatory - * video_object_start_code and video_object_layer_start_code) - */ - guint8 *data = NULL; - int offset = 0; - gboolean seen_vos = FALSE; - - while (TRUE) { - data = gst_type_find_peek (tf, offset, 4); - if (data && data[0] == 0 && data[1] == 0 && data[2] == 1) { - int sc = data[3]; - - if (sc == 0xB0) /* visual_object_sequence_start_code */ - offset += 5; - else if (sc == 0xB5) /* visual_object_start_code */ - offset += 5; - else if (sc >= 0x00 && sc <= 0x1F) { /* video_object_start_code */ - offset += 4; - seen_vos = TRUE; - } else if (sc >= 0x20 && sc <= 0x2F) { /* video_object_layer_start_code */ - if (seen_vos) { - GstCaps *caps = gst_caps_copy (MPEG4_VIDEO_CAPS); - - gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM - 1, caps); - gst_caps_unref (caps); - return; - } - } else - return; - } else - return; - } -} - -/*** video/mpeg video stream ***/ - -static GstStaticCaps mpeg_video_caps = GST_STATIC_CAPS ("video/mpeg, " - "systemstream = (boolean) false"); -#define MPEG_VIDEO_CAPS gst_static_caps_get(&mpeg_video_caps) -static void -mpeg_video_type_find (GstTypeFind * tf, gpointer unused) -{ - static const guint8 sequence_header[] = { 0x00, 0x00, 0x01, 0xb3 }; - guint8 *data = NULL; - - data = gst_type_find_peek (tf, 0, 8); - - if (data && memcmp (data, sequence_header, 4) == 0) { - GstCaps *caps = gst_caps_copy (MPEG_VIDEO_CAPS); - - gst_structure_set (gst_caps_get_structure (caps, 0), "mpegversion", - G_TYPE_INT, 1, NULL); - gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM - 1, caps); - gst_caps_unref (caps); - } -} - -/* - * Idea is the same as MPEG system stream typefinding: We check each - * byte of the stream to see if - from that point on - the stream - * matches a predefined set of marker bits as defined in the MPEG - * video specs. - * - * I'm sure someone will do a chance calculation here too. - */ - -#define GST_MPEGVID_TYPEFIND_TRY_PICTURES 6 -#define GST_MPEGVID_TYPEFIND_TRY_SYNC (100 * 1024) /* 100 kB */ -#define GST_MPEGVID_TYPEFIND_SYNC_SIZE 2048 - -static void -mpeg_video_stream_type_find (GstTypeFind * tf, gpointer unused) -{ - gint size = 0, found = 0; - guint64 skipped = 0; - guint8 *data = NULL; - - while (1) { - if (found >= GST_MPEGVID_TYPEFIND_TRY_PICTURES) { - GstCaps *caps = gst_caps_copy (MPEG_VIDEO_CAPS); - - gst_structure_set (gst_caps_get_structure (caps, 0), "mpegversion", - G_TYPE_INT, 1, NULL); - gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM - 2, caps); - gst_caps_unref (caps); - return; - } - - if (skipped > GST_MPEGVID_TYPEFIND_TRY_SYNC) - break; - - if (size < 5) { - data = gst_type_find_peek (tf, skipped, GST_MPEGVID_TYPEFIND_SYNC_SIZE); - if (!data) - break; - size = GST_MPEGVID_TYPEFIND_SYNC_SIZE; - } - - /* are we a sequence (0xB3) or GOP (0xB8) header? */ - if (data[0] == 0x0 && data[1] == 0x0 && data[2] == 0x1 && - (data[3] == 0xB3 || data[3] == 0xB8)) { - size -= 8; - data += 8; - skipped += 8; - if (data[3] == 0xB3) - continue; - else if (size < 4) { - data = gst_type_find_peek (tf, skipped, GST_MPEGVID_TYPEFIND_SYNC_SIZE); - size = GST_MPEGVID_TYPEFIND_SYNC_SIZE; - if (!data) - break; - } - /* else, we should now see an image */ - } - - /* image header (and, when found, slice header) */ - if (data[0] == 0x0 && data[1] == 0x0 && data[2] == 0x1 && data[4] == 0x0) { - size -= 8; - data += 8; - skipped += 8; - if (size < 5) { - data = gst_type_find_peek (tf, skipped, GST_MPEGVID_TYPEFIND_SYNC_SIZE); - size = GST_MPEGVID_TYPEFIND_SYNC_SIZE; - if (!data) - break; - } - if ((data[0] == 0x0 && data[1] == 0x0 && - data[2] == 0x1 && data[3] == 0x1) || - (data[1] == 0x0 && data[2] == 0x0 && - data[3] == 0x1 && data[4] == 0x1)) { - size -= 4; - data += 4; - skipped += 4; - found += 1; - continue; - } - } - - size--; - data++; - skipped++; - } -} - -/*** audio/x-aiff ***/ - -static GstStaticCaps aiff_caps = GST_STATIC_CAPS ("audio/x-aiff"); - -#define AIFF_CAPS gst_static_caps_get(&aiff_caps) -static void -aiff_type_find (GstTypeFind * tf, gpointer unused) -{ - guint8 *data = gst_type_find_peek (tf, 0, 4); - - if (data && memcmp (data, "FORM", 4) == 0) { - data += 8; - if (memcmp (data, "AIFF", 4) == 0 || memcmp (data, "AIFC", 4) == 0) - gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, AIFF_CAPS); - } -} - -/*** audio/x-aiff ***/ - -static GstStaticCaps svx_caps = GST_STATIC_CAPS ("audio/x-svx"); - -#define SVX_CAPS gst_static_caps_get(&svx_caps) -static void -svx_type_find (GstTypeFind * tf, gpointer unused) -{ - guint8 *data = gst_type_find_peek (tf, 0, 4); - - if (data && memcmp (data, "FORM", 4) == 0) { - data += 8; - if (memcmp (data, "8SVX", 4) == 0 || memcmp (data, "16SV", 4) == 0) - gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, SVX_CAPS); - } -} - -/*** audio/x-shorten ***/ - -static GstStaticCaps shn_caps = GST_STATIC_CAPS ("audio/x-shorten"); - -#define SHN_CAPS gst_static_caps_get(&shn_caps) -static void -shn_type_find (GstTypeFind * tf, gpointer unused) -{ - guint8 *data = gst_type_find_peek (tf, 0, 4); - - if (data && memcmp (data, "ajkg", 4) == 0) { - gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, SHN_CAPS); - } - data = gst_type_find_peek (tf, -8, 8); - if (data && memcmp (data, "SHNAMPSK", 8) == 0) { - gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, SHN_CAPS); - } -} - -/*** application/x-ape ***/ - -static GstStaticCaps ape_caps = GST_STATIC_CAPS ("application/x-ape"); - -#define APE_CAPS gst_static_caps_get(&ape_caps) -static void -ape_type_find (GstTypeFind * tf, gpointer unused) -{ - guint8 *data = gst_type_find_peek (tf, 0, 4); - - if (data && memcmp (data, "MAC ", 4) == 0) { - gst_type_find_suggest (tf, GST_TYPE_FIND_LIKELY + 10, APE_CAPS); - } -} - -/*** ISO FORMATS ***/ - -/*** audio/x-m4a ***/ - -static GstStaticCaps m4a_caps = GST_STATIC_CAPS ("audio/x-m4a"); - -#define M4A_CAPS (gst_static_caps_get(&m4a_caps)) -static void -m4a_type_find (GstTypeFind * tf, gpointer unused) -{ - guint8 *data = gst_type_find_peek (tf, 4, 8); - - if (data && - (memcmp (data, "ftypM4A ", 8) == 0 || - memcmp (data, "ftypmp42", 8) == 0)) { - gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, M4A_CAPS); - } -} - -/*** application/x-3gp ***/ - -/* The Q is there because variables can't start with a number. */ - - -static GstStaticCaps q3gp_caps = GST_STATIC_CAPS ("application/x-3gp"); - -#define Q3GP_CAPS (gst_static_caps_get(&q3gp_caps)) -static void -q3gp_type_find (GstTypeFind * tf, gpointer unused) -{ - - guint32 ftyp_size = 0; - gint offset = 0; - guint8 *data = NULL; - - if ((data = gst_type_find_peek (tf, 0, 12)) == NULL) { - return; - } - - data += 4; - if (memcmp (data, "ftyp", 4) != 0) { - return; - } - - /* check major brand */ - data += 4; - if (memcmp (data, "3gp", 3) == 0 || - memcmp (data, "3gr", 3) == 0 || - memcmp (data, "3gs", 3) == 0 || memcmp (data, "3gg", 3) == 0) { - gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, Q3GP_CAPS); - return; - } - - /* check compatible brands */ - if ((data = gst_type_find_peek (tf, 0, 4)) != NULL) { - ftyp_size = GST_READ_UINT32_BE (data); - } - for (offset = 16; offset < ftyp_size; offset += 4) { - if ((data = gst_type_find_peek (tf, offset, 3)) == NULL) { - break; - } - if (memcmp (data, "3gp", 3) == 0 || - memcmp (data, "3gr", 3) == 0 || - memcmp (data, "3gs", 3) == 0 || memcmp (data, "3gg", 3) == 0) { - gst_type_find_suggest (tf, GST_TYPE_FIND_LIKELY, Q3GP_CAPS); - break; - } - } - - return; - -} - -/*** video/quicktime ***/ - -static GstStaticCaps qt_caps = GST_STATIC_CAPS ("video/quicktime"); - -#define QT_CAPS gst_static_caps_get(&qt_caps) -#define STRNCMP(x,y,z) (strncmp ((char*)(x), (char*)(y), z)) - -static void -qt_type_find (GstTypeFind * tf, gpointer unused) -{ - guint8 *data; - guint tip = 0; - guint64 offset = 0; - guint64 size; - - while ((data = gst_type_find_peek (tf, offset, 8)) != NULL) { - /* box/atom types that are in common with ISO base media file format */ - if (STRNCMP (&data[4], "moov", 4) == 0 || - STRNCMP (&data[4], "mdat", 4) == 0 || - STRNCMP (&data[4], "ftyp", 4) == 0 || - STRNCMP (&data[4], "free", 4) == 0 || - STRNCMP (&data[4], "uuid", 4) == 0 || - STRNCMP (&data[4], "skip", 4) == 0) { - if (tip == 0) { - tip = GST_TYPE_FIND_LIKELY; - } else { - tip = GST_TYPE_FIND_NEARLY_CERTAIN; - } - } - /* other box/atom types, apparently quicktime specific */ - else if (STRNCMP (&data[4], "pnot", 4) == 0 || - STRNCMP (&data[4], "PICT", 4) == 0 || - STRNCMP (&data[4], "wide", 4) == 0 || - STRNCMP (&data[4], "prfl", 4) == 0) { - tip = GST_TYPE_FIND_MAXIMUM; - break; - } else { - tip = 0; - break; - } - size = GST_READ_UINT32_BE (data); - if (size == 1) { - guint8 *sizedata; - - sizedata = gst_type_find_peek (tf, offset + 8, 8); - if (sizedata == NULL) - break; - - size = GST_READ_UINT64_BE (sizedata); - } else { - if (size < 8) - break; - } - offset += size; - } - if (tip > 0) { - gst_type_find_suggest (tf, tip, QT_CAPS); - } -}; - - -/*** image/x-quicktime ***/ - -static GstStaticCaps qtif_caps = GST_STATIC_CAPS ("image/x-quicktime"); - -#define QTIF_CAPS gst_static_caps_get(&qtif_caps) - -/* how many atoms we check before we give up */ -#define QTIF_MAXROUNDS 25 - -static void -qtif_type_find (GstTypeFind * tf, gpointer unused) -{ - const guint8 *data; - gboolean found_idsc = FALSE; - gboolean found_idat = FALSE; - guint64 offset = 0; - guint rounds = 0; - - while ((data = gst_type_find_peek (tf, offset, 8)) != NULL) { - guint64 size; - - size = GST_READ_UINT32_BE (data); - if (size == 1) { - const guint8 *sizedata; - - sizedata = gst_type_find_peek (tf, offset + 8, 8); - if (sizedata == NULL) - break; - - size = GST_READ_UINT64_BE (sizedata); - } - if (size < 8) - break; - - if (STRNCMP (data + 4, "idsc", 4) == 0) - found_idsc = TRUE; - if (STRNCMP (data + 4, "idat", 4) == 0) - found_idat = TRUE; - - if (found_idsc && found_idat) { - gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, QTIF_CAPS); - return; - } - - offset += size; - if (++rounds > QTIF_MAXROUNDS) - break; - } - - if (found_idsc || found_idat) { - gst_type_find_suggest (tf, GST_TYPE_FIND_LIKELY, QTIF_CAPS); - return; - } -}; - -/*** audio/x-mod ***/ - -static GstStaticCaps mod_caps = GST_STATIC_CAPS ("audio/x-mod"); - -#define MOD_CAPS gst_static_caps_get(&mod_caps) -/* FIXME: M15 CheckType to do */ -static void -mod_type_find (GstTypeFind * tf, gpointer unused) -{ - guint8 *data; - - /* MOD */ - if ((data = gst_type_find_peek (tf, 1080, 4)) != NULL) { - /* Protracker and variants */ - if ((memcmp (data, "M.K.", 4) == 0) || (memcmp (data, "M!K!", 4) == 0) || - /* Star Tracker */ - (memcmp (data, "FLT", 3) == 0 && isdigit (data[3])) || - (memcmp (data, "EXO", 3) == 0 && isdigit (data[3])) || - /* Oktalyzer (Amiga) */ - (memcmp (data, "OKTA", 4) == 0) || - /* Oktalyser (Atari) */ - (memcmp (data, "CD81", 4) == 0) || - /* Fasttracker */ - (memcmp (data + 1, "CHN", 3) == 0 && isdigit (data[0])) || - /* Fasttracker or Taketracker */ - (memcmp (data + 2, "CH", 2) == 0 && isdigit (data[0]) - && isdigit (data[1])) || (memcmp (data + 2, "CN", 2) == 0 - && isdigit (data[0]) && isdigit (data[1]))) { - gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, MOD_CAPS); - return; - } - } - /* XM */ - if ((data = gst_type_find_peek (tf, 0, 38)) != NULL) { - if (memcmp (data, "Extended Module: ", 17) == 0 && data[37] == 0x1A) { - gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, MOD_CAPS); - return; - } - } - /* OKT */ - if (data || (data = gst_type_find_peek (tf, 0, 8)) != NULL) { - if (memcmp (data, "OKTASONG", 8) == 0) { - gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, MOD_CAPS); - return; - } - } - if (data || (data = gst_type_find_peek (tf, 0, 4)) != NULL) { - /* 669 */ - if ((memcmp (data, "if", 2) == 0) || (memcmp (data, "JN", 2) == 0)) { - gst_type_find_suggest (tf, GST_TYPE_FIND_LIKELY, MOD_CAPS); - return; - } - /* AMF */ - if ((memcmp (data, "AMF", 3) == 0 && data[3] > 10 && data[3] < 14) || - /* IT */ - (memcmp (data, "IMPM", 4) == 0) || - /* MED */ - (memcmp (data, "MMD0", 4) == 0) || (memcmp (data, "MMD1", 4) == 0) || - /* MTM */ - (memcmp (data, "MTM", 3) == 0)) { - gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, MOD_CAPS); - return; - } - /* DSM */ - if (memcmp (data, "RIFF", 4) == 0) { - guint8 *data2 = gst_type_find_peek (tf, 8, 4); - - if (data2) { - if (memcmp (data2, "DSMF", 4) == 0) { - gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, MOD_CAPS); - return; - } - } - } - /* FAM */ - if (memcmp (data, "FAM\xFE", 4) == 0) { - guint8 *data2 = gst_type_find_peek (tf, 44, 3); - - if (data2) { - if (memcmp (data2, "compare", 3) == 0) { - gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, MOD_CAPS); - return; - } - } else { - gst_type_find_suggest (tf, GST_TYPE_FIND_LIKELY, MOD_CAPS); - return; - } - } - /* GDM */ - if (memcmp (data, "GDM\xFE", 4) == 0) { - guint8 *data2 = gst_type_find_peek (tf, 71, 4); - - if (data2) { - if (memcmp (data2, "GMFS", 4) == 0) { - gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, MOD_CAPS); - return; - } - } else { - gst_type_find_suggest (tf, GST_TYPE_FIND_LIKELY, MOD_CAPS); - return; - } - } - } - /* IMF */ - if ((data = gst_type_find_peek (tf, 60, 4)) != NULL) { - if (memcmp (data, "IM10", 4) == 0) { - gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, MOD_CAPS); - return; - } - } - /* S3M */ - if ((data = gst_type_find_peek (tf, 44, 4)) != NULL) { - if (memcmp (data, "SCRM", 4) == 0) { - gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, MOD_CAPS); - return; - } - } -} - -/*** application/x-shockwave-flash ***/ - -static GstStaticCaps swf_caps = -GST_STATIC_CAPS ("application/x-shockwave-flash"); -#define SWF_CAPS (gst_static_caps_get(&swf_caps)) -static void -swf_type_find (GstTypeFind * tf, gpointer unused) -{ - guint8 *data = gst_type_find_peek (tf, 0, 4); - - if (data && (data[0] == 'F' || data[0] == 'C') && - data[1] == 'W' && data[2] == 'S') { - gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, SWF_CAPS); - } -} - -/*** image/jpeg ***/ - -static GstStaticCaps jpeg_caps = GST_STATIC_CAPS ("image/jpeg"); - -#define JPEG_CAPS (gst_static_caps_get(&jpeg_caps)) -static void -jpeg_type_find (GstTypeFind * tf, gpointer unused) -{ - guint8 *data = gst_type_find_peek (tf, 0, 10); - guint8 header[2] = { 0xFF, 0xD8 }; - - if (data && memcmp (data, header, 2) == 0) { - if (memcmp (data + 6, "JFIF", 4) == 0) { - gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, JPEG_CAPS); - } else if (memcmp (data + 6, "Exif", 4) == 0) { - gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, JPEG_CAPS); - } else { - gst_type_find_suggest (tf, GST_TYPE_FIND_POSSIBLE, JPEG_CAPS); - } - } -} - -/*** image/bmp ***/ - -static GstStaticCaps bmp_caps = GST_STATIC_CAPS ("image/bmp"); - -#define BMP_CAPS (gst_static_caps_get(&bmp_caps)) -static void -bmp_type_find (GstTypeFind * tf, gpointer unused) -{ - guint8 *data = gst_type_find_peek (tf, 0, 18); - - if (data && memcmp (data, "BM", 2) == 0) { - if ((data[14] == 0x0C || - data[14] == 0x28 || - data[14] == 0xF0) && - data[15] == 0 && data[16] == 0 && data[17] == 0) { - gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, BMP_CAPS); - } - } -} - -/*** image/tiff ***/ -static GstStaticCaps tiff_caps = GST_STATIC_CAPS ("image/tiff, " - "endianness = (int) { BIG_ENDIAN, LITTLE_ENDIAN }"); -#define TIFF_CAPS (gst_static_caps_get(&tiff_caps)) -static GstStaticCaps tiff_be_caps = GST_STATIC_CAPS ("image/tiff, " - "endianness = (int) BIG_ENDIAN"); -#define TIFF_BE_CAPS (gst_static_caps_get(&tiff_be_caps)) -static GstStaticCaps tiff_le_caps = GST_STATIC_CAPS ("image/tiff, " - "endianness = (int) LITTLE_ENDIAN"); -#define TIFF_LE_CAPS (gst_static_caps_get(&tiff_le_caps)) -static void -tiff_type_find (GstTypeFind * tf, gpointer ununsed) -{ - guint8 *data = gst_type_find_peek (tf, 0, 8); - guint8 le_header[4] = { 0x49, 0x49, 0x2A, 0x00 }; - guint8 be_header[4] = { 0x4D, 0x4D, 0x00, 0x2A }; - - if (data) { - if (memcmp (data, le_header, 4) == 0) { - gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, TIFF_LE_CAPS); - } else if (memcmp (data, be_header, 4) == 0) { - gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, TIFF_BE_CAPS); - } - } -} - -static GstStaticCaps sds_caps = GST_STATIC_CAPS ("audio/x-sds"); - -#define SDS_CAPS (gst_static_caps_get(&sds_caps)) -static void -sds_type_find (GstTypeFind * tf, gpointer ununsed) -{ - guint8 *data = gst_type_find_peek (tf, 0, 4); - guint8 mask[4] = { 0xFF, 0xFF, 0x80, 0xFF }; - guint8 match[4] = { 0xF0, 0x7E, 0, 0x01 }; - gint x; - - if (data) { - for (x = 0; x < 4; x++) { - if ((data[x] & mask[x]) != match[x]) { - return; - } - } - gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, SDS_CAPS); - } -} - -static GstStaticCaps ircam_caps = GST_STATIC_CAPS ("audio/x-ircam"); - -#define IRCAM_CAPS (gst_static_caps_get(&ircam_caps)) -static void -ircam_type_find (GstTypeFind * tf, gpointer ununsed) -{ - guint8 *data = gst_type_find_peek (tf, 0, 4); - guint8 mask[4] = { 0xFF, 0xFF, 0xF8, 0xFF }; - guint8 match[4] = { 0x64, 0xA3, 0x00, 0x00 }; - gint x; - gboolean matched = TRUE; - - if (!data) { - return; - } - for (x = 0; x < 4; x++) { - if ((data[x] & mask[x]) != match[x]) { - matched = FALSE; - } - } - if (matched) { - gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, IRCAM_CAPS); - return; - } - /* now try the reverse version */ - matched = TRUE; - for (x = 0; x < 4; x++) { - if ((data[x] & mask[3 - x]) != match[3 - x]) { - matched = FALSE; - } - } -} - - -/*** video/x-matroska ***/ -static GstStaticCaps matroska_caps = GST_STATIC_CAPS ("video/x-matroska"); - -#define MATROSKA_CAPS (gst_static_caps_get(&matroska_caps)) -static void -matroska_type_find (GstTypeFind * tf, gpointer ununsed) -{ - /* 4 bytes for EBML ID, 1 byte for header length identifier */ - guint8 *data = gst_type_find_peek (tf, 0, 4 + 1); - gint len_mask = 0x80, size = 1, n = 1, total; - guint8 probe_data[] = { 'm', 'a', 't', 'r', 'o', 's', 'k', 'a' }; - - if (!data) - return; - - /* ebml header? */ - if (data[0] != 0x1A || data[1] != 0x45 || data[2] != 0xDF || data[3] != 0xA3) - return; - - /* length of header */ - total = data[4]; - while (size <= 8 && !(total & len_mask)) { - size++; - len_mask >>= 1; - } - if (size > 8) - return; - total &= (len_mask - 1); - while (n < size) - total = (total << 8) | data[4 + n++]; - - /* get new data for full header, 4 bytes for EBML ID, - * EBML length tag and the actual header */ - data = gst_type_find_peek (tf, 0, 4 + size + total); - if (!data) - return; - - /* the header must contain the document type 'matroska'. For now, - * we don't parse the whole header but simply check for the - * availability of that array of characters inside the header. - * Not fully fool-proof, but good enough. */ - for (n = 4 + size; n <= 4 + size + total - sizeof (probe_data); n++) - if (!memcmp (&data[n], probe_data, sizeof (probe_data))) { - gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, MATROSKA_CAPS); - break; - } -} - -/*** video/x-dv ***/ - -static GstStaticCaps dv_caps = GST_STATIC_CAPS ("video/x-dv, " - "systemstream = (boolean) true"); -#define DV_CAPS (gst_static_caps_get(&dv_caps)) -static void -dv_type_find (GstTypeFind * tf, gpointer private) -{ - guint8 *data; - - data = gst_type_find_peek (tf, 0, 5); - - /* check for DIF and DV flag */ - if (data && (data[0] == 0x1f) && (data[1] == 0x07) && (data[2] == 0x00) && - ((data[4] & 0x01) == 0)) { - gchar *format; - GstCaps *caps = gst_caps_copy (DV_CAPS); - - if (data[3] & 0x80) { - format = "PAL"; - } else { - format = "NTSC"; - } - gst_structure_set (gst_caps_get_structure (caps, 0), "format", - G_TYPE_STRING, format, NULL); - - gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, caps); - gst_caps_unref (caps); - } -} - - -/*** application/ogg and application/x-annodex ***/ -static GstStaticCaps ogg_caps = GST_STATIC_CAPS ("application/ogg"); -static GstStaticCaps annodex_caps = GST_STATIC_CAPS ("application/x-annodex"); - -#define OGGANX_CAPS (gst_static_caps_get(&annodex_caps)) - -static void -ogganx_type_find (GstTypeFind * tf, gpointer private) -{ - guint8 *data = gst_type_find_peek (tf, 0, 4); - - if ((data != NULL) && (memcmp (data, "OggS", 4) == 0)) { - - /* Check for an annodex fishbone header */ - data = gst_type_find_peek (tf, 28, 8); - if (data && memcmp (data, "fishead\0", 8) == 0) - gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, OGGANX_CAPS); - - gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, - gst_static_caps_get (&ogg_caps)); - } -} - -/*** audio/x-vorbis ***/ -static GstStaticCaps vorbis_caps = GST_STATIC_CAPS ("audio/x-vorbis"); - -#define VORBIS_CAPS (gst_static_caps_get(&vorbis_caps)) -static void -vorbis_type_find (GstTypeFind * tf, gpointer private) -{ - guint8 *data = gst_type_find_peek (tf, 0, 30); - - if (data) { - guint blocksize_0; - guint blocksize_1; - - /* 1 byte packet type (identification=0x01) - 6 byte string "vorbis" - 4 byte vorbis version */ - if (memcmp (data, "\001vorbis\000\000\000\000", 11) != 0) - return; - data += 11; - /* 1 byte channels must be != 0 */ - if (data[0] == 0) - return; - data++; - /* 4 byte samplerate must be != 0 */ - if (*((guint32 *) data) == 0) - return; - data += 16; - /* blocksize checks */ - blocksize_0 = data[0] & 0x0F; - blocksize_1 = (data[0] & 0xF0) >> 4; - if (blocksize_0 > blocksize_1) - return; - if (blocksize_0 < 6 || blocksize_0 > 13) - return; - if (blocksize_1 < 6 || blocksize_1 > 13) - return; - data++; - /* framing bit */ - if ((data[0] & 0x01) != 1) - return; - gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, VORBIS_CAPS); - } -} - -/*** video/x-theora ***/ - -static GstStaticCaps theora_caps = GST_STATIC_CAPS ("video/x-theora"); - -#define THEORA_CAPS (gst_static_caps_get(&theora_caps)) -static void -theora_type_find (GstTypeFind * tf, gpointer private) -{ - guint8 *data = gst_type_find_peek (tf, 0, 7); //42); - - if (data) { - if (data[0] != 0x80) - return; - if (memcmp (&data[1], "theora", 6) != 0) - return; - /* FIXME: make this more reliable when specs are out */ - - gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, THEORA_CAPS); - } -} - -/*** application/x-ogm-video or audio***/ - -static GstStaticCaps ogmvideo_caps = -GST_STATIC_CAPS ("application/x-ogm-video"); -#define OGMVIDEO_CAPS (gst_static_caps_get(&ogmvideo_caps)) -static void -ogmvideo_type_find (GstTypeFind * tf, gpointer private) -{ - guint8 *data = gst_type_find_peek (tf, 0, 9); - - if (data) { - if (memcmp (data, "\001video\000\000\000", 9) != 0) - return; - gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, OGMVIDEO_CAPS); - } -} - -static GstStaticCaps ogmaudio_caps = -GST_STATIC_CAPS ("application/x-ogm-audio"); -#define OGMAUDIO_CAPS (gst_static_caps_get(&ogmaudio_caps)) -static void -ogmaudio_type_find (GstTypeFind * tf, gpointer private) -{ - guint8 *data = gst_type_find_peek (tf, 0, 9); - - if (data) { - if (memcmp (data, "\001audio\000\000\000", 9) != 0) - return; - gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, OGMAUDIO_CAPS); - } -} - -static GstStaticCaps ogmtext_caps = GST_STATIC_CAPS ("application/x-ogm-text"); - -#define OGMTEXT_CAPS (gst_static_caps_get(&ogmtext_caps)) -static void -ogmtext_type_find (GstTypeFind * tf, gpointer private) -{ - guint8 *data = gst_type_find_peek (tf, 0, 9); - - if (data) { - if (memcmp (data, "\001text\000\000\000\000", 9) != 0) - return; - gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, OGMTEXT_CAPS); - } -} - -/*** audio/x-speex ***/ - -static GstStaticCaps speex_caps = GST_STATIC_CAPS ("audio/x-speex"); - -#define SPEEX_CAPS (gst_static_caps_get(&speex_caps)) -static void -speex_type_find (GstTypeFind * tf, gpointer private) -{ - guint8 *data = gst_type_find_peek (tf, 0, 80); - - if (data) { - /* 8 byte string "Speex " - 24 byte speex version string + int */ - if (memcmp (data, "Speex ", 8) != 0) - return; - data += 32; - - /* 4 byte header size >= 80 */ - if (GST_READ_UINT32_LE (data) < 80) - return; - data += 4; - - /* 4 byte sample rate <= 48000 */ - if (GST_READ_UINT32_LE (data) > 48000) - return; - data += 4; - - /* currently there are only 3 speex modes. */ - if (GST_READ_UINT32_LE (data) > 3) - return; - data += 12; - - gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, SPEEX_CAPS); - } -} - -/*** application/x-ogg-skeleton ***/ -static GstStaticCaps ogg_skeleton_caps = -GST_STATIC_CAPS ("application/x-ogg-skeleton, parsed=(boolean)FALSE"); -#define OGG_SKELETON_CAPS (gst_static_caps_get(&ogg_skeleton_caps)) -static void -oggskel_type_find (GstTypeFind * tf, gpointer private) -{ - guint8 *data = gst_type_find_peek (tf, 0, 12); - - if (data) { - /* 8 byte string "fishead\0" for the ogg skeleton stream */ - if (memcmp (data, "fishead\0", 8) != 0) - return; - data += 8; - - /* Require that the header contains version 3.0 */ - if (GST_READ_UINT16_LE (data) != 3) - return; - data += 2; - if (GST_READ_UINT16_LE (data) != 0) - return; - - gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, OGG_SKELETON_CAPS); - } -} - -static GstStaticCaps cmml_caps = GST_STATIC_CAPS ("text/x-cmml"); - -#define CMML_CAPS (gst_static_caps_get(&cmml_caps)) -static void -cmml_type_find (GstTypeFind * tf, gpointer private) -{ - /* Header is 12 bytes minimum (though we don't check the minor version */ - guint8 *data = gst_type_find_peek (tf, 0, 12); - - if (data) { - - /* 8 byte string "CMML\0\0\0\0" for the magic number */ - if (memcmp (data, "CMML\0\0\0\0", 8) != 0) - return; - data += 8; - - /* Require that the header contains at least version 2.0 */ - if (GST_READ_UINT16_LE (data) < 2) - return; - - gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, CMML_CAPS); - } -} - -/*** application/x-tar ***/ - -static GstStaticCaps tar_caps = GST_STATIC_CAPS ("application/x-tar"); - -#define TAR_CAPS (gst_static_caps_get(&tar_caps)) -#define OLDGNU_MAGIC "ustar " /* 7 chars and a NUL */ -#define NEWGNU_MAGIC "ustar" /* 5 chars and a NUL */ -static void -tar_type_find (GstTypeFind * tf, gpointer unused) -{ - guint8 *data = gst_type_find_peek (tf, 257, 8); - - /* of course we are not certain, but we don't want other typefind funcs - * to detect formats of files within the tar archive, e.g. mp3s */ - if (data) { - if (memcmp (data, OLDGNU_MAGIC, 8) == 0) { /* sic */ - gst_type_find_suggest (tf, GST_TYPE_FIND_NEARLY_CERTAIN, TAR_CAPS); - } else if (memcmp (data, NEWGNU_MAGIC, 6) == 0 && /* sic */ - g_ascii_isdigit (data[6]) && g_ascii_isdigit (data[7])) { - gst_type_find_suggest (tf, GST_TYPE_FIND_NEARLY_CERTAIN, TAR_CAPS); - } - } -} - -/*** application/x-ar ***/ - -static GstStaticCaps ar_caps = GST_STATIC_CAPS ("application/x-ar"); - -#define AR_CAPS (gst_static_caps_get(&ar_caps)) -static void -ar_type_find (GstTypeFind * tf, gpointer unused) -{ - guint8 *data = gst_type_find_peek (tf, 0, 24); - - if (data && memcmp (data, "!", 7) == 0) { - gint i; - - for (i = 7; i < 24; ++i) { - if (!g_ascii_isprint (data[i]) && data[i] != '\n') { - gst_type_find_suggest (tf, GST_TYPE_FIND_POSSIBLE, AR_CAPS); - } - } - - gst_type_find_suggest (tf, GST_TYPE_FIND_NEARLY_CERTAIN, AR_CAPS); - } -} - -/*** audio/x-au ***/ - -/* NOTE: we cannot replace this function with TYPE_FIND_REGISTER_START_WITH, - * as it is only possible to register one typefind factory per 'name' - * (which is in this case the caps), and the first one would be replaced by - * the second one. */ -static GstStaticCaps au_caps = GST_STATIC_CAPS ("audio/x-au"); - -#define AU_CAPS (gst_static_caps_get(&au_caps)) -static void -au_type_find (GstTypeFind * tf, gpointer unused) -{ - guint8 *data = gst_type_find_peek (tf, 0, 4); - - if (data) { - if (memcmp (data, ".snd", 4) == 0 || memcmp (data, "dns.", 4) == 0) { - gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, AU_CAPS); - } - } -} - - -/*** video/x-nuv ***/ - -/* NOTE: we cannot replace this function with TYPE_FIND_REGISTER_START_WITH, - * as it is only possible to register one typefind factory per 'name' - * (which is in this case the caps), and the first one would be replaced by - * the second one. */ -static GstStaticCaps nuv_caps = GST_STATIC_CAPS ("video/x-nuv"); - -#define NUV_CAPS (gst_static_caps_get(&nuv_caps)) -static void -nuv_type_find (GstTypeFind * tf, gpointer unused) -{ - guint8 *data = gst_type_find_peek (tf, 0, 11); - - if (data) { - if (memcmp (data, "MythTVVideo", 11) == 0 - || memcmp (data, "NuppelVideo", 11) == 0) { - gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, NUV_CAPS); - } - } -} - -/*** audio/x-paris ***/ -/* NOTE: do not replace this function with two TYPE_FIND_REGISTER_START_WITH */ -static GstStaticCaps paris_caps = GST_STATIC_CAPS ("audio/x-paris"); - -#define PARIS_CAPS (gst_static_caps_get(&paris_caps)) -static void -paris_type_find (GstTypeFind * tf, gpointer unused) -{ - guint8 *data = gst_type_find_peek (tf, 0, 4); - - if (data) { - if (memcmp (data, " paf", 4) == 0 || memcmp (data, "fap ", 4) == 0) { - gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, PARIS_CAPS); - } - } -} - -/*** audio/iLBC-sh ***/ -/* NOTE: do not replace this function with two TYPE_FIND_REGISTER_START_WITH */ -static GstStaticCaps ilbc_caps = GST_STATIC_CAPS ("audio/iLBC-sh"); - -#define ILBC_CAPS (gst_static_caps_get(&ilbc_caps)) -static void -ilbc_type_find (GstTypeFind * tf, gpointer unused) -{ - guint8 *data = gst_type_find_peek (tf, 0, 8); - - if (data) { - if (memcmp (data, "#!iLBC30", 8) == 0 || memcmp (data, "#!iLBC20", 8) == 0) { - gst_type_find_suggest (tf, GST_TYPE_FIND_LIKELY, ILBC_CAPS); - } - } -} - -/*** application/x-ms-dos-executable ***/ - -static GstStaticCaps msdos_caps = -GST_STATIC_CAPS ("application/x-ms-dos-executable"); -#define MSDOS_CAPS (gst_static_caps_get(&msdos_caps)) -/* see http://www.madchat.org/vxdevl/papers/winsys/pefile/pefile.htm */ -static void -msdos_type_find (GstTypeFind * tf, gpointer unused) -{ - guint8 *data = gst_type_find_peek (tf, 0, 64); - - if (data && data[0] == 'M' && data[1] == 'Z' && - GST_READ_UINT16_LE (data + 8) == 4) { - guint32 pe_offset = GST_READ_UINT32_LE (data + 60); - - data = gst_type_find_peek (tf, pe_offset, 2); - if (data && data[0] == 'P' && data[1] == 'E') { - gst_type_find_suggest (tf, GST_TYPE_FIND_NEARLY_CERTAIN, MSDOS_CAPS); - } - } -} - -/*** application/x-mmsh ***/ - -static GstStaticCaps mmsh_caps = GST_STATIC_CAPS ("application/x-mmsh"); - -#define MMSH_CAPS gst_static_caps_get(&mmsh_caps) - -/* This is to recognise mssh-over-http */ -static void -mmsh_type_find (GstTypeFind * tf, gpointer unused) -{ - static const guint8 asf_marker[16] = { 0x30, 0x26, 0xb2, 0x75, 0x8e, 0x66, - 0xcf, 0x11, 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c - }; - - guint8 *data; - - data = gst_type_find_peek (tf, 0, 2 + 2 + 4 + 2 + 2 + 16); - if (data && data[0] == 0x24 && data[1] == 0x48 && - GST_READ_UINT16_LE (data + 2) > 2 + 2 + 4 + 2 + 2 + 16 && - memcmp (data + 2 + 2 + 4 + 2 + 2, asf_marker, 16) == 0) { - GstCaps *caps = gst_caps_copy (MMSH_CAPS); - - gst_type_find_suggest (tf, GST_TYPE_FIND_LIKELY, caps); - gst_caps_unref (caps); - return; - } -} - -/*** generic typefind for streams that have some data at a specific position***/ -typedef struct -{ - const guint8 *data; - guint size; - guint probability; - GstCaps *caps; -} -GstTypeFindData; - -static void -start_with_type_find (GstTypeFind * tf, gpointer private) -{ - GstTypeFindData *start_with = (GstTypeFindData *) private; - guint8 *data; - - GST_LOG ("trying to find mime type %s with the first %u bytes of data", - gst_structure_get_name (gst_caps_get_structure (start_with->caps, 0)), - start_with->size); - data = gst_type_find_peek (tf, 0, start_with->size); - if (data && memcmp (data, start_with->data, start_with->size) == 0) { - gst_type_find_suggest (tf, start_with->probability, start_with->caps); - } -} - -static void -sw_data_destroy (GstTypeFindData * sw_data) -{ - if (G_LIKELY (sw_data->caps != NULL)) - gst_caps_unref (sw_data->caps); - g_free (sw_data); -} - -#define TYPE_FIND_REGISTER_START_WITH(plugin,name,rank,ext,_data,_size,_probability)\ -G_BEGIN_DECLS{ \ - GstTypeFindData *sw_data = g_new (GstTypeFindData, 1); \ - sw_data->data = (const guint8 *)_data; \ - sw_data->size = _size; \ - sw_data->probability = _probability; \ - sw_data->caps = gst_caps_new_simple (name, NULL); \ - if (!gst_type_find_register (plugin, name, rank, start_with_type_find,\ - ext, sw_data->caps, sw_data, \ - (GDestroyNotify) (sw_data_destroy))) { \ - gst_caps_unref (sw_data->caps); \ - g_free (sw_data); \ - } \ -}G_END_DECLS - -/*** same for riff types ***/ - -static void -riff_type_find (GstTypeFind * tf, gpointer private) -{ - GstTypeFindData *riff_data = (GstTypeFindData *) private; - guint8 *data = gst_type_find_peek (tf, 0, 12); - - if (data && memcmp (data, "RIFF", 4) == 0) { - data += 8; - if (memcmp (data, riff_data->data, 4) == 0) - gst_type_find_suggest (tf, riff_data->probability, riff_data->caps); - } -} - -#define TYPE_FIND_REGISTER_RIFF(plugin,name,rank,ext,_data) \ -G_BEGIN_DECLS{ \ - GstTypeFindData *sw_data = g_new (GstTypeFindData, 1); \ - sw_data->data = (gpointer)_data; \ - sw_data->size = 4; \ - sw_data->probability = GST_TYPE_FIND_MAXIMUM; \ - sw_data->caps = gst_caps_new_simple (name, NULL); \ - if (!gst_type_find_register (plugin, name, rank, riff_type_find, \ - ext, sw_data->caps, sw_data, \ - (GDestroyNotify) (sw_data_destroy))) { \ - gst_caps_unref (sw_data->caps); \ - g_free (sw_data); \ - } \ -}G_END_DECLS - - - -/*** plugin initialization ***/ - -#define TYPE_FIND_REGISTER(plugin,name,rank,func,ext,caps,priv,notify) \ -G_BEGIN_DECLS{\ - if (!gst_type_find_register (plugin, name, rank, func, ext, caps, priv, notify))\ - return FALSE; \ -}G_END_DECLS -static gboolean -plugin_init (GstPlugin * plugin) -{ - /* can't initialize this via a struct as caps can't be statically initialized */ - - /* note: asx/wax/wmx are XML files, asf doesn't handle them */ - /* FIXME-0.11: these should be const, - this requires gstreamer/gst/gsttypefind::gst_type_find_register() - to have define the parameter as const - */ - static gchar *asf_exts[] = { "asf", "wm", "wma", "wmv", NULL }; - static gchar *au_exts[] = { "au", "snd", NULL }; - static gchar *avi_exts[] = { "avi", NULL }; - static gchar *cdxa_exts[] = { "dat", NULL }; - static gchar *flac_exts[] = { "flac", NULL }; - static gchar *flx_exts[] = { "flc", "fli", NULL }; - static gchar *id3_exts[] = - { "mp3", "mp2", "mp1", "mpga", "ogg", "flac", "tta", NULL }; - static gchar *apetag_exts[] = { "ape", "mpc", "wv", NULL }; /* and mp3 and wav? */ - static gchar *tta_exts[] = { "tta", NULL }; - static gchar *mod_exts[] = { "669", "amf", "dsm", "gdm", "far", "imf", - "it", "med", "mod", "mtm", "okt", "sam", - "s3m", "stm", "stx", "ult", "xm", NULL - }; - static gchar *mp3_exts[] = { "mp3", "mp2", "mp1", "mpga", NULL }; - static gchar *ac3_exts[] = { "ac3", NULL }; - static gchar *musepack_exts[] = { "mpc", NULL }; - static gchar *mpeg_sys_exts[] = { "mpe", "mpeg", "mpg", NULL }; - static gchar *mpeg_video_exts[] = { "mpv", "mpeg", "mpg", NULL }; - static gchar *mpeg_ts_exts[] = { "ts", NULL }; - static gchar *ogg_exts[] = { "anx", "ogg", "ogm", NULL }; - static gchar *qt_exts[] = { "mov", NULL }; - static gchar *qtif_exts[] = { "qif", "qtif", "qti", NULL }; - static gchar *rm_exts[] = { "ra", "ram", "rm", "rmvb", NULL }; - static gchar *swf_exts[] = { "swf", "swfl", NULL }; - static gchar *utf8_exts[] = { "txt", NULL }; - static gchar *wav_exts[] = { "wav", NULL }; - static gchar *aiff_exts[] = { "aiff", "aif", "aifc", NULL }; - static gchar *svx_exts[] = { "iff", "svx", NULL }; - static gchar *paris_exts[] = { "paf", NULL }; - static gchar *nist_exts[] = { "nist", NULL }; - static gchar *voc_exts[] = { "voc", NULL }; - static gchar *sds_exts[] = { "sds", NULL }; - static gchar *ircam_exts[] = { "sf", NULL }; - static gchar *w64_exts[] = { "w64", NULL }; - static gchar *shn_exts[] = { "shn", NULL }; - static gchar *ape_exts[] = { "ape", NULL }; - static gchar *uri_exts[] = { "ram", NULL }; - static gchar *smil_exts[] = { "smil", NULL }; - static gchar *html_exts[] = { "htm", "html", NULL }; - static gchar *xml_exts[] = { "xml", NULL }; - static gchar *jpeg_exts[] = { "jpg", "jpe", "jpeg", NULL }; - static gchar *gif_exts[] = { "gif", NULL }; - static gchar *png_exts[] = { "png", NULL }; - static gchar *bmp_exts[] = { "bmp", NULL }; - static gchar *tiff_exts[] = { "tif", "tiff", NULL }; - static gchar *matroska_exts[] = { "mkv", "mka", NULL }; - static gchar *mve_exts[] = { "mve", NULL }; - static gchar *dv_exts[] = { "dv", "dif", NULL }; - static gchar *amr_exts[] = { "amr", NULL }; - static gchar *ilbc_exts[] = { "ilbc", NULL }; - static gchar *sid_exts[] = { "sid", NULL }; - static gchar *xcf_exts[] = { "xcf", NULL }; - static gchar *mng_exts[] = { "mng", NULL }; - static gchar *jng_exts[] = { "jng", NULL }; - static gchar *xpm_exts[] = { "xpm", NULL }; - static gchar *ras_exts[] = { "ras", NULL }; - static gchar *bz2_exts[] = { "bz2", NULL }; - static gchar *gz_exts[] = { "gz", NULL }; - static gchar *zip_exts[] = { "zip", NULL }; - static gchar *compress_exts[] = { "Z", NULL }; - static gchar *m4a_exts[] = { "m4a", NULL }; - static gchar *q3gp_exts[] = { "3gp", NULL }; - static gchar *aac_exts[] = { "aac", NULL }; - static gchar *spc_exts[] = { "spc", NULL }; - static gchar *wavpack_exts[] = { "wv", "wvp", NULL }; - static gchar *wavpack_correction_exts[] = { "wvc", NULL }; - static gchar *rar_exts[] = { "rar", NULL }; - static gchar *tar_exts[] = { "tar", NULL }; - static gchar *ar_exts[] = { "a", NULL }; - static gchar *msdos_exts[] = { "dll", "exe", "ocx", "sys", "scr", - "msstyles", "cpl", NULL - }; - static gchar *flv_exts[] = { "flv", NULL }; - static gchar *m4v_exts[] = { "m4v", NULL }; - static gchar *nuv_exts[] = { "nuv", NULL }; - - GST_DEBUG_CATEGORY_INIT (type_find_debug, "typefindfunctions", - GST_DEBUG_FG_GREEN | GST_DEBUG_BG_RED, "generic type find functions"); - - /* must use strings, macros don't accept initializers */ - TYPE_FIND_REGISTER_START_WITH (plugin, "video/x-ms-asf", GST_RANK_SECONDARY, - asf_exts, - "\060\046\262\165\216\146\317\021\246\331\000\252\000\142\316\154", 16, - GST_TYPE_FIND_MAXIMUM); - TYPE_FIND_REGISTER (plugin, "audio/x-musepack", GST_RANK_PRIMARY, - musepack_type_find, musepack_exts, MUSEPACK_CAPS, NULL, NULL); - TYPE_FIND_REGISTER (plugin, "audio/x-au", GST_RANK_MARGINAL, - au_type_find, au_exts, AU_CAPS, NULL, NULL); - TYPE_FIND_REGISTER_RIFF (plugin, "video/x-msvideo", GST_RANK_PRIMARY, - avi_exts, "AVI "); - TYPE_FIND_REGISTER_RIFF (plugin, "video/x-cdxa", GST_RANK_PRIMARY, - cdxa_exts, "CDXA"); - TYPE_FIND_REGISTER_START_WITH (plugin, "video/x-vcd", GST_RANK_PRIMARY, - cdxa_exts, "\000\377\377\377\377\377\377\377\377\377\377\000", 12, - GST_TYPE_FIND_MAXIMUM); - TYPE_FIND_REGISTER_START_WITH (plugin, "audio/x-flac", GST_RANK_PRIMARY, - flac_exts, "fLaC", 4, GST_TYPE_FIND_MAXIMUM); - TYPE_FIND_REGISTER (plugin, "video/x-fli", GST_RANK_MARGINAL, flx_type_find, - flx_exts, FLX_CAPS, NULL, NULL); - TYPE_FIND_REGISTER (plugin, "application/x-id3v2", GST_RANK_PRIMARY + 3, - id3v2_type_find, id3_exts, ID3_CAPS, NULL, NULL); - TYPE_FIND_REGISTER (plugin, "application/x-id3v1", GST_RANK_PRIMARY + 1, - id3v1_type_find, id3_exts, ID3_CAPS, NULL, NULL); - TYPE_FIND_REGISTER (plugin, "application/x-apetag", GST_RANK_PRIMARY + 2, - apetag_type_find, apetag_exts, APETAG_CAPS, NULL, NULL); - TYPE_FIND_REGISTER (plugin, "audio/x-ttafile", GST_RANK_PRIMARY, - tta_type_find, tta_exts, TTA_CAPS, NULL, NULL); - TYPE_FIND_REGISTER (plugin, "audio/x-mod", GST_RANK_SECONDARY, mod_type_find, - mod_exts, MOD_CAPS, NULL, NULL); - TYPE_FIND_REGISTER (plugin, "audio/mpeg", GST_RANK_PRIMARY, mp3_type_find, - mp3_exts, MP3_CAPS, NULL, NULL); - TYPE_FIND_REGISTER (plugin, "audio/x-ac3", GST_RANK_PRIMARY, ac3_type_find, - ac3_exts, AC3_CAPS, NULL, NULL); - TYPE_FIND_REGISTER (plugin, "video/mpeg1", GST_RANK_PRIMARY, - mpeg1_sys_type_find, mpeg_sys_exts, MPEG_SYS_CAPS, NULL, NULL); - TYPE_FIND_REGISTER (plugin, "video/mpeg2", GST_RANK_SECONDARY, - mpeg2_sys_type_find, mpeg_sys_exts, MPEG_SYS_CAPS, NULL, NULL); - TYPE_FIND_REGISTER (plugin, "video/mpegts", GST_RANK_PRIMARY, - mpeg_ts_type_find, mpeg_ts_exts, MPEGTS_CAPS, NULL, NULL); - TYPE_FIND_REGISTER (plugin, "application/ogg", GST_RANK_PRIMARY, - ogganx_type_find, ogg_exts, OGGANX_CAPS, NULL, NULL); - TYPE_FIND_REGISTER (plugin, "video/mpeg", GST_RANK_SECONDARY, - mpeg_video_type_find, mpeg_video_exts, MPEG_VIDEO_CAPS, NULL, NULL); - TYPE_FIND_REGISTER (plugin, "video/mpeg-stream", GST_RANK_MARGINAL, - mpeg_video_stream_type_find, mpeg_video_exts, MPEG_VIDEO_CAPS, NULL, - NULL); - TYPE_FIND_REGISTER (plugin, "video/mpeg4", GST_RANK_PRIMARY, - mpeg4_video_type_find, m4v_exts, MPEG_VIDEO_CAPS, NULL, NULL); - TYPE_FIND_REGISTER (plugin, "video/x-nuv", GST_RANK_SECONDARY, - nuv_type_find, nuv_exts, NUV_CAPS, NULL, NULL); - - /* ISO formats */ - TYPE_FIND_REGISTER (plugin, "audio/x-m4a", GST_RANK_PRIMARY, m4a_type_find, - m4a_exts, M4A_CAPS, NULL, NULL); - TYPE_FIND_REGISTER (plugin, "application/x-3gp", GST_RANK_PRIMARY, - q3gp_type_find, q3gp_exts, Q3GP_CAPS, NULL, NULL); - TYPE_FIND_REGISTER (plugin, "video/quicktime", GST_RANK_SECONDARY, - qt_type_find, qt_exts, QT_CAPS, NULL, NULL); - TYPE_FIND_REGISTER (plugin, "image/x-quicktime", GST_RANK_SECONDARY, - qtif_type_find, qtif_exts, QTIF_CAPS, NULL, NULL); - - TYPE_FIND_REGISTER (plugin, "text/html", GST_RANK_SECONDARY, html_type_find, - html_exts, HTML_CAPS, NULL, NULL); - TYPE_FIND_REGISTER_START_WITH (plugin, "application/vnd.rn-realmedia", - GST_RANK_SECONDARY, rm_exts, ".RMF", 4, GST_TYPE_FIND_MAXIMUM); - TYPE_FIND_REGISTER_START_WITH (plugin, "application/x-pn-realaudio", - GST_RANK_SECONDARY, rm_exts, ".ra\375", 4, GST_TYPE_FIND_MAXIMUM); - TYPE_FIND_REGISTER (plugin, "application/x-shockwave-flash", - GST_RANK_SECONDARY, swf_type_find, swf_exts, SWF_CAPS, NULL, NULL); - TYPE_FIND_REGISTER_START_WITH (plugin, "video/x-flv", GST_RANK_SECONDARY, - flv_exts, "FLV", 3, GST_TYPE_FIND_MAXIMUM); - TYPE_FIND_REGISTER (plugin, "text/plain", GST_RANK_MARGINAL, utf8_type_find, - utf8_exts, UTF8_CAPS, NULL, NULL); - TYPE_FIND_REGISTER (plugin, "text/uri-list", GST_RANK_MARGINAL, uri_type_find, - uri_exts, URI_CAPS, NULL, NULL); - TYPE_FIND_REGISTER (plugin, "application/smil", GST_RANK_SECONDARY, - smil_type_find, smil_exts, SMIL_CAPS, NULL, NULL); - TYPE_FIND_REGISTER (plugin, "application/xml", GST_RANK_MARGINAL, - xml_type_find, xml_exts, GENERIC_XML_CAPS, NULL, NULL); - TYPE_FIND_REGISTER_RIFF (plugin, "audio/x-wav", GST_RANK_PRIMARY, wav_exts, - "WAVE"); - TYPE_FIND_REGISTER (plugin, "audio/x-aiff", GST_RANK_SECONDARY, - aiff_type_find, aiff_exts, AIFF_CAPS, NULL, NULL); - TYPE_FIND_REGISTER (plugin, "audio/x-svx", GST_RANK_SECONDARY, svx_type_find, - svx_exts, SVX_CAPS, NULL, NULL); - TYPE_FIND_REGISTER (plugin, "audio/x-paris", GST_RANK_SECONDARY, - paris_type_find, paris_exts, PARIS_CAPS, NULL, NULL); - TYPE_FIND_REGISTER_START_WITH (plugin, "audio/x-nist", GST_RANK_SECONDARY, - nist_exts, "NIST", 4, GST_TYPE_FIND_MAXIMUM); - TYPE_FIND_REGISTER_START_WITH (plugin, "audio/x-voc", GST_RANK_SECONDARY, - voc_exts, "Creative", 8, GST_TYPE_FIND_MAXIMUM); - TYPE_FIND_REGISTER (plugin, "audio/x-sds", GST_RANK_SECONDARY, sds_type_find, - sds_exts, SDS_CAPS, NULL, NULL); - TYPE_FIND_REGISTER (plugin, "audio/x-ircam", GST_RANK_SECONDARY, - ircam_type_find, ircam_exts, IRCAM_CAPS, NULL, NULL); - TYPE_FIND_REGISTER_START_WITH (plugin, "audio/x-w64", GST_RANK_SECONDARY, - w64_exts, "riff", 4, GST_TYPE_FIND_MAXIMUM); - TYPE_FIND_REGISTER (plugin, "audio/x-shorten", GST_RANK_SECONDARY, - shn_type_find, shn_exts, SHN_CAPS, NULL, NULL); - TYPE_FIND_REGISTER (plugin, "application/x-ape", GST_RANK_SECONDARY, - ape_type_find, ape_exts, APE_CAPS, NULL, NULL); - TYPE_FIND_REGISTER (plugin, "image/jpeg", GST_RANK_PRIMARY, jpeg_type_find, - jpeg_exts, JPEG_CAPS, NULL, NULL); - TYPE_FIND_REGISTER_START_WITH (plugin, "image/gif", GST_RANK_PRIMARY, - gif_exts, "GIF8", 4, GST_TYPE_FIND_MAXIMUM); - TYPE_FIND_REGISTER_START_WITH (plugin, "image/png", GST_RANK_PRIMARY, - png_exts, "\211PNG\015\012\032\012", 8, GST_TYPE_FIND_MAXIMUM); - TYPE_FIND_REGISTER (plugin, "image/bmp", GST_RANK_PRIMARY, bmp_type_find, - bmp_exts, BMP_CAPS, NULL, NULL); - TYPE_FIND_REGISTER (plugin, "image/tiff", GST_RANK_PRIMARY, tiff_type_find, - tiff_exts, TIFF_CAPS, NULL, NULL); - TYPE_FIND_REGISTER (plugin, "video/x-matroska", GST_RANK_PRIMARY, - matroska_type_find, matroska_exts, MATROSKA_CAPS, NULL, NULL); - TYPE_FIND_REGISTER_START_WITH (plugin, "video/x-mve", GST_RANK_SECONDARY, - mve_exts, "Interplay MVE File\032\000\032\000\000\001\063\021", 26, - GST_TYPE_FIND_MAXIMUM); - TYPE_FIND_REGISTER (plugin, "video/x-dv", GST_RANK_SECONDARY, dv_type_find, - dv_exts, DV_CAPS, NULL, NULL); - TYPE_FIND_REGISTER_START_WITH (plugin, "audio/x-amr-nb-sh", GST_RANK_PRIMARY, - amr_exts, "#!AMR", 5, GST_TYPE_FIND_LIKELY); - TYPE_FIND_REGISTER_START_WITH (plugin, "audio/x-amr-wb-sh", GST_RANK_PRIMARY, - amr_exts, "#!AMR-WB", 7, GST_TYPE_FIND_MAXIMUM); - TYPE_FIND_REGISTER (plugin, "audio/iLBC-sh", GST_RANK_PRIMARY, - ilbc_type_find, ilbc_exts, ILBC_CAPS, NULL, NULL); - TYPE_FIND_REGISTER_START_WITH (plugin, "audio/x-sid", GST_RANK_MARGINAL, - sid_exts, "PSID", 4, GST_TYPE_FIND_MAXIMUM); - TYPE_FIND_REGISTER_START_WITH (plugin, "image/x-xcf", GST_RANK_SECONDARY, - xcf_exts, "gimp xcf", 8, GST_TYPE_FIND_MAXIMUM); - TYPE_FIND_REGISTER_START_WITH (plugin, "video/x-mng", GST_RANK_SECONDARY, - mng_exts, "\212MNG\015\012\032\012", 8, GST_TYPE_FIND_MAXIMUM); - TYPE_FIND_REGISTER_START_WITH (plugin, "image/x-jng", GST_RANK_SECONDARY, - jng_exts, "\213JNG\015\012\032\012", 8, GST_TYPE_FIND_MAXIMUM); - TYPE_FIND_REGISTER_START_WITH (plugin, "image/x-xpixmap", GST_RANK_SECONDARY, - xpm_exts, "/* XPM */", 9, GST_TYPE_FIND_MAXIMUM); - TYPE_FIND_REGISTER_START_WITH (plugin, "image/x-sun-raster", - GST_RANK_SECONDARY, ras_exts, "\131\246\152\225", 4, - GST_TYPE_FIND_MAXIMUM); - TYPE_FIND_REGISTER_START_WITH (plugin, "application/x-bzip", - GST_RANK_SECONDARY, bz2_exts, "BZh", 3, GST_TYPE_FIND_LIKELY); - TYPE_FIND_REGISTER_START_WITH (plugin, "application/x-gzip", - GST_RANK_SECONDARY, gz_exts, "\037\213", 2, GST_TYPE_FIND_LIKELY); - TYPE_FIND_REGISTER_START_WITH (plugin, "application/zip", GST_RANK_SECONDARY, - zip_exts, "PK\003\004", 4, GST_TYPE_FIND_LIKELY); - TYPE_FIND_REGISTER_START_WITH (plugin, "application/x-compress", - GST_RANK_SECONDARY, compress_exts, "\037\235", 2, GST_TYPE_FIND_LIKELY); - TYPE_FIND_REGISTER (plugin, "audio/x-vorbis", GST_RANK_PRIMARY, - vorbis_type_find, NULL, VORBIS_CAPS, NULL, NULL); - TYPE_FIND_REGISTER (plugin, "video/x-theora", GST_RANK_PRIMARY, - theora_type_find, NULL, THEORA_CAPS, NULL, NULL); - TYPE_FIND_REGISTER (plugin, "application/x-ogm-video", GST_RANK_PRIMARY, - ogmvideo_type_find, NULL, OGMVIDEO_CAPS, NULL, NULL); - TYPE_FIND_REGISTER (plugin, "application/x-ogm-audio", GST_RANK_PRIMARY, - ogmaudio_type_find, NULL, OGMAUDIO_CAPS, NULL, NULL); - TYPE_FIND_REGISTER (plugin, "application/x-ogm-text", GST_RANK_PRIMARY, - ogmtext_type_find, NULL, OGMTEXT_CAPS, NULL, NULL); - TYPE_FIND_REGISTER (plugin, "audio/x-speex", GST_RANK_PRIMARY, - speex_type_find, NULL, SPEEX_CAPS, NULL, NULL); - TYPE_FIND_REGISTER (plugin, "application/x-ogg-skeleton", GST_RANK_PRIMARY, - oggskel_type_find, NULL, OGG_SKELETON_CAPS, NULL, NULL); - TYPE_FIND_REGISTER (plugin, "text/x-cmml", GST_RANK_PRIMARY, cmml_type_find, - NULL, CMML_CAPS, NULL, NULL); - TYPE_FIND_REGISTER_START_WITH (plugin, "application/x-executable", - GST_RANK_MARGINAL, NULL, "\177ELF", 4, GST_TYPE_FIND_MAXIMUM); - TYPE_FIND_REGISTER (plugin, "adts_mpeg_stream", GST_RANK_SECONDARY, - aac_type_find, aac_exts, AAC_CAPS, NULL, NULL); - TYPE_FIND_REGISTER_START_WITH (plugin, "audio/x-spc", GST_RANK_SECONDARY, - spc_exts, "SNES-SPC700 Sound File Data", 27, GST_TYPE_FIND_MAXIMUM); - TYPE_FIND_REGISTER (plugin, "audio/x-wavpack", GST_RANK_SECONDARY, - wavpack_type_find, wavpack_exts, WAVPACK_CAPS, NULL, NULL); - TYPE_FIND_REGISTER (plugin, "audio/x-wavpack-correction", GST_RANK_SECONDARY, - wavpack_type_find, wavpack_correction_exts, WAVPACK_CORRECTION_CAPS, NULL, - NULL); - TYPE_FIND_REGISTER_START_WITH (plugin, "application/x-rar", - GST_RANK_SECONDARY, rar_exts, "Rar!", 4, GST_TYPE_FIND_LIKELY); - TYPE_FIND_REGISTER (plugin, "application/x-tar", GST_RANK_SECONDARY, - tar_type_find, tar_exts, TAR_CAPS, NULL, NULL); - TYPE_FIND_REGISTER (plugin, "application/x-ar", GST_RANK_SECONDARY, - ar_type_find, ar_exts, AR_CAPS, NULL, NULL); - TYPE_FIND_REGISTER (plugin, "application/x-ms-dos-executable", - GST_RANK_SECONDARY, msdos_type_find, msdos_exts, MSDOS_CAPS, NULL, NULL); -#if 0 - TYPE_FIND_REGISTER_START_WITH (plugin, "video/x-dirac", - GST_RANK_PRIMARY, NULL, "BBCD", 4, GST_TYPE_FIND_MAXIMUM); -#endif - TYPE_FIND_REGISTER_START_WITH (plugin, "video/x-dirac", - GST_RANK_PRIMARY, NULL, "KW-DIRAC", 8, GST_TYPE_FIND_MAXIMUM); - TYPE_FIND_REGISTER (plugin, "multipart/x-mixed-replace", GST_RANK_SECONDARY, - multipart_type_find, NULL, MULTIPART_CAPS, NULL, NULL); - TYPE_FIND_REGISTER (plugin, "application/x-mmsh", GST_RANK_SECONDARY, - mmsh_type_find, NULL, MMSH_CAPS, NULL, NULL); - return TRUE; -} - -GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, - GST_VERSION_MINOR, - "typefindfunctions", - "default typefind functions", - plugin_init, VERSION, "LGPL", "GStreamer Base Plug-ins CVS/prerelease", "Gstreamer CVS")