[svn r853] gmemcoder folder renamed to gmencoder trunk
authormelunko
Tue Sep 18 13:45:36 2007 +0100 (2007-09-18)
branchtrunk
changeset 8473c18c36245e7
parent 846 5d027884a9d3
child 848 37e112f474db
[svn r853] gmemcoder folder renamed to gmencoder
gmyth-stream/gmemcoder/AUTHORS
gmyth-stream/gmemcoder/COPYING
gmyth-stream/gmemcoder/ChangeLog
gmyth-stream/gmemcoder/INSTALL
gmyth-stream/gmemcoder/Makefile.am
gmyth-stream/gmemcoder/NEWS
gmyth-stream/gmemcoder/README
gmyth-stream/gmemcoder/autogen.sh
gmyth-stream/gmemcoder/configure.ac
gmyth-stream/gmemcoder/m4/as-compiler-flag.m4
gmyth-stream/gmemcoder/m4/as-expand.m4
gmyth-stream/gmemcoder/m4/as-version.m4
gmyth-stream/gmemcoder/m4/gst-feature.m4
gmyth-stream/gmemcoder/src/Makefile.am
gmyth-stream/gmemcoder/src/gmencoder.c
gmyth-stream/gmemcoder/src/gmencoder.h
gmyth-stream/gmemcoder/src/main.c
gmyth-stream/gmemcoder/tests/Makefile.am
gmyth-stream/gmemcoder/tests/main.c
gmyth-stream/gmencoder/AUTHORS
gmyth-stream/gmencoder/COPYING
gmyth-stream/gmencoder/ChangeLog
gmyth-stream/gmencoder/INSTALL
gmyth-stream/gmencoder/Makefile.am
gmyth-stream/gmencoder/NEWS
gmyth-stream/gmencoder/README
gmyth-stream/gmencoder/autogen.sh
gmyth-stream/gmencoder/configure.ac
gmyth-stream/gmencoder/m4/as-compiler-flag.m4
gmyth-stream/gmencoder/m4/as-expand.m4
gmyth-stream/gmencoder/m4/as-version.m4
gmyth-stream/gmencoder/m4/gst-feature.m4
gmyth-stream/gmencoder/src/Makefile.am
gmyth-stream/gmencoder/src/gmencoder.c
gmyth-stream/gmencoder/src/gmencoder.h
gmyth-stream/gmencoder/src/main.c
gmyth-stream/gmencoder/tests/Makefile.am
gmyth-stream/gmencoder/tests/main.c
     1.1 --- a/gmyth-stream/gmemcoder/INSTALL	Tue Sep 18 13:45:04 2007 +0100
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,236 +0,0 @@
     1.4 -Installation Instructions
     1.5 -*************************
     1.6 -
     1.7 -Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005 Free
     1.8 -Software Foundation, Inc.
     1.9 -
    1.10 -This file is free documentation; the Free Software Foundation gives
    1.11 -unlimited permission to copy, distribute and modify it.
    1.12 -
    1.13 -Basic Installation
    1.14 -==================
    1.15 -
    1.16 -These are generic installation instructions.
    1.17 -
    1.18 -   The `configure' shell script attempts to guess correct values for
    1.19 -various system-dependent variables used during compilation.  It uses
    1.20 -those values to create a `Makefile' in each directory of the package.
    1.21 -It may also create one or more `.h' files containing system-dependent
    1.22 -definitions.  Finally, it creates a shell script `config.status' that
    1.23 -you can run in the future to recreate the current configuration, and a
    1.24 -file `config.log' containing compiler output (useful mainly for
    1.25 -debugging `configure').
    1.26 -
    1.27 -   It can also use an optional file (typically called `config.cache'
    1.28 -and enabled with `--cache-file=config.cache' or simply `-C') that saves
    1.29 -the results of its tests to speed up reconfiguring.  (Caching is
    1.30 -disabled by default to prevent problems with accidental use of stale
    1.31 -cache files.)
    1.32 -
    1.33 -   If you need to do unusual things to compile the package, please try
    1.34 -to figure out how `configure' could check whether to do them, and mail
    1.35 -diffs or instructions to the address given in the `README' so they can
    1.36 -be considered for the next release.  If you are using the cache, and at
    1.37 -some point `config.cache' contains results you don't want to keep, you
    1.38 -may remove or edit it.
    1.39 -
    1.40 -   The file `configure.ac' (or `configure.in') is used to create
    1.41 -`configure' by a program called `autoconf'.  You only need
    1.42 -`configure.ac' if you want to change it or regenerate `configure' using
    1.43 -a newer version of `autoconf'.
    1.44 -
    1.45 -The simplest way to compile this package is:
    1.46 -
    1.47 -  1. `cd' to the directory containing the package's source code and type
    1.48 -     `./configure' to configure the package for your system.  If you're
    1.49 -     using `csh' on an old version of System V, you might need to type
    1.50 -     `sh ./configure' instead to prevent `csh' from trying to execute
    1.51 -     `configure' itself.
    1.52 -
    1.53 -     Running `configure' takes awhile.  While running, it prints some
    1.54 -     messages telling which features it is checking for.
    1.55 -
    1.56 -  2. Type `make' to compile the package.
    1.57 -
    1.58 -  3. Optionally, type `make check' to run any self-tests that come with
    1.59 -     the package.
    1.60 -
    1.61 -  4. Type `make install' to install the programs and any data files and
    1.62 -     documentation.
    1.63 -
    1.64 -  5. You can remove the program binaries and object files from the
    1.65 -     source code directory by typing `make clean'.  To also remove the
    1.66 -     files that `configure' created (so you can compile the package for
    1.67 -     a different kind of computer), type `make distclean'.  There is
    1.68 -     also a `make maintainer-clean' target, but that is intended mainly
    1.69 -     for the package's developers.  If you use it, you may have to get
    1.70 -     all sorts of other programs in order to regenerate files that came
    1.71 -     with the distribution.
    1.72 -
    1.73 -Compilers and Options
    1.74 -=====================
    1.75 -
    1.76 -Some systems require unusual options for compilation or linking that the
    1.77 -`configure' script does not know about.  Run `./configure --help' for
    1.78 -details on some of the pertinent environment variables.
    1.79 -
    1.80 -   You can give `configure' initial values for configuration parameters
    1.81 -by setting variables in the command line or in the environment.  Here
    1.82 -is an example:
    1.83 -
    1.84 -     ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
    1.85 -
    1.86 -   *Note Defining Variables::, for more details.
    1.87 -
    1.88 -Compiling For Multiple Architectures
    1.89 -====================================
    1.90 -
    1.91 -You can compile the package for more than one kind of computer at the
    1.92 -same time, by placing the object files for each architecture in their
    1.93 -own directory.  To do this, you must use a version of `make' that
    1.94 -supports the `VPATH' variable, such as GNU `make'.  `cd' to the
    1.95 -directory where you want the object files and executables to go and run
    1.96 -the `configure' script.  `configure' automatically checks for the
    1.97 -source code in the directory that `configure' is in and in `..'.
    1.98 -
    1.99 -   If you have to use a `make' that does not support the `VPATH'
   1.100 -variable, you have to compile the package for one architecture at a
   1.101 -time in the source code directory.  After you have installed the
   1.102 -package for one architecture, use `make distclean' before reconfiguring
   1.103 -for another architecture.
   1.104 -
   1.105 -Installation Names
   1.106 -==================
   1.107 -
   1.108 -By default, `make install' installs the package's commands under
   1.109 -`/usr/local/bin', include files under `/usr/local/include', etc.  You
   1.110 -can specify an installation prefix other than `/usr/local' by giving
   1.111 -`configure' the option `--prefix=PREFIX'.
   1.112 -
   1.113 -   You can specify separate installation prefixes for
   1.114 -architecture-specific files and architecture-independent files.  If you
   1.115 -pass the option `--exec-prefix=PREFIX' to `configure', the package uses
   1.116 -PREFIX as the prefix for installing programs and libraries.
   1.117 -Documentation and other data files still use the regular prefix.
   1.118 -
   1.119 -   In addition, if you use an unusual directory layout you can give
   1.120 -options like `--bindir=DIR' to specify different values for particular
   1.121 -kinds of files.  Run `configure --help' for a list of the directories
   1.122 -you can set and what kinds of files go in them.
   1.123 -
   1.124 -   If the package supports it, you can cause programs to be installed
   1.125 -with an extra prefix or suffix on their names by giving `configure' the
   1.126 -option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
   1.127 -
   1.128 -Optional Features
   1.129 -=================
   1.130 -
   1.131 -Some packages pay attention to `--enable-FEATURE' options to
   1.132 -`configure', where FEATURE indicates an optional part of the package.
   1.133 -They may also pay attention to `--with-PACKAGE' options, where PACKAGE
   1.134 -is something like `gnu-as' or `x' (for the X Window System).  The
   1.135 -`README' should mention any `--enable-' and `--with-' options that the
   1.136 -package recognizes.
   1.137 -
   1.138 -   For packages that use the X Window System, `configure' can usually
   1.139 -find the X include and library files automatically, but if it doesn't,
   1.140 -you can use the `configure' options `--x-includes=DIR' and
   1.141 -`--x-libraries=DIR' to specify their locations.
   1.142 -
   1.143 -Specifying the System Type
   1.144 -==========================
   1.145 -
   1.146 -There may be some features `configure' cannot figure out automatically,
   1.147 -but needs to determine by the type of machine the package will run on.
   1.148 -Usually, assuming the package is built to be run on the _same_
   1.149 -architectures, `configure' can figure that out, but if it prints a
   1.150 -message saying it cannot guess the machine type, give it the
   1.151 -`--build=TYPE' option.  TYPE can either be a short name for the system
   1.152 -type, such as `sun4', or a canonical name which has the form:
   1.153 -
   1.154 -     CPU-COMPANY-SYSTEM
   1.155 -
   1.156 -where SYSTEM can have one of these forms:
   1.157 -
   1.158 -     OS KERNEL-OS
   1.159 -
   1.160 -   See the file `config.sub' for the possible values of each field.  If
   1.161 -`config.sub' isn't included in this package, then this package doesn't
   1.162 -need to know the machine type.
   1.163 -
   1.164 -   If you are _building_ compiler tools for cross-compiling, you should
   1.165 -use the option `--target=TYPE' to select the type of system they will
   1.166 -produce code for.
   1.167 -
   1.168 -   If you want to _use_ a cross compiler, that generates code for a
   1.169 -platform different from the build platform, you should specify the
   1.170 -"host" platform (i.e., that on which the generated programs will
   1.171 -eventually be run) with `--host=TYPE'.
   1.172 -
   1.173 -Sharing Defaults
   1.174 -================
   1.175 -
   1.176 -If you want to set default values for `configure' scripts to share, you
   1.177 -can create a site shell script called `config.site' that gives default
   1.178 -values for variables like `CC', `cache_file', and `prefix'.
   1.179 -`configure' looks for `PREFIX/share/config.site' if it exists, then
   1.180 -`PREFIX/etc/config.site' if it exists.  Or, you can set the
   1.181 -`CONFIG_SITE' environment variable to the location of the site script.
   1.182 -A warning: not all `configure' scripts look for a site script.
   1.183 -
   1.184 -Defining Variables
   1.185 -==================
   1.186 -
   1.187 -Variables not defined in a site shell script can be set in the
   1.188 -environment passed to `configure'.  However, some packages may run
   1.189 -configure again during the build, and the customized values of these
   1.190 -variables may be lost.  In order to avoid this problem, you should set
   1.191 -them in the `configure' command line, using `VAR=value'.  For example:
   1.192 -
   1.193 -     ./configure CC=/usr/local2/bin/gcc
   1.194 -
   1.195 -causes the specified `gcc' to be used as the C compiler (unless it is
   1.196 -overridden in the site shell script).  Here is a another example:
   1.197 -
   1.198 -     /bin/bash ./configure CONFIG_SHELL=/bin/bash
   1.199 -
   1.200 -Here the `CONFIG_SHELL=/bin/bash' operand causes subsequent
   1.201 -configuration-related scripts to be executed by `/bin/bash'.
   1.202 -
   1.203 -`configure' Invocation
   1.204 -======================
   1.205 -
   1.206 -`configure' recognizes the following options to control how it operates.
   1.207 -
   1.208 -`--help'
   1.209 -`-h'
   1.210 -     Print a summary of the options to `configure', and exit.
   1.211 -
   1.212 -`--version'
   1.213 -`-V'
   1.214 -     Print the version of Autoconf used to generate the `configure'
   1.215 -     script, and exit.
   1.216 -
   1.217 -`--cache-file=FILE'
   1.218 -     Enable the cache: use and save the results of the tests in FILE,
   1.219 -     traditionally `config.cache'.  FILE defaults to `/dev/null' to
   1.220 -     disable caching.
   1.221 -
   1.222 -`--config-cache'
   1.223 -`-C'
   1.224 -     Alias for `--cache-file=config.cache'.
   1.225 -
   1.226 -`--quiet'
   1.227 -`--silent'
   1.228 -`-q'
   1.229 -     Do not print messages saying which checks are being made.  To
   1.230 -     suppress all normal output, redirect it to `/dev/null' (any error
   1.231 -     messages will still be shown).
   1.232 -
   1.233 -`--srcdir=DIR'
   1.234 -     Look for the package's source code in directory DIR.  Usually
   1.235 -     `configure' can determine that directory automatically.
   1.236 -
   1.237 -`configure' also accepts some other, not widely useful, options.  Run
   1.238 -`configure --help' for more details.
   1.239 -
     2.1 --- a/gmyth-stream/gmemcoder/Makefile.am	Tue Sep 18 13:45:04 2007 +0100
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,7 +0,0 @@
     2.4 -SUBDIRS = src
     2.5 -
     2.6 -EXTRA_DIST = 			\
     2.7 -	ChangeLog
     2.8 -	
     2.9 -DIST_SUBDIRS = 			\
    2.10 -	src
     3.1 --- a/gmyth-stream/gmemcoder/autogen.sh	Tue Sep 18 13:45:04 2007 +0100
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,19 +0,0 @@
     3.4 -#!/bin/sh
     3.5 -# Run this to generate all the initial makefiles, etc.
     3.6 -
     3.7 -srcdir=`dirname $0`
     3.8 -test -z "$srcdir" && srcdir=.
     3.9 -
    3.10 -PKG_NAME="gmemcoder"
    3.11 -
    3.12 -(test -f $srcdir/configure.ac) || {
    3.13 -    echo -n "**Error**: Directory "\`$srcdir\'" does not look like the"
    3.14 -    echo " top-level $PKG_NAME directory"
    3.15 -    exit 1
    3.16 -}
    3.17 -
    3.18 -which gnome-autogen.sh || {
    3.19 -    echo "You need to install gnome-common from the GNOME CVS"
    3.20 -    exit 1
    3.21 -}
    3.22 -REQUIRED_AUTOMAKE_VERSION=1.9 USE_GNOME2_MACROS=1 . gnome-autogen.sh
     4.1 --- a/gmyth-stream/gmemcoder/configure.ac	Tue Sep 18 13:45:04 2007 +0100
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,93 +0,0 @@
     4.4 -#                                               -*- Autoconf -*-
     4.5 -# Process this file with autoconf to produce a configure script.
     4.6 -
     4.7 -AC_PREREQ(2.50)
     4.8 -
     4.9 -AC_INIT([gmemcoder],[0.1])
    4.10 -
    4.11 -AC_CONFIG_MACRO_DIR([m4])
    4.12 -AC_CONFIG_HEADER(config.h)
    4.13 -
    4.14 -AS_VERSION(gmemcoder, GMEMCODER, 0, 1, 0, 0, GMEMCODER_SVN="no", GMEMCODER_SVN="yes")
    4.15 -GMEMCODER_MAJORMINOR=$GMEMCODER_VERSION.$GMEMCODER_MINOR_VERSION
    4.16 -AC_SUBST(GMEMCODER_MAJORMINOR)
    4.17 -
    4.18 -dnl AM_MAINTAINER_MODE provides the option to enable maintainer mode
    4.19 -AM_MAINTAINER_MODE
    4.20 -dnl make aclocal work in maintainer mode
    4.21 -AC_SUBST(ACLOCAL_AMFLAGS, "-I m4")
    4.22 -
    4.23 -AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
    4.24 -
    4.25 -# Checks for programs.
    4.26 -# check for tools
    4.27 -# Make sure CFLAGS is defined to stop AC_PROC_CC adding -g
    4.28 -CFLAGS="$CFLAGS -Wall"
    4.29 -AC_PROG_CC
    4.30 -AC_PROG_LIBTOOL
    4.31 -
    4.32 -# Checks for libraries.
    4.33 -
    4.34 -# Checks for header files.
    4.35 -AC_HEADER_STDC
    4.36 -
    4.37 -#Test if --disable-debug given
    4.38 -AC_ARG_ENABLE(debug,
    4.39 -	AC_HELP_STRING([--disable-debug], [enable debugging mode]))
    4.40 -if test x"$enable_debug" != xno; then
    4.41 -    CFLAGS="$CFLAGS -g -DMYTH_STREAM_USE_DEBUG"
    4.42 -else
    4.43 -    CFLAGS="$CFLAGS -O2 -DG_DISABLE_CHECKS"
    4.44 -fi          
    4.45 -
    4.46 -
    4.47 -# Checks required packages ####################################################
    4.48 -###############################################################################
    4.49 -
    4.50 -## Check for pkgconfig ########################################################
    4.51 -###############################################################################
    4.52 -AC_CHECK_PROG(HAVE_PKGCONFIG, pkg-config, yes, no)
    4.53 -if test "x$HAVE_PKGCONFIG" = "xno"; then
    4.54 -  AC_MSG_ERROR(you need to have pkgconfig installed !)
    4.55 -fi
    4.56 -
    4.57 -## Check for Glib2.0 ##########################################################
    4.58 -###############################################################################
    4.59 -PKG_CHECK_MODULES(GLIB, glib-2.0, HAVE_GLIB=yes,HAVE_GLIB=no)
    4.60 -if test "x$HAVE_GLIB" = "xno"; then
    4.61 -  AC_MSG_ERROR(you need glib-2.0 installed)
    4.62 -fi
    4.63 -AC_SUBST(GLIB_CFLAGS)
    4.64 -AC_SUBST(GLIB_LIBS)
    4.65 -
    4.66 -## Check for GnomeVFS ##########################################################
    4.67 -###############################################################################
    4.68 -PKG_CHECK_MODULES(GVFS, gnome-vfs-2.0, HAVE_GVFS=yes,HAVE_GVFS=no)
    4.69 -if test "x$HAVE_GVFS" = "xno"; then
    4.70 -  AC_MSG_ERROR(you need gnome-vfs-2.0 installed)
    4.71 -fi
    4.72 -AC_SUBST(GVFS_CFLAGS)
    4.73 -AC_SUBST(GVFS_LIBS)
    4.74 -
    4.75 -
    4.76 -## Check for gst-base #########################################################
    4.77 -###############################################################################
    4.78 -PKG_CHECK_MODULES(GST, [gstreamer-base-0.10])
    4.79 -AC_SUBST(GST_CFLAGS)
    4.80 -AC_SUBST(GST_LIBS)
    4.81 -
    4.82 -AC_SUBST(CFLAGS)
    4.83 -AC_SUBST(LDFLAGS)
    4.84 -AC_SUBST(LIBS)
    4.85 -
    4.86 -AC_OUTPUT([
    4.87 -Makefile
    4.88 -src/Makefile
    4.89 -])
    4.90 -
    4.91 -if test "x$enable_debug" != "xno"; then
    4.92 -    AC_MSG_NOTICE([Debug: Enabled])
    4.93 -else
    4.94 -    AC_MSG_NOTICE([Debug: Disabled])
    4.95 -fi          
    4.96 -
     5.1 --- a/gmyth-stream/gmemcoder/m4/as-compiler-flag.m4	Tue Sep 18 13:45:04 2007 +0100
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,32 +0,0 @@
     5.4 -dnl as-compiler-flag.m4 0.1.0
     5.5 -
     5.6 -dnl autostars m4 macro for detection of compiler flags
     5.7 -
     5.8 -dnl David Schleef <ds@schleef.org>
     5.9 -
    5.10 -dnl $Id: as-compiler-flag.m4,v 1.1 2005/06/18 18:02:46 burgerman Exp $
    5.11 -
    5.12 -dnl AS_COMPILER_FLAG(CFLAGS, ACTION-IF-ACCEPTED, [ACTION-IF-NOT-ACCEPTED])
    5.13 -dnl Tries to compile with the given CFLAGS.
    5.14 -dnl Runs ACTION-IF-ACCEPTED if the compiler can compile with the flags,
    5.15 -dnl and ACTION-IF-NOT-ACCEPTED otherwise.
    5.16 -
    5.17 -AC_DEFUN([AS_COMPILER_FLAG],
    5.18 -[
    5.19 -  AC_MSG_CHECKING([to see if compiler understands $1])
    5.20 -
    5.21 -  save_CFLAGS="$CFLAGS"
    5.22 -  CFLAGS="$CFLAGS $1"
    5.23 -
    5.24 -  AC_TRY_COMPILE([ ], [], [flag_ok=yes], [flag_ok=no])
    5.25 -  CFLAGS="$save_CFLAGS"
    5.26 -
    5.27 -  if test "X$flag_ok" = Xyes ; then
    5.28 -    $2
    5.29 -    true
    5.30 -  else
    5.31 -    $3
    5.32 -    true
    5.33 -  fi
    5.34 -  AC_MSG_RESULT([$flag_ok])
    5.35 -])
     6.1 --- a/gmyth-stream/gmemcoder/m4/as-expand.m4	Tue Sep 18 13:45:04 2007 +0100
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,40 +0,0 @@
     6.4 -dnl AS_AC_EXPAND(VAR, CONFIGURE_VAR)
     6.5 -dnl
     6.6 -dnl example
     6.7 -dnl AS_AC_EXPAND(SYSCONFDIR, $sysconfdir)
     6.8 -dnl will set SYSCONFDIR to /usr/local/etc if prefix=/usr/local
     6.9 -
    6.10 -AC_DEFUN([AS_AC_EXPAND],
    6.11 -[
    6.12 -  EXP_VAR=[$1]
    6.13 -  FROM_VAR=[$2]
    6.14 -
    6.15 -  dnl first expand prefix and exec_prefix if necessary
    6.16 -  prefix_save=$prefix
    6.17 -  exec_prefix_save=$exec_prefix
    6.18 -
    6.19 -  dnl if no prefix given, then use /usr/local, the default prefix
    6.20 -  if test "x$prefix" = "xNONE"; then
    6.21 -    prefix=$ac_default_prefix
    6.22 -  fi
    6.23 -  dnl if no exec_prefix given, then use prefix
    6.24 -  if test "x$exec_prefix" = "xNONE"; then
    6.25 -    exec_prefix=$prefix
    6.26 -  fi
    6.27 -
    6.28 -  full_var="$FROM_VAR"
    6.29 -  dnl loop until it doesn't change anymore
    6.30 -  while true; do
    6.31 -    new_full_var="`eval echo $full_var`"
    6.32 -    if test "x$new_full_var"="x$full_var"; then break; fi
    6.33 -    full_var=$new_full_var
    6.34 -  done
    6.35 -
    6.36 -  dnl clean up
    6.37 -  full_var=$new_full_var
    6.38 -  AC_SUBST([$1], "$full_var")
    6.39 -
    6.40 -  dnl restore prefix and exec_prefix
    6.41 -  prefix=$prefix_save
    6.42 -  exec_prefix=$exec_prefix_save
    6.43 -])
     7.1 --- a/gmyth-stream/gmemcoder/m4/as-version.m4	Tue Sep 18 13:45:04 2007 +0100
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,67 +0,0 @@
     7.4 -dnl as-version.m4 0.1.0
     7.5 -
     7.6 -dnl autostars m4 macro for versioning
     7.7 -
     7.8 -dnl Thomas Vander Stichele <thomas at apestaart dot org>
     7.9 -
    7.10 -dnl $Id: as-version.m4,v 1.1 2005/06/18 18:02:46 burgerman Exp $
    7.11 -
    7.12 -dnl AS_VERSION(PACKAGE, PREFIX, MAJOR, MINOR, MICRO, NANO,
    7.13 -dnl            ACTION-IF-NO-NANO, [ACTION-IF-NANO])
    7.14 -
    7.15 -dnl example
    7.16 -dnl AS_VERSION(gstreamer, GST_VERSION, 0, 3, 2,)
    7.17 -dnl for a 0.3.2 release version
    7.18 -
    7.19 -dnl this macro
    7.20 -dnl - defines [$PREFIX]_MAJOR, MINOR and MICRO
    7.21 -dnl - if NANO is empty, then we're in release mode, else in cvs/dev mode
    7.22 -dnl - defines [$PREFIX], VERSION, and [$PREFIX]_RELEASE
    7.23 -dnl - executes the relevant action
    7.24 -dnl - AC_SUBST's PACKAGE, VERSION, [$PREFIX] and [$PREFIX]_RELEASE
    7.25 -dnl   as well as the little ones
    7.26 -dnl - doesn't call AM_INIT_AUTOMAKE anymore because it prevents
    7.27 -dnl   maintainer mode from running ok
    7.28 -dnl
    7.29 -dnl don't forget to put #undef [$2] and [$2]_RELEASE in acconfig.h
    7.30 -dnl if you use acconfig.h
    7.31 -
    7.32 -AC_DEFUN([AS_VERSION],
    7.33 -[
    7.34 -  PACKAGE=[$1]
    7.35 -  [$2]_MAJOR=[$3]
    7.36 -  [$2]_MINOR=[$4]
    7.37 -  [$2]_MICRO=[$5]
    7.38 -  NANO=[$6]
    7.39 -  [$2]_NANO=$NANO
    7.40 -  if test "x$NANO" = "x" || test "x$NANO" = "x0";
    7.41 -  then
    7.42 -      AC_MSG_NOTICE(configuring [$1] for release)
    7.43 -      VERSION=[$3].[$4].[$5]
    7.44 -      [$2]_RELEASE=1
    7.45 -      dnl execute action
    7.46 -      ifelse([$7], , :, [$7])
    7.47 -  else
    7.48 -      AC_MSG_NOTICE(configuring [$1] for development with nano $NANO)
    7.49 -      VERSION=[$3].[$4].[$5].$NANO
    7.50 -      [$2]_RELEASE=0.`date +%Y%m%d.%H%M%S`
    7.51 -      dnl execute action
    7.52 -      ifelse([$8], , :, [$8])
    7.53 -  fi
    7.54 -
    7.55 -  [$2]=$VERSION
    7.56 -  AC_DEFINE_UNQUOTED([$2], "$[$2]", [Define the version])
    7.57 -  AC_SUBST([$2])
    7.58 -  AC_DEFINE_UNQUOTED([$2]_RELEASE, "$[$2]_RELEASE", [Define the release version])
    7.59 -  AC_SUBST([$2]_RELEASE)
    7.60 -
    7.61 -  AC_SUBST([$2]_MAJOR)
    7.62 -  AC_SUBST([$2]_MINOR)
    7.63 -  AC_SUBST([$2]_MICRO)
    7.64 -  AC_SUBST([$2]_NANO)
    7.65 -  AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Define the package name])
    7.66 -  AC_SUBST(PACKAGE)
    7.67 -  AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Define the version])
    7.68 -  AC_SUBST(VERSION)
    7.69 -])
    7.70 -
     8.1 --- a/gmyth-stream/gmemcoder/m4/gst-feature.m4	Tue Sep 18 13:45:04 2007 +0100
     8.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.3 @@ -1,211 +0,0 @@
     8.4 -dnl Perform a check for a feature for GStreamer
     8.5 -dnl Richard Boulton <richard-alsa@tartarus.org>
     8.6 -dnl Thomas Vander Stichele <thomas@apestaart.org> added useful stuff
     8.7 -dnl Last modification: 25/06/2001
     8.8 -dnl GST_CHECK_FEATURE(FEATURE-NAME, FEATURE-DESCRIPTION,
     8.9 -dnl                   DEPENDENT-PLUGINS, TEST-FOR-FEATURE,
    8.10 -dnl                   DISABLE-BY-DEFAULT, ACTION-IF-USE, ACTION-IF-NOTUSE)
    8.11 -dnl
    8.12 -dnl This macro adds a command line argument to enable the user to enable
    8.13 -dnl or disable a feature, and if the feature is enabled, performs a supplied
    8.14 -dnl test to check if the feature is available.
    8.15 -dnl
    8.16 -dnl The test should define HAVE_<FEATURE-NAME> to "yes" or "no" depending
    8.17 -dnl on whether the feature is available.
    8.18 -dnl
    8.19 -dnl The macro will set USE_<FEATURE-NAME> to "yes" or "no" depending on
    8.20 -dnl whether the feature is to be used.
    8.21 -dnl Thomas changed this, so that when USE_<FEATURE-NAME> was already set
    8.22 -dnl to no, then it stays that way.
    8.23 -dnl
    8.24 -dnl The macro will call AM_CONDITIONAL(USE_<<FEATURE-NAME>, ...) to allow
    8.25 -dnl the feature to control what is built in Makefile.ams.  If you want
    8.26 -dnl additional actions resulting from the test, you can add them with the
    8.27 -dnl ACTION-IF-USE and ACTION-IF-NOTUSE parameters.
    8.28 -dnl 
    8.29 -dnl FEATURE-NAME        is the name of the feature, and should be in
    8.30 -dnl                     purely upper case characters.
    8.31 -dnl FEATURE-DESCRIPTION is used to describe the feature in help text for
    8.32 -dnl                     the command line argument.
    8.33 -dnl DEPENDENT-PLUGINS   lists any plugins which depend on this feature.
    8.34 -dnl TEST-FOR-FEATURE    is a test which sets HAVE_<FEATURE-NAME> to "yes"
    8.35 -dnl                     or "no" depending on whether the feature is
    8.36 -dnl                     available.
    8.37 -dnl DISABLE-BY-DEFAULT  if "disabled", the feature is disabled by default,
    8.38 -dnl                     if any other value, the feature is enabled by default.
    8.39 -dnl ACTION-IF-USE       any extra actions to perform if the feature is to be
    8.40 -dnl                     used.
    8.41 -dnl ACTION-IF-NOTUSE    any extra actions to perform if the feature is not to
    8.42 -dnl                     be used.
    8.43 -dnl
    8.44 -dnl
    8.45 -dnl thomas :
    8.46 -dnl we also added a history.  
    8.47 -dnl GST_PLUGINS_YES will contain all plugins to be built
    8.48 -dnl                 that were checked through GST_CHECK_FEATURE
    8.49 -dnl GST_PLUGINS_NO will contain those that won't be built
    8.50 -
    8.51 -AC_DEFUN([GST_CHECK_FEATURE],
    8.52 -AC_MSG_NOTICE(***)
    8.53 -AC_MSG_NOTICE(*** checking plugin: [$3] ***)
    8.54 -AC_MSG_NOTICE(***)
    8.55 -[dnl
    8.56 -builtin(define, [gst_endisable], ifelse($5, [disabled], [enable], [disable]))dnl
    8.57 -dnl if it is set to NO, then don't even consider it for building
    8.58 -NOUSE=
    8.59 -if test "x$USE_[$1]" = "xno"; then
    8.60 -  NOUSE="yes"
    8.61 -fi
    8.62 -AC_ARG_ENABLE(translit([$1], A-Z, a-z),
    8.63 -  [  ]builtin(format, --%-26s gst_endisable %s, gst_endisable-translit([$1], A-Z, a-z), [$2]ifelse([$3],,,: [$3])),
    8.64 -  [ case "${enableval}" in
    8.65 -      yes) USE_[$1]=yes;;
    8.66 -      no) USE_[$1]=no;;
    8.67 -      *) AC_MSG_ERROR(bad value ${enableval} for --enable-translit([$1], A-Z, a-z)) ;;
    8.68 -    esac],
    8.69 -  [ USE_$1=]ifelse($5, [disabled], [no], [yes]))           dnl DEFAULT
    8.70 -
    8.71 -dnl *** set it back to no if it was preset to no
    8.72 -if test "x$NOUSE" = "xyes"; then
    8.73 -  USE_[$1]="no"
    8.74 -  AC_MSG_WARN(*** $3 pre-configured not to be built)
    8.75 -fi
    8.76 -NOUSE=
    8.77 -
    8.78 -dnl *** If it's enabled
    8.79 -
    8.80 -if test x$USE_[$1] = xyes; then
    8.81 -  dnl save compile variables before the test
    8.82 -
    8.83 -  gst_check_save_LIBS=$LIBS
    8.84 -  gst_check_save_LDFLAGS=$LDFLAGS
    8.85 -  gst_check_save_CFLAGS=$CFLAGS
    8.86 -  gst_check_save_CPPFLAGS=$CPPFLAGS
    8.87 -  gst_check_save_CXXFLAGS=$CXXFLAGS
    8.88 -
    8.89 -  HAVE_[$1]=no
    8.90 -  dnl TEST_FOR_FEATURE
    8.91 -  $4
    8.92 -
    8.93 -  LIBS=$gst_check_save_LIBS
    8.94 -  LDFLAGS=$gst_check_save_LDFLAGS
    8.95 -  CFLAGS=$gst_check_save_CFLAGS
    8.96 -  CPPFLAGS=$gst_check_save_CPPFLAGS
    8.97 -  CXXFLAGS=$gst_check_save_CXXFLAGS
    8.98 -
    8.99 -  dnl If it isn't found, unset USE_[$1]
   8.100 -  if test x$HAVE_[$1] = xno; then
   8.101 -    USE_[$1]=no
   8.102 -  fi
   8.103 -fi
   8.104 -dnl *** Warn if it's disabled or not found
   8.105 -if test x$USE_[$1] = xyes; then
   8.106 -  ifelse([$6], , :, [$6])
   8.107 -  if test "x$3" != "x"; then
   8.108 -    GST_PLUGINS_YES="\t[$3]\n$GST_PLUGINS_YES"
   8.109 -  fi
   8.110 -  AC_DEFINE(HAVE_[$1], , [support for features: $3])
   8.111 -else
   8.112 -  ifelse([$3], , :, [AC_MSG_NOTICE(*** These plugins will not be built: [$3])])
   8.113 -  if test "x$3" != "x"; then
   8.114 -    GST_PLUGINS_NO="\t[$3]\n$GST_PLUGINS_NO"
   8.115 -  fi
   8.116 -  ifelse([$7], , :, [$7])
   8.117 -fi
   8.118 -dnl *** Define the conditional as appropriate
   8.119 -AM_CONDITIONAL(USE_[$1], test x$USE_[$1] = xyes)
   8.120 -])
   8.121 -
   8.122 -dnl Use a -config program which accepts --cflags and --libs parameters
   8.123 -dnl to set *_CFLAGS and *_LIBS and check existence of a feature.
   8.124 -dnl Richard Boulton <richard-alsa@tartarus.org>
   8.125 -dnl Last modification: 26/06/2001
   8.126 -dnl GST_CHECK_CONFIGPROG(FEATURE-NAME, CONFIG-PROG-FILENAME, MODULES)
   8.127 -dnl
   8.128 -dnl This check was written for GStreamer: it should be renamed and checked
   8.129 -dnl for portability if you decide to use it elsewhere.
   8.130 -dnl
   8.131 -AC_DEFUN([GST_CHECK_CONFIGPROG],
   8.132 -[
   8.133 -  AC_PATH_PROG([$1]_CONFIG, [$2], no)
   8.134 -  if test x$[$1]_CONFIG = xno; then
   8.135 -    [$1]_LIBS=
   8.136 -    [$1]_CFLAGS=
   8.137 -    HAVE_[$1]=no
   8.138 -  else
   8.139 -    if [$2] --plugin-libs [$3] &> /dev/null; then
   8.140 -      [$1]_LIBS=`[$2] --plugin-libs [$3]`
   8.141 -    else
   8.142 -      [$1]_LIBS=`[$2] --libs [$3]`
   8.143 -    fi
   8.144 -    [$1]_CFLAGS=`[$2] --cflags [$3]`
   8.145 -    HAVE_[$1]=yes
   8.146 -  fi
   8.147 -  AC_SUBST([$1]_LIBS)
   8.148 -  AC_SUBST([$1]_CFLAGS)
   8.149 -])
   8.150 -
   8.151 -dnl Use AC_CHECK_LIB and AC_CHECK_HEADER to do both tests at once
   8.152 -dnl sets HAVE_module if we have it
   8.153 -dnl Richard Boulton <richard-alsa@tartarus.org>
   8.154 -dnl Last modification: 26/06/2001
   8.155 -dnl GST_CHECK_LIBHEADER(FEATURE-NAME, LIB NAME, LIB FUNCTION, EXTRA LD FLAGS, 
   8.156 -dnl                     HEADER NAME, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
   8.157 -dnl
   8.158 -dnl This check was written for GStreamer: it should be renamed and checked
   8.159 -dnl for portability if you decide to use it elsewhere.
   8.160 -dnl
   8.161 -AC_DEFUN([GST_CHECK_LIBHEADER],
   8.162 -[
   8.163 -  AC_CHECK_LIB([$2], [$3], HAVE_[$1]=yes, HAVE_[$1]=no,[$4])
   8.164 -  if test "x$HAVE_[$1]" = "xyes"; then
   8.165 -    AC_CHECK_HEADER([$5], :, HAVE_[$1]=no)
   8.166 -    if test "x$HAVE_[$1]" = "xyes"; then
   8.167 -      dnl execute what needs to be
   8.168 -      ifelse([$6], , :, [$6])
   8.169 -    else
   8.170 -      ifelse([$7], , :, [$7])
   8.171 -    fi
   8.172 -  else
   8.173 -    ifelse([$7], , :, [$7])
   8.174 -  fi
   8.175 -  AC_SUBST(HAVE_[$1])
   8.176 -]
   8.177 -)
   8.178 -
   8.179 -dnl 2004-02-14 Thomas - changed to get set properly and use proper output
   8.180 -dnl 2003-06-27 Benjamin Otte - changed to make this work with gstconfig.h
   8.181 -dnl
   8.182 -dnl Add a subsystem --disable flag and all the necessary symbols and substitions
   8.183 -dnl
   8.184 -dnl GST_CHECK_SUBSYSTEM_DISABLE(SYSNAME, [subsystem name])
   8.185 -dnl
   8.186 -AC_DEFUN([GST_CHECK_SUBSYSTEM_DISABLE],
   8.187 -[
   8.188 -  dnl this define will replace each literal subsys_def occurrence with
   8.189 -  dnl the lowercase hyphen-separated subsystem
   8.190 -  dnl e.g. if $1 is GST_DEBUG then subsys_def will be a macro with gst-debug
   8.191 -  define([subsys_def],translit([$1], _A-Z, -a-z))
   8.192 -
   8.193 -  AC_ARG_ENABLE(subsys_def, 
   8.194 -    AC_HELP_STRING(--disable-subsys_def, [disable $2]),
   8.195 -    [
   8.196 -      case "${enableval}" in
   8.197 -        yes) GST_DISABLE_[$1]=no ;;
   8.198 -        no) GST_DISABLE_[$1]=yes ;;
   8.199 -        *) AC_MSG_ERROR([bad value ${enableval} for --enable-subsys_def]) ;;
   8.200 -       esac
   8.201 -    ],
   8.202 -    [GST_DISABLE_[$1]=no]) dnl Default value
   8.203 -
   8.204 -  if test x$GST_DISABLE_[$1] = xyes; then
   8.205 -    AC_MSG_NOTICE([disabled subsystem [$2]])
   8.206 -    GST_DISABLE_[$1]_DEFINE="#define GST_DISABLE_$1 1" 
   8.207 -  else
   8.208 -    GST_DISABLE_[$1]_DEFINE="/* #undef GST_DISABLE_$1 */"
   8.209 -  fi
   8.210 -  AC_SUBST(GST_DISABLE_[$1]_DEFINE)
   8.211 -  undefine([subsys_def])
   8.212 -])
   8.213 -
   8.214 -
     9.1 --- a/gmyth-stream/gmemcoder/src/Makefile.am	Tue Sep 18 13:45:04 2007 +0100
     9.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.3 @@ -1,20 +0,0 @@
     9.4 -bin_PROGRAMS = \
     9.5 -	gmencoder
     9.6 -
     9.7 -gmencoder_SOURCES = \
     9.8 -	main.c \
     9.9 -	gmencoder.c \
    9.10 -	gmencoder.h 
    9.11 -	
    9.12 -gmencoder_LDADD = \
    9.13 -	$(GLIB_LIBS) \
    9.14 -	$(GST_LIBS) \
    9.15 -	$(GVFS_LIBS) \
    9.16 -	-lgstinterfaces-0.10
    9.17 -
    9.18 -AM_CPPFLAGS = \
    9.19 -	$(GLIB_CFLAGS) \
    9.20 -	$(GST_CFLAGS) \
    9.21 -    $(GVFS_CFLAGS)
    9.22 -
    9.23 -CLEANFILES = 
    10.1 --- a/gmyth-stream/gmemcoder/src/gmencoder.c	Tue Sep 18 13:45:04 2007 +0100
    10.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.3 @@ -1,1207 +0,0 @@
    10.4 -#ifdef HAVE_CONFIG_H
    10.5 -#include "config.h"
    10.6 -#endif
    10.7 -
    10.8 -#include <sys/stat.h>
    10.9 -#include <fcntl.h>
   10.10 -#include <unistd.h>
   10.11 -#include <glib.h>
   10.12 -#include <gst/gst.h>
   10.13 -#include <string.h>
   10.14 -#include <sys/types.h>
   10.15 -#include <sys/socket.h>
   10.16 -#include <libgnomevfs/gnome-vfs.h>
   10.17 -#include <gst/interfaces/tuner.h>
   10.18 -
   10.19 -#include "gmencoder.h"
   10.20 -
   10.21 -#define G_MENCODER_GET_PRIVATE(obj) \
   10.22 -    (G_TYPE_INSTANCE_GET_PRIVATE ((obj), G_TYPE_MENCODER, GMencoderPrivate))
   10.23 -
   10.24 -#define USE_MANUAL_SINK
   10.25 -#define GMENCODER_TIMEOUT	5000
   10.26 -
   10.27 -typedef struct _GMencoderPrivate GMencoderPrivate;
   10.28 -typedef struct _SetupInfo SetupInfo;
   10.29 -
   10.30 -struct _SetupInfo {
   10.31 -    gchar          *video_encode;
   10.32 -    gchar          *mux_name;
   10.33 -    gchar         **video_encode_prop;
   10.34 -    gdouble         video_fps;
   10.35 -    gdouble         video_rate;
   10.36 -    guint           video_width;
   10.37 -    guint           video_height;
   10.38 -    gchar          *audio_encode;
   10.39 -    gchar         **audio_encode_prop;
   10.40 -    guint           audio_rate;
   10.41 -};
   10.42 -
   10.43 -
   10.44 -struct _GMencoderPrivate {
   10.45 -    GstElement     *pipe;
   10.46 -    GstElement     *abin;
   10.47 -    GstElement     *vbin;
   10.48 -    GstElement     *sink;
   10.49 -    GstElement     *src;
   10.50 -
   10.51 -    GnomeVFSHandle  *handle;
   10.52 -
   10.53 -    gboolean        ready;
   10.54 -    SetupInfo      *info;
   10.55 -    GstClockTime    videot;
   10.56 -    GstClockTime    audiot;
   10.57 -    gint            sources;
   10.58 -    gint            tick_id;
   10.59 -    gint64          duration;
   10.60 -    gboolean        send_chunked;
   10.61 -    gint 	    timeout_id;
   10.62 -
   10.63 -    //V4l info
   10.64 -    GstElement *v4lsrc;
   10.65 -    gchar *channel;
   10.66 -    gchar *norm;
   10.67 -    glong frequency;
   10.68 -};
   10.69 -
   10.70 -enum {
   10.71 -    PAUSED,
   10.72 -    PLAYING,
   10.73 -    STOPED,
   10.74 -    EOS,
   10.75 -    ERROR,
   10.76 -    LAST_SIGNAL
   10.77 -};
   10.78 -
   10.79 -static void     g_mencoder_class_init(GMencoderClass * klass);
   10.80 -static void     g_mencoder_init(GMencoder * object);
   10.81 -static void     g_mencoder_dispose(GObject * object);
   10.82 -static void     g_mencoder_finalize(GObject * object);
   10.83 -static GstElement *_create_audio_bin(const gchar * encode,
   10.84 -                                     gchar ** encode_prop, gint rate);
   10.85 -static GstElement *_create_video_bin(const gchar * encode,
   10.86 -                                     gchar ** encode_prop,
   10.87 -                                     gdouble fps,
   10.88 -                                     gint rate, guint width, guint height,
   10.89 -                                     gboolean use_deinterlace);
   10.90 -
   10.91 -static          gboolean
   10.92 -_pipeline_bus_cb(GstBus * bus, GstMessage * msg, gpointer user_data);
   10.93 -
   10.94 -static void     _decodebin_new_pad_cb(GstElement * object,
   10.95 -                                      GstPad * pad,
   10.96 -                                      gboolean flag, gpointer user_data);
   10.97 -
   10.98 -static void     _decodebin_unknown_type_cb(GstElement * object,
   10.99 -                                           GstPad * pad,
  10.100 -                                           GstCaps * caps,
  10.101 -                                           gpointer user_data);
  10.102 -
  10.103 -static void     _close_output(GMencoder * self);
  10.104 -static gboolean _open_output(GMencoder * self, const gchar * uri);
  10.105 -
  10.106 -static GstElement *_create_source(GMencoder *self, const gchar * uri);
  10.107 -static GstElement *_create_pipeline(GMencoder * self,
  10.108 -                                    const gchar * video_encode,
  10.109 -                                    const gchar * mux_name,
  10.110 -                                    gchar ** video_encode_prop,
  10.111 -                                    gdouble video_fps,
  10.112 -                                    gdouble video_rate,
  10.113 -                                    guint video_width,
  10.114 -                                    guint video_height,
  10.115 -                                    const gchar * audio_encode,
  10.116 -                                    gchar ** audio_encode_prop,
  10.117 -                                    guint audio_rate,
  10.118 -				    gboolean deinterlace);
  10.119 -static gboolean	_process_timeout_cb (gpointer user_data);
  10.120 -#ifdef USE_MANUAL_SINK
  10.121 -static void _flush_queue	        (GMencoder *self);
  10.122 -static void _buffer_arrive_cb       (GstElement* object,
  10.123 -                                     GstBuffer* buff,
  10.124 -                                     GstPad* pad,
  10.125 -                                     gpointer user_data);
  10.126 -#endif
  10.127 -
  10.128 -
  10.129 -static gboolean _tick_cb(gpointer data);
  10.130 -
  10.131 -static guint    g_mencoder_signals[LAST_SIGNAL] = { 0 };
  10.132 -
  10.133 -G_DEFINE_TYPE(GMencoder, g_mencoder, G_TYPE_OBJECT)
  10.134 -
  10.135 -static void     g_mencoder_class_init(GMencoderClass * klass)
  10.136 -{
  10.137 -    GObjectClass   *object_class;
  10.138 -    object_class = (GObjectClass *) klass;
  10.139 -    g_type_class_add_private(klass, sizeof(GMencoderPrivate));
  10.140 -
  10.141 -    object_class->dispose = g_mencoder_dispose;
  10.142 -    object_class->finalize = g_mencoder_finalize;
  10.143 -
  10.144 -    g_mencoder_signals[PAUSED] =
  10.145 -        g_signal_new("paused",
  10.146 -                     G_OBJECT_CLASS_TYPE(object_class),
  10.147 -                     G_SIGNAL_RUN_FIRST,
  10.148 -                     0, NULL, NULL,
  10.149 -                     g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
  10.150 -
  10.151 -    g_mencoder_signals[PLAYING] =
  10.152 -        g_signal_new("playing",
  10.153 -                     G_OBJECT_CLASS_TYPE(object_class),
  10.154 -                     G_SIGNAL_RUN_FIRST,
  10.155 -                     0, NULL, NULL,
  10.156 -                     g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
  10.157 -
  10.158 -    g_mencoder_signals[STOPED] =
  10.159 -        g_signal_new("stoped",
  10.160 -                     G_OBJECT_CLASS_TYPE(object_class),
  10.161 -                     G_SIGNAL_RUN_FIRST,
  10.162 -                     0, NULL, NULL,
  10.163 -                     g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
  10.164 -
  10.165 -    g_mencoder_signals[EOS] =
  10.166 -        g_signal_new("eos",
  10.167 -                     G_OBJECT_CLASS_TYPE(object_class),
  10.168 -                     G_SIGNAL_RUN_FIRST,
  10.169 -                     0, NULL, NULL,
  10.170 -                     g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
  10.171 -
  10.172 -    g_mencoder_signals[ERROR] =
  10.173 -        g_signal_new("error",
  10.174 -                     G_OBJECT_CLASS_TYPE(object_class),
  10.175 -                     G_SIGNAL_RUN_LAST,
  10.176 -                     0, NULL, NULL,
  10.177 -                     g_cclosure_marshal_VOID__STRING,
  10.178 -                     G_TYPE_NONE, 1, G_TYPE_STRING);
  10.179 -}
  10.180 -
  10.181 -static void
  10.182 -g_mencoder_init(GMencoder * self)
  10.183 -{
  10.184 -    GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(self);
  10.185 -    priv->info = g_new0(SetupInfo, 1);
  10.186 -}
  10.187 -
  10.188 -static void
  10.189 -g_mencoder_dispose(GObject * object)
  10.190 -{
  10.191 -}
  10.192 -
  10.193 -static void
  10.194 -g_mencoder_finalize(GObject * object)
  10.195 -{
  10.196 -    GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(object);
  10.197 -
  10.198 -    // TODO: clear vars
  10.199 -    g_mencoder_close_stream(G_MENCODER(object));
  10.200 -    g_free (priv->info);
  10.201 -}
  10.202 -
  10.203 -GMencoder      *
  10.204 -g_mencoder_new(void)
  10.205 -{
  10.206 -    return g_object_new(G_TYPE_MENCODER, NULL);
  10.207 -}
  10.208 -
  10.209 -
  10.210 -static void
  10.211 -_obj_set_prop(GObject * obj, const gchar * prop_name,
  10.212 -              const gchar * prop_val)
  10.213 -{
  10.214 -    GValue          p = { 0 };
  10.215 -    GValue          v = { 0 };
  10.216 -    GParamSpec     *s = NULL;
  10.217 -    GObjectClass   *k = G_OBJECT_GET_CLASS(obj);
  10.218 -
  10.219 -
  10.220 -    g_value_init(&v, G_TYPE_STRING);
  10.221 -    g_value_set_string(&v, prop_val);
  10.222 -
  10.223 -    s = g_object_class_find_property(k, prop_name);
  10.224 -    if (s == NULL) {
  10.225 -        g_print("Invalid property name: %s\n", prop_name);
  10.226 -        return;
  10.227 -    }
  10.228 -
  10.229 -    g_value_init(&p, s->value_type);
  10.230 -    switch (s->value_type) {
  10.231 -    case G_TYPE_INT:
  10.232 -        g_value_set_int(&p, atoi(prop_val));
  10.233 -        break;
  10.234 -    case G_TYPE_ULONG:
  10.235 -        g_value_set_ulong (&p, atol(prop_val));
  10.236 -        break;
  10.237 -    case G_TYPE_STRING:
  10.238 -        g_value_set_string(&p, prop_val);
  10.239 -        break;
  10.240 -    case G_TYPE_BOOLEAN:
  10.241 -        g_value_set_boolean(&p, (gboolean) atoi (prop_val));
  10.242 -        break;
  10.243 -    case G_TYPE_DOUBLE:
  10.244 -        g_value_set_double(&p, atof (prop_val));
  10.245 -        break;
  10.246 -    case G_TYPE_FLOAT:
  10.247 -        g_value_set_float(&p, (float) atof (prop_val));
  10.248 -        break;
  10.249 -    default:
  10.250 -        g_value_set_enum(&p, atoi(prop_val));
  10.251 -        g_warning ("Property %s of type %s. Not supported using default enum", 
  10.252 -                   prop_name, g_type_name (s->value_type));
  10.253 -        return;
  10.254 -    }
  10.255 -
  10.256 -    g_object_set_property(obj, prop_name, &p);
  10.257 -    g_value_unset(&v);
  10.258 -    g_value_unset(&p);
  10.259 -}
  10.260 -
  10.261 -static GstElement *
  10.262 -_create_element_with_prop(const gchar * factory_name,
  10.263 -                          const gchar * element_name, gchar ** prop)
  10.264 -{
  10.265 -    GstElement     *ret;
  10.266 -    int             i;
  10.267 -
  10.268 -    ret = gst_element_factory_make(factory_name, element_name);
  10.269 -    if (ret == NULL)
  10.270 -        return NULL;
  10.271 -
  10.272 -    if (prop != NULL) {
  10.273 -        for (i = 0; i < g_strv_length(prop); i++) {
  10.274 -            if (prop[i] != NULL) {
  10.275 -                char **v = g_strsplit(prop[i], "=", 2);
  10.276 -                if (g_strv_length(v) == 2) {
  10.277 -                    _obj_set_prop(G_OBJECT(ret), v[0], v[1]);
  10.278 -                }
  10.279 -                g_strfreev(v);
  10.280 -            }
  10.281 -        }
  10.282 -    }
  10.283 -
  10.284 -    return ret;
  10.285 -
  10.286 -}
  10.287 -
  10.288 -static GstElement *
  10.289 -_create_audio_bin(const gchar * encode, gchar ** encode_prop, gint rate)
  10.290 -{
  10.291 -    GstElement     *abin = NULL;
  10.292 -    GstElement     *aqueue = NULL;
  10.293 -    GstElement     *aconvert = NULL;
  10.294 -    GstElement     *aencode = NULL;
  10.295 -    GstElement     *aqueue_src = NULL;
  10.296 -    GstPad         *apad = NULL;
  10.297 -
  10.298 -    // audio/x-raw-int ! queue ! audioconvert ! faac ! rtpmp4gpay !
  10.299 -    // udpsink name=upd_audio host=224.0.0.1 port=5002
  10.300 -    abin = gst_bin_new("abin");
  10.301 -    aqueue = gst_element_factory_make("queue", "aqueue");
  10.302 -    aconvert = gst_element_factory_make("audioconvert", "aconvert");
  10.303 -    aencode =
  10.304 -        _create_element_with_prop((encode ? encode : "lame"), "aencode",
  10.305 -                                  encode_prop);
  10.306 -    aqueue_src = gst_element_factory_make("queue", "aqueue_src");
  10.307 -
  10.308 -    if ((abin == NULL) || (aqueue == NULL) || (aconvert == NULL)
  10.309 -        || (aencode == NULL) || (aqueue_src == NULL)) {
  10.310 -        g_warning("Audio elements not found");
  10.311 -        goto error;
  10.312 -    }
  10.313 -
  10.314 -    g_object_set(G_OBJECT(aencode), "bitrate", 32, NULL);
  10.315 -    /*
  10.316 -     * if (rate > 0) { g_object_set (G_OBJECT (aencode), "bitrate", 32,
  10.317 -     * NULL); } 
  10.318 -     */
  10.319 -
  10.320 -    gst_bin_add_many(GST_BIN(abin), aqueue, aconvert, aencode, aqueue_src,
  10.321 -                     NULL);
  10.322 -    if (gst_element_link_many(aqueue, aconvert, aencode, aqueue_src, NULL)
  10.323 -        == FALSE) {
  10.324 -        g_warning("Not Link audio elements");
  10.325 -    }
  10.326 -    // TODO: apply audio rate
  10.327 -
  10.328 -    // ghost pad the audio bin
  10.329 -    apad = gst_element_get_pad(aqueue, "sink");
  10.330 -    gst_element_add_pad(abin, gst_ghost_pad_new("sink", apad));
  10.331 -    gst_object_unref(apad);
  10.332 -
  10.333 -    apad = gst_element_get_pad(aqueue_src, "src");
  10.334 -    gst_element_add_pad(abin, gst_ghost_pad_new("src", apad));
  10.335 -    gst_object_unref(apad);
  10.336 -
  10.337 -    return abin;
  10.338 -  error:
  10.339 -    if (abin != NULL)
  10.340 -        gst_object_unref(abin);
  10.341 -
  10.342 -    if (aqueue != NULL)
  10.343 -        gst_object_unref(aqueue);
  10.344 -
  10.345 -    if (aconvert != NULL)
  10.346 -        gst_object_unref(aconvert);
  10.347 -
  10.348 -    if (aencode != NULL)
  10.349 -        gst_object_unref(aencode);
  10.350 -
  10.351 -    if (aqueue_src != NULL)
  10.352 -        gst_object_unref(aqueue_src);
  10.353 -
  10.354 -    if (apad != NULL)
  10.355 -        gst_object_unref(apad);
  10.356 -
  10.357 -    return NULL;
  10.358 -}
  10.359 -
  10.360 -
  10.361 -
  10.362 -
  10.363 -// queue ! videoscale ! video/x-raw-yuv,width=240,height=144 ! colorspace
  10.364 -// ! rate ! encode ! queue
  10.365 -static GstElement *
  10.366 -_create_video_bin(const gchar * encode,
  10.367 -                  gchar ** encode_prop,
  10.368 -                  gdouble fps, gint rate, guint width, guint height,
  10.369 -                  gboolean use_deinterlace)
  10.370 -{
  10.371 -    GstElement     *vbin = NULL;
  10.372 -    GstElement     *vqueue = NULL;
  10.373 -    GstElement     *vqueue_src = NULL;
  10.374 -    GstElement     *vcolorspace = NULL;
  10.375 -    GstElement     *vencode = NULL;
  10.376 -    GstElement     *vrate = NULL;
  10.377 -    GstElement	   *deinterlace = NULL;
  10.378 -    GstElement     *walk = NULL;
  10.379 -    GstPad         *vpad = NULL;
  10.380 -
  10.381 -    vbin = gst_bin_new("vbin");
  10.382 -    vqueue = gst_element_factory_make("queue", "vqueue");
  10.383 -    vcolorspace =
  10.384 -        gst_element_factory_make("ffmpegcolorspace", "colorspace");
  10.385 -
  10.386 -    if (use_deinterlace) {
  10.387 -        deinterlace = gst_element_factory_make ("ffdeinterlace", "deinterlace");
  10.388 -	    if (deinterlace == NULL) {
  10.389 -	        g_warning ("Fail to create deinterlace element: Continue without deinterlace.");
  10.390 -        }
  10.391 -    }
  10.392 -
  10.393 -
  10.394 -    vencode = _create_element_with_prop((encode !=
  10.395 -                                         NULL ? encode :
  10.396 -                                         "ffenc_mpeg1video"), "vencode",
  10.397 -                                        encode_prop);
  10.398 -    vqueue_src = gst_element_factory_make("queue", "queue_src");
  10.399 -
  10.400 -    if ((vbin == NULL) || (vqueue == NULL) || (vcolorspace == NULL)
  10.401 -        || (vencode == NULL) || (vqueue_src == NULL)) {
  10.402 -        g_warning("Video elements not found");
  10.403 -        goto error;
  10.404 -    }
  10.405 -
  10.406 -    gst_bin_add_many(GST_BIN(vbin), vqueue, vcolorspace, vencode,
  10.407 -                     vqueue_src, NULL);
  10.408 -
  10.409 -    if (deinterlace != NULL) {
  10.410 -        gst_bin_add(GST_BIN(vbin), deinterlace);
  10.411 -        gst_element_link (vqueue, deinterlace);
  10.412 -        walk = deinterlace;
  10.413 -    } else {
  10.414 -        walk = vqueue;
  10.415 -    }
  10.416 -
  10.417 -    if ((width > 0) && (height > 0)) {
  10.418 -        // Scalling video
  10.419 -        GstCaps        *vcaps;
  10.420 -        GstElement     *vscale =
  10.421 -            gst_element_factory_make("videoscale", "vscale");
  10.422 -
  10.423 -	g_object_set (G_OBJECT (vscale), "method", 1, NULL);
  10.424 -
  10.425 -        gst_bin_add(GST_BIN(vbin), vscale);
  10.426 -
  10.427 -        vcaps = gst_caps_new_simple("video/x-raw-yuv",
  10.428 -                                    "width", G_TYPE_INT, width,
  10.429 -                                    "height", G_TYPE_INT, height, NULL);
  10.430 -
  10.431 -        gst_element_link(walk, vscale);
  10.432 -
  10.433 -        if (gst_element_link_filtered(vscale, vcolorspace, vcaps) == FALSE) {
  10.434 -            g_warning("Fail to resize video");
  10.435 -            gst_object_unref(vcaps);
  10.436 -            gst_object_unref(vscale);
  10.437 -            goto error;
  10.438 -        }
  10.439 -        gst_caps_unref(vcaps);
  10.440 -    } else {
  10.441 -        gst_element_link(walk, vcolorspace);
  10.442 -    }
  10.443 -
  10.444 -    if (fps > 0) {
  10.445 -        // Changing the video fps
  10.446 -        GstCaps        *vcaps;
  10.447 -        vrate = gst_element_factory_make("videorate", "vrate");
  10.448 -
  10.449 -        gst_bin_add(GST_BIN(vbin), vrate);
  10.450 -
  10.451 -        if (gst_element_link(vcolorspace, vrate) == FALSE) {
  10.452 -            g_warning("Fail to link video elements");
  10.453 -            goto error;
  10.454 -        }
  10.455 -
  10.456 -        vcaps = gst_caps_new_simple("video/x-raw-yuv",
  10.457 -                                    "framerate", GST_TYPE_FRACTION,
  10.458 -                                    (int) (fps * 1000), 1000, NULL);
  10.459 -
  10.460 -        if (gst_element_link_filtered(vrate, vencode, vcaps) == FALSE) {
  10.461 -            g_warning("Fail to link vrate with vencode.");
  10.462 -            goto error;
  10.463 -        }
  10.464 -        gst_caps_unref(vcaps);
  10.465 -    } else {
  10.466 -        if (gst_element_link(vcolorspace, vencode) == FALSE) {
  10.467 -            g_warning("Fail to link colorspace and video encode element.");
  10.468 -            goto error;
  10.469 -        }
  10.470 -    }
  10.471 -
  10.472 -    gst_element_link(vencode, vqueue_src);
  10.473 -
  10.474 -    // ghost pad the video bin
  10.475 -    vpad = gst_element_get_pad(vqueue, "sink");
  10.476 -    gst_element_add_pad(vbin, gst_ghost_pad_new("sink", vpad));
  10.477 -    gst_object_unref(vpad);
  10.478 -
  10.479 -    vpad = gst_element_get_pad(vqueue_src, "src");
  10.480 -    gst_element_add_pad(vbin, gst_ghost_pad_new("src", vpad));
  10.481 -    gst_object_unref(vpad);
  10.482 -
  10.483 -    return vbin;
  10.484 -
  10.485 -  error:
  10.486 -    if (vpad != NULL)
  10.487 -        gst_object_unref(vpad);
  10.488 -
  10.489 -    if (vbin != NULL)
  10.490 -        gst_object_unref(vbin);
  10.491 -
  10.492 -    if (vqueue != NULL)
  10.493 -        gst_object_unref(vqueue);
  10.494 -
  10.495 -    if (vencode != NULL)
  10.496 -        gst_object_unref(vencode);
  10.497 -
  10.498 -    if (vqueue_src != NULL)
  10.499 -        gst_object_unref(vqueue_src);
  10.500 -
  10.501 -    if (vcolorspace != NULL)
  10.502 -        gst_object_unref(vcolorspace);
  10.503 -
  10.504 -    return NULL;
  10.505 -}
  10.506 -
  10.507 -
  10.508 -
  10.509 -gboolean 
  10.510 -g_mencoder_setup_stream(GMencoder * self,
  10.511 -			gboolean chunked,
  10.512 -			gboolean deinterlace,
  10.513 -                        const gchar * mux_name,
  10.514 -                        const gchar * video_encode,
  10.515 -                        gchar ** video_encode_prop,
  10.516 -                        gdouble video_fps,
  10.517 -                        gdouble video_rate,
  10.518 -                        guint video_width,
  10.519 -                        guint video_height,
  10.520 -                        const gchar * audio_encode,
  10.521 -                        gchar ** audio_encode_prop,
  10.522 -                        guint audio_rate, const gchar * out_uri)
  10.523 -{
  10.524 -    GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(self);
  10.525 -    if (priv->ready == TRUE) {
  10.526 -        g_warning
  10.527 -            ("Stream already configured. You need close stream first.");
  10.528 -        return FALSE;
  10.529 -    }
  10.530 -
  10.531 -    _close_output(self);
  10.532 -    if (_open_output(self, out_uri) == FALSE) {	
  10.533 -        return FALSE;
  10.534 -    }
  10.535 -
  10.536 -    priv->sources = 0;
  10.537 -    priv->send_chunked = chunked;
  10.538 -    priv->pipe = _create_pipeline(self,
  10.539 -                                  video_encode,
  10.540 -                                  mux_name,
  10.541 -                                  video_encode_prop,
  10.542 -                                  video_fps,
  10.543 -                                  video_rate,
  10.544 -                                  video_width,
  10.545 -                                  video_height,
  10.546 -                                  audio_encode, audio_encode_prop,
  10.547 -                                  audio_rate,
  10.548 -                                  deinterlace);
  10.549 -
  10.550 -    return (priv->pipe != NULL);
  10.551 -}
  10.552 -
  10.553 -
  10.554 -gboolean
  10.555 -g_mencoder_append_uri(GMencoder * self, const gchar * uri)
  10.556 -{
  10.557 -    GstPad         *pad_src;
  10.558 -    GstPad         *pad_sink;
  10.559 -    GstElement     *src;
  10.560 -    GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(self);
  10.561 -    gboolean        ret = FALSE;
  10.562 -    GstElement     *ap = NULL;
  10.563 -    GstElement     *vp = NULL;
  10.564 -
  10.565 -
  10.566 -    g_return_val_if_fail(priv->pipe != NULL, FALSE);
  10.567 -    g_return_val_if_fail(priv->ready == FALSE, FALSE);
  10.568 -
  10.569 -    src = _create_source(self, uri);
  10.570 -    if (src == NULL)
  10.571 -        return FALSE;
  10.572 -
  10.573 -    priv->src = gst_bin_get_by_name(GST_BIN(src), "src");
  10.574 -
  10.575 -    gst_bin_add(GST_BIN(priv->pipe), src);
  10.576 -
  10.577 -    ap = gst_bin_get_by_name(GST_BIN(priv->pipe), "abin");
  10.578 -    vp = gst_bin_get_by_name(GST_BIN(priv->pipe), "vbin");
  10.579 -
  10.580 -    if ((vp == NULL) || (ap == NULL)) {
  10.581 -        g_warning("Fail to get output bin");
  10.582 -        goto error;
  10.583 -    }
  10.584 -
  10.585 -    pad_src = gst_element_get_pad(src, "src_audio");
  10.586 -    pad_sink = gst_element_get_compatible_pad(ap,
  10.587 -                                              pad_src,
  10.588 -                                              gst_pad_get_caps(pad_src));
  10.589 -
  10.590 -    if ((pad_sink == NULL) || (pad_src == NULL))
  10.591 -        goto error;
  10.592 -
  10.593 -    GstPadLinkReturn lret = gst_pad_link(pad_src, pad_sink);
  10.594 -    if (lret != GST_PAD_LINK_OK)
  10.595 -        goto error;
  10.596 -
  10.597 -    gst_object_unref(pad_src);
  10.598 -    gst_object_unref(pad_sink);
  10.599 -
  10.600 -    pad_src = gst_element_get_pad(src, "src_video");
  10.601 -    pad_sink = gst_element_get_compatible_pad(vp,
  10.602 -                                              pad_src,
  10.603 -                                              gst_pad_get_caps(pad_src));
  10.604 -
  10.605 -    if ((pad_src == NULL) || (pad_sink == NULL))
  10.606 -        goto error;
  10.607 -
  10.608 -    if (gst_pad_link(pad_src, pad_sink) != GST_PAD_LINK_OK) {
  10.609 -        g_warning("invalid source. video");
  10.610 -        goto error;
  10.611 -    }
  10.612 -
  10.613 -    priv->sources++;
  10.614 -    ret = TRUE;
  10.615 -  error:
  10.616 -
  10.617 -    if ((src != NULL) && (ret == FALSE)) {
  10.618 -        gst_bin_remove(GST_BIN(priv->pipe), src);
  10.619 -        gst_object_unref(src);
  10.620 -    }
  10.621 -
  10.622 -    if (ap != NULL)
  10.623 -        gst_object_unref(ap);
  10.624 -
  10.625 -    if (vp != NULL)
  10.626 -        gst_object_unref(vp);
  10.627 -
  10.628 -    if (pad_src != NULL)
  10.629 -        gst_object_unref(pad_src);
  10.630 -
  10.631 -    if (pad_sink != NULL)
  10.632 -        gst_object_unref(pad_sink);
  10.633 -
  10.634 -    return ret;
  10.635 -}
  10.636 -
  10.637 -
  10.638 -
  10.639 -void
  10.640 -g_mencoder_remove_uri(GMencoder * self, const gchar * uri)
  10.641 -{
  10.642 -    // GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE (self);
  10.643 -    // TODO: remove src
  10.644 -}
  10.645 -
  10.646 -void
  10.647 -g_mencoder_play_stream(GMencoder * self)
  10.648 -{
  10.649 -    GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(self);
  10.650 -    g_return_if_fail(priv->ready == FALSE);
  10.651 -    priv->ready = TRUE;
  10.652 -    gst_element_set_state(priv->pipe, GST_STATE_PLAYING);
  10.653 -    if (priv->tick_id != 0) {
  10.654 -        g_source_remove (priv->tick_id);
  10.655 -    }
  10.656 -    priv->tick_id = g_timeout_add(500, _tick_cb, self);
  10.657 -
  10.658 -    if (priv->timeout_id != 0) {
  10.659 -        g_source_remove (priv->timeout_id);
  10.660 -    }
  10.661 -    //priv->timeout_id = g_timeout_add(GMENCODER_TIMEOUT, _process_timeout_cb, self);
  10.662 -}
  10.663 -
  10.664 -void
  10.665 -g_mencoder_pause_stream(GMencoder * self)
  10.666 -{
  10.667 -    GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(self);
  10.668 -    g_return_if_fail(priv->ready == TRUE);
  10.669 -    gst_element_set_state(priv->pipe, GST_STATE_PAUSED);
  10.670 -}
  10.671 -
  10.672 -void
  10.673 -g_mencoder_close_stream(GMencoder * self)
  10.674 -{
  10.675 -
  10.676 -    GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(self);
  10.677 -    if (priv->tick_id != 0) {
  10.678 -        g_source_remove(priv->tick_id);
  10.679 -        priv->tick_id = 0;
  10.680 -    }
  10.681 -
  10.682 -    if (priv->timeout_id != 0) {
  10.683 -        g_source_remove (priv->timeout_id);
  10.684 -	priv->timeout_id = 0;
  10.685 -    }
  10.686 -
  10.687 -    if (priv->pipe != NULL) {
  10.688 -        // TODO: fixe pipeline dispose
  10.689 -        //gst_element_set_state (priv->pipe, GST_STATE_NULL);
  10.690 -        // g_debug ("SETING STATE TO NULL: OK");
  10.691 -        // gst_element_set_state (priv->pipe, GST_STATE_NULL);
  10.692 -        //gst_object_unref (priv->pipe);
  10.693 -        //gst_object_unref(priv->src);
  10.694 -        priv->src = NULL;
  10.695 -        priv->pipe = NULL;
  10.696 -        priv->abin = NULL;
  10.697 -        priv->vbin = NULL;
  10.698 -        priv->sink = NULL;
  10.699 -    }
  10.700 -    priv->ready = FALSE;
  10.701 -}
  10.702 -
  10.703 -static GstElement *
  10.704 -_create_pipeline(GMencoder * self,
  10.705 -                 const gchar * video_encode,
  10.706 -                 const gchar * mux_name,
  10.707 -                 gchar ** video_encode_prop,
  10.708 -                 gdouble video_fps,
  10.709 -                 gdouble video_rate,
  10.710 -                 guint video_width,
  10.711 -                 guint video_height,
  10.712 -                 const gchar * audio_encode,
  10.713 -                 gchar ** audio_encode_prop, guint audio_rate,
  10.714 -		         gboolean deinterlace)
  10.715 -{
  10.716 -    GstBus         *bus = NULL;
  10.717 -    GstElement     *pipe = NULL;
  10.718 -    GstElement     *sink = NULL;
  10.719 -    GstElement     *mux = NULL;
  10.720 -    GstElement     *abin = NULL;
  10.721 -    GstElement     *vbin = NULL;
  10.722 -    GstElement     *queue = NULL;
  10.723 -    GstPad         *aux_pad = NULL;
  10.724 -    GstPad         *mux_pad = NULL;
  10.725 -
  10.726 -    pipe = gst_pipeline_new("pipe");
  10.727 -
  10.728 -    mux =
  10.729 -        gst_element_factory_make((mux_name ? mux_name : "ffmux_mpeg"),
  10.730 -                                 "mux");
  10.731 -    if (mux == NULL)
  10.732 -        goto error;
  10.733 -
  10.734 -    queue = gst_element_factory_make("queue", "queueu_sink");
  10.735 -
  10.736 -
  10.737 -    sink = gst_element_factory_make("fakesink", "sink");
  10.738 -    g_object_set (G_OBJECT (sink), "signal-handoffs", TRUE, NULL);
  10.739 -    g_signal_connect (G_OBJECT (sink),
  10.740 -                      "handoff",
  10.741 -                      G_CALLBACK (_buffer_arrive_cb),
  10.742 -                      self);
  10.743 -
  10.744 -    abin = _create_audio_bin(audio_encode, audio_encode_prop, audio_rate);
  10.745 -    if (abin == NULL)
  10.746 -        goto error;
  10.747 -
  10.748 -    vbin =
  10.749 -        _create_video_bin(video_encode, video_encode_prop, video_fps,
  10.750 -                          video_rate, video_width, video_height, deinterlace);
  10.751 -    if (vbin == NULL)
  10.752 -        goto error;
  10.753 -
  10.754 -    // Finish Pipe
  10.755 -    gst_bin_add_many(GST_BIN(pipe), abin, vbin, mux, queue, sink, NULL);
  10.756 -
  10.757 -
  10.758 -    // Link bins with mux
  10.759 -    aux_pad = gst_element_get_pad(abin, "src");
  10.760 -    mux_pad =
  10.761 -        gst_element_get_compatible_pad(mux, aux_pad,
  10.762 -                                       GST_PAD_CAPS(aux_pad));
  10.763 -    if (mux_pad == NULL) {
  10.764 -        g_warning("Mux element no have audio PAD");
  10.765 -        goto error;
  10.766 -    }
  10.767 -    GstPadLinkReturn ret = gst_pad_link(aux_pad, mux_pad);
  10.768 -    if (ret != GST_PAD_LINK_OK) {
  10.769 -        g_warning("Fail link audio and mux: %d", ret);
  10.770 -        goto error;
  10.771 -
  10.772 -    }
  10.773 -    gst_object_unref(aux_pad);
  10.774 -    gst_object_unref(mux_pad);
  10.775 -
  10.776 -    aux_pad = gst_element_get_pad(vbin, "src");
  10.777 -    mux_pad =
  10.778 -        gst_element_get_compatible_pad(mux, aux_pad,
  10.779 -                                       GST_PAD_CAPS(aux_pad));
  10.780 -    if (mux_pad == NULL) {
  10.781 -        g_warning("Mux element no have video PAD");
  10.782 -        goto error;
  10.783 -    }
  10.784 -    ret = gst_pad_link(aux_pad, mux_pad);
  10.785 -    if (ret != GST_PAD_LINK_OK) {
  10.786 -        g_warning("Fail link video and mux: %d", ret);
  10.787 -        goto error;
  10.788 -    }
  10.789 -    gst_object_unref(aux_pad);
  10.790 -    gst_object_unref(mux_pad);
  10.791 -    aux_pad = NULL;
  10.792 -    mux_pad = NULL;
  10.793 -
  10.794 -    // Link mux with sink
  10.795 -    gst_element_link_many(mux, queue, sink, NULL);
  10.796 -
  10.797 -    bus = gst_pipeline_get_bus(GST_PIPELINE(pipe));
  10.798 -    gst_bus_add_watch(bus, _pipeline_bus_cb, self);
  10.799 -    gst_object_unref(bus);
  10.800 -    return pipe;
  10.801 -
  10.802 -  error:
  10.803 -    g_warning("Invalid uri");
  10.804 -
  10.805 -    if (pipe != NULL) {
  10.806 -        gst_object_unref(pipe);
  10.807 -    }
  10.808 -
  10.809 -
  10.810 -    if (mux != NULL) {
  10.811 -        gst_object_unref(mux);
  10.812 -    }
  10.813 -
  10.814 -    if (mux_pad != NULL) {
  10.815 -        gst_object_unref(mux_pad);
  10.816 -    }
  10.817 -
  10.818 -    if (aux_pad != NULL) {
  10.819 -        gst_object_unref(mux_pad);
  10.820 -    }
  10.821 -
  10.822 -    if (sink != NULL) {
  10.823 -        gst_object_unref(sink);
  10.824 -    }
  10.825 -
  10.826 -    if (abin != NULL) {
  10.827 -        gst_object_unref(abin);
  10.828 -    }
  10.829 -
  10.830 -    if (vbin != NULL) {
  10.831 -        gst_object_unref(vbin);
  10.832 -    }
  10.833 -
  10.834 -    return FALSE;
  10.835 -}
  10.836 -
  10.837 -
  10.838 -static void
  10.839 -_close_output(GMencoder * self)
  10.840 -{
  10.841 -}
  10.842 -
  10.843 -static GstElement *
  10.844 -_create_v4l_source (GMencoder *self, const gchar * uri)
  10.845 -{
  10.846 -    gchar **info;
  10.847 -    GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(self);
  10.848 -
  10.849 -
  10.850 -    info = g_strsplit (uri+6, ":", 3);
  10.851 -    if (g_strv_length (info) != 3) {
  10.852 -        return NULL;
  10.853 -    }
  10.854 -
  10.855 -    priv->v4lsrc = gst_element_factory_make ("v4l2src", "src");
  10.856 -    g_debug ("channel %s, norm %s, frequ %s", info[0], info[1], info[2]);
  10.857 -    g_object_set (G_OBJECT (priv->v4lsrc),
  10.858 -                  "channel", info[0],
  10.859 -                  "norm", info[1],
  10.860 -                  "frequency", atoi (info[2]),
  10.861 -                  NULL);
  10.862 -
  10.863 -    return priv->v4lsrc;
  10.864 -}
  10.865 -
  10.866 -static GstElement *
  10.867 -_create_source(GMencoder *self, const gchar * uri)
  10.868 -{
  10.869 -
  10.870 -    GstElement     *bsrc = NULL;
  10.871 -    GstElement     *src = NULL;
  10.872 -    GstElement     *aqueue = NULL;
  10.873 -    GstElement     *vqueue = NULL;
  10.874 -    GstElement     *decode = NULL;
  10.875 -    GstPad         *src_pad = NULL;
  10.876 -
  10.877 -
  10.878 -    bsrc = gst_bin_new(NULL);
  10.879 -
  10.880 -    // src = gst_element_factory_make ("gnomevfssrc", "src");
  10.881 -    // g_object_set (G_OBJECT (src), "location", uri, NULL);
  10.882 -    if (strncmp (uri, "v4l://", 6) == 0) {
  10.883 -        g_debug ("V4L");
  10.884 -        src = _create_v4l_source (self, uri);
  10.885 -    }
  10.886 -    else {
  10.887 -        src = gst_element_make_from_uri(GST_URI_SRC, uri, "src");
  10.888 -    }
  10.889 -
  10.890 -    if (src == NULL)
  10.891 -        goto error;
  10.892 -
  10.893 -    decode = gst_element_factory_make("decodebin2", "decode");
  10.894 -    if (decode == NULL)
  10.895 -        goto error;
  10.896 -
  10.897 -    aqueue = gst_element_factory_make("queue", "aqueue");
  10.898 -    if (aqueue == NULL)
  10.899 -        goto error;
  10.900 -
  10.901 -    vqueue = gst_element_factory_make("queue", "vqueue");
  10.902 -    if (vqueue == NULL)
  10.903 -        goto error;
  10.904 -
  10.905 -    gst_bin_add_many(GST_BIN(bsrc), src, decode, aqueue, vqueue,
  10.906 -                     NULL);
  10.907 -    gst_element_link (src, decode);
  10.908 -
  10.909 -    g_signal_connect(G_OBJECT(decode),
  10.910 -                     "new-decoded-pad",
  10.911 -                     G_CALLBACK(_decodebin_new_pad_cb), bsrc);
  10.912 -
  10.913 -    g_signal_connect(G_OBJECT(decode),
  10.914 -                     "unknown-type",
  10.915 -                     G_CALLBACK(_decodebin_unknown_type_cb), pipe);
  10.916 -
  10.917 -    src_pad = gst_element_get_pad(aqueue, "src");
  10.918 -    gst_element_add_pad(bsrc, gst_ghost_pad_new("src_audio", src_pad));
  10.919 -    gst_object_unref(src_pad);
  10.920 -
  10.921 -    src_pad = gst_element_get_pad(vqueue, "src");
  10.922 -    gst_element_add_pad(bsrc, gst_ghost_pad_new("src_video", src_pad));
  10.923 -    gst_object_unref(src_pad);
  10.924 -
  10.925 -    return bsrc;
  10.926 -
  10.927 -  error:
  10.928 -    g_debug ("Fail to create source element");
  10.929 -    if (src != NULL) {
  10.930 -        gst_object_unref(src);
  10.931 -    }
  10.932 -
  10.933 -    if (decode != NULL) {
  10.934 -        gst_object_unref(decode);
  10.935 -    }
  10.936 -
  10.937 -    if (aqueue != NULL) {
  10.938 -        gst_object_unref(aqueue);
  10.939 -    }
  10.940 -
  10.941 -    if (vqueue != NULL) {
  10.942 -        gst_object_unref(vqueue);
  10.943 -    }
  10.944 -
  10.945 -    return NULL;
  10.946 -}
  10.947 -
  10.948 -static gboolean
  10.949 -_open_output(GMencoder * self, const gchar * uri)
  10.950 -{
  10.951 -    gchar         **i;
  10.952 -    GnomeVFSResult result;
  10.953 -    GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(self);
  10.954 -
  10.955 -    i = g_strsplit(uri, "://", 0);
  10.956 -    if (strcmp(i[0], "fd") == 0) {
  10.957 -        result = gnome_vfs_open_fd (&priv->handle, atoi(i[1]));
  10.958 -    } else {
  10.959 -        if (g_file_test (i[1], G_FILE_TEST_EXISTS) == FALSE) {
  10.960 -            result = gnome_vfs_create (&priv->handle, uri, GNOME_VFS_OPEN_WRITE, FALSE,
  10.961 -                              GNOME_VFS_PERM_USER_WRITE | GNOME_VFS_PERM_USER_READ | GNOME_VFS_PERM_GROUP_READ);
  10.962 -        } else {
  10.963 -            result = gnome_vfs_open (&priv->handle, uri,
  10.964 -                                     GNOME_VFS_OPEN_WRITE | GNOME_VFS_OPEN_TRUNCATE);
  10.965 -        }
  10.966 -    }
  10.967 -
  10.968 -    g_strfreev(i);
  10.969 -    return (result == GNOME_VFS_OK);
  10.970 -}
  10.971 -
  10.972 -static          gboolean
  10.973 -_pipeline_bus_cb(GstBus * bus, GstMessage * msg, gpointer user_data)
  10.974 -{
  10.975 -    GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(user_data);
  10.976 -
  10.977 -    switch (GST_MESSAGE_TYPE(msg)) {
  10.978 -
  10.979 -    case GST_MESSAGE_STATE_CHANGED:
  10.980 -        {
  10.981 -            GstState        oldstate;
  10.982 -            GstState        newstate;
  10.983 -            GstState        pendingstate;
  10.984 -
  10.985 -
  10.986 -            gst_message_parse_state_changed(msg, &oldstate,
  10.987 -                                            &newstate, &pendingstate);
  10.988 -
  10.989 -            if (pendingstate != GST_STATE_VOID_PENDING)
  10.990 -                break;
  10.991 -
  10.992 -            if ((oldstate == GST_STATE_READY)
  10.993 -                && (newstate == GST_STATE_PAUSED)) {
  10.994 -                if (priv->ready)
  10.995 -                    g_signal_emit(user_data, g_mencoder_signals[PAUSED],
  10.996 -                                  0);
  10.997 -            } else if ((oldstate == GST_STATE_PAUSED)
  10.998 -                       && (newstate == GST_STATE_PLAYING)) {
  10.999 -                g_signal_emit(user_data, g_mencoder_signals[PLAYING], 0);
 10.1000 -            } else if ((oldstate == GST_STATE_READY) &&
 10.1001 -                       (newstate == GST_STATE_NULL)) {
 10.1002 -                g_signal_emit(user_data, g_mencoder_signals[STOPED], 0);
 10.1003 -            }
 10.1004 -            break;
 10.1005 -        }
 10.1006 -
 10.1007 -    case GST_MESSAGE_ERROR:
 10.1008 -        {
 10.1009 -            GError         *error;
 10.1010 -            gchar          *debug;
 10.1011 -            gchar          *err_str;
 10.1012 -
 10.1013 -            if (priv->tick_id != 0) {
 10.1014 -                g_source_remove(priv->tick_id);
 10.1015 -                priv->tick_id = 0;
 10.1016 -            }
 10.1017 -
 10.1018 -            gst_message_parse_error(msg, &error, &debug);
 10.1019 -            err_str = g_strdup_printf("Error [%d] %s (%s)", error->code,
 10.1020 -                                      error->message, debug);
 10.1021 -            priv->ready = FALSE;
 10.1022 -            g_signal_emit(user_data, g_mencoder_signals[ERROR], 0,
 10.1023 -                          err_str);
 10.1024 -            g_free(err_str);
 10.1025 -            g_clear_error(&error);
 10.1026 -            g_free(debug);
 10.1027 -            break;
 10.1028 -        }
 10.1029 -
 10.1030 -    case GST_MESSAGE_EOS:
 10.1031 -        priv->ready = FALSE;
 10.1032 -#ifdef USE_MANUAL_SINK
 10.1033 -        _flush_queue (G_MENCODER (user_data));
 10.1034 -#endif
 10.1035 -        g_signal_emit(user_data, g_mencoder_signals[EOS], 0);
 10.1036 -        break;
 10.1037 -
 10.1038 -    case GST_MESSAGE_DURATION:
 10.1039 -        {
 10.1040 -            GstFormat       format;
 10.1041 -            gint64          duration;
 10.1042 -            gst_message_parse_duration(msg, &format, &duration);
 10.1043 -            if (format == GST_FORMAT_BYTES)
 10.1044 -                priv->duration = duration;
 10.1045 -            break;
 10.1046 -        }
 10.1047 -    default:
 10.1048 -        {
 10.1049 -            break;
 10.1050 -        }
 10.1051 -    }
 10.1052 -    return TRUE;
 10.1053 -}
 10.1054 -
 10.1055 -
 10.1056 -
 10.1057 -static void
 10.1058 -_decodebin_new_pad_cb(GstElement * object,
 10.1059 -                      GstPad * pad, gboolean flag, gpointer user_data)
 10.1060 -{
 10.1061 -    GstCaps        *caps;
 10.1062 -    gchar          *str_caps = NULL;
 10.1063 -    GstElement     *sink_element;
 10.1064 -    GstPad         *sink_pad;
 10.1065 -
 10.1066 -    caps = gst_pad_get_caps(pad);
 10.1067 -    str_caps = gst_caps_to_string(caps);
 10.1068 -    if (strstr(str_caps, "audio") != NULL) {
 10.1069 -        sink_element = gst_bin_get_by_name(GST_BIN(user_data), "aqueue");
 10.1070 -    } else if (strstr(str_caps, "video") != NULL) {
 10.1071 -        sink_element = gst_bin_get_by_name(GST_BIN(user_data), "vqueue");
 10.1072 -    } else {
 10.1073 -        g_warning("invalid caps %s", str_caps);
 10.1074 -    }
 10.1075 -
 10.1076 -    sink_pad = gst_element_get_pad(sink_element, "sink");
 10.1077 -    gst_pad_link(pad, sink_pad);
 10.1078 -
 10.1079 -    gst_object_unref(sink_element);
 10.1080 -    gst_object_unref(sink_pad);
 10.1081 -    g_free(str_caps);
 10.1082 -    gst_caps_unref(caps);
 10.1083 -}
 10.1084 -
 10.1085 -static void
 10.1086 -_decodebin_unknown_type_cb(GstElement * object,
 10.1087 -                           GstPad * pad, GstCaps * caps,
 10.1088 -                           gpointer user_data)
 10.1089 -{
 10.1090 -    g_warning("Unknown Type");
 10.1091 -    // priv->ready = FALSE;
 10.1092 -}
 10.1093 -
 10.1094 -static          gboolean
 10.1095 -_tick_cb(gpointer user_data)
 10.1096 -{
 10.1097 -    GstFormat       format = GST_FORMAT_BYTES;
 10.1098 -    gint64          cur = 0;
 10.1099 -
 10.1100 -    GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(user_data);
 10.1101 -
 10.1102 -    if (priv->duration == 0) {
 10.1103 -        gint64          d = 0;
 10.1104 -        if (gst_element_query_duration(priv->src, &format, &d))
 10.1105 -            priv->duration = d;
 10.1106 -    }
 10.1107 -
 10.1108 -    if (priv->duration != 0) {
 10.1109 -        gst_element_query_position(priv->src, &format, &cur);
 10.1110 -        g_print("PROGRESS:%lli\n", (99 * cur) / priv->duration);
 10.1111 -    }
 10.1112 -
 10.1113 -    return TRUE;
 10.1114 -}
 10.1115 -
 10.1116 -static gboolean 
 10.1117 -_process_timeout_cb (gpointer user_data)
 10.1118 -{
 10.1119 -    GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(user_data);
 10.1120 -
 10.1121 -    g_signal_emit(user_data, g_mencoder_signals[ERROR], 0, "timeout");
 10.1122 -    priv->timeout_id = 0;
 10.1123 -    return FALSE;
 10.1124 -}
 10.1125 -
 10.1126 -
 10.1127 -#ifdef USE_MANUAL_SINK
 10.1128 -static gboolean
 10.1129 -_send_buffer (GnomeVFSHandle *handle, gpointer buff, gint size)
 10.1130 -{
 10.1131 -    gchar *msg;
 10.1132 -    GByteArray *b_send;
 10.1133 -    GnomeVFSResult result;
 10.1134 -    GnomeVFSFileSize bytes_written;
 10.1135 -
 10.1136 -    b_send = g_byte_array_new ();
 10.1137 -    msg = g_strdup_printf ("%x\r\n", size);
 10.1138 -    b_send = g_byte_array_append (b_send, (const guint8*) msg, strlen (msg) * sizeof (gchar));
 10.1139 -    g_free (msg);
 10.1140 -
 10.1141 -    b_send = g_byte_array_append (b_send, buff, size);
 10.1142 -
 10.1143 -    msg = g_strdup ("\r\n");
 10.1144 -    b_send = g_byte_array_append (b_send, (const guint8*) msg, strlen (msg) * sizeof (gchar));
 10.1145 -    g_free (msg);
 10.1146 -
 10.1147 -    result = gnome_vfs_write (handle, b_send->data, b_send->len, &bytes_written);
 10.1148 -    g_byte_array_free (b_send, TRUE);
 10.1149 -
 10.1150 -    return (result == GNOME_VFS_OK);
 10.1151 -}
 10.1152 -
 10.1153 -static void
 10.1154 -_flush_queue (GMencoder *self)
 10.1155 -{
 10.1156 -    GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(self);
 10.1157 -
 10.1158 -    if (priv->send_chunked) {
 10.1159 -        GnomeVFSFileSize bytes_written;
 10.1160 -        gchar *end_msg;
 10.1161 -        end_msg = g_strdup ("0\r\n\r\n");
 10.1162 -        gnome_vfs_write (priv->handle,
 10.1163 -                         (const guint8*) end_msg,
 10.1164 -                         strlen(end_msg) * sizeof(gchar),
 10.1165 -                         &bytes_written);
 10.1166 -        g_free (end_msg);
 10.1167 -    }
 10.1168 -}
 10.1169 -
 10.1170 -static void
 10.1171 -_buffer_arrive_cb (GstElement* object,
 10.1172 -                   GstBuffer* buff,
 10.1173 -                   GstPad* pad,
 10.1174 -                   gpointer user_data)
 10.1175 -{
 10.1176 -    GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(user_data);
 10.1177 -
 10.1178 -    if (priv->timeout_id != 0) {
 10.1179 -	g_source_remove (priv->timeout_id);
 10.1180 -	priv->timeout_id = 0;
 10.1181 -    }
 10.1182 -
 10.1183 -    if (priv->send_chunked) {
 10.1184 -        if (_send_buffer (priv->handle, GST_BUFFER_DATA (buff), GST_BUFFER_SIZE (buff)) == FALSE)
 10.1185 -            goto error;
 10.1186 -    } else {
 10.1187 -        GnomeVFSResult result;
 10.1188 -        GnomeVFSFileSize bytes_written;
 10.1189 -
 10.1190 -        result = gnome_vfs_write (priv->handle,
 10.1191 -                                  GST_BUFFER_DATA (buff),
 10.1192 -                                  GST_BUFFER_SIZE (buff),
 10.1193 -                                  &bytes_written);
 10.1194 -
 10.1195 -        if (result != GNOME_VFS_OK)
 10.1196 -            goto error;
 10.1197 -    }
 10.1198 -
 10.1199 -    return;
 10.1200 -
 10.1201 -error:
 10.1202 -    if (priv->tick_id != 0) {
 10.1203 -        g_source_remove(priv->tick_id);
 10.1204 -        priv->tick_id = 0;
 10.1205 -    }
 10.1206 -    g_signal_emit(user_data, g_mencoder_signals[ERROR], 0, "Fail to write on socket");
 10.1207 -    gst_element_set_state (priv->pipe, GST_STATE_PAUSED);
 10.1208 -}
 10.1209 -
 10.1210 -#endif
    11.1 --- a/gmyth-stream/gmemcoder/src/gmencoder.h	Tue Sep 18 13:45:04 2007 +0100
    11.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.3 @@ -1,61 +0,0 @@
    11.4 -#ifndef __G_MENCODER_H__
    11.5 -#define __G_MENCODER_H__
    11.6 -
    11.7 -#include <glib-object.h>
    11.8 -
    11.9 -G_BEGIN_DECLS typedef struct _GMencoder GMencoder;
   11.10 -typedef struct _GMencoderClass GMencoderClass;
   11.11 -
   11.12 -struct _GMencoderClass {
   11.13 -    GObjectClass    parent_class;
   11.14 -};
   11.15 -
   11.16 -struct _GMencoder {
   11.17 -    GObject         parent;
   11.18 -};
   11.19 -
   11.20 -/*
   11.21 - * TYPE MACROS 
   11.22 - */
   11.23 -#define G_TYPE_MENCODER \
   11.24 -  (g_mencoder_get_type())
   11.25 -#define G_MENCODER(obj) \
   11.26 -  (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_MENCODER, GMencoder))
   11.27 -#define G_MENCODER_CLASS(klass) \
   11.28 -  (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_MENCODER, GMencoderClass))
   11.29 -#define G_IS_MENCODER(obj) \
   11.30 -  (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_MENCODER))
   11.31 -#define G_IS_MENCODER_CLASS(klass) \
   11.32 -  (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_MENCODER))
   11.33 -#define G_MENCODER_GET_CLASS(obj) \
   11.34 -  (G_TYPE_INSTANCE_GET_CLASS ((obj), G_TYPE_MENCODER, GMencoderClass))
   11.35 -
   11.36 -
   11.37 -GType           g_mencoder_get_type(void);
   11.38 -GMencoder      *g_mencoder_new(void);
   11.39 -
   11.40 -gboolean        g_mencoder_setup_stream(GMencoder * self,
   11.41 -					gboolean chunked,
   11.42 -					gboolean deinterlace,
   11.43 -                                        const gchar * mux_name,
   11.44 -                                        const gchar * video_encode,
   11.45 -                                        gchar ** video_encode_prop,
   11.46 -                                        gdouble video_fps,
   11.47 -                                        gdouble video_rate,
   11.48 -                                        guint video_width,
   11.49 -                                        guint video_height,
   11.50 -                                        const gchar * audio_encode,
   11.51 -                                        gchar ** audio_encode_prop,
   11.52 -                                        guint audio_rate,
   11.53 -                                        const gchar * output_uri);
   11.54 -
   11.55 -gboolean        g_mencoder_append_uri(GMencoder * self, const gchar * uri);
   11.56 -
   11.57 -void            g_mencoder_remove_uri(GMencoder * self, const gchar * uri);
   11.58 -
   11.59 -void            g_mencoder_play_stream(GMencoder * self);
   11.60 -void            g_mencoder_pause_stream(GMencoder * self);
   11.61 -void            g_mencoder_close_stream(GMencoder * self);
   11.62 -
   11.63 -G_END_DECLS
   11.64 -#endif
    12.1 --- a/gmyth-stream/gmemcoder/src/main.c	Tue Sep 18 13:45:04 2007 +0100
    12.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.3 @@ -1,207 +0,0 @@
    12.4 -#include <sys/stat.h>
    12.5 -#include <fcntl.h>
    12.6 -#include <unistd.h>
    12.7 -#include <string.h>
    12.8 -
    12.9 -#include <gst/gst.h>
   12.10 -#include <glib.h>
   12.11 -#include <libgnomevfs/gnome-vfs.h>
   12.12 -
   12.13 -#include "gmencoder.h"
   12.14 -
   12.15 -#define FILE_OUT  1
   12.16 -
   12.17 -static GMainLoop *mainloop = NULL;
   12.18 -/*
   12.19 - * Options 
   12.20 - */
   12.21 -static gchar   *input_file = NULL;
   12.22 -static gchar   *video_encode = NULL;
   12.23 -static gchar   *video_opts = NULL;
   12.24 -static gdouble  video_fps = 0.0;
   12.25 -static gint     video_rate = 0;
   12.26 -static gint     video_width = 0;
   12.27 -static gint     video_height = 0;
   12.28 -static gchar   *audio_encode = NULL;
   12.29 -static gchar   *audio_opts = NULL;
   12.30 -static double   audio_rate = 0.0;
   12.31 -static gchar   *mux_name = NULL;
   12.32 -static gchar   *output_uri = NULL;
   12.33 -static gboolean chunked = FALSE;
   12.34 -static gboolean deinterlace = FALSE;
   12.35 -
   12.36 -
   12.37 -
   12.38 -static gboolean
   12.39 -_quit(gpointer data)
   12.40 -{
   12.41 -    //g_object_unref(data);
   12.42 -    g_main_loop_quit(mainloop);
   12.43 -    return FALSE;
   12.44 -}
   12.45 -
   12.46 -static void
   12.47 -_mencoder_eos_cb(GMencoder * mencoder, gpointer data)
   12.48 -{
   12.49 -    g_print("PROGRESS: 100\n");
   12.50 -    g_idle_add(_quit, mencoder);
   12.51 -}
   12.52 -
   12.53 -
   12.54 -static void
   12.55 -_mencoder_error_cb(GMencoder * mencoder, const gchar * msg, gpointer data)
   12.56 -{
   12.57 -    g_print("Error: %s\n", msg);
   12.58 -    g_idle_add(_quit, mencoder);
   12.59 -}
   12.60 -
   12.61 -static          gboolean
   12.62 -_io_channel_cb(GIOChannel * ch, GIOCondition condition, gpointer data)
   12.63 -{
   12.64 -    GString        *cmd = g_string_new("");
   12.65 -    g_io_channel_read_line_string(ch, cmd, NULL, NULL);
   12.66 -
   12.67 -    if (strcmp(cmd->str, "PLAY\n") == 0) {
   12.68 -        g_mencoder_play_stream(G_MENCODER(data));
   12.69 -    } else if (strcmp(cmd->str, "PAUSE\n") == 0) {
   12.70 -        g_mencoder_pause_stream(G_MENCODER(data));
   12.71 -    } else if (strcmp(cmd->str, "STOP\n") == 0) {
   12.72 -        g_mencoder_close_stream(G_MENCODER(data));
   12.73 -    } else if (strcmp(cmd->str, "QUIT\n") == 0) {
   12.74 -        g_mencoder_close_stream(G_MENCODER(data));
   12.75 -        g_main_loop_quit(mainloop);
   12.76 -    }
   12.77 -    g_string_free(cmd, TRUE);
   12.78 -    return TRUE;
   12.79 -}
   12.80 -
   12.81 -int
   12.82 -main(int argc, char **argv)
   12.83 -{
   12.84 -    GMencoder      *coder = NULL;
   12.85 -    GIOChannel     *ch;
   12.86 -    gchar         **vopts;
   12.87 -    gchar         **aopts;
   12.88 -    gchar         **files;
   12.89 -    gint            i;
   12.90 -    gboolean      ret;
   12.91 -
   12.92 -    GOptionContext *context;
   12.93 -    static const GOptionEntry options[] = {
   12.94 -        {"input-files", 'i', 0, G_OPTION_ARG_STRING, &input_file,
   12.95 -         "Input File", NULL},
   12.96 -
   12.97 -        {"video-encode", 0, 0, G_OPTION_ARG_STRING, &video_encode,
   12.98 -         "GstElementName for used to video encode", NULL},
   12.99 -
  12.100 -        {"video-opts", 0, 0, G_OPTION_ARG_STRING, &video_opts,
  12.101 -         "Properties to set on video element", NULL},
  12.102 -
  12.103 -        {"video-fps", 0, 0, G_OPTION_ARG_DOUBLE, &video_fps,
  12.104 -         "Video FPS", NULL},
  12.105 -
  12.106 -        {"video-rate", 0, 0, G_OPTION_ARG_INT, &video_rate,
  12.107 -         "Video rate", NULL},
  12.108 -
  12.109 -        {"video-width", 0, 0, G_OPTION_ARG_INT, &video_width,
  12.110 -         "Video width", NULL},
  12.111 -
  12.112 -        {"video-height", 0, 0, G_OPTION_ARG_INT, &video_height,
  12.113 -         "Video height", NULL},
  12.114 -
  12.115 -        {"audio-encode", 0, 0, G_OPTION_ARG_STRING, &audio_encode,
  12.116 -         "GstElementName for use to audio encode", NULL},
  12.117 -
  12.118 -        {"audio-opts", 0, 0, G_OPTION_ARG_STRING, &audio_opts,
  12.119 -         "Properties to set on audio element", NULL},
  12.120 -
  12.121 -        {"audio-rate", 0, 0, G_OPTION_ARG_INT, &audio_rate,
  12.122 -         "Audio rate", NULL},
  12.123 -
  12.124 -        {"mux-element", 0, 0, G_OPTION_ARG_STRING, &mux_name,
  12.125 -         "GstElementName for use to mux file", NULL},
  12.126 -
  12.127 -        {"output-uri", 'o', 0, G_OPTION_ARG_STRING, &output_uri,
  12.128 -         "Uri to output", NULL},
  12.129 -
  12.130 -	{"chunked", 'c', 0, G_OPTION_ARG_NONE, &chunked, 
  12.131 -         "Send package chunked", NULL},
  12.132 -
  12.133 -	{"deinterlace", 'd', 0, G_OPTION_ARG_NONE, &deinterlace, 
  12.134 -         "Use to deinterlace videos", NULL},
  12.135 -
  12.136 -
  12.137 -        {NULL}
  12.138 -    };
  12.139 -
  12.140 -    g_type_init();
  12.141 -    g_thread_init(NULL);
  12.142 -    gnome_vfs_init ();
  12.143 -    mainloop = g_main_loop_new(NULL, FALSE);
  12.144 -
  12.145 -    g_set_prgname("gmemcoder");
  12.146 -    context = g_option_context_new(NULL);
  12.147 -    g_option_context_set_help_enabled(context, TRUE);
  12.148 -    g_option_context_add_main_entries(context, options, NULL);
  12.149 -    g_option_context_add_group(context, gst_init_get_option_group());
  12.150 -    g_option_context_parse(context, &argc, &argv, NULL);
  12.151 -
  12.152 -    gst_init(&argc, &argv);
  12.153 -
  12.154 -    if (output_uri == NULL) {
  12.155 -        g_print("You need to specify output-uri.\nTry --help "
  12.156 -                "for more information.\n");
  12.157 -        return 1;
  12.158 -    }
  12.159 -
  12.160 -    if (input_file == NULL) {
  12.161 -        g_print("You need to specify input file\nTry --help "
  12.162 -                "for more information.\n");
  12.163 -    }
  12.164 -
  12.165 -    coder = g_mencoder_new();
  12.166 -    ch = g_io_channel_unix_new(0);
  12.167 -
  12.168 -    if (audio_opts != NULL)
  12.169 -        aopts = g_strsplit(audio_opts, ",", 0);
  12.170 -    else
  12.171 -        aopts = NULL;
  12.172 -
  12.173 -    if (video_opts != NULL)
  12.174 -        vopts = g_strsplit(video_opts, ",", 0);
  12.175 -    else
  12.176 -        vopts = NULL;
  12.177 -
  12.178 -    ret = g_mencoder_setup_stream(coder, chunked, deinterlace, mux_name,
  12.179 -                                  video_encode, vopts, video_fps,
  12.180 -                                  video_rate, video_width, video_height,
  12.181 -                                  audio_encode, aopts, audio_rate, output_uri);
  12.182 -
  12.183 -    if (ret == TRUE) {
  12.184 -        files = g_strsplit(input_file, ",", 0);
  12.185 -        for (i = 0; i < g_strv_length(files); i++) {
  12.186 -            if (!g_mencoder_append_uri(coder, files[i])) {
  12.187 -                g_debug("Invalid uri: %s", files[i]);
  12.188 -            }
  12.189 -        }
  12.190 -        g_strfreev(files);
  12.191 -    }
  12.192 -
  12.193 -    g_strfreev(aopts);
  12.194 -    g_strfreev(vopts);
  12.195 -
  12.196 -    if (ret == TRUE) {
  12.197 -        g_io_add_watch(ch, G_IO_IN, _io_channel_cb, coder);
  12.198 -        g_signal_connect(G_OBJECT(coder),
  12.199 -                         "eos", G_CALLBACK(_mencoder_eos_cb), mainloop);
  12.200 -
  12.201 -        g_signal_connect(G_OBJECT(coder),
  12.202 -                         "error", G_CALLBACK(_mencoder_error_cb), mainloop);
  12.203 -
  12.204 -        g_mencoder_play_stream(coder);
  12.205 -        g_main_loop_run(mainloop);
  12.206 -    }
  12.207 -
  12.208 -    g_object_unref(coder);
  12.209 -    return 0;
  12.210 -}
    13.1 --- a/gmyth-stream/gmemcoder/tests/Makefile.am	Tue Sep 18 13:45:04 2007 +0100
    13.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.3 @@ -1,15 +0,0 @@
    13.4 -bin_PROGRAMS = \
    13.5 -	gnl-test
    13.6 -
    13.7 -gnl_test_SOURCES = \
    13.8 -	main.c 
    13.9 -	
   13.10 -gnl_test_LDADD = \
   13.11 -	$(GLIB_LIBS) \
   13.12 -	$(GST_LIBS)
   13.13 -
   13.14 -AM_CPPFLAGS = \
   13.15 -	$(GLIB_CFLAGS) \
   13.16 -	$(GST_CFLAGS)
   13.17 -
   13.18 -CLEANFILES = 
    14.1 --- a/gmyth-stream/gmemcoder/tests/main.c	Tue Sep 18 13:45:04 2007 +0100
    14.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.3 @@ -1,230 +0,0 @@
    14.4 -#include <sys/stat.h>
    14.5 -#include <fcntl.h>
    14.6 -#include <unistd.h>
    14.7 -#include <string.h>
    14.8 -
    14.9 -#include <gst/gst.h>
   14.10 -#include <glib.h>
   14.11 -
   14.12 -
   14.13 -static GMainLoop *mainloop = NULL;
   14.14 -static gint64   d = 0;
   14.15 -static gint64   gap = 10;
   14.16 -
   14.17 -typedef enum {
   14.18 -    MY_STREAM_TYPE_AUDIO = 0,
   14.19 -    MY_STREAM_TYPE_VIDEO = 1
   14.20 -} MyStreamType;
   14.21 -
   14.22 -typedef struct _StreamData StreamData;
   14.23 -struct _StreamData {
   14.24 -    GstElement     *bin;
   14.25 -    MyStreamType    type;
   14.26 -};
   14.27 -
   14.28 -static void
   14.29 -_stream_decode_pad_added_cb(GstElement * decode,
   14.30 -                            GstPad * pad, gboolean arg1,
   14.31 -                            gpointer user_data)
   14.32 -{
   14.33 -    StreamData     *data = (StreamData *) user_data;
   14.34 -    GstElement     *queue;
   14.35 -    GstPad         *sink_pad;
   14.36 -    GstCaps        *caps = gst_pad_get_caps(pad);
   14.37 -    gchar          *str_caps = gst_caps_to_string(caps);
   14.38 -
   14.39 -    g_debug("decode caps: [%d] [%s]", data->type, str_caps);
   14.40 -
   14.41 -    switch (data->type) {
   14.42 -    case MY_STREAM_TYPE_AUDIO:
   14.43 -        g_debug("Audio");
   14.44 -        if (strstr(str_caps, "audio") == NULL)
   14.45 -            goto done;
   14.46 -        break;
   14.47 -    case MY_STREAM_TYPE_VIDEO:
   14.48 -        g_debug("Video");
   14.49 -        if (strstr(str_caps, "video") == NULL)
   14.50 -            goto done;
   14.51 -        break;
   14.52 -    }
   14.53 -
   14.54 -    queue = gst_bin_get_by_name(GST_BIN(data->bin), "queue");
   14.55 -    sink_pad = gst_element_get_pad(queue, "sink");
   14.56 -
   14.57 -    if (gst_pad_link(pad, sink_pad) != GST_PAD_LINK_OK) {
   14.58 -        g_warning("Failed to link decode");
   14.59 -    }
   14.60 -
   14.61 -    gst_object_unref(queue);
   14.62 -    gst_object_unref(sink_pad);
   14.63 -    // g_free (data);
   14.64 -    g_debug("Linked");
   14.65 -
   14.66 -  done:
   14.67 -    gst_caps_unref(caps);
   14.68 -    g_free(str_caps);
   14.69 -}
   14.70 -
   14.71 -
   14.72 -static GstElement *
   14.73 -_create_src_element(const gchar * name,
   14.74 -                    const gchar * uri, MyStreamType type, guint priority)
   14.75 -{
   14.76 -    StreamData     *data;
   14.77 -    GstElement     *bin;
   14.78 -    GstElement     *src;
   14.79 -    GstElement     *decode;
   14.80 -    GstElement     *queue;
   14.81 -    GstPad         *src_pad;
   14.82 -
   14.83 -    GstElement     *gnl_src;
   14.84 -
   14.85 -    g_debug("element from uri: %s", uri);
   14.86 -
   14.87 -    bin = gst_bin_new("bin");
   14.88 -    src = gst_element_make_from_uri(GST_URI_SRC, uri, "src");
   14.89 -    g_return_val_if_fail(src != NULL, NULL);
   14.90 -
   14.91 -    decode = gst_element_factory_make("decodebin", NULL);
   14.92 -    g_return_val_if_fail(decode != NULL, NULL);
   14.93 -
   14.94 -    queue = gst_element_factory_make("queue", "queue");
   14.95 -    g_return_val_if_fail(queue != NULL, NULL);
   14.96 -
   14.97 -    gst_bin_add_many(GST_BIN(bin), src, decode, queue, NULL);
   14.98 -    gst_element_link(src, decode);
   14.99 -
  14.100 -    data = g_new0(StreamData, 1);
  14.101 -    data->bin = bin;
  14.102 -    data->type = type;
  14.103 -    g_debug("Type : %d = %d", type, data->type);
  14.104 -
  14.105 -    g_signal_connect(G_OBJECT(decode), "new-decoded-pad",
  14.106 -                     G_CALLBACK(_stream_decode_pad_added_cb), data);
  14.107 -
  14.108 -
  14.109 -    src_pad = gst_element_get_pad(queue, "src");
  14.110 -    g_return_val_if_fail(src_pad != NULL, NULL);
  14.111 -
  14.112 -    gst_element_add_pad(bin, gst_ghost_pad_new("src", src_pad));
  14.113 -
  14.114 -    gst_object_unref(src_pad);
  14.115 -
  14.116 -    gnl_src = gst_element_factory_make("gnlsource", name);
  14.117 -    g_return_val_if_fail(gnl_src != NULL, NULL);
  14.118 -    gst_bin_add(GST_BIN(gnl_src), bin);
  14.119 -
  14.120 -    g_debug("ADDING WITH: START [%lli] DUR [%lli]", d, gap);
  14.121 -    if (d == 0) {
  14.122 -        g_object_set(G_OBJECT(gnl_src),
  14.123 -                     // "start", 0L,
  14.124 -                     "duration", 10 * GST_SECOND,
  14.125 -                     // "media-start", 0L,
  14.126 -                     // "media-duration", 10 * GST_SECOND,
  14.127 -                     "priority", priority, NULL);
  14.128 -
  14.129 -    } else {
  14.130 -        g_object_set(G_OBJECT(gnl_src),
  14.131 -                     "start", 10 * GST_SECOND, "duration", 10 * GST_SECOND,
  14.132 -                     // /"media-start", 10 * GST_SECOND,
  14.133 -                     // "media-duration", 10 * GST_SECOND,
  14.134 -                     "priority", priority, NULL);
  14.135 -
  14.136 -    }
  14.137 -    d++;
  14.138 -
  14.139 -    return gnl_src;
  14.140 -}
  14.141 -
  14.142 -static void
  14.143 -_composition_pad_added_cb(GstElement * composition,
  14.144 -                          GstPad * pad, gpointer data)
  14.145 -{
  14.146 -    GstPad         *sink_pad =
  14.147 -        gst_element_get_pad(GST_ELEMENT(data), "sink");
  14.148 -    g_debug("compose pad added");
  14.149 -
  14.150 -    if (gst_pad_link(pad, sink_pad) != GST_PAD_LINK_OK) {
  14.151 -        g_warning("Failed to link decode");
  14.152 -    }
  14.153 -
  14.154 -    g_debug("Linked ok");
  14.155 -}
  14.156 -
  14.157 -static void
  14.158 -_compose_add_file(GstElement * compose,
  14.159 -                  const gchar * e_name,
  14.160 -                  const gchar * uri, MyStreamType type, guint priority)
  14.161 -{
  14.162 -    GstElement     *src;
  14.163 -
  14.164 -    src = _create_src_element(e_name, uri, type, priority);
  14.165 -    gst_bin_add(GST_BIN(compose), src);
  14.166 -}
  14.167 -
  14.168 -
  14.169 -int
  14.170 -main(int argc, char **argv)
  14.171 -{
  14.172 -    GstElement     *pipe;
  14.173 -    GstElement     *gnl_compose_a;
  14.174 -    GstElement     *gnl_compose_v;
  14.175 -    GstElement     *asink;
  14.176 -    GstElement     *vsink;
  14.177 -    GstElement     *aqueue;
  14.178 -    GstElement     *vqueue;
  14.179 -
  14.180 -    g_type_init();
  14.181 -    gst_init(&argc, &argv);
  14.182 -
  14.183 -    mainloop = g_main_loop_new(NULL, FALSE);
  14.184 -
  14.185 -    pipe = gst_pipeline_new("test_pipeline");
  14.186 -
  14.187 -    gnl_compose_a = gst_element_factory_make("gnlcomposition", "acompose");
  14.188 -    g_return_val_if_fail(gnl_compose_a != NULL, 1);
  14.189 -
  14.190 -    gnl_compose_v = gst_element_factory_make("gnlcomposition", "vcompose");
  14.191 -    g_return_val_if_fail(gnl_compose_v != NULL, 1);
  14.192 -
  14.193 -
  14.194 -    // _compose_add_file (gnl_compose_a, "src0", argv[1],
  14.195 -    // MY_STREAM_TYPE_AUDIO, 1);
  14.196 -    // _compose_add_file (gnl_compose_a, "src1", argv[2],
  14.197 -    // MY_STREAM_TYPE_AUDIO, 1);
  14.198 -
  14.199 -    d = 0;
  14.200 -
  14.201 -    _compose_add_file(gnl_compose_v, "src2", argv[1], MY_STREAM_TYPE_VIDEO,
  14.202 -                      1);
  14.203 -    _compose_add_file(gnl_compose_v, "src3", argv[2], MY_STREAM_TYPE_VIDEO,
  14.204 -                      1);
  14.205 -
  14.206 -
  14.207 -    // aqueue = gst_element_factory_make ("queue", "aqueue");
  14.208 -    // asink = gst_element_factory_make ("alsasink", "asink");
  14.209 -
  14.210 -    vqueue = gst_element_factory_make("queue", "vqueue");
  14.211 -    vsink = gst_element_factory_make("xvimagesink", "vsink");
  14.212 -
  14.213 -    gst_bin_add_many(GST_BIN(pipe), gnl_compose_a, gnl_compose_v, vqueue,
  14.214 -                     vsink,
  14.215 -                     // aqueue, asink, 
  14.216 -                     NULL);
  14.217 -
  14.218 -    gst_element_link(vqueue, vsink);
  14.219 -    // gst_element_link (aqueue, asink);
  14.220 -
  14.221 -    // g_signal_connect (G_OBJECT (gnl_compose_a), "pad-added",
  14.222 -    // G_CALLBACK (_composition_pad_added_cb), aqueue);
  14.223 -
  14.224 -    g_signal_connect(G_OBJECT(gnl_compose_v), "pad-added",
  14.225 -                     G_CALLBACK(_composition_pad_added_cb), vqueue);
  14.226 -
  14.227 -
  14.228 -    // g_idle_add (_play, pipe);
  14.229 -    gst_element_set_state(GST_ELEMENT(pipe), GST_STATE_PLAYING);
  14.230 -    g_main_loop_run(mainloop);
  14.231 -
  14.232 -    return 0;
  14.233 -}
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/gmyth-stream/gmencoder/INSTALL	Tue Sep 18 13:45:36 2007 +0100
    15.3 @@ -0,0 +1,236 @@
    15.4 +Installation Instructions
    15.5 +*************************
    15.6 +
    15.7 +Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005 Free
    15.8 +Software Foundation, Inc.
    15.9 +
   15.10 +This file is free documentation; the Free Software Foundation gives
   15.11 +unlimited permission to copy, distribute and modify it.
   15.12 +
   15.13 +Basic Installation
   15.14 +==================
   15.15 +
   15.16 +These are generic installation instructions.
   15.17 +
   15.18 +   The `configure' shell script attempts to guess correct values for
   15.19 +various system-dependent variables used during compilation.  It uses
   15.20 +those values to create a `Makefile' in each directory of the package.
   15.21 +It may also create one or more `.h' files containing system-dependent
   15.22 +definitions.  Finally, it creates a shell script `config.status' that
   15.23 +you can run in the future to recreate the current configuration, and a
   15.24 +file `config.log' containing compiler output (useful mainly for
   15.25 +debugging `configure').
   15.26 +
   15.27 +   It can also use an optional file (typically called `config.cache'
   15.28 +and enabled with `--cache-file=config.cache' or simply `-C') that saves
   15.29 +the results of its tests to speed up reconfiguring.  (Caching is
   15.30 +disabled by default to prevent problems with accidental use of stale
   15.31 +cache files.)
   15.32 +
   15.33 +   If you need to do unusual things to compile the package, please try
   15.34 +to figure out how `configure' could check whether to do them, and mail
   15.35 +diffs or instructions to the address given in the `README' so they can
   15.36 +be considered for the next release.  If you are using the cache, and at
   15.37 +some point `config.cache' contains results you don't want to keep, you
   15.38 +may remove or edit it.
   15.39 +
   15.40 +   The file `configure.ac' (or `configure.in') is used to create
   15.41 +`configure' by a program called `autoconf'.  You only need
   15.42 +`configure.ac' if you want to change it or regenerate `configure' using
   15.43 +a newer version of `autoconf'.
   15.44 +
   15.45 +The simplest way to compile this package is:
   15.46 +
   15.47 +  1. `cd' to the directory containing the package's source code and type
   15.48 +     `./configure' to configure the package for your system.  If you're
   15.49 +     using `csh' on an old version of System V, you might need to type
   15.50 +     `sh ./configure' instead to prevent `csh' from trying to execute
   15.51 +     `configure' itself.
   15.52 +
   15.53 +     Running `configure' takes awhile.  While running, it prints some
   15.54 +     messages telling which features it is checking for.
   15.55 +
   15.56 +  2. Type `make' to compile the package.
   15.57 +
   15.58 +  3. Optionally, type `make check' to run any self-tests that come with
   15.59 +     the package.
   15.60 +
   15.61 +  4. Type `make install' to install the programs and any data files and
   15.62 +     documentation.
   15.63 +
   15.64 +  5. You can remove the program binaries and object files from the
   15.65 +     source code directory by typing `make clean'.  To also remove the
   15.66 +     files that `configure' created (so you can compile the package for
   15.67 +     a different kind of computer), type `make distclean'.  There is
   15.68 +     also a `make maintainer-clean' target, but that is intended mainly
   15.69 +     for the package's developers.  If you use it, you may have to get
   15.70 +     all sorts of other programs in order to regenerate files that came
   15.71 +     with the distribution.
   15.72 +
   15.73 +Compilers and Options
   15.74 +=====================
   15.75 +
   15.76 +Some systems require unusual options for compilation or linking that the
   15.77 +`configure' script does not know about.  Run `./configure --help' for
   15.78 +details on some of the pertinent environment variables.
   15.79 +
   15.80 +   You can give `configure' initial values for configuration parameters
   15.81 +by setting variables in the command line or in the environment.  Here
   15.82 +is an example:
   15.83 +
   15.84 +     ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
   15.85 +
   15.86 +   *Note Defining Variables::, for more details.
   15.87 +
   15.88 +Compiling For Multiple Architectures
   15.89 +====================================
   15.90 +
   15.91 +You can compile the package for more than one kind of computer at the
   15.92 +same time, by placing the object files for each architecture in their
   15.93 +own directory.  To do this, you must use a version of `make' that
   15.94 +supports the `VPATH' variable, such as GNU `make'.  `cd' to the
   15.95 +directory where you want the object files and executables to go and run
   15.96 +the `configure' script.  `configure' automatically checks for the
   15.97 +source code in the directory that `configure' is in and in `..'.
   15.98 +
   15.99 +   If you have to use a `make' that does not support the `VPATH'
  15.100 +variable, you have to compile the package for one architecture at a
  15.101 +time in the source code directory.  After you have installed the
  15.102 +package for one architecture, use `make distclean' before reconfiguring
  15.103 +for another architecture.
  15.104 +
  15.105 +Installation Names
  15.106 +==================
  15.107 +
  15.108 +By default, `make install' installs the package's commands under
  15.109 +`/usr/local/bin', include files under `/usr/local/include', etc.  You
  15.110 +can specify an installation prefix other than `/usr/local' by giving
  15.111 +`configure' the option `--prefix=PREFIX'.
  15.112 +
  15.113 +   You can specify separate installation prefixes for
  15.114 +architecture-specific files and architecture-independent files.  If you
  15.115 +pass the option `--exec-prefix=PREFIX' to `configure', the package uses
  15.116 +PREFIX as the prefix for installing programs and libraries.
  15.117 +Documentation and other data files still use the regular prefix.
  15.118 +
  15.119 +   In addition, if you use an unusual directory layout you can give
  15.120 +options like `--bindir=DIR' to specify different values for particular
  15.121 +kinds of files.  Run `configure --help' for a list of the directories
  15.122 +you can set and what kinds of files go in them.
  15.123 +
  15.124 +   If the package supports it, you can cause programs to be installed
  15.125 +with an extra prefix or suffix on their names by giving `configure' the
  15.126 +option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
  15.127 +
  15.128 +Optional Features
  15.129 +=================
  15.130 +
  15.131 +Some packages pay attention to `--enable-FEATURE' options to
  15.132 +`configure', where FEATURE indicates an optional part of the package.
  15.133 +They may also pay attention to `--with-PACKAGE' options, where PACKAGE
  15.134 +is something like `gnu-as' or `x' (for the X Window System).  The
  15.135 +`README' should mention any `--enable-' and `--with-' options that the
  15.136 +package recognizes.
  15.137 +
  15.138 +   For packages that use the X Window System, `configure' can usually
  15.139 +find the X include and library files automatically, but if it doesn't,
  15.140 +you can use the `configure' options `--x-includes=DIR' and
  15.141 +`--x-libraries=DIR' to specify their locations.
  15.142 +
  15.143 +Specifying the System Type
  15.144 +==========================
  15.145 +
  15.146 +There may be some features `configure' cannot figure out automatically,
  15.147 +but needs to determine by the type of machine the package will run on.
  15.148 +Usually, assuming the package is built to be run on the _same_
  15.149 +architectures, `configure' can figure that out, but if it prints a
  15.150 +message saying it cannot guess the machine type, give it the
  15.151 +`--build=TYPE' option.  TYPE can either be a short name for the system
  15.152 +type, such as `sun4', or a canonical name which has the form:
  15.153 +
  15.154 +     CPU-COMPANY-SYSTEM
  15.155 +
  15.156 +where SYSTEM can have one of these forms:
  15.157 +
  15.158 +     OS KERNEL-OS
  15.159 +
  15.160 +   See the file `config.sub' for the possible values of each field.  If
  15.161 +`config.sub' isn't included in this package, then this package doesn't
  15.162 +need to know the machine type.
  15.163 +
  15.164 +   If you are _building_ compiler tools for cross-compiling, you should
  15.165 +use the option `--target=TYPE' to select the type of system they will
  15.166 +produce code for.
  15.167 +
  15.168 +   If you want to _use_ a cross compiler, that generates code for a
  15.169 +platform different from the build platform, you should specify the
  15.170 +"host" platform (i.e., that on which the generated programs will
  15.171 +eventually be run) with `--host=TYPE'.
  15.172 +
  15.173 +Sharing Defaults
  15.174 +================
  15.175 +
  15.176 +If you want to set default values for `configure' scripts to share, you
  15.177 +can create a site shell script called `config.site' that gives default
  15.178 +values for variables like `CC', `cache_file', and `prefix'.
  15.179 +`configure' looks for `PREFIX/share/config.site' if it exists, then
  15.180 +`PREFIX/etc/config.site' if it exists.  Or, you can set the
  15.181 +`CONFIG_SITE' environment variable to the location of the site script.
  15.182 +A warning: not all `configure' scripts look for a site script.
  15.183 +
  15.184 +Defining Variables
  15.185 +==================
  15.186 +
  15.187 +Variables not defined in a site shell script can be set in the
  15.188 +environment passed to `configure'.  However, some packages may run
  15.189 +configure again during the build, and the customized values of these
  15.190 +variables may be lost.  In order to avoid this problem, you should set
  15.191 +them in the `configure' command line, using `VAR=value'.  For example:
  15.192 +
  15.193 +     ./configure CC=/usr/local2/bin/gcc
  15.194 +
  15.195 +causes the specified `gcc' to be used as the C compiler (unless it is
  15.196 +overridden in the site shell script).  Here is a another example:
  15.197 +
  15.198 +     /bin/bash ./configure CONFIG_SHELL=/bin/bash
  15.199 +
  15.200 +Here the `CONFIG_SHELL=/bin/bash' operand causes subsequent
  15.201 +configuration-related scripts to be executed by `/bin/bash'.
  15.202 +
  15.203 +`configure' Invocation
  15.204 +======================
  15.205 +
  15.206 +`configure' recognizes the following options to control how it operates.
  15.207 +
  15.208 +`--help'
  15.209 +`-h'
  15.210 +     Print a summary of the options to `configure', and exit.
  15.211 +
  15.212 +`--version'
  15.213 +`-V'
  15.214 +     Print the version of Autoconf used to generate the `configure'
  15.215 +     script, and exit.
  15.216 +
  15.217 +`--cache-file=FILE'
  15.218 +     Enable the cache: use and save the results of the tests in FILE,
  15.219 +     traditionally `config.cache'.  FILE defaults to `/dev/null' to
  15.220 +     disable caching.
  15.221 +
  15.222 +`--config-cache'
  15.223 +`-C'
  15.224 +     Alias for `--cache-file=config.cache'.
  15.225 +
  15.226 +`--quiet'
  15.227 +`--silent'
  15.228 +`-q'
  15.229 +     Do not print messages saying which checks are being made.  To
  15.230 +     suppress all normal output, redirect it to `/dev/null' (any error
  15.231 +     messages will still be shown).
  15.232 +
  15.233 +`--srcdir=DIR'
  15.234 +     Look for the package's source code in directory DIR.  Usually
  15.235 +     `configure' can determine that directory automatically.
  15.236 +
  15.237 +`configure' also accepts some other, not widely useful, options.  Run
  15.238 +`configure --help' for more details.
  15.239 +
    16.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2 +++ b/gmyth-stream/gmencoder/Makefile.am	Tue Sep 18 13:45:36 2007 +0100
    16.3 @@ -0,0 +1,7 @@
    16.4 +SUBDIRS = src
    16.5 +
    16.6 +EXTRA_DIST = 			\
    16.7 +	ChangeLog
    16.8 +	
    16.9 +DIST_SUBDIRS = 			\
   16.10 +	src
    17.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.2 +++ b/gmyth-stream/gmencoder/autogen.sh	Tue Sep 18 13:45:36 2007 +0100
    17.3 @@ -0,0 +1,19 @@
    17.4 +#!/bin/sh
    17.5 +# Run this to generate all the initial makefiles, etc.
    17.6 +
    17.7 +srcdir=`dirname $0`
    17.8 +test -z "$srcdir" && srcdir=.
    17.9 +
   17.10 +PKG_NAME="gmemcoder"
   17.11 +
   17.12 +(test -f $srcdir/configure.ac) || {
   17.13 +    echo -n "**Error**: Directory "\`$srcdir\'" does not look like the"
   17.14 +    echo " top-level $PKG_NAME directory"
   17.15 +    exit 1
   17.16 +}
   17.17 +
   17.18 +which gnome-autogen.sh || {
   17.19 +    echo "You need to install gnome-common from the GNOME CVS"
   17.20 +    exit 1
   17.21 +}
   17.22 +REQUIRED_AUTOMAKE_VERSION=1.9 USE_GNOME2_MACROS=1 . gnome-autogen.sh
    18.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.2 +++ b/gmyth-stream/gmencoder/configure.ac	Tue Sep 18 13:45:36 2007 +0100
    18.3 @@ -0,0 +1,93 @@
    18.4 +#                                               -*- Autoconf -*-
    18.5 +# Process this file with autoconf to produce a configure script.
    18.6 +
    18.7 +AC_PREREQ(2.50)
    18.8 +
    18.9 +AC_INIT([gmemcoder],[0.1])
   18.10 +
   18.11 +AC_CONFIG_MACRO_DIR([m4])
   18.12 +AC_CONFIG_HEADER(config.h)
   18.13 +
   18.14 +AS_VERSION(gmemcoder, GMEMCODER, 0, 1, 0, 0, GMEMCODER_SVN="no", GMEMCODER_SVN="yes")
   18.15 +GMEMCODER_MAJORMINOR=$GMEMCODER_VERSION.$GMEMCODER_MINOR_VERSION
   18.16 +AC_SUBST(GMEMCODER_MAJORMINOR)
   18.17 +
   18.18 +dnl AM_MAINTAINER_MODE provides the option to enable maintainer mode
   18.19 +AM_MAINTAINER_MODE
   18.20 +dnl make aclocal work in maintainer mode
   18.21 +AC_SUBST(ACLOCAL_AMFLAGS, "-I m4")
   18.22 +
   18.23 +AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
   18.24 +
   18.25 +# Checks for programs.
   18.26 +# check for tools
   18.27 +# Make sure CFLAGS is defined to stop AC_PROC_CC adding -g
   18.28 +CFLAGS="$CFLAGS -Wall"
   18.29 +AC_PROG_CC
   18.30 +AC_PROG_LIBTOOL
   18.31 +
   18.32 +# Checks for libraries.
   18.33 +
   18.34 +# Checks for header files.
   18.35 +AC_HEADER_STDC
   18.36 +
   18.37 +#Test if --disable-debug given
   18.38 +AC_ARG_ENABLE(debug,
   18.39 +	AC_HELP_STRING([--disable-debug], [enable debugging mode]))
   18.40 +if test x"$enable_debug" != xno; then
   18.41 +    CFLAGS="$CFLAGS -g -DMYTH_STREAM_USE_DEBUG"
   18.42 +else
   18.43 +    CFLAGS="$CFLAGS -O2 -DG_DISABLE_CHECKS"
   18.44 +fi          
   18.45 +
   18.46 +
   18.47 +# Checks required packages ####################################################
   18.48 +###############################################################################
   18.49 +
   18.50 +## Check for pkgconfig ########################################################
   18.51 +###############################################################################
   18.52 +AC_CHECK_PROG(HAVE_PKGCONFIG, pkg-config, yes, no)
   18.53 +if test "x$HAVE_PKGCONFIG" = "xno"; then
   18.54 +  AC_MSG_ERROR(you need to have pkgconfig installed !)
   18.55 +fi
   18.56 +
   18.57 +## Check for Glib2.0 ##########################################################
   18.58 +###############################################################################
   18.59 +PKG_CHECK_MODULES(GLIB, glib-2.0, HAVE_GLIB=yes,HAVE_GLIB=no)
   18.60 +if test "x$HAVE_GLIB" = "xno"; then
   18.61 +  AC_MSG_ERROR(you need glib-2.0 installed)
   18.62 +fi
   18.63 +AC_SUBST(GLIB_CFLAGS)
   18.64 +AC_SUBST(GLIB_LIBS)
   18.65 +
   18.66 +## Check for GnomeVFS ##########################################################
   18.67 +###############################################################################
   18.68 +PKG_CHECK_MODULES(GVFS, gnome-vfs-2.0, HAVE_GVFS=yes,HAVE_GVFS=no)
   18.69 +if test "x$HAVE_GVFS" = "xno"; then
   18.70 +  AC_MSG_ERROR(you need gnome-vfs-2.0 installed)
   18.71 +fi
   18.72 +AC_SUBST(GVFS_CFLAGS)
   18.73 +AC_SUBST(GVFS_LIBS)
   18.74 +
   18.75 +
   18.76 +## Check for gst-base #########################################################
   18.77 +###############################################################################
   18.78 +PKG_CHECK_MODULES(GST, [gstreamer-base-0.10])
   18.79 +AC_SUBST(GST_CFLAGS)
   18.80 +AC_SUBST(GST_LIBS)
   18.81 +
   18.82 +AC_SUBST(CFLAGS)
   18.83 +AC_SUBST(LDFLAGS)
   18.84 +AC_SUBST(LIBS)
   18.85 +
   18.86 +AC_OUTPUT([
   18.87 +Makefile
   18.88 +src/Makefile
   18.89 +])
   18.90 +
   18.91 +if test "x$enable_debug" != "xno"; then
   18.92 +    AC_MSG_NOTICE([Debug: Enabled])
   18.93 +else
   18.94 +    AC_MSG_NOTICE([Debug: Disabled])
   18.95 +fi          
   18.96 +
    19.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.2 +++ b/gmyth-stream/gmencoder/m4/as-compiler-flag.m4	Tue Sep 18 13:45:36 2007 +0100
    19.3 @@ -0,0 +1,32 @@
    19.4 +dnl as-compiler-flag.m4 0.1.0
    19.5 +
    19.6 +dnl autostars m4 macro for detection of compiler flags
    19.7 +
    19.8 +dnl David Schleef <ds@schleef.org>
    19.9 +
   19.10 +dnl $Id: as-compiler-flag.m4,v 1.1 2005/06/18 18:02:46 burgerman Exp $
   19.11 +
   19.12 +dnl AS_COMPILER_FLAG(CFLAGS, ACTION-IF-ACCEPTED, [ACTION-IF-NOT-ACCEPTED])
   19.13 +dnl Tries to compile with the given CFLAGS.
   19.14 +dnl Runs ACTION-IF-ACCEPTED if the compiler can compile with the flags,
   19.15 +dnl and ACTION-IF-NOT-ACCEPTED otherwise.
   19.16 +
   19.17 +AC_DEFUN([AS_COMPILER_FLAG],
   19.18 +[
   19.19 +  AC_MSG_CHECKING([to see if compiler understands $1])
   19.20 +
   19.21 +  save_CFLAGS="$CFLAGS"
   19.22 +  CFLAGS="$CFLAGS $1"
   19.23 +
   19.24 +  AC_TRY_COMPILE([ ], [], [flag_ok=yes], [flag_ok=no])
   19.25 +  CFLAGS="$save_CFLAGS"
   19.26 +
   19.27 +  if test "X$flag_ok" = Xyes ; then
   19.28 +    $2
   19.29 +    true
   19.30 +  else
   19.31 +    $3
   19.32 +    true
   19.33 +  fi
   19.34 +  AC_MSG_RESULT([$flag_ok])
   19.35 +])
    20.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.2 +++ b/gmyth-stream/gmencoder/m4/as-expand.m4	Tue Sep 18 13:45:36 2007 +0100
    20.3 @@ -0,0 +1,40 @@
    20.4 +dnl AS_AC_EXPAND(VAR, CONFIGURE_VAR)
    20.5 +dnl
    20.6 +dnl example
    20.7 +dnl AS_AC_EXPAND(SYSCONFDIR, $sysconfdir)
    20.8 +dnl will set SYSCONFDIR to /usr/local/etc if prefix=/usr/local
    20.9 +
   20.10 +AC_DEFUN([AS_AC_EXPAND],
   20.11 +[
   20.12 +  EXP_VAR=[$1]
   20.13 +  FROM_VAR=[$2]
   20.14 +
   20.15 +  dnl first expand prefix and exec_prefix if necessary
   20.16 +  prefix_save=$prefix
   20.17 +  exec_prefix_save=$exec_prefix
   20.18 +
   20.19 +  dnl if no prefix given, then use /usr/local, the default prefix
   20.20 +  if test "x$prefix" = "xNONE"; then
   20.21 +    prefix=$ac_default_prefix
   20.22 +  fi
   20.23 +  dnl if no exec_prefix given, then use prefix
   20.24 +  if test "x$exec_prefix" = "xNONE"; then
   20.25 +    exec_prefix=$prefix
   20.26 +  fi
   20.27 +
   20.28 +  full_var="$FROM_VAR"
   20.29 +  dnl loop until it doesn't change anymore
   20.30 +  while true; do
   20.31 +    new_full_var="`eval echo $full_var`"
   20.32 +    if test "x$new_full_var"="x$full_var"; then break; fi
   20.33 +    full_var=$new_full_var
   20.34 +  done
   20.35 +
   20.36 +  dnl clean up
   20.37 +  full_var=$new_full_var
   20.38 +  AC_SUBST([$1], "$full_var")
   20.39 +
   20.40 +  dnl restore prefix and exec_prefix
   20.41 +  prefix=$prefix_save
   20.42 +  exec_prefix=$exec_prefix_save
   20.43 +])
    21.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.2 +++ b/gmyth-stream/gmencoder/m4/as-version.m4	Tue Sep 18 13:45:36 2007 +0100
    21.3 @@ -0,0 +1,67 @@
    21.4 +dnl as-version.m4 0.1.0
    21.5 +
    21.6 +dnl autostars m4 macro for versioning
    21.7 +
    21.8 +dnl Thomas Vander Stichele <thomas at apestaart dot org>
    21.9 +
   21.10 +dnl $Id: as-version.m4,v 1.1 2005/06/18 18:02:46 burgerman Exp $
   21.11 +
   21.12 +dnl AS_VERSION(PACKAGE, PREFIX, MAJOR, MINOR, MICRO, NANO,
   21.13 +dnl            ACTION-IF-NO-NANO, [ACTION-IF-NANO])
   21.14 +
   21.15 +dnl example
   21.16 +dnl AS_VERSION(gstreamer, GST_VERSION, 0, 3, 2,)
   21.17 +dnl for a 0.3.2 release version
   21.18 +
   21.19 +dnl this macro
   21.20 +dnl - defines [$PREFIX]_MAJOR, MINOR and MICRO
   21.21 +dnl - if NANO is empty, then we're in release mode, else in cvs/dev mode
   21.22 +dnl - defines [$PREFIX], VERSION, and [$PREFIX]_RELEASE
   21.23 +dnl - executes the relevant action
   21.24 +dnl - AC_SUBST's PACKAGE, VERSION, [$PREFIX] and [$PREFIX]_RELEASE
   21.25 +dnl   as well as the little ones
   21.26 +dnl - doesn't call AM_INIT_AUTOMAKE anymore because it prevents
   21.27 +dnl   maintainer mode from running ok
   21.28 +dnl
   21.29 +dnl don't forget to put #undef [$2] and [$2]_RELEASE in acconfig.h
   21.30 +dnl if you use acconfig.h
   21.31 +
   21.32 +AC_DEFUN([AS_VERSION],
   21.33 +[
   21.34 +  PACKAGE=[$1]
   21.35 +  [$2]_MAJOR=[$3]
   21.36 +  [$2]_MINOR=[$4]
   21.37 +  [$2]_MICRO=[$5]
   21.38 +  NANO=[$6]
   21.39 +  [$2]_NANO=$NANO
   21.40 +  if test "x$NANO" = "x" || test "x$NANO" = "x0";
   21.41 +  then
   21.42 +      AC_MSG_NOTICE(configuring [$1] for release)
   21.43 +      VERSION=[$3].[$4].[$5]
   21.44 +      [$2]_RELEASE=1
   21.45 +      dnl execute action
   21.46 +      ifelse([$7], , :, [$7])
   21.47 +  else
   21.48 +      AC_MSG_NOTICE(configuring [$1] for development with nano $NANO)
   21.49 +      VERSION=[$3].[$4].[$5].$NANO
   21.50 +      [$2]_RELEASE=0.`date +%Y%m%d.%H%M%S`
   21.51 +      dnl execute action
   21.52 +      ifelse([$8], , :, [$8])
   21.53 +  fi
   21.54 +
   21.55 +  [$2]=$VERSION
   21.56 +  AC_DEFINE_UNQUOTED([$2], "$[$2]", [Define the version])
   21.57 +  AC_SUBST([$2])
   21.58 +  AC_DEFINE_UNQUOTED([$2]_RELEASE, "$[$2]_RELEASE", [Define the release version])
   21.59 +  AC_SUBST([$2]_RELEASE)
   21.60 +
   21.61 +  AC_SUBST([$2]_MAJOR)
   21.62 +  AC_SUBST([$2]_MINOR)
   21.63 +  AC_SUBST([$2]_MICRO)
   21.64 +  AC_SUBST([$2]_NANO)
   21.65 +  AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Define the package name])
   21.66 +  AC_SUBST(PACKAGE)
   21.67 +  AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Define the version])
   21.68 +  AC_SUBST(VERSION)
   21.69 +])
   21.70 +
    22.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.2 +++ b/gmyth-stream/gmencoder/m4/gst-feature.m4	Tue Sep 18 13:45:36 2007 +0100
    22.3 @@ -0,0 +1,211 @@
    22.4 +dnl Perform a check for a feature for GStreamer
    22.5 +dnl Richard Boulton <richard-alsa@tartarus.org>
    22.6 +dnl Thomas Vander Stichele <thomas@apestaart.org> added useful stuff
    22.7 +dnl Last modification: 25/06/2001
    22.8 +dnl GST_CHECK_FEATURE(FEATURE-NAME, FEATURE-DESCRIPTION,
    22.9 +dnl                   DEPENDENT-PLUGINS, TEST-FOR-FEATURE,
   22.10 +dnl                   DISABLE-BY-DEFAULT, ACTION-IF-USE, ACTION-IF-NOTUSE)
   22.11 +dnl
   22.12 +dnl This macro adds a command line argument to enable the user to enable
   22.13 +dnl or disable a feature, and if the feature is enabled, performs a supplied
   22.14 +dnl test to check if the feature is available.
   22.15 +dnl
   22.16 +dnl The test should define HAVE_<FEATURE-NAME> to "yes" or "no" depending
   22.17 +dnl on whether the feature is available.
   22.18 +dnl
   22.19 +dnl The macro will set USE_<FEATURE-NAME> to "yes" or "no" depending on
   22.20 +dnl whether the feature is to be used.
   22.21 +dnl Thomas changed this, so that when USE_<FEATURE-NAME> was already set
   22.22 +dnl to no, then it stays that way.
   22.23 +dnl
   22.24 +dnl The macro will call AM_CONDITIONAL(USE_<<FEATURE-NAME>, ...) to allow
   22.25 +dnl the feature to control what is built in Makefile.ams.  If you want
   22.26 +dnl additional actions resulting from the test, you can add them with the
   22.27 +dnl ACTION-IF-USE and ACTION-IF-NOTUSE parameters.
   22.28 +dnl 
   22.29 +dnl FEATURE-NAME        is the name of the feature, and should be in
   22.30 +dnl                     purely upper case characters.
   22.31 +dnl FEATURE-DESCRIPTION is used to describe the feature in help text for
   22.32 +dnl                     the command line argument.
   22.33 +dnl DEPENDENT-PLUGINS   lists any plugins which depend on this feature.
   22.34 +dnl TEST-FOR-FEATURE    is a test which sets HAVE_<FEATURE-NAME> to "yes"
   22.35 +dnl                     or "no" depending on whether the feature is
   22.36 +dnl                     available.
   22.37 +dnl DISABLE-BY-DEFAULT  if "disabled", the feature is disabled by default,
   22.38 +dnl                     if any other value, the feature is enabled by default.
   22.39 +dnl ACTION-IF-USE       any extra actions to perform if the feature is to be
   22.40 +dnl                     used.
   22.41 +dnl ACTION-IF-NOTUSE    any extra actions to perform if the feature is not to
   22.42 +dnl                     be used.
   22.43 +dnl
   22.44 +dnl
   22.45 +dnl thomas :
   22.46 +dnl we also added a history.  
   22.47 +dnl GST_PLUGINS_YES will contain all plugins to be built
   22.48 +dnl                 that were checked through GST_CHECK_FEATURE
   22.49 +dnl GST_PLUGINS_NO will contain those that won't be built
   22.50 +
   22.51 +AC_DEFUN([GST_CHECK_FEATURE],
   22.52 +AC_MSG_NOTICE(***)
   22.53 +AC_MSG_NOTICE(*** checking plugin: [$3] ***)
   22.54 +AC_MSG_NOTICE(***)
   22.55 +[dnl
   22.56 +builtin(define, [gst_endisable], ifelse($5, [disabled], [enable], [disable]))dnl
   22.57 +dnl if it is set to NO, then don't even consider it for building
   22.58 +NOUSE=
   22.59 +if test "x$USE_[$1]" = "xno"; then
   22.60 +  NOUSE="yes"
   22.61 +fi
   22.62 +AC_ARG_ENABLE(translit([$1], A-Z, a-z),
   22.63 +  [  ]builtin(format, --%-26s gst_endisable %s, gst_endisable-translit([$1], A-Z, a-z), [$2]ifelse([$3],,,: [$3])),
   22.64 +  [ case "${enableval}" in
   22.65 +      yes) USE_[$1]=yes;;
   22.66 +      no) USE_[$1]=no;;
   22.67 +      *) AC_MSG_ERROR(bad value ${enableval} for --enable-translit([$1], A-Z, a-z)) ;;
   22.68 +    esac],
   22.69 +  [ USE_$1=]ifelse($5, [disabled], [no], [yes]))           dnl DEFAULT
   22.70 +
   22.71 +dnl *** set it back to no if it was preset to no
   22.72 +if test "x$NOUSE" = "xyes"; then
   22.73 +  USE_[$1]="no"
   22.74 +  AC_MSG_WARN(*** $3 pre-configured not to be built)
   22.75 +fi
   22.76 +NOUSE=
   22.77 +
   22.78 +dnl *** If it's enabled
   22.79 +
   22.80 +if test x$USE_[$1] = xyes; then
   22.81 +  dnl save compile variables before the test
   22.82 +
   22.83 +  gst_check_save_LIBS=$LIBS
   22.84 +  gst_check_save_LDFLAGS=$LDFLAGS
   22.85 +  gst_check_save_CFLAGS=$CFLAGS
   22.86 +  gst_check_save_CPPFLAGS=$CPPFLAGS
   22.87 +  gst_check_save_CXXFLAGS=$CXXFLAGS
   22.88 +
   22.89 +  HAVE_[$1]=no
   22.90 +  dnl TEST_FOR_FEATURE
   22.91 +  $4
   22.92 +
   22.93 +  LIBS=$gst_check_save_LIBS
   22.94 +  LDFLAGS=$gst_check_save_LDFLAGS
   22.95 +  CFLAGS=$gst_check_save_CFLAGS
   22.96 +  CPPFLAGS=$gst_check_save_CPPFLAGS
   22.97 +  CXXFLAGS=$gst_check_save_CXXFLAGS
   22.98 +
   22.99 +  dnl If it isn't found, unset USE_[$1]
  22.100 +  if test x$HAVE_[$1] = xno; then
  22.101 +    USE_[$1]=no
  22.102 +  fi
  22.103 +fi
  22.104 +dnl *** Warn if it's disabled or not found
  22.105 +if test x$USE_[$1] = xyes; then
  22.106 +  ifelse([$6], , :, [$6])
  22.107 +  if test "x$3" != "x"; then
  22.108 +    GST_PLUGINS_YES="\t[$3]\n$GST_PLUGINS_YES"
  22.109 +  fi
  22.110 +  AC_DEFINE(HAVE_[$1], , [support for features: $3])
  22.111 +else
  22.112 +  ifelse([$3], , :, [AC_MSG_NOTICE(*** These plugins will not be built: [$3])])
  22.113 +  if test "x$3" != "x"; then
  22.114 +    GST_PLUGINS_NO="\t[$3]\n$GST_PLUGINS_NO"
  22.115 +  fi
  22.116 +  ifelse([$7], , :, [$7])
  22.117 +fi
  22.118 +dnl *** Define the conditional as appropriate
  22.119 +AM_CONDITIONAL(USE_[$1], test x$USE_[$1] = xyes)
  22.120 +])
  22.121 +
  22.122 +dnl Use a -config program which accepts --cflags and --libs parameters
  22.123 +dnl to set *_CFLAGS and *_LIBS and check existence of a feature.
  22.124 +dnl Richard Boulton <richard-alsa@tartarus.org>
  22.125 +dnl Last modification: 26/06/2001
  22.126 +dnl GST_CHECK_CONFIGPROG(FEATURE-NAME, CONFIG-PROG-FILENAME, MODULES)
  22.127 +dnl
  22.128 +dnl This check was written for GStreamer: it should be renamed and checked
  22.129 +dnl for portability if you decide to use it elsewhere.
  22.130 +dnl
  22.131 +AC_DEFUN([GST_CHECK_CONFIGPROG],
  22.132 +[
  22.133 +  AC_PATH_PROG([$1]_CONFIG, [$2], no)
  22.134 +  if test x$[$1]_CONFIG = xno; then
  22.135 +    [$1]_LIBS=
  22.136 +    [$1]_CFLAGS=
  22.137 +    HAVE_[$1]=no
  22.138 +  else
  22.139 +    if [$2] --plugin-libs [$3] &> /dev/null; then
  22.140 +      [$1]_LIBS=`[$2] --plugin-libs [$3]`
  22.141 +    else
  22.142 +      [$1]_LIBS=`[$2] --libs [$3]`
  22.143 +    fi
  22.144 +    [$1]_CFLAGS=`[$2] --cflags [$3]`
  22.145 +    HAVE_[$1]=yes
  22.146 +  fi
  22.147 +  AC_SUBST([$1]_LIBS)
  22.148 +  AC_SUBST([$1]_CFLAGS)
  22.149 +])
  22.150 +
  22.151 +dnl Use AC_CHECK_LIB and AC_CHECK_HEADER to do both tests at once
  22.152 +dnl sets HAVE_module if we have it
  22.153 +dnl Richard Boulton <richard-alsa@tartarus.org>
  22.154 +dnl Last modification: 26/06/2001
  22.155 +dnl GST_CHECK_LIBHEADER(FEATURE-NAME, LIB NAME, LIB FUNCTION, EXTRA LD FLAGS, 
  22.156 +dnl                     HEADER NAME, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
  22.157 +dnl
  22.158 +dnl This check was written for GStreamer: it should be renamed and checked
  22.159 +dnl for portability if you decide to use it elsewhere.
  22.160 +dnl
  22.161 +AC_DEFUN([GST_CHECK_LIBHEADER],
  22.162 +[
  22.163 +  AC_CHECK_LIB([$2], [$3], HAVE_[$1]=yes, HAVE_[$1]=no,[$4])
  22.164 +  if test "x$HAVE_[$1]" = "xyes"; then
  22.165 +    AC_CHECK_HEADER([$5], :, HAVE_[$1]=no)
  22.166 +    if test "x$HAVE_[$1]" = "xyes"; then
  22.167 +      dnl execute what needs to be
  22.168 +      ifelse([$6], , :, [$6])
  22.169 +    else
  22.170 +      ifelse([$7], , :, [$7])
  22.171 +    fi
  22.172 +  else
  22.173 +    ifelse([$7], , :, [$7])
  22.174 +  fi
  22.175 +  AC_SUBST(HAVE_[$1])
  22.176 +]
  22.177 +)
  22.178 +
  22.179 +dnl 2004-02-14 Thomas - changed to get set properly and use proper output
  22.180 +dnl 2003-06-27 Benjamin Otte - changed to make this work with gstconfig.h
  22.181 +dnl
  22.182 +dnl Add a subsystem --disable flag and all the necessary symbols and substitions
  22.183 +dnl
  22.184 +dnl GST_CHECK_SUBSYSTEM_DISABLE(SYSNAME, [subsystem name])
  22.185 +dnl
  22.186 +AC_DEFUN([GST_CHECK_SUBSYSTEM_DISABLE],
  22.187 +[
  22.188 +  dnl this define will replace each literal subsys_def occurrence with
  22.189 +  dnl the lowercase hyphen-separated subsystem
  22.190 +  dnl e.g. if $1 is GST_DEBUG then subsys_def will be a macro with gst-debug
  22.191 +  define([subsys_def],translit([$1], _A-Z, -a-z))
  22.192 +
  22.193 +  AC_ARG_ENABLE(subsys_def, 
  22.194 +    AC_HELP_STRING(--disable-subsys_def, [disable $2]),
  22.195 +    [
  22.196 +      case "${enableval}" in
  22.197 +        yes) GST_DISABLE_[$1]=no ;;
  22.198 +        no) GST_DISABLE_[$1]=yes ;;
  22.199 +        *) AC_MSG_ERROR([bad value ${enableval} for --enable-subsys_def]) ;;
  22.200 +       esac
  22.201 +    ],
  22.202 +    [GST_DISABLE_[$1]=no]) dnl Default value
  22.203 +
  22.204 +  if test x$GST_DISABLE_[$1] = xyes; then
  22.205 +    AC_MSG_NOTICE([disabled subsystem [$2]])
  22.206 +    GST_DISABLE_[$1]_DEFINE="#define GST_DISABLE_$1 1" 
  22.207 +  else
  22.208 +    GST_DISABLE_[$1]_DEFINE="/* #undef GST_DISABLE_$1 */"
  22.209 +  fi
  22.210 +  AC_SUBST(GST_DISABLE_[$1]_DEFINE)
  22.211 +  undefine([subsys_def])
  22.212 +])
  22.213 +
  22.214 +
    23.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.2 +++ b/gmyth-stream/gmencoder/src/Makefile.am	Tue Sep 18 13:45:36 2007 +0100
    23.3 @@ -0,0 +1,20 @@
    23.4 +bin_PROGRAMS = \
    23.5 +	gmencoder
    23.6 +
    23.7 +gmencoder_SOURCES = \
    23.8 +	main.c \
    23.9 +	gmencoder.c \
   23.10 +	gmencoder.h 
   23.11 +	
   23.12 +gmencoder_LDADD = \
   23.13 +	$(GLIB_LIBS) \
   23.14 +	$(GST_LIBS) \
   23.15 +	$(GVFS_LIBS) \
   23.16 +	-lgstinterfaces-0.10
   23.17 +
   23.18 +AM_CPPFLAGS = \
   23.19 +	$(GLIB_CFLAGS) \
   23.20 +	$(GST_CFLAGS) \
   23.21 +    $(GVFS_CFLAGS)
   23.22 +
   23.23 +CLEANFILES = 
    24.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.2 +++ b/gmyth-stream/gmencoder/src/gmencoder.c	Tue Sep 18 13:45:36 2007 +0100
    24.3 @@ -0,0 +1,1207 @@
    24.4 +#ifdef HAVE_CONFIG_H
    24.5 +#include "config.h"
    24.6 +#endif
    24.7 +
    24.8 +#include <sys/stat.h>
    24.9 +#include <fcntl.h>
   24.10 +#include <unistd.h>
   24.11 +#include <glib.h>
   24.12 +#include <gst/gst.h>
   24.13 +#include <string.h>
   24.14 +#include <sys/types.h>
   24.15 +#include <sys/socket.h>
   24.16 +#include <libgnomevfs/gnome-vfs.h>
   24.17 +#include <gst/interfaces/tuner.h>
   24.18 +
   24.19 +#include "gmencoder.h"
   24.20 +
   24.21 +#define G_MENCODER_GET_PRIVATE(obj) \
   24.22 +    (G_TYPE_INSTANCE_GET_PRIVATE ((obj), G_TYPE_MENCODER, GMencoderPrivate))
   24.23 +
   24.24 +#define USE_MANUAL_SINK
   24.25 +#define GMENCODER_TIMEOUT	5000
   24.26 +
   24.27 +typedef struct _GMencoderPrivate GMencoderPrivate;
   24.28 +typedef struct _SetupInfo SetupInfo;
   24.29 +
   24.30 +struct _SetupInfo {
   24.31 +    gchar          *video_encode;
   24.32 +    gchar          *mux_name;
   24.33 +    gchar         **video_encode_prop;
   24.34 +    gdouble         video_fps;
   24.35 +    gdouble         video_rate;
   24.36 +    guint           video_width;
   24.37 +    guint           video_height;
   24.38 +    gchar          *audio_encode;
   24.39 +    gchar         **audio_encode_prop;
   24.40 +    guint           audio_rate;
   24.41 +};
   24.42 +
   24.43 +
   24.44 +struct _GMencoderPrivate {
   24.45 +    GstElement     *pipe;
   24.46 +    GstElement     *abin;
   24.47 +    GstElement     *vbin;
   24.48 +    GstElement     *sink;
   24.49 +    GstElement     *src;
   24.50 +
   24.51 +    GnomeVFSHandle  *handle;
   24.52 +
   24.53 +    gboolean        ready;
   24.54 +    SetupInfo      *info;
   24.55 +    GstClockTime    videot;
   24.56 +    GstClockTime    audiot;
   24.57 +    gint            sources;
   24.58 +    gint            tick_id;
   24.59 +    gint64          duration;
   24.60 +    gboolean        send_chunked;
   24.61 +    gint 	    timeout_id;
   24.62 +
   24.63 +    //V4l info
   24.64 +    GstElement *v4lsrc;
   24.65 +    gchar *channel;
   24.66 +    gchar *norm;
   24.67 +    glong frequency;
   24.68 +};
   24.69 +
   24.70 +enum {
   24.71 +    PAUSED,
   24.72 +    PLAYING,
   24.73 +    STOPED,
   24.74 +    EOS,
   24.75 +    ERROR,
   24.76 +    LAST_SIGNAL
   24.77 +};
   24.78 +
   24.79 +static void     g_mencoder_class_init(GMencoderClass * klass);
   24.80 +static void     g_mencoder_init(GMencoder * object);
   24.81 +static void     g_mencoder_dispose(GObject * object);
   24.82 +static void     g_mencoder_finalize(GObject * object);
   24.83 +static GstElement *_create_audio_bin(const gchar * encode,
   24.84 +                                     gchar ** encode_prop, gint rate);
   24.85 +static GstElement *_create_video_bin(const gchar * encode,
   24.86 +                                     gchar ** encode_prop,
   24.87 +                                     gdouble fps,
   24.88 +                                     gint rate, guint width, guint height,
   24.89 +                                     gboolean use_deinterlace);
   24.90 +
   24.91 +static          gboolean
   24.92 +_pipeline_bus_cb(GstBus * bus, GstMessage * msg, gpointer user_data);
   24.93 +
   24.94 +static void     _decodebin_new_pad_cb(GstElement * object,
   24.95 +                                      GstPad * pad,
   24.96 +                                      gboolean flag, gpointer user_data);
   24.97 +
   24.98 +static void     _decodebin_unknown_type_cb(GstElement * object,
   24.99 +                                           GstPad * pad,
  24.100 +                                           GstCaps * caps,
  24.101 +                                           gpointer user_data);
  24.102 +
  24.103 +static void     _close_output(GMencoder * self);
  24.104 +static gboolean _open_output(GMencoder * self, const gchar * uri);
  24.105 +
  24.106 +static GstElement *_create_source(GMencoder *self, const gchar * uri);
  24.107 +static GstElement *_create_pipeline(GMencoder * self,
  24.108 +                                    const gchar * video_encode,
  24.109 +                                    const gchar * mux_name,
  24.110 +                                    gchar ** video_encode_prop,
  24.111 +                                    gdouble video_fps,
  24.112 +                                    gdouble video_rate,
  24.113 +                                    guint video_width,
  24.114 +                                    guint video_height,
  24.115 +                                    const gchar * audio_encode,
  24.116 +                                    gchar ** audio_encode_prop,
  24.117 +                                    guint audio_rate,
  24.118 +				    gboolean deinterlace);
  24.119 +static gboolean	_process_timeout_cb (gpointer user_data);
  24.120 +#ifdef USE_MANUAL_SINK
  24.121 +static void _flush_queue	        (GMencoder *self);
  24.122 +static void _buffer_arrive_cb       (GstElement* object,
  24.123 +                                     GstBuffer* buff,
  24.124 +                                     GstPad* pad,
  24.125 +                                     gpointer user_data);
  24.126 +#endif
  24.127 +
  24.128 +
  24.129 +static gboolean _tick_cb(gpointer data);
  24.130 +
  24.131 +static guint    g_mencoder_signals[LAST_SIGNAL] = { 0 };
  24.132 +
  24.133 +G_DEFINE_TYPE(GMencoder, g_mencoder, G_TYPE_OBJECT)
  24.134 +
  24.135 +static void     g_mencoder_class_init(GMencoderClass * klass)
  24.136 +{
  24.137 +    GObjectClass   *object_class;
  24.138 +    object_class = (GObjectClass *) klass;
  24.139 +    g_type_class_add_private(klass, sizeof(GMencoderPrivate));
  24.140 +
  24.141 +    object_class->dispose = g_mencoder_dispose;
  24.142 +    object_class->finalize = g_mencoder_finalize;
  24.143 +
  24.144 +    g_mencoder_signals[PAUSED] =
  24.145 +        g_signal_new("paused",
  24.146 +                     G_OBJECT_CLASS_TYPE(object_class),
  24.147 +                     G_SIGNAL_RUN_FIRST,
  24.148 +                     0, NULL, NULL,
  24.149 +                     g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
  24.150 +
  24.151 +    g_mencoder_signals[PLAYING] =
  24.152 +        g_signal_new("playing",
  24.153 +                     G_OBJECT_CLASS_TYPE(object_class),
  24.154 +                     G_SIGNAL_RUN_FIRST,
  24.155 +                     0, NULL, NULL,
  24.156 +                     g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
  24.157 +
  24.158 +    g_mencoder_signals[STOPED] =
  24.159 +        g_signal_new("stoped",
  24.160 +                     G_OBJECT_CLASS_TYPE(object_class),
  24.161 +                     G_SIGNAL_RUN_FIRST,
  24.162 +                     0, NULL, NULL,
  24.163 +                     g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
  24.164 +
  24.165 +    g_mencoder_signals[EOS] =
  24.166 +        g_signal_new("eos",
  24.167 +                     G_OBJECT_CLASS_TYPE(object_class),
  24.168 +                     G_SIGNAL_RUN_FIRST,
  24.169 +                     0, NULL, NULL,
  24.170 +                     g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
  24.171 +
  24.172 +    g_mencoder_signals[ERROR] =
  24.173 +        g_signal_new("error",
  24.174 +                     G_OBJECT_CLASS_TYPE(object_class),
  24.175 +                     G_SIGNAL_RUN_LAST,
  24.176 +                     0, NULL, NULL,
  24.177 +                     g_cclosure_marshal_VOID__STRING,
  24.178 +                     G_TYPE_NONE, 1, G_TYPE_STRING);
  24.179 +}
  24.180 +
  24.181 +static void
  24.182 +g_mencoder_init(GMencoder * self)
  24.183 +{
  24.184 +    GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(self);
  24.185 +    priv->info = g_new0(SetupInfo, 1);
  24.186 +}
  24.187 +
  24.188 +static void
  24.189 +g_mencoder_dispose(GObject * object)
  24.190 +{
  24.191 +}
  24.192 +
  24.193 +static void
  24.194 +g_mencoder_finalize(GObject * object)
  24.195 +{
  24.196 +    GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(object);
  24.197 +
  24.198 +    // TODO: clear vars
  24.199 +    g_mencoder_close_stream(G_MENCODER(object));
  24.200 +    g_free (priv->info);
  24.201 +}
  24.202 +
  24.203 +GMencoder      *
  24.204 +g_mencoder_new(void)
  24.205 +{
  24.206 +    return g_object_new(G_TYPE_MENCODER, NULL);
  24.207 +}
  24.208 +
  24.209 +
  24.210 +static void
  24.211 +_obj_set_prop(GObject * obj, const gchar * prop_name,
  24.212 +              const gchar * prop_val)
  24.213 +{
  24.214 +    GValue          p = { 0 };
  24.215 +    GValue          v = { 0 };
  24.216 +    GParamSpec     *s = NULL;
  24.217 +    GObjectClass   *k = G_OBJECT_GET_CLASS(obj);
  24.218 +
  24.219 +
  24.220 +    g_value_init(&v, G_TYPE_STRING);
  24.221 +    g_value_set_string(&v, prop_val);
  24.222 +
  24.223 +    s = g_object_class_find_property(k, prop_name);
  24.224 +    if (s == NULL) {
  24.225 +        g_print("Invalid property name: %s\n", prop_name);
  24.226 +        return;
  24.227 +    }
  24.228 +
  24.229 +    g_value_init(&p, s->value_type);
  24.230 +    switch (s->value_type) {
  24.231 +    case G_TYPE_INT:
  24.232 +        g_value_set_int(&p, atoi(prop_val));
  24.233 +        break;
  24.234 +    case G_TYPE_ULONG:
  24.235 +        g_value_set_ulong (&p, atol(prop_val));
  24.236 +        break;
  24.237 +    case G_TYPE_STRING:
  24.238 +        g_value_set_string(&p, prop_val);
  24.239 +        break;
  24.240 +    case G_TYPE_BOOLEAN:
  24.241 +        g_value_set_boolean(&p, (gboolean) atoi (prop_val));
  24.242 +        break;
  24.243 +    case G_TYPE_DOUBLE:
  24.244 +        g_value_set_double(&p, atof (prop_val));
  24.245 +        break;
  24.246 +    case G_TYPE_FLOAT:
  24.247 +        g_value_set_float(&p, (float) atof (prop_val));
  24.248 +        break;
  24.249 +    default:
  24.250 +        g_value_set_enum(&p, atoi(prop_val));
  24.251 +        g_warning ("Property %s of type %s. Not supported using default enum", 
  24.252 +                   prop_name, g_type_name (s->value_type));
  24.253 +        return;
  24.254 +    }
  24.255 +
  24.256 +    g_object_set_property(obj, prop_name, &p);
  24.257 +    g_value_unset(&v);
  24.258 +    g_value_unset(&p);
  24.259 +}
  24.260 +
  24.261 +static GstElement *
  24.262 +_create_element_with_prop(const gchar * factory_name,
  24.263 +                          const gchar * element_name, gchar ** prop)
  24.264 +{
  24.265 +    GstElement     *ret;
  24.266 +    int             i;
  24.267 +
  24.268 +    ret = gst_element_factory_make(factory_name, element_name);
  24.269 +    if (ret == NULL)
  24.270 +        return NULL;
  24.271 +
  24.272 +    if (prop != NULL) {
  24.273 +        for (i = 0; i < g_strv_length(prop); i++) {
  24.274 +            if (prop[i] != NULL) {
  24.275 +                char **v = g_strsplit(prop[i], "=", 2);
  24.276 +                if (g_strv_length(v) == 2) {
  24.277 +                    _obj_set_prop(G_OBJECT(ret), v[0], v[1]);
  24.278 +                }
  24.279 +                g_strfreev(v);
  24.280 +            }
  24.281 +        }
  24.282 +    }
  24.283 +
  24.284 +    return ret;
  24.285 +
  24.286 +}
  24.287 +
  24.288 +static GstElement *
  24.289 +_create_audio_bin(const gchar * encode, gchar ** encode_prop, gint rate)
  24.290 +{
  24.291 +    GstElement     *abin = NULL;
  24.292 +    GstElement     *aqueue = NULL;
  24.293 +    GstElement     *aconvert = NULL;
  24.294 +    GstElement     *aencode = NULL;
  24.295 +    GstElement     *aqueue_src = NULL;
  24.296 +    GstPad         *apad = NULL;
  24.297 +
  24.298 +    // audio/x-raw-int ! queue ! audioconvert ! faac ! rtpmp4gpay !
  24.299 +    // udpsink name=upd_audio host=224.0.0.1 port=5002
  24.300 +    abin = gst_bin_new("abin");
  24.301 +    aqueue = gst_element_factory_make("queue", "aqueue");
  24.302 +    aconvert = gst_element_factory_make("audioconvert", "aconvert");
  24.303 +    aencode =
  24.304 +        _create_element_with_prop((encode ? encode : "lame"), "aencode",
  24.305 +                                  encode_prop);
  24.306 +    aqueue_src = gst_element_factory_make("queue", "aqueue_src");
  24.307 +
  24.308 +    if ((abin == NULL) || (aqueue == NULL) || (aconvert == NULL)
  24.309 +        || (aencode == NULL) || (aqueue_src == NULL)) {
  24.310 +        g_warning("Audio elements not found");
  24.311 +        goto error;
  24.312 +    }
  24.313 +
  24.314 +    g_object_set(G_OBJECT(aencode), "bitrate", 32, NULL);
  24.315 +    /*
  24.316 +     * if (rate > 0) { g_object_set (G_OBJECT (aencode), "bitrate", 32,
  24.317 +     * NULL); } 
  24.318 +     */
  24.319 +
  24.320 +    gst_bin_add_many(GST_BIN(abin), aqueue, aconvert, aencode, aqueue_src,
  24.321 +                     NULL);
  24.322 +    if (gst_element_link_many(aqueue, aconvert, aencode, aqueue_src, NULL)
  24.323 +        == FALSE) {
  24.324 +        g_warning("Not Link audio elements");
  24.325 +    }
  24.326 +    // TODO: apply audio rate
  24.327 +
  24.328 +    // ghost pad the audio bin
  24.329 +    apad = gst_element_get_pad(aqueue, "sink");
  24.330 +    gst_element_add_pad(abin, gst_ghost_pad_new("sink", apad));
  24.331 +    gst_object_unref(apad);
  24.332 +
  24.333 +    apad = gst_element_get_pad(aqueue_src, "src");
  24.334 +    gst_element_add_pad(abin, gst_ghost_pad_new("src", apad));
  24.335 +    gst_object_unref(apad);
  24.336 +
  24.337 +    return abin;
  24.338 +  error:
  24.339 +    if (abin != NULL)
  24.340 +        gst_object_unref(abin);
  24.341 +
  24.342 +    if (aqueue != NULL)
  24.343 +        gst_object_unref(aqueue);
  24.344 +
  24.345 +    if (aconvert != NULL)
  24.346 +        gst_object_unref(aconvert);
  24.347 +
  24.348 +    if (aencode != NULL)
  24.349 +        gst_object_unref(aencode);
  24.350 +
  24.351 +    if (aqueue_src != NULL)
  24.352 +        gst_object_unref(aqueue_src);
  24.353 +
  24.354 +    if (apad != NULL)
  24.355 +        gst_object_unref(apad);
  24.356 +
  24.357 +    return NULL;
  24.358 +}
  24.359 +
  24.360 +
  24.361 +
  24.362 +
  24.363 +// queue ! videoscale ! video/x-raw-yuv,width=240,height=144 ! colorspace
  24.364 +// ! rate ! encode ! queue
  24.365 +static GstElement *
  24.366 +_create_video_bin(const gchar * encode,
  24.367 +                  gchar ** encode_prop,
  24.368 +                  gdouble fps, gint rate, guint width, guint height,
  24.369 +                  gboolean use_deinterlace)
  24.370 +{
  24.371 +    GstElement     *vbin = NULL;
  24.372 +    GstElement     *vqueue = NULL;
  24.373 +    GstElement     *vqueue_src = NULL;
  24.374 +    GstElement     *vcolorspace = NULL;
  24.375 +    GstElement     *vencode = NULL;
  24.376 +    GstElement     *vrate = NULL;
  24.377 +    GstElement	   *deinterlace = NULL;
  24.378 +    GstElement     *walk = NULL;
  24.379 +    GstPad         *vpad = NULL;
  24.380 +
  24.381 +    vbin = gst_bin_new("vbin");
  24.382 +    vqueue = gst_element_factory_make("queue", "vqueue");
  24.383 +    vcolorspace =
  24.384 +        gst_element_factory_make("ffmpegcolorspace", "colorspace");
  24.385 +
  24.386 +    if (use_deinterlace) {
  24.387 +        deinterlace = gst_element_factory_make ("ffdeinterlace", "deinterlace");
  24.388 +	    if (deinterlace == NULL) {
  24.389 +	        g_warning ("Fail to create deinterlace element: Continue without deinterlace.");
  24.390 +        }
  24.391 +    }
  24.392 +
  24.393 +
  24.394 +    vencode = _create_element_with_prop((encode !=
  24.395 +                                         NULL ? encode :
  24.396 +                                         "ffenc_mpeg1video"), "vencode",
  24.397 +                                        encode_prop);
  24.398 +    vqueue_src = gst_element_factory_make("queue", "queue_src");
  24.399 +
  24.400 +    if ((vbin == NULL) || (vqueue == NULL) || (vcolorspace == NULL)
  24.401 +        || (vencode == NULL) || (vqueue_src == NULL)) {
  24.402 +        g_warning("Video elements not found");
  24.403 +        goto error;
  24.404 +    }
  24.405 +
  24.406 +    gst_bin_add_many(GST_BIN(vbin), vqueue, vcolorspace, vencode,
  24.407 +                     vqueue_src, NULL);
  24.408 +
  24.409 +    if (deinterlace != NULL) {
  24.410 +        gst_bin_add(GST_BIN(vbin), deinterlace);
  24.411 +        gst_element_link (vqueue, deinterlace);
  24.412 +        walk = deinterlace;
  24.413 +    } else {
  24.414 +        walk = vqueue;
  24.415 +    }
  24.416 +
  24.417 +    if ((width > 0) && (height > 0)) {
  24.418 +        // Scalling video
  24.419 +        GstCaps        *vcaps;
  24.420 +        GstElement     *vscale =
  24.421 +            gst_element_factory_make("videoscale", "vscale");
  24.422 +
  24.423 +	g_object_set (G_OBJECT (vscale), "method", 1, NULL);
  24.424 +
  24.425 +        gst_bin_add(GST_BIN(vbin), vscale);
  24.426 +
  24.427 +        vcaps = gst_caps_new_simple("video/x-raw-yuv",
  24.428 +                                    "width", G_TYPE_INT, width,
  24.429 +                                    "height", G_TYPE_INT, height, NULL);
  24.430 +
  24.431 +        gst_element_link(walk, vscale);
  24.432 +
  24.433 +        if (gst_element_link_filtered(vscale, vcolorspace, vcaps) == FALSE) {
  24.434 +            g_warning("Fail to resize video");
  24.435 +            gst_object_unref(vcaps);
  24.436 +            gst_object_unref(vscale);
  24.437 +            goto error;
  24.438 +        }
  24.439 +        gst_caps_unref(vcaps);
  24.440 +    } else {
  24.441 +        gst_element_link(walk, vcolorspace);
  24.442 +    }
  24.443 +
  24.444 +    if (fps > 0) {
  24.445 +        // Changing the video fps
  24.446 +        GstCaps        *vcaps;
  24.447 +        vrate = gst_element_factory_make("videorate", "vrate");
  24.448 +
  24.449 +        gst_bin_add(GST_BIN(vbin), vrate);
  24.450 +
  24.451 +        if (gst_element_link(vcolorspace, vrate) == FALSE) {
  24.452 +            g_warning("Fail to link video elements");
  24.453 +            goto error;
  24.454 +        }
  24.455 +
  24.456 +        vcaps = gst_caps_new_simple("video/x-raw-yuv",
  24.457 +                                    "framerate", GST_TYPE_FRACTION,
  24.458 +                                    (int) (fps * 1000), 1000, NULL);
  24.459 +
  24.460 +        if (gst_element_link_filtered(vrate, vencode, vcaps) == FALSE) {
  24.461 +            g_warning("Fail to link vrate with vencode.");
  24.462 +            goto error;
  24.463 +        }
  24.464 +        gst_caps_unref(vcaps);
  24.465 +    } else {
  24.466 +        if (gst_element_link(vcolorspace, vencode) == FALSE) {
  24.467 +            g_warning("Fail to link colorspace and video encode element.");
  24.468 +            goto error;
  24.469 +        }
  24.470 +    }
  24.471 +
  24.472 +    gst_element_link(vencode, vqueue_src);
  24.473 +
  24.474 +    // ghost pad the video bin
  24.475 +    vpad = gst_element_get_pad(vqueue, "sink");
  24.476 +    gst_element_add_pad(vbin, gst_ghost_pad_new("sink", vpad));
  24.477 +    gst_object_unref(vpad);
  24.478 +
  24.479 +    vpad = gst_element_get_pad(vqueue_src, "src");
  24.480 +    gst_element_add_pad(vbin, gst_ghost_pad_new("src", vpad));
  24.481 +    gst_object_unref(vpad);
  24.482 +
  24.483 +    return vbin;
  24.484 +
  24.485 +  error:
  24.486 +    if (vpad != NULL)
  24.487 +        gst_object_unref(vpad);
  24.488 +
  24.489 +    if (vbin != NULL)
  24.490 +        gst_object_unref(vbin);
  24.491 +
  24.492 +    if (vqueue != NULL)
  24.493 +        gst_object_unref(vqueue);
  24.494 +
  24.495 +    if (vencode != NULL)
  24.496 +        gst_object_unref(vencode);
  24.497 +
  24.498 +    if (vqueue_src != NULL)
  24.499 +        gst_object_unref(vqueue_src);
  24.500 +
  24.501 +    if (vcolorspace != NULL)
  24.502 +        gst_object_unref(vcolorspace);
  24.503 +
  24.504 +    return NULL;
  24.505 +}
  24.506 +
  24.507 +
  24.508 +
  24.509 +gboolean 
  24.510 +g_mencoder_setup_stream(GMencoder * self,
  24.511 +			gboolean chunked,
  24.512 +			gboolean deinterlace,
  24.513 +                        const gchar * mux_name,
  24.514 +                        const gchar * video_encode,
  24.515 +                        gchar ** video_encode_prop,
  24.516 +                        gdouble video_fps,
  24.517 +                        gdouble video_rate,
  24.518 +                        guint video_width,
  24.519 +                        guint video_height,
  24.520 +                        const gchar * audio_encode,
  24.521 +                        gchar ** audio_encode_prop,
  24.522 +                        guint audio_rate, const gchar * out_uri)
  24.523 +{
  24.524 +    GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(self);
  24.525 +    if (priv->ready == TRUE) {
  24.526 +        g_warning
  24.527 +            ("Stream already configured. You need close stream first.");
  24.528 +        return FALSE;
  24.529 +    }
  24.530 +
  24.531 +    _close_output(self);
  24.532 +    if (_open_output(self, out_uri) == FALSE) {	
  24.533 +        return FALSE;
  24.534 +    }
  24.535 +
  24.536 +    priv->sources = 0;
  24.537 +    priv->send_chunked = chunked;
  24.538 +    priv->pipe = _create_pipeline(self,
  24.539 +                                  video_encode,
  24.540 +                                  mux_name,
  24.541 +                                  video_encode_prop,
  24.542 +                                  video_fps,
  24.543 +                                  video_rate,
  24.544 +                                  video_width,
  24.545 +                                  video_height,
  24.546 +                                  audio_encode, audio_encode_prop,
  24.547 +                                  audio_rate,
  24.548 +                                  deinterlace);
  24.549 +
  24.550 +    return (priv->pipe != NULL);
  24.551 +}
  24.552 +
  24.553 +
  24.554 +gboolean
  24.555 +g_mencoder_append_uri(GMencoder * self, const gchar * uri)
  24.556 +{
  24.557 +    GstPad         *pad_src;
  24.558 +    GstPad         *pad_sink;
  24.559 +    GstElement     *src;
  24.560 +    GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(self);
  24.561 +    gboolean        ret = FALSE;
  24.562 +    GstElement     *ap = NULL;
  24.563 +    GstElement     *vp = NULL;
  24.564 +
  24.565 +
  24.566 +    g_return_val_if_fail(priv->pipe != NULL, FALSE);
  24.567 +    g_return_val_if_fail(priv->ready == FALSE, FALSE);
  24.568 +
  24.569 +    src = _create_source(self, uri);
  24.570 +    if (src == NULL)
  24.571 +        return FALSE;
  24.572 +
  24.573 +    priv->src = gst_bin_get_by_name(GST_BIN(src), "src");
  24.574 +
  24.575 +    gst_bin_add(GST_BIN(priv->pipe), src);
  24.576 +
  24.577 +    ap = gst_bin_get_by_name(GST_BIN(priv->pipe), "abin");
  24.578 +    vp = gst_bin_get_by_name(GST_BIN(priv->pipe), "vbin");
  24.579 +
  24.580 +    if ((vp == NULL) || (ap == NULL)) {
  24.581 +        g_warning("Fail to get output bin");
  24.582 +        goto error;
  24.583 +    }
  24.584 +
  24.585 +    pad_src = gst_element_get_pad(src, "src_audio");
  24.586 +    pad_sink = gst_element_get_compatible_pad(ap,
  24.587 +                                              pad_src,
  24.588 +                                              gst_pad_get_caps(pad_src));
  24.589 +
  24.590 +    if ((pad_sink == NULL) || (pad_src == NULL))
  24.591 +        goto error;
  24.592 +
  24.593 +    GstPadLinkReturn lret = gst_pad_link(pad_src, pad_sink);
  24.594 +    if (lret != GST_PAD_LINK_OK)
  24.595 +        goto error;
  24.596 +
  24.597 +    gst_object_unref(pad_src);
  24.598 +    gst_object_unref(pad_sink);
  24.599 +
  24.600 +    pad_src = gst_element_get_pad(src, "src_video");
  24.601 +    pad_sink = gst_element_get_compatible_pad(vp,
  24.602 +                                              pad_src,
  24.603 +                                              gst_pad_get_caps(pad_src));
  24.604 +
  24.605 +    if ((pad_src == NULL) || (pad_sink == NULL))
  24.606 +        goto error;
  24.607 +
  24.608 +    if (gst_pad_link(pad_src, pad_sink) != GST_PAD_LINK_OK) {
  24.609 +        g_warning("invalid source. video");
  24.610 +        goto error;
  24.611 +    }
  24.612 +
  24.613 +    priv->sources++;
  24.614 +    ret = TRUE;
  24.615 +  error:
  24.616 +
  24.617 +    if ((src != NULL) && (ret == FALSE)) {
  24.618 +        gst_bin_remove(GST_BIN(priv->pipe), src);
  24.619 +        gst_object_unref(src);
  24.620 +    }
  24.621 +
  24.622 +    if (ap != NULL)
  24.623 +        gst_object_unref(ap);
  24.624 +
  24.625 +    if (vp != NULL)
  24.626 +        gst_object_unref(vp);
  24.627 +
  24.628 +    if (pad_src != NULL)
  24.629 +        gst_object_unref(pad_src);
  24.630 +
  24.631 +    if (pad_sink != NULL)
  24.632 +        gst_object_unref(pad_sink);
  24.633 +
  24.634 +    return ret;
  24.635 +}
  24.636 +
  24.637 +
  24.638 +
  24.639 +void
  24.640 +g_mencoder_remove_uri(GMencoder * self, const gchar * uri)
  24.641 +{
  24.642 +    // GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE (self);
  24.643 +    // TODO: remove src
  24.644 +}
  24.645 +
  24.646 +void
  24.647 +g_mencoder_play_stream(GMencoder * self)
  24.648 +{
  24.649 +    GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(self);
  24.650 +    g_return_if_fail(priv->ready == FALSE);
  24.651 +    priv->ready = TRUE;
  24.652 +    gst_element_set_state(priv->pipe, GST_STATE_PLAYING);
  24.653 +    if (priv->tick_id != 0) {
  24.654 +        g_source_remove (priv->tick_id);
  24.655 +    }
  24.656 +    priv->tick_id = g_timeout_add(500, _tick_cb, self);
  24.657 +
  24.658 +    if (priv->timeout_id != 0) {
  24.659 +        g_source_remove (priv->timeout_id);
  24.660 +    }
  24.661 +    //priv->timeout_id = g_timeout_add(GMENCODER_TIMEOUT, _process_timeout_cb, self);
  24.662 +}
  24.663 +
  24.664 +void
  24.665 +g_mencoder_pause_stream(GMencoder * self)
  24.666 +{
  24.667 +    GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(self);
  24.668 +    g_return_if_fail(priv->ready == TRUE);
  24.669 +    gst_element_set_state(priv->pipe, GST_STATE_PAUSED);
  24.670 +}
  24.671 +
  24.672 +void
  24.673 +g_mencoder_close_stream(GMencoder * self)
  24.674 +{
  24.675 +
  24.676 +    GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(self);
  24.677 +    if (priv->tick_id != 0) {
  24.678 +        g_source_remove(priv->tick_id);
  24.679 +        priv->tick_id = 0;
  24.680 +    }
  24.681 +
  24.682 +    if (priv->timeout_id != 0) {
  24.683 +        g_source_remove (priv->timeout_id);
  24.684 +	priv->timeout_id = 0;
  24.685 +    }
  24.686 +
  24.687 +    if (priv->pipe != NULL) {
  24.688 +        // TODO: fixe pipeline dispose
  24.689 +        //gst_element_set_state (priv->pipe, GST_STATE_NULL);
  24.690 +        // g_debug ("SETING STATE TO NULL: OK");
  24.691 +        // gst_element_set_state (priv->pipe, GST_STATE_NULL);
  24.692 +        //gst_object_unref (priv->pipe);
  24.693 +        //gst_object_unref(priv->src);
  24.694 +        priv->src = NULL;
  24.695 +        priv->pipe = NULL;
  24.696 +        priv->abin = NULL;
  24.697 +        priv->vbin = NULL;
  24.698 +        priv->sink = NULL;
  24.699 +    }
  24.700 +    priv->ready = FALSE;
  24.701 +}
  24.702 +
  24.703 +static GstElement *
  24.704 +_create_pipeline(GMencoder * self,
  24.705 +                 const gchar * video_encode,
  24.706 +                 const gchar * mux_name,
  24.707 +                 gchar ** video_encode_prop,
  24.708 +                 gdouble video_fps,
  24.709 +                 gdouble video_rate,
  24.710 +                 guint video_width,
  24.711 +                 guint video_height,
  24.712 +                 const gchar * audio_encode,
  24.713 +                 gchar ** audio_encode_prop, guint audio_rate,
  24.714 +		         gboolean deinterlace)
  24.715 +{
  24.716 +    GstBus         *bus = NULL;
  24.717 +    GstElement     *pipe = NULL;
  24.718 +    GstElement     *sink = NULL;
  24.719 +    GstElement     *mux = NULL;
  24.720 +    GstElement     *abin = NULL;
  24.721 +    GstElement     *vbin = NULL;
  24.722 +    GstElement     *queue = NULL;
  24.723 +    GstPad         *aux_pad = NULL;
  24.724 +    GstPad         *mux_pad = NULL;
  24.725 +
  24.726 +    pipe = gst_pipeline_new("pipe");
  24.727 +
  24.728 +    mux =
  24.729 +        gst_element_factory_make((mux_name ? mux_name : "ffmux_mpeg"),
  24.730 +                                 "mux");
  24.731 +    if (mux == NULL)
  24.732 +        goto error;
  24.733 +
  24.734 +    queue = gst_element_factory_make("queue", "queueu_sink");
  24.735 +
  24.736 +
  24.737 +    sink = gst_element_factory_make("fakesink", "sink");
  24.738 +    g_object_set (G_OBJECT (sink), "signal-handoffs", TRUE, NULL);
  24.739 +    g_signal_connect (G_OBJECT (sink),
  24.740 +                      "handoff",
  24.741 +                      G_CALLBACK (_buffer_arrive_cb),
  24.742 +                      self);
  24.743 +
  24.744 +    abin = _create_audio_bin(audio_encode, audio_encode_prop, audio_rate);
  24.745 +    if (abin == NULL)
  24.746 +        goto error;
  24.747 +
  24.748 +    vbin =
  24.749 +        _create_video_bin(video_encode, video_encode_prop, video_fps,
  24.750 +                          video_rate, video_width, video_height, deinterlace);
  24.751 +    if (vbin == NULL)
  24.752 +        goto error;
  24.753 +
  24.754 +    // Finish Pipe
  24.755 +    gst_bin_add_many(GST_BIN(pipe), abin, vbin, mux, queue, sink, NULL);
  24.756 +
  24.757 +
  24.758 +    // Link bins with mux
  24.759 +    aux_pad = gst_element_get_pad(abin, "src");
  24.760 +    mux_pad =
  24.761 +        gst_element_get_compatible_pad(mux, aux_pad,
  24.762 +                                       GST_PAD_CAPS(aux_pad));
  24.763 +    if (mux_pad == NULL) {
  24.764 +        g_warning("Mux element no have audio PAD");
  24.765 +        goto error;
  24.766 +    }
  24.767 +    GstPadLinkReturn ret = gst_pad_link(aux_pad, mux_pad);
  24.768 +    if (ret != GST_PAD_LINK_OK) {
  24.769 +        g_warning("Fail link audio and mux: %d", ret);
  24.770 +        goto error;
  24.771 +
  24.772 +    }
  24.773 +    gst_object_unref(aux_pad);
  24.774 +    gst_object_unref(mux_pad);
  24.775 +
  24.776 +    aux_pad = gst_element_get_pad(vbin, "src");
  24.777 +    mux_pad =
  24.778 +        gst_element_get_compatible_pad(mux, aux_pad,
  24.779 +                                       GST_PAD_CAPS(aux_pad));
  24.780 +    if (mux_pad == NULL) {
  24.781 +        g_warning("Mux element no have video PAD");
  24.782 +        goto error;
  24.783 +    }
  24.784 +    ret = gst_pad_link(aux_pad, mux_pad);
  24.785 +    if (ret != GST_PAD_LINK_OK) {
  24.786 +        g_warning("Fail link video and mux: %d", ret);
  24.787 +        goto error;
  24.788 +    }
  24.789 +    gst_object_unref(aux_pad);
  24.790 +    gst_object_unref(mux_pad);
  24.791 +    aux_pad = NULL;
  24.792 +    mux_pad = NULL;
  24.793 +
  24.794 +    // Link mux with sink
  24.795 +    gst_element_link_many(mux, queue, sink, NULL);
  24.796 +
  24.797 +    bus = gst_pipeline_get_bus(GST_PIPELINE(pipe));
  24.798 +    gst_bus_add_watch(bus, _pipeline_bus_cb, self);
  24.799 +    gst_object_unref(bus);
  24.800 +    return pipe;
  24.801 +
  24.802 +  error:
  24.803 +    g_warning("Invalid uri");
  24.804 +
  24.805 +    if (pipe != NULL) {
  24.806 +        gst_object_unref(pipe);
  24.807 +    }
  24.808 +
  24.809 +
  24.810 +    if (mux != NULL) {
  24.811 +        gst_object_unref(mux);
  24.812 +    }
  24.813 +
  24.814 +    if (mux_pad != NULL) {
  24.815 +        gst_object_unref(mux_pad);
  24.816 +    }
  24.817 +
  24.818 +    if (aux_pad != NULL) {
  24.819 +        gst_object_unref(mux_pad);
  24.820 +    }
  24.821 +
  24.822 +    if (sink != NULL) {
  24.823 +        gst_object_unref(sink);
  24.824 +    }
  24.825 +
  24.826 +    if (abin != NULL) {
  24.827 +        gst_object_unref(abin);
  24.828 +    }
  24.829 +
  24.830 +    if (vbin != NULL) {
  24.831 +        gst_object_unref(vbin);
  24.832 +    }
  24.833 +
  24.834 +    return FALSE;
  24.835 +}
  24.836 +
  24.837 +
  24.838 +static void
  24.839 +_close_output(GMencoder * self)
  24.840 +{
  24.841 +}
  24.842 +
  24.843 +static GstElement *
  24.844 +_create_v4l_source (GMencoder *self, const gchar * uri)
  24.845 +{
  24.846 +    gchar **info;
  24.847 +    GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(self);
  24.848 +
  24.849 +
  24.850 +    info = g_strsplit (uri+6, ":", 3);
  24.851 +    if (g_strv_length (info) != 3) {
  24.852 +        return NULL;
  24.853 +    }
  24.854 +
  24.855 +    priv->v4lsrc = gst_element_factory_make ("v4l2src", "src");
  24.856 +    g_debug ("channel %s, norm %s, frequ %s", info[0], info[1], info[2]);
  24.857 +    g_object_set (G_OBJECT (priv->v4lsrc),
  24.858 +                  "channel", info[0],
  24.859 +                  "norm", info[1],
  24.860 +                  "frequency", atoi (info[2]),
  24.861 +                  NULL);
  24.862 +
  24.863 +    return priv->v4lsrc;
  24.864 +}
  24.865 +
  24.866 +static GstElement *
  24.867 +_create_source(GMencoder *self, const gchar * uri)
  24.868 +{
  24.869 +
  24.870 +    GstElement     *bsrc = NULL;
  24.871 +    GstElement     *src = NULL;
  24.872 +    GstElement     *aqueue = NULL;
  24.873 +    GstElement     *vqueue = NULL;
  24.874 +    GstElement     *decode = NULL;
  24.875 +    GstPad         *src_pad = NULL;
  24.876 +
  24.877 +
  24.878 +    bsrc = gst_bin_new(NULL);
  24.879 +
  24.880 +    // src = gst_element_factory_make ("gnomevfssrc", "src");
  24.881 +    // g_object_set (G_OBJECT (src), "location", uri, NULL);
  24.882 +    if (strncmp (uri, "v4l://", 6) == 0) {
  24.883 +        g_debug ("V4L");
  24.884 +        src = _create_v4l_source (self, uri);
  24.885 +    }
  24.886 +    else {
  24.887 +        src = gst_element_make_from_uri(GST_URI_SRC, uri, "src");
  24.888 +    }
  24.889 +
  24.890 +    if (src == NULL)
  24.891 +        goto error;
  24.892 +
  24.893 +    decode = gst_element_factory_make("decodebin2", "decode");
  24.894 +    if (decode == NULL)
  24.895 +        goto error;
  24.896 +
  24.897 +    aqueue = gst_element_factory_make("queue", "aqueue");
  24.898 +    if (aqueue == NULL)
  24.899 +        goto error;
  24.900 +
  24.901 +    vqueue = gst_element_factory_make("queue", "vqueue");
  24.902 +    if (vqueue == NULL)
  24.903 +        goto error;
  24.904 +
  24.905 +    gst_bin_add_many(GST_BIN(bsrc), src, decode, aqueue, vqueue,
  24.906 +                     NULL);
  24.907 +    gst_element_link (src, decode);
  24.908 +
  24.909 +    g_signal_connect(G_OBJECT(decode),
  24.910 +                     "new-decoded-pad",
  24.911 +                     G_CALLBACK(_decodebin_new_pad_cb), bsrc);
  24.912 +
  24.913 +    g_signal_connect(G_OBJECT(decode),
  24.914 +                     "unknown-type",
  24.915 +                     G_CALLBACK(_decodebin_unknown_type_cb), pipe);
  24.916 +
  24.917 +    src_pad = gst_element_get_pad(aqueue, "src");
  24.918 +    gst_element_add_pad(bsrc, gst_ghost_pad_new("src_audio", src_pad));
  24.919 +    gst_object_unref(src_pad);
  24.920 +
  24.921 +    src_pad = gst_element_get_pad(vqueue, "src");
  24.922 +    gst_element_add_pad(bsrc, gst_ghost_pad_new("src_video", src_pad));
  24.923 +    gst_object_unref(src_pad);
  24.924 +
  24.925 +    return bsrc;
  24.926 +
  24.927 +  error:
  24.928 +    g_debug ("Fail to create source element");
  24.929 +    if (src != NULL) {
  24.930 +        gst_object_unref(src);
  24.931 +    }
  24.932 +
  24.933 +    if (decode != NULL) {
  24.934 +        gst_object_unref(decode);
  24.935 +    }
  24.936 +
  24.937 +    if (aqueue != NULL) {
  24.938 +        gst_object_unref(aqueue);
  24.939 +    }
  24.940 +
  24.941 +    if (vqueue != NULL) {
  24.942 +        gst_object_unref(vqueue);
  24.943 +    }
  24.944 +
  24.945 +    return NULL;
  24.946 +}
  24.947 +
  24.948 +static gboolean
  24.949 +_open_output(GMencoder * self, const gchar * uri)
  24.950 +{
  24.951 +    gchar         **i;
  24.952 +    GnomeVFSResult result;
  24.953 +    GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(self);
  24.954 +
  24.955 +    i = g_strsplit(uri, "://", 0);
  24.956 +    if (strcmp(i[0], "fd") == 0) {
  24.957 +        result = gnome_vfs_open_fd (&priv->handle, atoi(i[1]));
  24.958 +    } else {
  24.959 +        if (g_file_test (i[1], G_FILE_TEST_EXISTS) == FALSE) {
  24.960 +            result = gnome_vfs_create (&priv->handle, uri, GNOME_VFS_OPEN_WRITE, FALSE,
  24.961 +                              GNOME_VFS_PERM_USER_WRITE | GNOME_VFS_PERM_USER_READ | GNOME_VFS_PERM_GROUP_READ);
  24.962 +        } else {
  24.963 +            result = gnome_vfs_open (&priv->handle, uri,
  24.964 +                                     GNOME_VFS_OPEN_WRITE | GNOME_VFS_OPEN_TRUNCATE);
  24.965 +        }
  24.966 +    }
  24.967 +
  24.968 +    g_strfreev(i);
  24.969 +    return (result == GNOME_VFS_OK);
  24.970 +}
  24.971 +
  24.972 +static          gboolean
  24.973 +_pipeline_bus_cb(GstBus * bus, GstMessage * msg, gpointer user_data)
  24.974 +{
  24.975 +    GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(user_data);
  24.976 +
  24.977 +    switch (GST_MESSAGE_TYPE(msg)) {
  24.978 +
  24.979 +    case GST_MESSAGE_STATE_CHANGED:
  24.980 +        {
  24.981 +            GstState        oldstate;
  24.982 +            GstState        newstate;
  24.983 +            GstState        pendingstate;
  24.984 +
  24.985 +
  24.986 +            gst_message_parse_state_changed(msg, &oldstate,
  24.987 +                                            &newstate, &pendingstate);
  24.988 +
  24.989 +            if (pendingstate != GST_STATE_VOID_PENDING)
  24.990 +                break;
  24.991 +
  24.992 +            if ((oldstate == GST_STATE_READY)
  24.993 +                && (newstate == GST_STATE_PAUSED)) {
  24.994 +                if (priv->ready)
  24.995 +                    g_signal_emit(user_data, g_mencoder_signals[PAUSED],
  24.996 +                                  0);
  24.997 +            } else if ((oldstate == GST_STATE_PAUSED)
  24.998 +                       && (newstate == GST_STATE_PLAYING)) {
  24.999 +                g_signal_emit(user_data, g_mencoder_signals[PLAYING], 0);
 24.1000 +            } else if ((oldstate == GST_STATE_READY) &&
 24.1001 +                       (newstate == GST_STATE_NULL)) {
 24.1002 +                g_signal_emit(user_data, g_mencoder_signals[STOPED], 0);
 24.1003 +            }
 24.1004 +            break;
 24.1005 +        }
 24.1006 +
 24.1007 +    case GST_MESSAGE_ERROR:
 24.1008 +        {
 24.1009 +            GError         *error;
 24.1010 +            gchar          *debug;
 24.1011 +            gchar          *err_str;
 24.1012 +
 24.1013 +            if (priv->tick_id != 0) {
 24.1014 +                g_source_remove(priv->tick_id);
 24.1015 +                priv->tick_id = 0;
 24.1016 +            }
 24.1017 +
 24.1018 +            gst_message_parse_error(msg, &error, &debug);
 24.1019 +            err_str = g_strdup_printf("Error [%d] %s (%s)", error->code,
 24.1020 +                                      error->message, debug);
 24.1021 +            priv->ready = FALSE;
 24.1022 +            g_signal_emit(user_data, g_mencoder_signals[ERROR], 0,
 24.1023 +                          err_str);
 24.1024 +            g_free(err_str);
 24.1025 +            g_clear_error(&error);
 24.1026 +            g_free(debug);
 24.1027 +            break;
 24.1028 +        }
 24.1029 +
 24.1030 +    case GST_MESSAGE_EOS:
 24.1031 +        priv->ready = FALSE;
 24.1032 +#ifdef USE_MANUAL_SINK
 24.1033 +        _flush_queue (G_MENCODER (user_data));
 24.1034 +#endif
 24.1035 +        g_signal_emit(user_data, g_mencoder_signals[EOS], 0);
 24.1036 +        break;
 24.1037 +
 24.1038 +    case GST_MESSAGE_DURATION:
 24.1039 +        {
 24.1040 +            GstFormat       format;
 24.1041 +            gint64          duration;
 24.1042 +            gst_message_parse_duration(msg, &format, &duration);
 24.1043 +            if (format == GST_FORMAT_BYTES)
 24.1044 +                priv->duration = duration;
 24.1045 +            break;
 24.1046 +        }
 24.1047 +    default:
 24.1048 +        {
 24.1049 +            break;
 24.1050 +        }
 24.1051 +    }
 24.1052 +    return TRUE;
 24.1053 +}
 24.1054 +
 24.1055 +
 24.1056 +
 24.1057 +static void
 24.1058 +_decodebin_new_pad_cb(GstElement * object,
 24.1059 +                      GstPad * pad, gboolean flag, gpointer user_data)
 24.1060 +{
 24.1061 +    GstCaps        *caps;
 24.1062 +    gchar          *str_caps = NULL;
 24.1063 +    GstElement     *sink_element;
 24.1064 +    GstPad         *sink_pad;
 24.1065 +
 24.1066 +    caps = gst_pad_get_caps(pad);
 24.1067 +    str_caps = gst_caps_to_string(caps);
 24.1068 +    if (strstr(str_caps, "audio") != NULL) {
 24.1069 +        sink_element = gst_bin_get_by_name(GST_BIN(user_data), "aqueue");
 24.1070 +    } else if (strstr(str_caps, "video") != NULL) {
 24.1071 +        sink_element = gst_bin_get_by_name(GST_BIN(user_data), "vqueue");
 24.1072 +    } else {
 24.1073 +        g_warning("invalid caps %s", str_caps);
 24.1074 +    }
 24.1075 +
 24.1076 +    sink_pad = gst_element_get_pad(sink_element, "sink");
 24.1077 +    gst_pad_link(pad, sink_pad);
 24.1078 +
 24.1079 +    gst_object_unref(sink_element);
 24.1080 +    gst_object_unref(sink_pad);
 24.1081 +    g_free(str_caps);
 24.1082 +    gst_caps_unref(caps);
 24.1083 +}
 24.1084 +
 24.1085 +static void
 24.1086 +_decodebin_unknown_type_cb(GstElement * object,
 24.1087 +                           GstPad * pad, GstCaps * caps,
 24.1088 +                           gpointer user_data)
 24.1089 +{
 24.1090 +    g_warning("Unknown Type");
 24.1091 +    // priv->ready = FALSE;
 24.1092 +}
 24.1093 +
 24.1094 +static          gboolean
 24.1095 +_tick_cb(gpointer user_data)
 24.1096 +{
 24.1097 +    GstFormat       format = GST_FORMAT_BYTES;
 24.1098 +    gint64          cur = 0;
 24.1099 +
 24.1100 +    GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(user_data);
 24.1101 +
 24.1102 +    if (priv->duration == 0) {
 24.1103 +        gint64          d = 0;
 24.1104 +        if (gst_element_query_duration(priv->src, &format, &d))
 24.1105 +            priv->duration = d;
 24.1106 +    }
 24.1107 +
 24.1108 +    if (priv->duration != 0) {
 24.1109 +        gst_element_query_position(priv->src, &format, &cur);
 24.1110 +        g_print("PROGRESS:%lli\n", (99 * cur) / priv->duration);
 24.1111 +    }
 24.1112 +
 24.1113 +    return TRUE;
 24.1114 +}
 24.1115 +
 24.1116 +static gboolean 
 24.1117 +_process_timeout_cb (gpointer user_data)
 24.1118 +{
 24.1119 +    GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(user_data);
 24.1120 +
 24.1121 +    g_signal_emit(user_data, g_mencoder_signals[ERROR], 0, "timeout");
 24.1122 +    priv->timeout_id = 0;
 24.1123 +    return FALSE;
 24.1124 +}
 24.1125 +
 24.1126 +
 24.1127 +#ifdef USE_MANUAL_SINK
 24.1128 +static gboolean
 24.1129 +_send_buffer (GnomeVFSHandle *handle, gpointer buff, gint size)
 24.1130 +{
 24.1131 +    gchar *msg;
 24.1132 +    GByteArray *b_send;
 24.1133 +    GnomeVFSResult result;
 24.1134 +    GnomeVFSFileSize bytes_written;
 24.1135 +
 24.1136 +    b_send = g_byte_array_new ();
 24.1137 +    msg = g_strdup_printf ("%x\r\n", size);
 24.1138 +    b_send = g_byte_array_append (b_send, (const guint8*) msg, strlen (msg) * sizeof (gchar));
 24.1139 +    g_free (msg);
 24.1140 +
 24.1141 +    b_send = g_byte_array_append (b_send, buff, size);
 24.1142 +
 24.1143 +    msg = g_strdup ("\r\n");
 24.1144 +    b_send = g_byte_array_append (b_send, (const guint8*) msg, strlen (msg) * sizeof (gchar));
 24.1145 +    g_free (msg);
 24.1146 +
 24.1147 +    result = gnome_vfs_write (handle, b_send->data, b_send->len, &bytes_written);
 24.1148 +    g_byte_array_free (b_send, TRUE);
 24.1149 +
 24.1150 +    return (result == GNOME_VFS_OK);
 24.1151 +}
 24.1152 +
 24.1153 +static void
 24.1154 +_flush_queue (GMencoder *self)
 24.1155 +{
 24.1156 +    GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(self);
 24.1157 +
 24.1158 +    if (priv->send_chunked) {
 24.1159 +        GnomeVFSFileSize bytes_written;
 24.1160 +        gchar *end_msg;
 24.1161 +        end_msg = g_strdup ("0\r\n\r\n");
 24.1162 +        gnome_vfs_write (priv->handle,
 24.1163 +                         (const guint8*) end_msg,
 24.1164 +                         strlen(end_msg) * sizeof(gchar),
 24.1165 +                         &bytes_written);
 24.1166 +        g_free (end_msg);
 24.1167 +    }
 24.1168 +}
 24.1169 +
 24.1170 +static void
 24.1171 +_buffer_arrive_cb (GstElement* object,
 24.1172 +                   GstBuffer* buff,
 24.1173 +                   GstPad* pad,
 24.1174 +                   gpointer user_data)
 24.1175 +{
 24.1176 +    GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(user_data);
 24.1177 +
 24.1178 +    if (priv->timeout_id != 0) {
 24.1179 +	g_source_remove (priv->timeout_id);
 24.1180 +	priv->timeout_id = 0;
 24.1181 +    }
 24.1182 +
 24.1183 +    if (priv->send_chunked) {
 24.1184 +        if (_send_buffer (priv->handle, GST_BUFFER_DATA (buff), GST_BUFFER_SIZE (buff)) == FALSE)
 24.1185 +            goto error;
 24.1186 +    } else {
 24.1187 +        GnomeVFSResult result;
 24.1188 +        GnomeVFSFileSize bytes_written;
 24.1189 +
 24.1190 +        result = gnome_vfs_write (priv->handle,
 24.1191 +                                  GST_BUFFER_DATA (buff),
 24.1192 +                                  GST_BUFFER_SIZE (buff),
 24.1193 +                                  &bytes_written);
 24.1194 +
 24.1195 +        if (result != GNOME_VFS_OK)
 24.1196 +            goto error;
 24.1197 +    }
 24.1198 +
 24.1199 +    return;
 24.1200 +
 24.1201 +error:
 24.1202 +    if (priv->tick_id != 0) {
 24.1203 +        g_source_remove(priv->tick_id);
 24.1204 +        priv->tick_id = 0;
 24.1205 +    }
 24.1206 +    g_signal_emit(user_data, g_mencoder_signals[ERROR], 0, "Fail to write on socket");
 24.1207 +    gst_element_set_state (priv->pipe, GST_STATE_PAUSED);
 24.1208 +}
 24.1209 +
 24.1210 +#endif
    25.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.2 +++ b/gmyth-stream/gmencoder/src/gmencoder.h	Tue Sep 18 13:45:36 2007 +0100
    25.3 @@ -0,0 +1,61 @@
    25.4 +#ifndef __G_MENCODER_H__
    25.5 +#define __G_MENCODER_H__
    25.6 +
    25.7 +#include <glib-object.h>
    25.8 +
    25.9 +G_BEGIN_DECLS typedef struct _GMencoder GMencoder;
   25.10 +typedef struct _GMencoderClass GMencoderClass;
   25.11 +
   25.12 +struct _GMencoderClass {
   25.13 +    GObjectClass    parent_class;
   25.14 +};
   25.15 +
   25.16 +struct _GMencoder {
   25.17 +    GObject         parent;
   25.18 +};
   25.19 +
   25.20 +/*
   25.21 + * TYPE MACROS 
   25.22 + */
   25.23 +#define G_TYPE_MENCODER \
   25.24 +  (g_mencoder_get_type())
   25.25 +#define G_MENCODER(obj) \
   25.26 +  (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_MENCODER, GMencoder))
   25.27 +#define G_MENCODER_CLASS(klass) \
   25.28 +  (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_MENCODER, GMencoderClass))
   25.29 +#define G_IS_MENCODER(obj) \
   25.30 +  (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_MENCODER))
   25.31 +#define G_IS_MENCODER_CLASS(klass) \
   25.32 +  (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_MENCODER))
   25.33 +#define G_MENCODER_GET_CLASS(obj) \
   25.34 +  (G_TYPE_INSTANCE_GET_CLASS ((obj), G_TYPE_MENCODER, GMencoderClass))
   25.35 +
   25.36 +
   25.37 +GType           g_mencoder_get_type(void);
   25.38 +GMencoder      *g_mencoder_new(void);
   25.39 +
   25.40 +gboolean        g_mencoder_setup_stream(GMencoder * self,
   25.41 +					gboolean chunked,
   25.42 +					gboolean deinterlace,
   25.43 +                                        const gchar * mux_name,
   25.44 +                                        const gchar * video_encode,
   25.45 +                                        gchar ** video_encode_prop,
   25.46 +                                        gdouble video_fps,
   25.47 +                                        gdouble video_rate,
   25.48 +                                        guint video_width,
   25.49 +                                        guint video_height,
   25.50 +                                        const gchar * audio_encode,
   25.51 +                                        gchar ** audio_encode_prop,
   25.52 +                                        guint audio_rate,
   25.53 +                                        const gchar * output_uri);
   25.54 +
   25.55 +gboolean        g_mencoder_append_uri(GMencoder * self, const gchar * uri);
   25.56 +
   25.57 +void            g_mencoder_remove_uri(GMencoder * self, const gchar * uri);
   25.58 +
   25.59 +void            g_mencoder_play_stream(GMencoder * self);
   25.60 +void            g_mencoder_pause_stream(GMencoder * self);
   25.61 +void            g_mencoder_close_stream(GMencoder * self);
   25.62 +
   25.63 +G_END_DECLS
   25.64 +#endif
    26.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.2 +++ b/gmyth-stream/gmencoder/src/main.c	Tue Sep 18 13:45:36 2007 +0100
    26.3 @@ -0,0 +1,207 @@
    26.4 +#include <sys/stat.h>
    26.5 +#include <fcntl.h>
    26.6 +#include <unistd.h>
    26.7 +#include <string.h>
    26.8 +
    26.9 +#include <gst/gst.h>
   26.10 +#include <glib.h>
   26.11 +#include <libgnomevfs/gnome-vfs.h>
   26.12 +
   26.13 +#include "gmencoder.h"
   26.14 +
   26.15 +#define FILE_OUT  1
   26.16 +
   26.17 +static GMainLoop *mainloop = NULL;
   26.18 +/*
   26.19 + * Options 
   26.20 + */
   26.21 +static gchar   *input_file = NULL;
   26.22 +static gchar   *video_encode = NULL;
   26.23 +static gchar   *video_opts = NULL;
   26.24 +static gdouble  video_fps = 0.0;
   26.25 +static gint     video_rate = 0;
   26.26 +static gint     video_width = 0;
   26.27 +static gint     video_height = 0;
   26.28 +static gchar   *audio_encode = NULL;
   26.29 +static gchar   *audio_opts = NULL;
   26.30 +static double   audio_rate = 0.0;
   26.31 +static gchar   *mux_name = NULL;
   26.32 +static gchar   *output_uri = NULL;
   26.33 +static gboolean chunked = FALSE;
   26.34 +static gboolean deinterlace = FALSE;
   26.35 +
   26.36 +
   26.37 +
   26.38 +static gboolean
   26.39 +_quit(gpointer data)
   26.40 +{
   26.41 +    //g_object_unref(data);
   26.42 +    g_main_loop_quit(mainloop);
   26.43 +    return FALSE;
   26.44 +}
   26.45 +
   26.46 +static void
   26.47 +_mencoder_eos_cb(GMencoder * mencoder, gpointer data)
   26.48 +{
   26.49 +    g_print("PROGRESS: 100\n");
   26.50 +    g_idle_add(_quit, mencoder);
   26.51 +}
   26.52 +
   26.53 +
   26.54 +static void
   26.55 +_mencoder_error_cb(GMencoder * mencoder, const gchar * msg, gpointer data)
   26.56 +{
   26.57 +    g_print("Error: %s\n", msg);
   26.58 +    g_idle_add(_quit, mencoder);
   26.59 +}
   26.60 +
   26.61 +static          gboolean
   26.62 +_io_channel_cb(GIOChannel * ch, GIOCondition condition, gpointer data)
   26.63 +{
   26.64 +    GString        *cmd = g_string_new("");
   26.65 +    g_io_channel_read_line_string(ch, cmd, NULL, NULL);
   26.66 +
   26.67 +    if (strcmp(cmd->str, "PLAY\n") == 0) {
   26.68 +        g_mencoder_play_stream(G_MENCODER(data));
   26.69 +    } else if (strcmp(cmd->str, "PAUSE\n") == 0) {
   26.70 +        g_mencoder_pause_stream(G_MENCODER(data));
   26.71 +    } else if (strcmp(cmd->str, "STOP\n") == 0) {
   26.72 +        g_mencoder_close_stream(G_MENCODER(data));
   26.73 +    } else if (strcmp(cmd->str, "QUIT\n") == 0) {
   26.74 +        g_mencoder_close_stream(G_MENCODER(data));
   26.75 +        g_main_loop_quit(mainloop);
   26.76 +    }
   26.77 +    g_string_free(cmd, TRUE);
   26.78 +    return TRUE;
   26.79 +}
   26.80 +
   26.81 +int
   26.82 +main(int argc, char **argv)
   26.83 +{
   26.84 +    GMencoder      *coder = NULL;
   26.85 +    GIOChannel     *ch;
   26.86 +    gchar         **vopts;
   26.87 +    gchar         **aopts;
   26.88 +    gchar         **files;
   26.89 +    gint            i;
   26.90 +    gboolean      ret;
   26.91 +
   26.92 +    GOptionContext *context;
   26.93 +    static const GOptionEntry options[] = {
   26.94 +        {"input-files", 'i', 0, G_OPTION_ARG_STRING, &input_file,
   26.95 +         "Input File", NULL},
   26.96 +
   26.97 +        {"video-encode", 0, 0, G_OPTION_ARG_STRING, &video_encode,
   26.98 +         "GstElementName for used to video encode", NULL},
   26.99 +
  26.100 +        {"video-opts", 0, 0, G_OPTION_ARG_STRING, &video_opts,
  26.101 +         "Properties to set on video element", NULL},
  26.102 +
  26.103 +        {"video-fps", 0, 0, G_OPTION_ARG_DOUBLE, &video_fps,
  26.104 +         "Video FPS", NULL},
  26.105 +
  26.106 +        {"video-rate", 0, 0, G_OPTION_ARG_INT, &video_rate,
  26.107 +         "Video rate", NULL},
  26.108 +
  26.109 +        {"video-width", 0, 0, G_OPTION_ARG_INT, &video_width,
  26.110 +         "Video width", NULL},
  26.111 +
  26.112 +        {"video-height", 0, 0, G_OPTION_ARG_INT, &video_height,
  26.113 +         "Video height", NULL},
  26.114 +
  26.115 +        {"audio-encode", 0, 0, G_OPTION_ARG_STRING, &audio_encode,
  26.116 +         "GstElementName for use to audio encode", NULL},
  26.117 +
  26.118 +        {"audio-opts", 0, 0, G_OPTION_ARG_STRING, &audio_opts,
  26.119 +         "Properties to set on audio element", NULL},
  26.120 +
  26.121 +        {"audio-rate", 0, 0, G_OPTION_ARG_INT, &audio_rate,
  26.122 +         "Audio rate", NULL},
  26.123 +
  26.124 +        {"mux-element", 0, 0, G_OPTION_ARG_STRING, &mux_name,
  26.125 +         "GstElementName for use to mux file", NULL},
  26.126 +
  26.127 +        {"output-uri", 'o', 0, G_OPTION_ARG_STRING, &output_uri,
  26.128 +         "Uri to output", NULL},
  26.129 +
  26.130 +	{"chunked", 'c', 0, G_OPTION_ARG_NONE, &chunked, 
  26.131 +         "Send package chunked", NULL},
  26.132 +
  26.133 +	{"deinterlace", 'd', 0, G_OPTION_ARG_NONE, &deinterlace, 
  26.134 +         "Use to deinterlace videos", NULL},
  26.135 +
  26.136 +
  26.137 +        {NULL}
  26.138 +    };
  26.139 +
  26.140 +    g_type_init();
  26.141 +    g_thread_init(NULL);
  26.142 +    gnome_vfs_init ();
  26.143 +    mainloop = g_main_loop_new(NULL, FALSE);
  26.144 +
  26.145 +    g_set_prgname("gmemcoder");
  26.146 +    context = g_option_context_new(NULL);
  26.147 +    g_option_context_set_help_enabled(context, TRUE);
  26.148 +    g_option_context_add_main_entries(context, options, NULL);
  26.149 +    g_option_context_add_group(context, gst_init_get_option_group());
  26.150 +    g_option_context_parse(context, &argc, &argv, NULL);
  26.151 +
  26.152 +    gst_init(&argc, &argv);
  26.153 +
  26.154 +    if (output_uri == NULL) {
  26.155 +        g_print("You need to specify output-uri.\nTry --help "
  26.156 +                "for more information.\n");
  26.157 +        return 1;
  26.158 +    }
  26.159 +
  26.160 +    if (input_file == NULL) {
  26.161 +        g_print("You need to specify input file\nTry --help "
  26.162 +                "for more information.\n");
  26.163 +    }
  26.164 +
  26.165 +    coder = g_mencoder_new();
  26.166 +    ch = g_io_channel_unix_new(0);
  26.167 +
  26.168 +    if (audio_opts != NULL)
  26.169 +        aopts = g_strsplit(audio_opts, ",", 0);
  26.170 +    else
  26.171 +        aopts = NULL;
  26.172 +
  26.173 +    if (video_opts != NULL)
  26.174 +        vopts = g_strsplit(video_opts, ",", 0);
  26.175 +    else
  26.176 +        vopts = NULL;
  26.177 +
  26.178 +    ret = g_mencoder_setup_stream(coder, chunked, deinterlace, mux_name,
  26.179 +                                  video_encode, vopts, video_fps,
  26.180 +                                  video_rate, video_width, video_height,
  26.181 +                                  audio_encode, aopts, audio_rate, output_uri);
  26.182 +
  26.183 +    if (ret == TRUE) {
  26.184 +        files = g_strsplit(input_file, ",", 0);
  26.185 +        for (i = 0; i < g_strv_length(files); i++) {
  26.186 +            if (!g_mencoder_append_uri(coder, files[i])) {
  26.187 +                g_debug("Invalid uri: %s", files[i]);
  26.188 +            }
  26.189 +        }
  26.190 +        g_strfreev(files);
  26.191 +    }
  26.192 +
  26.193 +    g_strfreev(aopts);
  26.194 +    g_strfreev(vopts);
  26.195 +
  26.196 +    if (ret == TRUE) {
  26.197 +        g_io_add_watch(ch, G_IO_IN, _io_channel_cb, coder);
  26.198 +        g_signal_connect(G_OBJECT(coder),
  26.199 +                         "eos", G_CALLBACK(_mencoder_eos_cb), mainloop);
  26.200 +
  26.201 +        g_signal_connect(G_OBJECT(coder),
  26.202 +                         "error", G_CALLBACK(_mencoder_error_cb), mainloop);
  26.203 +
  26.204 +        g_mencoder_play_stream(coder);
  26.205 +        g_main_loop_run(mainloop);
  26.206 +    }
  26.207 +
  26.208 +    g_object_unref(coder);
  26.209 +    return 0;
  26.210 +}
    27.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    27.2 +++ b/gmyth-stream/gmencoder/tests/Makefile.am	Tue Sep 18 13:45:36 2007 +0100
    27.3 @@ -0,0 +1,15 @@
    27.4 +bin_PROGRAMS = \
    27.5 +	gnl-test
    27.6 +
    27.7 +gnl_test_SOURCES = \
    27.8 +	main.c 
    27.9 +	
   27.10 +gnl_test_LDADD = \
   27.11 +	$(GLIB_LIBS) \
   27.12 +	$(GST_LIBS)
   27.13 +
   27.14 +AM_CPPFLAGS = \
   27.15 +	$(GLIB_CFLAGS) \
   27.16 +	$(GST_CFLAGS)
   27.17 +
   27.18 +CLEANFILES = 
    28.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    28.2 +++ b/gmyth-stream/gmencoder/tests/main.c	Tue Sep 18 13:45:36 2007 +0100
    28.3 @@ -0,0 +1,230 @@
    28.4 +#include <sys/stat.h>
    28.5 +#include <fcntl.h>
    28.6 +#include <unistd.h>
    28.7 +#include <string.h>
    28.8 +
    28.9 +#include <gst/gst.h>
   28.10 +#include <glib.h>
   28.11 +
   28.12 +
   28.13 +static GMainLoop *mainloop = NULL;
   28.14 +static gint64   d = 0;
   28.15 +static gint64   gap = 10;
   28.16 +
   28.17 +typedef enum {
   28.18 +    MY_STREAM_TYPE_AUDIO = 0,
   28.19 +    MY_STREAM_TYPE_VIDEO = 1
   28.20 +} MyStreamType;
   28.21 +
   28.22 +typedef struct _StreamData StreamData;
   28.23 +struct _StreamData {
   28.24 +    GstElement     *bin;
   28.25 +    MyStreamType    type;
   28.26 +};
   28.27 +
   28.28 +static void
   28.29 +_stream_decode_pad_added_cb(GstElement * decode,
   28.30 +                            GstPad * pad, gboolean arg1,
   28.31 +                            gpointer user_data)
   28.32 +{
   28.33 +    StreamData     *data = (StreamData *) user_data;
   28.34 +    GstElement     *queue;
   28.35 +    GstPad         *sink_pad;
   28.36 +    GstCaps        *caps = gst_pad_get_caps(pad);
   28.37 +    gchar          *str_caps = gst_caps_to_string(caps);
   28.38 +
   28.39 +    g_debug("decode caps: [%d] [%s]", data->type, str_caps);
   28.40 +
   28.41 +    switch (data->type) {
   28.42 +    case MY_STREAM_TYPE_AUDIO:
   28.43 +        g_debug("Audio");
   28.44 +        if (strstr(str_caps, "audio") == NULL)
   28.45 +            goto done;
   28.46 +        break;
   28.47 +    case MY_STREAM_TYPE_VIDEO:
   28.48 +        g_debug("Video");
   28.49 +        if (strstr(str_caps, "video") == NULL)
   28.50 +            goto done;
   28.51 +        break;
   28.52 +    }
   28.53 +
   28.54 +    queue = gst_bin_get_by_name(GST_BIN(data->bin), "queue");
   28.55 +    sink_pad = gst_element_get_pad(queue, "sink");
   28.56 +
   28.57 +    if (gst_pad_link(pad, sink_pad) != GST_PAD_LINK_OK) {
   28.58 +        g_warning("Failed to link decode");
   28.59 +    }
   28.60 +
   28.61 +    gst_object_unref(queue);
   28.62 +    gst_object_unref(sink_pad);
   28.63 +    // g_free (data);
   28.64 +    g_debug("Linked");
   28.65 +
   28.66 +  done:
   28.67 +    gst_caps_unref(caps);
   28.68 +    g_free(str_caps);
   28.69 +}
   28.70 +
   28.71 +
   28.72 +static GstElement *
   28.73 +_create_src_element(const gchar * name,
   28.74 +                    const gchar * uri, MyStreamType type, guint priority)
   28.75 +{
   28.76 +    StreamData     *data;
   28.77 +    GstElement     *bin;
   28.78 +    GstElement     *src;
   28.79 +    GstElement     *decode;
   28.80 +    GstElement     *queue;
   28.81 +    GstPad         *src_pad;
   28.82 +
   28.83 +    GstElement     *gnl_src;
   28.84 +
   28.85 +    g_debug("element from uri: %s", uri);
   28.86 +
   28.87 +    bin = gst_bin_new("bin");
   28.88 +    src = gst_element_make_from_uri(GST_URI_SRC, uri, "src");
   28.89 +    g_return_val_if_fail(src != NULL, NULL);
   28.90 +
   28.91 +    decode = gst_element_factory_make("decodebin", NULL);
   28.92 +    g_return_val_if_fail(decode != NULL, NULL);
   28.93 +
   28.94 +    queue = gst_element_factory_make("queue", "queue");
   28.95 +    g_return_val_if_fail(queue != NULL, NULL);
   28.96 +
   28.97 +    gst_bin_add_many(GST_BIN(bin), src, decode, queue, NULL);
   28.98 +    gst_element_link(src, decode);
   28.99 +
  28.100 +    data = g_new0(StreamData, 1);
  28.101 +    data->bin = bin;
  28.102 +    data->type = type;
  28.103 +    g_debug("Type : %d = %d", type, data->type);
  28.104 +
  28.105 +    g_signal_connect(G_OBJECT(decode), "new-decoded-pad",
  28.106 +                     G_CALLBACK(_stream_decode_pad_added_cb), data);
  28.107 +
  28.108 +
  28.109 +    src_pad = gst_element_get_pad(queue, "src");
  28.110 +    g_return_val_if_fail(src_pad != NULL, NULL);
  28.111 +
  28.112 +    gst_element_add_pad(bin, gst_ghost_pad_new("src", src_pad));
  28.113 +
  28.114 +    gst_object_unref(src_pad);
  28.115 +
  28.116 +    gnl_src = gst_element_factory_make("gnlsource", name);
  28.117 +    g_return_val_if_fail(gnl_src != NULL, NULL);
  28.118 +    gst_bin_add(GST_BIN(gnl_src), bin);
  28.119 +
  28.120 +    g_debug("ADDING WITH: START [%lli] DUR [%lli]", d, gap);
  28.121 +    if (d == 0) {
  28.122 +        g_object_set(G_OBJECT(gnl_src),
  28.123 +                     // "start", 0L,
  28.124 +                     "duration", 10 * GST_SECOND,
  28.125 +                     // "media-start", 0L,
  28.126 +                     // "media-duration", 10 * GST_SECOND,
  28.127 +                     "priority", priority, NULL);
  28.128 +
  28.129 +    } else {
  28.130 +        g_object_set(G_OBJECT(gnl_src),
  28.131 +                     "start", 10 * GST_SECOND, "duration", 10 * GST_SECOND,
  28.132 +                     // /"media-start", 10 * GST_SECOND,
  28.133 +                     // "media-duration", 10 * GST_SECOND,
  28.134 +                     "priority", priority, NULL);
  28.135 +
  28.136 +    }
  28.137 +    d++;
  28.138 +
  28.139 +    return gnl_src;
  28.140 +}
  28.141 +
  28.142 +static void
  28.143 +_composition_pad_added_cb(GstElement * composition,
  28.144 +                          GstPad * pad, gpointer data)
  28.145 +{
  28.146 +    GstPad         *sink_pad =
  28.147 +        gst_element_get_pad(GST_ELEMENT(data), "sink");
  28.148 +    g_debug("compose pad added");
  28.149 +
  28.150 +    if (gst_pad_link(pad, sink_pad) != GST_PAD_LINK_OK) {
  28.151 +        g_warning("Failed to link decode");
  28.152 +    }
  28.153 +
  28.154 +    g_debug("Linked ok");
  28.155 +}
  28.156 +
  28.157 +static void
  28.158 +_compose_add_file(GstElement * compose,
  28.159 +                  const gchar * e_name,
  28.160 +                  const gchar * uri, MyStreamType type, guint priority)
  28.161 +{
  28.162 +    GstElement     *src;
  28.163 +
  28.164 +    src = _create_src_element(e_name, uri, type, priority);
  28.165 +    gst_bin_add(GST_BIN(compose), src);
  28.166 +}
  28.167 +
  28.168 +
  28.169 +int
  28.170 +main(int argc, char **argv)
  28.171 +{
  28.172 +    GstElement     *pipe;
  28.173 +    GstElement     *gnl_compose_a;
  28.174 +    GstElement     *gnl_compose_v;
  28.175 +    GstElement     *asink;
  28.176 +    GstElement     *vsink;
  28.177 +    GstElement     *aqueue;
  28.178 +    GstElement     *vqueue;
  28.179 +
  28.180 +    g_type_init();
  28.181 +    gst_init(&argc, &argv);
  28.182 +
  28.183 +    mainloop = g_main_loop_new(NULL, FALSE);
  28.184 +
  28.185 +    pipe = gst_pipeline_new("test_pipeline");
  28.186 +
  28.187 +    gnl_compose_a = gst_element_factory_make("gnlcomposition", "acompose");
  28.188 +    g_return_val_if_fail(gnl_compose_a != NULL, 1);
  28.189 +
  28.190 +    gnl_compose_v = gst_element_factory_make("gnlcomposition", "vcompose");
  28.191 +    g_return_val_if_fail(gnl_compose_v != NULL, 1);
  28.192 +
  28.193 +
  28.194 +    // _compose_add_file (gnl_compose_a, "src0", argv[1],
  28.195 +    // MY_STREAM_TYPE_AUDIO, 1);
  28.196 +    // _compose_add_file (gnl_compose_a, "src1", argv[2],
  28.197 +    // MY_STREAM_TYPE_AUDIO, 1);
  28.198 +
  28.199 +    d = 0;
  28.200 +
  28.201 +    _compose_add_file(gnl_compose_v, "src2", argv[1], MY_STREAM_TYPE_VIDEO,
  28.202 +                      1);
  28.203 +    _compose_add_file(gnl_compose_v, "src3", argv[2], MY_STREAM_TYPE_VIDEO,
  28.204 +                      1);
  28.205 +
  28.206 +
  28.207 +    // aqueue = gst_element_factory_make ("queue", "aqueue");
  28.208 +    // asink = gst_element_factory_make ("alsasink", "asink");
  28.209 +
  28.210 +    vqueue = gst_element_factory_make("queue", "vqueue");
  28.211 +    vsink = gst_element_factory_make("xvimagesink", "vsink");
  28.212 +
  28.213 +    gst_bin_add_many(GST_BIN(pipe), gnl_compose_a, gnl_compose_v, vqueue,
  28.214 +                     vsink,
  28.215 +                     // aqueue, asink, 
  28.216 +                     NULL);
  28.217 +
  28.218 +    gst_element_link(vqueue, vsink);
  28.219 +    // gst_element_link (aqueue, asink);
  28.220 +
  28.221 +    // g_signal_connect (G_OBJECT (gnl_compose_a), "pad-added",
  28.222 +    // G_CALLBACK (_composition_pad_added_cb), aqueue);
  28.223 +
  28.224 +    g_signal_connect(G_OBJECT(gnl_compose_v), "pad-added",
  28.225 +                     G_CALLBACK(_composition_pad_added_cb), vqueue);
  28.226 +
  28.227 +
  28.228 +    // g_idle_add (_play, pipe);
  28.229 +    gst_element_set_state(GST_ELEMENT(pipe), GST_STATE_PLAYING);
  28.230 +    g_main_loop_run(mainloop);
  28.231 +
  28.232 +    return 0;
  28.233 +}