# HG changeset patch # User melunko # Date 1190119536 -3600 # Node ID 3c18c36245e787bcb1f426b82fc4cc846cfdf83a # Parent 5d027884a9d3f97837f75f90462b49f043b85307 [svn r853] gmemcoder folder renamed to gmencoder diff -r 5d027884a9d3 -r 3c18c36245e7 gmyth-stream/gmemcoder/INSTALL --- a/gmyth-stream/gmemcoder/INSTALL Tue Sep 18 13:45:04 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,236 +0,0 @@ -Installation Instructions -************************* - -Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005 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' installs the package's commands under -`/usr/local/bin', include files under `/usr/local/include', etc. You -can specify an installation prefix other than `/usr/local' by giving -`configure' the option `--prefix=PREFIX'. - - You can specify separate installation prefixes for -architecture-specific files and architecture-independent files. If you -pass the option `--exec-prefix=PREFIX' to `configure', the package uses -PREFIX as the prefix for installing programs and libraries. -Documentation and other data files still use the regular prefix. - - In addition, if you use an unusual directory layout you can give -options like `--bindir=DIR' to specify different values for particular -kinds of files. Run `configure --help' for a list of the directories -you can set and what kinds of files go in them. - - If the package supports it, you can cause programs to be installed -with an extra prefix or suffix on their names by giving `configure' the -option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. - -Optional Features -================= - -Some packages pay attention to `--enable-FEATURE' options to -`configure', where FEATURE indicates an optional part of the package. -They may also pay attention to `--with-PACKAGE' options, where PACKAGE -is something like `gnu-as' or `x' (for the X Window System). The -`README' should mention any `--enable-' and `--with-' options that the -package recognizes. - - For packages that use the X Window System, `configure' can usually -find the X include and library files automatically, but if it doesn't, -you can use the `configure' options `--x-includes=DIR' and -`--x-libraries=DIR' to specify their locations. - -Specifying the System Type -========================== - -There may be some features `configure' cannot figure out automatically, -but needs to determine by the type of machine the package will run on. -Usually, assuming the package is built to be run on the _same_ -architectures, `configure' can figure that out, but if it prints a -message saying it cannot guess the machine type, give it the -`--build=TYPE' option. TYPE can either be a short name for the system -type, such as `sun4', or a canonical name which has the form: - - CPU-COMPANY-SYSTEM - -where SYSTEM can have one of these forms: - - OS KERNEL-OS - - See the file `config.sub' for the possible values of each field. If -`config.sub' isn't included in this package, then this package doesn't -need to know the machine type. - - If you are _building_ compiler tools for cross-compiling, you should -use the option `--target=TYPE' to select the type of system they will -produce code for. - - If you want to _use_ a cross compiler, that generates code for a -platform different from the build platform, you should specify the -"host" platform (i.e., that on which the generated programs will -eventually be run) with `--host=TYPE'. - -Sharing Defaults -================ - -If you want to set default values for `configure' scripts to share, you -can create a site shell script called `config.site' that gives default -values for variables like `CC', `cache_file', and `prefix'. -`configure' looks for `PREFIX/share/config.site' if it exists, then -`PREFIX/etc/config.site' if it exists. Or, you can set the -`CONFIG_SITE' environment variable to the location of the site script. -A warning: not all `configure' scripts look for a site script. - -Defining Variables -================== - -Variables not defined in a site shell script can be set in the -environment passed to `configure'. However, some packages may run -configure again during the build, and the customized values of these -variables may be lost. In order to avoid this problem, you should set -them in the `configure' command line, using `VAR=value'. For example: - - ./configure CC=/usr/local2/bin/gcc - -causes the specified `gcc' to be used as the C compiler (unless it is -overridden in the site shell script). Here is a another example: - - /bin/bash ./configure CONFIG_SHELL=/bin/bash - -Here the `CONFIG_SHELL=/bin/bash' operand causes subsequent -configuration-related scripts to be executed by `/bin/bash'. - -`configure' Invocation -====================== - -`configure' recognizes the following options to control how it operates. - -`--help' -`-h' - Print a summary of the options to `configure', and exit. - -`--version' -`-V' - Print the version of Autoconf used to generate the `configure' - script, and exit. - -`--cache-file=FILE' - Enable the cache: use and save the results of the tests in FILE, - traditionally `config.cache'. FILE defaults to `/dev/null' to - disable caching. - -`--config-cache' -`-C' - Alias for `--cache-file=config.cache'. - -`--quiet' -`--silent' -`-q' - Do not print messages saying which checks are being made. To - suppress all normal output, redirect it to `/dev/null' (any error - messages will still be shown). - -`--srcdir=DIR' - Look for the package's source code in directory DIR. Usually - `configure' can determine that directory automatically. - -`configure' also accepts some other, not widely useful, options. Run -`configure --help' for more details. - diff -r 5d027884a9d3 -r 3c18c36245e7 gmyth-stream/gmemcoder/Makefile.am --- a/gmyth-stream/gmemcoder/Makefile.am Tue Sep 18 13:45:04 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7 +0,0 @@ -SUBDIRS = src - -EXTRA_DIST = \ - ChangeLog - -DIST_SUBDIRS = \ - src diff -r 5d027884a9d3 -r 3c18c36245e7 gmyth-stream/gmemcoder/autogen.sh --- a/gmyth-stream/gmemcoder/autogen.sh Tue Sep 18 13:45:04 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,19 +0,0 @@ -#!/bin/sh -# Run this to generate all the initial makefiles, etc. - -srcdir=`dirname $0` -test -z "$srcdir" && srcdir=. - -PKG_NAME="gmemcoder" - -(test -f $srcdir/configure.ac) || { - echo -n "**Error**: Directory "\`$srcdir\'" does not look like the" - echo " top-level $PKG_NAME directory" - exit 1 -} - -which gnome-autogen.sh || { - echo "You need to install gnome-common from the GNOME CVS" - exit 1 -} -REQUIRED_AUTOMAKE_VERSION=1.9 USE_GNOME2_MACROS=1 . gnome-autogen.sh diff -r 5d027884a9d3 -r 3c18c36245e7 gmyth-stream/gmemcoder/configure.ac --- a/gmyth-stream/gmemcoder/configure.ac Tue Sep 18 13:45:04 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,93 +0,0 @@ -# -*- Autoconf -*- -# Process this file with autoconf to produce a configure script. - -AC_PREREQ(2.50) - -AC_INIT([gmemcoder],[0.1]) - -AC_CONFIG_MACRO_DIR([m4]) -AC_CONFIG_HEADER(config.h) - -AS_VERSION(gmemcoder, GMEMCODER, 0, 1, 0, 0, GMEMCODER_SVN="no", GMEMCODER_SVN="yes") -GMEMCODER_MAJORMINOR=$GMEMCODER_VERSION.$GMEMCODER_MINOR_VERSION -AC_SUBST(GMEMCODER_MAJORMINOR) - -dnl AM_MAINTAINER_MODE provides the option to enable maintainer mode -AM_MAINTAINER_MODE -dnl make aclocal work in maintainer mode -AC_SUBST(ACLOCAL_AMFLAGS, "-I m4") - -AM_INIT_AUTOMAKE($PACKAGE, $VERSION) - -# Checks for programs. -# check for tools -# Make sure CFLAGS is defined to stop AC_PROC_CC adding -g -CFLAGS="$CFLAGS -Wall" -AC_PROG_CC -AC_PROG_LIBTOOL - -# Checks for libraries. - -# Checks for header files. -AC_HEADER_STDC - -#Test if --disable-debug given -AC_ARG_ENABLE(debug, - AC_HELP_STRING([--disable-debug], [enable debugging mode])) -if test x"$enable_debug" != xno; then - CFLAGS="$CFLAGS -g -DMYTH_STREAM_USE_DEBUG" -else - CFLAGS="$CFLAGS -O2 -DG_DISABLE_CHECKS" -fi - - -# Checks required packages #################################################### -############################################################################### - -## Check for pkgconfig ######################################################## -############################################################################### -AC_CHECK_PROG(HAVE_PKGCONFIG, pkg-config, yes, no) -if test "x$HAVE_PKGCONFIG" = "xno"; then - AC_MSG_ERROR(you need to have pkgconfig installed !) -fi - -## Check for Glib2.0 ########################################################## -############################################################################### -PKG_CHECK_MODULES(GLIB, glib-2.0, HAVE_GLIB=yes,HAVE_GLIB=no) -if test "x$HAVE_GLIB" = "xno"; then - AC_MSG_ERROR(you need glib-2.0 installed) -fi -AC_SUBST(GLIB_CFLAGS) -AC_SUBST(GLIB_LIBS) - -## Check for GnomeVFS ########################################################## -############################################################################### -PKG_CHECK_MODULES(GVFS, gnome-vfs-2.0, HAVE_GVFS=yes,HAVE_GVFS=no) -if test "x$HAVE_GVFS" = "xno"; then - AC_MSG_ERROR(you need gnome-vfs-2.0 installed) -fi -AC_SUBST(GVFS_CFLAGS) -AC_SUBST(GVFS_LIBS) - - -## Check for gst-base ######################################################### -############################################################################### -PKG_CHECK_MODULES(GST, [gstreamer-base-0.10]) -AC_SUBST(GST_CFLAGS) -AC_SUBST(GST_LIBS) - -AC_SUBST(CFLAGS) -AC_SUBST(LDFLAGS) -AC_SUBST(LIBS) - -AC_OUTPUT([ -Makefile -src/Makefile -]) - -if test "x$enable_debug" != "xno"; then - AC_MSG_NOTICE([Debug: Enabled]) -else - AC_MSG_NOTICE([Debug: Disabled]) -fi - diff -r 5d027884a9d3 -r 3c18c36245e7 gmyth-stream/gmemcoder/m4/as-compiler-flag.m4 --- a/gmyth-stream/gmemcoder/m4/as-compiler-flag.m4 Tue Sep 18 13:45:04 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 5d027884a9d3 -r 3c18c36245e7 gmyth-stream/gmemcoder/m4/as-expand.m4 --- a/gmyth-stream/gmemcoder/m4/as-expand.m4 Tue Sep 18 13:45:04 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -dnl AS_AC_EXPAND(VAR, CONFIGURE_VAR) -dnl -dnl example -dnl AS_AC_EXPAND(SYSCONFDIR, $sysconfdir) -dnl will set SYSCONFDIR to /usr/local/etc if prefix=/usr/local - -AC_DEFUN([AS_AC_EXPAND], -[ - EXP_VAR=[$1] - FROM_VAR=[$2] - - dnl first expand prefix and exec_prefix if necessary - prefix_save=$prefix - exec_prefix_save=$exec_prefix - - dnl if no prefix given, then use /usr/local, the default prefix - if test "x$prefix" = "xNONE"; then - prefix=$ac_default_prefix - fi - dnl if no exec_prefix given, then use prefix - if test "x$exec_prefix" = "xNONE"; then - exec_prefix=$prefix - fi - - full_var="$FROM_VAR" - dnl loop until it doesn't change anymore - while true; do - new_full_var="`eval echo $full_var`" - if test "x$new_full_var"="x$full_var"; then break; fi - full_var=$new_full_var - done - - dnl clean up - full_var=$new_full_var - AC_SUBST([$1], "$full_var") - - dnl restore prefix and exec_prefix - prefix=$prefix_save - exec_prefix=$exec_prefix_save -]) diff -r 5d027884a9d3 -r 3c18c36245e7 gmyth-stream/gmemcoder/m4/as-version.m4 --- a/gmyth-stream/gmemcoder/m4/as-version.m4 Tue Sep 18 13:45:04 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 5d027884a9d3 -r 3c18c36245e7 gmyth-stream/gmemcoder/m4/gst-feature.m4 --- a/gmyth-stream/gmemcoder/m4/gst-feature.m4 Tue Sep 18 13:45:04 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 5d027884a9d3 -r 3c18c36245e7 gmyth-stream/gmemcoder/src/Makefile.am --- a/gmyth-stream/gmemcoder/src/Makefile.am Tue Sep 18 13:45:04 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,20 +0,0 @@ -bin_PROGRAMS = \ - gmencoder - -gmencoder_SOURCES = \ - main.c \ - gmencoder.c \ - gmencoder.h - -gmencoder_LDADD = \ - $(GLIB_LIBS) \ - $(GST_LIBS) \ - $(GVFS_LIBS) \ - -lgstinterfaces-0.10 - -AM_CPPFLAGS = \ - $(GLIB_CFLAGS) \ - $(GST_CFLAGS) \ - $(GVFS_CFLAGS) - -CLEANFILES = diff -r 5d027884a9d3 -r 3c18c36245e7 gmyth-stream/gmemcoder/src/gmencoder.c --- a/gmyth-stream/gmemcoder/src/gmencoder.c Tue Sep 18 13:45:04 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1207 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "gmencoder.h" - -#define G_MENCODER_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((obj), G_TYPE_MENCODER, GMencoderPrivate)) - -#define USE_MANUAL_SINK -#define GMENCODER_TIMEOUT 5000 - -typedef struct _GMencoderPrivate GMencoderPrivate; -typedef struct _SetupInfo SetupInfo; - -struct _SetupInfo { - gchar *video_encode; - gchar *mux_name; - gchar **video_encode_prop; - gdouble video_fps; - gdouble video_rate; - guint video_width; - guint video_height; - gchar *audio_encode; - gchar **audio_encode_prop; - guint audio_rate; -}; - - -struct _GMencoderPrivate { - GstElement *pipe; - GstElement *abin; - GstElement *vbin; - GstElement *sink; - GstElement *src; - - GnomeVFSHandle *handle; - - gboolean ready; - SetupInfo *info; - GstClockTime videot; - GstClockTime audiot; - gint sources; - gint tick_id; - gint64 duration; - gboolean send_chunked; - gint timeout_id; - - //V4l info - GstElement *v4lsrc; - gchar *channel; - gchar *norm; - glong frequency; -}; - -enum { - PAUSED, - PLAYING, - STOPED, - EOS, - ERROR, - LAST_SIGNAL -}; - -static void g_mencoder_class_init(GMencoderClass * klass); -static void g_mencoder_init(GMencoder * object); -static void g_mencoder_dispose(GObject * object); -static void g_mencoder_finalize(GObject * object); -static GstElement *_create_audio_bin(const gchar * encode, - gchar ** encode_prop, gint rate); -static GstElement *_create_video_bin(const gchar * encode, - gchar ** encode_prop, - gdouble fps, - gint rate, guint width, guint height, - gboolean use_deinterlace); - -static gboolean -_pipeline_bus_cb(GstBus * bus, GstMessage * msg, gpointer user_data); - -static void _decodebin_new_pad_cb(GstElement * object, - GstPad * pad, - gboolean flag, gpointer user_data); - -static void _decodebin_unknown_type_cb(GstElement * object, - GstPad * pad, - GstCaps * caps, - gpointer user_data); - -static void _close_output(GMencoder * self); -static gboolean _open_output(GMencoder * self, const gchar * uri); - -static GstElement *_create_source(GMencoder *self, const gchar * uri); -static GstElement *_create_pipeline(GMencoder * self, - const gchar * video_encode, - const gchar * mux_name, - gchar ** video_encode_prop, - gdouble video_fps, - gdouble video_rate, - guint video_width, - guint video_height, - const gchar * audio_encode, - gchar ** audio_encode_prop, - guint audio_rate, - gboolean deinterlace); -static gboolean _process_timeout_cb (gpointer user_data); -#ifdef USE_MANUAL_SINK -static void _flush_queue (GMencoder *self); -static void _buffer_arrive_cb (GstElement* object, - GstBuffer* buff, - GstPad* pad, - gpointer user_data); -#endif - - -static gboolean _tick_cb(gpointer data); - -static guint g_mencoder_signals[LAST_SIGNAL] = { 0 }; - -G_DEFINE_TYPE(GMencoder, g_mencoder, G_TYPE_OBJECT) - -static void g_mencoder_class_init(GMencoderClass * klass) -{ - GObjectClass *object_class; - object_class = (GObjectClass *) klass; - g_type_class_add_private(klass, sizeof(GMencoderPrivate)); - - object_class->dispose = g_mencoder_dispose; - object_class->finalize = g_mencoder_finalize; - - g_mencoder_signals[PAUSED] = - g_signal_new("paused", - G_OBJECT_CLASS_TYPE(object_class), - G_SIGNAL_RUN_FIRST, - 0, NULL, NULL, - g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - - g_mencoder_signals[PLAYING] = - g_signal_new("playing", - G_OBJECT_CLASS_TYPE(object_class), - G_SIGNAL_RUN_FIRST, - 0, NULL, NULL, - g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - - g_mencoder_signals[STOPED] = - g_signal_new("stoped", - G_OBJECT_CLASS_TYPE(object_class), - G_SIGNAL_RUN_FIRST, - 0, NULL, NULL, - g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - - g_mencoder_signals[EOS] = - g_signal_new("eos", - G_OBJECT_CLASS_TYPE(object_class), - G_SIGNAL_RUN_FIRST, - 0, NULL, NULL, - g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - - g_mencoder_signals[ERROR] = - g_signal_new("error", - G_OBJECT_CLASS_TYPE(object_class), - G_SIGNAL_RUN_LAST, - 0, NULL, NULL, - g_cclosure_marshal_VOID__STRING, - G_TYPE_NONE, 1, G_TYPE_STRING); -} - -static void -g_mencoder_init(GMencoder * self) -{ - GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(self); - priv->info = g_new0(SetupInfo, 1); -} - -static void -g_mencoder_dispose(GObject * object) -{ -} - -static void -g_mencoder_finalize(GObject * object) -{ - GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(object); - - // TODO: clear vars - g_mencoder_close_stream(G_MENCODER(object)); - g_free (priv->info); -} - -GMencoder * -g_mencoder_new(void) -{ - return g_object_new(G_TYPE_MENCODER, NULL); -} - - -static void -_obj_set_prop(GObject * obj, const gchar * prop_name, - const gchar * prop_val) -{ - GValue p = { 0 }; - GValue v = { 0 }; - GParamSpec *s = NULL; - GObjectClass *k = G_OBJECT_GET_CLASS(obj); - - - g_value_init(&v, G_TYPE_STRING); - g_value_set_string(&v, prop_val); - - s = g_object_class_find_property(k, prop_name); - if (s == NULL) { - g_print("Invalid property name: %s\n", prop_name); - return; - } - - g_value_init(&p, s->value_type); - switch (s->value_type) { - case G_TYPE_INT: - g_value_set_int(&p, atoi(prop_val)); - break; - case G_TYPE_ULONG: - g_value_set_ulong (&p, atol(prop_val)); - break; - case G_TYPE_STRING: - g_value_set_string(&p, prop_val); - break; - case G_TYPE_BOOLEAN: - g_value_set_boolean(&p, (gboolean) atoi (prop_val)); - break; - case G_TYPE_DOUBLE: - g_value_set_double(&p, atof (prop_val)); - break; - case G_TYPE_FLOAT: - g_value_set_float(&p, (float) atof (prop_val)); - break; - default: - g_value_set_enum(&p, atoi(prop_val)); - g_warning ("Property %s of type %s. Not supported using default enum", - prop_name, g_type_name (s->value_type)); - return; - } - - g_object_set_property(obj, prop_name, &p); - g_value_unset(&v); - g_value_unset(&p); -} - -static GstElement * -_create_element_with_prop(const gchar * factory_name, - const gchar * element_name, gchar ** prop) -{ - GstElement *ret; - int i; - - ret = gst_element_factory_make(factory_name, element_name); - if (ret == NULL) - return NULL; - - if (prop != NULL) { - for (i = 0; i < g_strv_length(prop); i++) { - if (prop[i] != NULL) { - char **v = g_strsplit(prop[i], "=", 2); - if (g_strv_length(v) == 2) { - _obj_set_prop(G_OBJECT(ret), v[0], v[1]); - } - g_strfreev(v); - } - } - } - - return ret; - -} - -static GstElement * -_create_audio_bin(const gchar * encode, gchar ** encode_prop, gint rate) -{ - GstElement *abin = NULL; - GstElement *aqueue = NULL; - GstElement *aconvert = NULL; - GstElement *aencode = NULL; - GstElement *aqueue_src = NULL; - GstPad *apad = NULL; - - // audio/x-raw-int ! queue ! audioconvert ! faac ! rtpmp4gpay ! - // udpsink name=upd_audio host=224.0.0.1 port=5002 - abin = gst_bin_new("abin"); - aqueue = gst_element_factory_make("queue", "aqueue"); - aconvert = gst_element_factory_make("audioconvert", "aconvert"); - aencode = - _create_element_with_prop((encode ? encode : "lame"), "aencode", - encode_prop); - aqueue_src = gst_element_factory_make("queue", "aqueue_src"); - - if ((abin == NULL) || (aqueue == NULL) || (aconvert == NULL) - || (aencode == NULL) || (aqueue_src == NULL)) { - g_warning("Audio elements not found"); - goto error; - } - - g_object_set(G_OBJECT(aencode), "bitrate", 32, NULL); - /* - * if (rate > 0) { g_object_set (G_OBJECT (aencode), "bitrate", 32, - * NULL); } - */ - - gst_bin_add_many(GST_BIN(abin), aqueue, aconvert, aencode, aqueue_src, - NULL); - if (gst_element_link_many(aqueue, aconvert, aencode, aqueue_src, NULL) - == FALSE) { - g_warning("Not Link audio elements"); - } - // TODO: apply audio rate - - // ghost pad the audio bin - apad = gst_element_get_pad(aqueue, "sink"); - gst_element_add_pad(abin, gst_ghost_pad_new("sink", apad)); - gst_object_unref(apad); - - apad = gst_element_get_pad(aqueue_src, "src"); - gst_element_add_pad(abin, gst_ghost_pad_new("src", apad)); - gst_object_unref(apad); - - return abin; - error: - if (abin != NULL) - gst_object_unref(abin); - - if (aqueue != NULL) - gst_object_unref(aqueue); - - if (aconvert != NULL) - gst_object_unref(aconvert); - - if (aencode != NULL) - gst_object_unref(aencode); - - if (aqueue_src != NULL) - gst_object_unref(aqueue_src); - - if (apad != NULL) - gst_object_unref(apad); - - return NULL; -} - - - - -// queue ! videoscale ! video/x-raw-yuv,width=240,height=144 ! colorspace -// ! rate ! encode ! queue -static GstElement * -_create_video_bin(const gchar * encode, - gchar ** encode_prop, - gdouble fps, gint rate, guint width, guint height, - gboolean use_deinterlace) -{ - GstElement *vbin = NULL; - GstElement *vqueue = NULL; - GstElement *vqueue_src = NULL; - GstElement *vcolorspace = NULL; - GstElement *vencode = NULL; - GstElement *vrate = NULL; - GstElement *deinterlace = NULL; - GstElement *walk = NULL; - GstPad *vpad = NULL; - - vbin = gst_bin_new("vbin"); - vqueue = gst_element_factory_make("queue", "vqueue"); - vcolorspace = - gst_element_factory_make("ffmpegcolorspace", "colorspace"); - - if (use_deinterlace) { - deinterlace = gst_element_factory_make ("ffdeinterlace", "deinterlace"); - if (deinterlace == NULL) { - g_warning ("Fail to create deinterlace element: Continue without deinterlace."); - } - } - - - vencode = _create_element_with_prop((encode != - NULL ? encode : - "ffenc_mpeg1video"), "vencode", - encode_prop); - vqueue_src = gst_element_factory_make("queue", "queue_src"); - - if ((vbin == NULL) || (vqueue == NULL) || (vcolorspace == NULL) - || (vencode == NULL) || (vqueue_src == NULL)) { - g_warning("Video elements not found"); - goto error; - } - - gst_bin_add_many(GST_BIN(vbin), vqueue, vcolorspace, vencode, - vqueue_src, NULL); - - if (deinterlace != NULL) { - gst_bin_add(GST_BIN(vbin), deinterlace); - gst_element_link (vqueue, deinterlace); - walk = deinterlace; - } else { - walk = vqueue; - } - - if ((width > 0) && (height > 0)) { - // Scalling video - GstCaps *vcaps; - GstElement *vscale = - gst_element_factory_make("videoscale", "vscale"); - - g_object_set (G_OBJECT (vscale), "method", 1, NULL); - - gst_bin_add(GST_BIN(vbin), vscale); - - vcaps = gst_caps_new_simple("video/x-raw-yuv", - "width", G_TYPE_INT, width, - "height", G_TYPE_INT, height, NULL); - - gst_element_link(walk, vscale); - - if (gst_element_link_filtered(vscale, vcolorspace, vcaps) == FALSE) { - g_warning("Fail to resize video"); - gst_object_unref(vcaps); - gst_object_unref(vscale); - goto error; - } - gst_caps_unref(vcaps); - } else { - gst_element_link(walk, vcolorspace); - } - - if (fps > 0) { - // Changing the video fps - GstCaps *vcaps; - vrate = gst_element_factory_make("videorate", "vrate"); - - gst_bin_add(GST_BIN(vbin), vrate); - - if (gst_element_link(vcolorspace, vrate) == FALSE) { - g_warning("Fail to link video elements"); - goto error; - } - - vcaps = gst_caps_new_simple("video/x-raw-yuv", - "framerate", GST_TYPE_FRACTION, - (int) (fps * 1000), 1000, NULL); - - if (gst_element_link_filtered(vrate, vencode, vcaps) == FALSE) { - g_warning("Fail to link vrate with vencode."); - goto error; - } - gst_caps_unref(vcaps); - } else { - if (gst_element_link(vcolorspace, vencode) == FALSE) { - g_warning("Fail to link colorspace and video encode element."); - goto error; - } - } - - gst_element_link(vencode, vqueue_src); - - // ghost pad the video bin - vpad = gst_element_get_pad(vqueue, "sink"); - gst_element_add_pad(vbin, gst_ghost_pad_new("sink", vpad)); - gst_object_unref(vpad); - - vpad = gst_element_get_pad(vqueue_src, "src"); - gst_element_add_pad(vbin, gst_ghost_pad_new("src", vpad)); - gst_object_unref(vpad); - - return vbin; - - error: - if (vpad != NULL) - gst_object_unref(vpad); - - if (vbin != NULL) - gst_object_unref(vbin); - - if (vqueue != NULL) - gst_object_unref(vqueue); - - if (vencode != NULL) - gst_object_unref(vencode); - - if (vqueue_src != NULL) - gst_object_unref(vqueue_src); - - if (vcolorspace != NULL) - gst_object_unref(vcolorspace); - - return NULL; -} - - - -gboolean -g_mencoder_setup_stream(GMencoder * self, - gboolean chunked, - gboolean deinterlace, - const gchar * mux_name, - const gchar * video_encode, - gchar ** video_encode_prop, - gdouble video_fps, - gdouble video_rate, - guint video_width, - guint video_height, - const gchar * audio_encode, - gchar ** audio_encode_prop, - guint audio_rate, const gchar * out_uri) -{ - GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(self); - if (priv->ready == TRUE) { - g_warning - ("Stream already configured. You need close stream first."); - return FALSE; - } - - _close_output(self); - if (_open_output(self, out_uri) == FALSE) { - return FALSE; - } - - priv->sources = 0; - priv->send_chunked = chunked; - priv->pipe = _create_pipeline(self, - video_encode, - mux_name, - video_encode_prop, - video_fps, - video_rate, - video_width, - video_height, - audio_encode, audio_encode_prop, - audio_rate, - deinterlace); - - return (priv->pipe != NULL); -} - - -gboolean -g_mencoder_append_uri(GMencoder * self, const gchar * uri) -{ - GstPad *pad_src; - GstPad *pad_sink; - GstElement *src; - GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(self); - gboolean ret = FALSE; - GstElement *ap = NULL; - GstElement *vp = NULL; - - - g_return_val_if_fail(priv->pipe != NULL, FALSE); - g_return_val_if_fail(priv->ready == FALSE, FALSE); - - src = _create_source(self, uri); - if (src == NULL) - return FALSE; - - priv->src = gst_bin_get_by_name(GST_BIN(src), "src"); - - gst_bin_add(GST_BIN(priv->pipe), src); - - ap = gst_bin_get_by_name(GST_BIN(priv->pipe), "abin"); - vp = gst_bin_get_by_name(GST_BIN(priv->pipe), "vbin"); - - if ((vp == NULL) || (ap == NULL)) { - g_warning("Fail to get output bin"); - goto error; - } - - pad_src = gst_element_get_pad(src, "src_audio"); - pad_sink = gst_element_get_compatible_pad(ap, - pad_src, - gst_pad_get_caps(pad_src)); - - if ((pad_sink == NULL) || (pad_src == NULL)) - goto error; - - GstPadLinkReturn lret = gst_pad_link(pad_src, pad_sink); - if (lret != GST_PAD_LINK_OK) - goto error; - - gst_object_unref(pad_src); - gst_object_unref(pad_sink); - - pad_src = gst_element_get_pad(src, "src_video"); - pad_sink = gst_element_get_compatible_pad(vp, - pad_src, - gst_pad_get_caps(pad_src)); - - if ((pad_src == NULL) || (pad_sink == NULL)) - goto error; - - if (gst_pad_link(pad_src, pad_sink) != GST_PAD_LINK_OK) { - g_warning("invalid source. video"); - goto error; - } - - priv->sources++; - ret = TRUE; - error: - - if ((src != NULL) && (ret == FALSE)) { - gst_bin_remove(GST_BIN(priv->pipe), src); - gst_object_unref(src); - } - - if (ap != NULL) - gst_object_unref(ap); - - if (vp != NULL) - gst_object_unref(vp); - - if (pad_src != NULL) - gst_object_unref(pad_src); - - if (pad_sink != NULL) - gst_object_unref(pad_sink); - - return ret; -} - - - -void -g_mencoder_remove_uri(GMencoder * self, const gchar * uri) -{ - // GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE (self); - // TODO: remove src -} - -void -g_mencoder_play_stream(GMencoder * self) -{ - GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(self); - g_return_if_fail(priv->ready == FALSE); - priv->ready = TRUE; - gst_element_set_state(priv->pipe, GST_STATE_PLAYING); - if (priv->tick_id != 0) { - g_source_remove (priv->tick_id); - } - priv->tick_id = g_timeout_add(500, _tick_cb, self); - - if (priv->timeout_id != 0) { - g_source_remove (priv->timeout_id); - } - //priv->timeout_id = g_timeout_add(GMENCODER_TIMEOUT, _process_timeout_cb, self); -} - -void -g_mencoder_pause_stream(GMencoder * self) -{ - GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(self); - g_return_if_fail(priv->ready == TRUE); - gst_element_set_state(priv->pipe, GST_STATE_PAUSED); -} - -void -g_mencoder_close_stream(GMencoder * self) -{ - - GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(self); - if (priv->tick_id != 0) { - g_source_remove(priv->tick_id); - priv->tick_id = 0; - } - - if (priv->timeout_id != 0) { - g_source_remove (priv->timeout_id); - priv->timeout_id = 0; - } - - if (priv->pipe != NULL) { - // TODO: fixe pipeline dispose - //gst_element_set_state (priv->pipe, GST_STATE_NULL); - // g_debug ("SETING STATE TO NULL: OK"); - // gst_element_set_state (priv->pipe, GST_STATE_NULL); - //gst_object_unref (priv->pipe); - //gst_object_unref(priv->src); - priv->src = NULL; - priv->pipe = NULL; - priv->abin = NULL; - priv->vbin = NULL; - priv->sink = NULL; - } - priv->ready = FALSE; -} - -static GstElement * -_create_pipeline(GMencoder * self, - const gchar * video_encode, - const gchar * mux_name, - gchar ** video_encode_prop, - gdouble video_fps, - gdouble video_rate, - guint video_width, - guint video_height, - const gchar * audio_encode, - gchar ** audio_encode_prop, guint audio_rate, - gboolean deinterlace) -{ - GstBus *bus = NULL; - GstElement *pipe = NULL; - GstElement *sink = NULL; - GstElement *mux = NULL; - GstElement *abin = NULL; - GstElement *vbin = NULL; - GstElement *queue = NULL; - GstPad *aux_pad = NULL; - GstPad *mux_pad = NULL; - - pipe = gst_pipeline_new("pipe"); - - mux = - gst_element_factory_make((mux_name ? mux_name : "ffmux_mpeg"), - "mux"); - if (mux == NULL) - goto error; - - queue = gst_element_factory_make("queue", "queueu_sink"); - - - sink = gst_element_factory_make("fakesink", "sink"); - g_object_set (G_OBJECT (sink), "signal-handoffs", TRUE, NULL); - g_signal_connect (G_OBJECT (sink), - "handoff", - G_CALLBACK (_buffer_arrive_cb), - self); - - abin = _create_audio_bin(audio_encode, audio_encode_prop, audio_rate); - if (abin == NULL) - goto error; - - vbin = - _create_video_bin(video_encode, video_encode_prop, video_fps, - video_rate, video_width, video_height, deinterlace); - if (vbin == NULL) - goto error; - - // Finish Pipe - gst_bin_add_many(GST_BIN(pipe), abin, vbin, mux, queue, sink, NULL); - - - // Link bins with mux - aux_pad = gst_element_get_pad(abin, "src"); - mux_pad = - gst_element_get_compatible_pad(mux, aux_pad, - GST_PAD_CAPS(aux_pad)); - if (mux_pad == NULL) { - g_warning("Mux element no have audio PAD"); - goto error; - } - GstPadLinkReturn ret = gst_pad_link(aux_pad, mux_pad); - if (ret != GST_PAD_LINK_OK) { - g_warning("Fail link audio and mux: %d", ret); - goto error; - - } - gst_object_unref(aux_pad); - gst_object_unref(mux_pad); - - aux_pad = gst_element_get_pad(vbin, "src"); - mux_pad = - gst_element_get_compatible_pad(mux, aux_pad, - GST_PAD_CAPS(aux_pad)); - if (mux_pad == NULL) { - g_warning("Mux element no have video PAD"); - goto error; - } - ret = gst_pad_link(aux_pad, mux_pad); - if (ret != GST_PAD_LINK_OK) { - g_warning("Fail link video and mux: %d", ret); - goto error; - } - gst_object_unref(aux_pad); - gst_object_unref(mux_pad); - aux_pad = NULL; - mux_pad = NULL; - - // Link mux with sink - gst_element_link_many(mux, queue, sink, NULL); - - bus = gst_pipeline_get_bus(GST_PIPELINE(pipe)); - gst_bus_add_watch(bus, _pipeline_bus_cb, self); - gst_object_unref(bus); - return pipe; - - error: - g_warning("Invalid uri"); - - if (pipe != NULL) { - gst_object_unref(pipe); - } - - - if (mux != NULL) { - gst_object_unref(mux); - } - - if (mux_pad != NULL) { - gst_object_unref(mux_pad); - } - - if (aux_pad != NULL) { - gst_object_unref(mux_pad); - } - - if (sink != NULL) { - gst_object_unref(sink); - } - - if (abin != NULL) { - gst_object_unref(abin); - } - - if (vbin != NULL) { - gst_object_unref(vbin); - } - - return FALSE; -} - - -static void -_close_output(GMencoder * self) -{ -} - -static GstElement * -_create_v4l_source (GMencoder *self, const gchar * uri) -{ - gchar **info; - GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(self); - - - info = g_strsplit (uri+6, ":", 3); - if (g_strv_length (info) != 3) { - return NULL; - } - - priv->v4lsrc = gst_element_factory_make ("v4l2src", "src"); - g_debug ("channel %s, norm %s, frequ %s", info[0], info[1], info[2]); - g_object_set (G_OBJECT (priv->v4lsrc), - "channel", info[0], - "norm", info[1], - "frequency", atoi (info[2]), - NULL); - - return priv->v4lsrc; -} - -static GstElement * -_create_source(GMencoder *self, const gchar * uri) -{ - - GstElement *bsrc = NULL; - GstElement *src = NULL; - GstElement *aqueue = NULL; - GstElement *vqueue = NULL; - GstElement *decode = NULL; - GstPad *src_pad = NULL; - - - bsrc = gst_bin_new(NULL); - - // src = gst_element_factory_make ("gnomevfssrc", "src"); - // g_object_set (G_OBJECT (src), "location", uri, NULL); - if (strncmp (uri, "v4l://", 6) == 0) { - g_debug ("V4L"); - src = _create_v4l_source (self, uri); - } - else { - src = gst_element_make_from_uri(GST_URI_SRC, uri, "src"); - } - - if (src == NULL) - goto error; - - decode = gst_element_factory_make("decodebin2", "decode"); - if (decode == NULL) - goto error; - - aqueue = gst_element_factory_make("queue", "aqueue"); - if (aqueue == NULL) - goto error; - - vqueue = gst_element_factory_make("queue", "vqueue"); - if (vqueue == NULL) - goto error; - - gst_bin_add_many(GST_BIN(bsrc), src, decode, aqueue, vqueue, - NULL); - gst_element_link (src, decode); - - g_signal_connect(G_OBJECT(decode), - "new-decoded-pad", - G_CALLBACK(_decodebin_new_pad_cb), bsrc); - - g_signal_connect(G_OBJECT(decode), - "unknown-type", - G_CALLBACK(_decodebin_unknown_type_cb), pipe); - - src_pad = gst_element_get_pad(aqueue, "src"); - gst_element_add_pad(bsrc, gst_ghost_pad_new("src_audio", src_pad)); - gst_object_unref(src_pad); - - src_pad = gst_element_get_pad(vqueue, "src"); - gst_element_add_pad(bsrc, gst_ghost_pad_new("src_video", src_pad)); - gst_object_unref(src_pad); - - return bsrc; - - error: - g_debug ("Fail to create source element"); - if (src != NULL) { - gst_object_unref(src); - } - - if (decode != NULL) { - gst_object_unref(decode); - } - - if (aqueue != NULL) { - gst_object_unref(aqueue); - } - - if (vqueue != NULL) { - gst_object_unref(vqueue); - } - - return NULL; -} - -static gboolean -_open_output(GMencoder * self, const gchar * uri) -{ - gchar **i; - GnomeVFSResult result; - GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(self); - - i = g_strsplit(uri, "://", 0); - if (strcmp(i[0], "fd") == 0) { - result = gnome_vfs_open_fd (&priv->handle, atoi(i[1])); - } else { - if (g_file_test (i[1], G_FILE_TEST_EXISTS) == FALSE) { - result = gnome_vfs_create (&priv->handle, uri, GNOME_VFS_OPEN_WRITE, FALSE, - GNOME_VFS_PERM_USER_WRITE | GNOME_VFS_PERM_USER_READ | GNOME_VFS_PERM_GROUP_READ); - } else { - result = gnome_vfs_open (&priv->handle, uri, - GNOME_VFS_OPEN_WRITE | GNOME_VFS_OPEN_TRUNCATE); - } - } - - g_strfreev(i); - return (result == GNOME_VFS_OK); -} - -static gboolean -_pipeline_bus_cb(GstBus * bus, GstMessage * msg, gpointer user_data) -{ - GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(user_data); - - switch (GST_MESSAGE_TYPE(msg)) { - - case GST_MESSAGE_STATE_CHANGED: - { - GstState oldstate; - GstState newstate; - GstState pendingstate; - - - gst_message_parse_state_changed(msg, &oldstate, - &newstate, &pendingstate); - - if (pendingstate != GST_STATE_VOID_PENDING) - break; - - if ((oldstate == GST_STATE_READY) - && (newstate == GST_STATE_PAUSED)) { - if (priv->ready) - g_signal_emit(user_data, g_mencoder_signals[PAUSED], - 0); - } else if ((oldstate == GST_STATE_PAUSED) - && (newstate == GST_STATE_PLAYING)) { - g_signal_emit(user_data, g_mencoder_signals[PLAYING], 0); - } else if ((oldstate == GST_STATE_READY) && - (newstate == GST_STATE_NULL)) { - g_signal_emit(user_data, g_mencoder_signals[STOPED], 0); - } - break; - } - - case GST_MESSAGE_ERROR: - { - GError *error; - gchar *debug; - gchar *err_str; - - if (priv->tick_id != 0) { - g_source_remove(priv->tick_id); - priv->tick_id = 0; - } - - gst_message_parse_error(msg, &error, &debug); - err_str = g_strdup_printf("Error [%d] %s (%s)", error->code, - error->message, debug); - priv->ready = FALSE; - g_signal_emit(user_data, g_mencoder_signals[ERROR], 0, - err_str); - g_free(err_str); - g_clear_error(&error); - g_free(debug); - break; - } - - case GST_MESSAGE_EOS: - priv->ready = FALSE; -#ifdef USE_MANUAL_SINK - _flush_queue (G_MENCODER (user_data)); -#endif - g_signal_emit(user_data, g_mencoder_signals[EOS], 0); - break; - - case GST_MESSAGE_DURATION: - { - GstFormat format; - gint64 duration; - gst_message_parse_duration(msg, &format, &duration); - if (format == GST_FORMAT_BYTES) - priv->duration = duration; - break; - } - default: - { - break; - } - } - return TRUE; -} - - - -static void -_decodebin_new_pad_cb(GstElement * object, - GstPad * pad, gboolean flag, gpointer user_data) -{ - GstCaps *caps; - gchar *str_caps = NULL; - GstElement *sink_element; - GstPad *sink_pad; - - caps = gst_pad_get_caps(pad); - str_caps = gst_caps_to_string(caps); - if (strstr(str_caps, "audio") != NULL) { - sink_element = gst_bin_get_by_name(GST_BIN(user_data), "aqueue"); - } else if (strstr(str_caps, "video") != NULL) { - sink_element = gst_bin_get_by_name(GST_BIN(user_data), "vqueue"); - } else { - g_warning("invalid caps %s", str_caps); - } - - sink_pad = gst_element_get_pad(sink_element, "sink"); - gst_pad_link(pad, sink_pad); - - gst_object_unref(sink_element); - gst_object_unref(sink_pad); - g_free(str_caps); - gst_caps_unref(caps); -} - -static void -_decodebin_unknown_type_cb(GstElement * object, - GstPad * pad, GstCaps * caps, - gpointer user_data) -{ - g_warning("Unknown Type"); - // priv->ready = FALSE; -} - -static gboolean -_tick_cb(gpointer user_data) -{ - GstFormat format = GST_FORMAT_BYTES; - gint64 cur = 0; - - GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(user_data); - - if (priv->duration == 0) { - gint64 d = 0; - if (gst_element_query_duration(priv->src, &format, &d)) - priv->duration = d; - } - - if (priv->duration != 0) { - gst_element_query_position(priv->src, &format, &cur); - g_print("PROGRESS:%lli\n", (99 * cur) / priv->duration); - } - - return TRUE; -} - -static gboolean -_process_timeout_cb (gpointer user_data) -{ - GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(user_data); - - g_signal_emit(user_data, g_mencoder_signals[ERROR], 0, "timeout"); - priv->timeout_id = 0; - return FALSE; -} - - -#ifdef USE_MANUAL_SINK -static gboolean -_send_buffer (GnomeVFSHandle *handle, gpointer buff, gint size) -{ - gchar *msg; - GByteArray *b_send; - GnomeVFSResult result; - GnomeVFSFileSize bytes_written; - - b_send = g_byte_array_new (); - msg = g_strdup_printf ("%x\r\n", size); - b_send = g_byte_array_append (b_send, (const guint8*) msg, strlen (msg) * sizeof (gchar)); - g_free (msg); - - b_send = g_byte_array_append (b_send, buff, size); - - msg = g_strdup ("\r\n"); - b_send = g_byte_array_append (b_send, (const guint8*) msg, strlen (msg) * sizeof (gchar)); - g_free (msg); - - result = gnome_vfs_write (handle, b_send->data, b_send->len, &bytes_written); - g_byte_array_free (b_send, TRUE); - - return (result == GNOME_VFS_OK); -} - -static void -_flush_queue (GMencoder *self) -{ - GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(self); - - if (priv->send_chunked) { - GnomeVFSFileSize bytes_written; - gchar *end_msg; - end_msg = g_strdup ("0\r\n\r\n"); - gnome_vfs_write (priv->handle, - (const guint8*) end_msg, - strlen(end_msg) * sizeof(gchar), - &bytes_written); - g_free (end_msg); - } -} - -static void -_buffer_arrive_cb (GstElement* object, - GstBuffer* buff, - GstPad* pad, - gpointer user_data) -{ - GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(user_data); - - if (priv->timeout_id != 0) { - g_source_remove (priv->timeout_id); - priv->timeout_id = 0; - } - - if (priv->send_chunked) { - if (_send_buffer (priv->handle, GST_BUFFER_DATA (buff), GST_BUFFER_SIZE (buff)) == FALSE) - goto error; - } else { - GnomeVFSResult result; - GnomeVFSFileSize bytes_written; - - result = gnome_vfs_write (priv->handle, - GST_BUFFER_DATA (buff), - GST_BUFFER_SIZE (buff), - &bytes_written); - - if (result != GNOME_VFS_OK) - goto error; - } - - return; - -error: - if (priv->tick_id != 0) { - g_source_remove(priv->tick_id); - priv->tick_id = 0; - } - g_signal_emit(user_data, g_mencoder_signals[ERROR], 0, "Fail to write on socket"); - gst_element_set_state (priv->pipe, GST_STATE_PAUSED); -} - -#endif diff -r 5d027884a9d3 -r 3c18c36245e7 gmyth-stream/gmemcoder/src/gmencoder.h --- a/gmyth-stream/gmemcoder/src/gmencoder.h Tue Sep 18 13:45:04 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,61 +0,0 @@ -#ifndef __G_MENCODER_H__ -#define __G_MENCODER_H__ - -#include - -G_BEGIN_DECLS typedef struct _GMencoder GMencoder; -typedef struct _GMencoderClass GMencoderClass; - -struct _GMencoderClass { - GObjectClass parent_class; -}; - -struct _GMencoder { - GObject parent; -}; - -/* - * TYPE MACROS - */ -#define G_TYPE_MENCODER \ - (g_mencoder_get_type()) -#define G_MENCODER(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_MENCODER, GMencoder)) -#define G_MENCODER_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_MENCODER, GMencoderClass)) -#define G_IS_MENCODER(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_MENCODER)) -#define G_IS_MENCODER_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_MENCODER)) -#define G_MENCODER_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), G_TYPE_MENCODER, GMencoderClass)) - - -GType g_mencoder_get_type(void); -GMencoder *g_mencoder_new(void); - -gboolean g_mencoder_setup_stream(GMencoder * self, - gboolean chunked, - gboolean deinterlace, - const gchar * mux_name, - const gchar * video_encode, - gchar ** video_encode_prop, - gdouble video_fps, - gdouble video_rate, - guint video_width, - guint video_height, - const gchar * audio_encode, - gchar ** audio_encode_prop, - guint audio_rate, - const gchar * output_uri); - -gboolean g_mencoder_append_uri(GMencoder * self, const gchar * uri); - -void g_mencoder_remove_uri(GMencoder * self, const gchar * uri); - -void g_mencoder_play_stream(GMencoder * self); -void g_mencoder_pause_stream(GMencoder * self); -void g_mencoder_close_stream(GMencoder * self); - -G_END_DECLS -#endif diff -r 5d027884a9d3 -r 3c18c36245e7 gmyth-stream/gmemcoder/src/main.c --- a/gmyth-stream/gmemcoder/src/main.c Tue Sep 18 13:45:04 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,207 +0,0 @@ -#include -#include -#include -#include - -#include -#include -#include - -#include "gmencoder.h" - -#define FILE_OUT 1 - -static GMainLoop *mainloop = NULL; -/* - * Options - */ -static gchar *input_file = NULL; -static gchar *video_encode = NULL; -static gchar *video_opts = NULL; -static gdouble video_fps = 0.0; -static gint video_rate = 0; -static gint video_width = 0; -static gint video_height = 0; -static gchar *audio_encode = NULL; -static gchar *audio_opts = NULL; -static double audio_rate = 0.0; -static gchar *mux_name = NULL; -static gchar *output_uri = NULL; -static gboolean chunked = FALSE; -static gboolean deinterlace = FALSE; - - - -static gboolean -_quit(gpointer data) -{ - //g_object_unref(data); - g_main_loop_quit(mainloop); - return FALSE; -} - -static void -_mencoder_eos_cb(GMencoder * mencoder, gpointer data) -{ - g_print("PROGRESS: 100\n"); - g_idle_add(_quit, mencoder); -} - - -static void -_mencoder_error_cb(GMencoder * mencoder, const gchar * msg, gpointer data) -{ - g_print("Error: %s\n", msg); - g_idle_add(_quit, mencoder); -} - -static gboolean -_io_channel_cb(GIOChannel * ch, GIOCondition condition, gpointer data) -{ - GString *cmd = g_string_new(""); - g_io_channel_read_line_string(ch, cmd, NULL, NULL); - - if (strcmp(cmd->str, "PLAY\n") == 0) { - g_mencoder_play_stream(G_MENCODER(data)); - } else if (strcmp(cmd->str, "PAUSE\n") == 0) { - g_mencoder_pause_stream(G_MENCODER(data)); - } else if (strcmp(cmd->str, "STOP\n") == 0) { - g_mencoder_close_stream(G_MENCODER(data)); - } else if (strcmp(cmd->str, "QUIT\n") == 0) { - g_mencoder_close_stream(G_MENCODER(data)); - g_main_loop_quit(mainloop); - } - g_string_free(cmd, TRUE); - return TRUE; -} - -int -main(int argc, char **argv) -{ - GMencoder *coder = NULL; - GIOChannel *ch; - gchar **vopts; - gchar **aopts; - gchar **files; - gint i; - gboolean ret; - - GOptionContext *context; - static const GOptionEntry options[] = { - {"input-files", 'i', 0, G_OPTION_ARG_STRING, &input_file, - "Input File", NULL}, - - {"video-encode", 0, 0, G_OPTION_ARG_STRING, &video_encode, - "GstElementName for used to video encode", NULL}, - - {"video-opts", 0, 0, G_OPTION_ARG_STRING, &video_opts, - "Properties to set on video element", NULL}, - - {"video-fps", 0, 0, G_OPTION_ARG_DOUBLE, &video_fps, - "Video FPS", NULL}, - - {"video-rate", 0, 0, G_OPTION_ARG_INT, &video_rate, - "Video rate", NULL}, - - {"video-width", 0, 0, G_OPTION_ARG_INT, &video_width, - "Video width", NULL}, - - {"video-height", 0, 0, G_OPTION_ARG_INT, &video_height, - "Video height", NULL}, - - {"audio-encode", 0, 0, G_OPTION_ARG_STRING, &audio_encode, - "GstElementName for use to audio encode", NULL}, - - {"audio-opts", 0, 0, G_OPTION_ARG_STRING, &audio_opts, - "Properties to set on audio element", NULL}, - - {"audio-rate", 0, 0, G_OPTION_ARG_INT, &audio_rate, - "Audio rate", NULL}, - - {"mux-element", 0, 0, G_OPTION_ARG_STRING, &mux_name, - "GstElementName for use to mux file", NULL}, - - {"output-uri", 'o', 0, G_OPTION_ARG_STRING, &output_uri, - "Uri to output", NULL}, - - {"chunked", 'c', 0, G_OPTION_ARG_NONE, &chunked, - "Send package chunked", NULL}, - - {"deinterlace", 'd', 0, G_OPTION_ARG_NONE, &deinterlace, - "Use to deinterlace videos", NULL}, - - - {NULL} - }; - - g_type_init(); - g_thread_init(NULL); - gnome_vfs_init (); - mainloop = g_main_loop_new(NULL, FALSE); - - g_set_prgname("gmemcoder"); - context = g_option_context_new(NULL); - g_option_context_set_help_enabled(context, TRUE); - g_option_context_add_main_entries(context, options, NULL); - g_option_context_add_group(context, gst_init_get_option_group()); - g_option_context_parse(context, &argc, &argv, NULL); - - gst_init(&argc, &argv); - - if (output_uri == NULL) { - g_print("You need to specify output-uri.\nTry --help " - "for more information.\n"); - return 1; - } - - if (input_file == NULL) { - g_print("You need to specify input file\nTry --help " - "for more information.\n"); - } - - coder = g_mencoder_new(); - ch = g_io_channel_unix_new(0); - - if (audio_opts != NULL) - aopts = g_strsplit(audio_opts, ",", 0); - else - aopts = NULL; - - if (video_opts != NULL) - vopts = g_strsplit(video_opts, ",", 0); - else - vopts = NULL; - - ret = g_mencoder_setup_stream(coder, chunked, deinterlace, mux_name, - video_encode, vopts, video_fps, - video_rate, video_width, video_height, - audio_encode, aopts, audio_rate, output_uri); - - if (ret == TRUE) { - files = g_strsplit(input_file, ",", 0); - for (i = 0; i < g_strv_length(files); i++) { - if (!g_mencoder_append_uri(coder, files[i])) { - g_debug("Invalid uri: %s", files[i]); - } - } - g_strfreev(files); - } - - g_strfreev(aopts); - g_strfreev(vopts); - - if (ret == TRUE) { - g_io_add_watch(ch, G_IO_IN, _io_channel_cb, coder); - g_signal_connect(G_OBJECT(coder), - "eos", G_CALLBACK(_mencoder_eos_cb), mainloop); - - g_signal_connect(G_OBJECT(coder), - "error", G_CALLBACK(_mencoder_error_cb), mainloop); - - g_mencoder_play_stream(coder); - g_main_loop_run(mainloop); - } - - g_object_unref(coder); - return 0; -} diff -r 5d027884a9d3 -r 3c18c36245e7 gmyth-stream/gmemcoder/tests/Makefile.am --- a/gmyth-stream/gmemcoder/tests/Makefile.am Tue Sep 18 13:45:04 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,15 +0,0 @@ -bin_PROGRAMS = \ - gnl-test - -gnl_test_SOURCES = \ - main.c - -gnl_test_LDADD = \ - $(GLIB_LIBS) \ - $(GST_LIBS) - -AM_CPPFLAGS = \ - $(GLIB_CFLAGS) \ - $(GST_CFLAGS) - -CLEANFILES = diff -r 5d027884a9d3 -r 3c18c36245e7 gmyth-stream/gmemcoder/tests/main.c --- a/gmyth-stream/gmemcoder/tests/main.c Tue Sep 18 13:45:04 2007 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,230 +0,0 @@ -#include -#include -#include -#include - -#include -#include - - -static GMainLoop *mainloop = NULL; -static gint64 d = 0; -static gint64 gap = 10; - -typedef enum { - MY_STREAM_TYPE_AUDIO = 0, - MY_STREAM_TYPE_VIDEO = 1 -} MyStreamType; - -typedef struct _StreamData StreamData; -struct _StreamData { - GstElement *bin; - MyStreamType type; -}; - -static void -_stream_decode_pad_added_cb(GstElement * decode, - GstPad * pad, gboolean arg1, - gpointer user_data) -{ - StreamData *data = (StreamData *) user_data; - GstElement *queue; - GstPad *sink_pad; - GstCaps *caps = gst_pad_get_caps(pad); - gchar *str_caps = gst_caps_to_string(caps); - - g_debug("decode caps: [%d] [%s]", data->type, str_caps); - - switch (data->type) { - case MY_STREAM_TYPE_AUDIO: - g_debug("Audio"); - if (strstr(str_caps, "audio") == NULL) - goto done; - break; - case MY_STREAM_TYPE_VIDEO: - g_debug("Video"); - if (strstr(str_caps, "video") == NULL) - goto done; - break; - } - - queue = gst_bin_get_by_name(GST_BIN(data->bin), "queue"); - sink_pad = gst_element_get_pad(queue, "sink"); - - if (gst_pad_link(pad, sink_pad) != GST_PAD_LINK_OK) { - g_warning("Failed to link decode"); - } - - gst_object_unref(queue); - gst_object_unref(sink_pad); - // g_free (data); - g_debug("Linked"); - - done: - gst_caps_unref(caps); - g_free(str_caps); -} - - -static GstElement * -_create_src_element(const gchar * name, - const gchar * uri, MyStreamType type, guint priority) -{ - StreamData *data; - GstElement *bin; - GstElement *src; - GstElement *decode; - GstElement *queue; - GstPad *src_pad; - - GstElement *gnl_src; - - g_debug("element from uri: %s", uri); - - bin = gst_bin_new("bin"); - src = gst_element_make_from_uri(GST_URI_SRC, uri, "src"); - g_return_val_if_fail(src != NULL, NULL); - - decode = gst_element_factory_make("decodebin", NULL); - g_return_val_if_fail(decode != NULL, NULL); - - queue = gst_element_factory_make("queue", "queue"); - g_return_val_if_fail(queue != NULL, NULL); - - gst_bin_add_many(GST_BIN(bin), src, decode, queue, NULL); - gst_element_link(src, decode); - - data = g_new0(StreamData, 1); - data->bin = bin; - data->type = type; - g_debug("Type : %d = %d", type, data->type); - - g_signal_connect(G_OBJECT(decode), "new-decoded-pad", - G_CALLBACK(_stream_decode_pad_added_cb), data); - - - src_pad = gst_element_get_pad(queue, "src"); - g_return_val_if_fail(src_pad != NULL, NULL); - - gst_element_add_pad(bin, gst_ghost_pad_new("src", src_pad)); - - gst_object_unref(src_pad); - - gnl_src = gst_element_factory_make("gnlsource", name); - g_return_val_if_fail(gnl_src != NULL, NULL); - gst_bin_add(GST_BIN(gnl_src), bin); - - g_debug("ADDING WITH: START [%lli] DUR [%lli]", d, gap); - if (d == 0) { - g_object_set(G_OBJECT(gnl_src), - // "start", 0L, - "duration", 10 * GST_SECOND, - // "media-start", 0L, - // "media-duration", 10 * GST_SECOND, - "priority", priority, NULL); - - } else { - g_object_set(G_OBJECT(gnl_src), - "start", 10 * GST_SECOND, "duration", 10 * GST_SECOND, - // /"media-start", 10 * GST_SECOND, - // "media-duration", 10 * GST_SECOND, - "priority", priority, NULL); - - } - d++; - - return gnl_src; -} - -static void -_composition_pad_added_cb(GstElement * composition, - GstPad * pad, gpointer data) -{ - GstPad *sink_pad = - gst_element_get_pad(GST_ELEMENT(data), "sink"); - g_debug("compose pad added"); - - if (gst_pad_link(pad, sink_pad) != GST_PAD_LINK_OK) { - g_warning("Failed to link decode"); - } - - g_debug("Linked ok"); -} - -static void -_compose_add_file(GstElement * compose, - const gchar * e_name, - const gchar * uri, MyStreamType type, guint priority) -{ - GstElement *src; - - src = _create_src_element(e_name, uri, type, priority); - gst_bin_add(GST_BIN(compose), src); -} - - -int -main(int argc, char **argv) -{ - GstElement *pipe; - GstElement *gnl_compose_a; - GstElement *gnl_compose_v; - GstElement *asink; - GstElement *vsink; - GstElement *aqueue; - GstElement *vqueue; - - g_type_init(); - gst_init(&argc, &argv); - - mainloop = g_main_loop_new(NULL, FALSE); - - pipe = gst_pipeline_new("test_pipeline"); - - gnl_compose_a = gst_element_factory_make("gnlcomposition", "acompose"); - g_return_val_if_fail(gnl_compose_a != NULL, 1); - - gnl_compose_v = gst_element_factory_make("gnlcomposition", "vcompose"); - g_return_val_if_fail(gnl_compose_v != NULL, 1); - - - // _compose_add_file (gnl_compose_a, "src0", argv[1], - // MY_STREAM_TYPE_AUDIO, 1); - // _compose_add_file (gnl_compose_a, "src1", argv[2], - // MY_STREAM_TYPE_AUDIO, 1); - - d = 0; - - _compose_add_file(gnl_compose_v, "src2", argv[1], MY_STREAM_TYPE_VIDEO, - 1); - _compose_add_file(gnl_compose_v, "src3", argv[2], MY_STREAM_TYPE_VIDEO, - 1); - - - // aqueue = gst_element_factory_make ("queue", "aqueue"); - // asink = gst_element_factory_make ("alsasink", "asink"); - - vqueue = gst_element_factory_make("queue", "vqueue"); - vsink = gst_element_factory_make("xvimagesink", "vsink"); - - gst_bin_add_many(GST_BIN(pipe), gnl_compose_a, gnl_compose_v, vqueue, - vsink, - // aqueue, asink, - NULL); - - gst_element_link(vqueue, vsink); - // gst_element_link (aqueue, asink); - - // g_signal_connect (G_OBJECT (gnl_compose_a), "pad-added", - // G_CALLBACK (_composition_pad_added_cb), aqueue); - - g_signal_connect(G_OBJECT(gnl_compose_v), "pad-added", - G_CALLBACK(_composition_pad_added_cb), vqueue); - - - // g_idle_add (_play, pipe); - gst_element_set_state(GST_ELEMENT(pipe), GST_STATE_PLAYING); - g_main_loop_run(mainloop); - - return 0; -} diff -r 5d027884a9d3 -r 3c18c36245e7 gmyth-stream/gmencoder/INSTALL --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gmyth-stream/gmencoder/INSTALL Tue Sep 18 13:45:36 2007 +0100 @@ -0,0 +1,236 @@ +Installation Instructions +************************* + +Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005 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' installs the package's commands under +`/usr/local/bin', include files under `/usr/local/include', etc. You +can specify an installation prefix other than `/usr/local' by giving +`configure' the option `--prefix=PREFIX'. + + You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If you +pass the option `--exec-prefix=PREFIX' to `configure', the package uses +PREFIX as the prefix for installing programs and libraries. +Documentation and other data files still use the regular prefix. + + In addition, if you use an unusual directory layout you can give +options like `--bindir=DIR' to specify different values for particular +kinds of files. Run `configure --help' for a list of the directories +you can set and what kinds of files go in them. + + If the package supports it, you can cause programs to be installed +with an extra prefix or suffix on their names by giving `configure' the +option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. + +Optional Features +================= + +Some packages pay attention to `--enable-FEATURE' options to +`configure', where FEATURE indicates an optional part of the package. +They may also pay attention to `--with-PACKAGE' options, where PACKAGE +is something like `gnu-as' or `x' (for the X Window System). The +`README' should mention any `--enable-' and `--with-' options that the +package recognizes. + + For packages that use the X Window System, `configure' can usually +find the X include and library files automatically, but if it doesn't, +you can use the `configure' options `--x-includes=DIR' and +`--x-libraries=DIR' to specify their locations. + +Specifying the System Type +========================== + +There may be some features `configure' cannot figure out automatically, +but needs to determine by the type of machine the package will run on. +Usually, assuming the package is built to be run on the _same_ +architectures, `configure' can figure that out, but if it prints a +message saying it cannot guess the machine type, give it the +`--build=TYPE' option. TYPE can either be a short name for the system +type, such as `sun4', or a canonical name which has the form: + + CPU-COMPANY-SYSTEM + +where SYSTEM can have one of these forms: + + OS KERNEL-OS + + See the file `config.sub' for the possible values of each field. If +`config.sub' isn't included in this package, then this package doesn't +need to know the machine type. + + If you are _building_ compiler tools for cross-compiling, you should +use the option `--target=TYPE' to select the type of system they will +produce code for. + + If you want to _use_ a cross compiler, that generates code for a +platform different from the build platform, you should specify the +"host" platform (i.e., that on which the generated programs will +eventually be run) with `--host=TYPE'. + +Sharing Defaults +================ + +If you want to set default values for `configure' scripts to share, you +can create a site shell script called `config.site' that gives default +values for variables like `CC', `cache_file', and `prefix'. +`configure' looks for `PREFIX/share/config.site' if it exists, then +`PREFIX/etc/config.site' if it exists. Or, you can set the +`CONFIG_SITE' environment variable to the location of the site script. +A warning: not all `configure' scripts look for a site script. + +Defining Variables +================== + +Variables not defined in a site shell script can be set in the +environment passed to `configure'. However, some packages may run +configure again during the build, and the customized values of these +variables may be lost. In order to avoid this problem, you should set +them in the `configure' command line, using `VAR=value'. For example: + + ./configure CC=/usr/local2/bin/gcc + +causes the specified `gcc' to be used as the C compiler (unless it is +overridden in the site shell script). Here is a another example: + + /bin/bash ./configure CONFIG_SHELL=/bin/bash + +Here the `CONFIG_SHELL=/bin/bash' operand causes subsequent +configuration-related scripts to be executed by `/bin/bash'. + +`configure' Invocation +====================== + +`configure' recognizes the following options to control how it operates. + +`--help' +`-h' + Print a summary of the options to `configure', and exit. + +`--version' +`-V' + Print the version of Autoconf used to generate the `configure' + script, and exit. + +`--cache-file=FILE' + Enable the cache: use and save the results of the tests in FILE, + traditionally `config.cache'. FILE defaults to `/dev/null' to + disable caching. + +`--config-cache' +`-C' + Alias for `--cache-file=config.cache'. + +`--quiet' +`--silent' +`-q' + Do not print messages saying which checks are being made. To + suppress all normal output, redirect it to `/dev/null' (any error + messages will still be shown). + +`--srcdir=DIR' + Look for the package's source code in directory DIR. Usually + `configure' can determine that directory automatically. + +`configure' also accepts some other, not widely useful, options. Run +`configure --help' for more details. + diff -r 5d027884a9d3 -r 3c18c36245e7 gmyth-stream/gmencoder/Makefile.am --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gmyth-stream/gmencoder/Makefile.am Tue Sep 18 13:45:36 2007 +0100 @@ -0,0 +1,7 @@ +SUBDIRS = src + +EXTRA_DIST = \ + ChangeLog + +DIST_SUBDIRS = \ + src diff -r 5d027884a9d3 -r 3c18c36245e7 gmyth-stream/gmencoder/autogen.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gmyth-stream/gmencoder/autogen.sh Tue Sep 18 13:45:36 2007 +0100 @@ -0,0 +1,19 @@ +#!/bin/sh +# Run this to generate all the initial makefiles, etc. + +srcdir=`dirname $0` +test -z "$srcdir" && srcdir=. + +PKG_NAME="gmemcoder" + +(test -f $srcdir/configure.ac) || { + echo -n "**Error**: Directory "\`$srcdir\'" does not look like the" + echo " top-level $PKG_NAME directory" + exit 1 +} + +which gnome-autogen.sh || { + echo "You need to install gnome-common from the GNOME CVS" + exit 1 +} +REQUIRED_AUTOMAKE_VERSION=1.9 USE_GNOME2_MACROS=1 . gnome-autogen.sh diff -r 5d027884a9d3 -r 3c18c36245e7 gmyth-stream/gmencoder/configure.ac --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gmyth-stream/gmencoder/configure.ac Tue Sep 18 13:45:36 2007 +0100 @@ -0,0 +1,93 @@ +# -*- Autoconf -*- +# Process this file with autoconf to produce a configure script. + +AC_PREREQ(2.50) + +AC_INIT([gmemcoder],[0.1]) + +AC_CONFIG_MACRO_DIR([m4]) +AC_CONFIG_HEADER(config.h) + +AS_VERSION(gmemcoder, GMEMCODER, 0, 1, 0, 0, GMEMCODER_SVN="no", GMEMCODER_SVN="yes") +GMEMCODER_MAJORMINOR=$GMEMCODER_VERSION.$GMEMCODER_MINOR_VERSION +AC_SUBST(GMEMCODER_MAJORMINOR) + +dnl AM_MAINTAINER_MODE provides the option to enable maintainer mode +AM_MAINTAINER_MODE +dnl make aclocal work in maintainer mode +AC_SUBST(ACLOCAL_AMFLAGS, "-I m4") + +AM_INIT_AUTOMAKE($PACKAGE, $VERSION) + +# Checks for programs. +# check for tools +# Make sure CFLAGS is defined to stop AC_PROC_CC adding -g +CFLAGS="$CFLAGS -Wall" +AC_PROG_CC +AC_PROG_LIBTOOL + +# Checks for libraries. + +# Checks for header files. +AC_HEADER_STDC + +#Test if --disable-debug given +AC_ARG_ENABLE(debug, + AC_HELP_STRING([--disable-debug], [enable debugging mode])) +if test x"$enable_debug" != xno; then + CFLAGS="$CFLAGS -g -DMYTH_STREAM_USE_DEBUG" +else + CFLAGS="$CFLAGS -O2 -DG_DISABLE_CHECKS" +fi + + +# Checks required packages #################################################### +############################################################################### + +## Check for pkgconfig ######################################################## +############################################################################### +AC_CHECK_PROG(HAVE_PKGCONFIG, pkg-config, yes, no) +if test "x$HAVE_PKGCONFIG" = "xno"; then + AC_MSG_ERROR(you need to have pkgconfig installed !) +fi + +## Check for Glib2.0 ########################################################## +############################################################################### +PKG_CHECK_MODULES(GLIB, glib-2.0, HAVE_GLIB=yes,HAVE_GLIB=no) +if test "x$HAVE_GLIB" = "xno"; then + AC_MSG_ERROR(you need glib-2.0 installed) +fi +AC_SUBST(GLIB_CFLAGS) +AC_SUBST(GLIB_LIBS) + +## Check for GnomeVFS ########################################################## +############################################################################### +PKG_CHECK_MODULES(GVFS, gnome-vfs-2.0, HAVE_GVFS=yes,HAVE_GVFS=no) +if test "x$HAVE_GVFS" = "xno"; then + AC_MSG_ERROR(you need gnome-vfs-2.0 installed) +fi +AC_SUBST(GVFS_CFLAGS) +AC_SUBST(GVFS_LIBS) + + +## Check for gst-base ######################################################### +############################################################################### +PKG_CHECK_MODULES(GST, [gstreamer-base-0.10]) +AC_SUBST(GST_CFLAGS) +AC_SUBST(GST_LIBS) + +AC_SUBST(CFLAGS) +AC_SUBST(LDFLAGS) +AC_SUBST(LIBS) + +AC_OUTPUT([ +Makefile +src/Makefile +]) + +if test "x$enable_debug" != "xno"; then + AC_MSG_NOTICE([Debug: Enabled]) +else + AC_MSG_NOTICE([Debug: Disabled]) +fi + diff -r 5d027884a9d3 -r 3c18c36245e7 gmyth-stream/gmencoder/m4/as-compiler-flag.m4 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gmyth-stream/gmencoder/m4/as-compiler-flag.m4 Tue Sep 18 13:45:36 2007 +0100 @@ -0,0 +1,32 @@ +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 5d027884a9d3 -r 3c18c36245e7 gmyth-stream/gmencoder/m4/as-expand.m4 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gmyth-stream/gmencoder/m4/as-expand.m4 Tue Sep 18 13:45:36 2007 +0100 @@ -0,0 +1,40 @@ +dnl AS_AC_EXPAND(VAR, CONFIGURE_VAR) +dnl +dnl example +dnl AS_AC_EXPAND(SYSCONFDIR, $sysconfdir) +dnl will set SYSCONFDIR to /usr/local/etc if prefix=/usr/local + +AC_DEFUN([AS_AC_EXPAND], +[ + EXP_VAR=[$1] + FROM_VAR=[$2] + + dnl first expand prefix and exec_prefix if necessary + prefix_save=$prefix + exec_prefix_save=$exec_prefix + + dnl if no prefix given, then use /usr/local, the default prefix + if test "x$prefix" = "xNONE"; then + prefix=$ac_default_prefix + fi + dnl if no exec_prefix given, then use prefix + if test "x$exec_prefix" = "xNONE"; then + exec_prefix=$prefix + fi + + full_var="$FROM_VAR" + dnl loop until it doesn't change anymore + while true; do + new_full_var="`eval echo $full_var`" + if test "x$new_full_var"="x$full_var"; then break; fi + full_var=$new_full_var + done + + dnl clean up + full_var=$new_full_var + AC_SUBST([$1], "$full_var") + + dnl restore prefix and exec_prefix + prefix=$prefix_save + exec_prefix=$exec_prefix_save +]) diff -r 5d027884a9d3 -r 3c18c36245e7 gmyth-stream/gmencoder/m4/as-version.m4 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gmyth-stream/gmencoder/m4/as-version.m4 Tue Sep 18 13:45:36 2007 +0100 @@ -0,0 +1,67 @@ +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 5d027884a9d3 -r 3c18c36245e7 gmyth-stream/gmencoder/m4/gst-feature.m4 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gmyth-stream/gmencoder/m4/gst-feature.m4 Tue Sep 18 13:45:36 2007 +0100 @@ -0,0 +1,211 @@ +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 5d027884a9d3 -r 3c18c36245e7 gmyth-stream/gmencoder/src/Makefile.am --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gmyth-stream/gmencoder/src/Makefile.am Tue Sep 18 13:45:36 2007 +0100 @@ -0,0 +1,20 @@ +bin_PROGRAMS = \ + gmencoder + +gmencoder_SOURCES = \ + main.c \ + gmencoder.c \ + gmencoder.h + +gmencoder_LDADD = \ + $(GLIB_LIBS) \ + $(GST_LIBS) \ + $(GVFS_LIBS) \ + -lgstinterfaces-0.10 + +AM_CPPFLAGS = \ + $(GLIB_CFLAGS) \ + $(GST_CFLAGS) \ + $(GVFS_CFLAGS) + +CLEANFILES = diff -r 5d027884a9d3 -r 3c18c36245e7 gmyth-stream/gmencoder/src/gmencoder.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gmyth-stream/gmencoder/src/gmencoder.c Tue Sep 18 13:45:36 2007 +0100 @@ -0,0 +1,1207 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "gmencoder.h" + +#define G_MENCODER_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE ((obj), G_TYPE_MENCODER, GMencoderPrivate)) + +#define USE_MANUAL_SINK +#define GMENCODER_TIMEOUT 5000 + +typedef struct _GMencoderPrivate GMencoderPrivate; +typedef struct _SetupInfo SetupInfo; + +struct _SetupInfo { + gchar *video_encode; + gchar *mux_name; + gchar **video_encode_prop; + gdouble video_fps; + gdouble video_rate; + guint video_width; + guint video_height; + gchar *audio_encode; + gchar **audio_encode_prop; + guint audio_rate; +}; + + +struct _GMencoderPrivate { + GstElement *pipe; + GstElement *abin; + GstElement *vbin; + GstElement *sink; + GstElement *src; + + GnomeVFSHandle *handle; + + gboolean ready; + SetupInfo *info; + GstClockTime videot; + GstClockTime audiot; + gint sources; + gint tick_id; + gint64 duration; + gboolean send_chunked; + gint timeout_id; + + //V4l info + GstElement *v4lsrc; + gchar *channel; + gchar *norm; + glong frequency; +}; + +enum { + PAUSED, + PLAYING, + STOPED, + EOS, + ERROR, + LAST_SIGNAL +}; + +static void g_mencoder_class_init(GMencoderClass * klass); +static void g_mencoder_init(GMencoder * object); +static void g_mencoder_dispose(GObject * object); +static void g_mencoder_finalize(GObject * object); +static GstElement *_create_audio_bin(const gchar * encode, + gchar ** encode_prop, gint rate); +static GstElement *_create_video_bin(const gchar * encode, + gchar ** encode_prop, + gdouble fps, + gint rate, guint width, guint height, + gboolean use_deinterlace); + +static gboolean +_pipeline_bus_cb(GstBus * bus, GstMessage * msg, gpointer user_data); + +static void _decodebin_new_pad_cb(GstElement * object, + GstPad * pad, + gboolean flag, gpointer user_data); + +static void _decodebin_unknown_type_cb(GstElement * object, + GstPad * pad, + GstCaps * caps, + gpointer user_data); + +static void _close_output(GMencoder * self); +static gboolean _open_output(GMencoder * self, const gchar * uri); + +static GstElement *_create_source(GMencoder *self, const gchar * uri); +static GstElement *_create_pipeline(GMencoder * self, + const gchar * video_encode, + const gchar * mux_name, + gchar ** video_encode_prop, + gdouble video_fps, + gdouble video_rate, + guint video_width, + guint video_height, + const gchar * audio_encode, + gchar ** audio_encode_prop, + guint audio_rate, + gboolean deinterlace); +static gboolean _process_timeout_cb (gpointer user_data); +#ifdef USE_MANUAL_SINK +static void _flush_queue (GMencoder *self); +static void _buffer_arrive_cb (GstElement* object, + GstBuffer* buff, + GstPad* pad, + gpointer user_data); +#endif + + +static gboolean _tick_cb(gpointer data); + +static guint g_mencoder_signals[LAST_SIGNAL] = { 0 }; + +G_DEFINE_TYPE(GMencoder, g_mencoder, G_TYPE_OBJECT) + +static void g_mencoder_class_init(GMencoderClass * klass) +{ + GObjectClass *object_class; + object_class = (GObjectClass *) klass; + g_type_class_add_private(klass, sizeof(GMencoderPrivate)); + + object_class->dispose = g_mencoder_dispose; + object_class->finalize = g_mencoder_finalize; + + g_mencoder_signals[PAUSED] = + g_signal_new("paused", + G_OBJECT_CLASS_TYPE(object_class), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, + g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); + + g_mencoder_signals[PLAYING] = + g_signal_new("playing", + G_OBJECT_CLASS_TYPE(object_class), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, + g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); + + g_mencoder_signals[STOPED] = + g_signal_new("stoped", + G_OBJECT_CLASS_TYPE(object_class), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, + g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); + + g_mencoder_signals[EOS] = + g_signal_new("eos", + G_OBJECT_CLASS_TYPE(object_class), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, + g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); + + g_mencoder_signals[ERROR] = + g_signal_new("error", + G_OBJECT_CLASS_TYPE(object_class), + G_SIGNAL_RUN_LAST, + 0, NULL, NULL, + g_cclosure_marshal_VOID__STRING, + G_TYPE_NONE, 1, G_TYPE_STRING); +} + +static void +g_mencoder_init(GMencoder * self) +{ + GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(self); + priv->info = g_new0(SetupInfo, 1); +} + +static void +g_mencoder_dispose(GObject * object) +{ +} + +static void +g_mencoder_finalize(GObject * object) +{ + GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(object); + + // TODO: clear vars + g_mencoder_close_stream(G_MENCODER(object)); + g_free (priv->info); +} + +GMencoder * +g_mencoder_new(void) +{ + return g_object_new(G_TYPE_MENCODER, NULL); +} + + +static void +_obj_set_prop(GObject * obj, const gchar * prop_name, + const gchar * prop_val) +{ + GValue p = { 0 }; + GValue v = { 0 }; + GParamSpec *s = NULL; + GObjectClass *k = G_OBJECT_GET_CLASS(obj); + + + g_value_init(&v, G_TYPE_STRING); + g_value_set_string(&v, prop_val); + + s = g_object_class_find_property(k, prop_name); + if (s == NULL) { + g_print("Invalid property name: %s\n", prop_name); + return; + } + + g_value_init(&p, s->value_type); + switch (s->value_type) { + case G_TYPE_INT: + g_value_set_int(&p, atoi(prop_val)); + break; + case G_TYPE_ULONG: + g_value_set_ulong (&p, atol(prop_val)); + break; + case G_TYPE_STRING: + g_value_set_string(&p, prop_val); + break; + case G_TYPE_BOOLEAN: + g_value_set_boolean(&p, (gboolean) atoi (prop_val)); + break; + case G_TYPE_DOUBLE: + g_value_set_double(&p, atof (prop_val)); + break; + case G_TYPE_FLOAT: + g_value_set_float(&p, (float) atof (prop_val)); + break; + default: + g_value_set_enum(&p, atoi(prop_val)); + g_warning ("Property %s of type %s. Not supported using default enum", + prop_name, g_type_name (s->value_type)); + return; + } + + g_object_set_property(obj, prop_name, &p); + g_value_unset(&v); + g_value_unset(&p); +} + +static GstElement * +_create_element_with_prop(const gchar * factory_name, + const gchar * element_name, gchar ** prop) +{ + GstElement *ret; + int i; + + ret = gst_element_factory_make(factory_name, element_name); + if (ret == NULL) + return NULL; + + if (prop != NULL) { + for (i = 0; i < g_strv_length(prop); i++) { + if (prop[i] != NULL) { + char **v = g_strsplit(prop[i], "=", 2); + if (g_strv_length(v) == 2) { + _obj_set_prop(G_OBJECT(ret), v[0], v[1]); + } + g_strfreev(v); + } + } + } + + return ret; + +} + +static GstElement * +_create_audio_bin(const gchar * encode, gchar ** encode_prop, gint rate) +{ + GstElement *abin = NULL; + GstElement *aqueue = NULL; + GstElement *aconvert = NULL; + GstElement *aencode = NULL; + GstElement *aqueue_src = NULL; + GstPad *apad = NULL; + + // audio/x-raw-int ! queue ! audioconvert ! faac ! rtpmp4gpay ! + // udpsink name=upd_audio host=224.0.0.1 port=5002 + abin = gst_bin_new("abin"); + aqueue = gst_element_factory_make("queue", "aqueue"); + aconvert = gst_element_factory_make("audioconvert", "aconvert"); + aencode = + _create_element_with_prop((encode ? encode : "lame"), "aencode", + encode_prop); + aqueue_src = gst_element_factory_make("queue", "aqueue_src"); + + if ((abin == NULL) || (aqueue == NULL) || (aconvert == NULL) + || (aencode == NULL) || (aqueue_src == NULL)) { + g_warning("Audio elements not found"); + goto error; + } + + g_object_set(G_OBJECT(aencode), "bitrate", 32, NULL); + /* + * if (rate > 0) { g_object_set (G_OBJECT (aencode), "bitrate", 32, + * NULL); } + */ + + gst_bin_add_many(GST_BIN(abin), aqueue, aconvert, aencode, aqueue_src, + NULL); + if (gst_element_link_many(aqueue, aconvert, aencode, aqueue_src, NULL) + == FALSE) { + g_warning("Not Link audio elements"); + } + // TODO: apply audio rate + + // ghost pad the audio bin + apad = gst_element_get_pad(aqueue, "sink"); + gst_element_add_pad(abin, gst_ghost_pad_new("sink", apad)); + gst_object_unref(apad); + + apad = gst_element_get_pad(aqueue_src, "src"); + gst_element_add_pad(abin, gst_ghost_pad_new("src", apad)); + gst_object_unref(apad); + + return abin; + error: + if (abin != NULL) + gst_object_unref(abin); + + if (aqueue != NULL) + gst_object_unref(aqueue); + + if (aconvert != NULL) + gst_object_unref(aconvert); + + if (aencode != NULL) + gst_object_unref(aencode); + + if (aqueue_src != NULL) + gst_object_unref(aqueue_src); + + if (apad != NULL) + gst_object_unref(apad); + + return NULL; +} + + + + +// queue ! videoscale ! video/x-raw-yuv,width=240,height=144 ! colorspace +// ! rate ! encode ! queue +static GstElement * +_create_video_bin(const gchar * encode, + gchar ** encode_prop, + gdouble fps, gint rate, guint width, guint height, + gboolean use_deinterlace) +{ + GstElement *vbin = NULL; + GstElement *vqueue = NULL; + GstElement *vqueue_src = NULL; + GstElement *vcolorspace = NULL; + GstElement *vencode = NULL; + GstElement *vrate = NULL; + GstElement *deinterlace = NULL; + GstElement *walk = NULL; + GstPad *vpad = NULL; + + vbin = gst_bin_new("vbin"); + vqueue = gst_element_factory_make("queue", "vqueue"); + vcolorspace = + gst_element_factory_make("ffmpegcolorspace", "colorspace"); + + if (use_deinterlace) { + deinterlace = gst_element_factory_make ("ffdeinterlace", "deinterlace"); + if (deinterlace == NULL) { + g_warning ("Fail to create deinterlace element: Continue without deinterlace."); + } + } + + + vencode = _create_element_with_prop((encode != + NULL ? encode : + "ffenc_mpeg1video"), "vencode", + encode_prop); + vqueue_src = gst_element_factory_make("queue", "queue_src"); + + if ((vbin == NULL) || (vqueue == NULL) || (vcolorspace == NULL) + || (vencode == NULL) || (vqueue_src == NULL)) { + g_warning("Video elements not found"); + goto error; + } + + gst_bin_add_many(GST_BIN(vbin), vqueue, vcolorspace, vencode, + vqueue_src, NULL); + + if (deinterlace != NULL) { + gst_bin_add(GST_BIN(vbin), deinterlace); + gst_element_link (vqueue, deinterlace); + walk = deinterlace; + } else { + walk = vqueue; + } + + if ((width > 0) && (height > 0)) { + // Scalling video + GstCaps *vcaps; + GstElement *vscale = + gst_element_factory_make("videoscale", "vscale"); + + g_object_set (G_OBJECT (vscale), "method", 1, NULL); + + gst_bin_add(GST_BIN(vbin), vscale); + + vcaps = gst_caps_new_simple("video/x-raw-yuv", + "width", G_TYPE_INT, width, + "height", G_TYPE_INT, height, NULL); + + gst_element_link(walk, vscale); + + if (gst_element_link_filtered(vscale, vcolorspace, vcaps) == FALSE) { + g_warning("Fail to resize video"); + gst_object_unref(vcaps); + gst_object_unref(vscale); + goto error; + } + gst_caps_unref(vcaps); + } else { + gst_element_link(walk, vcolorspace); + } + + if (fps > 0) { + // Changing the video fps + GstCaps *vcaps; + vrate = gst_element_factory_make("videorate", "vrate"); + + gst_bin_add(GST_BIN(vbin), vrate); + + if (gst_element_link(vcolorspace, vrate) == FALSE) { + g_warning("Fail to link video elements"); + goto error; + } + + vcaps = gst_caps_new_simple("video/x-raw-yuv", + "framerate", GST_TYPE_FRACTION, + (int) (fps * 1000), 1000, NULL); + + if (gst_element_link_filtered(vrate, vencode, vcaps) == FALSE) { + g_warning("Fail to link vrate with vencode."); + goto error; + } + gst_caps_unref(vcaps); + } else { + if (gst_element_link(vcolorspace, vencode) == FALSE) { + g_warning("Fail to link colorspace and video encode element."); + goto error; + } + } + + gst_element_link(vencode, vqueue_src); + + // ghost pad the video bin + vpad = gst_element_get_pad(vqueue, "sink"); + gst_element_add_pad(vbin, gst_ghost_pad_new("sink", vpad)); + gst_object_unref(vpad); + + vpad = gst_element_get_pad(vqueue_src, "src"); + gst_element_add_pad(vbin, gst_ghost_pad_new("src", vpad)); + gst_object_unref(vpad); + + return vbin; + + error: + if (vpad != NULL) + gst_object_unref(vpad); + + if (vbin != NULL) + gst_object_unref(vbin); + + if (vqueue != NULL) + gst_object_unref(vqueue); + + if (vencode != NULL) + gst_object_unref(vencode); + + if (vqueue_src != NULL) + gst_object_unref(vqueue_src); + + if (vcolorspace != NULL) + gst_object_unref(vcolorspace); + + return NULL; +} + + + +gboolean +g_mencoder_setup_stream(GMencoder * self, + gboolean chunked, + gboolean deinterlace, + const gchar * mux_name, + const gchar * video_encode, + gchar ** video_encode_prop, + gdouble video_fps, + gdouble video_rate, + guint video_width, + guint video_height, + const gchar * audio_encode, + gchar ** audio_encode_prop, + guint audio_rate, const gchar * out_uri) +{ + GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(self); + if (priv->ready == TRUE) { + g_warning + ("Stream already configured. You need close stream first."); + return FALSE; + } + + _close_output(self); + if (_open_output(self, out_uri) == FALSE) { + return FALSE; + } + + priv->sources = 0; + priv->send_chunked = chunked; + priv->pipe = _create_pipeline(self, + video_encode, + mux_name, + video_encode_prop, + video_fps, + video_rate, + video_width, + video_height, + audio_encode, audio_encode_prop, + audio_rate, + deinterlace); + + return (priv->pipe != NULL); +} + + +gboolean +g_mencoder_append_uri(GMencoder * self, const gchar * uri) +{ + GstPad *pad_src; + GstPad *pad_sink; + GstElement *src; + GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(self); + gboolean ret = FALSE; + GstElement *ap = NULL; + GstElement *vp = NULL; + + + g_return_val_if_fail(priv->pipe != NULL, FALSE); + g_return_val_if_fail(priv->ready == FALSE, FALSE); + + src = _create_source(self, uri); + if (src == NULL) + return FALSE; + + priv->src = gst_bin_get_by_name(GST_BIN(src), "src"); + + gst_bin_add(GST_BIN(priv->pipe), src); + + ap = gst_bin_get_by_name(GST_BIN(priv->pipe), "abin"); + vp = gst_bin_get_by_name(GST_BIN(priv->pipe), "vbin"); + + if ((vp == NULL) || (ap == NULL)) { + g_warning("Fail to get output bin"); + goto error; + } + + pad_src = gst_element_get_pad(src, "src_audio"); + pad_sink = gst_element_get_compatible_pad(ap, + pad_src, + gst_pad_get_caps(pad_src)); + + if ((pad_sink == NULL) || (pad_src == NULL)) + goto error; + + GstPadLinkReturn lret = gst_pad_link(pad_src, pad_sink); + if (lret != GST_PAD_LINK_OK) + goto error; + + gst_object_unref(pad_src); + gst_object_unref(pad_sink); + + pad_src = gst_element_get_pad(src, "src_video"); + pad_sink = gst_element_get_compatible_pad(vp, + pad_src, + gst_pad_get_caps(pad_src)); + + if ((pad_src == NULL) || (pad_sink == NULL)) + goto error; + + if (gst_pad_link(pad_src, pad_sink) != GST_PAD_LINK_OK) { + g_warning("invalid source. video"); + goto error; + } + + priv->sources++; + ret = TRUE; + error: + + if ((src != NULL) && (ret == FALSE)) { + gst_bin_remove(GST_BIN(priv->pipe), src); + gst_object_unref(src); + } + + if (ap != NULL) + gst_object_unref(ap); + + if (vp != NULL) + gst_object_unref(vp); + + if (pad_src != NULL) + gst_object_unref(pad_src); + + if (pad_sink != NULL) + gst_object_unref(pad_sink); + + return ret; +} + + + +void +g_mencoder_remove_uri(GMencoder * self, const gchar * uri) +{ + // GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE (self); + // TODO: remove src +} + +void +g_mencoder_play_stream(GMencoder * self) +{ + GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(self); + g_return_if_fail(priv->ready == FALSE); + priv->ready = TRUE; + gst_element_set_state(priv->pipe, GST_STATE_PLAYING); + if (priv->tick_id != 0) { + g_source_remove (priv->tick_id); + } + priv->tick_id = g_timeout_add(500, _tick_cb, self); + + if (priv->timeout_id != 0) { + g_source_remove (priv->timeout_id); + } + //priv->timeout_id = g_timeout_add(GMENCODER_TIMEOUT, _process_timeout_cb, self); +} + +void +g_mencoder_pause_stream(GMencoder * self) +{ + GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(self); + g_return_if_fail(priv->ready == TRUE); + gst_element_set_state(priv->pipe, GST_STATE_PAUSED); +} + +void +g_mencoder_close_stream(GMencoder * self) +{ + + GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(self); + if (priv->tick_id != 0) { + g_source_remove(priv->tick_id); + priv->tick_id = 0; + } + + if (priv->timeout_id != 0) { + g_source_remove (priv->timeout_id); + priv->timeout_id = 0; + } + + if (priv->pipe != NULL) { + // TODO: fixe pipeline dispose + //gst_element_set_state (priv->pipe, GST_STATE_NULL); + // g_debug ("SETING STATE TO NULL: OK"); + // gst_element_set_state (priv->pipe, GST_STATE_NULL); + //gst_object_unref (priv->pipe); + //gst_object_unref(priv->src); + priv->src = NULL; + priv->pipe = NULL; + priv->abin = NULL; + priv->vbin = NULL; + priv->sink = NULL; + } + priv->ready = FALSE; +} + +static GstElement * +_create_pipeline(GMencoder * self, + const gchar * video_encode, + const gchar * mux_name, + gchar ** video_encode_prop, + gdouble video_fps, + gdouble video_rate, + guint video_width, + guint video_height, + const gchar * audio_encode, + gchar ** audio_encode_prop, guint audio_rate, + gboolean deinterlace) +{ + GstBus *bus = NULL; + GstElement *pipe = NULL; + GstElement *sink = NULL; + GstElement *mux = NULL; + GstElement *abin = NULL; + GstElement *vbin = NULL; + GstElement *queue = NULL; + GstPad *aux_pad = NULL; + GstPad *mux_pad = NULL; + + pipe = gst_pipeline_new("pipe"); + + mux = + gst_element_factory_make((mux_name ? mux_name : "ffmux_mpeg"), + "mux"); + if (mux == NULL) + goto error; + + queue = gst_element_factory_make("queue", "queueu_sink"); + + + sink = gst_element_factory_make("fakesink", "sink"); + g_object_set (G_OBJECT (sink), "signal-handoffs", TRUE, NULL); + g_signal_connect (G_OBJECT (sink), + "handoff", + G_CALLBACK (_buffer_arrive_cb), + self); + + abin = _create_audio_bin(audio_encode, audio_encode_prop, audio_rate); + if (abin == NULL) + goto error; + + vbin = + _create_video_bin(video_encode, video_encode_prop, video_fps, + video_rate, video_width, video_height, deinterlace); + if (vbin == NULL) + goto error; + + // Finish Pipe + gst_bin_add_many(GST_BIN(pipe), abin, vbin, mux, queue, sink, NULL); + + + // Link bins with mux + aux_pad = gst_element_get_pad(abin, "src"); + mux_pad = + gst_element_get_compatible_pad(mux, aux_pad, + GST_PAD_CAPS(aux_pad)); + if (mux_pad == NULL) { + g_warning("Mux element no have audio PAD"); + goto error; + } + GstPadLinkReturn ret = gst_pad_link(aux_pad, mux_pad); + if (ret != GST_PAD_LINK_OK) { + g_warning("Fail link audio and mux: %d", ret); + goto error; + + } + gst_object_unref(aux_pad); + gst_object_unref(mux_pad); + + aux_pad = gst_element_get_pad(vbin, "src"); + mux_pad = + gst_element_get_compatible_pad(mux, aux_pad, + GST_PAD_CAPS(aux_pad)); + if (mux_pad == NULL) { + g_warning("Mux element no have video PAD"); + goto error; + } + ret = gst_pad_link(aux_pad, mux_pad); + if (ret != GST_PAD_LINK_OK) { + g_warning("Fail link video and mux: %d", ret); + goto error; + } + gst_object_unref(aux_pad); + gst_object_unref(mux_pad); + aux_pad = NULL; + mux_pad = NULL; + + // Link mux with sink + gst_element_link_many(mux, queue, sink, NULL); + + bus = gst_pipeline_get_bus(GST_PIPELINE(pipe)); + gst_bus_add_watch(bus, _pipeline_bus_cb, self); + gst_object_unref(bus); + return pipe; + + error: + g_warning("Invalid uri"); + + if (pipe != NULL) { + gst_object_unref(pipe); + } + + + if (mux != NULL) { + gst_object_unref(mux); + } + + if (mux_pad != NULL) { + gst_object_unref(mux_pad); + } + + if (aux_pad != NULL) { + gst_object_unref(mux_pad); + } + + if (sink != NULL) { + gst_object_unref(sink); + } + + if (abin != NULL) { + gst_object_unref(abin); + } + + if (vbin != NULL) { + gst_object_unref(vbin); + } + + return FALSE; +} + + +static void +_close_output(GMencoder * self) +{ +} + +static GstElement * +_create_v4l_source (GMencoder *self, const gchar * uri) +{ + gchar **info; + GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(self); + + + info = g_strsplit (uri+6, ":", 3); + if (g_strv_length (info) != 3) { + return NULL; + } + + priv->v4lsrc = gst_element_factory_make ("v4l2src", "src"); + g_debug ("channel %s, norm %s, frequ %s", info[0], info[1], info[2]); + g_object_set (G_OBJECT (priv->v4lsrc), + "channel", info[0], + "norm", info[1], + "frequency", atoi (info[2]), + NULL); + + return priv->v4lsrc; +} + +static GstElement * +_create_source(GMencoder *self, const gchar * uri) +{ + + GstElement *bsrc = NULL; + GstElement *src = NULL; + GstElement *aqueue = NULL; + GstElement *vqueue = NULL; + GstElement *decode = NULL; + GstPad *src_pad = NULL; + + + bsrc = gst_bin_new(NULL); + + // src = gst_element_factory_make ("gnomevfssrc", "src"); + // g_object_set (G_OBJECT (src), "location", uri, NULL); + if (strncmp (uri, "v4l://", 6) == 0) { + g_debug ("V4L"); + src = _create_v4l_source (self, uri); + } + else { + src = gst_element_make_from_uri(GST_URI_SRC, uri, "src"); + } + + if (src == NULL) + goto error; + + decode = gst_element_factory_make("decodebin2", "decode"); + if (decode == NULL) + goto error; + + aqueue = gst_element_factory_make("queue", "aqueue"); + if (aqueue == NULL) + goto error; + + vqueue = gst_element_factory_make("queue", "vqueue"); + if (vqueue == NULL) + goto error; + + gst_bin_add_many(GST_BIN(bsrc), src, decode, aqueue, vqueue, + NULL); + gst_element_link (src, decode); + + g_signal_connect(G_OBJECT(decode), + "new-decoded-pad", + G_CALLBACK(_decodebin_new_pad_cb), bsrc); + + g_signal_connect(G_OBJECT(decode), + "unknown-type", + G_CALLBACK(_decodebin_unknown_type_cb), pipe); + + src_pad = gst_element_get_pad(aqueue, "src"); + gst_element_add_pad(bsrc, gst_ghost_pad_new("src_audio", src_pad)); + gst_object_unref(src_pad); + + src_pad = gst_element_get_pad(vqueue, "src"); + gst_element_add_pad(bsrc, gst_ghost_pad_new("src_video", src_pad)); + gst_object_unref(src_pad); + + return bsrc; + + error: + g_debug ("Fail to create source element"); + if (src != NULL) { + gst_object_unref(src); + } + + if (decode != NULL) { + gst_object_unref(decode); + } + + if (aqueue != NULL) { + gst_object_unref(aqueue); + } + + if (vqueue != NULL) { + gst_object_unref(vqueue); + } + + return NULL; +} + +static gboolean +_open_output(GMencoder * self, const gchar * uri) +{ + gchar **i; + GnomeVFSResult result; + GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(self); + + i = g_strsplit(uri, "://", 0); + if (strcmp(i[0], "fd") == 0) { + result = gnome_vfs_open_fd (&priv->handle, atoi(i[1])); + } else { + if (g_file_test (i[1], G_FILE_TEST_EXISTS) == FALSE) { + result = gnome_vfs_create (&priv->handle, uri, GNOME_VFS_OPEN_WRITE, FALSE, + GNOME_VFS_PERM_USER_WRITE | GNOME_VFS_PERM_USER_READ | GNOME_VFS_PERM_GROUP_READ); + } else { + result = gnome_vfs_open (&priv->handle, uri, + GNOME_VFS_OPEN_WRITE | GNOME_VFS_OPEN_TRUNCATE); + } + } + + g_strfreev(i); + return (result == GNOME_VFS_OK); +} + +static gboolean +_pipeline_bus_cb(GstBus * bus, GstMessage * msg, gpointer user_data) +{ + GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(user_data); + + switch (GST_MESSAGE_TYPE(msg)) { + + case GST_MESSAGE_STATE_CHANGED: + { + GstState oldstate; + GstState newstate; + GstState pendingstate; + + + gst_message_parse_state_changed(msg, &oldstate, + &newstate, &pendingstate); + + if (pendingstate != GST_STATE_VOID_PENDING) + break; + + if ((oldstate == GST_STATE_READY) + && (newstate == GST_STATE_PAUSED)) { + if (priv->ready) + g_signal_emit(user_data, g_mencoder_signals[PAUSED], + 0); + } else if ((oldstate == GST_STATE_PAUSED) + && (newstate == GST_STATE_PLAYING)) { + g_signal_emit(user_data, g_mencoder_signals[PLAYING], 0); + } else if ((oldstate == GST_STATE_READY) && + (newstate == GST_STATE_NULL)) { + g_signal_emit(user_data, g_mencoder_signals[STOPED], 0); + } + break; + } + + case GST_MESSAGE_ERROR: + { + GError *error; + gchar *debug; + gchar *err_str; + + if (priv->tick_id != 0) { + g_source_remove(priv->tick_id); + priv->tick_id = 0; + } + + gst_message_parse_error(msg, &error, &debug); + err_str = g_strdup_printf("Error [%d] %s (%s)", error->code, + error->message, debug); + priv->ready = FALSE; + g_signal_emit(user_data, g_mencoder_signals[ERROR], 0, + err_str); + g_free(err_str); + g_clear_error(&error); + g_free(debug); + break; + } + + case GST_MESSAGE_EOS: + priv->ready = FALSE; +#ifdef USE_MANUAL_SINK + _flush_queue (G_MENCODER (user_data)); +#endif + g_signal_emit(user_data, g_mencoder_signals[EOS], 0); + break; + + case GST_MESSAGE_DURATION: + { + GstFormat format; + gint64 duration; + gst_message_parse_duration(msg, &format, &duration); + if (format == GST_FORMAT_BYTES) + priv->duration = duration; + break; + } + default: + { + break; + } + } + return TRUE; +} + + + +static void +_decodebin_new_pad_cb(GstElement * object, + GstPad * pad, gboolean flag, gpointer user_data) +{ + GstCaps *caps; + gchar *str_caps = NULL; + GstElement *sink_element; + GstPad *sink_pad; + + caps = gst_pad_get_caps(pad); + str_caps = gst_caps_to_string(caps); + if (strstr(str_caps, "audio") != NULL) { + sink_element = gst_bin_get_by_name(GST_BIN(user_data), "aqueue"); + } else if (strstr(str_caps, "video") != NULL) { + sink_element = gst_bin_get_by_name(GST_BIN(user_data), "vqueue"); + } else { + g_warning("invalid caps %s", str_caps); + } + + sink_pad = gst_element_get_pad(sink_element, "sink"); + gst_pad_link(pad, sink_pad); + + gst_object_unref(sink_element); + gst_object_unref(sink_pad); + g_free(str_caps); + gst_caps_unref(caps); +} + +static void +_decodebin_unknown_type_cb(GstElement * object, + GstPad * pad, GstCaps * caps, + gpointer user_data) +{ + g_warning("Unknown Type"); + // priv->ready = FALSE; +} + +static gboolean +_tick_cb(gpointer user_data) +{ + GstFormat format = GST_FORMAT_BYTES; + gint64 cur = 0; + + GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(user_data); + + if (priv->duration == 0) { + gint64 d = 0; + if (gst_element_query_duration(priv->src, &format, &d)) + priv->duration = d; + } + + if (priv->duration != 0) { + gst_element_query_position(priv->src, &format, &cur); + g_print("PROGRESS:%lli\n", (99 * cur) / priv->duration); + } + + return TRUE; +} + +static gboolean +_process_timeout_cb (gpointer user_data) +{ + GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(user_data); + + g_signal_emit(user_data, g_mencoder_signals[ERROR], 0, "timeout"); + priv->timeout_id = 0; + return FALSE; +} + + +#ifdef USE_MANUAL_SINK +static gboolean +_send_buffer (GnomeVFSHandle *handle, gpointer buff, gint size) +{ + gchar *msg; + GByteArray *b_send; + GnomeVFSResult result; + GnomeVFSFileSize bytes_written; + + b_send = g_byte_array_new (); + msg = g_strdup_printf ("%x\r\n", size); + b_send = g_byte_array_append (b_send, (const guint8*) msg, strlen (msg) * sizeof (gchar)); + g_free (msg); + + b_send = g_byte_array_append (b_send, buff, size); + + msg = g_strdup ("\r\n"); + b_send = g_byte_array_append (b_send, (const guint8*) msg, strlen (msg) * sizeof (gchar)); + g_free (msg); + + result = gnome_vfs_write (handle, b_send->data, b_send->len, &bytes_written); + g_byte_array_free (b_send, TRUE); + + return (result == GNOME_VFS_OK); +} + +static void +_flush_queue (GMencoder *self) +{ + GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(self); + + if (priv->send_chunked) { + GnomeVFSFileSize bytes_written; + gchar *end_msg; + end_msg = g_strdup ("0\r\n\r\n"); + gnome_vfs_write (priv->handle, + (const guint8*) end_msg, + strlen(end_msg) * sizeof(gchar), + &bytes_written); + g_free (end_msg); + } +} + +static void +_buffer_arrive_cb (GstElement* object, + GstBuffer* buff, + GstPad* pad, + gpointer user_data) +{ + GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(user_data); + + if (priv->timeout_id != 0) { + g_source_remove (priv->timeout_id); + priv->timeout_id = 0; + } + + if (priv->send_chunked) { + if (_send_buffer (priv->handle, GST_BUFFER_DATA (buff), GST_BUFFER_SIZE (buff)) == FALSE) + goto error; + } else { + GnomeVFSResult result; + GnomeVFSFileSize bytes_written; + + result = gnome_vfs_write (priv->handle, + GST_BUFFER_DATA (buff), + GST_BUFFER_SIZE (buff), + &bytes_written); + + if (result != GNOME_VFS_OK) + goto error; + } + + return; + +error: + if (priv->tick_id != 0) { + g_source_remove(priv->tick_id); + priv->tick_id = 0; + } + g_signal_emit(user_data, g_mencoder_signals[ERROR], 0, "Fail to write on socket"); + gst_element_set_state (priv->pipe, GST_STATE_PAUSED); +} + +#endif diff -r 5d027884a9d3 -r 3c18c36245e7 gmyth-stream/gmencoder/src/gmencoder.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gmyth-stream/gmencoder/src/gmencoder.h Tue Sep 18 13:45:36 2007 +0100 @@ -0,0 +1,61 @@ +#ifndef __G_MENCODER_H__ +#define __G_MENCODER_H__ + +#include + +G_BEGIN_DECLS typedef struct _GMencoder GMencoder; +typedef struct _GMencoderClass GMencoderClass; + +struct _GMencoderClass { + GObjectClass parent_class; +}; + +struct _GMencoder { + GObject parent; +}; + +/* + * TYPE MACROS + */ +#define G_TYPE_MENCODER \ + (g_mencoder_get_type()) +#define G_MENCODER(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_MENCODER, GMencoder)) +#define G_MENCODER_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_MENCODER, GMencoderClass)) +#define G_IS_MENCODER(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_MENCODER)) +#define G_IS_MENCODER_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_MENCODER)) +#define G_MENCODER_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS ((obj), G_TYPE_MENCODER, GMencoderClass)) + + +GType g_mencoder_get_type(void); +GMencoder *g_mencoder_new(void); + +gboolean g_mencoder_setup_stream(GMencoder * self, + gboolean chunked, + gboolean deinterlace, + const gchar * mux_name, + const gchar * video_encode, + gchar ** video_encode_prop, + gdouble video_fps, + gdouble video_rate, + guint video_width, + guint video_height, + const gchar * audio_encode, + gchar ** audio_encode_prop, + guint audio_rate, + const gchar * output_uri); + +gboolean g_mencoder_append_uri(GMencoder * self, const gchar * uri); + +void g_mencoder_remove_uri(GMencoder * self, const gchar * uri); + +void g_mencoder_play_stream(GMencoder * self); +void g_mencoder_pause_stream(GMencoder * self); +void g_mencoder_close_stream(GMencoder * self); + +G_END_DECLS +#endif diff -r 5d027884a9d3 -r 3c18c36245e7 gmyth-stream/gmencoder/src/main.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gmyth-stream/gmencoder/src/main.c Tue Sep 18 13:45:36 2007 +0100 @@ -0,0 +1,207 @@ +#include +#include +#include +#include + +#include +#include +#include + +#include "gmencoder.h" + +#define FILE_OUT 1 + +static GMainLoop *mainloop = NULL; +/* + * Options + */ +static gchar *input_file = NULL; +static gchar *video_encode = NULL; +static gchar *video_opts = NULL; +static gdouble video_fps = 0.0; +static gint video_rate = 0; +static gint video_width = 0; +static gint video_height = 0; +static gchar *audio_encode = NULL; +static gchar *audio_opts = NULL; +static double audio_rate = 0.0; +static gchar *mux_name = NULL; +static gchar *output_uri = NULL; +static gboolean chunked = FALSE; +static gboolean deinterlace = FALSE; + + + +static gboolean +_quit(gpointer data) +{ + //g_object_unref(data); + g_main_loop_quit(mainloop); + return FALSE; +} + +static void +_mencoder_eos_cb(GMencoder * mencoder, gpointer data) +{ + g_print("PROGRESS: 100\n"); + g_idle_add(_quit, mencoder); +} + + +static void +_mencoder_error_cb(GMencoder * mencoder, const gchar * msg, gpointer data) +{ + g_print("Error: %s\n", msg); + g_idle_add(_quit, mencoder); +} + +static gboolean +_io_channel_cb(GIOChannel * ch, GIOCondition condition, gpointer data) +{ + GString *cmd = g_string_new(""); + g_io_channel_read_line_string(ch, cmd, NULL, NULL); + + if (strcmp(cmd->str, "PLAY\n") == 0) { + g_mencoder_play_stream(G_MENCODER(data)); + } else if (strcmp(cmd->str, "PAUSE\n") == 0) { + g_mencoder_pause_stream(G_MENCODER(data)); + } else if (strcmp(cmd->str, "STOP\n") == 0) { + g_mencoder_close_stream(G_MENCODER(data)); + } else if (strcmp(cmd->str, "QUIT\n") == 0) { + g_mencoder_close_stream(G_MENCODER(data)); + g_main_loop_quit(mainloop); + } + g_string_free(cmd, TRUE); + return TRUE; +} + +int +main(int argc, char **argv) +{ + GMencoder *coder = NULL; + GIOChannel *ch; + gchar **vopts; + gchar **aopts; + gchar **files; + gint i; + gboolean ret; + + GOptionContext *context; + static const GOptionEntry options[] = { + {"input-files", 'i', 0, G_OPTION_ARG_STRING, &input_file, + "Input File", NULL}, + + {"video-encode", 0, 0, G_OPTION_ARG_STRING, &video_encode, + "GstElementName for used to video encode", NULL}, + + {"video-opts", 0, 0, G_OPTION_ARG_STRING, &video_opts, + "Properties to set on video element", NULL}, + + {"video-fps", 0, 0, G_OPTION_ARG_DOUBLE, &video_fps, + "Video FPS", NULL}, + + {"video-rate", 0, 0, G_OPTION_ARG_INT, &video_rate, + "Video rate", NULL}, + + {"video-width", 0, 0, G_OPTION_ARG_INT, &video_width, + "Video width", NULL}, + + {"video-height", 0, 0, G_OPTION_ARG_INT, &video_height, + "Video height", NULL}, + + {"audio-encode", 0, 0, G_OPTION_ARG_STRING, &audio_encode, + "GstElementName for use to audio encode", NULL}, + + {"audio-opts", 0, 0, G_OPTION_ARG_STRING, &audio_opts, + "Properties to set on audio element", NULL}, + + {"audio-rate", 0, 0, G_OPTION_ARG_INT, &audio_rate, + "Audio rate", NULL}, + + {"mux-element", 0, 0, G_OPTION_ARG_STRING, &mux_name, + "GstElementName for use to mux file", NULL}, + + {"output-uri", 'o', 0, G_OPTION_ARG_STRING, &output_uri, + "Uri to output", NULL}, + + {"chunked", 'c', 0, G_OPTION_ARG_NONE, &chunked, + "Send package chunked", NULL}, + + {"deinterlace", 'd', 0, G_OPTION_ARG_NONE, &deinterlace, + "Use to deinterlace videos", NULL}, + + + {NULL} + }; + + g_type_init(); + g_thread_init(NULL); + gnome_vfs_init (); + mainloop = g_main_loop_new(NULL, FALSE); + + g_set_prgname("gmemcoder"); + context = g_option_context_new(NULL); + g_option_context_set_help_enabled(context, TRUE); + g_option_context_add_main_entries(context, options, NULL); + g_option_context_add_group(context, gst_init_get_option_group()); + g_option_context_parse(context, &argc, &argv, NULL); + + gst_init(&argc, &argv); + + if (output_uri == NULL) { + g_print("You need to specify output-uri.\nTry --help " + "for more information.\n"); + return 1; + } + + if (input_file == NULL) { + g_print("You need to specify input file\nTry --help " + "for more information.\n"); + } + + coder = g_mencoder_new(); + ch = g_io_channel_unix_new(0); + + if (audio_opts != NULL) + aopts = g_strsplit(audio_opts, ",", 0); + else + aopts = NULL; + + if (video_opts != NULL) + vopts = g_strsplit(video_opts, ",", 0); + else + vopts = NULL; + + ret = g_mencoder_setup_stream(coder, chunked, deinterlace, mux_name, + video_encode, vopts, video_fps, + video_rate, video_width, video_height, + audio_encode, aopts, audio_rate, output_uri); + + if (ret == TRUE) { + files = g_strsplit(input_file, ",", 0); + for (i = 0; i < g_strv_length(files); i++) { + if (!g_mencoder_append_uri(coder, files[i])) { + g_debug("Invalid uri: %s", files[i]); + } + } + g_strfreev(files); + } + + g_strfreev(aopts); + g_strfreev(vopts); + + if (ret == TRUE) { + g_io_add_watch(ch, G_IO_IN, _io_channel_cb, coder); + g_signal_connect(G_OBJECT(coder), + "eos", G_CALLBACK(_mencoder_eos_cb), mainloop); + + g_signal_connect(G_OBJECT(coder), + "error", G_CALLBACK(_mencoder_error_cb), mainloop); + + g_mencoder_play_stream(coder); + g_main_loop_run(mainloop); + } + + g_object_unref(coder); + return 0; +} diff -r 5d027884a9d3 -r 3c18c36245e7 gmyth-stream/gmencoder/tests/Makefile.am --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gmyth-stream/gmencoder/tests/Makefile.am Tue Sep 18 13:45:36 2007 +0100 @@ -0,0 +1,15 @@ +bin_PROGRAMS = \ + gnl-test + +gnl_test_SOURCES = \ + main.c + +gnl_test_LDADD = \ + $(GLIB_LIBS) \ + $(GST_LIBS) + +AM_CPPFLAGS = \ + $(GLIB_CFLAGS) \ + $(GST_CFLAGS) + +CLEANFILES = diff -r 5d027884a9d3 -r 3c18c36245e7 gmyth-stream/gmencoder/tests/main.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gmyth-stream/gmencoder/tests/main.c Tue Sep 18 13:45:36 2007 +0100 @@ -0,0 +1,230 @@ +#include +#include +#include +#include + +#include +#include + + +static GMainLoop *mainloop = NULL; +static gint64 d = 0; +static gint64 gap = 10; + +typedef enum { + MY_STREAM_TYPE_AUDIO = 0, + MY_STREAM_TYPE_VIDEO = 1 +} MyStreamType; + +typedef struct _StreamData StreamData; +struct _StreamData { + GstElement *bin; + MyStreamType type; +}; + +static void +_stream_decode_pad_added_cb(GstElement * decode, + GstPad * pad, gboolean arg1, + gpointer user_data) +{ + StreamData *data = (StreamData *) user_data; + GstElement *queue; + GstPad *sink_pad; + GstCaps *caps = gst_pad_get_caps(pad); + gchar *str_caps = gst_caps_to_string(caps); + + g_debug("decode caps: [%d] [%s]", data->type, str_caps); + + switch (data->type) { + case MY_STREAM_TYPE_AUDIO: + g_debug("Audio"); + if (strstr(str_caps, "audio") == NULL) + goto done; + break; + case MY_STREAM_TYPE_VIDEO: + g_debug("Video"); + if (strstr(str_caps, "video") == NULL) + goto done; + break; + } + + queue = gst_bin_get_by_name(GST_BIN(data->bin), "queue"); + sink_pad = gst_element_get_pad(queue, "sink"); + + if (gst_pad_link(pad, sink_pad) != GST_PAD_LINK_OK) { + g_warning("Failed to link decode"); + } + + gst_object_unref(queue); + gst_object_unref(sink_pad); + // g_free (data); + g_debug("Linked"); + + done: + gst_caps_unref(caps); + g_free(str_caps); +} + + +static GstElement * +_create_src_element(const gchar * name, + const gchar * uri, MyStreamType type, guint priority) +{ + StreamData *data; + GstElement *bin; + GstElement *src; + GstElement *decode; + GstElement *queue; + GstPad *src_pad; + + GstElement *gnl_src; + + g_debug("element from uri: %s", uri); + + bin = gst_bin_new("bin"); + src = gst_element_make_from_uri(GST_URI_SRC, uri, "src"); + g_return_val_if_fail(src != NULL, NULL); + + decode = gst_element_factory_make("decodebin", NULL); + g_return_val_if_fail(decode != NULL, NULL); + + queue = gst_element_factory_make("queue", "queue"); + g_return_val_if_fail(queue != NULL, NULL); + + gst_bin_add_many(GST_BIN(bin), src, decode, queue, NULL); + gst_element_link(src, decode); + + data = g_new0(StreamData, 1); + data->bin = bin; + data->type = type; + g_debug("Type : %d = %d", type, data->type); + + g_signal_connect(G_OBJECT(decode), "new-decoded-pad", + G_CALLBACK(_stream_decode_pad_added_cb), data); + + + src_pad = gst_element_get_pad(queue, "src"); + g_return_val_if_fail(src_pad != NULL, NULL); + + gst_element_add_pad(bin, gst_ghost_pad_new("src", src_pad)); + + gst_object_unref(src_pad); + + gnl_src = gst_element_factory_make("gnlsource", name); + g_return_val_if_fail(gnl_src != NULL, NULL); + gst_bin_add(GST_BIN(gnl_src), bin); + + g_debug("ADDING WITH: START [%lli] DUR [%lli]", d, gap); + if (d == 0) { + g_object_set(G_OBJECT(gnl_src), + // "start", 0L, + "duration", 10 * GST_SECOND, + // "media-start", 0L, + // "media-duration", 10 * GST_SECOND, + "priority", priority, NULL); + + } else { + g_object_set(G_OBJECT(gnl_src), + "start", 10 * GST_SECOND, "duration", 10 * GST_SECOND, + // /"media-start", 10 * GST_SECOND, + // "media-duration", 10 * GST_SECOND, + "priority", priority, NULL); + + } + d++; + + return gnl_src; +} + +static void +_composition_pad_added_cb(GstElement * composition, + GstPad * pad, gpointer data) +{ + GstPad *sink_pad = + gst_element_get_pad(GST_ELEMENT(data), "sink"); + g_debug("compose pad added"); + + if (gst_pad_link(pad, sink_pad) != GST_PAD_LINK_OK) { + g_warning("Failed to link decode"); + } + + g_debug("Linked ok"); +} + +static void +_compose_add_file(GstElement * compose, + const gchar * e_name, + const gchar * uri, MyStreamType type, guint priority) +{ + GstElement *src; + + src = _create_src_element(e_name, uri, type, priority); + gst_bin_add(GST_BIN(compose), src); +} + + +int +main(int argc, char **argv) +{ + GstElement *pipe; + GstElement *gnl_compose_a; + GstElement *gnl_compose_v; + GstElement *asink; + GstElement *vsink; + GstElement *aqueue; + GstElement *vqueue; + + g_type_init(); + gst_init(&argc, &argv); + + mainloop = g_main_loop_new(NULL, FALSE); + + pipe = gst_pipeline_new("test_pipeline"); + + gnl_compose_a = gst_element_factory_make("gnlcomposition", "acompose"); + g_return_val_if_fail(gnl_compose_a != NULL, 1); + + gnl_compose_v = gst_element_factory_make("gnlcomposition", "vcompose"); + g_return_val_if_fail(gnl_compose_v != NULL, 1); + + + // _compose_add_file (gnl_compose_a, "src0", argv[1], + // MY_STREAM_TYPE_AUDIO, 1); + // _compose_add_file (gnl_compose_a, "src1", argv[2], + // MY_STREAM_TYPE_AUDIO, 1); + + d = 0; + + _compose_add_file(gnl_compose_v, "src2", argv[1], MY_STREAM_TYPE_VIDEO, + 1); + _compose_add_file(gnl_compose_v, "src3", argv[2], MY_STREAM_TYPE_VIDEO, + 1); + + + // aqueue = gst_element_factory_make ("queue", "aqueue"); + // asink = gst_element_factory_make ("alsasink", "asink"); + + vqueue = gst_element_factory_make("queue", "vqueue"); + vsink = gst_element_factory_make("xvimagesink", "vsink"); + + gst_bin_add_many(GST_BIN(pipe), gnl_compose_a, gnl_compose_v, vqueue, + vsink, + // aqueue, asink, + NULL); + + gst_element_link(vqueue, vsink); + // gst_element_link (aqueue, asink); + + // g_signal_connect (G_OBJECT (gnl_compose_a), "pad-added", + // G_CALLBACK (_composition_pad_added_cb), aqueue); + + g_signal_connect(G_OBJECT(gnl_compose_v), "pad-added", + G_CALLBACK(_composition_pad_added_cb), vqueue); + + + // g_idle_add (_play, pipe); + gst_element_set_state(GST_ELEMENT(pipe), GST_STATE_PLAYING); + g_main_loop_run(mainloop); + + return 0; +}