├── NEWS ├── README ├── ChangeLog ├── .rvmrc ├── AUTHORS ├── Makefile.am ├── common ├── m4 │ ├── README │ ├── gst-gettext.m4 │ ├── gst-plugindir.m4 │ ├── gst-plugin-docs.m4 │ ├── Makefile.am │ ├── gst-dowhile.m4 │ ├── as-compiler.m4 │ ├── as-objc.m4 │ ├── gst-valgrind.m4 │ ├── gst.m4 │ ├── as-ac-expand.m4 │ ├── as-libtool.m4 │ ├── as-scrub-include.m4 │ ├── as-gcc-inline-assembly.m4 │ ├── gtk-doc.m4 │ ├── as-compiler-flag.m4 │ ├── as-auto-alt.m4 │ ├── gst-debuginfo.m4 │ ├── gst-libxml2.m4 │ ├── gst-parser.m4 │ ├── as-docbook.m4 │ ├── gst-function.m4 │ ├── orc.m4 │ ├── as-version.m4 │ ├── gst-platform.m4 │ ├── gst-glib2.m4 │ ├── gst-x11.m4 │ ├── as-libtool-tags.m4 │ ├── introspection.m4 │ ├── gst-package-release-datetime.m4 │ ├── gst-default.m4 │ ├── gst-arch.m4 │ ├── as-python.m4 │ ├── gst-doc.m4 │ ├── pkg.m4 │ ├── check.m4 │ ├── gst-error.m4 │ ├── gst-feature.m4 │ ├── gst-check.m4 │ ├── gst-args.m4 │ └── glib-gettext.m4 └── gst-autogen.sh ├── src ├── Makefile.am ├── uuencode.h ├── gst-util.h ├── op_services.h ├── operations │ ├── ping.h │ ├── control.h │ ├── play.h │ ├── ping.c │ ├── control.c │ └── play.c ├── pubsub.h ├── parser.h ├── utility.h ├── gst_playd.1 ├── pubsub.c ├── gst-util.c ├── utility.c ├── parser.c ├── uuencode.c └── gst_playd.c ├── .gitignore ├── configure.in ├── extras └── gst-playd-client.rb ├── README.md └── autogen.sh /NEWS: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.rvmrc: -------------------------------------------------------------------------------- 1 | rvm use 1.9.3 2 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Paul Betts 2 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = src 2 | DIST_SUBDIRS = src 3 | -------------------------------------------------------------------------------- /common/m4/README: -------------------------------------------------------------------------------- 1 | All aclocal .m4 files we need are put here and cat'd to acinclude.m4 in 2 | the source root. Official ones (taken from the relevant devel packages) 3 | are named as-is, unofficial ones (or changed ones) get a gst-prefix. 4 | -------------------------------------------------------------------------------- /src/Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS=gst_playd 2 | 3 | gst_playd_SOURCES= \ 4 | gst_playd.c \ 5 | gst-util.c \ 6 | parser.c \ 7 | pubsub.c \ 8 | operations/control.c \ 9 | operations/ping.c \ 10 | operations/play.c \ 11 | utility.c \ 12 | uuencode.c \ 13 | gst_playd.1 \ 14 | aclocal.m4 15 | 16 | # uncomment the following if gst_playd requires the math library 17 | gst_playd_CFLAGS = \ 18 | -Wall \ 19 | $(GLIB_CFLAGS) \ 20 | $(LIBZMQ_CFLAGS) \ 21 | $(GST_CFLAGS) 22 | 23 | gst_playd_LDADD = \ 24 | $(GLIB_LIBS) \ 25 | $(LIBZMQ_LIBS) \ 26 | $(GST_LIBS) 27 | 28 | # install the man pages 29 | man_MANS=gst_playd.1 30 | -------------------------------------------------------------------------------- /common/m4/gst-gettext.m4: -------------------------------------------------------------------------------- 1 | dnl gettext setup 2 | 3 | dnl AG_GST_GETTEXT([gettext-package]) 4 | dnl defines GETTEXT_PACKAGE and LOCALEDIR 5 | 6 | AC_DEFUN([AG_GST_GETTEXT], 7 | [ 8 | if test "$USE_NLS" = "yes"; then 9 | GETTEXT_PACKAGE=[$1] 10 | else 11 | GETTEXT_PACKAGE=[NULL] 12 | fi 13 | AC_SUBST(GETTEXT_PACKAGE) 14 | AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE], "$GETTEXT_PACKAGE", 15 | [gettext package name]) 16 | 17 | dnl define LOCALEDIR in config.h 18 | AS_AC_EXPAND(LOCALEDIR, $datadir/locale) 19 | AC_DEFINE_UNQUOTED([LOCALEDIR], "$LOCALEDIR", 20 | [gettext locale dir]) 21 | ]) 22 | -------------------------------------------------------------------------------- /common/m4/gst-plugindir.m4: -------------------------------------------------------------------------------- 1 | dnl AG_GST_SET_PLUGINDIR 2 | 3 | dnl AC_DEFINE PLUGINDIR to the full location where plug-ins will be installed 4 | dnl AC_SUBST plugindir, to be used in Makefile.am's 5 | 6 | AC_DEFUN([AG_GST_SET_PLUGINDIR], 7 | [ 8 | dnl define location of plugin directory 9 | AS_AC_EXPAND(PLUGINDIR, ${libdir}/gstreamer-$GST_MAJORMINOR) 10 | AC_DEFINE_UNQUOTED(PLUGINDIR, "$PLUGINDIR", 11 | [directory where plugins are located]) 12 | AC_MSG_NOTICE([Using $PLUGINDIR as the plugin install location]) 13 | 14 | dnl plugin directory configure-time variable for use in Makefile.am 15 | plugindir="\$(libdir)/gstreamer-$GST_MAJORMINOR" 16 | AC_SUBST(plugindir) 17 | ]) 18 | -------------------------------------------------------------------------------- /common/m4/gst-plugin-docs.m4: -------------------------------------------------------------------------------- 1 | dnl AG_GST_PLUGIN_DOCS([MINIMUM-GTK-DOC-VERSION],[MINIMUM-PYTHON-VERSION]) 2 | dnl 3 | dnl checks for prerequisites for the common/mangle-tmpl.py script 4 | dnl used when building the plugin documentation 5 | 6 | AC_DEFUN([AG_GST_PLUGIN_DOCS], 7 | [ 8 | AC_BEFORE([GTK_DOC_CHECK],[$0])dnl check for gtk-doc first 9 | AC_BEFORE([AS_PATH_PYTHON],[$1])dnl find python first 10 | 11 | build_plugin_docs=no 12 | AC_MSG_CHECKING([whether to build plugin documentation]) 13 | if test x$enable_gtk_doc = xyes; then 14 | build_plugin_docs=yes 15 | AC_MSG_RESULT([yes]) 16 | else 17 | AC_MSG_RESULT([no (gtk-doc disabled or not available)]) 18 | fi 19 | 20 | AM_CONDITIONAL(ENABLE_PLUGIN_DOCS, test x$build_plugin_docs = xyes) 21 | ]) 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | Android.mk 2 | ABOUT-NLS 3 | Makefile 4 | Makefile.in 5 | aclocal.m4 6 | config.cache 7 | config.guess 8 | config.h 9 | config.h.in 10 | config.h-new 11 | config.log 12 | config.rpath 13 | config.status* 14 | config.sub 15 | configure 16 | gstreamer-[0-9]* 17 | gstreamer-config 18 | gstreamer.pc 19 | gstreamer-uninstalled.pc 20 | gstreamer.spec 21 | gst-element-check-*.m4 22 | libtool 23 | ltconfig 24 | ltmain.sh 25 | missing 26 | stamp-h 27 | stamp-h.in 28 | stamp.h 29 | autom4te.cache 30 | autom4te-2.53.cache 31 | stamp-h1 32 | autoregen.sh 33 | compile 34 | depcomp 35 | install-sh 36 | mkinstalldirs 37 | py-compile 38 | registry.* 39 | coverage-report.txt 40 | gst-element-check.m4 41 | .deps 42 | .libs 43 | *~ 44 | _stdint.h 45 | *.gir 46 | *.typelib 47 | *.o 48 | src/gst_playd 49 | -------------------------------------------------------------------------------- /src/uuencode.h: -------------------------------------------------------------------------------- 1 | /* vi: set sw=4 ts=4: */ 2 | /* 3 | * Copyright 2003, Glenn McGrath 4 | * Copyright 2006, Rob Landley 5 | * Copyright 2010, Denys Vlasenko 6 | * 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. 8 | */ 9 | 10 | #ifndef __UUENCODE_H 11 | #define __UUENCODE_H 12 | 13 | enum { 14 | BASE64_FLAG_UU_STOP = 0x100, 15 | /* Sign-extends to a value which never_uses_backup_flager matches fgetc result: */ 16 | BASE64_FLAG_NO_STOP_CHAR = 0x80, 17 | }; 18 | 19 | const char uuenc_tbl_base64[65 + 1]; 20 | const char uuenc_tbl_std[65]; 21 | 22 | void uuencode(char *p, const void *src, int length, const char *tbl); 23 | int uuencode_get_length(int source_size); 24 | const char* decode_base64(char **pp_dst, const char *src); 25 | int read_base64(FILE *src_stream, FILE *dst_stream, int flags); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /common/m4/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST = \ 2 | README \ 3 | as-ac-expand.m4 \ 4 | as-auto-alt.m4 \ 5 | as-compiler-flag.m4 \ 6 | as-compiler.m4 \ 7 | as-docbook.m4 \ 8 | as-gcc-inline-assembly.m4 \ 9 | as-libtool.m4 \ 10 | as-libtool-tags.m4 \ 11 | as-objc.m4 \ 12 | as-python.m4 \ 13 | as-scrub-include.m4 \ 14 | as-version.m4 \ 15 | ax_create_stdint_h.m4 \ 16 | glib-gettext.m4 \ 17 | gst-arch.m4 \ 18 | gst-args.m4 \ 19 | gst-check.m4 \ 20 | gst-debuginfo.m4 \ 21 | gst-default.m4 \ 22 | gst-doc.m4 \ 23 | gst-dowhile.m4 \ 24 | gst-error.m4 \ 25 | gst-feature.m4 \ 26 | gst-function.m4 \ 27 | gst-gettext.m4 \ 28 | gst-glib2.m4 \ 29 | gst-libxml2.m4 \ 30 | gst-parser.m4 \ 31 | gst-package-release-datetime.m4 \ 32 | gst-platform.m4 \ 33 | gst-plugindir.m4 \ 34 | gst-plugin-docs.m4 \ 35 | gst-valgrind.m4 \ 36 | gst-x11.m4 \ 37 | gst.m4 \ 38 | gtk-doc.m4 \ 39 | introspection.m4 \ 40 | pkg.m4 \ 41 | check.m4 \ 42 | orc.m4 43 | -------------------------------------------------------------------------------- /common/m4/gst-dowhile.m4: -------------------------------------------------------------------------------- 1 | dnl 2 | dnl Check for working do while(0) macros. This is used by G_STMT_START 3 | dnl and G_STMT_END in glib/gmacros.h. Without having this defined we 4 | dnl get "ambigious if-else" compiler warnings when compling C++ code. 5 | dnl 6 | dnl Copied from GLib's configure.in 7 | dnl 8 | AC_DEFUN([AG_GST_CHECK_DOWHILE_MACROS],[ 9 | 10 | dnl *** check for working do while(0) macros *** 11 | AC_CACHE_CHECK([for working do while(0) macros], _cv_g_support_dowhile_macros, [ 12 | AC_TRY_COMPILE([],[ 13 | #define STMT_START do 14 | #define STMT_END while(0) 15 | #define STMT_TEST STMT_START { i = 0; } STMT_END 16 | int main(void) { int i = 1; STMT_TEST; return i; }], 17 | [_cv_g_support_dowhile_macros=yes], 18 | [_cv_g_support_dowhile_macros=no], 19 | [_cv_g_support_dowhile_macros=yes]) 20 | ]) 21 | if test x$_cv_g_support_dowhile_macros = xyes; then 22 | AC_DEFINE(HAVE_DOWHILE_MACROS, 1, [define for working do while(0) macros]) 23 | fi 24 | ]) 25 | -------------------------------------------------------------------------------- /common/m4/as-compiler.m4: -------------------------------------------------------------------------------- 1 | dnl as-compiler.m4 0.1.0 2 | 3 | dnl autostars m4 macro for detection of compiler flavor 4 | 5 | dnl Thomas Vander Stichele 6 | 7 | dnl $Id: as-compiler.m4,v 1.4 2004/06/01 09:44:19 thomasvs Exp $ 8 | 9 | dnl AS_COMPILER(COMPILER) 10 | dnl will set variable COMPILER to 11 | dnl - gcc 12 | dnl - forte 13 | dnl - (empty) if no guess could be made 14 | 15 | AC_DEFUN([AS_COMPILER], 16 | [ 17 | as_compiler= 18 | AC_MSG_CHECKING(for compiler flavour) 19 | 20 | dnl is it gcc ? 21 | if test "x$GCC" = "xyes"; then 22 | as_compiler="gcc" 23 | fi 24 | 25 | dnl is it forte ? 26 | AC_TRY_RUN([ 27 | int main 28 | (int argc, char *argv[]) 29 | { 30 | #ifdef __sun 31 | return 0; 32 | #else 33 | return 1; 34 | #endif 35 | } 36 | ], as_compiler="forte", ,) 37 | 38 | if test "x$as_compiler" = "x"; then 39 | AC_MSG_RESULT([unknown !]) 40 | else 41 | AC_MSG_RESULT($as_compiler) 42 | fi 43 | [$1]=$as_compiler 44 | ]) 45 | -------------------------------------------------------------------------------- /src/gst-util.h: -------------------------------------------------------------------------------- 1 | /* 2 | gst-util.h - GStreamer helper functions 3 | 4 | Copyright (C) 2012 Paul Betts 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2, or (at your option) 9 | any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software Foundation, 18 | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | 22 | #ifndef _GST_UTIL_H 23 | #define _GST_UTIL_H 24 | 25 | #include 26 | #include 27 | 28 | void gsu_tags_to_hash_table(const GstTagList* tags, GHashTable* table); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /common/m4/as-objc.m4: -------------------------------------------------------------------------------- 1 | 2 | 3 | # AC_PROG_OBJC([LIST-OF-COMPILERS]) 4 | # 5 | AC_DEFUN([AS_PROG_OBJC], 6 | [ 7 | AC_CHECK_TOOLS(OBJC, 8 | [m4_default([$1], [objcc objc gcc cc CC])], 9 | none) 10 | AC_SUBST(OBJC) 11 | OBJC_LDFLAGS="-lobjc" 12 | AC_SUBST(OBJC_LDFLAGS) 13 | if test "x$OBJC" != xnone ; then 14 | _AM_DEPENDENCIES(OBJC) 15 | AC_MSG_CHECKING([if Objective C compiler works]) 16 | cat >>conftest.m < 18 | @interface Moo:Object 19 | { 20 | } 21 | - moo; 22 | int main(); 23 | @end 24 | 25 | @implementation Moo 26 | - moo 27 | { 28 | exit(0); 29 | } 30 | 31 | int main() 32 | { 33 | id moo; 34 | moo = [[Moo new]]; 35 | [[moo moo]]; 36 | return 1; 37 | } 38 | @end 39 | EOF 40 | ${OBJC} conftest.m ${OBJC_LDFLAGS} >&5 2>&5 41 | if test -f a.out -o -f a.exe ; then 42 | result=yes 43 | else 44 | result=no 45 | echo failed program is: >&5 46 | cat conftest.m >&5 47 | fi 48 | rm -f conftest.m a.out a.exe 49 | AC_MSG_RESULT([$result]) 50 | else 51 | _AM_DEPENDENCIES(OBJC) 52 | fi 53 | 54 | ]) 55 | 56 | 57 | -------------------------------------------------------------------------------- /src/op_services.h: -------------------------------------------------------------------------------- 1 | /* 2 | op_services.h - Defines objects that are available to message handlers 3 | 4 | Copyright (C) 2012 Paul Betts 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2, or (at your option) 9 | any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software Foundation, 18 | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | #ifndef _OP_SERVICES_H 22 | #define _OP_SERVICES_H 23 | 24 | #include "pubsub.h" 25 | 26 | struct op_services { 27 | struct pubsub_ctx* pub_sub; 28 | gboolean* should_quit; 29 | }; 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /src/operations/ping.h: -------------------------------------------------------------------------------- 1 | /* 2 | ping.h - ping operations 3 | 4 | Copyright (C) 2012 Paul Betts 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2, or (at your option) 9 | any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software Foundation, 18 | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | #ifndef _PING_H 22 | #define _PING_H 23 | 24 | void* op_ping_new(void*); 25 | char* op_ping_parse(const char* param, void*); 26 | gboolean op_ping_register(void* ctx, struct message_dispatch_entry** entries); 27 | void op_ping_free(void* ctx); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /common/m4/gst-valgrind.m4: -------------------------------------------------------------------------------- 1 | AC_DEFUN([AG_GST_VALGRIND_CHECK], 2 | [ 3 | dnl valgrind inclusion 4 | AC_ARG_ENABLE(valgrind, 5 | AC_HELP_STRING([--disable-valgrind], [disable run-time valgrind detection]), 6 | [ 7 | case "${enableval}" in 8 | yes) USE_VALGRIND="$USE_DEBUG" ;; 9 | no) USE_VALGRIND=no ;; 10 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-valgrind) ;; 11 | esac], 12 | [ 13 | USE_VALGRIND="$USE_DEBUG" 14 | ]) dnl Default value 15 | 16 | VALGRIND_REQ="3.0" 17 | if test "x$USE_VALGRIND" = xyes; then 18 | PKG_CHECK_MODULES(VALGRIND, valgrind >= $VALGRIND_REQ, 19 | USE_VALGRIND="yes", 20 | [ 21 | USE_VALGRIND="no" 22 | AC_MSG_RESULT([no]) 23 | ]) 24 | fi 25 | 26 | if test "x$USE_VALGRIND" = xyes; then 27 | AC_DEFINE(HAVE_VALGRIND, 1, [Define if valgrind should be used]) 28 | AC_MSG_NOTICE(Using extra code paths for valgrind) 29 | fi 30 | AC_SUBST(VALGRIND_CFLAGS) 31 | AC_SUBST(VALGRIND_LIBS) 32 | 33 | AC_PATH_PROG(VALGRIND_PATH, valgrind, no) 34 | AM_CONDITIONAL(HAVE_VALGRIND, test ! "x$VALGRIND_PATH" = "xno") 35 | ]) 36 | -------------------------------------------------------------------------------- /src/operations/control.h: -------------------------------------------------------------------------------- 1 | /* 2 | control.h - Control operations 3 | 4 | Copyright (C) 2012 Paul Betts 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2, or (at your option) 9 | any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software Foundation, 18 | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | #ifndef _CONTROL_H 22 | #define _CONTROL_H 23 | 24 | void* op_control_new(void*); 25 | char* op_pubsub_parse(const char* param, void*); 26 | char* op_quit_parse(const char* param, void* ctx); 27 | gboolean op_control_register(void* ctx, struct message_dispatch_entry** entries); 28 | void op_control_free(void* ctx); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /src/pubsub.h: -------------------------------------------------------------------------------- 1 | /* 2 | pubsub.h - API for sending messages over the ZeroMQ PUB socket 3 | 4 | Copyright (C) 2012 Paul Betts 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2, or (at your option) 9 | any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software Foundation, 18 | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | #ifndef _PUBSUB_H 22 | #define _PUBSUB_H 23 | 24 | struct pubsub_ctx; 25 | 26 | struct pubsub_ctx* pubsub_new(void* zmq_context, int icecast_port); 27 | void pubsub_free(struct pubsub_ctx* ctx); 28 | const char* pubsub_get_address(struct pubsub_ctx* ctx); 29 | gboolean pubsub_send_message(struct pubsub_ctx* ctx, const char* message); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /common/m4/gst.m4: -------------------------------------------------------------------------------- 1 | dnl AG_GST_INIT 2 | dnl sets up use of GStreamer configure.ac macros 3 | dnl all GStreamer autoconf macros are prefixed 4 | dnl with AG_GST_ for public macros 5 | dnl with _AG_GST_ for private macros 6 | 7 | AC_DEFUN([AG_GST_INIT], 8 | [ 9 | m4_pattern_forbid(^_?AG_GST_) 10 | ]) 11 | 12 | dnl AG_GST_PKG_CONFIG_PATH 13 | dnl 14 | dnl sets up a GST_PKG_CONFIG_PATH variable for use in Makefile.am 15 | dnl which contains the path of the in-tree pkgconfig directory first 16 | dnl and then any paths specified in PKG_CONFIG_PATH. 17 | dnl 18 | dnl We do this mostly so we don't have to use unportable shell constructs 19 | dnl such as ${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH} in Makefile.am to handle 20 | dnl the case where the environment variable is not set, but also in order 21 | dnl to avoid a trailing ':' in the PKG_CONFIG_PATH which apparently causes 22 | dnl problems with pkg-config on windows with msys/mingw. 23 | AC_DEFUN([AG_GST_PKG_CONFIG_PATH], 24 | [ 25 | GST_PKG_CONFIG_PATH="\$(top_builddir)/pkgconfig" 26 | if test "x$PKG_CONFIG_PATH" != "x"; then 27 | GST_PKG_CONFIG_PATH="$GST_PKG_CONFIG_PATH:$PKG_CONFIG_PATH" 28 | fi 29 | AC_SUBST([GST_PKG_CONFIG_PATH]) 30 | AC_MSG_NOTICE([Using GST_PKG_CONFIG_PATH = $GST_PKG_CONFIG_PATH]) 31 | ]) 32 | -------------------------------------------------------------------------------- /common/m4/as-ac-expand.m4: -------------------------------------------------------------------------------- 1 | dnl as-ac-expand.m4 0.2.0 2 | dnl autostars m4 macro for expanding directories using configure's prefix 3 | dnl thomas@apestaart.org 4 | 5 | dnl AS_AC_EXPAND(VAR, CONFIGURE_VAR) 6 | dnl example 7 | dnl AS_AC_EXPAND(SYSCONFDIR, $sysconfdir) 8 | dnl will set SYSCONFDIR to /usr/local/etc if prefix=/usr/local 9 | 10 | AC_DEFUN([AS_AC_EXPAND], 11 | [ 12 | EXP_VAR=[$1] 13 | FROM_VAR=[$2] 14 | 15 | dnl first expand prefix and exec_prefix if necessary 16 | prefix_save=$prefix 17 | exec_prefix_save=$exec_prefix 18 | 19 | dnl if no prefix given, then use /usr/local, the default prefix 20 | if test "x$prefix" = "xNONE"; then 21 | prefix="$ac_default_prefix" 22 | fi 23 | dnl if no exec_prefix given, then use prefix 24 | if test "x$exec_prefix" = "xNONE"; then 25 | exec_prefix=$prefix 26 | fi 27 | 28 | full_var="$FROM_VAR" 29 | dnl loop until it doesn't change anymore 30 | while true; do 31 | new_full_var="`eval echo $full_var`" 32 | if test "x$new_full_var" = "x$full_var"; then break; fi 33 | full_var=$new_full_var 34 | done 35 | 36 | dnl clean up 37 | full_var=$new_full_var 38 | AC_SUBST([$1], "$full_var") 39 | 40 | dnl restore prefix and exec_prefix 41 | prefix=$prefix_save 42 | exec_prefix=$exec_prefix_save 43 | ]) 44 | -------------------------------------------------------------------------------- /common/m4/as-libtool.m4: -------------------------------------------------------------------------------- 1 | dnl as-libtool.m4 0.1.4 2 | 3 | dnl autostars m4 macro for libtool versioning 4 | 5 | dnl Thomas Vander Stichele 6 | 7 | dnl $Id: as-libtool.m4,v 1.10 2005/10/15 13:44:23 thomasvs Exp $ 8 | 9 | dnl AS_LIBTOOL(PREFIX, CURRENT, REVISION, AGE, [RELEASE]) 10 | 11 | dnl example 12 | dnl AS_LIBTOOL(GST, 2, 0, 0) 13 | 14 | dnl this macro 15 | dnl - defines [$PREFIX]_CURRENT, REVISION and AGE 16 | dnl - defines [$PREFIX]_LIBVERSION 17 | dnl - defines [$PREFIX]_LT_LDFLAGS to set versioning 18 | dnl - AC_SUBST's them all 19 | 20 | dnl if RELEASE is given, then add a -release option to the LDFLAGS 21 | dnl with the given release version 22 | dnl then use [$PREFIX]_LT_LDFLAGS in the relevant Makefile.am's 23 | 24 | dnl call AM_PROG_LIBTOOL after this call 25 | 26 | AC_DEFUN([AS_LIBTOOL], 27 | [ 28 | [$1]_CURRENT=[$2] 29 | [$1]_REVISION=[$3] 30 | [$1]_AGE=[$4] 31 | [$1]_LIBVERSION=[$2]:[$3]:[$4] 32 | AC_SUBST([$1]_CURRENT) 33 | AC_SUBST([$1]_REVISION) 34 | AC_SUBST([$1]_AGE) 35 | AC_SUBST([$1]_LIBVERSION) 36 | 37 | [$1]_LT_LDFLAGS="$[$1]_LT_LDFLAGS -version-info $[$1]_LIBVERSION" 38 | if test ! -z "[$5]" 39 | then 40 | [$1]_LT_LDFLAGS="$[$1]_LT_LDFLAGS -release [$5]" 41 | fi 42 | AC_SUBST([$1]_LT_LDFLAGS) 43 | 44 | AC_LIBTOOL_DLOPEN 45 | ]) 46 | -------------------------------------------------------------------------------- /configure.in: -------------------------------------------------------------------------------- 1 | dnl Process this file with autoconf to produce a configure script. 2 | 3 | AC_INIT(src/gst_playd.c) 4 | dnl Every other copy of the package version number gets its value from here 5 | AM_INIT_AUTOMAKE(gst_playd, 0.1.0) 6 | 7 | dnl create a config.h file (Automake will add -DHAVE_CONFIG_H) 8 | AM_CONFIG_HEADER(config.h) 9 | 10 | AC_SUBST(VERSION) 11 | 12 | ISODATE=`date +%Y-%m-%d` 13 | AC_SUBST(ISODATE) 14 | 15 | AC_CANONICAL_HOST 16 | 17 | dnl Checks for programs. 18 | AC_PROG_INSTALL 19 | AC_PROG_CC 20 | AM_PROG_CC_C_O 21 | 22 | dnl Checks for libraries. 23 | PKG_CHECK_MODULES(GLIB, glib-2.0) 24 | AC_SUBST(GLIB) 25 | 26 | PKG_CHECK_MODULES(LIBZMQ, libzmq = 2.2.0) 27 | AC_SUBST(LIBZMQ) 28 | 29 | PKG_CHECK_MODULES(GST, gstreamer-0.10) 30 | AC_SUBST(GST) 31 | 32 | dnl Checks for header files. 33 | AC_HEADER_STDC 34 | AC_CHECK_HEADERS(unistd.h sys/param.h sys/time.h time.h sys/mkdev.h sys/sysmacros.h string.h memory.h fcntl.h dirent.h sys/ndir.h ndir.h alloca.h locale.h ) 35 | 36 | AC_HEADER_MAJOR 37 | AC_FUNC_ALLOCA 38 | AC_STRUCT_TM 39 | AC_STRUCT_ST_BLOCKS 40 | AC_FUNC_CLOSEDIR_VOID 41 | AC_CHECK_FUNCS(mkfifo) 42 | AC_CHECK_FUNC(mknod) 43 | 44 | dnl Checks for typedefs, structures, and compiler characteristics. 45 | 46 | dnl Checks for library functions. 47 | 48 | AC_OUTPUT(Makefile src/Makefile) 49 | -------------------------------------------------------------------------------- /src/operations/play.h: -------------------------------------------------------------------------------- 1 | /* 2 | play.h - Play pipeline message handlers 3 | 4 | Copyright (C) 2012 Paul Betts 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2, or (at your option) 9 | any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software Foundation, 18 | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | #ifndef _PLAY_H 22 | #define _PLAY_H 23 | 24 | void* op_playback_new(void*); 25 | char* op_tags_parse(const char* param, void*); 26 | char* op_play_parse(const char* param, void* ctx); 27 | char* op_dumpgraph_parse(const char* param, void* ctx); 28 | char* op_stop_parse(const char* param, void* ctx); 29 | gboolean op_playback_register(void* ctx, struct message_dispatch_entry** entries); 30 | void op_playback_free(void* ctx); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /common/m4/as-scrub-include.m4: -------------------------------------------------------------------------------- 1 | dnl as-scrub-include.m4 0.0.4 2 | 3 | dnl autostars m4 macro for scrubbing CFLAGS of system include dirs 4 | dnl because gcc 3.x complains about including system including dirs 5 | 6 | dnl Thomas Vander Stichele 7 | 8 | dnl $Id: as-scrub-include.m4,v 1.7 2004/06/12 08:30:20 thomasvs Exp $ 9 | 10 | dnl This macro uses output of cpp -v and expects it to contain text that 11 | dnl looks a little bit like this: 12 | dnl #include <...> search starts here: 13 | dnl /usr/local/include 14 | dnl /usr/lib/gcc-lib/i386-redhat-linux/3.2/include 15 | dnl /usr/include 16 | dnl End of search list. 17 | 18 | dnl AS_SCRUB_INCLUDE(VAR) 19 | dnl example 20 | dnl AS_SCRUB_INCLUDE(CFLAGS) 21 | dnl will remove all system include dirs from the given CFLAGS 22 | 23 | AC_DEFUN([AS_SCRUB_INCLUDE], 24 | [ 25 | GIVEN_CFLAGS=$[$1] 26 | INCLUDE_DIRS=`echo | cpp -v 2>&1` 27 | 28 | dnl remove everything from this output between the "starts here" and "End of" 29 | dnl line 30 | INCLUDE_DIRS=`echo $INCLUDE_DIRS | sed -e 's/.*<...> search starts here://' | sed -e 's/End of search list.*//'` 31 | for dir in $INCLUDE_DIRS; do 32 | dnl use "" as the sed script so $dir gets expanded 33 | GIVEN_CFLAGS=`echo $GIVEN_CFLAGS | sed -e "s#-I$dir ##"` 34 | done 35 | [$1]=$GIVEN_CFLAGS 36 | ]) 37 | -------------------------------------------------------------------------------- /common/m4/as-gcc-inline-assembly.m4: -------------------------------------------------------------------------------- 1 | dnl as-gcc-inline-assembly.m4 0.1.0 2 | 3 | dnl autostars m4 macro for detection of gcc inline assembly 4 | 5 | dnl David Schleef 6 | 7 | dnl $Id$ 8 | 9 | dnl AS_COMPILER_FLAG(ACTION-IF-ACCEPTED, [ACTION-IF-NOT-ACCEPTED]) 10 | dnl Tries to compile with the given CFLAGS. 11 | dnl Runs ACTION-IF-ACCEPTED if the compiler can compile with the flags, 12 | dnl and ACTION-IF-NOT-ACCEPTED otherwise. 13 | 14 | AC_DEFUN([AS_GCC_INLINE_ASSEMBLY], 15 | [ 16 | AC_MSG_CHECKING([if compiler supports gcc-style inline assembly]) 17 | 18 | AC_TRY_COMPILE([], [ 19 | #ifdef __GNUC_MINOR__ 20 | #if (__GNUC__ * 1000 + __GNUC_MINOR__) < 3004 21 | #error GCC before 3.4 has critical bugs compiling inline assembly 22 | #endif 23 | #endif 24 | __asm__ (""::) ], [flag_ok=yes], [flag_ok=no]) 25 | 26 | if test "X$flag_ok" = Xyes ; then 27 | $1 28 | true 29 | else 30 | $2 31 | true 32 | fi 33 | AC_MSG_RESULT([$flag_ok]) 34 | ]) 35 | 36 | 37 | AC_DEFUN([AS_GCC_ASM_POWERPC_FPU], 38 | [ 39 | AC_MSG_CHECKING([if compiler supports FPU instructions on PowerPC]) 40 | 41 | AC_TRY_COMPILE([], [__asm__ ("fadd 0,0,0"::) ], [flag_ok=yes], [flag_ok=no]) 42 | 43 | if test "X$flag_ok" = Xyes ; then 44 | $1 45 | true 46 | else 47 | $2 48 | true 49 | fi 50 | AC_MSG_RESULT([$flag_ok]) 51 | ]) 52 | 53 | -------------------------------------------------------------------------------- /extras/gst-playd-client.rb: -------------------------------------------------------------------------------- 1 | require 'zmq' 2 | 3 | class GstPlayDaemon 4 | def initialize(address) 5 | ctx = ZMQ::Context.new(1) 6 | @rep = ctx.socket(ZMQ::REQ) 7 | @rep.connect address 8 | 9 | @rep.send "PUBSUB " 10 | pubsub_addr = parse_response(@rep.recv) 11 | 12 | puts "PubSub addr is #{pubsub_addr}" 13 | @pubsub = ctx.socket(ZMQ::SUB) 14 | @pubsub.connect pubsub_addr 15 | end 16 | 17 | def ping 18 | msg = "GstPlayDaemon" 19 | @rep.send "PING #{msg}" 20 | 21 | return @rep.recv().end_with?(msg) 22 | end 23 | 24 | def close 25 | @pubsub.close; @pubsub = nil 26 | @rep.close; @rep = nil 27 | end 28 | 29 | def tags(uri) 30 | @rep.send "TAGS #{uri}" 31 | response_to_tag_dict(@rep.recv) 32 | end 33 | 34 | def play(uri) 35 | @rep.send "PLAY #{uri}" 36 | return parse_response(@rep.recv).gsub(/.*: /, '') 37 | end 38 | 39 | def stop(id) 40 | @rep.send "STOP #{id}" 41 | parse_response(@rep.recv); nil 42 | end 43 | 44 | private 45 | 46 | def parse_response(msg) 47 | re = /^([A-Z]+)[ ]?(.*)$/ 48 | m = re.match msg 49 | 50 | throw m[2] unless m[1] == "OK" 51 | m[2] 52 | end 53 | 54 | def response_to_tag_dict(msg) 55 | parse_response msg 56 | 57 | re = /^(.*)_([0-9]+)$/ ## someparam_0 58 | msg.lines.drop(1).each_slice(2).inject({}) do |acc,x| 59 | key,value = x 60 | m = re.match key 61 | 62 | acc[m[1]] ||= [] 63 | acc[m[1]] << value.chomp 64 | acc 65 | end 66 | end 67 | end 68 | -------------------------------------------------------------------------------- /common/m4/gtk-doc.m4: -------------------------------------------------------------------------------- 1 | dnl -*- mode: autoconf -*- 2 | 3 | # serial 1 4 | 5 | dnl Usage: 6 | dnl GTK_DOC_CHECK([minimum-gtk-doc-version]) 7 | AC_DEFUN([GTK_DOC_CHECK], 8 | [ 9 | AC_BEFORE([AC_PROG_LIBTOOL],[$0])dnl setup libtool first 10 | AC_BEFORE([AM_PROG_LIBTOOL],[$0])dnl setup libtool first 11 | dnl for overriding the documentation installation directory 12 | AC_ARG_WITH([html-dir], 13 | AS_HELP_STRING([--with-html-dir=PATH], [path to installed docs]),, 14 | [with_html_dir='${datadir}/gtk-doc/html']) 15 | HTML_DIR="$with_html_dir" 16 | AC_SUBST([HTML_DIR]) 17 | 18 | dnl enable/disable documentation building 19 | AC_ARG_ENABLE([gtk-doc], 20 | AS_HELP_STRING([--enable-gtk-doc], 21 | [use gtk-doc to build documentation [[default=no]]]),, 22 | [enable_gtk_doc=no]) 23 | 24 | if test x$enable_gtk_doc = xyes; then 25 | ifelse([$1],[], 26 | [PKG_CHECK_EXISTS([gtk-doc],, 27 | AC_MSG_ERROR([gtk-doc not installed and --enable-gtk-doc requested]))], 28 | [PKG_CHECK_EXISTS([gtk-doc >= $1],, 29 | AC_MSG_ERROR([You need to have gtk-doc >= $1 installed to build gtk-doc]))]) 30 | if test -z "$SED"; then 31 | AC_PROG_SED 32 | fi 33 | fi 34 | 35 | AC_MSG_CHECKING([whether to build gtk-doc documentation]) 36 | AC_MSG_RESULT($enable_gtk_doc) 37 | 38 | AC_PATH_PROGS(GTKDOC_CHECK,gtkdoc-check,) 39 | 40 | AM_CONDITIONAL([ENABLE_GTK_DOC], [test x$enable_gtk_doc = xyes]) 41 | AM_CONDITIONAL([GTK_DOC_USE_LIBTOOL], [test -n "$LIBTOOL"]) 42 | ]) 43 | -------------------------------------------------------------------------------- /src/parser.h: -------------------------------------------------------------------------------- 1 | /* 2 | parser.h - Message parsing and dispatch 3 | 4 | Copyright (C) 2012 Paul Betts 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2, or (at your option) 9 | any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software Foundation, 18 | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | #ifndef _PARSER_H 22 | #define _PARSER_H 23 | 24 | struct parse_ctx; 25 | 26 | typedef char* (*parse_handler_cb) (const char* prefix, void* ctx); 27 | 28 | struct message_dispatch_entry { 29 | const char* prefix; 30 | parse_handler_cb op_parse; 31 | }; 32 | 33 | struct parser_plugin_entry { 34 | const char* friendly_name; 35 | void* context; 36 | 37 | void* (*plugin_new)(void* registrar_ctx); 38 | gboolean (*plugin_register)(void* ctx, struct message_dispatch_entry** entries); 39 | void (*plugin_free)(void* ctx); 40 | }; 41 | 42 | struct parse_ctx* parse_new(); 43 | void parse_free(struct parse_ctx* parser); 44 | gboolean parse_register_plugin(struct parse_ctx* parser, struct parser_plugin_entry* plugin); 45 | char* parse_message(struct parse_ctx* parser, const char* message); 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /common/m4/as-compiler-flag.m4: -------------------------------------------------------------------------------- 1 | dnl as-compiler-flag.m4 0.1.0 2 | 3 | dnl autostars m4 macro for detection of compiler flags 4 | 5 | dnl David Schleef 6 | dnl Tim-Philipp Müller 7 | 8 | dnl AS_COMPILER_FLAG(CFLAGS, ACTION-IF-ACCEPTED, [ACTION-IF-NOT-ACCEPTED]) 9 | dnl Tries to compile with the given CFLAGS. 10 | dnl Runs ACTION-IF-ACCEPTED if the compiler can compile with the flags, 11 | dnl and ACTION-IF-NOT-ACCEPTED otherwise. 12 | 13 | AC_DEFUN([AS_COMPILER_FLAG], 14 | [ 15 | AC_MSG_CHECKING([to see if compiler understands $1]) 16 | 17 | save_CFLAGS="$CFLAGS" 18 | CFLAGS="$CFLAGS $1" 19 | 20 | AC_TRY_COMPILE([ ], [], [flag_ok=yes], [flag_ok=no]) 21 | CFLAGS="$save_CFLAGS" 22 | 23 | if test "X$flag_ok" = Xyes ; then 24 | $2 25 | true 26 | else 27 | $3 28 | true 29 | fi 30 | AC_MSG_RESULT([$flag_ok]) 31 | ]) 32 | 33 | dnl AS_CXX_COMPILER_FLAG(CPPFLAGS, ACTION-IF-ACCEPTED, [ACTION-IF-NOT-ACCEPTED]) 34 | dnl Tries to compile with the given CPPFLAGS. 35 | dnl Runs ACTION-IF-ACCEPTED if the compiler can compile with the flags, 36 | dnl and ACTION-IF-NOT-ACCEPTED otherwise. 37 | 38 | AC_DEFUN([AS_CXX_COMPILER_FLAG], 39 | [ 40 | AC_REQUIRE([AC_PROG_CXX]) 41 | 42 | AC_MSG_CHECKING([to see if c++ compiler understands $1]) 43 | 44 | save_CPPFLAGS="$CPPFLAGS" 45 | CPPFLAGS="$CPPFLAGS $1" 46 | 47 | AC_LANG_PUSH(C++) 48 | 49 | AC_TRY_COMPILE([ ], [], [flag_ok=yes], [flag_ok=no]) 50 | CPPFLAGS="$save_CPPFLAGS" 51 | 52 | if test "X$flag_ok" = Xyes ; then 53 | $2 54 | true 55 | else 56 | $3 57 | true 58 | fi 59 | 60 | AC_LANG_POP(C++) 61 | 62 | AC_MSG_RESULT([$flag_ok]) 63 | ]) 64 | 65 | -------------------------------------------------------------------------------- /src/utility.h: -------------------------------------------------------------------------------- 1 | /* 2 | utility.h - Misc helper functions 3 | 4 | Copyright (C) 2012 Paul Betts 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2, or (at your option) 9 | any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software Foundation, 18 | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | #ifndef _UTILITY_H 22 | #define _UTILITY_H 23 | 24 | #ifndef ZMQ_DONTWAIT 25 | # define ZMQ_DONTWAIT ZMQ_NOBLOCK 26 | #endif 27 | #if ZMQ_VERSION_MAJOR == 2 28 | # define zmq_ctx_new() zmq_init(1) 29 | # define zmq_ctx_destroy(ctx) zmq_term(ctx) 30 | # define zmq_msg_send(msg,sock,opt) zmq_send (sock, msg, opt) 31 | # define zmq_msg_recv(msg,sock,opt) zmq_recv (sock, msg, opt) 32 | # define ZMQ_POLL_MSEC 1000 // zmq_poll is usec 33 | #elif ZMQ_VERSION_MAJOR == 3 34 | # define ZMQ_POLL_MSEC 1 // zmq_poll is msec 35 | #endif 36 | 37 | gboolean util_close_socket(void* sock); 38 | char* util_send_reqrep_msg(void* zmq_context, const char* message, const char* address); 39 | void util_zmq_glib_free(void* to_free, void* hint); 40 | char* util_hash_table_as_string(GHashTable* table); 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /common/m4/as-auto-alt.m4: -------------------------------------------------------------------------------- 1 | dnl as-auto-alt.m4 0.0.2 2 | dnl autostars m4 macro for supplying alternate autotools versions to configure 3 | dnl thomas@apestaart.org 4 | dnl 5 | dnl AS_AUTOTOOLS_ALTERNATE() 6 | dnl 7 | dnl supplies --with arguments for autoconf, autoheader, automake, aclocal 8 | 9 | AC_DEFUN([AS_AUTOTOOLS_ALTERNATE], 10 | [ 11 | dnl allow for different autoconf version 12 | AC_ARG_WITH(autoconf, 13 | AC_HELP_STRING([--with-autoconf], 14 | [use a different autoconf for regeneration of Makefiles]), 15 | [ 16 | unset AUTOCONF 17 | AM_MISSING_PROG(AUTOCONF, ${withval}) 18 | AC_MSG_NOTICE([Using $AUTOCONF as autoconf]) 19 | ]) 20 | 21 | dnl allow for different autoheader version 22 | AC_ARG_WITH(autoheader, 23 | AC_HELP_STRING([--with-autoheader], 24 | [use a different autoheader for regeneration of Makefiles]), 25 | [ 26 | unset AUTOHEADER 27 | AM_MISSING_PROG(AUTOHEADER, ${withval}) 28 | AC_MSG_NOTICE([Using $AUTOHEADER as autoheader]) 29 | ]) 30 | 31 | dnl allow for different automake version 32 | AC_ARG_WITH(automake, 33 | AC_HELP_STRING([--with-automake], 34 | [use a different automake for regeneration of Makefiles]), 35 | [ 36 | unset AUTOMAKE 37 | AM_MISSING_PROG(AUTOMAKE, ${withval}) 38 | AC_MSG_NOTICE([Using $AUTOMAKE as automake]) 39 | ]) 40 | 41 | dnl allow for different aclocal version 42 | AC_ARG_WITH(aclocal, 43 | AC_HELP_STRING([--with-aclocal], 44 | [use a different aclocal for regeneration of Makefiles]), 45 | [ 46 | unset ACLOCAL 47 | AM_MISSING_PROG(ACLOCAL, ${withval}) 48 | AC_MSG_NOTICE([Using $ACLOCAL as aclocal]) 49 | ]) 50 | ]) 51 | -------------------------------------------------------------------------------- /src/operations/ping.c: -------------------------------------------------------------------------------- 1 | /* 2 | ping.h - Ping operations 3 | 4 | Copyright (C) 2012 Paul Betts 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2, or (at your option) 9 | any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software Foundation, 18 | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | #include 22 | #include 23 | 24 | #include "parser.h" 25 | #include "ping.h" 26 | #include "utility.h" 27 | #include "op_services.h" 28 | 29 | #include "operations/ping.h" 30 | 31 | static struct message_dispatch_entry ping_messages[] = { 32 | { "PING", op_ping_parse }, 33 | { NULL }, 34 | }; 35 | 36 | void* op_ping_new(void* services) 37 | { 38 | return services; 39 | } 40 | 41 | gboolean op_ping_register(void* ctx, struct message_dispatch_entry** entries) 42 | { 43 | *entries = ping_messages; 44 | return TRUE; 45 | } 46 | 47 | void op_ping_free(void* dontcare) 48 | { 49 | } 50 | 51 | char* op_ping_parse(const char* param, void* ctx) 52 | { 53 | struct op_services* services = (struct op_services*)ctx; 54 | 55 | if (!param) param = "(none)"; 56 | char* ret = g_strdup_printf("OK Message was %s", param); 57 | 58 | pubsub_send_message(services->pub_sub, ret); 59 | return ret; 60 | } 61 | -------------------------------------------------------------------------------- /common/m4/gst-debuginfo.m4: -------------------------------------------------------------------------------- 1 | AC_DEFUN([AG_GST_DEBUGINFO], [ 2 | AC_ARG_ENABLE(debug, 3 | AC_HELP_STRING([--disable-debug],[disable addition of -g debugging info]), 4 | [case "${enableval}" in 5 | yes) USE_DEBUG=yes ;; 6 | no) USE_DEBUG=no ;; 7 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-debug) ;; 8 | esac], 9 | [USE_DEBUG=yes]) dnl Default value 10 | 11 | AC_ARG_ENABLE(DEBUG, 12 | AC_HELP_STRING([--disable-DEBUG],[disables compilation of debugging messages]), 13 | [case "${enableval}" in 14 | yes) ENABLE_DEBUG=yes ;; 15 | no) ENABLE_DEBUG=no ;; 16 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-DEBUG) ;; 17 | esac], 18 | [ENABLE_DEBUG=yes]) dnl Default value 19 | if test x$ENABLE_DEBUG = xyes; then 20 | AC_DEFINE(GST_DEBUG_ENABLED, 1, [Define if DEBUG statements should be compiled in]) 21 | fi 22 | 23 | AC_ARG_ENABLE(INFO, 24 | AC_HELP_STRING([--disable-INFO],[disables compilation of informational messages]), 25 | [case "${enableval}" in 26 | yes) ENABLE_INFO=yes ;; 27 | no) ENABLE_INFO=no ;; 28 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-INFO) ;; 29 | esac], 30 | [ENABLE_INFO=yes]) dnl Default value 31 | if test x$ENABLE_INFO = xyes; then 32 | AC_DEFINE(GST_INFO_ENABLED, 1, [Define if INFO statements should be compiled in]) 33 | fi 34 | 35 | AC_ARG_ENABLE(debug-color, 36 | AC_HELP_STRING([--disable-debug-color],[disables color output of DEBUG and INFO output]), 37 | [case "${enableval}" in 38 | yes) ENABLE_DEBUG_COLOR=yes ;; 39 | no) ENABLE_DEBUG_COLOR=no ;; 40 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-debug-color) ;; 41 | esac], 42 | [ENABLE_DEBUG_COLOR=yes]) dnl Default value 43 | if test "x$ENABLE_DEBUG_COLOR" = xyes; then 44 | AC_DEFINE(GST_DEBUG_COLOR, 1, [Define if debugging messages should be colorized]) 45 | fi 46 | ]) 47 | -------------------------------------------------------------------------------- /common/m4/gst-libxml2.m4: -------------------------------------------------------------------------------- 1 | dnl call this macro with the minimum required version as an argument 2 | dnl this macro sets and AC_SUBSTs XML_CFLAGS and XML_LIBS 3 | dnl it also sets LIBXML_PKG, used for the pkg-config file 4 | 5 | AC_DEFUN([AG_GST_LIBXML2_CHECK], 6 | [ 7 | dnl Minimum required version of libxml2 8 | dnl default to 2.4.9 if not specified 9 | LIBXML2_REQ=ifelse([$1],,2.4.9,[$1]) 10 | AC_SUBST(LIBXML2_REQ) 11 | 12 | dnl check for libxml2 13 | PKG_CHECK_MODULES(XML, libxml-2.0 >= $LIBXML2_REQ, 14 | HAVE_LIBXML2=yes, [ 15 | AC_MSG_RESULT(no) 16 | HAVE_LIBXML2=no 17 | ]) 18 | if test "x$HAVE_LIBXML2" = "xyes"; then 19 | AC_DEFINE(HAVE_LIBXML2, 1, [Define if libxml2 is available]) 20 | else 21 | AC_MSG_ERROR([ 22 | Need libxml2 and development headers/files to build GStreamer. 23 | 24 | You can do without libxml2 if you pass --disable-loadsave to 25 | configure, but that breaks ABI, so don't do that unless you 26 | are building for an embedded setup and know what you are doing. 27 | ]) 28 | fi 29 | dnl this is for the .pc file 30 | LIBXML_PKG=', libxml-2.0' 31 | AC_SUBST(LIBXML_PKG) 32 | AC_SUBST(XML_LIBS) 33 | AC_SUBST(XML_CFLAGS) 34 | 35 | dnl XML_LIBS might pull in -lz without zlib actually being on the system, so 36 | dnl try linking with these LIBS and CFLAGS 37 | ac_save_CFLAGS=$CFLAGS 38 | ac_save_LIBS=$LIBS 39 | CFLAGS="$CFLAGS $XML_CFLAGS" 40 | LIBS="$LIBS $XML_LIBS" 41 | AC_TRY_LINK([ 42 | #include 43 | #include 44 | ],[ 45 | /* function body */ 46 | ], 47 | AC_MSG_NOTICE([Test xml2 program linked]), 48 | AC_MSG_ERROR([Could not link libxml2 test program. Check if you have the necessary dependencies.]) 49 | ) 50 | CFLAGS="$ac_save_CFLAGS" 51 | LIBS="$ac_save_LIBS" 52 | ]) 53 | -------------------------------------------------------------------------------- /src/operations/control.c: -------------------------------------------------------------------------------- 1 | /* 2 | control.c - Control operations 3 | 4 | Copyright (C) 2012 Paul Betts 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2, or (at your option) 9 | any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software Foundation, 18 | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | #include 22 | #include 23 | 24 | #include "parser.h" 25 | #include "ping.h" 26 | #include "utility.h" 27 | #include "op_services.h" 28 | 29 | #include "operations/control.h" 30 | 31 | static struct message_dispatch_entry control_messages[] = { 32 | { "PUBSUB", op_pubsub_parse }, 33 | { "QUIT", op_quit_parse }, 34 | { NULL }, 35 | }; 36 | 37 | void* op_control_new(void* op_services) 38 | { 39 | return op_services; 40 | } 41 | 42 | gboolean op_control_register(void* ctx, struct message_dispatch_entry** entries) 43 | { 44 | *entries = control_messages; 45 | return TRUE; 46 | } 47 | 48 | void op_control_free(void* dontcare) 49 | { 50 | } 51 | 52 | char* op_pubsub_parse(const char* param, void* ctx) 53 | { 54 | struct op_services* services = (struct op_services*)ctx; 55 | return g_strdup_printf("OK %s", pubsub_get_address(services->pub_sub)); 56 | } 57 | 58 | char* op_quit_parse(const char* param, void* ctx) 59 | { 60 | struct op_services* services = (struct op_services*)ctx; 61 | *services->should_quit = TRUE; 62 | 63 | return strdup("OK"); 64 | } 65 | -------------------------------------------------------------------------------- /src/gst_playd.1: -------------------------------------------------------------------------------- 1 | .\" hey, Emacs: -*- nroff -*- 2 | .\" gst_playd is free software; you can redistribute it and/or modify 3 | .\" it under the terms of the GNU General Public License as published by 4 | .\" the Free Software Foundation; either version 2 of the License, or 5 | .\" (at your option) any later version. 6 | .\" 7 | .\" This program is distributed in the hope that it will be useful, 8 | .\" but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | .\" GNU General Public License for more details. 11 | .\" 12 | .\" You should have received a copy of the GNU General Public License 13 | .\" along with this program; see the file COPYING. If not, write to 14 | .\" the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 15 | .\" 16 | .TH GST_PLAYD 1 "September 10, 2012" 17 | .\" Please update the above date whenever this man page is modified. 18 | .\" 19 | .\" Some roff macros, for reference: 20 | .\" .nh disable hyphenation 21 | .\" .hy enable hyphenation 22 | .\" .ad l left justify 23 | .\" .ad b justify to both left and right margins (default) 24 | .\" .nf disable filling 25 | .\" .fi enable filling 26 | .\" .br insert line break 27 | .\" .sp insert n+1 empty lines 28 | .\" for manpage-specific macros, see man(7) 29 | .SH NAME 30 | gst_playd \- GStreamer backend for Play 31 | .SH SYNOPSIS 32 | .B gst_playd 33 | .RI [ options ] 34 | .SH DESCRIPTION 35 | \fBgst_playd\fP washes your windows, mends your fences, mows your lawn... 36 | .PP 37 | It also... 38 | .SH OPTIONS 39 | \fBgst_playd\fP accepts the following options: 40 | .TP 41 | .B -v, --verbose 42 | Print more information. 43 | .TP 44 | .B \-h, \-\-help 45 | Show summary of options. 46 | .TP 47 | .B \-V, \-\-version 48 | Show version of program. 49 | .\" .SH "SEE ALSO" 50 | .\" .BR foo (1), 51 | .\" .BR bar (1). 52 | .SH AUTHOR 53 | Paul Betts . 54 | -------------------------------------------------------------------------------- /common/m4/gst-parser.m4: -------------------------------------------------------------------------------- 1 | AC_DEFUN([AG_GST_BISON_CHECK], 2 | [ 3 | dnl FIXME: check if AC_PROG_YACC is suitable here 4 | dnl FIXME: make precious 5 | AC_PATH_PROG(BISON_PATH, bison, no) 6 | if test x$BISON_PATH = xno; then 7 | AC_MSG_ERROR(Could not find bison) 8 | fi 9 | 10 | dnl check bison version 11 | dnl we need version >= 1.875 for the reentrancy support 12 | dnl in the parser. 13 | dnl First lines observed: 'bison (GNU Bison) 2.3' or 'GNU Bison version 1.28' 14 | bison_min_version=1.875 15 | bison_version=`$BISON_PATH --version | head -n 1 | sed 's/^[[^0-9]]*//' | sed 's/[[^0-9]]*$//' | cut -d' ' -f1` 16 | AC_MSG_CHECKING([bison version $bison_version >= $bison_min_version]) 17 | 18 | if perl -we "exit ((v$bison_version ge v$bison_min_version) ? 0 : 1)"; then 19 | AC_MSG_RESULT([yes]) 20 | else 21 | AC_MSG_ERROR([no]) 22 | fi 23 | ]) 24 | 25 | AC_DEFUN([AG_GST_FLEX_CHECK], 26 | [ 27 | dnl we require flex for building the parser 28 | AC_PATH_PROG(FLEX_PATH, flex, no) 29 | if test x$FLEX_PATH = xno; then 30 | AC_MSG_ERROR(Could not find flex) 31 | fi 32 | 33 | dnl check flex version 34 | dnl we need version >= 2.5.31 for the reentrancy support 35 | dnl in the parser. 36 | flex_min_version=2.5.31 37 | flex_version=`$FLEX_PATH --version | head -n 1 | sed 's/^.* //' | sed 's/[[a-zA-Z]]*$//' | cut -d' ' -f1` 38 | AC_MSG_CHECKING([flex version $flex_version >= $flex_min_version]) 39 | if perl -w < \$min_version_major) || 43 | ((\$flex_version_major == \$min_version_major) && 44 | (\$flex_version_minor > \$min_version_minor)) || 45 | ((\$flex_version_major == \$min_version_major) && 46 | (\$flex_version_minor == \$min_version_minor) && 47 | (\$flex_version_micro >= \$min_version_micro))) 48 | ? 0 : 1); 49 | EOF 50 | then 51 | AC_MSG_RESULT(yes) 52 | else 53 | AC_MSG_ERROR([no]) 54 | fi 55 | ]) 56 | -------------------------------------------------------------------------------- /common/m4/as-docbook.m4: -------------------------------------------------------------------------------- 1 | dnl AS_DOCBOOK([, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) 2 | dnl checks if xsltproc can build docbook documentation 3 | dnl (which is possible if the catalog is set up properly 4 | dnl I also tried checking for a specific version and type of docbook 5 | dnl but xsltproc seemed to happily run anyway, so we can't check for that 6 | dnl and version 7 | dnl this macro takes inspiration from 8 | dnl http://www.movement.uklinux.net/docs/docbook-autotools/configure.html 9 | AC_DEFUN([AS_DOCBOOK], 10 | [ 11 | XSLTPROC_FLAGS=--nonet 12 | DOCBOOK_ROOT= 13 | TYPE_LC=xml 14 | TYPE_UC=XML 15 | DOCBOOK_VERSION=4.1.2 16 | 17 | if test ! -f /etc/xml/catalog; then 18 | for i in /usr/share/sgml/docbook/stylesheet/xsl/nwalsh /usr/share/sgml/docbook/xsl-stylesheets/ /usr/local/share/xsl/docbook ; 19 | do 20 | if test -d "$i"; then 21 | DOCBOOK_ROOT=$i 22 | fi 23 | done 24 | else 25 | XML_CATALOG=/etc/xml/catalog 26 | CAT_ENTRY_START='' 28 | fi 29 | 30 | dnl We need xsltproc to process the test 31 | AC_CHECK_PROG(XSLTPROC,xsltproc,xsltproc,) 32 | XSLTPROC_WORKS=no 33 | if test -n "$XSLTPROC"; then 34 | AC_MSG_CHECKING([whether xsltproc docbook processing works]) 35 | 36 | if test -n "$XML_CATALOG"; then 37 | DB_FILE="http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl" 38 | else 39 | DB_FILE="$DOCBOOK_ROOT/xhtml/docbook.xsl" 40 | fi 41 | $XSLTPROC $XSLTPROC_FLAGS $DB_FILE >/dev/null 2>&1 << END 42 | 43 | 44 | 45 | 46 | END 47 | if test "$?" = 0; then 48 | XSLTPROC_WORKS=yes 49 | fi 50 | AC_MSG_RESULT($XSLTPROC_WORKS) 51 | fi 52 | 53 | if test "x$XSLTPROC_WORKS" = "xyes"; then 54 | dnl execute ACTION-IF-FOUND 55 | ifelse([$1], , :, [$1]) 56 | else 57 | dnl execute ACTION-IF-NOT-FOUND 58 | ifelse([$2], , :, [$2]) 59 | fi 60 | 61 | AC_SUBST(XML_CATALOG) 62 | AC_SUBST(XSLTPROC_FLAGS) 63 | AC_SUBST(DOCBOOK_ROOT) 64 | AC_SUBST(CAT_ENTRY_START) 65 | AC_SUBST(CAT_ENTRY_END) 66 | ]) 67 | -------------------------------------------------------------------------------- /common/m4/gst-function.m4: -------------------------------------------------------------------------------- 1 | dnl 2 | dnl Check for compiler mechanism to show functions in debugging 3 | dnl copied from an Ali patch floating on the internet 4 | dnl 5 | AC_DEFUN([AG_GST_CHECK_FUNCTION],[ 6 | dnl #1: __PRETTY_FUNCTION__ 7 | AC_MSG_CHECKING(whether $CC implements __PRETTY_FUNCTION__) 8 | AC_CACHE_VAL(gst_cv_have_pretty_function,[ 9 | AC_TRY_LINK([#include ], 10 | [printf("%s", __PRETTY_FUNCTION__);], 11 | gst_cv_have_pretty_function=yes, 12 | gst_cv_have_pretty_function=no) 13 | ]) 14 | AC_MSG_RESULT($gst_cv_have_pretty_function) 15 | if test "$gst_cv_have_pretty_function" = yes; then 16 | AC_DEFINE(HAVE_PRETTY_FUNCTION, 1, 17 | [defined if the compiler implements __PRETTY_FUNCTION__]) 18 | fi 19 | 20 | dnl #2: __FUNCTION__ 21 | AC_MSG_CHECKING(whether $CC implements __FUNCTION__) 22 | AC_CACHE_VAL(gst_cv_have_function,[ 23 | AC_TRY_LINK([#include ], 24 | [printf("%s", __FUNCTION__);], 25 | gst_cv_have_function=yes, 26 | gst_cv_have_function=no) 27 | ]) 28 | AC_MSG_RESULT($gst_cv_have_function) 29 | if test "$gst_cv_have_function" = yes; then 30 | AC_DEFINE(HAVE_FUNCTION, 1, 31 | [defined if the compiler implements __FUNCTION__]) 32 | fi 33 | 34 | dnl #3: __func__ 35 | AC_MSG_CHECKING(whether $CC implements __func__) 36 | AC_CACHE_VAL(gst_cv_have_func,[ 37 | AC_TRY_LINK([#include ], 38 | [printf("%s", __func__);], 39 | gst_cv_have_func=yes, 40 | gst_cv_have_func=no) 41 | ]) 42 | AC_MSG_RESULT($gst_cv_have_func) 43 | if test "$gst_cv_have_func" = yes; then 44 | AC_DEFINE(HAVE_FUNC, 1, 45 | [defined if the compiler implements __func__]) 46 | fi 47 | 48 | dnl now define FUNCTION to whatever works, and fallback to "" 49 | if test "$gst_cv_have_pretty_function" = yes; then 50 | function=__PRETTY_FUNCTION__ 51 | else 52 | if test "$gst_cv_have_function" = yes; then 53 | function=__FUNCTION__ 54 | else 55 | if test "$gst_cv_have_func" = yes; then 56 | function=__func__ 57 | else 58 | function=\"\" 59 | fi 60 | fi 61 | fi 62 | AC_DEFINE_UNQUOTED(GST_FUNCTION, $function, [macro to use to show function name]) 63 | ]) 64 | -------------------------------------------------------------------------------- /common/m4/orc.m4: -------------------------------------------------------------------------------- 1 | dnl pkg-config-based checks for Orc 2 | 3 | dnl specific: 4 | dnl ORC_CHECK([REQUIRED_VERSION]) 5 | 6 | AC_DEFUN([ORC_CHECK], 7 | [ 8 | ORC_REQ=ifelse([$1], , "0.4.6", [$1]) 9 | 10 | AC_ARG_ENABLE(orc, 11 | AC_HELP_STRING([--enable-orc],[use Orc if installed]), 12 | [case "${enableval}" in 13 | auto) enable_orc=auto ;; 14 | yes) enable_orc=yes ;; 15 | no) enable_orc=no ;; 16 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-orc) ;; 17 | esac 18 | ], 19 | [enable_orc=auto]) dnl Default value 20 | 21 | if test "x$enable_orc" != "xno" ; then 22 | PKG_CHECK_MODULES(ORC, orc-0.4 >= $ORC_REQ, [ 23 | AC_DEFINE(HAVE_ORC, 1, [Use Orc]) 24 | HAVE_ORC=yes 25 | if test "x$ORCC" = "x" ; then 26 | AC_MSG_CHECKING(for usable orcc) 27 | ORCC=`$PKG_CONFIG --variable=orcc orc-0.4` 28 | dnl check whether the orcc found by pkg-config can be run from the build environment 29 | dnl if this is not the case (e.g. when cross-compiling) fall back to orcc from PATH 30 | AS_IF([$ORCC --version 1> /dev/null 2> /dev/null], [], [ORCC=`which orcc`]) 31 | AC_MSG_RESULT($ORCC) 32 | fi 33 | AC_SUBST(ORCC) 34 | ORCC_FLAGS="--compat $ORC_REQ" 35 | AC_SUBST(ORCC_FLAGS) 36 | AS_IF([test "x$ORCC" = "x"], [HAVE_ORCC=no], [HAVE_ORCC=yes]) 37 | ], [ 38 | if test "x$enable_orc" = "xyes" ; then 39 | AC_MSG_ERROR([--enable-orc specified, but Orc >= $ORC_REQ not found]) 40 | fi 41 | AC_DEFINE(DISABLE_ORC, 1, [Disable Orc]) 42 | HAVE_ORC=no 43 | HAVE_ORCC=no 44 | ]) 45 | else 46 | AC_DEFINE(DISABLE_ORC, 1, [Disable Orc]) 47 | HAVE_ORC=no 48 | HAVE_ORCC=no 49 | fi 50 | AM_CONDITIONAL(HAVE_ORC, [test "x$HAVE_ORC" = "xyes"]) 51 | AM_CONDITIONAL(HAVE_ORCC, [test "x$HAVE_ORCC" = "xyes"]) 52 | 53 | ])) 54 | 55 | AC_DEFUN([ORC_OUTPUT], 56 | [ 57 | if test "$HAVE_ORC" = yes ; then 58 | printf "configure: *** Orc acceleration enabled.\n" 59 | else 60 | if test "x$enable_orc" = "xno" ; then 61 | printf "configure: *** Orc acceleration disabled by --disable-orc. Slower code paths\n" 62 | printf " will be used.\n" 63 | else 64 | printf "configure: *** Orc acceleration disabled. Requires Orc >= $ORC_REQ, which was\n" 65 | printf " not found. Slower code paths will be used.\n" 66 | fi 67 | fi 68 | printf "\n" 69 | ]) 70 | 71 | -------------------------------------------------------------------------------- /common/m4/as-version.m4: -------------------------------------------------------------------------------- 1 | dnl as-version.m4 0.2.0 2 | 3 | dnl autostars m4 macro for versioning 4 | 5 | dnl Thomas Vander Stichele 6 | 7 | dnl $Id: as-version.m4,v 1.15 2006/04/01 09:40:24 thomasvs Exp $ 8 | 9 | dnl AS_VERSION 10 | 11 | dnl example 12 | dnl AS_VERSION 13 | 14 | dnl this macro 15 | dnl - AC_SUBST's PACKAGE_VERSION_MAJOR, _MINOR, _MICRO 16 | dnl - AC_SUBST's PACKAGE_VERSION_RELEASE, 17 | dnl which can be used for rpm release fields 18 | dnl - doesn't call AM_INIT_AUTOMAKE anymore because it prevents 19 | dnl maintainer mode from running correctly 20 | dnl 21 | dnl don't forget to put #undef PACKAGE_VERSION_RELEASE in acconfig.h 22 | dnl if you use acconfig.h 23 | 24 | AC_DEFUN([AS_VERSION], 25 | [ 26 | PACKAGE_VERSION_MAJOR=$(echo AC_PACKAGE_VERSION | cut -d'.' -f1) 27 | PACKAGE_VERSION_MINOR=$(echo AC_PACKAGE_VERSION | cut -d'.' -f2) 28 | PACKAGE_VERSION_MICRO=$(echo AC_PACKAGE_VERSION | cut -d'.' -f3) 29 | 30 | AC_SUBST(PACKAGE_VERSION_MAJOR) 31 | AC_SUBST(PACKAGE_VERSION_MINOR) 32 | AC_SUBST(PACKAGE_VERSION_MICRO) 33 | ]) 34 | 35 | dnl AS_NANO(ACTION-IF-NANO-NON-NULL, [ACTION-IF-NANO-NULL]) 36 | 37 | dnl requires AC_INIT to be called before 38 | dnl For projects using a fourth or nano number in your versioning to indicate 39 | dnl development or prerelease snapshots, this macro allows the build to be 40 | dnl set up differently accordingly. 41 | 42 | dnl this macro: 43 | dnl - parses AC_PACKAGE_VERSION, set by AC_INIT, and extracts the nano number 44 | dnl - sets the variable PACKAGE_VERSION_NANO 45 | dnl - sets the variable PACKAGE_VERSION_RELEASE, which can be used 46 | dnl for rpm release fields 47 | dnl - executes ACTION-IF-NANO-NON-NULL or ACTION-IF-NANO-NULL 48 | 49 | dnl example: 50 | dnl AS_NANO(RELEASE="yes", RELEASE="no") 51 | 52 | AC_DEFUN([AS_NANO], 53 | [ 54 | AC_MSG_CHECKING(nano version) 55 | 56 | NANO=$(echo AC_PACKAGE_VERSION | cut -d'.' -f4) 57 | 58 | if test x"$NANO" = x || test "x$NANO" = "x0" ; then 59 | AC_MSG_RESULT([0 (release)]) 60 | NANO=0 61 | PACKAGE_VERSION_RELEASE=1 62 | ifelse([$1], , :, [$1]) 63 | else 64 | AC_MSG_RESULT($NANO) 65 | PACKAGE_VERSION_RELEASE=0.`date +%Y%m%d.%H%M%S` 66 | if test "x$NANO" != "x1" ; then 67 | ifelse([$1], , :, [$1]) 68 | else 69 | ifelse([$2], , :, [$2]) 70 | fi 71 | fi 72 | PACKAGE_VERSION_NANO=$NANO 73 | AC_SUBST(PACKAGE_VERSION_NANO) 74 | AC_SUBST(PACKAGE_VERSION_RELEASE) 75 | ]) 76 | -------------------------------------------------------------------------------- /common/m4/gst-platform.m4: -------------------------------------------------------------------------------- 1 | dnl AG_GST_PLATFORM 2 | dnl Check for platform specific features and define some variables 3 | dnl 4 | dnl GST_EXTRA_MODULE_SUFFIX: contains a platform specific 5 | dnl extra module suffix additional to G_MODULE_SUFFIX 6 | dnl 7 | dnl HAVE_OSX: Defined if compiling for OS X 8 | dnl 9 | dnl GST_HAVE_UNSAFE_FORK: Defined if fork is unsafe (Windows) 10 | dnl 11 | dnl HAVE_WIN32: Defined if compiling on Win32 12 | dnl 13 | 14 | AC_DEFUN([AG_GST_PLATFORM], 15 | [ 16 | AC_REQUIRE([AC_CANONICAL_HOST]) 17 | 18 | case $host_os in 19 | rhapsody*) 20 | AC_DEFINE_UNQUOTED(GST_EXTRA_MODULE_SUFFIX, [".dylib"], [Extra platform specific plugin suffix]) 21 | ;; 22 | darwin*) 23 | AC_DEFINE_UNQUOTED(GST_EXTRA_MODULE_SUFFIX, [".dylib"], [Extra platform specific plugin suffix]) 24 | AC_DEFINE_UNQUOTED(HAVE_OSX, 1, [Defined if compiling for OSX]) 25 | ;; 26 | cygwin*) 27 | AC_DEFINE_UNQUOTED(GST_HAVE_UNSAFE_FORK, 1, [Defined when registry scanning through fork is unsafe]) 28 | ;; 29 | mingw* | msvc* | mks*) 30 | dnl HAVE_WIN32 currently means "disable POSIXisms". 31 | AC_DEFINE_UNQUOTED(HAVE_WIN32, 1, [Defined if compiling for Windows]) 32 | 33 | dnl define __MSVCRT_VERSION__ version if not set already by the 34 | dnl compiler (ie. mostly for mingw). This is needed for things like 35 | dnl __stat64 to be available. If set by the compiler, ensure it's 36 | dnl new enough - we need at least WinXP SP2. 37 | AC_TRY_COMPILE([ ], [ return __MSVCRT_VERSION__; ], [ 38 | AC_TRY_COMPILE([ ], [ 39 | #if __MSVCRT_VERSION__ < 0x0601 40 | #error "MSVCRT too old" 41 | #endif 42 | ], [ 43 | AC_MSG_NOTICE([MSVCRT version looks ok]) 44 | ], [ 45 | AC_MSG_ERROR([MSVCRT version too old, need at least WinXP SP2]) 46 | ]) 47 | ], [ 48 | AC_MSG_NOTICE([Setting MSVCRT version to 0x0601]) 49 | AC_DEFINE_UNQUOTED(__MSVCRT_VERSION__, 0x0601, [We need at least WinXP SP2 for __stat64]) 50 | ]) 51 | ;; 52 | *) 53 | ;; 54 | esac 55 | ]) 56 | 57 | AC_DEFUN([AG_GST_LIBTOOL_PREPARE], 58 | [ 59 | dnl Persuade libtool to also link (-l) a 'pure' (DirectX) static lib, 60 | dnl i.e. as opposed to only import lib with dll counterpart. 61 | dnl Needs to be tweaked before libtool's checks. 62 | case $host_os in 63 | cygwin* | mingw*) 64 | lt_cv_deplibs_check_method=pass_all 65 | ;; 66 | esac 67 | ]) -------------------------------------------------------------------------------- /src/pubsub.c: -------------------------------------------------------------------------------- 1 | /* 2 | pubsub.c - API for sending messages over the ZeroMQ PUB socket 3 | 4 | Copyright (C) 2012 Paul Betts 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2, or (at your option) 9 | any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software Foundation, 18 | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #include "pubsub.h" 27 | #include "utility.h" 28 | 29 | struct pubsub_ctx { 30 | void* sock; 31 | char* addr; 32 | }; 33 | 34 | static char* pubsub_address_from_port(const char* address, int port) 35 | { 36 | return g_strdup_printf("tcp://%s:%d", address, port + 10001); 37 | } 38 | 39 | struct pubsub_ctx* pubsub_new(void* zmq_context, int icecast_port) 40 | { 41 | struct pubsub_ctx* ret = g_new0(struct pubsub_ctx, 1); 42 | int linger = 15*1000; 43 | 44 | ret->sock = zmq_socket(zmq_context, ZMQ_PUB); 45 | zmq_setsockopt(ret->sock, ZMQ_LINGER, &linger, sizeof(int)); 46 | 47 | ret->addr = pubsub_address_from_port("127.0.0.1", icecast_port); 48 | g_warning("Binding %s to 0x%p", ret->addr, ret->sock); 49 | if (zmq_bind(ret->sock, ret->addr) == -1) { 50 | g_warning("Failed to start server on address %s: %s", ret->addr, zmq_strerror(zmq_errno())); 51 | 52 | pubsub_free(ret); 53 | ret = NULL; 54 | } 55 | 56 | return ret; 57 | } 58 | 59 | void pubsub_free(struct pubsub_ctx* ctx) 60 | { 61 | util_close_socket(ctx->sock); 62 | g_free(ctx->addr); 63 | g_free(ctx); 64 | } 65 | 66 | const char* pubsub_get_address(struct pubsub_ctx* ctx) 67 | { 68 | return ctx->addr; 69 | } 70 | 71 | gboolean pubsub_send_message(struct pubsub_ctx* ctx, const char* message) 72 | { 73 | zmq_msg_t msg; 74 | zmq_msg_init_data(&msg, (void*) strdup(message), sizeof(char) * strlen(message), util_zmq_glib_free, NULL); 75 | g_warning("Sending %s to 0x%p", message, ctx->sock); 76 | zmq_msg_send(&msg, ctx->sock, 0); 77 | zmq_msg_close(&msg); 78 | 79 | return TRUE; 80 | } 81 | -------------------------------------------------------------------------------- /common/m4/gst-glib2.m4: -------------------------------------------------------------------------------- 1 | dnl check for a minimum version of GLib 2 | 3 | dnl AG_GST_GLIB_CHECK([minimum-version-required]) 4 | 5 | AC_DEFUN([AG_GST_GLIB_CHECK], 6 | [ 7 | AC_REQUIRE([AS_NANO]) 8 | 9 | dnl Minimum required version of GLib 10 | GLIB_REQ=[$1] 11 | if test "x$GLIB_REQ" = "x" 12 | then 13 | AC_MSG_ERROR([Please specify a required version for GLib 2.0]) 14 | fi 15 | AC_SUBST(GLIB_REQ) 16 | 17 | dnl Check for glib with everything 18 | AG_GST_PKG_CHECK_MODULES(GLIB, 19 | glib-2.0 >= $GLIB_REQ gobject-2.0 gthread-2.0 gmodule-no-export-2.0) 20 | 21 | if test "x$HAVE_GLIB" = "xno"; then 22 | AC_MSG_ERROR([This package requires GLib >= $GLIB_REQ to compile.]) 23 | fi 24 | 25 | dnl Add define to tell GLib that threading is always enabled within GStreamer 26 | dnl code (optimisation, bypasses checks if the threading system is enabled 27 | dnl when using threading primitives) 28 | GLIB_EXTRA_CFLAGS="$GLIB_EXTRA_CFLAGS -DG_THREADS_MANDATORY" 29 | 30 | dnl Define G_DISABLE_DEPRECATED for GIT versions 31 | if test "x$PACKAGE_VERSION_NANO" = "x1"; then 32 | GLIB_EXTRA_CFLAGS="$GLIB_EXTRA_CFLAGS -DG_DISABLE_DEPRECATED" 33 | fi 34 | 35 | AC_ARG_ENABLE(gobject-cast-checks, 36 | AS_HELP_STRING([--enable-gobject-cast-checks[=@<:@no/auto/yes@:>@]], 37 | [Enable GObject cast checks]),, 38 | [enable_gobject_cast_checks=auto]) 39 | 40 | if test "x$enable_gobject_cast_checks" = "xauto"; then 41 | dnl For releases, turn off the cast checks 42 | if test "x$PACKAGE_VERSION_NANO" = "x1"; then 43 | enable_gobject_cast_checks=yes 44 | else 45 | enable_gobject_cast_checks=no 46 | fi 47 | fi 48 | 49 | if test "x$enable_gobject_cast_checks" = "xno"; then 50 | GLIB_EXTRA_CFLAGS="$GLIB_EXTRA_CFLAGS -DG_DISABLE_CAST_CHECKS" 51 | fi 52 | 53 | AC_ARG_ENABLE(glib-asserts, 54 | AS_HELP_STRING([--enable-glib-asserts[=@<:@no/auto/yes@:>@]], 55 | [Enable GLib assertion]),, 56 | [enable_glib_assertions=auto]) 57 | 58 | if test "x$enable_glib_assertions" = "xauto"; then 59 | dnl For releases, turn off the assertions 60 | if test "x$PACKAGE_VERSION_NANO" = "x1"; then 61 | enable_glib_assertions=yes 62 | else 63 | enable_glib_assertions=no 64 | fi 65 | fi 66 | 67 | if test "x$enable_glib_assertions" = "xno"; then 68 | GLIB_EXTRA_CFLAGS="$GLIB_EXTRA_CFLAGS -DG_DISABLE_ASSERT" 69 | fi 70 | 71 | dnl for the poor souls who for example have glib in /usr/local 72 | AS_SCRUB_INCLUDE(GLIB_CFLAGS) 73 | 74 | AC_SUBST(GLIB_EXTRA_CFLAGS) 75 | ]) 76 | -------------------------------------------------------------------------------- /common/m4/gst-x11.m4: -------------------------------------------------------------------------------- 1 | dnl macros for X-related detections 2 | dnl AC_SUBST's HAVE_X, X_CFLAGS, X_LIBS 3 | AC_DEFUN([AG_GST_CHECK_X], 4 | [ 5 | AC_PATH_XTRA 6 | ac_cflags_save="$CFLAGS" 7 | ac_cppflags_save="$CPPFLAGS" 8 | CFLAGS="$CFLAGS $X_CFLAGS" 9 | CPPFLAGS="$CPPFLAGS $X_CFLAGS" 10 | 11 | dnl now try to find the HEADER 12 | AC_CHECK_HEADER(X11/Xlib.h, HAVE_X="yes", HAVE_X="no") 13 | 14 | if test "x$HAVE_X" = "xno" 15 | then 16 | AC_MSG_NOTICE([cannot find X11 development files]) 17 | else 18 | dnl this is much more than we want 19 | X_LIBS="$X_LIBS $X_PRE_LIBS $X_EXTRA_LIBS" 20 | dnl AC_PATH_XTRA only defines the path needed to find the X libs, 21 | dnl it does not add the libs; therefore we add them here 22 | X_LIBS="$X_LIBS -lX11" 23 | AC_SUBST(X_CFLAGS) 24 | AC_SUBST(X_LIBS) 25 | fi 26 | AC_SUBST(HAVE_X) 27 | 28 | CFLAGS="$ac_cflags_save" 29 | CPPFLAGS="$ac_cppflags_save" 30 | ]) 31 | 32 | dnl *** XVideo *** 33 | dnl Look for the PIC library first, Debian requires it. 34 | dnl Check debian-devel archives for gory details. 35 | dnl 20020110: 36 | dnl At the moment XFree86 doesn't distribute shared libXv due 37 | dnl to unstable API. On many platforms you CAN NOT link a shared 38 | dnl lib to a static non-PIC lib. This is what the xvideo GStreamer 39 | dnl plug-in wants to do. So Debian distributes a PIC compiled 40 | dnl version of the static lib for plug-ins to link to when it is 41 | dnl inappropriate to link the main application to libXv directly. 42 | dnl FIXME: add check if this platform can support linking to a 43 | dnl non-PIC libXv, if not then don not use Xv. 44 | dnl FIXME: perhaps warn user if they have a shared libXv since 45 | dnl this is an error until XFree86 starts shipping one 46 | AC_DEFUN([AG_GST_CHECK_XV], 47 | [ 48 | if test x$HAVE_X = xyes; then 49 | AC_CHECK_LIB(Xv_pic, XvQueryExtension, 50 | HAVE_XVIDEO="yes", HAVE_XVIDEO="no", 51 | $X_LIBS -lXext) 52 | 53 | if test x$HAVE_XVIDEO = xyes; then 54 | XVIDEO_LIBS="-lXv_pic -lXext" 55 | AC_SUBST(XVIDEO_LIBS) 56 | else 57 | dnl try again using something else if we didn't find it first 58 | if test x$HAVE_XVIDEO = xno; then 59 | AC_CHECK_LIB(Xv, XvQueryExtension, 60 | HAVE_XVIDEO="yes", HAVE_XVIDEO="no", 61 | $X_LIBS -lXext) 62 | 63 | if test x$HAVE_XVIDEO = xyes; then 64 | XVIDEO_LIBS="-lXv -lXext" 65 | AC_SUBST(XVIDEO_LIBS) 66 | fi 67 | fi 68 | fi 69 | fi 70 | ]) 71 | -------------------------------------------------------------------------------- /src/gst-util.c: -------------------------------------------------------------------------------- 1 | /* 2 | gst-util.c - GStreamer helper functions 3 | 4 | Copyright (C) 2012 Paul Betts 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2, or (at your option) 9 | any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software Foundation, 18 | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | #include "gst-util.h" 26 | #include "uuencode.h" 27 | 28 | static void tag_to_hash_table(const GstTagList * list, const gchar * tag, gpointer user_data) 29 | { 30 | char* value; 31 | int num = gst_tag_list_get_tag_size (list, tag); 32 | GHashTable* ret = (GHashTable*)user_data; 33 | 34 | for (int i = 0; i < num; ++i) { 35 | const GValue *val = gst_tag_list_get_value_index (list, tag, i); 36 | 37 | if (G_VALUE_HOLDS_STRING (val)) { 38 | value = strdup(g_value_get_string(val)); 39 | } else if (G_VALUE_HOLDS_UINT (val)) { 40 | value = g_strdup_printf("%u", g_value_get_uint(val)); 41 | } else if (G_VALUE_HOLDS_UINT64(val)) { 42 | value = g_strdup_printf("%lu64", g_value_get_uint64(val)); 43 | } else if (G_VALUE_HOLDS_DOUBLE (val)) { 44 | value = g_strdup_printf("%f", g_value_get_double(val)); 45 | } else if (G_VALUE_HOLDS_BOOLEAN (val)) { 46 | value = strdup(g_value_get_boolean (val) ? "true" : "false"); 47 | } else if (GST_VALUE_HOLDS_BUFFER (val)) { 48 | GstBuffer* buf = gst_value_get_buffer(val); 49 | 50 | int size = uuencode_get_length(GST_BUFFER_SIZE(buf)); 51 | value = g_new0 (char, size + 1); 52 | uuencode(value, GST_BUFFER_DATA(buf), GST_BUFFER_SIZE(buf), uuenc_tbl_base64); 53 | } else if (GST_VALUE_HOLDS_DATE (val)) { 54 | value = g_new0(char, sizeof(char) * 128); 55 | g_date_strftime(value, 50, "%F", gst_value_get_date (val)); 56 | /*} else if (GST_VALUE_HOLDS_DATE_TIME (val)) { 57 | value = gst_date_time_to_iso8601_string((GstDateTime*)val); */ 58 | } else { 59 | value = g_strdup_printf ("tag of type ’%s’", G_VALUE_TYPE_NAME (val)); 60 | } 61 | 62 | g_warning("Found tag: %s", tag); 63 | g_hash_table_insert(ret, g_strdup_printf("%s_%d", tag, i), value); 64 | } 65 | } 66 | 67 | void gsu_tags_to_hash_table(const GstTagList* tags, GHashTable* table) 68 | { 69 | gst_tag_list_foreach(tags, tag_to_hash_table, table); 70 | } 71 | -------------------------------------------------------------------------------- /common/m4/as-libtool-tags.m4: -------------------------------------------------------------------------------- 1 | dnl as-libtool-tags.m4 0.1.4 2 | 3 | dnl autostars m4 macro for selecting libtool "tags" (languages) 4 | 5 | dnl Andy Wingo does not claim credit for this macro 6 | dnl backported from libtool 1.6 by Paolo Bonzini 7 | dnl see http://lists.gnu.org/archive/html/libtool/2003-12/msg00007.html 8 | 9 | dnl $Id$ 10 | 11 | dnl AS_LIBTOOL_TAGS([tags...]) 12 | 13 | dnl example 14 | dnl AS_LIBTOOL_TAGS([]) for only C (no fortran, etc) 15 | 16 | dnl When AC_LIBTOOL_TAGS is used, I redefine _LT_AC_TAGCONFIG 17 | dnl to be more similar to the libtool 1.6 implementation, which 18 | dnl uses an m4 loop and m4 case instead of a shell loop. This 19 | dnl way the CXX/GCJ/F77/RC tests are not always expanded. 20 | 21 | dnl AS_LIBTOOL_TAGS 22 | dnl --------------- 23 | dnl tags to enable 24 | AC_DEFUN([AS_LIBTOOL_TAGS], 25 | [m4_define([_LT_TAGS],[$1]) 26 | m4_define([_LT_AC_TAGCONFIG], [ 27 | # redefined LT AC TAGCONFIG 28 | if test -f "$ltmain"; then 29 | if test ! -f "${ofile}"; then 30 | AC_MSG_WARN([output file `$ofile' does not exist]) 31 | fi 32 | 33 | if test -z "$LTCC"; then 34 | eval "`$SHELL ${ofile} --config | grep '^LTCC='`" 35 | if test -z "$LTCC"; then 36 | AC_MSG_WARN([output file `$ofile' does not look like a libtool script]) 37 | else 38 | AC_MSG_WARN([using `LTCC=$LTCC', extracted from `$ofile']) 39 | fi 40 | fi 41 | 42 | AC_FOREACH([_LT_TAG], _LT_TAGS, 43 | echo THOMAS: tag _LT_TAG 44 | [m4_case(_LT_TAG, 45 | [CXX], [ 46 | if test -n "$CXX" && test "X$CXX" != "Xno"; then 47 | echo "THOMAS: YAY CXX" 48 | AC_LIBTOOL_LANG_CXX_CONFIG 49 | available_tags="$available_tags _LT_TAG" 50 | fi], 51 | [F77], [ 52 | if test -n "$F77" && test "X$F77" != "Xno"; then 53 | AC_LIBTOOL_LANG_F77_CONFIG 54 | available_tags="$available_tags _LT_TAG" 55 | fi], 56 | [GCJ], [ 57 | if test -n "$GCJ" && test "X$GCJ" != "Xno"; then 58 | AC_LIBTOOL_LANG_GCJ_CONFIG 59 | available_tags="$available_tags _LT_TAG" 60 | fi], 61 | [RC], [ 62 | if test -n "$RC" && test "X$RC" != "Xno"; then 63 | AC_LIBTOOL_LANG_RC_CONFIG 64 | available_tags="$available_tags _LT_TAG" 65 | fi], 66 | [m4_errprintn(m4_location[: error: invalid tag name: ]"_LT_TAG") 67 | m4_exit(1)]) 68 | ]) 69 | echo THOMAS: available tags: $available_tags 70 | fi 71 | # Now substitute the updated list of available tags. 72 | if eval "sed -e 's/^available_tags=.*\$/available_tags=\"$available_tags\"/' \"$ofile\" > \"${ofile}T\""; then 73 | mv "${ofile}T" "$ofile" 74 | chmod +x "$ofile" 75 | AC_MSG_NOTICE([updated available libtool tags with $available_tags.]) 76 | else 77 | rm -f "${ofile}T" 78 | AC_MSG_ERROR([unable to update list of available tagged configurations.]) 79 | 80 | fi 81 | 82 | ])dnl _LT_AC_TAG_CONFIG 83 | ]) 84 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## What Is This? 2 | 3 | `gst-playd` is a really simple cross-platform service whose sole job is to 4 | play back media files to a list of targets (IceCast and AirPlay), using the 5 | GStreamer API. 6 | 7 | It's a single exe, it's simple to manage and configure, and you can run as 8 | many as you want in parallel for multiple audio streams. 9 | 10 | ## What *Doesn't* It Do 11 | 12 | gst-playd knows nothing about library management. Its goal is to replace 13 | Airfoil and Nicecast in the current Play implementation (Play v2) 14 | 15 | ## But can you explain it in ASCII art? 16 | 17 | Sure. 18 | 19 | ``` 20 | +------------+ 21 | | | 22 | | source1 |+ +----------------+ 23 | | || | | 24 | +------------+| +------------------+ +-+| icecast | 25 | +---------+ | +---------------+ | | | 26 | +------------+ | | | +----+ +----------------+ 27 | | | | | | | 28 | | source2 +----------+ mixer +----> splitter | +----------------+ 29 | | | | | | |+ | | 30 | +------------+ +----+ | | |+------+ airport1 | 31 | | +------------------+ +-------------+-+ | | 32 | ... | | +----------------+ 33 | | | 34 | +------------+-----+ | +----------------+ 35 | | | | | | 36 | | source_n + +---------+ airport2 | 37 | | | | | 38 | +------------+ +----------------+ 39 | ``` 40 | 41 | ## How does it work? 42 | 43 | gst-playd will start up a REQ/REP ZeroMQ socket on a specified port - meaning, 44 | it will boot up and wait for a request to come in. The requests are really 45 | simple string-based, Redis-style commands, something like: 46 | 47 | ``` 48 | PLAY file:///home/foo/bar.mp3 49 | STOP 50 | ``` 51 | 52 | And the responses will be equivalently structured: 53 | 54 | ``` 55 | OK 56 | ERROR IceCast isn't installed. Install it via 'brew install icecast' 57 | ``` 58 | 59 | Internally, `gst-playd` will manage the GStreamer Pipeline as well as handle 60 | starting up and configuring the Icecast server (including tying the lifetime 61 | of the icecast process to gst-playd, so if gst-playd dies, it kills the 62 | associated icecasts on its way out) 63 | 64 | ## How do I build this? 65 | 66 | On OS X: 67 | 68 | ```sh 69 | brew install zeromq --head 70 | brew install gst-plugins-good gst-plugins-ugly gst-ffmpeg ## Get some coffee. 71 | brew link libxml2 72 | 73 | ./autogen.sh && make 74 | ``` 75 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Run this to generate all the initial makefiles, etc. 3 | 4 | DIE=0 5 | package=gst_playd 6 | srcfile=src/gst_playd.c 7 | 8 | # Make sure we have common 9 | if test ! -f common/gst-autogen.sh; 10 | then 11 | echo "+ Setting up common submodule" 12 | git submodule init 13 | fi 14 | git submodule update 15 | 16 | # source helper functions 17 | if test ! -f common/gst-autogen.sh; 18 | then 19 | echo There is something wrong with your source tree. 20 | echo You are missing common/gst-autogen.sh 21 | exit 1 22 | fi 23 | . common/gst-autogen.sh 24 | 25 | # install pre-commit hook for doing clean commits 26 | if test ! \( -x .git/hooks/pre-commit -a -L .git/hooks/pre-commit \); 27 | then 28 | rm -f .git/hooks/pre-commit 29 | ln -s ../../common/hooks/pre-commit.hook .git/hooks/pre-commit 30 | fi 31 | 32 | 33 | 34 | CONFIGURE_DEF_OPT='--enable-maintainer-mode --enable-failing-tests --enable-poisoning --enable-gtk-doc --enable-docbook' 35 | 36 | autogen_options $@ 37 | 38 | printf "+ check for build tools" 39 | if test ! -z "$NOCHECK"; then echo ": skipped version checks"; else echo; fi 40 | version_check "autoconf" "$AUTOCONF autoconf autoconf270 autoconf269 autoconf268 autoconf267 autoconf266 autoconf265 autoconf264 autoconf263 autoconf262 autoconf261 autoconf260" \ 41 | "ftp://ftp.gnu.org/pub/gnu/autoconf/" 2 60 || DIE=1 42 | version_check "automake" "$AUTOMAKE automake automake-1.11 automake-1.10" \ 43 | "ftp://ftp.gnu.org/pub/gnu/automake/" 1 10 || DIE=1 44 | version_check "libtoolize" "libtoolize libtoolize15 glibtoolize" \ 45 | "ftp://ftp.gnu.org/pub/gnu/libtool/" 1 5 0 || DIE=1 46 | version_check "pkg-config" "" \ 47 | "http://www.freedesktop.org/software/pkgconfig" 0 8 0 || DIE=1 48 | 49 | die_check $DIE 50 | 51 | aclocal_check || DIE=1 52 | autoheader_check || DIE=1 53 | 54 | die_check $DIE 55 | 56 | # if no arguments specified then this will be printed 57 | if test -z "$*"; then 58 | echo "+ checking for autogen.sh options" 59 | echo " This autogen script will automatically run ./configure as:" 60 | echo " ./configure $CONFIGURE_DEF_OPT" 61 | echo " To pass any additional options, please specify them on the $0" 62 | echo " command line." 63 | fi 64 | 65 | toplevel_check $srcfile 66 | 67 | # aclocal 68 | if test -f acinclude.m4; then rm acinclude.m4; fi 69 | 70 | tool_run "$libtoolize" "--copy --force" 71 | tool_run "$aclocal" "-I common/m4 $ACLOCAL_FLAGS" 72 | tool_run "$autoheader" 73 | 74 | # touch the stamp-h.in build stamp so we don't re-run autoheader in maintainer mode 75 | echo timestamp > stamp-h.in 2> /dev/null 76 | 77 | tool_run "$autoconf" 78 | debug "automake: $automake" 79 | tool_run "$automake" "--add-missing --copy" 80 | 81 | test -n "$NOCONFIGURE" && { 82 | echo "skipping configure stage for package $package, as requested." 83 | echo "autogen.sh done." 84 | exit 0 85 | } 86 | 87 | echo "+ running configure ... " 88 | test ! -z "$CONFIGURE_DEF_OPT" && echo " ./configure default flags: $CONFIGURE_DEF_OPT" 89 | test ! -z "$CONFIGURE_EXT_OPT" && echo " ./configure external flags: $CONFIGURE_EXT_OPT" 90 | echo 91 | 92 | echo ./configure $CONFIGURE_DEF_OPT $CONFIGURE_EXT_OPT 93 | ./configure $CONFIGURE_DEF_OPT $CONFIGURE_EXT_OPT || { 94 | echo " configure failed" 95 | exit 1 96 | } 97 | 98 | echo "Now type 'make' to compile $package." 99 | -------------------------------------------------------------------------------- /src/utility.c: -------------------------------------------------------------------------------- 1 | /* 2 | utility.c - Misc helper functions 3 | 4 | Copyright (C) 2012 Paul Betts 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2, or (at your option) 9 | any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software Foundation, 18 | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #include "utility.h" 28 | 29 | 30 | void util_zmq_glib_free(void* to_free, void* hint) 31 | { 32 | g_free(to_free); 33 | } 34 | 35 | gboolean util_close_socket(void* sock) 36 | { 37 | if (!sock) return TRUE; 38 | 39 | if (zmq_close(sock) == -1) { 40 | g_warning("Failed to close socket: %s", zmq_strerror(zmq_errno())); 41 | return FALSE; 42 | } 43 | 44 | return TRUE; 45 | } 46 | 47 | char* util_send_reqrep_msg(void* zmq_context, const char* message, const char* address) 48 | { 49 | char* ret = NULL; 50 | int linger = 15*1000; 51 | void* sock = zmq_socket(zmq_context, ZMQ_REQ); 52 | 53 | if (!sock) { 54 | g_warning("Failed to create socket: %s", zmq_strerror(zmq_errno())); 55 | return ret; 56 | } 57 | 58 | zmq_setsockopt(sock, ZMQ_LINGER, &linger, sizeof(int)); 59 | 60 | g_print("Connecting to %s\n", address); 61 | if (zmq_connect(sock, address) == -1) { 62 | g_warning("Failed to connect: %s", zmq_strerror(zmq_errno())); 63 | goto out; 64 | } 65 | 66 | zmq_msg_t msg; 67 | zmq_msg_init_data(&msg, (void*) message, sizeof(char) * strlen(message), NULL, NULL); 68 | zmq_msg_send(&msg, sock, 0); 69 | zmq_msg_close(&msg); 70 | 71 | zmq_msg_t rep_msg; 72 | zmq_msg_init(&rep_msg); 73 | zmq_msg_recv(&rep_msg, sock, 0); 74 | 75 | char* rep_text = g_new0(char, zmq_msg_size(&rep_msg) + 1); 76 | memcpy(rep_text, zmq_msg_data(&rep_msg), zmq_msg_size(&rep_msg)); 77 | zmq_msg_close(&rep_msg); 78 | 79 | ret = rep_text; 80 | 81 | out: 82 | util_close_socket(sock); 83 | return ret; 84 | } 85 | 86 | static void hash_foreach_calc_length(gpointer key, gpointer value, gpointer user_data) 87 | { 88 | int* len = (int*)user_data; 89 | *len = (*len) + strlen((char*)key) + strlen((char*)value) + 2; /*newlines*/ 90 | } 91 | 92 | static void hash_foreach_create_message(gpointer key, gpointer value, gpointer user_data) 93 | { 94 | /* XXX: I hate this code and it makes me want to die */ 95 | char** data = (char**)user_data; 96 | *data += sprintf(*data, "%s\n%s\n", (char*)key, (char*)value); 97 | } 98 | 99 | char* util_hash_table_as_string(GHashTable* table) 100 | { 101 | char* ret; 102 | int bufsize = 4; 103 | 104 | g_hash_table_foreach(table, hash_foreach_calc_length, &bufsize); 105 | 106 | ret = g_new0(char, bufsize); 107 | 108 | char* iter = ret; 109 | g_hash_table_foreach(table, hash_foreach_create_message, &iter); 110 | 111 | return ret; 112 | } 113 | -------------------------------------------------------------------------------- /common/m4/introspection.m4: -------------------------------------------------------------------------------- 1 | dnl -*- mode: autoconf -*- 2 | dnl Copyright 2009 Johan Dahlin 3 | dnl 4 | dnl This file is free software; the author(s) gives unlimited 5 | dnl permission to copy and/or distribute it, with or without 6 | dnl modifications, as long as this notice is preserved. 7 | dnl 8 | 9 | # serial 1 10 | 11 | m4_define([_GOBJECT_INTROSPECTION_CHECK_INTERNAL], 12 | [ 13 | AC_BEFORE([AC_PROG_LIBTOOL],[$0])dnl setup libtool first 14 | AC_BEFORE([AM_PROG_LIBTOOL],[$0])dnl setup libtool first 15 | AC_BEFORE([LT_INIT],[$0])dnl setup libtool first 16 | 17 | dnl enable/disable introspection 18 | m4_if([$2], [require], 19 | [dnl 20 | enable_introspection=yes 21 | ],[dnl 22 | AC_ARG_ENABLE(introspection, 23 | AS_HELP_STRING([--enable-introspection[=@<:@no/auto/yes@:>@]], 24 | [Enable introspection for this build]),, 25 | [enable_introspection=auto]) 26 | ])dnl 27 | 28 | AC_MSG_CHECKING([for gobject-introspection]) 29 | 30 | dnl presence/version checking 31 | AS_CASE([$enable_introspection], 32 | [no], [dnl 33 | found_introspection="no (disabled, use --enable-introspection to enable)" 34 | ],dnl 35 | [yes],[dnl 36 | PKG_CHECK_EXISTS([gobject-introspection-1.0],, 37 | AC_MSG_ERROR([gobject-introspection-1.0 is not installed])) 38 | PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $1], 39 | found_introspection=yes, 40 | AC_MSG_ERROR([You need to have gobject-introspection >= $1 installed to build AC_PACKAGE_NAME])) 41 | ],dnl 42 | [auto],[dnl 43 | PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $1], found_introspection=yes, found_introspection=no) 44 | ],dnl 45 | [dnl 46 | AC_MSG_ERROR([invalid argument passed to --enable-introspection, should be one of @<:@no/auto/yes@:>@]) 47 | ])dnl 48 | 49 | AC_MSG_RESULT([$found_introspection]) 50 | 51 | INTROSPECTION_SCANNER= 52 | INTROSPECTION_COMPILER= 53 | INTROSPECTION_GENERATE= 54 | INTROSPECTION_GIRDIR= 55 | INTROSPECTION_TYPELIBDIR= 56 | if test "x$found_introspection" = "xyes"; then 57 | INTROSPECTION_SCANNER=`$PKG_CONFIG --variable=g_ir_scanner gobject-introspection-1.0` 58 | INTROSPECTION_COMPILER=`$PKG_CONFIG --variable=g_ir_compiler gobject-introspection-1.0` 59 | INTROSPECTION_GENERATE=`$PKG_CONFIG --variable=g_ir_generate gobject-introspection-1.0` 60 | INTROSPECTION_GIRDIR=`$PKG_CONFIG --variable=girdir gobject-introspection-1.0` 61 | INTROSPECTION_TYPELIBDIR="$($PKG_CONFIG --variable=typelibdir gobject-introspection-1.0)" 62 | INTROSPECTION_CFLAGS=`$PKG_CONFIG --cflags gobject-introspection-1.0` 63 | INTROSPECTION_LIBS=`$PKG_CONFIG --libs gobject-introspection-1.0` 64 | INTROSPECTION_MAKEFILE=`$PKG_CONFIG --variable=datadir gobject-introspection-1.0`/gobject-introspection-1.0/Makefile.introspection 65 | fi 66 | AC_SUBST(INTROSPECTION_SCANNER) 67 | AC_SUBST(INTROSPECTION_COMPILER) 68 | AC_SUBST(INTROSPECTION_GENERATE) 69 | AC_SUBST(INTROSPECTION_GIRDIR) 70 | AC_SUBST(INTROSPECTION_TYPELIBDIR) 71 | AC_SUBST(INTROSPECTION_CFLAGS) 72 | AC_SUBST(INTROSPECTION_LIBS) 73 | AC_SUBST(INTROSPECTION_MAKEFILE) 74 | 75 | AM_CONDITIONAL(HAVE_INTROSPECTION, test "x$found_introspection" = "xyes") 76 | ]) 77 | 78 | 79 | dnl Usage: 80 | dnl GOBJECT_INTROSPECTION_CHECK([minimum-g-i-version]) 81 | 82 | AC_DEFUN([GOBJECT_INTROSPECTION_CHECK], 83 | [ 84 | _GOBJECT_INTROSPECTION_CHECK_INTERNAL([$1]) 85 | ]) 86 | 87 | dnl Usage: 88 | dnl GOBJECT_INTROSPECTION_REQUIRE([minimum-g-i-version]) 89 | 90 | 91 | AC_DEFUN([GOBJECT_INTROSPECTION_REQUIRE], 92 | [ 93 | _GOBJECT_INTROSPECTION_CHECK_INTERNAL([$1], [require]) 94 | ]) 95 | -------------------------------------------------------------------------------- /common/m4/gst-package-release-datetime.m4: -------------------------------------------------------------------------------- 1 | dnl macros to set GST_PACKAGE_RELEASE_DATETIME 2 | 3 | dnl =========================================================================== 4 | dnl AG_GST_SET_PACKAGE_RELEASE_DATETIME 5 | dnl 6 | dnl Usage: 7 | dnl 8 | dnl AG_GST_SET_PACKAGE_RELEASE_DATETIME() 9 | dnl AG_GST_SET_PACKAGE_RELEASE_DATETIME([no]...) 10 | dnl sets the release datetime to the current date 11 | dnl (no = this is not a release, but git or prerelease) 12 | dnl 13 | dnl AG_GST_SET_PACKAGE_RELEASE_DATETIME([YYYY-MM-DD]) 14 | dnl AG_GST_SET_PACKAGE_RELEASE_DATETIME([yes], [YYYY-MM-DD]) 15 | dnl sets the release datetime to the specified date (and time, if given) 16 | dnl (yes = this is a release, not git or prerelease) 17 | dnl 18 | dnl AG_GST_SET_PACKAGE_RELEASE_DATETIME([yes], [DOAP-FILE], [RELEASE-VERSION]) 19 | dnl sets the release date to the release date associated with version 20 | dnl RELEASE-VERSION in the .doap file DOAP-FILE 21 | dnl (yes = this is a release, not git or prerelease) 22 | dnl 23 | dnl We need to treat pre-releases like git because there won't be an entry 24 | dnl in the .doap file for pre-releases yet, and we don't want to use the 25 | dnl date of the last release either. 26 | dnl =========================================================================== 27 | AC_DEFUN([AG_GST_SET_PACKAGE_RELEASE_DATETIME], 28 | [ 29 | dnl AG_GST_SET_PACKAGE_RELEASE_DATETIME() 30 | dnl AG_GST_SET_PACKAGE_RELEASE_DATETIME([yes]...) 31 | if test "x$1" = "xno" -o "x$1" = "x"; then 32 | GST_PACKAGE_RELEASE_DATETIME=`date -u "+%Y-%m-%dT%H:%MZ"` 33 | elif test "x$1" = "xyes"; then 34 | dnl AG_GST_SET_PACKAGE_RELEASE_DATETIME([no], ["YYYY-MM-DD"]) 35 | dnl AG_GST_SET_PACKAGE_RELEASE_DATETIME([no], [DOAP-FILE], [RELEASE-VERSION]) 36 | if ( echo $1 | grep -e '^20[1-9][0-9]-[0-1][0-9]-[0-3][0-9]' >/dev/null ) ; then 37 | GST_PACKAGE_RELEASE_DATETIME=$1 38 | else 39 | dnl we assume the .doap file contains the date as YYYY-MM-DD 40 | YYYY_MM_DD=`sh "${srcdir}/common/extract-release-date-from-doap-file" $3 $2`; 41 | if test "x$YYYY_MM_DD" != "x"; then 42 | GST_PACKAGE_RELEASE_DATETIME=$YYYY_MM_DD 43 | else 44 | AC_MSG_ERROR([SET_PACKAGE_RELEASE_DATETIME: could not extract 45 | release date for release version $3 from $2]) 46 | GST_PACKAGE_RELEASE_DATETIME="" 47 | fi 48 | fi 49 | dnl AG_GST_SET_PACKAGE_RELEASE_DATETIME([YYYY-MM-DD]) 50 | elif ( echo $1 | grep -e '^20[1-9][0-9]-[0-1][0-9]-[0-3][0-9]' >/dev/null ) ; then 51 | GST_PACKAGE_RELEASE_DATETIME=$1 52 | else 53 | AC_MSG_WARN([SET_PACKAGE_RELEASE_DATETIME: invalid first argument]) 54 | GST_PACKAGE_RELEASE_DATETIME="" 55 | fi 56 | 57 | if test "x$GST_PACKAGE_RELEASE_DATETIME" = "x"; then 58 | AC_MSG_WARN([Invalid package release date time: $GST_PACKAGE_RELEASE_DATETIME]) 59 | else 60 | AC_MSG_NOTICE([Setting GST_PACKAGE_RELEASE_DATETIME to $GST_PACKAGE_RELEASE_DATETIME]) 61 | 62 | AC_DEFINE_UNQUOTED([GST_PACKAGE_RELEASE_DATETIME], 63 | ["$GST_PACKAGE_RELEASE_DATETIME"], 64 | [GStreamer package release date/time for plugins as YYYY-MM-DD]) 65 | fi 66 | ]) 67 | 68 | dnl =========================================================================== 69 | dnl AG_GST_SET_PACKAGE_RELEASE_DATETIME_WITH_NANO 70 | dnl 71 | dnl Usage: 72 | dnl 73 | dnl AG_GST_SET_PACKAGE_RELEASE_DATETIME([NANO-VERSION], [DOAP-FILE], [RELEASE-VERSION]) 74 | dnl if NANO-VERSION is 0, sets the release date to the release date associated 75 | dnl with version RELEASE-VERSION in the .doap file DOAP-FILE, otherwise sets 76 | dnl the release date and time to the current date/time. 77 | dnl 78 | dnl We need to treat pre-releases like git because there won't be an entry 79 | dnl in the .doap file for pre-releases yet, and we don't want to use the 80 | dnl date of the last release either. 81 | dnl =========================================================================== 82 | AC_DEFUN([AG_GST_SET_PACKAGE_RELEASE_DATETIME_WITH_NANO], 83 | [ 84 | if test "x$1" = "x0"; then 85 | AG_GST_SET_PACKAGE_RELEASE_DATETIME([yes], [ $2 ], [ $3 ]) 86 | else 87 | AG_GST_SET_PACKAGE_RELEASE_DATETIME([no]) 88 | fi 89 | ]) 90 | -------------------------------------------------------------------------------- /src/parser.c: -------------------------------------------------------------------------------- 1 | /* 2 | parser.c - Message parsing and dispatch 3 | 4 | Copyright (C) 2012 Paul Betts 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2, or (at your option) 9 | any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software Foundation, 18 | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | #include 22 | #include 23 | 24 | #include "parser.h" 25 | 26 | struct reg_entry_with_ctx { 27 | const char* prefix; 28 | void* plugin_context; 29 | 30 | parse_handler_cb parser; 31 | }; 32 | 33 | struct plugin_entry_with_ctx { 34 | void *ctx; 35 | void (*plugin_free)(void* ctx); 36 | }; 37 | 38 | struct parse_ctx { 39 | GHashTable* message_table; /* prefix -> reg_entry_with_ctx */ 40 | GSList* plugin_list; /* list of plugin_entry_with_ctx */ 41 | }; 42 | 43 | static void plugin_entry_free(void* entry); 44 | 45 | struct parse_ctx* parse_new(void) 46 | { 47 | struct parse_ctx* ret = g_new0(struct parse_ctx, 1); 48 | 49 | ret->plugin_list = NULL; 50 | ret->message_table = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); 51 | 52 | return ret; 53 | } 54 | 55 | void parse_free(struct parse_ctx* parser) 56 | { 57 | g_hash_table_destroy(parser->message_table); 58 | g_slist_free_full(parser->plugin_list, plugin_entry_free); 59 | 60 | g_free(parser); 61 | } 62 | 63 | gboolean parse_register_plugin(struct parse_ctx* parser, struct parser_plugin_entry* plugin) 64 | { 65 | void* plugin_ctx = (*plugin->plugin_new)(plugin->context); 66 | 67 | struct message_dispatch_entry* regd_messages = NULL; 68 | struct plugin_entry_with_ctx* p_entry; 69 | struct reg_entry_with_ctx* r_entry; 70 | char* prefix; 71 | 72 | if (!(*plugin->plugin_register)(plugin_ctx, ®d_messages)) { 73 | g_warning("plugin failed to register: %s", plugin->friendly_name); 74 | (*plugin->plugin_free)(plugin_ctx); 75 | 76 | return FALSE; 77 | } 78 | 79 | p_entry = g_new0(struct plugin_entry_with_ctx, 1); 80 | p_entry->ctx = plugin_ctx; 81 | p_entry->plugin_free = plugin->plugin_free; 82 | parser->plugin_list = g_slist_prepend(parser->plugin_list, p_entry); 83 | 84 | for (struct message_dispatch_entry* msg = regd_messages; msg->prefix; msg++) { 85 | r_entry = g_new0(struct reg_entry_with_ctx, 1); 86 | prefix = strdup(msg->prefix); 87 | 88 | r_entry->prefix = prefix; 89 | r_entry->plugin_context = plugin_ctx; 90 | r_entry->parser = msg->op_parse; 91 | 92 | g_hash_table_insert(parser->message_table, prefix, r_entry); 93 | } 94 | 95 | g_print("Registered plugin: %s\n", plugin->friendly_name); 96 | return TRUE; 97 | } 98 | 99 | char* parse_message(struct parse_ctx* parser, const char* message) 100 | { 101 | char* ret = strdup("FAIL Message is Invalid"); 102 | 103 | GError* err = NULL; 104 | GRegex* msg_regex = g_regex_new("^([A-Z]+)[ ]?(.+)$", 0, 0, &err); 105 | char* prefix = NULL; 106 | char* param; 107 | struct reg_entry_with_ctx* prefix_entry; 108 | 109 | GMatchInfo* match_info = NULL; 110 | if (!g_regex_match(msg_regex, message, 0, &match_info)) { 111 | g_warning("Message is invalid: %s", message); 112 | goto out; 113 | } 114 | 115 | prefix = g_match_info_fetch(match_info, 1); 116 | if (!prefix) { 117 | goto out; 118 | } 119 | 120 | prefix_entry = g_hash_table_lookup(parser->message_table, prefix); 121 | if (!prefix_entry) { 122 | g_warning("Message is invalid: %s", message); 123 | goto out; 124 | } 125 | 126 | param = g_match_info_fetch(match_info, 2); 127 | g_free(ret); /* free the error message */ 128 | ret = (*prefix_entry->parser)(param, prefix_entry->plugin_context); 129 | g_free(param); 130 | 131 | out: 132 | if (prefix) g_free(prefix); 133 | if (match_info) g_match_info_free(match_info); 134 | g_regex_unref(msg_regex); 135 | 136 | return ret; 137 | } 138 | 139 | static void plugin_entry_free(void* entry) 140 | { 141 | struct plugin_entry_with_ctx* e = (struct plugin_entry_with_ctx*)entry; 142 | (*e->plugin_free)(e->ctx); 143 | g_free(entry); 144 | } 145 | -------------------------------------------------------------------------------- /common/m4/gst-default.m4: -------------------------------------------------------------------------------- 1 | dnl default elements used for tests and such 2 | 3 | dnl AG_GST_DEFAULT_ELEMENTS 4 | 5 | AC_DEFUN([AG_GST_DEFAULT_ELEMENTS], 6 | [ 7 | dnl decide on default elements 8 | dnl FIXME: describe where exactly this gets used 9 | dnl FIXME: decide if it's a problem that this could point to sinks from 10 | dnl depending plugin modules 11 | dnl FIXME: when can we just use autoaudiosrc and autovideosrc? 12 | DEFAULT_AUDIOSINK="autoaudiosink" 13 | DEFAULT_VIDEOSINK="autovideosink" 14 | DEFAULT_AUDIOSRC="alsasrc" 15 | DEFAULT_VIDEOSRC="v4l2src" 16 | DEFAULT_VISUALIZER="goom" 17 | case "$host" in 18 | *-sun-* | *pc-solaris* ) 19 | DEFAULT_AUDIOSRC="sunaudiosrc" 20 | ;; 21 | *-darwin* ) 22 | DEFAULT_AUDIOSRC="osxaudiosrc" 23 | ;; 24 | esac 25 | 26 | dnl Default audio sink 27 | AC_ARG_WITH(default-audiosink, 28 | AC_HELP_STRING([--with-default-audiosink], [specify default audio sink]), 29 | [ 30 | case "${withval}" in 31 | yes) AC_MSG_ERROR(bad value ${withval} for --with-default-audiosink) ;; 32 | no) AC_MSG_ERROR(bad value ${withval} for --with-default-audiosink) ;; 33 | *) DEFAULT_AUDIOSINK="${withval}" ;; 34 | esac 35 | ], 36 | [ 37 | DEFAULT_AUDIOSINK="$DEFAULT_AUDIOSINK" 38 | ] dnl Default value as determined above 39 | ) 40 | AC_MSG_NOTICE(Using $DEFAULT_AUDIOSINK as default audio sink) 41 | AC_SUBST(DEFAULT_AUDIOSINK) 42 | AC_DEFINE_UNQUOTED(DEFAULT_AUDIOSINK, "$DEFAULT_AUDIOSINK", 43 | [Default audio sink]) 44 | 45 | dnl Default audio source 46 | AC_ARG_WITH(default-audiosrc, 47 | AC_HELP_STRING([--with-default-audiosrc], [specify default audio source]), 48 | [ 49 | case "${withval}" in 50 | yes) AC_MSG_ERROR(bad value ${withval} for --with-default-audiosrc) ;; 51 | no) AC_MSG_ERROR(bad value ${withval} for --with-default-audiosrc) ;; 52 | *) DEFAULT_AUDIOSRC="${withval}" ;; 53 | esac 54 | ], 55 | [ 56 | DEFAULT_AUDIOSRC="$DEFAULT_AUDIOSRC" 57 | ] dnl Default value as determined above 58 | ) 59 | AC_MSG_NOTICE(Using $DEFAULT_AUDIOSRC as default audio source) 60 | AC_SUBST(DEFAULT_AUDIOSRC) 61 | AC_DEFINE_UNQUOTED(DEFAULT_AUDIOSRC, "$DEFAULT_AUDIOSRC", 62 | [Default audio source]) 63 | 64 | dnl Default video sink 65 | AC_ARG_WITH(default-videosink, 66 | AC_HELP_STRING([--with-default-videosink], [specify default video sink]), 67 | [ 68 | case "${withval}" in 69 | yes) AC_MSG_ERROR(bad value ${withval} for --with-default-videosink) ;; 70 | no) AC_MSG_ERROR(bad value ${withval} for --with-default-videosink) ;; 71 | *) DEFAULT_VIDEOSINK="${withval}" ;; 72 | esac 73 | ], 74 | [ 75 | DEFAULT_VIDEOSINK="$DEFAULT_VIDEOSINK" 76 | ] dnl Default value as determined above 77 | ) 78 | AC_MSG_NOTICE(Using $DEFAULT_VIDEOSINK as default video sink) 79 | AC_SUBST(DEFAULT_VIDEOSINK) 80 | AC_DEFINE_UNQUOTED(DEFAULT_VIDEOSINK, "$DEFAULT_VIDEOSINK", 81 | [Default video sink]) 82 | 83 | dnl Default video source 84 | AC_ARG_WITH(default-videosrc, 85 | AC_HELP_STRING([--with-default-videosrc], [specify default video source]), 86 | [ 87 | case "${withval}" in 88 | yes) AC_MSG_ERROR(bad value ${withval} for --with-default-videosrc) ;; 89 | no) AC_MSG_ERROR(bad value ${withval} for --with-default-videosrc) ;; 90 | *) DEFAULT_VIDEOSRC="${withval}" ;; 91 | esac 92 | ], 93 | [ 94 | DEFAULT_VIDEOSRC="$DEFAULT_VIDEOSRC" 95 | ] dnl Default value as determined above 96 | ) 97 | AC_MSG_NOTICE(Using $DEFAULT_VIDEOSRC as default video source) 98 | AC_SUBST(DEFAULT_VIDEOSRC) 99 | AC_DEFINE_UNQUOTED(DEFAULT_VIDEOSRC, "$DEFAULT_VIDEOSRC", 100 | [Default video source]) 101 | 102 | dnl Default visualizer 103 | AC_ARG_WITH(default-visualizer, 104 | AC_HELP_STRING([--with-default-visualizer], [specify default visualizer]), 105 | [ 106 | case "${withval}" in 107 | yes) AC_MSG_ERROR(bad value ${withval} for --with-default-visualizer) ;; 108 | no) AC_MSG_ERROR(bad value ${withval} for --with-default-visualizer) ;; 109 | *) DEFAULT_VISUALIZER="${withval}" ;; 110 | esac 111 | ], 112 | [ 113 | DEFAULT_VISUALIZER="$DEFAULT_VISUALIZER" 114 | ] dnl Default value as determined above 115 | ) 116 | AC_MSG_NOTICE(Using $DEFAULT_VISUALIZER as default visualizer) 117 | AC_SUBST(DEFAULT_VISUALIZER) 118 | AC_DEFINE_UNQUOTED(DEFAULT_VISUALIZER, "$DEFAULT_VISUALIZER", 119 | [Default visualizer]) 120 | ]) 121 | -------------------------------------------------------------------------------- /common/m4/gst-arch.m4: -------------------------------------------------------------------------------- 1 | dnl AG_GST_ARCH 2 | dnl sets up defines and automake conditionals for host architecture 3 | dnl checks endianness 4 | dnl defines HOST_CPU 5 | 6 | AC_DEFUN([AG_GST_ARCH], 7 | [ 8 | AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use host_ variables 9 | 10 | dnl Determine CPU 11 | case "x${host_cpu}" in 12 | xi?86 | xk? | xi?86_64) 13 | case $host_os in 14 | solaris*) 15 | AC_CHECK_DECL([__i386], [I386_ABI="yes"], [I386_ABI="no"]) 16 | AC_CHECK_DECL([__amd64], [AMD64_ABI="yes"], [AMD64_ABI="no"]) 17 | 18 | if test "x$I386_ABI" = "xyes" ; then 19 | HAVE_CPU_I386=yes 20 | AC_DEFINE(HAVE_CPU_I386, 1, [Define if the host CPU is an x86]) 21 | fi 22 | if test "x$AMD64_ABI" = "xyes" ; then 23 | HAVE_CPU_X86_64=yes 24 | AC_DEFINE(HAVE_CPU_X86_64, 1, [Define if the host CPU is a x86_64]) 25 | fi 26 | ;; 27 | *) 28 | HAVE_CPU_I386=yes 29 | AC_DEFINE(HAVE_CPU_I386, 1, [Define if the host CPU is an x86]) 30 | 31 | dnl FIXME could use some better detection 32 | dnl (ie CPUID) 33 | case "x${host_cpu}" in 34 | xi386 | xi486) ;; 35 | *) 36 | AC_DEFINE(HAVE_RDTSC, 1, [Define if RDTSC is available]) ;; 37 | esac 38 | ;; 39 | esac 40 | ;; 41 | xpowerpc) 42 | HAVE_CPU_PPC=yes 43 | AC_DEFINE(HAVE_CPU_PPC, 1, [Define if the host CPU is a PowerPC]) ;; 44 | xpowerpc64) 45 | HAVE_CPU_PPC64=yes 46 | AC_DEFINE(HAVE_CPU_PPC64, 1, [Define if the host CPU is a 64 bit PowerPC]) ;; 47 | xalpha*) 48 | HAVE_CPU_ALPHA=yes 49 | AC_DEFINE(HAVE_CPU_ALPHA, 1, [Define if the host CPU is an Alpha]) ;; 50 | xarm*) 51 | HAVE_CPU_ARM=yes 52 | AC_DEFINE(HAVE_CPU_ARM, 1, [Define if the host CPU is an ARM]) ;; 53 | xsparc*) 54 | HAVE_CPU_SPARC=yes 55 | AC_DEFINE(HAVE_CPU_SPARC, 1, [Define if the host CPU is a SPARC]) ;; 56 | xmips*) 57 | HAVE_CPU_MIPS=yes 58 | AC_DEFINE(HAVE_CPU_MIPS, 1, [Define if the host CPU is a MIPS]) ;; 59 | xhppa*) 60 | HAVE_CPU_HPPA=yes 61 | AC_DEFINE(HAVE_CPU_HPPA, 1, [Define if the host CPU is a HPPA]) ;; 62 | xs390*) 63 | HAVE_CPU_S390=yes 64 | AC_DEFINE(HAVE_CPU_S390, 1, [Define if the host CPU is a S390]) ;; 65 | xia64*) 66 | HAVE_CPU_IA64=yes 67 | AC_DEFINE(HAVE_CPU_IA64, 1, [Define if the host CPU is a IA64]) ;; 68 | xm68k*) 69 | HAVE_CPU_M68K=yes 70 | AC_DEFINE(HAVE_CPU_M68K, 1, [Define if the host CPU is a M68K]) ;; 71 | xx86_64) 72 | HAVE_CPU_X86_64=yes 73 | AC_DEFINE(HAVE_CPU_X86_64, 1, [Define if the host CPU is a x86_64]) ;; 74 | xcris) 75 | HAVE_CPU_CRIS=yes 76 | AC_DEFINE(HAVE_CPU_CRIS, 1, [Define if the host CPU is a CRIS]) ;; 77 | xcrisv32) 78 | HAVE_CPU_CRISV32=yes 79 | AC_DEFINE(HAVE_CPU_CRISV32, 1, [Define if the host CPU is a CRISv32]) ;; 80 | esac 81 | 82 | dnl Determine endianness 83 | AC_C_BIGENDIAN 84 | 85 | AM_CONDITIONAL(HAVE_CPU_I386, test "x$HAVE_CPU_I386" = "xyes") 86 | AM_CONDITIONAL(HAVE_CPU_PPC, test "x$HAVE_CPU_PPC" = "xyes") 87 | AM_CONDITIONAL(HAVE_CPU_PPC64, test "x$HAVE_CPU_PPC64" = "xyes") 88 | AM_CONDITIONAL(HAVE_CPU_ALPHA, test "x$HAVE_CPU_ALPHA" = "xyes") 89 | AM_CONDITIONAL(HAVE_CPU_ARM, test "x$HAVE_CPU_ARM" = "xyes") 90 | AM_CONDITIONAL(HAVE_CPU_SPARC, test "x$HAVE_CPU_SPARC" = "xyes") 91 | AM_CONDITIONAL(HAVE_CPU_HPPA, test "x$HAVE_CPU_HPPA" = "xyes") 92 | AM_CONDITIONAL(HAVE_CPU_MIPS, test "x$HAVE_CPU_MIPS" = "xyes") 93 | AM_CONDITIONAL(HAVE_CPU_S390, test "x$HAVE_CPU_S390" = "xyes") 94 | AM_CONDITIONAL(HAVE_CPU_IA64, test "x$HAVE_CPU_IA64" = "xyes") 95 | AM_CONDITIONAL(HAVE_CPU_M68K, test "x$HAVE_CPU_M68K" = "xyes") 96 | AM_CONDITIONAL(HAVE_CPU_X86_64, test "x$HAVE_CPU_X86_64" = "xyes") 97 | AM_CONDITIONAL(HAVE_CPU_CRIS, test "x$HAVE_CPU_CRIS" = "xyes") 98 | AM_CONDITIONAL(HAVE_CPU_CRISV32, test "x$HAVE_CPU_CRISV32" = "xyes") 99 | 100 | AC_DEFINE_UNQUOTED(HOST_CPU, "$host_cpu", [the host CPU]) 101 | ]) 102 | 103 | dnl check if unaligned memory access works correctly 104 | AC_DEFUN([AG_GST_UNALIGNED_ACCESS], [ 105 | AC_MSG_CHECKING([if unaligned memory access works correctly]) 106 | if test x"$as_cv_unaligned_access" = x ; then 107 | case $host in 108 | alpha*|arm*|hp*|mips*|sh*|sparc*|ia64*) 109 | _AS_ECHO_N([(blacklisted) ]) 110 | as_cv_unaligned_access=no 111 | ;; 112 | i?86*|x86_64*|amd64*|powerpc*|m68k*|cris*) 113 | _AS_ECHO_N([(whitelisted) ]) 114 | as_cv_unaligned_access=yes 115 | ;; 116 | esac 117 | else 118 | _AS_ECHO_N([(cached) ]) 119 | fi 120 | if test x"$as_cv_unaligned_access" = x ; then 121 | AC_TRY_RUN([ 122 | int main(int argc, char **argv) 123 | { 124 | char array[] = "ABCDEFGH"; 125 | unsigned int iarray[2]; 126 | memcpy(iarray,array,8); 127 | #define GET(x) (*(unsigned int *)((char *)iarray + (x))) 128 | if(GET(0) != 0x41424344 && GET(0) != 0x44434241) return 1; 129 | if(GET(1) != 0x42434445 && GET(1) != 0x45444342) return 1; 130 | if(GET(2) != 0x43444546 && GET(2) != 0x46454443) return 1; 131 | if(GET(3) != 0x44454647 && GET(3) != 0x47464544) return 1; 132 | return 0; 133 | } 134 | ], as_cv_unaligned_access="yes", as_cv_unaligned_access="no") 135 | fi 136 | AC_MSG_RESULT($as_cv_unaligned_access) 137 | if test "$as_cv_unaligned_access" = "yes"; then 138 | AC_DEFINE_UNQUOTED(HAVE_UNALIGNED_ACCESS, 1, 139 | [defined if unaligned memory access works correctly]) 140 | fi 141 | ]) 142 | -------------------------------------------------------------------------------- /common/m4/as-python.m4: -------------------------------------------------------------------------------- 1 | ## ------------------------ 2 | ## Python file handling 3 | ## From Andrew Dalke 4 | ## Updated by James Henstridge 5 | ## Updated by Andy Wingo to loop through possible pythons 6 | ## ------------------------ 7 | 8 | # AS_PATH_PYTHON([MINIMUM-VERSION]) 9 | 10 | # Adds support for distributing Python modules and packages. To 11 | # install modules, copy them to $(pythondir), using the python_PYTHON 12 | # automake variable. To install a package with the same name as the 13 | # automake package, install to $(pkgpythondir), or use the 14 | # pkgpython_PYTHON automake variable. 15 | 16 | # The variables $(pyexecdir) and $(pkgpyexecdir) are provided as 17 | # locations to install python extension modules (shared libraries). 18 | # Another macro is required to find the appropriate flags to compile 19 | # extension modules. 20 | 21 | # If your package is configured with a different prefix to python, 22 | # users will have to add the install directory to the PYTHONPATH 23 | # environment variable, or create a .pth file (see the python 24 | # documentation for details). 25 | 26 | # If the MINIMUM-VERSION argument is passed, AS_PATH_PYTHON will 27 | # cause an error if the version of python installed on the system 28 | # doesn't meet the requirement. MINIMUM-VERSION should consist of 29 | # numbers and dots only. 30 | 31 | # Updated to loop over all possible python binaries by Andy Wingo 32 | # 33 | # Updated to only warn and unset PYTHON if no good one is found 34 | 35 | AC_DEFUN([AS_PATH_PYTHON], 36 | [ 37 | dnl Find a version of Python. I could check for python versions 1.4 38 | dnl or earlier, but the default installation locations changed from 39 | dnl $prefix/lib/site-python in 1.4 to $prefix/lib/python1.5/site-packages 40 | dnl in 1.5, and I don't want to maintain that logic. 41 | 42 | dnl should we do the version check? 43 | PYTHON_CANDIDATES="python python2.2 python2.1 python2.0 python2 \ 44 | python1.6 python1.5" 45 | ifelse([$1],[], 46 | [AC_PATH_PROG(PYTHON, $PYTHON_CANDIDATES)], 47 | [ 48 | AC_MSG_NOTICE(Looking for Python version >= $1) 49 | changequote(<<, >>)dnl 50 | prog=" 51 | import sys, string 52 | minver = '$1' 53 | # split string by '.' and convert to numeric 54 | minver_info = map(string.atoi, string.split(minver, '.')) 55 | # we can now do comparisons on the two lists: 56 | if sys.version_info >= tuple(minver_info): 57 | sys.exit(0) 58 | else: 59 | sys.exit(1)" 60 | changequote([, ])dnl 61 | 62 | python_good=false 63 | for python_candidate in $PYTHON_CANDIDATES; do 64 | unset PYTHON 65 | AC_PATH_PROG(PYTHON, $python_candidate) 1> /dev/null 2> /dev/null 66 | 67 | if test "x$PYTHON" = "x"; then continue; fi 68 | 69 | if $PYTHON -c "$prog" 1>&AC_FD_CC 2>&AC_FD_CC; then 70 | AC_MSG_CHECKING(["$PYTHON":]) 71 | AC_MSG_RESULT([okay]) 72 | python_good=true 73 | break; 74 | else 75 | dnl clear the cache val 76 | unset ac_cv_path_PYTHON 77 | fi 78 | done 79 | ]) 80 | 81 | if test "$python_good" != "true"; then 82 | AC_MSG_WARN([No suitable version of python found]) 83 | PYTHON= 84 | else 85 | 86 | AC_MSG_CHECKING([local Python configuration]) 87 | 88 | dnl Query Python for its version number. Getting [:3] seems to be 89 | dnl the best way to do this; it's what "site.py" does in the standard 90 | dnl library. Need to change quote character because of [:3] 91 | 92 | AC_SUBST(PYTHON_VERSION) 93 | changequote(<<, >>)dnl 94 | PYTHON_VERSION=`$PYTHON -c "import sys; print sys.version[:3]"` 95 | changequote([, ])dnl 96 | 97 | 98 | dnl Use the values of $prefix and $exec_prefix for the corresponding 99 | dnl values of PYTHON_PREFIX and PYTHON_EXEC_PREFIX. These are made 100 | dnl distinct variables so they can be overridden if need be. However, 101 | dnl general consensus is that you shouldn't need this ability. 102 | 103 | AC_SUBST(PYTHON_PREFIX) 104 | PYTHON_PREFIX='${prefix}' 105 | 106 | AC_SUBST(PYTHON_EXEC_PREFIX) 107 | PYTHON_EXEC_PREFIX='${exec_prefix}' 108 | 109 | dnl At times (like when building shared libraries) you may want 110 | dnl to know which OS platform Python thinks this is. 111 | 112 | AC_SUBST(PYTHON_PLATFORM) 113 | PYTHON_PLATFORM=`$PYTHON -c "import sys; print sys.platform"` 114 | 115 | 116 | dnl Set up 4 directories: 117 | 118 | dnl pythondir -- where to install python scripts. This is the 119 | dnl site-packages directory, not the python standard library 120 | dnl directory like in previous automake betas. This behaviour 121 | dnl is more consistent with lispdir.m4 for example. 122 | dnl 123 | dnl Also, if the package prefix isn't the same as python's prefix, 124 | dnl then the old $(pythondir) was pretty useless. 125 | 126 | AC_SUBST(pythondir) 127 | pythondir=$PYTHON_PREFIX"/lib/python"$PYTHON_VERSION/site-packages 128 | 129 | dnl pkgpythondir -- $PACKAGE directory under pythondir. Was 130 | dnl PYTHON_SITE_PACKAGE in previous betas, but this naming is 131 | dnl more consistent with the rest of automake. 132 | dnl Maybe this should be put in python.am? 133 | 134 | AC_SUBST(pkgpythondir) 135 | pkgpythondir=\${pythondir}/$PACKAGE 136 | 137 | dnl pyexecdir -- directory for installing python extension modules 138 | dnl (shared libraries) Was PYTHON_SITE_EXEC in previous betas. 139 | 140 | AC_SUBST(pyexecdir) 141 | pyexecdir=$PYTHON_EXEC_PREFIX"/lib/python"$PYTHON_VERSION/site-packages 142 | 143 | dnl pkgpyexecdir -- $(pyexecdir)/$(PACKAGE) 144 | dnl Maybe this should be put in python.am? 145 | 146 | AC_SUBST(pkgpyexecdir) 147 | pkgpyexecdir=\${pyexecdir}/$PACKAGE 148 | 149 | AC_MSG_RESULT([looks good]) 150 | 151 | fi 152 | ]) 153 | -------------------------------------------------------------------------------- /common/m4/gst-doc.m4: -------------------------------------------------------------------------------- 1 | AC_DEFUN([AG_GST_DOCBOOK_CHECK], 2 | [ 3 | dnl choose a location to install docbook docs in 4 | if test "x$PACKAGE_TARNAME" = "x" 5 | then 6 | AC_MSG_ERROR([Internal error - PACKAGE_TARNAME not set]) 7 | fi 8 | docdir="\$(datadir)/doc/$PACKAGE_TARNAME-$GST_MAJORMINOR" 9 | 10 | dnl enable/disable docbook documentation building 11 | AC_ARG_ENABLE(docbook, 12 | AC_HELP_STRING([--enable-docbook], 13 | [use docbook to build documentation [default=no]]),, 14 | enable_docbook=no) 15 | 16 | have_docbook=no 17 | 18 | if test x$enable_docbook = xyes; then 19 | dnl check if we actually have everything we need 20 | 21 | dnl check for docbook tools 22 | AC_CHECK_PROG(HAVE_DOCBOOK2PS, docbook2ps, yes, no) 23 | AC_CHECK_PROG(HAVE_DOCBOOK2HTML, docbook2html, yes, no) 24 | AC_CHECK_PROG(HAVE_JADETEX, jadetex, yes, no) 25 | AC_CHECK_PROG(HAVE_PS2PDF, ps2pdf, yes, no) 26 | 27 | # -V option appeared in 0.6.10 28 | docbook2html_min_version=0.6.10 29 | if test "x$HAVE_DOCBOOK2HTML" != "xno"; then 30 | docbook2html_version=`docbook2html --version` 31 | AC_MSG_CHECKING([docbook2html version ($docbook2html_version) >= $docbook2html_min_version]) 32 | if perl -w < \$min_version_major) || 36 | ((\$docbook2html_version_major == \$min_version_major) && 37 | (\$docbook2html_version_minor >= \$min_version_minor)) || 38 | ((\$docbook2html_version_major == \$min_version_major) && 39 | (\$docbook2html_version_minor >= \$min_version_minor) && 40 | (\$docbook2html_version_micro >= \$min_version_micro))) 41 | ? 0 : 1); 42 | EOF 43 | then 44 | AC_MSG_RESULT(yes) 45 | else 46 | AC_MSG_RESULT(no) 47 | HAVE_DOCBOOK2HTML=no 48 | fi 49 | fi 50 | 51 | dnl check if we can process docbook stuff 52 | AS_DOCBOOK(have_docbook=yes, have_docbook=no) 53 | 54 | dnl check for extra tools 55 | AC_CHECK_PROG(HAVE_DVIPS, dvips, yes, no) 56 | AC_CHECK_PROG(HAVE_XMLLINT, xmllint, yes, no) 57 | 58 | dnl check for image conversion tools 59 | AC_CHECK_PROG(HAVE_FIG2DEV, fig2dev, yes, no) 60 | if test "x$HAVE_FIG2DEV" = "xno" ; then 61 | AC_MSG_WARN([Did not find fig2dev (from xfig), images will not be generated.]) 62 | fi 63 | 64 | dnl The following is a hack: if fig2dev doesn't display an error message 65 | dnl for the desired type, we assume it supports it. 66 | HAVE_FIG2DEV_EPS=no 67 | if test "x$HAVE_FIG2DEV" = "xyes" ; then 68 | fig2dev_quiet=`fig2dev -L eps &1 >/dev/null` 69 | if test "x$fig2dev_quiet" = "x" ; then 70 | HAVE_FIG2DEV_EPS=yes 71 | fi 72 | fi 73 | HAVE_FIG2DEV_PNG=no 74 | if test "x$HAVE_FIG2DEV" = "xyes" ; then 75 | fig2dev_quiet=`fig2dev -L png &1 >/dev/null` 76 | if test "x$fig2dev_quiet" = "x" ; then 77 | HAVE_FIG2DEV_PNG=yes 78 | fi 79 | fi 80 | HAVE_FIG2DEV_PDF=no 81 | if test "x$HAVE_FIG2DEV" = "xyes" ; then 82 | fig2dev_quiet=`fig2dev -L pdf &1 >/dev/null` 83 | if test "x$fig2dev_quiet" = "x" ; then 84 | HAVE_FIG2DEV_PDF=yes 85 | fi 86 | fi 87 | 88 | AC_CHECK_PROG(HAVE_PNGTOPNM, pngtopnm, yes, no) 89 | AC_CHECK_PROG(HAVE_PNMTOPS, pnmtops, yes, no) 90 | AC_CHECK_PROG(HAVE_EPSTOPDF, epstopdf, yes, no) 91 | 92 | dnl check if we can generate HTML 93 | if test "x$HAVE_DOCBOOK2HTML" = "xyes" && \ 94 | test "x$enable_docbook" = "xyes" && \ 95 | test "x$HAVE_XMLLINT" = "xyes" && \ 96 | test "x$HAVE_FIG2DEV_PNG" = "xyes"; then 97 | DOC_HTML=yes 98 | AC_MSG_NOTICE(Will output HTML documentation) 99 | else 100 | DOC_HTML=no 101 | AC_MSG_NOTICE(Will not output HTML documentation) 102 | fi 103 | 104 | dnl check if we can generate PS 105 | if test "x$HAVE_DOCBOOK2PS" = "xyes" && \ 106 | test "x$enable_docbook" = "xyes" && \ 107 | test "x$HAVE_XMLLINT" = "xyes" && \ 108 | test "x$HAVE_JADETEX" = "xyes" && \ 109 | test "x$HAVE_FIG2DEV_EPS" = "xyes" && \ 110 | test "x$HAVE_DVIPS" = "xyes" && \ 111 | test "x$HAVE_PNGTOPNM" = "xyes" && \ 112 | test "x$HAVE_PNMTOPS" = "xyes"; then 113 | DOC_PS=yes 114 | AC_MSG_NOTICE(Will output PS documentation) 115 | else 116 | DOC_PS=no 117 | AC_MSG_NOTICE(Will not output PS documentation) 118 | fi 119 | 120 | dnl check if we can generate PDF - using only ps2pdf 121 | if test "x$DOC_PS" = "xyes" && \ 122 | test "x$enable_docbook" = "xyes" && \ 123 | test "x$HAVE_XMLLINT" = "xyes" && \ 124 | test "x$HAVE_PS2PDF" = "xyes"; then 125 | DOC_PDF=yes 126 | AC_MSG_NOTICE(Will output PDF documentation) 127 | else 128 | DOC_PDF=no 129 | AC_MSG_NOTICE(Will not output PDF documentation) 130 | fi 131 | 132 | dnl if we don't have everything, we should disable 133 | if test "x$have_docbook" != "xyes"; then 134 | enable_docbook=no 135 | fi 136 | fi 137 | 138 | dnl if we're going to install documentation, tell us where 139 | if test "x$have_docbook" = "xyes"; then 140 | AC_MSG_NOTICE(Installing documentation in $docdir) 141 | AC_SUBST(docdir) 142 | fi 143 | 144 | AM_CONDITIONAL(ENABLE_DOCBOOK, test x$enable_docbook = xyes) 145 | AM_CONDITIONAL(DOC_HTML, test x$DOC_HTML = xyes) 146 | AM_CONDITIONAL(DOC_PDF, test x$DOC_PDF = xyes) 147 | AM_CONDITIONAL(DOC_PS, test x$DOC_PS = xyes) 148 | ]) 149 | -------------------------------------------------------------------------------- /common/m4/pkg.m4: -------------------------------------------------------------------------------- 1 | # pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- 2 | # 3 | # Copyright © 2004 Scott James Remnant . 4 | # 5 | # This program is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation; either version 2 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, but 11 | # WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | # General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program; if not, write to the Free Software 17 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | # 19 | # As a special exception to the GNU General Public License, if you 20 | # distribute this file as part of a program that contains a 21 | # configuration script generated by Autoconf, you may include it under 22 | # the same distribution terms that you use for the rest of that program. 23 | 24 | # PKG_PROG_PKG_CONFIG([MIN-VERSION]) 25 | # ---------------------------------- 26 | AC_DEFUN([PKG_PROG_PKG_CONFIG], 27 | [m4_pattern_forbid([^_?PKG_[A-Z_]+$]) 28 | m4_pattern_allow([^PKG_CONFIG(_PATH)?$]) 29 | AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])dnl 30 | if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then 31 | AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) 32 | fi 33 | if test -n "$PKG_CONFIG"; then 34 | _pkg_min_version=m4_default([$1], [0.9.0]) 35 | AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) 36 | if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then 37 | AC_MSG_RESULT([yes]) 38 | else 39 | AC_MSG_RESULT([no]) 40 | PKG_CONFIG="" 41 | fi 42 | 43 | fi[]dnl 44 | ])# PKG_PROG_PKG_CONFIG 45 | 46 | # PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) 47 | # 48 | # Check to see whether a particular set of modules exists. Similar 49 | # to PKG_CHECK_MODULES(), but does not set variables or print errors. 50 | # 51 | # 52 | # Similar to PKG_CHECK_MODULES, make sure that the first instance of 53 | # this or PKG_CHECK_MODULES is called, or make sure to call 54 | # PKG_CHECK_EXISTS manually 55 | # -------------------------------------------------------------- 56 | AC_DEFUN([PKG_CHECK_EXISTS], 57 | [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl 58 | if test -n "$PKG_CONFIG" && \ 59 | AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then 60 | m4_ifval([$2], [$2], [:]) 61 | m4_ifvaln([$3], [else 62 | $3])dnl 63 | fi]) 64 | 65 | 66 | # _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) 67 | # --------------------------------------------- 68 | m4_define([_PKG_CONFIG], 69 | [if test -n "$PKG_CONFIG"; then 70 | if test -n "$$1"; then 71 | pkg_cv_[]$1="$$1" 72 | else 73 | PKG_CHECK_EXISTS([$3], 74 | [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`], 75 | [pkg_failed=yes]) 76 | fi 77 | else 78 | pkg_failed=untried 79 | fi[]dnl 80 | ])# _PKG_CONFIG 81 | 82 | # _PKG_SHORT_ERRORS_SUPPORTED 83 | # ----------------------------- 84 | AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], 85 | [AC_REQUIRE([PKG_PROG_PKG_CONFIG]) 86 | if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then 87 | _pkg_short_errors_supported=yes 88 | else 89 | _pkg_short_errors_supported=no 90 | fi[]dnl 91 | ])# _PKG_SHORT_ERRORS_SUPPORTED 92 | 93 | 94 | # PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], 95 | # [ACTION-IF-NOT-FOUND]) 96 | # 97 | # 98 | # Note that if there is a possibility the first call to 99 | # PKG_CHECK_MODULES might not happen, you should be sure to include an 100 | # explicit call to PKG_PROG_PKG_CONFIG in your configure.ac 101 | # 102 | # 103 | # -------------------------------------------------------------- 104 | AC_DEFUN([PKG_CHECK_MODULES], 105 | [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl 106 | AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl 107 | AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl 108 | 109 | pkg_failed=no 110 | AC_MSG_CHECKING([for $1]) 111 | 112 | _PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) 113 | _PKG_CONFIG([$1][_LIBS], [libs], [$2]) 114 | 115 | m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS 116 | and $1[]_LIBS to avoid the need to call pkg-config. 117 | See the pkg-config man page for more details.]) 118 | 119 | if test $pkg_failed = yes; then 120 | _PKG_SHORT_ERRORS_SUPPORTED 121 | if test $_pkg_short_errors_supported = yes; then 122 | $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "$2"` 123 | else 124 | $1[]_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"` 125 | fi 126 | # Put the nasty error message in config.log where it belongs 127 | echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD 128 | 129 | ifelse([$4], , [AC_MSG_ERROR(dnl 130 | [Package requirements ($2) were not met: 131 | 132 | $$1_PKG_ERRORS 133 | 134 | Consider adjusting the PKG_CONFIG_PATH environment variable if you 135 | installed software in a non-standard prefix. 136 | 137 | _PKG_TEXT 138 | ])], 139 | [AC_MSG_RESULT([no]) 140 | $4]) 141 | elif test $pkg_failed = untried; then 142 | ifelse([$4], , [AC_MSG_FAILURE(dnl 143 | [The pkg-config script could not be found or is too old. Make sure it 144 | is in your PATH or set the PKG_CONFIG environment variable to the full 145 | path to pkg-config. 146 | 147 | _PKG_TEXT 148 | 149 | To get pkg-config, see .])], 150 | [$4]) 151 | else 152 | $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS 153 | $1[]_LIBS=$pkg_cv_[]$1[]_LIBS 154 | AC_MSG_RESULT([yes]) 155 | ifelse([$3], , :, [$3]) 156 | fi[]dnl 157 | ])# PKG_CHECK_MODULES 158 | -------------------------------------------------------------------------------- /common/m4/check.m4: -------------------------------------------------------------------------------- 1 | dnl _AM_TRY_CHECK(MINIMUM-VERSION, EXTRA-CFLAGS, EXTRA-LIBS, CHECK-LIB-NAME 2 | dnl [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) 3 | dnl Test for check, and define CHECK_CFLAGS and CHECK_LIBS 4 | dnl Done this way because of the brokenness that is 5 | dnl https://launchpad.net/distros/ubuntu/+source/check/+bug/5840 6 | dnl 7 | 8 | AC_DEFUN([_AM_TRY_CHECK], 9 | [ 10 | min_check_version=$1 11 | extra_cflags=$2 12 | extra_libs=$3 13 | check_lib_name=$4 14 | 15 | CHECK_CFLAGS="$extra_cflags" 16 | CHECK_LIBS="$extra_libs -l$check_lib_name" 17 | 18 | ac_save_CFLAGS="$CFLAGS" 19 | ac_save_LIBS="$LIBS" 20 | 21 | CFLAGS="$CFLAGS $CHECK_CFLAGS" 22 | LIBS="$CHECK_LIBS $LIBS" 23 | 24 | AC_MSG_CHECKING(for check named $check_lib_name - version >= $min_check_version) 25 | 26 | rm -f conf.check-test 27 | dnl unset no_check, since in our second run it would have been set to yes 28 | dnl before 29 | no_check= 30 | AC_TRY_RUN([ 31 | #include 32 | #include 33 | 34 | #include 35 | 36 | int main () 37 | { 38 | int major, minor, micro; 39 | char *tmp_version; 40 | 41 | system ("touch conf.check-test"); 42 | 43 | /* HP/UX 9 (%@#!) writes to sscanf strings */ 44 | tmp_version = strdup("$min_check_version"); 45 | if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { 46 | printf("%s, bad version string\n", "$min_check_version"); 47 | return 1; 48 | } 49 | 50 | if ((CHECK_MAJOR_VERSION != check_major_version) || 51 | (CHECK_MINOR_VERSION != check_minor_version) || 52 | (CHECK_MICRO_VERSION != check_micro_version)) 53 | { 54 | printf("\n*** The check header file (version %d.%d.%d) does not match\n", 55 | CHECK_MAJOR_VERSION, CHECK_MINOR_VERSION, CHECK_MICRO_VERSION); 56 | printf("*** the check library (version %d.%d.%d).\n", 57 | check_major_version, check_minor_version, check_micro_version); 58 | return 1; 59 | } 60 | 61 | if ((check_major_version > major) || 62 | ((check_major_version == major) && (check_minor_version > minor)) || 63 | ((check_major_version == major) && (check_minor_version == minor) && (check_micro_version >= micro))) 64 | { 65 | return 0; 66 | } 67 | else 68 | { 69 | printf("\n*** An old version of check (%d.%d.%d) was found.\n", 70 | check_major_version, check_minor_version, check_micro_version); 71 | printf("*** You need a version of check being at least %d.%d.%d.\n", major, minor, micro); 72 | printf("***\n"); 73 | printf("*** If you have already installed a sufficiently new version, this error\n"); 74 | printf("*** probably means that the wrong copy of the check library and header\n"); 75 | printf("*** file is being found. Rerun configure with the --with-check=PATH option\n"); 76 | printf("*** to specify the prefix where the correct version was installed.\n"); 77 | } 78 | 79 | return 1; 80 | } 81 | ],, no_check=yes, [echo $ac_n "cross compiling; assumed OK... $ac_c"]) 82 | 83 | CFLAGS="$ac_save_CFLAGS" 84 | LIBS="$ac_save_LIBS" 85 | 86 | if test "x$no_check" = x ; then 87 | AC_MSG_RESULT(yes) 88 | ifelse([$5], , :, [$5]) 89 | else 90 | AC_MSG_RESULT(no) 91 | if test -f conf.check-test ; then 92 | : 93 | else 94 | echo "*** Could not run check test program, checking why..." 95 | CFLAGS="$CFLAGS $CHECK_CFLAGS" 96 | LIBS="$CHECK_LIBS $LIBS" 97 | AC_TRY_LINK([ 98 | #include 99 | #include 100 | 101 | #include 102 | ], , [ echo "*** The test program compiled, but did not run. This usually means" 103 | echo "*** that the run-time linker is not finding check. You'll need to set your" 104 | echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" 105 | echo "*** to the installed location Also, make sure you have run ldconfig if that" 106 | echo "*** is required on your system" 107 | echo "***" 108 | echo "*** If you have an old version installed, it is best to remove it, although" 109 | echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], 110 | [ echo "*** The test program failed to compile or link. See the file config.log for" 111 | echo "*** the exact error that occured." ]) 112 | 113 | CFLAGS="$ac_save_CFLAGS" 114 | LIBS="$ac_save_LIBS" 115 | fi 116 | 117 | CHECK_CFLAGS="" 118 | CHECK_LIBS="" 119 | 120 | rm -f conf.check-test 121 | ifelse([$6], , AC_MSG_ERROR([check not found]), [$6]) 122 | fi 123 | ]) 124 | 125 | 126 | dnl AM_PATH_CHECK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) 127 | dnl Test for check, and define CHECK_CFLAGS and CHECK_LIBS 128 | dnl 129 | 130 | AC_DEFUN([AM_PATH_CHECK], 131 | [ 132 | AC_ARG_WITH(check, 133 | [ --with-check=PATH prefix where check is installed [default=auto]]) 134 | 135 | AC_ARG_WITH(checklibname, 136 | AC_HELP_STRING([--with-check-lib-name=NAME], 137 | [name of the PIC check library (default=check)])) 138 | 139 | min_check_version=ifelse([$1], ,0.8.2,$1) 140 | 141 | if test x$with_check = xno; then 142 | AC_MSG_RESULT(disabled) 143 | ifelse([$3], , AC_MSG_ERROR([disabling check is not supported]), [$3]) 144 | else 145 | if test "x$with_check" != x; then 146 | CHECK_EXTRA_CFLAGS="-I$with_check/include" 147 | CHECK_EXTRA_LIBS="-L$with_check/lib" 148 | else 149 | CHECK_EXTRA_CFLAGS="" 150 | CHECK_EXTRA_LIBS="" 151 | fi 152 | 153 | if test x$with_checklibname = x; then 154 | _AM_TRY_CHECK($min_check_version, $CHECK_EXTRA_CFLAGS, $CHECK_EXTRA_LIBS, 155 | check_pic, [have_check=true], [have_check=false]) 156 | if test x$have_check = xtrue; then 157 | ifelse([$2], , :, [$2]) 158 | else 159 | _AM_TRY_CHECK($min_check_version, $CHECK_EXTRA_CFLAGS, $CHECK_EXTRA_LIBS, 160 | check, [have_check=true], [have_check=false]) 161 | if test x$have_check = xtrue; then 162 | ifelse([$2], , :, [$2]) 163 | else 164 | ifelse([$3], , AC_MSG_ERROR([check not found]), [$3]) 165 | fi 166 | fi 167 | else 168 | _AM_TRY_CHECK($min_check_version, $CHECK_EXTRA_CFLAGS, $CHECK_EXTRA_LIBS, 169 | $with_checklibname, [have_check=true], [have_check=false]) 170 | if test x$have_check = xtrue; then 171 | ifelse([$2], , :, [$2]) 172 | else 173 | ifelse([$3], , AC_MSG_ERROR([check not found]), [$3]) 174 | fi 175 | fi 176 | 177 | AC_SUBST(CHECK_CFLAGS) 178 | AC_SUBST(CHECK_LIBS) 179 | rm -f conf.check-test 180 | fi 181 | ]) 182 | -------------------------------------------------------------------------------- /src/uuencode.c: -------------------------------------------------------------------------------- 1 | /* vi: set sw=4 ts=4: */ 2 | /* 3 | * Copyright 2003, Glenn McGrath 4 | * Copyright 2006, Rob Landley 5 | * Copyright 2010, Denys Vlasenko 6 | * Copyright 2012, Paul Betts 7 | * 8 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #include "uuencode.h" 18 | 19 | /* Conversion table. for base 64 */ 20 | const char uuenc_tbl_base64[65 + 1] = { 21 | 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 22 | 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 23 | 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 24 | 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 25 | 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 26 | 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 27 | 'w', 'x', 'y', 'z', '0', '1', '2', '3', 28 | '4', '5', '6', '7', '8', '9', '+', '/', 29 | '=' /* termination character */, 30 | '\0' /* needed for uudecode.c only */ 31 | }; 32 | 33 | const char uuenc_tbl_std[65] = { 34 | '`', '!', '"', '#', '$', '%', '&', '\'', 35 | '(', ')', '*', '+', ',', '-', '.', '/', 36 | '0', '1', '2', '3', '4', '5', '6', '7', 37 | '8', '9', ':', ';', '<', '=', '>', '?', 38 | '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 39 | 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 40 | 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 41 | 'X', 'Y', 'Z', '[', '\\', ']', '^', '_', 42 | '`' /* termination character */ 43 | }; 44 | 45 | int uuencode_get_length(int source_size) 46 | { 47 | return (4 * ((source_size + 2) / 3)); 48 | } 49 | 50 | /* 51 | * Encode bytes at S of length LENGTH to uuencode or base64 format and place it 52 | * to STORE. STORE will be 0-terminated, and must point to a writable 53 | * buffer of at least 1+BASE64_LENGTH(length) bytes. 54 | * where BASE64_LENGTH(len) = (4 * ((LENGTH + 2) / 3)) 55 | */ 56 | void uuencode(char *p, const void *src, int length, const char *tbl) 57 | { 58 | const unsigned char *s = src; 59 | 60 | /* Transform the 3x8 bits to 4x6 bits */ 61 | while (length > 0) { 62 | unsigned s1, s2; 63 | 64 | /* Are s[1], s[2] valid or should be assumed 0? */ 65 | s1 = s2 = 0; 66 | length -= 3; /* can be >=0, -1, -2 */ 67 | if (length >= -1) { 68 | s1 = s[1]; 69 | if (length >= 0) 70 | s2 = s[2]; 71 | } 72 | *p++ = tbl[s[0] >> 2]; 73 | *p++ = tbl[((s[0] & 3) << 4) + (s1 >> 4)]; 74 | *p++ = tbl[((s1 & 0xf) << 2) + (s2 >> 6)]; 75 | *p++ = tbl[s2 & 0x3f]; 76 | s += 3; 77 | } 78 | /* Zero-terminate */ 79 | *p = '\0'; 80 | /* If length is -2 or -1, pad last char or two */ 81 | while (length) { 82 | *--p = tbl[64]; 83 | length++; 84 | } 85 | } 86 | 87 | /* 88 | * Decode base64 encoded string. Stops on '\0'. 89 | * 90 | * Returns: pointer to the undecoded part of source. 91 | * If points to '\0', then the source was fully decoded. 92 | * (*pp_dst): advanced past the last written byte. 93 | */ 94 | const char* decode_base64(char **pp_dst, const char *src) 95 | { 96 | char *dst = *pp_dst; 97 | const char *src_tail; 98 | 99 | while (1) { 100 | unsigned char six_bit[4]; 101 | int count = 0; 102 | 103 | /* Fetch up to four 6-bit values */ 104 | src_tail = src; 105 | while (count < 4) { 106 | char *table_ptr; 107 | int ch; 108 | 109 | /* Get next _valid_ character. 110 | * uuenc_tbl_base64[] contains this string: 111 | * 0 1 2 3 4 5 6 112 | * 01234567890123456789012345678901234567890123456789012345678901234 113 | * "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=" 114 | */ 115 | do { 116 | ch = *src; 117 | if (ch == '\0') { 118 | if (count == 0) { 119 | /* Example: 120 | * If we decode "QUJD ", we want 121 | * to return ptr to NUL, not to ' ', 122 | * because we did fully decode 123 | * the string (to "ABC"). 124 | */ 125 | src_tail = src; 126 | } 127 | goto ret; 128 | } 129 | src++; 130 | table_ptr = strchr(uuenc_tbl_base64, ch); 131 | //TODO: add BASE64_FLAG_foo to die on bad char? 132 | } while (!table_ptr); 133 | 134 | /* Convert encoded character to decimal */ 135 | ch = table_ptr - uuenc_tbl_base64; 136 | 137 | /* ch is 64 if char was '=', otherwise 0..63 */ 138 | if (ch == 64) 139 | break; 140 | six_bit[count] = ch; 141 | count++; 142 | } 143 | 144 | /* Transform 6-bit values to 8-bit ones. 145 | * count can be < 4 when we decode the tail: 146 | * "eQ==" -> "y", not "y NUL NUL". 147 | * Note that (count > 1) is always true, 148 | * "x===" encoding is not valid: 149 | * even a single zero byte encodes as "AA==". 150 | * However, with current logic we come here with count == 1 151 | * when we decode "==" tail. 152 | */ 153 | if (count > 1) 154 | *dst++ = six_bit[0] << 2 | six_bit[1] >> 4; 155 | if (count > 2) 156 | *dst++ = six_bit[1] << 4 | six_bit[2] >> 2; 157 | if (count > 3) 158 | *dst++ = six_bit[2] << 6 | six_bit[3]; 159 | /* Note that if we decode "AA==" and ate first '=', 160 | * we just decoded one char (count == 2) and now we'll 161 | * do the loop once more to decode second '='. 162 | */ 163 | } /* while (1) */ 164 | ret: 165 | *pp_dst = dst; 166 | return src_tail; 167 | } 168 | 169 | /* 170 | * Decode base64 encoded stream. 171 | * Can stop on EOF, specified char, or on uuencode-style "====" line: 172 | * flags argument controls it. 173 | */ 174 | int read_base64(FILE *src_stream, FILE *dst_stream, int flags) 175 | { 176 | /* Note that EOF _can_ be passed as exit_char too */ 177 | #define exit_char ((int)(signed char)flags) 178 | #define uu_style_end (flags & BASE64_FLAG_UU_STOP) 179 | 180 | /* uuencoded files have 61 byte lines. Use 64 byte buffer 181 | * to process line at a time. 182 | */ 183 | enum { BUFFER_SIZE = 64 }; 184 | 185 | char in_buf[BUFFER_SIZE + 2]; 186 | char out_buf[BUFFER_SIZE / 4 * 3 + 2]; 187 | char *out_tail; 188 | const char *in_tail; 189 | int term_seen = 0; 190 | int in_count = 0; 191 | 192 | while (1) { 193 | while (in_count < BUFFER_SIZE) { 194 | int ch = fgetc(src_stream); 195 | if (ch == exit_char) { 196 | if (in_count == 0) 197 | return 1; 198 | term_seen = 1; 199 | break; 200 | } 201 | if (ch == EOF) { 202 | term_seen = 1; 203 | break; 204 | } 205 | /* Prevent "====" line to be split: stop if we see '\n'. 206 | * We can also skip other whitespace and skirt the problem 207 | * of files with NULs by stopping on any control char or space: 208 | */ 209 | if (ch <= ' ') 210 | break; 211 | in_buf[in_count++] = ch; 212 | } 213 | in_buf[in_count] = '\0'; 214 | 215 | /* Did we encounter "====" line? */ 216 | if (uu_style_end && strcmp(in_buf, "====") == 0) 217 | return 1; 218 | 219 | out_tail = out_buf; 220 | in_tail = decode_base64(&out_tail, in_buf); 221 | 222 | fwrite(out_buf, (out_tail - out_buf), 1, dst_stream); 223 | 224 | if (term_seen) { 225 | /* Did we consume ALL characters? */ 226 | if (*in_tail == '\0') 227 | return 1; 228 | /* No */ 229 | return 0; 230 | } 231 | 232 | /* It was partial decode */ 233 | in_count = strlen(in_tail); 234 | memmove(in_buf, in_tail, in_count); 235 | } 236 | } 237 | -------------------------------------------------------------------------------- /common/m4/gst-error.m4: -------------------------------------------------------------------------------- 1 | dnl handle various error-related things 2 | 3 | dnl Thomas Vander Stichele 4 | dnl Tim-Philipp Müller 5 | 6 | dnl Last modification: 2008-02-18 7 | 8 | dnl AG_GST_SET_ERROR_CFLAGS([ADD-WERROR], [MORE_FLAGS]) 9 | dnl AG_GST_SET_ERROR_CXXFLAGS([ADD-WERROR], [MORE_FLAGS]) 10 | dnl AG_GST_SET_LEVEL_DEFAULT([IS-GIT-VERSION]) 11 | 12 | 13 | dnl Sets WARNING_CFLAGS and ERROR_CFLAGS to something the compiler 14 | dnl will accept and AC_SUBST them so they are available in Makefile 15 | dnl 16 | dnl WARNING_CFLAGS will contain flags to make the compiler emit more 17 | dnl warnings. 18 | dnl ERROR_CFLAGS will contain flags to make those warnings fatal, 19 | dnl unless ADD-WERROR is set to "no" 20 | dnl 21 | dnl If MORE_FLAGS is set, tries to add each of the given flags 22 | dnl to WARNING_CFLAGS if the compiler supports them. Each flag is 23 | dnl tested separately. 24 | dnl 25 | dnl These flags can be overridden at make time: 26 | dnl make ERROR_CFLAGS= 27 | AC_DEFUN([AG_GST_SET_ERROR_CFLAGS], 28 | [ 29 | AC_REQUIRE([AC_PROG_CC]) 30 | AC_REQUIRE([AS_COMPILER_FLAG]) 31 | 32 | WARNING_CFLAGS="" 33 | ERROR_CFLAGS="" 34 | 35 | dnl if we support -Wall, set it unconditionally 36 | AS_COMPILER_FLAG(-Wall, 37 | WARNING_CFLAGS="$WARNING_CFLAGS -Wall") 38 | 39 | dnl Warn if declarations after statements are used (C99 extension) 40 | AS_COMPILER_FLAG(-Wdeclaration-after-statement, 41 | WARNING_CFLAGS="$WARNING_CFLAGS -Wdeclaration-after-statement") 42 | 43 | dnl Warn if variable length arrays are used (C99 extension) 44 | AS_COMPILER_FLAG(-Wvla, 45 | WARNING_CFLAGS="$WARNING_CFLAGS -Wvla") 46 | 47 | dnl Warn for invalid pointer arithmetic 48 | AS_COMPILER_FLAG(-Wpointer-arith, 49 | WARNING_CFLAGS="$WARNING_CFLAGS -Wpointer-arith") 50 | 51 | dnl if asked for, add -Werror if supported 52 | if test "x$1" != "xno" 53 | then 54 | AS_COMPILER_FLAG(-Werror, ERROR_CFLAGS="$ERROR_CFLAGS -Werror") 55 | 56 | dnl if -Werror isn't suported, try -errwarn=%all (Sun Forte case) 57 | if test "x$ERROR_CFLAGS" = "x" 58 | then 59 | AS_COMPILER_FLAG([-errwarn=%all], [ 60 | ERROR_CFLAGS="-errwarn=%all" 61 | dnl try -errwarn=%all,no%E_EMPTY_DECLARATION, 62 | dnl no%E_STATEMENT_NOT_REACHED,no%E_ARGUEMENT_MISMATCH, 63 | dnl no%E_MACRO_REDEFINED (Sun Forte case) 64 | dnl For Forte we need disable "empty declaration" warning produced by un-needed semicolon 65 | dnl "statement not reached" disabled because there is g_assert_not_reached () in some places 66 | dnl "macro redefined" because of gst/gettext.h 67 | dnl FIXME: is it really supposed to be 'ARGUEMENT' and not 'ARGUMENT'? 68 | for f in 'no%E_EMPTY_DECLARATION' \ 69 | 'no%E_STATEMENT_NOT_REACHED' \ 70 | 'no%E_ARGUEMENT_MISMATCH' \ 71 | 'no%E_MACRO_REDEFINED' \ 72 | 'no%E_LOOP_NOT_ENTERED_AT_TOP' 73 | do 74 | AS_COMPILER_FLAG([-errwarn=%all,$f], [ 75 | ERROR_CFLAGS="$ERROR_CFLAGS,$f" 76 | ]) 77 | done 78 | ]) 79 | else 80 | dnl Add -fno-strict-aliasing for GLib versions before 2.19.8 81 | dnl as before G_LOCK and friends caused strict aliasing compiler 82 | dnl warnings. 83 | PKG_CHECK_EXISTS([glib-2.0 < 2.19.8], [ 84 | AS_COMPILER_FLAG(-fno-strict-aliasing, 85 | ERROR_CFLAGS="$ERROR_CFLAGS -fno-strict-aliasing") 86 | ]) 87 | fi 88 | fi 89 | 90 | if test "x$2" != "x" 91 | then 92 | UNSUPPORTED="" 93 | list="$2" 94 | for each in $list 95 | do 96 | AS_COMPILER_FLAG($each, 97 | WARNING_CFLAGS="$WARNING_CFLAGS $each", 98 | UNSUPPORTED="$UNSUPPORTED $each") 99 | done 100 | if test "X$UNSUPPORTED" != X ; then 101 | AC_MSG_NOTICE([unsupported compiler flags: $UNSUPPORTED]) 102 | fi 103 | fi 104 | 105 | AC_SUBST(WARNING_CFLAGS) 106 | AC_SUBST(ERROR_CFLAGS) 107 | AC_MSG_NOTICE([set WARNING_CFLAGS to $WARNING_CFLAGS]) 108 | AC_MSG_NOTICE([set ERROR_CFLAGS to $ERROR_CFLAGS]) 109 | ]) 110 | 111 | dnl Sets WARNING_CXXFLAGS and ERROR_CXXFLAGS to something the compiler 112 | dnl will accept and AC_SUBST them so they are available in Makefile 113 | dnl 114 | dnl WARNING_CXXFLAGS will contain flags to make the compiler emit more 115 | dnl warnings. 116 | dnl ERROR_CXXFLAGS will contain flags to make those warnings fatal, 117 | dnl unless ADD-WERROR is set to "no" 118 | dnl 119 | dnl If MORE_FLAGS is set, tries to add each of the given flags 120 | dnl to WARNING_CFLAGS if the compiler supports them. Each flag is 121 | dnl tested separately. 122 | dnl 123 | dnl These flags can be overridden at make time: 124 | dnl make ERROR_CXXFLAGS= 125 | AC_DEFUN([AG_GST_SET_ERROR_CXXFLAGS], 126 | [ 127 | AC_REQUIRE([AC_PROG_CXX]) 128 | AC_REQUIRE([AS_CXX_COMPILER_FLAG]) 129 | 130 | ERROR_CXXFLAGS="" 131 | WARNING_CXXFLAGS="" 132 | 133 | dnl if we support -Wall, set it unconditionally 134 | AS_CXX_COMPILER_FLAG(-Wall, WARNING_CXXFLAGS="$WARNING_CXXFLAGS -Wall") 135 | 136 | dnl if asked for, add -Werror if supported 137 | if test "x$1" != "xno" 138 | then 139 | AS_CXX_COMPILER_FLAG(-Werror, ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror") 140 | 141 | if test "x$ERROR_CXXFLAGS" != "x" 142 | then 143 | dnl add exceptions 144 | AS_CXX_COMPILER_FLAG([-Wno-non-virtual-dtor], ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Wno-non-virtual-dtor") 145 | 146 | dnl Add -fno-strict-aliasing for GLib versions before 2.19.8 147 | dnl as before G_LOCK and friends caused strict aliasing compiler 148 | dnl warnings. 149 | PKG_CHECK_EXISTS([glib-2.0 < 2.19.8], [ 150 | AS_CXX_COMPILER_FLAG([-fno-strict-aliasing], 151 | ERROR_CXXFLAGS="$ERROR_CXXFLAGS -fno-strict-aliasing") 152 | ]) 153 | else 154 | dnl if -Werror isn't suported, try -errwarn=%all 155 | AS_CXX_COMPILER_FLAG([-errwarn=%all], ERROR_CXXFLAGS="$ERROR_CXXFLAGS -errwarn=%all") 156 | if test "x$ERROR_CXXFLAGS" != "x"; then 157 | dnl try -errwarn=%all,no%E_EMPTY_DECLARATION, 158 | dnl no%E_STATEMENT_NOT_REACHED,no%E_ARGUEMENT_MISMATCH, 159 | dnl no%E_MACRO_REDEFINED (Sun Forte case) 160 | dnl For Forte we need disable "empty declaration" warning produced by un-needed semicolon 161 | dnl "statement not reached" disabled because there is g_assert_not_reached () in some places 162 | dnl "macro redefined" because of gst/gettext.h 163 | dnl FIXME: is it really supposed to be 'ARGUEMENT' and not 'ARGUMENT'? 164 | dnl FIXME: do any of these work with the c++ compiler? if not, why 165 | dnl do we check at all? 166 | for f in 'no%E_EMPTY_DECLARATION' \ 167 | 'no%E_STATEMENT_NOT_REACHED' \ 168 | 'no%E_ARGUEMENT_MISMATCH' \ 169 | 'no%E_MACRO_REDEFINED' \ 170 | 'no%E_LOOP_NOT_ENTERED_AT_TOP' 171 | do 172 | AS_CXX_COMPILER_FLAG([-errwarn=%all,$f], ERROR_CXXFLAGS="$ERROR_CXXFLAGS,$f") 173 | done 174 | fi 175 | fi 176 | fi 177 | 178 | if test "x$2" != "x" 179 | then 180 | UNSUPPORTED="" 181 | list="$2" 182 | for each in $list 183 | do 184 | AS_CXX_COMPILER_FLAG($each, 185 | WARNING_CXXFLAGS="$WARNING_CXXFLAGS $each", 186 | UNSUPPORTED="$UNSUPPORTED $each") 187 | done 188 | if test "X$UNSUPPORTED" != X ; then 189 | AC_MSG_NOTICE([unsupported compiler flags: $UNSUPPORTED]) 190 | fi 191 | fi 192 | 193 | AC_SUBST(WARNING_CXXFLAGS) 194 | AC_SUBST(ERROR_CXXFLAGS) 195 | AC_MSG_NOTICE([set WARNING_CXXFLAGS to $WARNING_CXXFLAGS]) 196 | AC_MSG_NOTICE([set ERROR_CXXFLAGS to $ERROR_CXXFLAGS]) 197 | ]) 198 | 199 | dnl Sets the default error level for debugging messages 200 | AC_DEFUN([AG_GST_SET_LEVEL_DEFAULT], 201 | [ 202 | dnl define correct errorlevel for debugging messages. We want to have 203 | dnl GST_ERROR messages printed when running cvs builds 204 | if test "x[$1]" = "xyes"; then 205 | GST_LEVEL_DEFAULT=GST_LEVEL_ERROR 206 | else 207 | GST_LEVEL_DEFAULT=GST_LEVEL_NONE 208 | fi 209 | AC_DEFINE_UNQUOTED(GST_LEVEL_DEFAULT, $GST_LEVEL_DEFAULT, 210 | [Default errorlevel to use]) 211 | dnl AC_SUBST so we can use it for win32/common/config.h 212 | AC_SUBST(GST_LEVEL_DEFAULT) 213 | ]) 214 | -------------------------------------------------------------------------------- /src/gst_playd.c: -------------------------------------------------------------------------------- 1 | /* 2 | gst_playd - GStreamer backend for Play 3 | 4 | Copyright (C) 2012 Paul Betts 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2, or (at your option) 9 | any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software Foundation, 18 | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #ifdef G_OS_UNIX 30 | #include 31 | #endif 32 | 33 | #include "parser.h" 34 | #include "utility.h" 35 | #include "op_services.h" 36 | 37 | #include "operations/ping.h" 38 | #include "operations/control.h" 39 | #include "operations/play.h" 40 | 41 | #define EXIT_FAILURE 1 42 | 43 | static gboolean verbose = FALSE; 44 | static gboolean pubsub_listen = FALSE; 45 | static char* client_message = NULL; 46 | static int icecast_port = 8000; 47 | 48 | static GOptionEntry entries[] = { 49 | { "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, "Be verbose", NULL }, 50 | { "send-message", 's', 0, G_OPTION_ARG_STRING, &client_message, "Send a message to a running gst_playd and exit", NULL }, 51 | { "events-listen", 'e', 0, G_OPTION_ARG_NONE, &pubsub_listen, "Listen to the event stream of a running gst_playd (for debugging purposes)", NULL }, 52 | { "port", 'p', 0, G_OPTION_ARG_INT, &icecast_port, "Set the port that Icecast will bind to", NULL }, 53 | { NULL }, 54 | }; 55 | 56 | struct timer_closure { 57 | void* zmq_socket; 58 | struct parse_ctx* parse_ctx; 59 | GMainLoop* main_loop; 60 | gboolean should_quit; 61 | gboolean pubsub_mode; 62 | }; 63 | 64 | static struct parser_plugin_entry parser_operations[] = { 65 | { "Ping", NULL, op_ping_new, op_ping_register, op_ping_free }, 66 | { "Control", NULL, op_control_new, op_control_register, op_control_free }, 67 | { "Playback", NULL, op_playback_new, op_playback_register, op_playback_free }, 68 | { NULL }, 69 | }; 70 | 71 | static char* zeromq_address_from_port(const char* address, int port) 72 | { 73 | return g_strdup_printf("tcp://%s:%d", address, port + 10000); 74 | } 75 | 76 | static int handle_message(void* zmq_sock, struct parse_ctx* parser) 77 | { 78 | int ret = 0; 79 | zmq_msg_t msg; 80 | char* message_text = NULL; 81 | 82 | zmq_msg_init(&msg); 83 | if (zmq_msg_recv(&msg, zmq_sock, ZMQ_DONTWAIT) == -1) { 84 | switch (ret = zmq_errno()) { 85 | case EAGAIN: 86 | goto out; 87 | case EINTR: 88 | /* We'll pretend we "succeeded" so we'll look for a new message */ 89 | ret = 0; 90 | goto out; 91 | default: 92 | g_warning("Failed to recieve message: 0x%x (%s)", ret, zmq_strerror(ret)); 93 | goto out; 94 | } 95 | } 96 | 97 | message_text = g_new0(char, zmq_msg_size(&msg) + 1); 98 | memcpy(message_text, zmq_msg_data(&msg), zmq_msg_size(&msg)); 99 | 100 | char* data = parse_message(parser, message_text); 101 | g_warning("About to send reply: %s", data); 102 | 103 | zmq_msg_t rep_msg; 104 | zmq_msg_init_data(&rep_msg, (void*)data, sizeof(char) * strlen(data), util_zmq_glib_free, NULL); 105 | zmq_msg_send(&rep_msg, zmq_sock, 0); 106 | zmq_msg_close(&rep_msg); 107 | 108 | out: 109 | if (message_text) g_free(message_text); 110 | zmq_msg_close(&msg); 111 | return ret; 112 | } 113 | 114 | static int handle_pubsub_message(void* zmq_sock) 115 | { 116 | int ret = 0; 117 | zmq_msg_t msg; 118 | char* message_text = NULL; 119 | 120 | zmq_msg_init(&msg); 121 | if (zmq_msg_recv(&msg, zmq_sock, ZMQ_DONTWAIT) == -1) { 122 | switch (ret = zmq_errno()) { 123 | case EAGAIN: 124 | goto out; 125 | case EINTR: 126 | /* We'll pretend we "succeeded" so we'll look for a new message */ 127 | ret = 0; 128 | goto out; 129 | default: 130 | g_warning("Failed to recieve message: 0x%x (%s)", ret, zmq_strerror(ret)); 131 | goto out; 132 | } 133 | } 134 | 135 | message_text = g_new0(char, zmq_msg_size(&msg) + 1); 136 | memcpy(message_text, zmq_msg_data(&msg), zmq_msg_size(&msg)); 137 | 138 | g_print("%s\n", message_text); 139 | 140 | out: 141 | if (message_text) g_free(message_text); 142 | zmq_msg_close(&msg); 143 | return ret; 144 | } 145 | 146 | static gboolean handle_incoming_messages(gpointer user_data) 147 | { 148 | struct timer_closure* closure = (struct timer_closure*) user_data; 149 | 150 | if (closure->should_quit) { 151 | g_main_loop_quit(closure->main_loop); 152 | return FALSE; 153 | } 154 | 155 | if (closure->pubsub_mode) { 156 | while (handle_pubsub_message(closure->zmq_socket) == 0) { 157 | g_debug("Processing new message"); 158 | } 159 | } else { 160 | while (handle_message(closure->zmq_socket, closure->parse_ctx) == 0) { 161 | g_debug("Processing new message"); 162 | } 163 | } 164 | 165 | return TRUE; 166 | } 167 | 168 | static gboolean handle_sigint(void* shouldquit) 169 | { 170 | gboolean* should_quit = shouldquit; 171 | *should_quit = TRUE; 172 | 173 | return TRUE; 174 | } 175 | 176 | static void* create_server_socket(void* zmq_ctx, int icecast_port) 177 | { 178 | void* sock; 179 | void* ret = NULL; 180 | char* address = zeromq_address_from_port("127.0.0.1", icecast_port); 181 | 182 | int linger = 5*1000; 183 | sock = zmq_socket(zmq_ctx, ZMQ_REP); 184 | 185 | if (!sock) { 186 | g_warning("Failing to create socket %s", zmq_strerror(zmq_errno())); 187 | goto out; 188 | } 189 | 190 | zmq_setsockopt(sock, ZMQ_LINGER, &linger, sizeof(int)); 191 | 192 | if (zmq_bind(sock, address) == -1) { 193 | g_warning("Failed to start server on address %s: %s", address, zmq_strerror(zmq_errno())); 194 | goto out; 195 | } 196 | 197 | ret = sock; 198 | 199 | out: 200 | g_free(address); 201 | return ret; 202 | } 203 | 204 | static void* create_pubsub_socket(void* zmq_ctx, int icecast_port) 205 | { 206 | char* repreq_addr = zeromq_address_from_port("127.0.0.1", icecast_port); 207 | char* pubsub_addr = NULL; 208 | void* ret = NULL; 209 | int linger = 5*1000; 210 | 211 | if (!(pubsub_addr = util_send_reqrep_msg(zmq_ctx, "PUBSUB ", repreq_addr))) { 212 | g_warning("Couldn't connect to %s to get PUB/SUB address.\nCheck to see if the server is down", repreq_addr); 213 | goto out; 214 | } 215 | 216 | if (pubsub_addr[0] != 'O' || pubsub_addr[1] != 'K') { 217 | g_warning("Invalid server response: %s. Maybe versions have changed?", pubsub_addr); 218 | goto out; 219 | } 220 | 221 | g_warning("Connecting to SUB %s", pubsub_addr+3); 222 | ret = zmq_socket(zmq_ctx, ZMQ_SUB); 223 | 224 | if (!ret) { 225 | g_warning("Failing to create socket %s", zmq_strerror(zmq_errno())); 226 | goto out; 227 | } 228 | 229 | zmq_setsockopt(ret, ZMQ_LINGER, &linger, sizeof(int)); 230 | zmq_setsockopt(ret, ZMQ_SUBSCRIBE, NULL, 0); 231 | 232 | if (zmq_connect(ret, pubsub_addr+3) == -1) { 233 | g_warning("Failed to connect to PubSub on address %s: %s", pubsub_addr, zmq_strerror(zmq_errno())); 234 | 235 | ret = NULL; 236 | goto out; 237 | } 238 | 239 | out: 240 | if (pubsub_addr) g_free(pubsub_addr); 241 | g_free(repreq_addr); 242 | return ret; 243 | } 244 | 245 | int main (int argc, char **argv) 246 | { 247 | int ret = 0; 248 | 249 | GError* err = NULL; 250 | GOptionContext* ctx; 251 | 252 | void* zmq_ctx = NULL; 253 | struct op_services services; 254 | 255 | char cwd[4096]; 256 | getcwd(cwd, sizeof(char) * 4096); 257 | setenv("GST_DEBUG_DUMP_DOT_DIR", cwd, 0); 258 | 259 | g_thread_init(NULL); 260 | 261 | ctx = g_option_context_new(" - A GStreamer backend daemon for Play"); 262 | g_option_context_add_main_entries(ctx, entries, ""); 263 | 264 | g_option_context_add_group(ctx, gst_init_get_option_group()); 265 | 266 | if (!g_option_context_parse(ctx, &argc, &argv, &err)) { 267 | g_error("Option parsing failed: %s", err->message); 268 | ret = EXIT_FAILURE; 269 | goto out; 270 | } 271 | 272 | zmq_ctx = zmq_ctx_new(); 273 | 274 | struct timer_closure closure = { NULL, NULL, NULL, FALSE, FALSE, }; 275 | services.should_quit = &closure.should_quit; 276 | 277 | if (client_message) { 278 | char* address = zeromq_address_from_port("127.0.0.1", icecast_port); 279 | char* msg = util_send_reqrep_msg(zmq_ctx, client_message, address); 280 | 281 | if (msg) { 282 | g_print("%s\n", msg); 283 | g_free(msg); 284 | } 285 | 286 | ret = msg ? 0 : 1; 287 | g_free(address); 288 | goto out; 289 | } 290 | 291 | if (pubsub_listen) { 292 | if (!(closure.zmq_socket = create_pubsub_socket(zmq_ctx, icecast_port))) { 293 | goto out; 294 | } 295 | 296 | closure.pubsub_mode = TRUE; 297 | } else { 298 | if (!(services.pub_sub = pubsub_new(zmq_ctx, icecast_port))) { 299 | goto out; 300 | } 301 | 302 | for (struct parser_plugin_entry* pp_entry = parser_operations; pp_entry->friendly_name; pp_entry++) { 303 | pp_entry->context = &services; 304 | } 305 | 306 | struct parse_ctx* parser = parse_new(); 307 | 308 | for (struct parser_plugin_entry* op = parser_operations; op->friendly_name; op++) { 309 | parse_register_plugin(parser, op); 310 | } 311 | 312 | closure.zmq_socket = create_server_socket(zmq_ctx, icecast_port); 313 | closure.parse_ctx = parser; 314 | } 315 | 316 | /* Server Mainloop */ 317 | 318 | GMainLoop* main_loop = g_main_loop_new(NULL, FALSE); 319 | closure.main_loop = main_loop; 320 | 321 | g_timeout_add(250, handle_incoming_messages, &closure); 322 | 323 | #ifdef G_OS_UNIX 324 | g_unix_signal_add(SIGINT, handle_sigint, &closure.should_quit); 325 | g_unix_signal_add(SIGTERM, handle_sigint, &closure.should_quit); 326 | #endif 327 | 328 | g_warning("Starting Main Loop"); 329 | g_main_loop_run(main_loop); 330 | g_warning("Bailing"); 331 | 332 | if (!pubsub_listen) { 333 | parse_free(closure.parse_ctx); 334 | pubsub_free(services.pub_sub); 335 | } 336 | 337 | out: 338 | if (closure.zmq_socket) util_close_socket(closure.zmq_socket); 339 | if (zmq_ctx) zmq_ctx_destroy(zmq_ctx); 340 | 341 | g_option_context_free(ctx); 342 | return ret; 343 | } 344 | -------------------------------------------------------------------------------- /common/m4/gst-feature.m4: -------------------------------------------------------------------------------- 1 | dnl Perform a check for a feature for GStreamer 2 | dnl Richard Boulton 3 | dnl Thomas Vander Stichele added useful stuff 4 | dnl Last modification: 25/06/2001 5 | dnl 6 | dnl AG_GST_CHECK_FEATURE(FEATURE-NAME, FEATURE-DESCRIPTION, 7 | dnl DEPENDENT-PLUGINS, TEST-FOR-FEATURE, 8 | dnl DISABLE-BY-DEFAULT, ACTION-IF-USE, ACTION-IF-NOTUSE) 9 | dnl 10 | dnl This macro adds a command line argument to allow the user to enable 11 | dnl or disable a feature, and if the feature is enabled, performs a supplied 12 | dnl test to check if the feature is available. 13 | dnl 14 | dnl The test should define HAVE_ to "yes" or "no" depending 15 | dnl on whether the feature is available. 16 | dnl 17 | dnl The macro will set USE_ to "yes" or "no" depending on 18 | dnl whether the feature is to be used. 19 | dnl Thomas changed this, so that when USE_ was already set 20 | dnl to no, then it stays that way. 21 | dnl 22 | dnl The macro will call AM_CONDITIONAL(USE_, ...) to allow 23 | dnl the feature to control what is built in Makefile.ams. If you want 24 | dnl additional actions resulting from the test, you can add them with the 25 | dnl ACTION-IF-USE and ACTION-IF-NOTUSE parameters. 26 | dnl 27 | dnl FEATURE-NAME is the name of the feature, and should be in 28 | dnl purely upper case characters. 29 | dnl FEATURE-DESCRIPTION is used to describe the feature in help text for 30 | dnl the command line argument. 31 | dnl DEPENDENT-PLUGINS lists any plug-ins which depend on this feature. 32 | dnl TEST-FOR-FEATURE is a test which sets HAVE_ to "yes" 33 | dnl or "no" depending on whether the feature is 34 | dnl available. 35 | dnl DISABLE-BY-DEFAULT if "disabled", the feature is disabled by default, 36 | dnl if any other value, the feature is enabled by default. 37 | dnl ACTION-IF-USE any extra actions to perform if the feature is to be 38 | dnl used. 39 | dnl ACTION-IF-NOTUSE any extra actions to perform if the feature is not to 40 | dnl be used. 41 | dnl 42 | dnl 43 | dnl thomas : 44 | dnl we also added a history. 45 | dnl GST_PLUGINS_YES will contain all plugins to be built 46 | dnl that were checked through AG_GST_CHECK_FEATURE 47 | dnl GST_PLUGINS_NO will contain those that won't be built 48 | 49 | AC_DEFUN([AG_GST_CHECK_FEATURE], 50 | [echo 51 | AC_MSG_NOTICE(*** checking feature: [$2] ***) 52 | if test "x[$3]" != "x" 53 | then 54 | AC_MSG_NOTICE(*** for plug-ins: [$3] ***) 55 | fi 56 | dnl 57 | builtin(define, [gst_endisable], ifelse($5, [disabled], [enable], [disable]))dnl 58 | dnl if it is set to NO, then don't even consider it for building 59 | NOUSE= 60 | if test "x$USE_[$1]" = "xno"; then 61 | NOUSE="yes" 62 | fi 63 | AC_ARG_ENABLE(translit([$1], A-Z, a-z), 64 | [ ]builtin(format, --%-26s gst_endisable %s, gst_endisable-translit([$1], A-Z, a-z), [$2]ifelse([$3],,,: [$3])), 65 | [ case "${enableval}" in 66 | yes) USE_[$1]=yes;; 67 | no) USE_[$1]=no;; 68 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-translit([$1], A-Z, a-z)) ;; 69 | esac], 70 | [ USE_$1=]ifelse($5, [disabled], [no], [yes])) dnl DEFAULT 71 | 72 | dnl *** set it back to no if it was preset to no 73 | if test "x$NOUSE" = "xyes"; then 74 | USE_[$1]="no" 75 | AC_MSG_WARN(*** $3 pre-configured not to be built) 76 | fi 77 | NOUSE= 78 | 79 | dnl *** If it's enabled 80 | 81 | if test x$USE_[$1] = xyes; then 82 | dnl save compile variables before the test 83 | 84 | gst_check_save_LIBS=$LIBS 85 | gst_check_save_LDFLAGS=$LDFLAGS 86 | gst_check_save_CFLAGS=$CFLAGS 87 | gst_check_save_CPPFLAGS=$CPPFLAGS 88 | gst_check_save_CXXFLAGS=$CXXFLAGS 89 | 90 | HAVE_[$1]=no 91 | dnl TEST_FOR_FEATURE 92 | $4 93 | 94 | LIBS=$gst_check_save_LIBS 95 | LDFLAGS=$gst_check_save_LDFLAGS 96 | CFLAGS=$gst_check_save_CFLAGS 97 | CPPFLAGS=$gst_check_save_CPPFLAGS 98 | CXXFLAGS=$gst_check_save_CXXFLAGS 99 | 100 | dnl If it isn't found, unset USE_[$1] 101 | if test x$HAVE_[$1] = xno; then 102 | USE_[$1]=no 103 | else 104 | ifelse([$3], , :, [AC_MSG_NOTICE(*** These plugins will be built: [$3])]) 105 | fi 106 | fi 107 | dnl *** Warn if it's disabled or not found 108 | if test x$USE_[$1] = xyes; then 109 | ifelse([$6], , :, [$6]) 110 | if test "x$3" != "x"; then 111 | GST_PLUGINS_YES="\t[$3]\n$GST_PLUGINS_YES" 112 | fi 113 | AC_DEFINE(HAVE_[$1], , [Define to enable $2]ifelse($3,,, [ (used by $3)]).) 114 | else 115 | ifelse([$3], , :, [AC_MSG_NOTICE(*** These plugins will not be built: [$3])]) 116 | if test "x$3" != "x"; then 117 | GST_PLUGINS_NO="\t[$3]\n$GST_PLUGINS_NO" 118 | fi 119 | ifelse([$7], , :, [$7]) 120 | fi 121 | dnl *** Define the conditional as appropriate 122 | AM_CONDITIONAL(USE_[$1], test x$USE_[$1] = xyes) 123 | ]) 124 | 125 | dnl Use AC_CHECK_LIB and AC_CHECK_HEADER to do both tests at once 126 | dnl sets HAVE_module if we have it 127 | dnl Richard Boulton 128 | dnl Last modification: 26/06/2001 129 | dnl AG_GST_CHECK_LIBHEADER(FEATURE-NAME, LIB NAME, LIB FUNCTION, EXTRA LD FLAGS, 130 | dnl HEADER NAME, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND) 131 | dnl 132 | dnl This check was written for GStreamer: it should be renamed and checked 133 | dnl for portability if you decide to use it elsewhere. 134 | dnl 135 | AC_DEFUN([AG_GST_CHECK_LIBHEADER], 136 | [ 137 | AC_CHECK_LIB([$2], [$3], HAVE_[$1]=yes, HAVE_[$1]=no,[$4]) 138 | if test "x$HAVE_[$1]" = "xyes"; then 139 | AC_CHECK_HEADER([$5], :, HAVE_[$1]=no) 140 | if test "x$HAVE_[$1]" = "xyes"; then 141 | dnl execute what needs to be 142 | ifelse([$6], , :, [$6]) 143 | else 144 | ifelse([$7], , :, [$7]) 145 | fi 146 | else 147 | ifelse([$7], , :, [$7]) 148 | fi 149 | AC_SUBST(HAVE_[$1]) 150 | ] 151 | ) 152 | 153 | dnl 2004-02-14 Thomas - changed to get set properly and use proper output 154 | dnl 2003-06-27 Benjamin Otte - changed to make this work with gstconfig.h 155 | dnl 156 | dnl Add a subsystem --disable flag and all the necessary symbols and substitions 157 | dnl 158 | dnl AG_GST_CHECK_SUBSYSTEM_DISABLE(SYSNAME, [subsystem name]) 159 | dnl 160 | AC_DEFUN([AG_GST_CHECK_SUBSYSTEM_DISABLE], 161 | [ 162 | dnl this define will replace each literal subsys_def occurrence with 163 | dnl the lowercase hyphen-separated subsystem 164 | dnl e.g. if $1 is GST_DEBUG then subsys_def will be a macro with gst-debug 165 | define([subsys_def],translit([$1], _A-Z, -a-z)) 166 | 167 | AC_ARG_ENABLE(subsys_def, 168 | AC_HELP_STRING(--disable-subsys_def, [disable $2]), 169 | [ 170 | case "${enableval}" in 171 | yes) GST_DISABLE_[$1]=no ;; 172 | no) GST_DISABLE_[$1]=yes ;; 173 | *) AC_MSG_ERROR([bad value ${enableval} for --enable-subsys_def]) ;; 174 | esac 175 | ], 176 | [GST_DISABLE_[$1]=no]) dnl Default value 177 | 178 | if test x$GST_DISABLE_[$1] = xyes; then 179 | AC_MSG_NOTICE([disabled subsystem [$2]]) 180 | GST_DISABLE_[$1]_DEFINE="#define GST_DISABLE_$1 1" 181 | else 182 | GST_DISABLE_[$1]_DEFINE="/* #undef GST_DISABLE_$1 */" 183 | fi 184 | AC_SUBST(GST_DISABLE_[$1]_DEFINE) 185 | undefine([subsys_def]) 186 | ]) 187 | 188 | 189 | dnl Parse gstconfig.h for feature and defines add the symbols and substitions 190 | dnl 191 | dnl AG_GST_PARSE_SUBSYSTEM_DISABLE(GST_CONFIGPATH, FEATURE) 192 | dnl 193 | AC_DEFUN([AG_GST_PARSE_SUBSYSTEM_DISABLE], 194 | [ 195 | grep >/dev/null "#undef GST_DISABLE_$2" $1 196 | if test $? = 0; then 197 | GST_DISABLE_[$2]=0 198 | else 199 | GST_DISABLE_[$2]=1 200 | fi 201 | AC_SUBST(GST_DISABLE_[$2]) 202 | ]) 203 | 204 | dnl Parse gstconfig.h and defines add the symbols and substitions 205 | dnl 206 | dnl GST_CONFIGPATH=`$PKG_CONFIG --variable=includedir gstreamer-0.10`"/gst/gstconfig.h" 207 | dnl AG_GST_PARSE_SUBSYSTEM_DISABLES(GST_CONFIGPATH) 208 | dnl 209 | AC_DEFUN([AG_GST_PARSE_SUBSYSTEM_DISABLES], 210 | [ 211 | AG_GST_PARSE_SUBSYSTEM_DISABLE($1,GST_DEBUG) 212 | AG_GST_PARSE_SUBSYSTEM_DISABLE($1,LOADSAVE) 213 | AG_GST_PARSE_SUBSYSTEM_DISABLE($1,PARSE) 214 | AG_GST_PARSE_SUBSYSTEM_DISABLE($1,TRACE) 215 | AG_GST_PARSE_SUBSYSTEM_DISABLE($1,ALLOC_TRACE) 216 | AG_GST_PARSE_SUBSYSTEM_DISABLE($1,REGISTRY) 217 | AG_GST_PARSE_SUBSYSTEM_DISABLE($1,PLUGIN) 218 | AG_GST_PARSE_SUBSYSTEM_DISABLE($1,XML) 219 | ]) 220 | 221 | dnl AG_GST_CHECK_GST_DEBUG_DISABLED(ACTION-IF-DISABLED, ACTION-IF-NOT-DISABLED) 222 | dnl 223 | dnl Checks if the GStreamer debugging system is disabled in the core version 224 | dnl we are compiling against (by checking gstconfig.h) 225 | dnl 226 | AC_DEFUN([AG_GST_CHECK_GST_DEBUG_DISABLED], 227 | [ 228 | AC_REQUIRE([AG_GST_CHECK_GST]) 229 | 230 | AC_MSG_CHECKING([whether the GStreamer debugging system is enabled]) 231 | AC_LANG_PUSH([C]) 232 | save_CFLAGS="$CFLAGS" 233 | CFLAGS="$GST_CFLAGS $CFLAGS" 234 | AC_COMPILE_IFELSE([ 235 | #include 236 | #ifdef GST_DISABLE_GST_DEBUG 237 | #error "debugging disabled, make compiler fail" 238 | #endif], [ debug_system_enabled=yes], [debug_system_enabled=no]) 239 | CFLAGS="$save_CFLAGS" 240 | AC_LANG_POP([C]) 241 | 242 | AC_MSG_RESULT([$debug_system_enabled]) 243 | 244 | if test "x$debug_system_enabled" = "xyes" ; then 245 | $2 246 | true 247 | else 248 | $1 249 | true 250 | fi 251 | ]) 252 | 253 | dnl relies on GST_PLUGINS_ALL, GST_PLUGINS_SELECTED, GST_PLUGINS_YES, 254 | dnl GST_PLUGINS_NO, and BUILD_EXTERNAL 255 | AC_DEFUN([AG_GST_OUTPUT_PLUGINS], [ 256 | 257 | printf "configure: *** Plug-ins without external dependencies that will be built:\n" 258 | ( for i in $GST_PLUGINS_SELECTED; do printf '\t'$i'\n'; done ) | sort 259 | printf "\n" 260 | 261 | printf "configure: *** Plug-ins without external dependencies that will NOT be built:\n" 262 | ( for i in $GST_PLUGINS_ALL; do 263 | case " $GST_PLUGINS_SELECTED " in 264 | *\ $i\ *) 265 | ;; 266 | *) 267 | printf '\t'$i'\n' 268 | ;; 269 | esac 270 | done ) | sort 271 | printf "\n" 272 | 273 | if test "x$BUILD_EXTERNAL" = "xno"; then 274 | printf "configure: *** No plug-ins with external dependencies will be built\n" 275 | else 276 | printf "configure: *** Plug-ins with dependencies that will be built:" 277 | printf "$GST_PLUGINS_YES\n" | sort 278 | printf "\n" 279 | printf "configure: *** Plug-ins with dependencies that will NOT be built:" 280 | printf "$GST_PLUGINS_NO\n" | sort 281 | printf "\n" 282 | fi 283 | ]) 284 | 285 | -------------------------------------------------------------------------------- /src/operations/play.c: -------------------------------------------------------------------------------- 1 | /* 2 | play.c - Play pipeline message handlers 3 | 4 | Copyright (C) 2012 Paul Betts 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2, or (at your option) 9 | any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software Foundation, 18 | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | #include 22 | #include 23 | 24 | #include "parser.h" 25 | #include "utility.h" 26 | #include "gst-util.h" 27 | #include "op_services.h" 28 | 29 | #include "operations/play.h" 30 | 31 | static struct message_dispatch_entry playback_messages[] = { 32 | { "TAGS", op_tags_parse }, 33 | { "PLAY", op_play_parse }, 34 | { "STOP", op_stop_parse }, 35 | { "DUMPGRAPH", op_dumpgraph_parse }, 36 | { NULL }, 37 | }; 38 | 39 | struct source_item { 40 | char* uri; 41 | GDateTime* created_at; 42 | 43 | GstElement* element; 44 | GstElement* ac; 45 | }; 46 | 47 | struct playback_ctx { 48 | struct op_services* services; 49 | GstElement* pipeline; 50 | 51 | GstElement* mux; 52 | GstElement* audio_sink; 53 | 54 | GSList* sources; 55 | }; 56 | 57 | 58 | static void on_new_source_pad_link(GstElement* src, GstPad* pad, GstElement* mux) 59 | { 60 | if (!gst_element_link(src, mux)) { 61 | g_error("Couldn't link source to mux"); 62 | } 63 | } 64 | 65 | static struct source_item* source_new_and_link(const char* uri, GstElement* pipeline, GstElement* mux) 66 | { 67 | struct source_item* ret = g_new0(struct source_item, 1); 68 | 69 | ret->uri = strdup(uri); 70 | ret->created_at = g_date_time_new_now_utc(); 71 | ret->element = gst_element_factory_make("uridecodebin", NULL); 72 | 73 | ret->ac = gst_element_factory_make("audioconvert", NULL); 74 | gst_bin_add(GST_BIN(pipeline), ret->ac); 75 | gst_element_link(ret->ac, mux); 76 | 77 | gst_bin_add(GST_BIN(pipeline), ret->element); 78 | g_object_set(ret->element, "uri", uri, NULL); 79 | g_signal_connect(ret->element, "pad-added", G_CALLBACK(on_new_source_pad_link), ret->ac); 80 | 81 | GstState current, pending; 82 | gst_element_get_state(pipeline, ¤t, &pending, 0); 83 | 84 | GstElement* target = ret->element; 85 | if (pending != GST_STATE_PLAYING && current != GST_STATE_PLAYING) { 86 | target = pipeline; 87 | } 88 | 89 | if (gst_element_set_state(target, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE) { 90 | g_error("Couldn't move element state to PLAYING"); 91 | } 92 | 93 | return ret; 94 | } 95 | 96 | static void source_free_and_unlink(struct source_item* item, GstElement* pipeline, GstElement* mux) 97 | { 98 | if (gst_element_set_state(item->element, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE) { 99 | g_error("Couldn't move element state to READY"); 100 | } 101 | 102 | /* NB: If we simply unlink element, ac, and mux, we'll leave behind a 103 | * request sink on the mux where the source used to be. Since we're 104 | * playing, this will cause us to fault out and playback to stop. 105 | * 106 | * So here, we grab the mux's request pad via the audioconvert source, 107 | * then remove it after we do the unlink. */ 108 | GstPad* ac_src = gst_element_get_static_pad(item->ac, "src"); 109 | GstPad* mux_sink = gst_pad_get_peer(ac_src); 110 | 111 | gst_element_unlink_many(item->element, item->ac, mux, NULL); 112 | 113 | gst_element_release_request_pad(mux, mux_sink); 114 | 115 | gst_bin_remove(GST_BIN(pipeline), item->element); 116 | gst_bin_remove(GST_BIN(pipeline), item->ac); 117 | 118 | g_date_time_unref(item->created_at); 119 | g_free(item->uri); 120 | g_free(item); 121 | } 122 | 123 | static guint source_item_to_id(struct source_item* item) 124 | { 125 | char to_hash[2048]; 126 | sprintf(to_hash, "%s 0x%p %lu", item->uri, item, g_date_time_to_unix(item->created_at)); 127 | 128 | return g_str_hash(to_hash); 129 | } 130 | 131 | static struct source_item* source_item_from_id(GSList* item_list, guint id) 132 | { 133 | GSList* haystack = item_list; 134 | 135 | while (haystack) { 136 | struct source_item* needle = haystack->data; 137 | if (source_item_to_id(needle) == id) { 138 | return needle; 139 | } 140 | 141 | haystack = g_slist_next(haystack); 142 | } 143 | 144 | return NULL; 145 | } 146 | 147 | static gboolean playback_bus_callback(GstBus* bus, GstMessage* message, gpointer userdata) 148 | { 149 | struct playback_ctx* ctx = userdata; 150 | 151 | GError* err = NULL; 152 | char* prefix = NULL; 153 | 154 | g_warning ("Got pipeline bus message of type %s", GST_MESSAGE_TYPE_NAME(message)); 155 | switch (GST_MESSAGE_TYPE(message)) { 156 | case GST_MESSAGE_ERROR: 157 | prefix = "ERROR"; 158 | gst_message_parse_error(message, &err, NULL); 159 | break; 160 | case GST_MESSAGE_WARNING: 161 | prefix = "WARNING"; 162 | gst_message_parse_warning(message, &err, NULL); 163 | break; 164 | case GST_MESSAGE_INFO: 165 | prefix = "INFO"; 166 | gst_message_parse_info(message, &err, NULL); 167 | break; 168 | default: 169 | return TRUE; 170 | } 171 | 172 | char* msg = g_strdup_printf("%s: %s", prefix, err->message); 173 | g_warning("Writing message to bus: %s", msg); 174 | pubsub_send_message(ctx->services->pub_sub, msg); 175 | 176 | return TRUE; 177 | } 178 | 179 | void* op_playback_new(void* op_services) 180 | { 181 | GError* error = NULL; 182 | struct playback_ctx* ret = g_new0(struct playback_ctx, 1); 183 | 184 | ret->services = op_services; 185 | if (!(ret->audio_sink = gst_element_factory_make("osxaudiosink", NULL))) { 186 | g_error("Couldn't create audio sink: %s", error->message); 187 | return NULL; 188 | } 189 | 190 | if (!(ret->mux = gst_element_factory_make("adder", NULL))) { 191 | g_error("Couldn't create mixer"); 192 | return NULL; 193 | } 194 | 195 | ret->pipeline = gst_pipeline_new("pipeline"); 196 | 197 | GstElement* ac = gst_element_factory_make("audioconvert", NULL); 198 | gst_bin_add_many(GST_BIN_CAST(ret->pipeline), ret->mux, ac, ret->audio_sink, NULL); 199 | 200 | if (!(gst_element_link_many(ret->mux, ac, ret->audio_sink, NULL))) { 201 | g_error("Couldn't link mux"); 202 | return NULL; 203 | } 204 | 205 | GstBus* bus = gst_pipeline_get_bus(GST_PIPELINE(ret->pipeline)); 206 | gst_bus_add_watch(bus, playback_bus_callback, ret); 207 | gst_object_unref(bus); 208 | 209 | return ret; 210 | } 211 | 212 | gboolean op_playback_register(void* ctx, struct message_dispatch_entry** entries) 213 | { 214 | if (!ctx) { 215 | return FALSE; 216 | } 217 | 218 | *entries = playback_messages; 219 | return TRUE; 220 | } 221 | 222 | void op_playback_free(void* ctx) 223 | { 224 | struct playback_ctx* context = (struct playback_ctx*)ctx; 225 | GSList* iter = context->sources; 226 | 227 | while (iter) { 228 | source_free_and_unlink((struct source_item*)iter->data, context->pipeline, context->mux); 229 | iter = g_slist_next(iter); 230 | } 231 | 232 | gst_element_set_state(context->pipeline, GST_STATE_READY); 233 | g_object_unref(GST_OBJECT(context->pipeline)); 234 | 235 | g_slist_free(context->sources); 236 | g_free(context); 237 | } 238 | 239 | static void on_new_pad_tags(GstElement* dec, GstPad* pad, GstElement* fakesink) 240 | { 241 | GstPad *sinkpad; 242 | 243 | sinkpad = gst_element_get_static_pad(fakesink, "sink"); 244 | 245 | if (!gst_pad_is_linked (sinkpad)) { 246 | if (gst_pad_link(pad, sinkpad) != GST_PAD_LINK_OK) { 247 | g_error("Failed to link pads!"); 248 | } 249 | } 250 | 251 | gst_object_unref (sinkpad); 252 | } 253 | 254 | char* op_tags_parse(const char* param, void* ctx) 255 | { 256 | GstElement* pipe; 257 | GstElement* dec; 258 | GstElement* sink; 259 | 260 | GstMessage* msg; 261 | char* ret = NULL; 262 | 263 | pipe = gst_pipeline_new("pipeline"); 264 | dec = gst_element_factory_make("uridecodebin", NULL); 265 | 266 | g_object_set(dec, "uri", param, NULL); 267 | 268 | gst_bin_add (GST_BIN (pipe), dec); 269 | sink = gst_element_factory_make("fakesink", NULL); gst_bin_add (GST_BIN (pipe), sink); 270 | g_signal_connect(dec, "pad-added", G_CALLBACK (on_new_pad_tags), sink); 271 | 272 | gst_element_set_state(pipe, GST_STATE_PAUSED); 273 | 274 | GHashTable* tag_table = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); 275 | 276 | while (TRUE) { 277 | GstTagList *tags = NULL; 278 | 279 | msg = gst_bus_timed_pop_filtered(GST_ELEMENT_BUS (pipe), GST_CLOCK_TIME_NONE, 280 | GST_MESSAGE_ASYNC_DONE | GST_MESSAGE_TAG | GST_MESSAGE_ERROR); 281 | 282 | if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR) { 283 | GError* error = NULL; 284 | gst_message_parse_error(msg, &error, NULL); 285 | ret = g_strdup_printf("FAIL %s", error->message); 286 | break; 287 | } 288 | 289 | /* error or async_done */ 290 | if (GST_MESSAGE_TYPE (msg) != GST_MESSAGE_TAG) { 291 | break; 292 | } 293 | 294 | gst_message_parse_tag(msg, &tags); 295 | gsu_tags_to_hash_table(tags, tag_table); 296 | 297 | gst_tag_list_free(tags); 298 | gst_message_unref(msg); 299 | } 300 | 301 | if (!ret || g_hash_table_size(tag_table) > 0) { 302 | if (ret) g_free(ret); 303 | 304 | char* table_data = util_hash_table_as_string(tag_table); 305 | ret = g_strdup_printf("OK\n%s", table_data); 306 | g_free(table_data); 307 | } 308 | 309 | g_hash_table_destroy(tag_table); 310 | return ret; 311 | } 312 | 313 | char* op_play_parse(const char* param, void* ctx) 314 | { 315 | struct playback_ctx* context = (struct playback_ctx*)ctx; 316 | 317 | struct source_item* to_add; 318 | if (!(to_add = source_new_and_link(param, context->pipeline, context->mux))) { 319 | return g_strdup_printf("FAIL Can't load source: %s", param); 320 | } 321 | 322 | context->sources = g_slist_prepend(context->sources, to_add); 323 | return g_strdup_printf("OK player id: %u", source_item_to_id(to_add)); 324 | } 325 | 326 | char* op_stop_parse(const char* param, void* ctx) 327 | { 328 | struct playback_ctx* context = (struct playback_ctx*)ctx; 329 | 330 | guint id = (guint) atoll(param); 331 | struct source_item* to_remove = source_item_from_id(context->sources, id); 332 | 333 | if (!to_remove) { 334 | return strdup("FAIL id is invalid"); 335 | } 336 | 337 | context->sources = g_slist_remove(context->sources, to_remove); 338 | 339 | source_free_and_unlink(to_remove, context->pipeline, context->mux); 340 | return g_strdup_printf("OK player id: %u", id); 341 | } 342 | 343 | char* op_dumpgraph_parse(const char* param, void* ctx) 344 | { 345 | struct playback_ctx* context = (struct playback_ctx*)ctx; 346 | 347 | GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS(GST_BIN(context->pipeline), GST_DEBUG_GRAPH_SHOW_ALL, param); 348 | return strdup("OK"); 349 | } 350 | -------------------------------------------------------------------------------- /common/m4/gst-check.m4: -------------------------------------------------------------------------------- 1 | dnl pkg-config-based checks for GStreamer modules and dependency modules 2 | 3 | dnl generic: 4 | dnl AG_GST_PKG_CHECK_MODULES([PREFIX], [WHICH], [REQUIRED]) 5 | dnl sets HAVE_[$PREFIX], [$PREFIX]_* 6 | dnl AG_GST_CHECK_MODULES([PREFIX], [MODULE], [MINVER], [NAME], [REQUIRED]) 7 | dnl sets HAVE_[$PREFIX], [$PREFIX]_* 8 | 9 | dnl specific: 10 | dnl AG_GST_CHECK_GST([MAJMIN], [MINVER], [REQUIRED]) 11 | dnl also sets/ACSUBSTs GST_TOOLS_DIR and GST_PLUGINS_DIR 12 | dnl AG_GST_CHECK_GST_BASE([MAJMIN], [MINVER], [REQUIRED]) 13 | dnl AG_GST_CHECK_GST_GDP([MAJMIN], [MINVER], [REQUIRED]) 14 | dnl AG_GST_CHECK_GST_CONTROLLER([MAJMIN], [MINVER], [REQUIRED]) 15 | dnl AG_GST_CHECK_GST_CHECK([MAJMIN], [MINVER], [REQUIRED]) 16 | dnl AG_GST_CHECK_GST_PLUGINS_BASE([MAJMIN], [MINVER], [REQUIRED]) 17 | dnl also sets/ACSUBSTs GSTPB_PLUGINS_DIR 18 | 19 | AC_DEFUN([AG_GST_PKG_CHECK_MODULES], 20 | [ 21 | which="[$2]" 22 | dnl not required by default, since we use this mostly for plugin deps 23 | required=ifelse([$3], , "no", [$3]) 24 | 25 | PKG_CHECK_MODULES([$1], $which, 26 | [ 27 | HAVE_[$1]="yes" 28 | ], 29 | [ 30 | HAVE_[$1]="no" 31 | if test "x$required" = "xyes"; then 32 | AC_MSG_ERROR($[$1]_PKG_ERRORS) 33 | else 34 | AC_MSG_NOTICE($[$1]_PKG_ERRORS) 35 | fi 36 | ]) 37 | 38 | dnl AC_SUBST of CFLAGS and LIBS was not done before automake 1.7 39 | dnl It gets done automatically in automake >= 1.7, which we now require 40 | ])) 41 | 42 | AC_DEFUN([AG_GST_CHECK_MODULES], 43 | [ 44 | module=[$2] 45 | minver=[$3] 46 | name="[$4]" 47 | required=ifelse([$5], , "yes", [$5]) dnl required by default 48 | 49 | PKG_CHECK_MODULES([$1], $module >= $minver, 50 | [ 51 | HAVE_[$1]="yes" 52 | ], 53 | [ 54 | HAVE_[$1]="no" 55 | AC_MSG_NOTICE($[$1]_PKG_ERRORS) 56 | if test "x$required" = "xyes"; then 57 | AC_MSG_ERROR([no $module >= $minver ($name) found]) 58 | else 59 | AC_MSG_NOTICE([no $module >= $minver ($name) found]) 60 | fi 61 | ]) 62 | 63 | dnl AC_SUBST of CFLAGS and LIBS was not done before automake 1.7 64 | dnl It gets done automatically in automake >= 1.7, which we now require 65 | ])) 66 | 67 | AC_DEFUN([AG_GST_CHECK_GST], 68 | [ 69 | AG_GST_CHECK_MODULES(GST, gstreamer-[$1], [$2], [GStreamer], [$3]) 70 | dnl allow setting before calling this macro to override 71 | if test -z $GST_TOOLS_DIR; then 72 | GST_TOOLS_DIR=`$PKG_CONFIG --variable=toolsdir gstreamer-[$1]` 73 | if test -z $GST_TOOLS_DIR; then 74 | AC_MSG_ERROR( 75 | [no tools dir set in GStreamer pkg-config file, core upgrade needed.]) 76 | fi 77 | fi 78 | AC_MSG_NOTICE([using GStreamer tools in $GST_TOOLS_DIR]) 79 | AC_SUBST(GST_TOOLS_DIR) 80 | 81 | dnl check for where core plug-ins got installed 82 | dnl this is used for unit tests 83 | dnl allow setting before calling this macro to override 84 | if test -z $GST_PLUGINS_DIR; then 85 | GST_PLUGINS_DIR=`$PKG_CONFIG --variable=pluginsdir gstreamer-[$1]` 86 | if test -z $GST_PLUGINS_DIR; then 87 | AC_MSG_ERROR( 88 | [no pluginsdir set in GStreamer pkg-config file, core upgrade needed.]) 89 | fi 90 | fi 91 | AC_MSG_NOTICE([using GStreamer plug-ins in $GST_PLUGINS_DIR]) 92 | AC_SUBST(GST_PLUGINS_DIR) 93 | ]) 94 | 95 | AC_DEFUN([AG_GST_CHECK_GST_BASE], 96 | [ 97 | AG_GST_CHECK_MODULES(GST_BASE, gstreamer-base-[$1], [$2], 98 | [GStreamer Base Libraries], [$3]) 99 | ]) 100 | 101 | AC_DEFUN([AG_GST_CHECK_GST_GDP], 102 | [ 103 | AG_GST_CHECK_MODULES(GST_GDP, gstreamer-dataprotocol-[$1], [$2], 104 | [GStreamer Data Protocol Library], [$3]) 105 | ]) 106 | 107 | AC_DEFUN([AG_GST_CHECK_GST_CONTROLLER], 108 | [ 109 | AG_GST_CHECK_MODULES(GST_CONTROLLER, gstreamer-controller-[$1], [$2], 110 | [GStreamer Controller Library], [$3]) 111 | ]) 112 | 113 | AC_DEFUN([AG_GST_CHECK_GST_CHECK], 114 | [ 115 | AG_GST_CHECK_MODULES(GST_CHECK, gstreamer-check-[$1], [$2], 116 | [GStreamer Check unittest Library], [$3]) 117 | ]) 118 | 119 | dnl =========================================================================== 120 | dnl AG_GST_CHECK_GST_PLUGINS_BASE([GST-MAJORMINOR], [MIN-VERSION], [REQUIRED]) 121 | dnl 122 | dnl Sets GST_PLUGINS_BASE_CFLAGS and GST_PLUGINS_BASE_LIBS. 123 | dnl 124 | dnl Also sets GSTPB_PLUGINS_DIR (and for consistency also GST_PLUGINS_BASE_DIR) 125 | dnl for use in Makefile.am. This is only really needed/useful in uninstalled 126 | dnl setups, since in an installed setup all plugins will be found in 127 | dnl GST_PLUGINS_DIR anyway. 128 | dnl =========================================================================== 129 | AC_DEFUN([AG_GST_CHECK_GST_PLUGINS_BASE], 130 | [ 131 | AG_GST_CHECK_MODULES(GST_PLUGINS_BASE, gstreamer-plugins-base-[$1], [$2], 132 | [GStreamer Base Plugins], [$3]) 133 | 134 | if test "x$HAVE_GST_PLUGINS_BASE" = "xyes"; then 135 | dnl check for where base plugins got installed 136 | dnl this is used for unit tests 137 | dnl allow setting before calling this macro to override 138 | if test -z $GSTPB_PLUGINS_DIR; then 139 | GSTPB_PLUGINS_DIR=`$PKG_CONFIG --variable=pluginsdir gstreamer-plugins-base-[$1]` 140 | if test -z $GSTPB_PLUGINS_DIR; then 141 | AC_MSG_ERROR( 142 | [no pluginsdir set in GStreamer Base Plugins pkg-config file]) 143 | fi 144 | fi 145 | AC_MSG_NOTICE([using GStreamer Base Plugins in $GSTPB_PLUGINS_DIR]) 146 | GST_PLUGINS_BASE_DIR="$GSTPB_PLUGINS_DIR/gst:$GSTPB_PLUGINS_DIR/sys:$GSTPB_PLUGINS_DIR/ext" 147 | AC_SUBST(GST_PLUGINS_BASE_DIR) 148 | AC_SUBST(GSTPB_PLUGINS_DIR) 149 | fi 150 | ]) 151 | 152 | dnl =========================================================================== 153 | dnl AG_GST_CHECK_GST_PLUGINS_GOOD([GST-MAJORMINOR], [MIN-VERSION]) 154 | dnl 155 | dnl Will set GST_PLUGINS_GOOD_DIR for use in Makefile.am. Note that this will 156 | dnl only be set in an uninstalled setup, since -good ships no .pc file and in 157 | dnl an installed setup all plugins will be found in GST_PLUGINS_DIR anyway. 158 | dnl =========================================================================== 159 | AC_DEFUN([AG_GST_CHECK_GST_PLUGINS_GOOD], 160 | [ 161 | AG_GST_CHECK_MODULES(GST_PLUGINS_GOOD, gstreamer-plugins-good-[$1], [$2], 162 | [GStreamer Good Plugins], [no]) 163 | 164 | if test "x$HAVE_GST_PLUGINS_GOOD" = "xyes"; then 165 | dnl check for where good plugins got installed 166 | dnl this is used for unit tests 167 | dnl allow setting before calling this macro to override 168 | if test -z $GST_PLUGINS_GOOD_DIR; then 169 | GST_PLUGINS_GOOD_DIR=`$PKG_CONFIG --variable=pluginsdir gstreamer-plugins-good-[$1]` 170 | if test -z $GST_PLUGINS_GOOD_DIR; then 171 | AC_MSG_ERROR([no pluginsdir set in GStreamer Good Plugins pkg-config file]) 172 | fi 173 | fi 174 | AC_MSG_NOTICE([using GStreamer Good Plugins in $GST_PLUGINS_GOOD_DIR]) 175 | GST_PLUGINS_GOOD_DIR="$GST_PLUGINS_GOOD_DIR/gst:$GST_PLUGINS_GOOD_DIR/sys:$GST_PLUGINS_GOOD_DIR/ext" 176 | AC_SUBST(GST_PLUGINS_GOOD_DIR) 177 | fi 178 | ]) 179 | 180 | dnl =========================================================================== 181 | dnl AG_GST_CHECK_GST_PLUGINS_UGLY([GST-MAJORMINOR], [MIN-VERSION]) 182 | dnl 183 | dnl Will set GST_PLUGINS_UGLY_DIR for use in Makefile.am. Note that this will 184 | dnl only be set in an uninstalled setup, since -bad ships no .pc file and in 185 | dnl an installed setup all plugins will be found in GST_PLUGINS_DIR anyway. 186 | dnl =========================================================================== 187 | AC_DEFUN([AG_GST_CHECK_GST_PLUGINS_UGLY], 188 | [ 189 | AG_GST_CHECK_MODULES(GST_PLUGINS_UGLY, gstreamer-plugins-ugly-[$1], [$2], 190 | [GStreamer Ugly Plugins], [no]) 191 | 192 | if test "x$HAVE_GST_PLUGINS_UGLY" = "xyes"; then 193 | dnl check for where ugly plugins got installed 194 | dnl this is used for unit tests 195 | dnl allow setting before calling this macro to override 196 | if test -z $GST_PLUGINS_UGLY_DIR; then 197 | GST_PLUGINS_UGLY_DIR=`$PKG_CONFIG --variable=pluginsdir gstreamer-plugins-ugly-[$1]` 198 | if test -z $GST_PLUGINS_UGLY_DIR; then 199 | AC_MSG_ERROR([no pluginsdir set in GStreamer Ugly Plugins pkg-config file]) 200 | fi 201 | fi 202 | AC_MSG_NOTICE([using GStreamer Ugly Plugins in $GST_PLUGINS_UGLY_DIR]) 203 | GST_PLUGINS_UGLY_DIR="$GST_PLUGINS_UGLY_DIR/gst:$GST_PLUGINS_UGLY_DIR/sys:$GST_PLUGINS_UGLY_DIR/ext" 204 | AC_SUBST(GST_PLUGINS_UGLY_DIR) 205 | fi 206 | ]) 207 | 208 | dnl =========================================================================== 209 | dnl AG_GST_CHECK_GST_PLUGINS_BAD([GST-MAJORMINOR], [MIN-VERSION]) 210 | dnl 211 | dnl Will set GST_PLUGINS_BAD_DIR for use in Makefile.am. Note that this will 212 | dnl only be set in an uninstalled setup, since -ugly ships no .pc file and in 213 | dnl an installed setup all plugins will be found in GST_PLUGINS_DIR anyway. 214 | dnl =========================================================================== 215 | AC_DEFUN([AG_GST_CHECK_GST_PLUGINS_BAD], 216 | [ 217 | AG_GST_CHECK_MODULES(GST_PLUGINS_BAD, gstreamer-plugins-bad-[$1], [$2], 218 | [GStreamer Bad Plugins], [no]) 219 | 220 | if test "x$HAVE_GST_PLUGINS_BAD" = "xyes"; then 221 | dnl check for where bad plugins got installed 222 | dnl this is used for unit tests 223 | dnl allow setting before calling this macro to override 224 | if test -z $GST_PLUGINS_BAD_DIR; then 225 | GST_PLUGINS_BAD_DIR=`$PKG_CONFIG --variable=pluginsdir gstreamer-plugins-bad-[$1]` 226 | if test -z $GST_PLUGINS_BAD_DIR; then 227 | AC_MSG_ERROR([no pluginsdir set in GStreamer Bad Plugins pkg-config file]) 228 | fi 229 | fi 230 | AC_MSG_NOTICE([using GStreamer Bad Plugins in $GST_PLUGINS_BAD_DIR]) 231 | GST_PLUGINS_BAD_DIR="$GST_PLUGINS_BAD_DIR/gst:$GST_PLUGINS_BAD_DIR/sys:$GST_PLUGINS_BAD_DIR/ext" 232 | AC_SUBST(GST_PLUGINS_BAD_DIR) 233 | fi 234 | ]) 235 | 236 | dnl =========================================================================== 237 | dnl AG_GST_CHECK_GST_PLUGINS_FFMPEG([GST-MAJORMINOR], [MIN-VERSION]) 238 | dnl 239 | dnl Will set GST_PLUGINS_FFMPEG_DIR for use in Makefile.am. Note that this will 240 | dnl only be set in an uninstalled setup, since -ffmpeg ships no .pc file and in 241 | dnl an installed setup all plugins will be found in GST_PLUGINS_DIR anyway. 242 | dnl =========================================================================== 243 | AC_DEFUN([AG_GST_CHECK_GST_PLUGINS_FFMPEG], 244 | [ 245 | AG_GST_CHECK_MODULES(GST_PLUGINS_FFMPEG, gstreamer-plugins-ffmpeg-[$1], [$2], 246 | [GStreamer FFmpeg Plugins], [no]) 247 | 248 | if test "x$HAVE_GST_PLUGINS_FFMPEG" = "xyes"; then 249 | dnl check for where ffmpeg plugins got installed 250 | dnl this is used for unit tests 251 | dnl allow setting before calling this macro to override 252 | if test -z $GST_PLUGINS_FFMPEG_DIR; then 253 | GST_PLUGINS_FFMPEG_DIR=`$PKG_CONFIG --variable=pluginsdir gstreamer-plugins-ffmpeg-[$1]` 254 | if test -z $GST_PLUGINS_FFMPEG_DIR; then 255 | AC_MSG_ERROR([no pluginsdir set in GStreamer FFmpeg Plugins pkg-config file]) 256 | fi 257 | fi 258 | GST_PLUGINS_FFMPEG_DIR="$GST_PLUGINS_FFMPEG_DIR/ext/ffmpeg" 259 | AC_MSG_NOTICE([using GStreamer FFmpeg Plugins in $GST_PLUGINS_FFMPEG_DIR]) 260 | AC_SUBST(GST_PLUGINS_FFMPEG_DIR) 261 | fi 262 | ]) 263 | -------------------------------------------------------------------------------- /common/m4/gst-args.m4: -------------------------------------------------------------------------------- 1 | dnl configure-time options shared among gstreamer modules 2 | 3 | dnl AG_GST_ARG_DEBUG 4 | dnl AG_GST_ARG_PROFILING 5 | dnl AG_GST_ARG_VALGRIND 6 | dnl AG_GST_ARG_GCOV 7 | 8 | dnl AG_GST_ARG_EXAMPLES 9 | 10 | dnl AG_GST_ARG_WITH_PKG_CONFIG_PATH 11 | dnl AG_GST_ARG_WITH_PACKAGE_NAME 12 | dnl AG_GST_ARG_WITH_PACKAGE_ORIGIN 13 | 14 | dnl AG_GST_ARG_WITH_PLUGINS 15 | dnl AG_GST_CHECK_PLUGIN 16 | dnl AG_GST_DISABLE_PLUGIN 17 | 18 | dnl AG_GST_ARG_ENABLE_EXTERNAL 19 | dnl AG_GST_ARG_ENABLE_EXPERIMENTAL 20 | dnl AG_GST_ARG_ENABLE_BROKEN 21 | 22 | AC_DEFUN([AG_GST_ARG_DEBUG], 23 | [ 24 | dnl debugging stuff 25 | AC_ARG_ENABLE(debug, 26 | AC_HELP_STRING([--disable-debug],[disable addition of -g debugging info]), 27 | [ 28 | case "${enableval}" in 29 | yes) USE_DEBUG=yes ;; 30 | no) USE_DEBUG=no ;; 31 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-debug) ;; 32 | esac 33 | ], 34 | [USE_DEBUG=yes]) dnl Default value 35 | ]) 36 | 37 | AC_DEFUN([AG_GST_ARG_PROFILING], 38 | [ 39 | AC_ARG_ENABLE(profiling, 40 | AC_HELP_STRING([--enable-profiling], 41 | [adds -pg to compiler commandline, for profiling]), 42 | [ 43 | case "${enableval}" in 44 | yes) USE_PROFILING=yes ;; 45 | no) USE_PROFILING=no ;; 46 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-profiling) ;; 47 | esac 48 | ], 49 | [USE_PROFILING=no]) dnl Default value 50 | ]) 51 | 52 | AC_DEFUN([AG_GST_ARG_VALGRIND], 53 | [ 54 | dnl valgrind inclusion 55 | AC_ARG_ENABLE(valgrind, 56 | AC_HELP_STRING([--disable-valgrind],[disable run-time valgrind detection]), 57 | [ 58 | case "${enableval}" in 59 | yes) USE_VALGRIND="$USE_DEBUG" ;; 60 | no) USE_VALGRIND=no ;; 61 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-valgrind) ;; 62 | esac 63 | ], 64 | [USE_VALGRIND="$USE_DEBUG"]) dnl Default value 65 | VALGRIND_REQ="3.0" 66 | if test "x$USE_VALGRIND" = xyes; then 67 | PKG_CHECK_MODULES(VALGRIND, valgrind >= $VALGRIND_REQ, 68 | USE_VALGRIND="yes", 69 | USE_VALGRIND="no") 70 | fi 71 | if test "x$USE_VALGRIND" = xyes; then 72 | AC_DEFINE(HAVE_VALGRIND, 1, [Define if valgrind should be used]) 73 | AC_MSG_NOTICE(Using extra code paths for valgrind) 74 | fi 75 | ]) 76 | 77 | AC_DEFUN([AG_GST_ARG_GCOV], 78 | [ 79 | AC_ARG_ENABLE(gcov, 80 | AC_HELP_STRING([--enable-gcov], 81 | [compile with coverage profiling instrumentation (gcc only)]), 82 | enable_gcov=$enableval, 83 | enable_gcov=no) 84 | if test x$enable_gcov = xyes ; then 85 | if test "x$GCC" != "xyes" 86 | then 87 | AC_MSG_ERROR([gcov only works if gcc is used]) 88 | fi 89 | 90 | AS_COMPILER_FLAG(["-fprofile-arcs"], 91 | [GCOV_CFLAGS="$GCOV_CFLAGS -fprofile-arcs"], 92 | true) 93 | AS_COMPILER_FLAG(["-ftest-coverage"], 94 | [GCOV_CFLAGS="$GCOV_CFLAGS -ftest-coverage"], 95 | true) 96 | dnl remove any -O flags - FIXME: is this needed ? 97 | GCOV_CFLAGS=`echo "$GCOV_CFLAGS" | sed -e 's/-O[[0-9]]*//g'` 98 | dnl libtool 1.5.22 and lower strip -fprofile-arcs from the flags 99 | dnl passed to the linker, which is a bug; -fprofile-arcs implicitly 100 | dnl links in -lgcov, so we do it explicitly here for the same effect 101 | GCOV_LIBS=-lgcov 102 | AC_SUBST(GCOV_CFLAGS) 103 | AC_SUBST(GCOV_LIBS) 104 | GCOV=`echo $CC | sed s/gcc/gcov/g` 105 | AC_SUBST(GCOV) 106 | 107 | GST_GCOV_ENABLED=yes 108 | AC_DEFINE_UNQUOTED(GST_GCOV_ENABLED, 1, 109 | [Defined if gcov is enabled to force a rebuild due to config.h changing]) 110 | dnl if gcov is used, we do not want default -O2 CFLAGS 111 | if test "x$GST_GCOV_ENABLED" = "xyes" 112 | then 113 | CFLAGS="-O0" 114 | AC_SUBST(CFLAGS) 115 | CXXFLAGS="-O0" 116 | AC_SUBST(CXXFLAGS) 117 | FFLAGS="-O0" 118 | AC_SUBST(FFLAGS) 119 | CCASFLAGS="-O0" 120 | AC_SUBST(CCASFLAGS) 121 | AC_MSG_NOTICE([gcov enabled, setting CFLAGS and friends to $CFLAGS]) 122 | fi 123 | fi 124 | AM_CONDITIONAL(GST_GCOV_ENABLED, test x$enable_gcov = xyes) 125 | ]) 126 | 127 | AC_DEFUN([AG_GST_ARG_EXAMPLES], 128 | [ 129 | AC_ARG_ENABLE(examples, 130 | AC_HELP_STRING([--disable-examples], [disable building examples]), 131 | [ 132 | case "${enableval}" in 133 | yes) BUILD_EXAMPLES=yes ;; 134 | no) BUILD_EXAMPLES=no ;; 135 | *) AC_MSG_ERROR(bad value ${enableval} for --disable-examples) ;; 136 | esac 137 | ], 138 | [BUILD_EXAMPLES=yes]) dnl Default value 139 | AM_CONDITIONAL(BUILD_EXAMPLES, test "x$BUILD_EXAMPLES" = "xyes") 140 | ]) 141 | 142 | AC_DEFUN([AG_GST_ARG_WITH_PKG_CONFIG_PATH], 143 | [ 144 | dnl possibly modify pkg-config path 145 | AC_ARG_WITH(pkg-config-path, 146 | AC_HELP_STRING([--with-pkg-config-path], 147 | [colon-separated list of pkg-config(1) dirs]), 148 | [ 149 | export PKG_CONFIG_PATH=${withval} 150 | AC_MSG_NOTICE(Set PKG_CONFIG_PATH to $PKG_CONFIG_PATH) 151 | ]) 152 | ]) 153 | 154 | 155 | dnl This macro requires that GST_GIT or GST_CVS is set to yes or no (release) 156 | AC_DEFUN([AG_GST_ARG_WITH_PACKAGE_NAME], 157 | [ 158 | dnl package name in plugins 159 | AC_ARG_WITH(package-name, 160 | AC_HELP_STRING([--with-package-name], 161 | [specify package name to use in plugins]), 162 | [ 163 | case "${withval}" in 164 | yes) AC_MSG_ERROR(bad value ${withval} for --with-package-name) ;; 165 | no) AC_MSG_ERROR(bad value ${withval} for --with-package-name) ;; 166 | *) GST_PACKAGE_NAME="${withval}" ;; 167 | esac 168 | ], 169 | [ 170 | P=$1 171 | if test "x$P" = "x" 172 | then 173 | P=$PACKAGE_NAME 174 | fi 175 | 176 | if test "x$PACKAGE_VERSION_NANO" = "x0" 177 | then 178 | GST_PACKAGE_NAME="$P source release" 179 | else 180 | if test "x$PACKAGE_VERSION_NANO" = "x1" 181 | then 182 | GST_PACKAGE_NAME="$P git" 183 | else 184 | GST_PACKAGE_NAME="$P prerelease" 185 | fi 186 | fi 187 | ] 188 | ) 189 | AC_MSG_NOTICE(Using $GST_PACKAGE_NAME as package name) 190 | AC_DEFINE_UNQUOTED(GST_PACKAGE_NAME, "$GST_PACKAGE_NAME", 191 | [package name in plugins]) 192 | AC_SUBST(GST_PACKAGE_NAME) 193 | ]) 194 | 195 | AC_DEFUN([AG_GST_ARG_WITH_PACKAGE_ORIGIN], 196 | [ 197 | dnl package origin URL 198 | AC_ARG_WITH(package-origin, 199 | AC_HELP_STRING([--with-package-origin], 200 | [specify package origin URL to use in plugins]), 201 | [ 202 | case "${withval}" in 203 | yes) AC_MSG_ERROR(bad value ${withval} for --with-package-origin) ;; 204 | no) AC_MSG_ERROR(bad value ${withval} for --with-package-origin) ;; 205 | *) GST_PACKAGE_ORIGIN="${withval}" ;; 206 | esac 207 | ], 208 | [GST_PACKAGE_ORIGIN="[Unknown package origin]"] dnl Default value 209 | ) 210 | AC_MSG_NOTICE(Using $GST_PACKAGE_ORIGIN as package origin) 211 | AC_DEFINE_UNQUOTED(GST_PACKAGE_ORIGIN, "$GST_PACKAGE_ORIGIN", 212 | [package origin]) 213 | AC_SUBST(GST_PACKAGE_ORIGIN) 214 | ]) 215 | 216 | dnl sets WITH_PLUGINS to the list of plug-ins given as an argument 217 | dnl also clears GST_PLUGINS_ALL and GST_PLUGINS_SELECTED 218 | AC_DEFUN([AG_GST_ARG_WITH_PLUGINS], 219 | [ 220 | AC_ARG_WITH(plugins, 221 | AC_HELP_STRING([--with-plugins], 222 | [comma-separated list of dependencyless plug-ins to compile]), 223 | [WITH_PLUGINS=$withval], 224 | [WITH_PLUGINS=]) 225 | 226 | GST_PLUGINS_ALL="" 227 | GST_PLUGINS_SELECTED="" 228 | 229 | AC_SUBST(GST_PLUGINS_ALL) 230 | AC_SUBST(GST_PLUGINS_SELECTED) 231 | ]) 232 | 233 | dnl AG_GST_CHECK_PLUGIN(PLUGIN-NAME) 234 | dnl 235 | dnl This macro adds the plug-in to GST_PLUGINS_ALL. Then it 236 | dnl checks if WITH_PLUGINS is empty or the plugin is present in WITH_PLUGINS, 237 | dnl and if so adds it to GST_PLUGINS_SELECTED. Then it checks if the plugin 238 | dnl is present in WITHOUT_PLUGINS (ie. was disabled specifically) and if so 239 | dnl removes it from GST_PLUGINS_SELECTED. 240 | dnl 241 | dnl The macro will call AM_CONDITIONAL(USE_PLUGIN_, ...) to allow 242 | dnl control of what is built in Makefile.ams. 243 | AC_DEFUN([AG_GST_CHECK_PLUGIN], 244 | [ 245 | GST_PLUGINS_ALL="$GST_PLUGINS_ALL [$1]" 246 | 247 | define([pname_def],translit([$1], -a-z, _a-z)) 248 | 249 | AC_ARG_ENABLE([$1], 250 | AC_HELP_STRING([--disable-[$1]], [disable dependency-less $1 plugin]), 251 | [ 252 | case "${enableval}" in 253 | yes) [gst_use_]pname_def=yes ;; 254 | no) [gst_use_]pname_def=no ;; 255 | *) AC_MSG_ERROR([bad value ${enableval} for --enable-$1]) ;; 256 | esac 257 | ], 258 | [[gst_use_]pname_def=yes]) dnl Default value 259 | 260 | if test x$[gst_use_]pname_def = xno; then 261 | AC_MSG_NOTICE(disabling dependency-less plugin $1) 262 | WITHOUT_PLUGINS="$WITHOUT_PLUGINS [$1]" 263 | fi 264 | undefine([pname_def]) 265 | 266 | if [[ -z "$WITH_PLUGINS" ]] || echo " [$WITH_PLUGINS] " | tr , ' ' | grep -i " [$1] " > /dev/null; then 267 | GST_PLUGINS_SELECTED="$GST_PLUGINS_SELECTED [$1]" 268 | fi 269 | if echo " [$WITHOUT_PLUGINS] " | tr , ' ' | grep -i " [$1] " > /dev/null; then 270 | GST_PLUGINS_SELECTED=`echo " $GST_PLUGINS_SELECTED " | $SED -e 's/ [$1] / /'` 271 | fi 272 | AM_CONDITIONAL([USE_PLUGIN_]translit([$1], a-z, A-Z), echo " $GST_PLUGINS_SELECTED " | grep -i " [$1] " > /dev/null) 273 | ]) 274 | 275 | dnl AG_GST_DISABLE_PLUGIN(PLUGIN-NAME) 276 | dnl 277 | dnl This macro disables the plug-in by removing it from 278 | dnl GST_PLUGINS_SELECTED. 279 | AC_DEFUN([AG_GST_DISABLE_PLUGIN], 280 | [ 281 | GST_PLUGINS_SELECTED=`echo " $GST_PLUGINS_SELECTED " | $SED -e 's/ [$1] / /'` 282 | AM_CONDITIONAL([USE_PLUGIN_]translit([$1], a-z, A-Z), false) 283 | ]) 284 | 285 | AC_DEFUN([AG_GST_ARG_ENABLE_EXTERNAL], 286 | [ 287 | AG_GST_CHECK_FEATURE(EXTERNAL, [building of plug-ins with external deps],, 288 | HAVE_EXTERNAL=yes, enabled, 289 | [ 290 | AC_MSG_NOTICE(building external plug-ins) 291 | BUILD_EXTERNAL="yes" 292 | ],[ 293 | AC_MSG_WARN(all plug-ins with external dependencies will not be built) 294 | BUILD_EXTERNAL="no" 295 | ]) 296 | # make BUILD_EXTERNAL available to Makefile.am 297 | AM_CONDITIONAL(BUILD_EXTERNAL, test "x$BUILD_EXTERNAL" = "xyes") 298 | ]) 299 | 300 | dnl experimental plug-ins; stuff that hasn't had the dust settle yet 301 | dnl read 'builds, but might not work' 302 | AC_DEFUN([AG_GST_ARG_ENABLE_EXPERIMENTAL], 303 | [ 304 | AG_GST_CHECK_FEATURE(EXPERIMENTAL, [building of experimental plug-ins],, 305 | HAVE_EXPERIMENTAL=yes, disabled, 306 | [ 307 | AC_MSG_WARN(building experimental plug-ins) 308 | BUILD_EXPERIMENTAL="yes" 309 | ],[ 310 | AC_MSG_NOTICE(not building experimental plug-ins) 311 | BUILD_EXPERIMENTAL="no" 312 | ]) 313 | # make BUILD_EXPERIMENTAL available to Makefile.am 314 | AM_CONDITIONAL(BUILD_EXPERIMENTAL, test "x$BUILD_EXPERIMENTAL" = "xyes") 315 | ]) 316 | 317 | dnl broken plug-ins; stuff that doesn't seem to build at the moment 318 | AC_DEFUN([AG_GST_ARG_ENABLE_BROKEN], 319 | [ 320 | AG_GST_CHECK_FEATURE(BROKEN, [building of broken plug-ins],, 321 | HAVE_BROKEN=yes, disabled, 322 | [ 323 | AC_MSG_WARN([building broken plug-ins -- no bug reports on these, only patches ...]) 324 | ],[ 325 | AC_MSG_NOTICE([not building broken plug-ins]) 326 | ]) 327 | ]) 328 | -------------------------------------------------------------------------------- /common/gst-autogen.sh: -------------------------------------------------------------------------------- 1 | # a silly hack that generates autoregen.sh but it's handy 2 | # Remove the old autoregen.sh first to create a new file, 3 | # as the current one may be being read by the shell executing 4 | # this script. 5 | if [ -f "autoregen.sh" ]; then 6 | rm autoregen.sh 7 | fi 8 | echo "#!/bin/sh" > autoregen.sh 9 | echo "./autogen.sh $@ \$@" >> autoregen.sh 10 | chmod +x autoregen.sh 11 | 12 | # helper functions for autogen.sh 13 | 14 | debug () 15 | # print out a debug message if DEBUG is a defined variable 16 | { 17 | if test ! -z "$DEBUG" 18 | then 19 | echo "DEBUG: $1" 20 | fi 21 | } 22 | 23 | version_get () 24 | # based on the command's version output, set variables 25 | # _MAJOR, _MINOR, _MICRO, _VERSION, using the given prefix as variable prefix 26 | # 27 | # arg 1: command binary name 28 | # arg 2: (uppercased) variable name prefix 29 | { 30 | COMMAND=$1 31 | VARPREFIX=`echo $2 | tr .,- _` 32 | 33 | # strip everything that's not a digit, then use cut to get the first field 34 | pkg_version=`$COMMAND --version|head -n 1|sed 's/^.*)[^0-9]*//'|cut -d' ' -f1` 35 | debug "pkg_version $pkg_version" 36 | # remove any non-digit characters from the version numbers to permit numeric 37 | # comparison 38 | pkg_major=`echo $pkg_version | cut -d. -f1 | sed s/[a-zA-Z\-].*//g` 39 | pkg_minor=`echo $pkg_version | cut -d. -f2 | sed s/[a-zA-Z\-].*//g` 40 | pkg_micro=`echo $pkg_version | cut -d. -f3 | sed s/[a-zA-Z\-].*//g` 41 | test -z "$pkg_major" && pkg_major=0 42 | test -z "$pkg_minor" && pkg_minor=0 43 | test -z "$pkg_micro" && pkg_micro=0 44 | debug "found major $pkg_major minor $pkg_minor micro $pkg_micro" 45 | eval ${VARPREFIX}_MAJOR=$pkg_major 46 | eval ${VARPREFIX}_MINOR=$pkg_minor 47 | eval ${VARPREFIX}_MICRO=$pkg_micro 48 | eval ${VARPREFIX}_VERSION=$pkg_version 49 | } 50 | 51 | version_compare () 52 | # Checks whether the version of VARPREFIX is equal to or 53 | # newer than the requested version 54 | # arg1: VARPREFIX 55 | # arg2: MAJOR 56 | # arg3: MINOR 57 | # arg4: MICRO 58 | { 59 | VARPREFIX=`echo $1 | tr .,- _` 60 | MAJOR=$2 61 | MINOR=$3 62 | MICRO=$4 63 | 64 | eval pkg_major=\$${VARPREFIX}_MAJOR; 65 | eval pkg_minor=\$${VARPREFIX}_MINOR; 66 | eval pkg_micro=\$${VARPREFIX}_MICRO; 67 | 68 | #start checking the version 69 | debug "version_compare: $VARPREFIX against $MAJOR.$MINOR.$MICRO" 70 | 71 | # reset check 72 | WRONG= 73 | 74 | if [ ! "$pkg_major" -gt "$MAJOR" ]; then 75 | debug "major: $pkg_major <= $MAJOR" 76 | if [ "$pkg_major" -lt "$MAJOR" ]; then 77 | debug "major: $pkg_major < $MAJOR" 78 | WRONG=1 79 | elif [ ! "$pkg_minor" -gt "$MINOR" ]; then 80 | debug "minor: $pkg_minor <= $MINOR" 81 | if [ "$pkg_minor" -lt "$MINOR" ]; then 82 | debug "minor: $pkg_minor < $MINOR" 83 | WRONG=1 84 | elif [ "$pkg_micro" -lt "$MICRO" ]; then 85 | debug "micro: $pkg_micro < $MICRO" 86 | WRONG=1 87 | fi 88 | fi 89 | fi 90 | if test ! -z "$WRONG"; then 91 | debug "version_compare: $VARPREFIX older than $MAJOR.$MINOR.$MICRO" 92 | return 1 93 | fi 94 | debug "version_compare: $VARPREFIX equal to/newer than $MAJOR.$MINOR.$MICRO" 95 | return 0 96 | } 97 | 98 | 99 | version_check () 100 | # check the version of a package 101 | # first argument : package name (executable) 102 | # second argument : optional path where to look for it instead 103 | # third argument : source download url 104 | # rest of arguments : major, minor, micro version 105 | # all consecutive ones : suggestions for binaries to use 106 | # (if not specified in second argument) 107 | { 108 | PACKAGE=$1 109 | PKG_PATH=$2 110 | URL=$3 111 | MAJOR=$4 112 | MINOR=$5 113 | MICRO=$6 114 | 115 | # for backwards compatibility, we let PKG_PATH=PACKAGE when PKG_PATH null 116 | if test -z "$PKG_PATH"; then PKG_PATH=$PACKAGE; fi 117 | debug "major $MAJOR minor $MINOR micro $MICRO" 118 | VERSION=$MAJOR 119 | if test ! -z "$MINOR"; then VERSION=$VERSION.$MINOR; else MINOR=0; fi 120 | if test ! -z "$MICRO"; then VERSION=$VERSION.$MICRO; else MICRO=0; fi 121 | 122 | debug "major $MAJOR minor $MINOR micro $MICRO" 123 | 124 | for SUGGESTION in $PKG_PATH; do 125 | COMMAND="$SUGGESTION" 126 | 127 | # don't check if asked not to 128 | test -z "$NOCHECK" && { 129 | printf " checking for $COMMAND >= $VERSION ... " 130 | } || { 131 | # we set a var with the same name as the package, but stripped of 132 | # unwanted chars 133 | VAR=`echo $PACKAGE | sed 's/-//g'` 134 | debug "setting $VAR" 135 | eval $VAR="$COMMAND" 136 | return 0 137 | } 138 | 139 | which $COMMAND > /dev/null 2>&1 140 | if test $? -eq 1; 141 | then 142 | debug "$COMMAND not found" 143 | continue 144 | fi 145 | 146 | VARPREFIX=`echo $COMMAND | sed 's/-//g' | tr [:lower:] [:upper:]` 147 | version_get $COMMAND $VARPREFIX 148 | 149 | version_compare $VARPREFIX $MAJOR $MINOR $MICRO 150 | if test $? -ne 0; then 151 | echo "found $pkg_version, not ok !" 152 | continue 153 | else 154 | echo "found $pkg_version, ok." 155 | # we set a var with the same name as the package, but stripped of 156 | # unwanted chars 157 | VAR=`echo $PACKAGE | sed 's/-//g'` 158 | debug "setting $VAR" 159 | eval $VAR="$COMMAND" 160 | return 0 161 | fi 162 | done 163 | 164 | echo "$PACKAGE not found !" 165 | echo "You must have $PACKAGE installed to compile $package." 166 | echo "Download the appropriate package for your distribution," 167 | echo "or get the source tarball at $URL" 168 | return 1; 169 | } 170 | 171 | aclocal_check () 172 | { 173 | # normally aclocal is part of automake 174 | # so we expect it to be in the same place as automake 175 | # so if a different automake is supplied, we need to adapt as well 176 | # so how's about replacing automake with aclocal in the set var, 177 | # and saving that in $aclocal ? 178 | # note, this will fail if the actual automake isn't called automake* 179 | # or if part of the path before it contains it 180 | if [ -z "$automake" ]; then 181 | echo "Error: no automake variable set !" 182 | return 1 183 | else 184 | aclocal=`echo $automake | sed s/automake/aclocal/` 185 | debug "aclocal: $aclocal" 186 | if [ "$aclocal" != "aclocal" ]; 187 | then 188 | CONFIGURE_DEF_OPT="$CONFIGURE_DEF_OPT --with-aclocal=$aclocal" 189 | fi 190 | if [ ! -x `which $aclocal` ]; then 191 | echo "Error: cannot execute $aclocal !" 192 | return 1 193 | fi 194 | fi 195 | } 196 | 197 | autoheader_check () 198 | { 199 | # same here - autoheader is part of autoconf 200 | # use the same voodoo 201 | if [ -z "$autoconf" ]; then 202 | echo "Error: no autoconf variable set !" 203 | return 1 204 | else 205 | autoheader=`echo $autoconf | sed s/autoconf/autoheader/` 206 | debug "autoheader: $autoheader" 207 | if [ "$autoheader" != "autoheader" ]; 208 | then 209 | CONFIGURE_DEF_OPT="$CONFIGURE_DEF_OPT --with-autoheader=$autoheader" 210 | fi 211 | if [ ! -x `which $autoheader` ]; then 212 | echo "Error: cannot execute $autoheader !" 213 | return 1 214 | fi 215 | fi 216 | 217 | } 218 | 219 | autoconf_2_52d_check () 220 | { 221 | # autoconf 2.52d has a weird issue involving a yes:no error 222 | # so don't allow it's use 223 | test -z "$NOCHECK" && { 224 | ac_version=`$autoconf --version|head -n 1|sed 's/^[a-zA-Z\.\ ()]*//;s/ .*$//'` 225 | if test "$ac_version" = "2.52d"; then 226 | echo "autoconf 2.52d has an issue with our current build." 227 | echo "We don't know who's to blame however. So until we do, get a" 228 | echo "regular version. RPM's of a working version are on the gstreamer site." 229 | exit 1 230 | fi 231 | } 232 | return 0 233 | } 234 | libtool_2_2_gettext_check () 235 | { 236 | # libtool 2.2 needs autopoint 0.17 or higher 237 | version_compare LIBTOOLIZE 2 2 0 238 | if test $? -eq 0 239 | then 240 | version_compare AUTOPOINT 0 17 0 241 | if test $? -ne 0 242 | then 243 | echo "libtool 2.2 requires autopoint 0.17 or higher" 244 | return 1 245 | fi 246 | fi 247 | return 0 248 | } 249 | 250 | 251 | die_check () 252 | { 253 | # call with $DIE 254 | # if set to 1, we need to print something helpful then die 255 | DIE=$1 256 | if test "x$DIE" = "x1"; 257 | then 258 | echo 259 | echo "- Please get the right tools before proceeding." 260 | echo "- Alternatively, if you're sure we're wrong, run with --nocheck." 261 | exit 1 262 | fi 263 | } 264 | 265 | autogen_options () 266 | { 267 | if test "x$1" = "x"; then 268 | return 0 269 | fi 270 | 271 | while test "x$1" != "x" ; do 272 | optarg=`expr "x$1" : 'x[^=]*=\(.*\)'` 273 | case "$1" in 274 | --noconfigure) 275 | NOCONFIGURE=defined 276 | AUTOGEN_EXT_OPT="$AUTOGEN_EXT_OPT --noconfigure" 277 | echo "+ configure run disabled" 278 | shift 279 | ;; 280 | --nocheck) 281 | AUTOGEN_EXT_OPT="$AUTOGEN_EXT_OPT --nocheck" 282 | NOCHECK=defined 283 | echo "+ autotools version check disabled" 284 | shift 285 | ;; 286 | -d|--debug) 287 | DEBUG=defined 288 | AUTOGEN_EXT_OPT="$AUTOGEN_EXT_OPT --debug" 289 | echo "+ debug output enabled" 290 | shift 291 | ;; 292 | -h|--help) 293 | echo "autogen.sh (autogen options) -- (configure options)" 294 | echo "autogen.sh help options: " 295 | echo " --noconfigure don't run the configure script" 296 | echo " --nocheck don't do version checks" 297 | echo " --debug debug the autogen process" 298 | echo 299 | echo " --with-autoconf PATH use autoconf in PATH" 300 | echo " --with-automake PATH use automake in PATH" 301 | echo 302 | echo "Any argument either not in the above list or after a '--' will be " 303 | echo "passed to ./configure." 304 | exit 1 305 | ;; 306 | --with-automake=*) 307 | AUTOMAKE=$optarg 308 | echo "+ using alternate automake in $optarg" 309 | CONFIGURE_DEF_OPT="$CONFIGURE_DEF_OPT --with-automake=$AUTOMAKE" 310 | shift 311 | ;; 312 | --with-autoconf=*) 313 | AUTOCONF=$optarg 314 | echo "+ using alternate autoconf in $optarg" 315 | CONFIGURE_DEF_OPT="$CONFIGURE_DEF_OPT --with-autoconf=$AUTOCONF" 316 | shift 317 | ;; 318 | --) shift ; break ;; 319 | *) 320 | echo "+ passing argument $1 to configure" 321 | CONFIGURE_EXT_OPT="$CONFIGURE_EXT_OPT $1" 322 | shift 323 | ;; 324 | esac 325 | done 326 | 327 | for arg do CONFIGURE_EXT_OPT="$CONFIGURE_EXT_OPT $arg"; done 328 | if test ! -z "$CONFIGURE_EXT_OPT" 329 | then 330 | echo "+ options passed to configure: $CONFIGURE_EXT_OPT" 331 | fi 332 | } 333 | 334 | toplevel_check () 335 | { 336 | srcfile=$1 337 | test -f $srcfile || { 338 | echo "You must run this script in the top-level $package directory" 339 | exit 1 340 | } 341 | } 342 | 343 | tool_run () 344 | { 345 | tool=$1 346 | options=$2 347 | run_if_fail=$3 348 | echo "+ running $tool $options..." 349 | $tool $options || { 350 | echo 351 | echo $tool failed 352 | eval $run_if_fail 353 | exit 1 354 | } 355 | } 356 | 357 | install_git_hooks () 358 | { 359 | if test -d .git; then 360 | # install pre-commit hook for doing clean commits 361 | for hook in pre-commit; do 362 | if test ! \( -x .git/hooks/$hook -a -L .git/hooks/$hook \); then 363 | echo "+ Installing git $hook hook" 364 | rm -f .git/hooks/$hook 365 | ln -s ../../common/hooks/$hook.hook .git/hooks/$hook || { 366 | # if we couldn't create a symbolic link, try doing a plain cp 367 | if cp common/hooks/pre-commit.hook .git/hooks/pre-commit; then 368 | chmod +x .git/hooks/pre-commit; 369 | else 370 | echo "********** Couldn't install git $hook hook **********"; 371 | fi 372 | } 373 | fi 374 | done 375 | fi 376 | } 377 | -------------------------------------------------------------------------------- /common/m4/glib-gettext.m4: -------------------------------------------------------------------------------- 1 | # Copyright (C) 1995-2002 Free Software Foundation, Inc. 2 | # Copyright (C) 2001-2003,2004 Red Hat, Inc. 3 | # 4 | # This file is free software, distributed under the terms of the GNU 5 | # General Public License. As a special exception to the GNU General 6 | # Public License, this file may be distributed as part of a program 7 | # that contains a configuration script generated by Autoconf, under 8 | # the same distribution terms as the rest of that program. 9 | # 10 | # This file can be copied and used freely without restrictions. It can 11 | # be used in projects which are not available under the GNU Public License 12 | # but which still want to provide support for the GNU gettext functionality. 13 | # 14 | # Macro to add for using GNU gettext. 15 | # Ulrich Drepper , 1995, 1996 16 | # 17 | # Modified to never use included libintl. 18 | # Owen Taylor , 12/15/1998 19 | # 20 | # Major rework to remove unused code 21 | # Owen Taylor , 12/11/2002 22 | # 23 | # Added better handling of ALL_LINGUAS from GNU gettext version 24 | # written by Bruno Haible, Owen Taylor 5/30/3002 25 | # 26 | # Modified to require ngettext 27 | # Matthias Clasen 08/06/2004 28 | # 29 | # We need this here as well, since someone might use autoconf-2.5x 30 | # to configure GLib then an older version to configure a package 31 | # using AM_GLIB_GNU_GETTEXT 32 | AC_PREREQ(2.53) 33 | 34 | dnl 35 | dnl We go to great lengths to make sure that aclocal won't 36 | dnl try to pull in the installed version of these macros 37 | dnl when running aclocal in the glib directory. 38 | dnl 39 | m4_copy([AC_DEFUN],[glib_DEFUN]) 40 | m4_copy([AC_REQUIRE],[glib_REQUIRE]) 41 | dnl 42 | dnl At the end, if we're not within glib, we'll define the public 43 | dnl definitions in terms of our private definitions. 44 | dnl 45 | 46 | # GLIB_LC_MESSAGES 47 | #-------------------- 48 | glib_DEFUN([GLIB_LC_MESSAGES], 49 | [AC_CHECK_HEADERS([locale.h]) 50 | if test $ac_cv_header_locale_h = yes; then 51 | AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES, 52 | [AC_TRY_LINK([#include ], [return LC_MESSAGES], 53 | am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)]) 54 | if test $am_cv_val_LC_MESSAGES = yes; then 55 | AC_DEFINE(HAVE_LC_MESSAGES, 1, 56 | [Define if your file defines LC_MESSAGES.]) 57 | fi 58 | fi]) 59 | 60 | # GLIB_PATH_PROG_WITH_TEST 61 | #---------------------------- 62 | dnl GLIB_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR, 63 | dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]]) 64 | glib_DEFUN([GLIB_PATH_PROG_WITH_TEST], 65 | [# Extract the first word of "$2", so it can be a program name with args. 66 | set dummy $2; ac_word=[$]2 67 | AC_MSG_CHECKING([for $ac_word]) 68 | AC_CACHE_VAL(ac_cv_path_$1, 69 | [case "[$]$1" in 70 | /*) 71 | ac_cv_path_$1="[$]$1" # Let the user override the test with a path. 72 | ;; 73 | *) 74 | IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" 75 | for ac_dir in ifelse([$5], , $PATH, [$5]); do 76 | test -z "$ac_dir" && ac_dir=. 77 | if test -f $ac_dir/$ac_word; then 78 | if [$3]; then 79 | ac_cv_path_$1="$ac_dir/$ac_word" 80 | break 81 | fi 82 | fi 83 | done 84 | IFS="$ac_save_ifs" 85 | dnl If no 4th arg is given, leave the cache variable unset, 86 | dnl so AC_PATH_PROGS will keep looking. 87 | ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4" 88 | ])dnl 89 | ;; 90 | esac])dnl 91 | $1="$ac_cv_path_$1" 92 | if test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then 93 | AC_MSG_RESULT([$]$1) 94 | else 95 | AC_MSG_RESULT(no) 96 | fi 97 | AC_SUBST($1)dnl 98 | ]) 99 | 100 | # GLIB_WITH_NLS 101 | #----------------- 102 | glib_DEFUN([GLIB_WITH_NLS], 103 | dnl NLS is obligatory 104 | [USE_NLS=yes 105 | AC_SUBST(USE_NLS) 106 | 107 | gt_cv_have_gettext=no 108 | 109 | CATOBJEXT=NONE 110 | XGETTEXT=: 111 | INTLLIBS= 112 | 113 | AC_CHECK_HEADER(libintl.h, 114 | [gt_cv_func_dgettext_libintl="no" 115 | libintl_extra_libs="" 116 | 117 | # 118 | # First check in libc 119 | # 120 | AC_CACHE_CHECK([for ngettext in libc], gt_cv_func_ngettext_libc, 121 | [AC_TRY_LINK([ 122 | #include 123 | ], 124 | [return !ngettext ("","", 1)], 125 | gt_cv_func_ngettext_libc=yes, 126 | gt_cv_func_ngettext_libc=no) 127 | ]) 128 | 129 | if test "$gt_cv_func_ngettext_libc" = "yes" ; then 130 | AC_CACHE_CHECK([for dgettext in libc], gt_cv_func_dgettext_libc, 131 | [AC_TRY_LINK([ 132 | #include 133 | ], 134 | [return !dgettext ("","")], 135 | gt_cv_func_dgettext_libc=yes, 136 | gt_cv_func_dgettext_libc=no) 137 | ]) 138 | fi 139 | 140 | if test "$gt_cv_func_ngettext_libc" = "yes" ; then 141 | AC_CHECK_FUNCS(bind_textdomain_codeset) 142 | fi 143 | 144 | # 145 | # If we don't have everything we want, check in libintl 146 | # 147 | if test "$gt_cv_func_dgettext_libc" != "yes" \ 148 | || test "$gt_cv_func_ngettext_libc" != "yes" \ 149 | || test "$ac_cv_func_bind_textdomain_codeset" != "yes" ; then 150 | 151 | AC_CHECK_LIB(intl, bindtextdomain, 152 | [AC_CHECK_LIB(intl, ngettext, 153 | [AC_CHECK_LIB(intl, dgettext, 154 | gt_cv_func_dgettext_libintl=yes)])]) 155 | 156 | if test "$gt_cv_func_dgettext_libintl" != "yes" ; then 157 | AC_MSG_CHECKING([if -liconv is needed to use gettext]) 158 | AC_MSG_RESULT([]) 159 | AC_CHECK_LIB(intl, ngettext, 160 | [AC_CHECK_LIB(intl, dcgettext, 161 | [gt_cv_func_dgettext_libintl=yes 162 | libintl_extra_libs=-liconv], 163 | :,-liconv)], 164 | :,-liconv) 165 | fi 166 | 167 | # 168 | # If we found libintl, then check in it for bind_textdomain_codeset(); 169 | # we'll prefer libc if neither have bind_textdomain_codeset(), 170 | # and both have dgettext and ngettext 171 | # 172 | if test "$gt_cv_func_dgettext_libintl" = "yes" ; then 173 | glib_save_LIBS="$LIBS" 174 | LIBS="$LIBS -lintl $libintl_extra_libs" 175 | unset ac_cv_func_bind_textdomain_codeset 176 | AC_CHECK_FUNCS(bind_textdomain_codeset) 177 | LIBS="$glib_save_LIBS" 178 | 179 | if test "$ac_cv_func_bind_textdomain_codeset" = "yes" ; then 180 | gt_cv_func_dgettext_libc=no 181 | else 182 | if test "$gt_cv_func_dgettext_libc" = "yes" \ 183 | && test "$gt_cv_func_ngettext_libc" = "yes"; then 184 | gt_cv_func_dgettext_libintl=no 185 | fi 186 | fi 187 | fi 188 | fi 189 | 190 | if test "$gt_cv_func_dgettext_libc" = "yes" \ 191 | || test "$gt_cv_func_dgettext_libintl" = "yes"; then 192 | gt_cv_have_gettext=yes 193 | fi 194 | 195 | if test "$gt_cv_func_dgettext_libintl" = "yes"; then 196 | INTLLIBS="-lintl $libintl_extra_libs" 197 | fi 198 | 199 | if test "$gt_cv_have_gettext" = "yes"; then 200 | AC_DEFINE(HAVE_GETTEXT,1, 201 | [Define if the GNU gettext() function is already present or preinstalled.]) 202 | GLIB_PATH_PROG_WITH_TEST(MSGFMT, msgfmt, 203 | [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl 204 | if test "$MSGFMT" != "no"; then 205 | glib_save_LIBS="$LIBS" 206 | LIBS="$LIBS $INTLLIBS" 207 | AC_CHECK_FUNCS(dcgettext) 208 | MSGFMT_OPTS= 209 | AC_MSG_CHECKING([if msgfmt accepts -c]) 210 | GLIB_RUN_PROG([$MSGFMT -c -o /dev/null],[ 211 | msgid "" 212 | msgstr "" 213 | "Content-Type: text/plain; charset=UTF-8\n" 214 | "Project-Id-Version: test 1.0\n" 215 | "PO-Revision-Date: 2007-02-15 12:01+0100\n" 216 | "Last-Translator: test \n" 217 | "Language-Team: C \n" 218 | "MIME-Version: 1.0\n" 219 | "Content-Transfer-Encoding: 8bit\n" 220 | ], [MSGFMT_OPTS=-c; AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no])]) 221 | AC_SUBST(MSGFMT_OPTS) 222 | AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT) 223 | GLIB_PATH_PROG_WITH_TEST(XGETTEXT, xgettext, 224 | [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :) 225 | AC_TRY_LINK(, [extern int _nl_msg_cat_cntr; 226 | return _nl_msg_cat_cntr], 227 | [CATOBJEXT=.gmo 228 | DATADIRNAME=share], 229 | [case $host in 230 | *-*-solaris*) 231 | dnl On Solaris, if bind_textdomain_codeset is in libc, 232 | dnl GNU format message catalog is always supported, 233 | dnl since both are added to the libc all together. 234 | dnl Hence, we'd like to go with DATADIRNAME=share and 235 | dnl and CATOBJEXT=.gmo in this case. 236 | AC_CHECK_FUNC(bind_textdomain_codeset, 237 | [CATOBJEXT=.gmo 238 | DATADIRNAME=share], 239 | [CATOBJEXT=.mo 240 | DATADIRNAME=lib]) 241 | ;; 242 | *) 243 | CATOBJEXT=.mo 244 | DATADIRNAME=lib 245 | ;; 246 | esac]) 247 | LIBS="$glib_save_LIBS" 248 | INSTOBJEXT=.mo 249 | else 250 | gt_cv_have_gettext=no 251 | fi 252 | fi 253 | ]) 254 | 255 | if test "$gt_cv_have_gettext" = "yes" ; then 256 | AC_DEFINE(ENABLE_NLS, 1, 257 | [always defined to indicate that i18n is enabled]) 258 | fi 259 | 260 | dnl Test whether we really found GNU xgettext. 261 | if test "$XGETTEXT" != ":"; then 262 | dnl If it is not GNU xgettext we define it as : so that the 263 | dnl Makefiles still can work. 264 | if $XGETTEXT --omit-header /dev/null 2> /dev/null; then 265 | : ; 266 | else 267 | AC_MSG_RESULT( 268 | [found xgettext program is not GNU xgettext; ignore it]) 269 | XGETTEXT=":" 270 | fi 271 | fi 272 | 273 | # We need to process the po/ directory. 274 | POSUB=po 275 | 276 | AC_OUTPUT_COMMANDS( 277 | [case "$CONFIG_FILES" in *po/Makefile.in*) 278 | sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile 279 | esac]) 280 | 281 | dnl These rules are solely for the distribution goal. While doing this 282 | dnl we only have to keep exactly one list of the available catalogs 283 | dnl in configure.in. 284 | for lang in $ALL_LINGUAS; do 285 | GMOFILES="$GMOFILES $lang.gmo" 286 | POFILES="$POFILES $lang.po" 287 | done 288 | 289 | dnl Make all variables we use known to autoconf. 290 | AC_SUBST(CATALOGS) 291 | AC_SUBST(CATOBJEXT) 292 | AC_SUBST(DATADIRNAME) 293 | AC_SUBST(GMOFILES) 294 | AC_SUBST(INSTOBJEXT) 295 | AC_SUBST(INTLLIBS) 296 | AC_SUBST(PO_IN_DATADIR_TRUE) 297 | AC_SUBST(PO_IN_DATADIR_FALSE) 298 | AC_SUBST(POFILES) 299 | AC_SUBST(POSUB) 300 | ]) 301 | 302 | # AM_GLIB_GNU_GETTEXT 303 | # ------------------- 304 | # Do checks necessary for use of gettext. If a suitable implementation 305 | # of gettext is found in either in libintl or in the C library, 306 | # it will set INTLLIBS to the libraries needed for use of gettext 307 | # and AC_DEFINE() HAVE_GETTEXT and ENABLE_NLS. (The shell variable 308 | # gt_cv_have_gettext will be set to "yes".) It will also call AC_SUBST() 309 | # on various variables needed by the Makefile.in.in installed by 310 | # glib-gettextize. 311 | dnl 312 | glib_DEFUN([GLIB_GNU_GETTEXT], 313 | [AC_REQUIRE([AC_PROG_CC])dnl 314 | AC_REQUIRE([AC_HEADER_STDC])dnl 315 | 316 | GLIB_LC_MESSAGES 317 | GLIB_WITH_NLS 318 | 319 | if test "$gt_cv_have_gettext" = "yes"; then 320 | if test "x$ALL_LINGUAS" = "x"; then 321 | LINGUAS= 322 | else 323 | AC_MSG_CHECKING(for catalogs to be installed) 324 | NEW_LINGUAS= 325 | for presentlang in $ALL_LINGUAS; do 326 | useit=no 327 | if test "%UNSET%" != "${LINGUAS-%UNSET%}"; then 328 | desiredlanguages="$LINGUAS" 329 | else 330 | desiredlanguages="$ALL_LINGUAS" 331 | fi 332 | for desiredlang in $desiredlanguages; do 333 | # Use the presentlang catalog if desiredlang is 334 | # a. equal to presentlang, or 335 | # b. a variant of presentlang (because in this case, 336 | # presentlang can be used as a fallback for messages 337 | # which are not translated in the desiredlang catalog). 338 | case "$desiredlang" in 339 | "$presentlang"*) useit=yes;; 340 | esac 341 | done 342 | if test $useit = yes; then 343 | NEW_LINGUAS="$NEW_LINGUAS $presentlang" 344 | fi 345 | done 346 | LINGUAS=$NEW_LINGUAS 347 | AC_MSG_RESULT($LINGUAS) 348 | fi 349 | 350 | dnl Construct list of names of catalog files to be constructed. 351 | if test -n "$LINGUAS"; then 352 | for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done 353 | fi 354 | fi 355 | 356 | dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly 357 | dnl find the mkinstalldirs script in another subdir but ($top_srcdir). 358 | dnl Try to locate is. 359 | MKINSTALLDIRS= 360 | if test -n "$ac_aux_dir"; then 361 | MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs" 362 | fi 363 | if test -z "$MKINSTALLDIRS"; then 364 | MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs" 365 | fi 366 | AC_SUBST(MKINSTALLDIRS) 367 | 368 | dnl Generate list of files to be processed by xgettext which will 369 | dnl be included in po/Makefile. 370 | test -d po || mkdir po 371 | if test "x$srcdir" != "x."; then 372 | if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then 373 | posrcprefix="$srcdir/" 374 | else 375 | posrcprefix="../$srcdir/" 376 | fi 377 | else 378 | posrcprefix="../" 379 | fi 380 | rm -f po/POTFILES 381 | sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \ 382 | < $srcdir/po/POTFILES.in > po/POTFILES 383 | ]) 384 | 385 | # AM_GLIB_DEFINE_LOCALEDIR(VARIABLE) 386 | # ------------------------------- 387 | # Define VARIABLE to the location where catalog files will 388 | # be installed by po/Makefile. 389 | glib_DEFUN([GLIB_DEFINE_LOCALEDIR], 390 | [glib_REQUIRE([GLIB_GNU_GETTEXT])dnl 391 | glib_save_prefix="$prefix" 392 | glib_save_exec_prefix="$exec_prefix" 393 | glib_save_datarootdir="$datarootdir" 394 | test "x$prefix" = xNONE && prefix=$ac_default_prefix 395 | test "x$exec_prefix" = xNONE && exec_prefix=$prefix 396 | datarootdir=`eval echo "${datarootdir}"` 397 | if test "x$CATOBJEXT" = "x.mo" ; then 398 | localedir=`eval echo "${libdir}/locale"` 399 | else 400 | localedir=`eval echo "${datadir}/locale"` 401 | fi 402 | prefix="$glib_save_prefix" 403 | exec_prefix="$glib_save_exec_prefix" 404 | datarootdir="$glib_save_datarootdir" 405 | AC_DEFINE_UNQUOTED($1, "$localedir", 406 | [Define the location where the catalogs will be installed]) 407 | ]) 408 | 409 | dnl 410 | dnl Now the definitions that aclocal will find 411 | dnl 412 | ifdef(glib_configure_in,[],[ 413 | AC_DEFUN([AM_GLIB_GNU_GETTEXT],[GLIB_GNU_GETTEXT($@)]) 414 | AC_DEFUN([AM_GLIB_DEFINE_LOCALEDIR],[GLIB_DEFINE_LOCALEDIR($@)]) 415 | ])dnl 416 | 417 | # GLIB_RUN_PROG(PROGRAM, TEST-FILE, [ACTION-IF-PASS], [ACTION-IF-FAIL]) 418 | # 419 | # Create a temporary file with TEST-FILE as its contents and pass the 420 | # file name to PROGRAM. Perform ACTION-IF-PASS if PROGRAM exits with 421 | # 0 and perform ACTION-IF-FAIL for any other exit status. 422 | AC_DEFUN([GLIB_RUN_PROG], 423 | [cat >conftest.foo <<_ACEOF 424 | $2 425 | _ACEOF 426 | if AC_RUN_LOG([$1 conftest.foo]); then 427 | m4_ifval([$3], [$3], [:]) 428 | m4_ifvaln([$4], [else $4])dnl 429 | echo "$as_me: failed input was:" >&AS_MESSAGE_LOG_FD 430 | sed 's/^/| /' conftest.foo >&AS_MESSAGE_LOG_FD 431 | fi]) 432 | 433 | --------------------------------------------------------------------------------