CC-1695 Remove Campcaster Studio and make install easier
Removed more stuff and started creating new directory structure.
This commit is contained in:
parent
3f5b1a1c92
commit
d9c6971131
|
@ -1,12 +0,0 @@
|
|||
DirectoryIndex index.php
|
||||
Options +FollowSymLinks -Indexes
|
||||
|
||||
<IfModule mod_mime.c>
|
||||
<IfModule mod_php4.c>
|
||||
AddType application/x-httpd-php .php
|
||||
|
||||
php_flag magic_quotes_gpc On
|
||||
php_flag register_globals Off
|
||||
</IfModule>
|
||||
|
||||
</IfModule>
|
|
@ -1,90 +0,0 @@
|
|||
#!/bin/bash
|
||||
#-------------------------------------------------------------------------------
|
||||
# Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
#
|
||||
# This file is part of the Campcaster project.
|
||||
# http://campcaster.sourcefabric.org/
|
||||
# To report bugs, send an e-mail to bugs@campware.org
|
||||
#
|
||||
# Campcaster is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Campcaster is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Campcaster; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Run this to set up the build system: configure, makefiles, etc.
|
||||
# (based on the version in enlightenment's cvs)
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
package="Alib"
|
||||
|
||||
# assume we're in $basedir/bin
|
||||
reldir=`dirname $0`/..
|
||||
basedir=`cd $reldir; pwd;`
|
||||
test -z "$basedir" && basedir=.
|
||||
|
||||
bindir=$basedir/bin
|
||||
etcdir=$basedir/etc
|
||||
tmpdir=$basedir/tmp
|
||||
|
||||
cd "$tmpdir"
|
||||
DIE=0
|
||||
|
||||
(autoheader --version) < /dev/null > /dev/null 2>&1 || {
|
||||
echo
|
||||
echo "You must have autoconf installed to compile $package."
|
||||
echo "Download the appropriate package for your distribution,"
|
||||
echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
|
||||
DIE=1
|
||||
}
|
||||
|
||||
(autoconf --version) < /dev/null > /dev/null 2>&1 || {
|
||||
echo
|
||||
echo "You must have autoconf installed to compile $package."
|
||||
echo "Download the appropriate package for your distribution,"
|
||||
echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
|
||||
DIE=1
|
||||
}
|
||||
|
||||
if test "$DIE" -eq 1; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if test -z "$*"; then
|
||||
echo "I am going to run ./configure with no arguments - if you wish "
|
||||
echo "to pass any to it, please specify them on the $0 command line."
|
||||
fi
|
||||
|
||||
echo "Generating configuration files for $package, please wait...."
|
||||
|
||||
configure_ac=${etcdir}/configure.ac
|
||||
configure=${tmpdir}/configure
|
||||
aclocal_m4=${tmpdir}/aclocal.m4
|
||||
|
||||
# copy over configure.ac and acinlclude.m4 from etc to tmp,
|
||||
# as aclocal >= 1.8 is sooo unbelivably stupid that it will simply try to
|
||||
# look for configure.ac in the current directory, and include acinclude.m4
|
||||
# in aclocal.m4 it without a directory path in front
|
||||
#ACLOCAL_FLAGS="-I ${tmpdir} --acdir=${tmpdir} --output=${aclocal_m4}"
|
||||
#echo " aclocal $ACLOCAL_FLAGS"
|
||||
#cp -f ${configure_ac} ${tmpdir}
|
||||
#cp -f ${etcdir}/acinclude.m4 ${tmpdir}
|
||||
#aclocal $ACLOCAL_FLAGS
|
||||
|
||||
#echo " autoheader ${configure_ac}"
|
||||
#autoheader ${configure_ac}
|
||||
|
||||
echo " autoconf -I ${tmpdir} -o ${configure} ${configure_ac}"
|
||||
autoconf -I ${tmpdir} -o ${configure} ${configure_ac}
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
#!/bin/sh
|
||||
#-------------------------------------------------------------------------------
|
||||
# Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
#
|
||||
# This file is part of the Campcaster project.
|
||||
# http://campcaster.sourcefabric.org/
|
||||
#
|
||||
# Campcaster is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Campcaster is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Campcaster; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Run this script to configure the environment.
|
||||
#
|
||||
# This script in effect calls the real automake / autoconf configure script
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
# assume we're in $basedir
|
||||
reldir=`dirname $0`
|
||||
basedir=`cd $reldir; pwd;`
|
||||
test -z "$basedir" && basedir=.
|
||||
|
||||
bindir=$basedir/bin
|
||||
tmpdir=$basedir/tmp
|
||||
|
||||
|
||||
autogen=$bindir/autogen.sh
|
||||
configure=$tmpdir/configure
|
||||
|
||||
if [ ! -x $configure ]; then
|
||||
(cd $basedir && $autogen "$@")
|
||||
fi
|
||||
|
||||
(cd $tmpdir && $configure "$@")
|
||||
|
|
@ -1,147 +0,0 @@
|
|||
#-------------------------------------------------------------------------------
|
||||
# Alib - authentication and authorizaction component
|
||||
# Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
#
|
||||
# This file is part of the Campcaster project.
|
||||
#
|
||||
# Campcaster is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Campcaster is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Campcaster; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
# @configure_input@
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# General command definitions
|
||||
#-------------------------------------------------------------------------------
|
||||
SHELL = /bin/bash
|
||||
MKDIR = mkdir -p
|
||||
RM = rm -f
|
||||
RMDIR = rm -rf
|
||||
DOXYGEN = doxygen
|
||||
CP = cp -f
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Misc
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
MODULE_NAME = alib
|
||||
TAR_C = tar -cj --exclude .svn --exclude '*~' -C ${BASE_DIR} -f
|
||||
DIST_EXT = .tgz
|
||||
DATE = `date +%y%m%d`
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Basic directory and file definitions
|
||||
#-------------------------------------------------------------------------------
|
||||
#BASE_DIR = @builddir@
|
||||
BASE_DIR = .
|
||||
DOC_DIR = ${BASE_DIR}/doc
|
||||
DOXYGEN_DIR = ${DOC_DIR}/doxygen
|
||||
ETC_DIR = ${BASE_DIR}/etc
|
||||
INCLUDE_DIR = ${BASE_DIR}/include
|
||||
LIB_DIR = ${BASE_DIR}/lib
|
||||
SRC_DIR = ${BASE_DIR}/src
|
||||
TMP_DIR = ${BASE_DIR}/tmp
|
||||
VAR_DIR = ${BASE_DIR}/var
|
||||
|
||||
prefix = @prefix@
|
||||
|
||||
USR_DIR = ${prefix}
|
||||
USR_INCLUDE_DIR = ${USR_DIR}/include
|
||||
USR_VAR_DIR = ${USR_DIR}/var
|
||||
|
||||
DOXYGEN_CONFIG = ${ETC_DIR}/doxygen.config
|
||||
|
||||
PHP_DIR = ${VAR_DIR}
|
||||
TEST_RUNNER = ${PHP_DIR}/tests/index.php
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Configuration parameters
|
||||
#-------------------------------------------------------------------------------
|
||||
#CPPFLAGS = @CPPFLAGS@
|
||||
#CXXFLAGS = @CXXFLAGS@ @DEFS@ -I${USR_INCLUDE_DIR} -I${INCLUDE_DIR} -I${TMP_DIR}\
|
||||
# -pedantic -Wall
|
||||
#LDFLAGS = @LDFLAGS@ -L${USR_LIB_DIR} -L${LIB_DIR}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Dependencies
|
||||
#-------------------------------------------------------------------------------
|
||||
#HELLO_LIB_OBJS = ${TMP_DIR}/Hello.o
|
||||
#TEST_RUNNER_OBJS = ${TMP_DIR}/HelloTest.o ${TMP_DIR}/TestRunner.o
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Targets
|
||||
#-------------------------------------------------------------------------------
|
||||
.PHONY: all clean depclean distclean dist install
|
||||
|
||||
all:
|
||||
|
||||
#dir_setup: ${DOXYGEN_DIR}
|
||||
|
||||
#doc:
|
||||
# ${DOXYGEN} ${DOXYGEN_CONFIG}
|
||||
|
||||
clean:
|
||||
# ${RM} ...
|
||||
|
||||
#docclean:
|
||||
# ${RMDIR} ${DOXYGEN_DIR}/html
|
||||
|
||||
depclean: clean
|
||||
|
||||
#dist: all
|
||||
# ${TAR_C} ${MODULE_NAME}${DATE}${DIST_EXT} *
|
||||
|
||||
distclean: clean
|
||||
# ${RMDIR} ${TMP_DIR}/config* ${TMP_DIR}/autom4te*
|
||||
|
||||
#check: all ${TEST_RUNNER}
|
||||
# ${TEST_RUNNER}
|
||||
check: all
|
||||
|
||||
install: all
|
||||
${MKDIR} ${USR_VAR_DIR}/Campcaster/alib/var
|
||||
# ${MKDIR} ${USR_VAR_DIR}/Campcaster/alib/var/xmlrpc
|
||||
${CP} ${VAR_DIR}/*.php ${USR_VAR_DIR}/Campcaster/alib/var
|
||||
# ${CP} ${VAR_DIR}/xmlrpc/*.php ${USR_VAR_DIR}/Campcaster/alib/var/xmlrpc
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Specific targets
|
||||
#-------------------------------------------------------------------------------
|
||||
# IMPORTANT: db_init and db_clean are commented out only for Campcaster,
|
||||
# where alib is initialized through storageServer module
|
||||
|
||||
#db_init:
|
||||
# cd var/install; php -q install.php
|
||||
|
||||
#db_clean:
|
||||
# cd var/install; php -q uninstall.php
|
||||
|
||||
#${TMP_DIR}:
|
||||
# ${MKDIR} ${TMP_DIR}
|
||||
|
||||
#${DOXYGEN_DIR}:
|
||||
# ${MKDIR} ${DOXYGEN_DIR}
|
||||
|
||||
#${TEST_RUNNER}:
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Pattern rules
|
||||
#-------------------------------------------------------------------------------
|
||||
#${TMP_DIR}/%.o : ${SRC_DIR}/%.cxx
|
||||
# ${CXX} ${CPPFLAGS} ${CXXFLAGS} -c -o $@ $<
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
dnl-----------------------------------------------------------------------------
|
||||
dnl Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
dnl
|
||||
dnl This file is part of the Campcaster project.
|
||||
dnl http://campcaster.sourcefabric.org/
|
||||
dnl
|
||||
dnl Campcaster is free software; you can redistribute it and/or modify
|
||||
dnl it under the terms of the GNU General Public License as published by
|
||||
dnl the Free Software Foundation; either version 2 of the License, or
|
||||
dnl (at your option) any later version.
|
||||
dnl
|
||||
dnl Campcaster is distributed in the hope that it will be useful,
|
||||
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
dnl GNU General Public License for more details.
|
||||
dnl
|
||||
dnl You should have received a copy of the GNU General Public License
|
||||
dnl along with Campcaster; if not, write to the Free Software
|
||||
dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
dnl
|
||||
dnl-----------------------------------------------------------------------------
|
||||
|
||||
dnl-----------------------------------------------------------------------------
|
||||
dnl NOTE: Run all configure related scripts from the tmp directory of the
|
||||
dnl project.
|
||||
dnl This is due to the fact that configure spreads a lot of trash around,
|
||||
dnl like atom4te cache directories, config.* files, etc. into the directory
|
||||
dnl it is being run from. We clearly don't want these in our base directory.
|
||||
dnl-----------------------------------------------------------------------------
|
||||
AC_INIT(Alib, 1.1.1, support@sourcefabric.org)
|
||||
AC_PREREQ(2.59)
|
||||
AC_COPYRIGHT([Copyright (c) 2010 Sourcefabric O.P.S. under the GNU GPL])
|
||||
AC_REVISION($Revision$)
|
||||
|
||||
AC_CONFIG_SRCDIR(../var/Alib.php)
|
||||
|
||||
|
||||
AC_CONFIG_FILES(../Makefile:../etc/Makefile.in)
|
||||
|
||||
AC_OUTPUT()
|
File diff suppressed because it is too large
Load Diff
|
@ -1,12 +0,0 @@
|
|||
DirectoryIndex index.php
|
||||
Options +FollowSymLinks -Indexes
|
||||
|
||||
<IfModule mod_mime.c>
|
||||
<IfModule mod_php4.c>
|
||||
AddType application/x-httpd-php .php
|
||||
|
||||
php_flag magic_quotes_gpc On
|
||||
php_flag register_globals Off
|
||||
</IfModule>
|
||||
|
||||
</IfModule>
|
|
@ -1,7 +0,0 @@
|
|||
<html><head>
|
||||
<title>ALib module</title>
|
||||
</head><body>
|
||||
<h3>Alib</h3>
|
||||
<a href="example/">Example</a><br>
|
||||
<!--<a href="xmlrpc/">XmlRpc test</a>-->
|
||||
</body></html>
|
|
@ -1,133 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @package Campcaster
|
||||
* @subpackage Alib
|
||||
* @copyright 2010 Sourcefabric O.P.S.
|
||||
* @license http://www.gnu.org/licenses/gpl.txt
|
||||
*/
|
||||
include_once("xmlrpc.inc");
|
||||
include_once("xmlrpcs.inc");
|
||||
require_once("../example/alib_h.php");
|
||||
|
||||
function v2xr($var, $struct=true)
|
||||
{
|
||||
if (is_array($var)) {
|
||||
$r = array();
|
||||
foreach ($var as $k => $v) {
|
||||
if ($struct) {
|
||||
$r[$k] = v2xr($v);
|
||||
} else {
|
||||
$r[] = v2xr($v);
|
||||
}
|
||||
}
|
||||
return new xmlrpcval($r, ($struct ? "struct":"array"));
|
||||
} else if(is_int($var)) {
|
||||
return new xmlrpcval($var, "int");
|
||||
} else {
|
||||
return new xmlrpcval($var, "string");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* XMLRPC interface for Alib class<br>
|
||||
* only for testing now (with example) - Campcaster uses special interface
|
||||
*
|
||||
* @package Campcaster
|
||||
* @subpackage Alib
|
||||
* @copyright 2010 Sourcefabric O.P.S.
|
||||
* @license http://www.gnu.org/licenses/gpl.txt
|
||||
*/
|
||||
class XR_Alib {
|
||||
//class XR_Alib extends Alib {
|
||||
function xr_test($input)
|
||||
{
|
||||
$p1 = $input->getParam(0);
|
||||
if (isset($p1) && $p1->scalartyp()=="string") {
|
||||
$s = $p1->scalarval();
|
||||
} else {
|
||||
return new xmlrpcresp(0, 801,
|
||||
"xr_login: wrong 1st parameter, string expected.");
|
||||
}
|
||||
$p2 = $input->getParam(1);
|
||||
if (isset($p2) && $p2->scalartyp() == "string") {
|
||||
$sessid=$p2->scalarval();
|
||||
} else {
|
||||
return new xmlrpcresp(0, 801,
|
||||
"xr_login: wrong 2nd parameter, string expected.");
|
||||
}
|
||||
return new xmlrpcresp(
|
||||
v2xr(strtoupper($s)."_".Alib::GetSessLogin($sessid)."_".$sessid, false)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
function xr_login($input)
|
||||
{
|
||||
$p1 = $input->getParam(0);
|
||||
if (isset($p1) && $p1->scalartyp()=="string") {
|
||||
$login = $p1->scalarval();
|
||||
}
|
||||
else {
|
||||
return new xmlrpcresp(0, 801,
|
||||
"xr_login: wrong 1st parameter, string expected.");
|
||||
}
|
||||
$p2 = $input->getParam(1);
|
||||
if (isset($p2) && $p2->scalartyp() == "string") {
|
||||
$pass = $p2->scalarval();
|
||||
} else {
|
||||
return new xmlrpcresp(0, 801,
|
||||
"xr_login: wrong 2nd parameter, string expected.");
|
||||
}
|
||||
if (!($res = Alib::Login($login, $pass))) {
|
||||
return new xmlrpcresp(0, 802,
|
||||
"xr_login: login failed - incorrect username or password.");
|
||||
} else {
|
||||
return new xmlrpcresp(v2xr($res, false));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function xr_logout($input)
|
||||
{
|
||||
$p1 = $input->getParam(0);
|
||||
if (isset($p1) && $p1->scalartyp()=="string") {
|
||||
$sessid=$p1->scalarval();
|
||||
} else {
|
||||
return new xmlrpcresp(0, 801,
|
||||
"xr_login: wrong 2nd parameter, string expected.");
|
||||
}
|
||||
$res = Alib::Logout($sessid);
|
||||
if (!PEAR::isError($res)) {
|
||||
return new xmlrpcresp(v2xr('Bye', false));
|
||||
} else {
|
||||
return new xmlrpcresp(0, 803,
|
||||
"xr_logout: logout failed - not logged.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // class XR_Alib
|
||||
|
||||
$alib = new XR_Alib();
|
||||
|
||||
$s = new xmlrpc_server( array(
|
||||
"alib.xrTest" => array(
|
||||
"function" => array(&$alib, 'xr_test'),
|
||||
"signature" => array(array($xmlrpcString, $xmlrpcString, $xmlrpcString)),
|
||||
"docstring" => ""
|
||||
),
|
||||
"alib.login" => array(
|
||||
"function" => array(&$alib, 'xr_login'),
|
||||
"signature" => array(array($xmlrpcString, $xmlrpcString, $xmlrpcString)),
|
||||
"docstring" => ""
|
||||
),
|
||||
"alib.logout" => array(
|
||||
"function" => array(&$alib, 'xr_logout'),
|
||||
"signature" => array(array($xmlrpcString, $xmlrpcString)),
|
||||
"docstring" => ""
|
||||
)
|
||||
));
|
||||
|
||||
require_once("../example/alib_f.php");
|
||||
?>
|
|
@ -1,4 +0,0 @@
|
|||
<?php
|
||||
header ("location: xr_cli_test.php");
|
||||
die;
|
||||
?>
|
File diff suppressed because it is too large
Load Diff
|
@ -1,450 +0,0 @@
|
|||
<?php
|
||||
// by Edd Dumbill (C) 1999-2002
|
||||
// <edd@usefulinc.com>
|
||||
// $Id$
|
||||
|
||||
// Copyright (c) 1999,2000,2002 Edd Dumbill.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// * Neither the name of the "XML-RPC for PHP" nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
// REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
// OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// XML RPC Server class
|
||||
// requires: xmlrpc.inc
|
||||
|
||||
// listMethods: either a string, or nothing
|
||||
$_xmlrpcs_listMethods_sig=array(array($xmlrpcArray, $xmlrpcString), array($xmlrpcArray));
|
||||
$_xmlrpcs_listMethods_doc='This method lists all the methods that the XML-RPC server knows how to dispatch';
|
||||
function _xmlrpcs_listMethods($server, $m)
|
||||
{
|
||||
global $xmlrpcerr, $xmlrpcstr, $_xmlrpcs_dmap;
|
||||
$v=new xmlrpcval();
|
||||
$dmap=$server->dmap;
|
||||
$outAr=array();
|
||||
for(reset($dmap); list($key, $val)=each($dmap); )
|
||||
{
|
||||
$outAr[]=new xmlrpcval($key, 'string');
|
||||
}
|
||||
$dmap=$_xmlrpcs_dmap;
|
||||
for(reset($dmap); list($key, $val)=each($dmap); )
|
||||
{
|
||||
$outAr[]=new xmlrpcval($key, 'string');
|
||||
}
|
||||
$v->addArray($outAr);
|
||||
return new xmlrpcresp($v);
|
||||
}
|
||||
|
||||
$_xmlrpcs_methodSignature_sig=array(array($xmlrpcArray, $xmlrpcString));
|
||||
$_xmlrpcs_methodSignature_doc='Returns an array of known signatures (an array of arrays) for the method name passed. If no signatures are known, returns a none-array (test for type != array to detect missing signature)';
|
||||
function _xmlrpcs_methodSignature($server, $m)
|
||||
{
|
||||
global $xmlrpcerr, $xmlrpcstr, $_xmlrpcs_dmap;
|
||||
|
||||
$methName=$m->getParam(0);
|
||||
$methName=$methName->scalarval();
|
||||
if (ereg("^system\.", $methName))
|
||||
{
|
||||
$dmap=$_xmlrpcs_dmap; $sysCall=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$dmap=$server->dmap; $sysCall=0;
|
||||
}
|
||||
// print "<!-- ${methName} -->\n";
|
||||
if (isset($dmap[$methName]))
|
||||
{
|
||||
if ($dmap[$methName]['signature'])
|
||||
{
|
||||
$sigs=array();
|
||||
$thesigs=$dmap[$methName]['signature'];
|
||||
for($i=0; $i<sizeof($thesigs); $i++)
|
||||
{
|
||||
$cursig=array();
|
||||
$inSig=$thesigs[$i];
|
||||
for($j=0; $j<sizeof($inSig); $j++)
|
||||
{
|
||||
$cursig[]=new xmlrpcval($inSig[$j], 'string');
|
||||
}
|
||||
$sigs[]=new xmlrpcval($cursig, 'array');
|
||||
}
|
||||
$r=new xmlrpcresp(new xmlrpcval($sigs, 'array'));
|
||||
}
|
||||
else
|
||||
{
|
||||
$r=new xmlrpcresp(new xmlrpcval('undef', 'string'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$r=new xmlrpcresp(0,$xmlrpcerr['introspect_unknown'], $xmlrpcstr['introspect_unknown']);
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
$_xmlrpcs_methodHelp_sig=array(array($xmlrpcString, $xmlrpcString));
|
||||
$_xmlrpcs_methodHelp_doc='Returns help text if defined for the method passed, otherwise returns an empty string';
|
||||
function _xmlrpcs_methodHelp($server, $m)
|
||||
{
|
||||
global $xmlrpcerr, $xmlrpcstr, $_xmlrpcs_dmap;
|
||||
|
||||
$methName=$m->getParam(0);
|
||||
$methName=$methName->scalarval();
|
||||
if (ereg("^system\.", $methName))
|
||||
{
|
||||
$dmap=$_xmlrpcs_dmap; $sysCall=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$dmap=$server->dmap; $sysCall=0;
|
||||
}
|
||||
// print "<!-- ${methName} -->\n";
|
||||
if (isset($dmap[$methName]))
|
||||
{
|
||||
if ($dmap[$methName]['docstring'])
|
||||
{
|
||||
$r=new xmlrpcresp(new xmlrpcval($dmap[$methName]["docstring"]), 'string');
|
||||
}
|
||||
else
|
||||
{
|
||||
$r=new xmlrpcresp(new xmlrpcval('', 'string'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$r=new xmlrpcresp(0, $xmlrpcerr['introspect_unknown'], $xmlrpcstr['introspect_unknown']);
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
$_xmlrpcs_multicall_sig = array(array($xmlrpcArray, $xmlrpcArray));
|
||||
$_xmlrpcs_multicall_doc = 'Boxcar multiple RPC calls in one request. See http://www.xmlrpc.com/discuss/msgReader$1208 for details';
|
||||
|
||||
function _xmlrpcs_multicall_error($err)
|
||||
{
|
||||
if (is_string($err))
|
||||
{
|
||||
global $xmlrpcerr, $xmlrpcstr;
|
||||
$str = $xmlrpcstr["multicall_${err}"];
|
||||
$code = $xmlrpcerr["multicall_${err}"];
|
||||
}
|
||||
else
|
||||
{
|
||||
$code = $err->faultCode();
|
||||
$str = $err->faultString();
|
||||
}
|
||||
$struct['faultCode'] = new xmlrpcval($code, 'int');
|
||||
$struct['faultString'] = new xmlrpcval($str, 'string');
|
||||
return new xmlrpcval($struct, 'struct');
|
||||
}
|
||||
|
||||
function _xmlrpcs_multicall_do_call($server, $call)
|
||||
{
|
||||
if ($call->kindOf() != 'struct')
|
||||
return _xmlrpcs_multicall_error('notstruct');
|
||||
$methName = $call->structmem('methodName');
|
||||
if (!$methName)
|
||||
return _xmlrpcs_multicall_error('nomethod');
|
||||
if ($methName->kindOf() != 'scalar' || $methName->scalartyp() != 'string')
|
||||
return _xmlrpcs_multicall_error('notstring');
|
||||
if ($methName->scalarval() == 'system.multicall')
|
||||
return _xmlrpcs_multicall_error('recursion');
|
||||
|
||||
$params = $call->structmem('params');
|
||||
if (!$params)
|
||||
return _xmlrpcs_multicall_error('noparams');
|
||||
if ($params->kindOf() != 'array')
|
||||
return _xmlrpcs_multicall_error('notarray');
|
||||
$numParams = $params->arraysize();
|
||||
|
||||
$msg = new xmlrpcmsg($methName->scalarval());
|
||||
for ($i = 0; $i < $numParams; $i++)
|
||||
$msg->addParam($params->arraymem($i));
|
||||
|
||||
$result = $server->execute($msg);
|
||||
|
||||
if ($result->faultCode() != 0)
|
||||
return _xmlrpcs_multicall_error($result); // Method returned fault.
|
||||
|
||||
return new xmlrpcval(array($result->value()), "array");
|
||||
}
|
||||
|
||||
function _xmlrpcs_multicall($server, $m)
|
||||
{
|
||||
$calls = $m->getParam(0);
|
||||
$numCalls = $calls->arraysize();
|
||||
$result = array();
|
||||
|
||||
for ($i = 0; $i < $numCalls; $i++)
|
||||
{
|
||||
$call = $calls->arraymem($i);
|
||||
$result[$i] = _xmlrpcs_multicall_do_call($server, $call);
|
||||
}
|
||||
|
||||
return new xmlrpcresp(new xmlrpcval($result, 'array'));
|
||||
}
|
||||
|
||||
$_xmlrpcs_dmap=array(
|
||||
'system.listMethods' => array(
|
||||
'function' => '_xmlrpcs_listMethods',
|
||||
'signature' => $_xmlrpcs_listMethods_sig,
|
||||
'docstring' => $_xmlrpcs_listMethods_doc),
|
||||
'system.methodHelp' => array(
|
||||
'function' => '_xmlrpcs_methodHelp',
|
||||
'signature' => $_xmlrpcs_methodHelp_sig,
|
||||
'docstring' => $_xmlrpcs_methodHelp_doc),
|
||||
'system.methodSignature' => array(
|
||||
'function' => '_xmlrpcs_methodSignature',
|
||||
'signature' => $_xmlrpcs_methodSignature_sig,
|
||||
'docstring' => $_xmlrpcs_methodSignature_doc),
|
||||
'system.multicall' => array(
|
||||
'function' => '_xmlrpcs_multicall',
|
||||
'signature' => $_xmlrpcs_multicall_sig,
|
||||
'docstring' => $_xmlrpcs_multicall_doc
|
||||
)
|
||||
);
|
||||
|
||||
$_xmlrpc_debuginfo='';
|
||||
function xmlrpc_debugmsg($m)
|
||||
{
|
||||
global $_xmlrpc_debuginfo;
|
||||
$_xmlrpc_debuginfo=$_xmlrpc_debuginfo . $m . "\n";
|
||||
}
|
||||
|
||||
class xmlrpc_server
|
||||
{
|
||||
var $dmap=array();
|
||||
|
||||
function xmlrpc_server($dispMap='', $serviceNow=1)
|
||||
{
|
||||
global $HTTP_RAW_POST_DATA;
|
||||
// dispMap is a dispatch array of methods
|
||||
// mapped to function names and signatures
|
||||
// if a method
|
||||
// doesn't appear in the map then an unknown
|
||||
// method error is generated
|
||||
/* milosch - changed to make passing dispMap optional.
|
||||
* instead, you can use the class add_to_map() function
|
||||
* to add functions manually (borrowed from SOAPX4)
|
||||
*/
|
||||
if($dispMap)
|
||||
{
|
||||
$this->dmap = $dispMap;
|
||||
if($serviceNow)
|
||||
{
|
||||
$this->service();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function serializeDebug()
|
||||
{
|
||||
global $_xmlrpc_debuginfo;
|
||||
if ($_xmlrpc_debuginfo!='')
|
||||
{
|
||||
return "<!-- DEBUG INFO:\n\n" . $_xmlrpc_debuginfo . "\n-->\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
function service()
|
||||
{
|
||||
global $xmlrpc_defencoding;
|
||||
|
||||
$r=$this->parseRequest();
|
||||
$payload='<?xml version="1.0" encoding="' . $xmlrpc_defencoding . '"?>' . "\n"
|
||||
. $this->serializeDebug()
|
||||
. $r->serialize();
|
||||
Header("Content-type: text/xml\r\nContent-length: " .
|
||||
strlen($payload));
|
||||
print $payload;
|
||||
}
|
||||
|
||||
/*
|
||||
add a method to the dispatch map
|
||||
*/
|
||||
function add_to_map($methodname,$function,$sig,$doc)
|
||||
{
|
||||
$this->dmap[$methodname] = array(
|
||||
'function' => $function,
|
||||
'signature' => $sig,
|
||||
'docstring' => $doc
|
||||
);
|
||||
}
|
||||
|
||||
function verifySignature($in, $sig)
|
||||
{
|
||||
for($i=0; $i<sizeof($sig); $i++)
|
||||
{
|
||||
// check each possible signature in turn
|
||||
$cursig=$sig[$i];
|
||||
if (sizeof($cursig)==$in->getNumParams()+1)
|
||||
{
|
||||
$itsOK=1;
|
||||
for($n=0; $n<$in->getNumParams(); $n++)
|
||||
{
|
||||
$p=$in->getParam($n);
|
||||
// print "<!-- $p -->\n";
|
||||
if ($p->kindOf() == 'scalar')
|
||||
{
|
||||
$pt=$p->scalartyp();
|
||||
}
|
||||
else
|
||||
{
|
||||
$pt=$p->kindOf();
|
||||
}
|
||||
// $n+1 as first type of sig is return type
|
||||
if ($pt != $cursig[$n+1])
|
||||
{
|
||||
$itsOK=0;
|
||||
$pno=$n+1; $wanted=$cursig[$n+1]; $got=$pt;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($itsOK)
|
||||
{
|
||||
return array(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return array(0, "Wanted ${wanted}, got ${got} at param ${pno})");
|
||||
}
|
||||
|
||||
function parseRequest($data='')
|
||||
{
|
||||
global $_xh,$HTTP_RAW_POST_DATA;
|
||||
global $xmlrpcerr, $xmlrpcstr, $xmlrpcerrxml, $xmlrpc_defencoding,
|
||||
$_xmlrpcs_dmap;
|
||||
|
||||
if ($data=="")
|
||||
{
|
||||
$data=$HTTP_RAW_POST_DATA;
|
||||
}
|
||||
$parser = xml_parser_create($xmlrpc_defencoding);
|
||||
|
||||
$_xh[$parser]=array();
|
||||
$_xh[$parser]['st']='';
|
||||
$_xh[$parser]['cm']=0;
|
||||
$_xh[$parser]['isf']=0;
|
||||
$_xh[$parser]['params']=array();
|
||||
$_xh[$parser]['method']='';
|
||||
|
||||
// decompose incoming XML into request structure
|
||||
|
||||
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true);
|
||||
xml_set_element_handler($parser, 'xmlrpc_se', 'xmlrpc_ee');
|
||||
xml_set_character_data_handler($parser, 'xmlrpc_cd');
|
||||
xml_set_default_handler($parser, 'xmlrpc_dh');
|
||||
if (!xml_parse($parser, $data, 1))
|
||||
{
|
||||
// return XML error as a faultCode
|
||||
$r=new xmlrpcresp(0,
|
||||
$xmlrpcerrxml+xml_get_error_code($parser),
|
||||
sprintf("XML error: %s at line %d",
|
||||
xml_error_string(xml_get_error_code($parser)),
|
||||
xml_get_current_line_number($parser)));
|
||||
xml_parser_free($parser);
|
||||
}
|
||||
else
|
||||
{
|
||||
xml_parser_free($parser);
|
||||
$m=new xmlrpcmsg($_xh[$parser]['method']);
|
||||
// now add parameters in
|
||||
$plist="";
|
||||
for($i=0; $i<sizeof($_xh[$parser]['params']); $i++)
|
||||
{
|
||||
//print "<!-- " . $_xh[$parser]['params'][$i]. "-->\n";
|
||||
$plist.="$i - " . $_xh[$parser]['params'][$i]. " \n";
|
||||
eval('$m->addParam(' . $_xh[$parser]['params'][$i]. ");");
|
||||
}
|
||||
// uncomment this to really see what the server's getting!
|
||||
// xmlrpc_debugmsg($plist);
|
||||
|
||||
$r = $this->execute($m);
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
function execute ($m)
|
||||
{
|
||||
global $xmlrpcerr, $xmlrpcstr, $_xmlrpcs_dmap;
|
||||
// now to deal with the method
|
||||
$methName = $m->method();
|
||||
$sysCall = ereg("^system\.", $methName);
|
||||
$dmap = $sysCall ? $_xmlrpcs_dmap : $this->dmap;
|
||||
|
||||
if (!isset($dmap[$methName]['function']))
|
||||
{
|
||||
// No such method
|
||||
return new xmlrpcresp(0,
|
||||
$xmlrpcerr['unknown_method'],
|
||||
$xmlrpcstr['unknown_method']);
|
||||
}
|
||||
|
||||
// Check signature.
|
||||
if (isset($dmap[$methName]['signature']))
|
||||
{
|
||||
$sig = $dmap[$methName]['signature'];
|
||||
list ($ok, $errstr) = $this->verifySignature($m, $sig);
|
||||
if (!$ok)
|
||||
{
|
||||
// Didn't match.
|
||||
return new xmlrpcresp(0,
|
||||
$xmlrpcerr['incorrect_params'],
|
||||
$xmlrpcstr['incorrect_params'] . ": ${errstr}");
|
||||
}
|
||||
}
|
||||
|
||||
$func = $dmap[$methName]['function'];
|
||||
|
||||
if ($sysCall)
|
||||
{
|
||||
return call_user_func($func, $this, $m);
|
||||
}
|
||||
else
|
||||
{
|
||||
return call_user_func($func, $m);
|
||||
}
|
||||
}
|
||||
|
||||
function echoInput()
|
||||
{
|
||||
global $HTTP_RAW_POST_DATA;
|
||||
|
||||
// a debugging routine: just echos back the input
|
||||
// packet as a string value
|
||||
|
||||
$r=new xmlrpcresp;
|
||||
$r->xv=new xmlrpcval( "'Aha said I: '" . $HTTP_RAW_POST_DATA, 'string');
|
||||
print $r->serialize();
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -1,90 +0,0 @@
|
|||
<?php
|
||||
include("xmlrpc.inc");
|
||||
|
||||
$host = "localhost";
|
||||
$port = 80;
|
||||
$serverscript = dirname($_SERVER['PHP_SELF'])."/alib_xr.php";
|
||||
$log = '';
|
||||
$ak = $_REQUEST['ak'];
|
||||
$sessid = $_REQUEST['sessid'];
|
||||
|
||||
switch($ak){
|
||||
case"test":
|
||||
$f=new xmlrpcmsg('alib.xrTest',
|
||||
array(new xmlrpcval($_REQUEST['str'], "string"),
|
||||
new xmlrpcval($_REQUEST['sessid'], "string")));
|
||||
break;
|
||||
case"login":
|
||||
$f=new xmlrpcmsg('alib.login',array(
|
||||
new xmlrpcval($_REQUEST['login'], "string"),
|
||||
new xmlrpcval($_REQUEST['pass'], "string")
|
||||
));
|
||||
break;
|
||||
case"logout":
|
||||
$f=new xmlrpcmsg('alib.logout', array(
|
||||
new xmlrpcval($_REQUEST['sessid'], "string")
|
||||
));
|
||||
break;
|
||||
}
|
||||
|
||||
switch($ak){
|
||||
case"test":
|
||||
case"login":
|
||||
case"logout":
|
||||
$c=new xmlrpc_client($serverscript, $host, $port);
|
||||
#$c->setDebug(1);
|
||||
$r=$c->send($f);
|
||||
if (!($r->faultCode()>0)) {
|
||||
$v=$r->value();
|
||||
$log = $v->serialize();
|
||||
if($ak=='test')
|
||||
{
|
||||
$log = split('_',$log);
|
||||
$log="{$log[0]}\nusername: {$log[1]}\ntoken: {$log[2]}";
|
||||
}
|
||||
if($ak=='login') $sessid = $v->scalarval();
|
||||
if($ak=='logout') $sessid = '';
|
||||
} else {
|
||||
$log = "Fault:\n Code: ".$r->faultCode()."\n".
|
||||
"Reason:'".$r->faultString()."'<BR>\n";
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
?>
|
||||
<html><head>
|
||||
<title>Alib XMLRPC test client</title>
|
||||
</head><body>
|
||||
<h2>Alib XMLRPC test client</h2>
|
||||
XMLRPC server: <b><?="http://$host:$port$serverscript"?></b><br>
|
||||
|
||||
<?=($log?'<h3>Output:</h3>':'')?>
|
||||
<pre style="background-color:#ddd"><?=$log?></pre>
|
||||
|
||||
<hr>
|
||||
<h3>test</h3>
|
||||
flip teststring to uppercase and print username and session token<br>
|
||||
<form method="post">
|
||||
test string: <input type="text" name="str" value="abCDef"><br>
|
||||
token: <input type="text" name="sessid" value="<?=$sessid?>" size="34"><br>
|
||||
<input type="hidden" name="ak" value="test">
|
||||
<input type="submit" value="Test">
|
||||
</form>
|
||||
<hr>
|
||||
<h3>login</h3>
|
||||
<form method="post">
|
||||
username: <input type="text" name="login" value="test1"><br>
|
||||
password: <input type="password" name="pass" value="a"><br>
|
||||
<input type="hidden" name="ak" value="login">
|
||||
<input type="submit" value="Login">
|
||||
</form>
|
||||
<hr>
|
||||
<h3>logout</h3>
|
||||
<form method="post">
|
||||
token: <input type="text" name="sessid" value="<?=$sessid?>" size="34"><br>
|
||||
<input type="hidden" name="ak" value="logout">
|
||||
<input type="submit" value="Logout">
|
||||
</form>
|
||||
<hr>
|
||||
<a href="../">Back</a>
|
||||
</body></html>
|
|
@ -1,77 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
#
|
||||
# Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
#
|
||||
# This file is part of the Campcaster project.
|
||||
# http://campcaster.sourcefabric.org/
|
||||
# To report bugs, send an e-mail to bugs@campware.org
|
||||
#
|
||||
# Campcaster is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Campcaster is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Campcaster; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
from xmlrpclib import *
|
||||
import sys
|
||||
|
||||
if len(sys.argv)<3:
|
||||
print """
|
||||
Usage: xr_cli_pok.py http://<server>/<path>/xmlrpc/alib_xr.php <command> <args>
|
||||
commands and args:
|
||||
test <teststring> [<sessin_id>]
|
||||
login <username> <password>
|
||||
logout <session_id>
|
||||
"""
|
||||
sys.exit(1)
|
||||
elif sys.argv[2]=="test":
|
||||
if len(sys.argv)>3:
|
||||
tstr=sys.argv[3]
|
||||
if len(sys.argv)>4:
|
||||
sessid=sys.argv[4]
|
||||
else:
|
||||
sessid=''
|
||||
path=sys.argv[1]
|
||||
server = Server(path)
|
||||
try:
|
||||
r = server.alib.xrTest(tstr, sessid)
|
||||
print r
|
||||
except Error, v:
|
||||
print "XML-RPC Error:",v
|
||||
elif sys.argv[2]=="login":
|
||||
login=sys.argv[3]
|
||||
passwd=sys.argv[4]
|
||||
path=sys.argv[1]
|
||||
server = Server(path)
|
||||
try:
|
||||
r = server.alib.login(login, passwd)
|
||||
print r
|
||||
except Error, v:
|
||||
print "XML-RPC Error:",v
|
||||
elif sys.argv[2]=="logout":
|
||||
sessid=sys.argv[3]
|
||||
path=sys.argv[1]
|
||||
server = Server(path)
|
||||
try:
|
||||
r = server.alib.logout(sessid)
|
||||
print r
|
||||
except Error, v:
|
||||
print "XML-RPC Error:",v
|
||||
else:
|
||||
print "Unknown command: "+sys.argv[2]
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
|
|
@ -1,90 +0,0 @@
|
|||
#!/bin/bash
|
||||
#-------------------------------------------------------------------------------
|
||||
# Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
#
|
||||
# This file is part of the Campcaster project.
|
||||
# http://campcaster.sourcefabric.org/
|
||||
#
|
||||
# Campcaster is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Campcaster is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Campcaster; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Run this to set up the build system: configure, makefiles, etc.
|
||||
# (based on the version in enlightenment's cvs)
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
package="PlaylistExecutor"
|
||||
|
||||
# assume we're in $basedir/bin
|
||||
reldir=`dirname $0`/..
|
||||
basedir=`cd $reldir; pwd;`
|
||||
test -z "$basedir" && basedir=.
|
||||
usrdir=`cd $basedir/../../../usr; pwd;`
|
||||
|
||||
bindir=$basedir/bin
|
||||
etcdir=$basedir/etc
|
||||
tmpdir=$basedir/tmp
|
||||
|
||||
cd "$tmpdir"
|
||||
DIE=0
|
||||
|
||||
(autoheader --version) < /dev/null > /dev/null 2>&1 || {
|
||||
echo
|
||||
echo "You must have autoconf installed to compile $package."
|
||||
echo "Download the appropriate package for your distribution,"
|
||||
echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
|
||||
DIE=1
|
||||
}
|
||||
|
||||
(autoconf --version) < /dev/null > /dev/null 2>&1 || {
|
||||
echo
|
||||
echo "You must have autoconf installed to compile $package."
|
||||
echo "Download the appropriate package for your distribution,"
|
||||
echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
|
||||
DIE=1
|
||||
}
|
||||
|
||||
if test "$DIE" -eq 1; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if test -z "$*"; then
|
||||
echo "I am going to run ./configure with no arguments - if you wish "
|
||||
echo "to pass any to it, please specify them on the $0 command line."
|
||||
fi
|
||||
|
||||
echo "Generating configuration files for $package, please wait...."
|
||||
|
||||
configure_ac=${etcdir}/configure.ac
|
||||
configure=${tmpdir}/configure
|
||||
aclocal_m4=${tmpdir}/aclocal.m4
|
||||
|
||||
# copy over configure.ac and acinlclude.m4 from etc to tmp,
|
||||
# as aclocal >= 1.8 is sooo unbelivably stupid that it will simply try to
|
||||
# look for configure.ac in the current directory, and include acinclude.m4
|
||||
# in aclocal.m4 it without a directory path in front
|
||||
ACLOCAL_FLAGS="-I ${tmpdir} --acdir=${tmpdir} --output=${aclocal_m4}"
|
||||
echo " aclocal $ACLOCAL_FLAGS"
|
||||
cp -f ${configure_ac} ${tmpdir}
|
||||
cp -f ${etcdir}/acinclude.m4 ${tmpdir}
|
||||
aclocal $ACLOCAL_FLAGS
|
||||
|
||||
echo " autoheader ${configure_ac}"
|
||||
autoheader ${configure_ac}
|
||||
|
||||
echo " autoconf -I ${tmpdir} -o ${configure} ${configure_ac}"
|
||||
autoconf -I ${tmpdir} -o ${configure} ${configure_ac}
|
||||
|
|
@ -1,75 +0,0 @@
|
|||
#!/bin/bash
|
||||
#-------------------------------------------------------------------------------
|
||||
# Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
#
|
||||
# This file is part of the Campcaster project.
|
||||
# http://campcaster.sourcefabric.org/
|
||||
#
|
||||
# Campcaster is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Campcaster is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Campcaster; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
#-------------------------------------------------------------------------------
|
||||
# This script generates code coverage data for the module
|
||||
#-------------------------------------------------------------------------------
|
||||
module="Campcaster PlaylistExecutor"
|
||||
|
||||
reldir=`dirname $0`/..
|
||||
basedir=`cd $reldir; pwd;`
|
||||
bindir=$basedir/bin
|
||||
docdir=$basedir/doc
|
||||
tmpdir=$basedir/tmp
|
||||
|
||||
usrdir=`cd $basedir/../../../usr; pwd;`
|
||||
|
||||
coverage_report_dir=$docdir/coverage
|
||||
|
||||
raw_coverage_file=$tmpdir/raw_coverage.info
|
||||
coverage_file=$tmpdir/coverage.info
|
||||
|
||||
lcov=$usrdir/bin/lcov
|
||||
genhtml=$usrdir/bin/genhtml
|
||||
|
||||
|
||||
cd $basedir
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Re-configure with covarege collection enabled, compile and run the tests
|
||||
#-------------------------------------------------------------------------------
|
||||
$bindir/autogen.sh --enable-coverage
|
||||
make clean
|
||||
make check
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Generate some symlinks so that the sources are visible from tmpdir
|
||||
#-------------------------------------------------------------------------------
|
||||
ln -s $basedir/include $tmpdir/include
|
||||
ln -s $basedir/src $tmpdir/src
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Use lcov to generate an HTML report on the coverage data
|
||||
#-------------------------------------------------------------------------------
|
||||
$lcov -d $tmpdir -c > $raw_coverage_file
|
||||
$lcov -e $raw_coverage_file "$tmpdir/*" > $coverage_file
|
||||
rm -rf $coverage_report_dir
|
||||
mkdir -p $coverage_report_dir
|
||||
$genhtml -t "$module" -o $coverage_report_dir $coverage_file
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Clean up
|
||||
#-------------------------------------------------------------------------------
|
||||
rm -f $tmpdir/include
|
||||
rm -f $tmpdir/src
|
|
@ -1,47 +0,0 @@
|
|||
#!/bin/sh
|
||||
#-------------------------------------------------------------------------------
|
||||
# Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
#
|
||||
# This file is part of the Campcaster project.
|
||||
# http://campcaster.campware.org/
|
||||
#
|
||||
# Campcaster is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Campcaster is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Campcaster; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Run this script to configure the environment.
|
||||
#
|
||||
# This script in effect calls the real automake / autoconf configure script
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
# assume we're in $basedir
|
||||
reldir=`dirname $0`
|
||||
basedir=`cd $reldir; pwd;`
|
||||
test -z "$basedir" && basedir=.
|
||||
|
||||
bindir=$basedir/bin
|
||||
tmpdir=$basedir/tmp
|
||||
|
||||
|
||||
autogen=$bindir/autogen.sh
|
||||
configure=$tmpdir/configure
|
||||
|
||||
if [ ! -x $configure ]; then
|
||||
(cd $basedir && $autogen $*)
|
||||
fi
|
||||
|
||||
(cd $tmpdir && $configure $*)
|
||||
|
|
@ -1 +0,0 @@
|
|||
keep me
|
|
@ -1,217 +0,0 @@
|
|||
#-------------------------------------------------------------------------------
|
||||
# Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
#
|
||||
# This file is part of the Campcaster project.
|
||||
# http://campcaster.sourcefabric.org/
|
||||
#
|
||||
# Campcaster is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Campcaster is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Campcaster; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
# @configure_input@
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# General command definitions
|
||||
#-------------------------------------------------------------------------------
|
||||
MKDIR = mkdir -p
|
||||
RM = rm -f
|
||||
RMDIR = rm -rf
|
||||
DOXYGEN = doxygen
|
||||
CP = cp -f
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Basic directory and file definitions
|
||||
#-------------------------------------------------------------------------------
|
||||
BASE_DIR = @builddir@
|
||||
DOC_DIR = ${BASE_DIR}/doc
|
||||
DOXYGEN_DIR = ${DOC_DIR}/doxygen
|
||||
COVERAGE_DIR = ${DOC_DIR}/coverage
|
||||
ETC_DIR = ${BASE_DIR}/etc
|
||||
INCLUDE_DIR = ${BASE_DIR}/include
|
||||
LIB_DIR = ${BASE_DIR}/lib
|
||||
SRC_DIR = ${BASE_DIR}/src
|
||||
TMP_DIR = ${BASE_DIR}/tmp
|
||||
|
||||
VAR_DIR = ${BASE_DIR}/var
|
||||
TMP_CC_DIR = /tmp/campcaster
|
||||
|
||||
REAL_BASE_DIR=$(shell cd ${BASE_DIR}; pwd)
|
||||
|
||||
|
||||
prefix = @prefix@
|
||||
|
||||
USR_DIR = ${prefix}
|
||||
USR_INCLUDE_DIR = ${USR_DIR}/include
|
||||
USR_LIB_DIR = ${USR_DIR}/lib
|
||||
|
||||
|
||||
MODULES_DIR = ${BASE_DIR}/..
|
||||
|
||||
CORE_DIR = ${MODULES_DIR}/core
|
||||
CORE_INCLUDE_DIR = ${CORE_DIR}/include
|
||||
CORE_LIB_DIR = ${CORE_DIR}/lib
|
||||
CORE_LIB = livesupport_core
|
||||
CORE_LIB_FILE = ${CORE_LIB_DIR}/lib${CORE_LIB}.a
|
||||
|
||||
|
||||
VPATH = ${SRC_DIR}
|
||||
|
||||
BOOST_CFLAGS=@BOOST_CPPFLAGS@
|
||||
BOOST_LIBS=@BOOST_LDFLAGS@
|
||||
BOOST_DATE_TIME_LIB=@BOOST_DATE_TIME_LIB@
|
||||
|
||||
LIBXMLPP_CFLAGS=@LIBXMLPP_CFLAGS@
|
||||
LIBXMLPP_LIBS=@LIBXMLPP_LIBS@
|
||||
|
||||
ICU_CFLAGS=@ICU_CFLAGS@
|
||||
ICU_CXXFLAGS=@ICU_CXXFLAGS@
|
||||
ICU_LIBS=@ICU_LIBS@
|
||||
|
||||
GSTREAMER_CFLAGS=@GSTREAMER_CFLAGS@
|
||||
GSTREAMER_LIBS=@GSTREAMER_LIBS@
|
||||
|
||||
GSTCONTROLLER_CFLAGS=@GSTCONTROLLER_CFLAGS@
|
||||
GSTCONTROLLER_LIBS=@GSTCONTROLLER_LIBS@
|
||||
|
||||
TAGLIB_CFLAGS=@TAGLIB_CFLAGS@
|
||||
TAGLIB_LIBS=@TAGLIB_LIBS@
|
||||
|
||||
TEST_RESULTS = ${DOC_DIR}/testResults.xml
|
||||
# the text result XSLT has to be relative to the test result file, e.g. TMP_DIR
|
||||
TEST_XSLT = ../etc/testResultToHtml.xsl
|
||||
|
||||
PLAYLIST_EXECUTOR_LIB = livesupport_playlist_executor
|
||||
PLAYLIST_EXECUTOR_LIB_FILE = ${LIB_DIR}/lib${PLAYLIST_EXECUTOR_LIB}.a
|
||||
TEST_RUNNER = ${TMP_DIR}/testRunner
|
||||
TWOTEST_RUNNER = ${TMP_DIR}/twoTestRunner
|
||||
|
||||
DOXYGEN_CONFIG = ${ETC_DIR}/doxygen.config
|
||||
|
||||
export LD_LIBRARY_PATH:=${USR_LIB_DIR}:${LD_LIBRARY_PATH}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Configuration parameters
|
||||
#-------------------------------------------------------------------------------
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CXXFLAGS = @CXXFLAGS@ @DEFS@ @COVERAGE_CXXFLAGS@ -pthread \
|
||||
-Wall -Wno-long-long \
|
||||
${BOOST_CFLAGS} \
|
||||
${LIBXMLPP_CFLAGS} \
|
||||
${GSTREAMER_CFLAGS} \
|
||||
${GSTCONTROLLER_CFLAGS} \
|
||||
-I${USR_INCLUDE_DIR} \
|
||||
-I${CORE_INCLUDE_DIR} \
|
||||
-I${INCLUDE_DIR} -I${TMP_DIR}
|
||||
LDFLAGS = @LDFLAGS@ -pthread \
|
||||
${BOOST_LIBS} \
|
||||
${LIBXMLPP_LIBS} \
|
||||
${ICU_LIBS} \
|
||||
${GSTREAMER_LIBS} \
|
||||
${GSTCONTROLLER_LIBS} \
|
||||
${TAGLIB_LIBS} \
|
||||
-L${USR_LIB_DIR} \
|
||||
-L${CORE_LIB_DIR} \
|
||||
-L${LIB_DIR}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Dependencies
|
||||
#-------------------------------------------------------------------------------
|
||||
PLAYLIST_EXECUTOR_LIB_OBJS = ${TMP_DIR}/AudioPlayerFactory.o \
|
||||
${TMP_DIR}/GstreamerPlayer.o
|
||||
TEST_RUNNER_OBJS = ${TMP_DIR}/TestRunner.o \
|
||||
${TMP_DIR}/AudioPlayerFactoryGstreamerTest.o
|
||||
# ${TMP_DIR}/GstreamerPlayerTest.o
|
||||
TEST_RUNNER_LIBS = -l${PLAYLIST_EXECUTOR_LIB} -l${CORE_LIB} \
|
||||
${TAGLIB_LIBS} \
|
||||
${BOOST_DATE_TIME_LIB} -lcppunit -ldl -lm -lxmlrpc++
|
||||
|
||||
TWOTEST_RUNNER_OBJS = ${TMP_DIR}/TestRunner.o \
|
||||
${TMP_DIR}/TwoGstreamerPlayersTest.o
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Targets
|
||||
#-------------------------------------------------------------------------------
|
||||
.PHONY: all dir_setup doc clean docclean depclean distclean check install
|
||||
|
||||
all: dir_setup ${PLAYLIST_EXECUTOR_LIB_FILE}
|
||||
|
||||
dir_setup: ${TMP_DIR} ${DOXYGEN_DIR}
|
||||
|
||||
doc:
|
||||
${DOXYGEN} ${DOXYGEN_CONFIG}
|
||||
|
||||
clean:
|
||||
${RM} ${PLAYLIST_EXECUTOR_LIB_OBJS} ${PLAYLIST_EXECUTOR_LIB_FILE}
|
||||
${RM} ${TEST_RUNNER_OBJS} ${TWOTEST_RUNNER_OBJS} ${TEST_RUNNER}
|
||||
${RM} ${TMP_DIR}/*.bb ${TMP_DIR}/*.bbg ${TMP_DIR}/*.da ${TMP_DIR}/*.info
|
||||
|
||||
docclean:
|
||||
${RMDIR} ${DOXYGEN_DIR}/html
|
||||
${RMDIR} ${COVERAGE_DIR}/*
|
||||
${RM} ${TEST_RESULTS}
|
||||
|
||||
depclean: clean
|
||||
|
||||
distclean: clean docclean
|
||||
${RMDIR} ${TMP_DIR}/config* ${TMP_DIR}/autom4te* ${TMP_DIR}/ac*.m4
|
||||
|
||||
check: all ${TEST_RUNNER}
|
||||
${MKDIR} ${TMP_CC_DIR}
|
||||
${CP} ${VAR_DIR}/* ${TMP_CC_DIR}/
|
||||
${TEST_RUNNER} -o ${TEST_RESULTS} -s ${TEST_XSLT}
|
||||
|
||||
check_two: all ${TWOTEST_RUNNER}
|
||||
${TWOTEST_RUNNER} -o ${TEST_RESULTS} -s ${TEST_XSLT}
|
||||
|
||||
install: all
|
||||
${MKDIR} ${USR_INCLUDE_DIR}/LiveSupport/PlaylistExecutor
|
||||
${CP} ${INCLUDE_DIR}/LiveSupport/PlaylistExecutor/*.h \
|
||||
${USR_INCLUDE_DIR}/LiveSupport/PlaylistExecutor
|
||||
${CP} ${PLAYLIST_EXECUTOR_LIB_FILE} ${USR_LIB_DIR}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Specific targets
|
||||
#-------------------------------------------------------------------------------
|
||||
${PLAYLIST_EXECUTOR_LIB_FILE}: ${PLAYLIST_EXECUTOR_LIB_OBJS}
|
||||
${AR} crus $@ $^
|
||||
|
||||
${TMP_DIR}:
|
||||
${MKDIR} ${TMP_DIR}
|
||||
|
||||
${DOXYGEN_DIR}:
|
||||
${MKDIR} ${DOXYGEN_DIR}
|
||||
|
||||
${TEST_RUNNER}: ${CORE_LIB_FILE} \
|
||||
${TEST_RUNNER_OBJS} ${PLAYLIST_EXECUTOR_LIB_FILE}
|
||||
${CXX} ${LDFLAGS} -o $@ ${TEST_RUNNER_OBJS} ${TEST_RUNNER_LIBS}
|
||||
|
||||
${TWOTEST_RUNNER}: ${CORE_LIB_FILE} \
|
||||
${TWOTEST_RUNNER_OBJS} ${PLAYLIST_EXECUTOR_LIB_FILE}
|
||||
${CXX} ${LDFLAGS} -o $@ ${TWOTEST_RUNNER_OBJS} ${TEST_RUNNER_LIBS}
|
||||
|
||||
${CORE_LIB_FILE}:
|
||||
${MAKE} -C ${CORE_DIR}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Pattern rules
|
||||
#-------------------------------------------------------------------------------
|
||||
${TMP_DIR}/%.o : ${SRC_DIR}/%.cxx
|
||||
${CXX} ${CPPFLAGS} ${CXXFLAGS} -c -o $@ $<
|
||||
|
|
@ -1,519 +0,0 @@
|
|||
dnl-----------------------------------------------------------------------------
|
||||
dnl Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
dnl
|
||||
dnl This file is part of the Campcaster project.
|
||||
dnl http://campcaster.sourcefabric.org/
|
||||
dnl
|
||||
dnl Campcaster is free software; you can redistribute it and/or modify
|
||||
dnl it under the terms of the GNU General Public License as published by
|
||||
dnl the Free Software Foundation; either version 2 of the License, or
|
||||
dnl (at your option) any later version.
|
||||
dnl
|
||||
dnl Campcaster is distributed in the hope that it will be useful,
|
||||
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
dnl GNU General Public License for more details.
|
||||
dnl
|
||||
dnl You should have received a copy of the GNU General Public License
|
||||
dnl along with Campcaster; if not, write to the Free Software
|
||||
dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
dnl
|
||||
dnl-----------------------------------------------------------------------------
|
||||
|
||||
dnl-----------------------------------------------------------------------------
|
||||
dnl Macro to check for available modules using pkg-conf
|
||||
dnl
|
||||
dnl usage:
|
||||
dnl PKG_CHECK_MODULES(GSTUFF,[gtk+-2.0 >= 1.3], action-if, action-not)
|
||||
dnl
|
||||
dnl defines GSTUFF_LIBS, GSTUFF_CFLAGS, see pkg-config man page
|
||||
dnl also defines GSTUFF_PKG_ERRORS on error
|
||||
dnl
|
||||
dnl This function was taken from the glade-- project
|
||||
dnl-----------------------------------------------------------------------------
|
||||
AC_DEFUN([PKG_CHECK_MODULES], [
|
||||
succeeded=no
|
||||
|
||||
if test -z "$PKG_CONFIG"; then
|
||||
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
|
||||
fi
|
||||
|
||||
if test "$PKG_CONFIG" = "no" ; then
|
||||
echo "*** The pkg-config script could not be found. Make sure it is"
|
||||
echo "*** in your path, or set the PKG_CONFIG environment variable"
|
||||
echo "*** to the full path to pkg-config."
|
||||
echo "*** Or see http://www.freedesktop.org/software/pkgconfig to get pkg-config."
|
||||
else
|
||||
PKG_CONFIG_MIN_VERSION=0.9.0
|
||||
if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
|
||||
AC_MSG_CHECKING(for $2)
|
||||
|
||||
if $PKG_CONFIG --exists "$2" ; then
|
||||
AC_MSG_RESULT(yes)
|
||||
succeeded=yes
|
||||
|
||||
AC_MSG_CHECKING($1_CFLAGS)
|
||||
$1_CFLAGS=`$PKG_CONFIG --cflags "$2"`
|
||||
AC_MSG_RESULT($$1_CFLAGS)
|
||||
|
||||
AC_MSG_CHECKING($1_LIBS)
|
||||
$1_LIBS=`$PKG_CONFIG --libs "$2"`
|
||||
AC_MSG_RESULT($$1_LIBS)
|
||||
else
|
||||
$1_CFLAGS=""
|
||||
$1_LIBS=""
|
||||
## If we have a custom action on failure, don't print errors, but
|
||||
## do set a variable so people can do so.
|
||||
$1_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"`
|
||||
ifelse([$4], ,echo $$1_PKG_ERRORS,)
|
||||
fi
|
||||
|
||||
AC_SUBST($1_CFLAGS)
|
||||
AC_SUBST($1_LIBS)
|
||||
else
|
||||
echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
|
||||
echo "*** See http://www.freedesktop.org/software/pkgconfig"
|
||||
fi
|
||||
fi
|
||||
|
||||
if test $succeeded = yes; then
|
||||
ifelse([$3], , :, [$3])
|
||||
else
|
||||
ifelse([$4], , AC_MSG_ERROR([Library requirements ($2) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them.]), [$4])
|
||||
fi
|
||||
])
|
||||
|
||||
|
||||
|
||||
dnl-----------------------------------------------------------------------------
|
||||
dnl Macro to check for taglib of sufficient version by looking at taglib-config
|
||||
dnl
|
||||
dnl usage:
|
||||
dnl AC_CHECK_TAGLIB(version, action-if, action-not)
|
||||
dnl
|
||||
dnl defines TAGLIB_LIBS, TAGLIB_CFLAGS, see taglib-config man page
|
||||
dnl-----------------------------------------------------------------------------
|
||||
AC_DEFUN([AC_CHECK_TAGLIB], [
|
||||
succeeded=no
|
||||
|
||||
if test -z "$TAGLIB_CONFIG"; then
|
||||
AC_PATH_PROG(TAGLIB_CONFIG, taglib-config, no)
|
||||
fi
|
||||
|
||||
if test "$TAGLIB_CONFIG" = "no" ; then
|
||||
echo "*** The taglib-config script could not be found. Make sure it is"
|
||||
echo "*** in your path, and that taglib is properly installed."
|
||||
echo "*** Or see http://developer.kde.org/~wheeler/taglib.html"
|
||||
else
|
||||
TAGLIB_VERSION=`$TAGLIB_CONFIG --version`
|
||||
AC_MSG_CHECKING(for taglib >= $1)
|
||||
VERSION_CHECK=`expr $TAGLIB_VERSION \>\= $1`
|
||||
if test "$VERSION_CHECK" = "1" ; then
|
||||
AC_MSG_RESULT(yes)
|
||||
succeeded=yes
|
||||
|
||||
AC_MSG_CHECKING(TAGLIB_CFLAGS)
|
||||
TAGLIB_CFLAGS=`$TAGLIB_CONFIG --cflags`
|
||||
AC_MSG_RESULT($TAGLIB_CFLAGS)
|
||||
|
||||
AC_MSG_CHECKING(TAGLIB_LIBS)
|
||||
TAGLIB_LIBS=`$TAGLIB_CONFIG --libs`
|
||||
AC_MSG_RESULT($TAGLIB_LIBS)
|
||||
else
|
||||
TAGLIB_CFLAGS=""
|
||||
TAGLIB_LIBS=""
|
||||
## If we have a custom action on failure, don't print errors, but
|
||||
## do set a variable so people can do so.
|
||||
ifelse([$3], ,echo "can't find taglib >= $1",)
|
||||
fi
|
||||
|
||||
AC_SUBST(TAGLIB_CFLAGS)
|
||||
AC_SUBST(TAGLIB_LIBS)
|
||||
fi
|
||||
|
||||
if test $succeeded = yes; then
|
||||
ifelse([$2], , :, [$2])
|
||||
else
|
||||
ifelse([$3], , AC_MSG_ERROR([Library requirements (taglib) not met.]), [$3])
|
||||
fi
|
||||
])
|
||||
|
||||
|
||||
|
||||
dnl-----------------------------------------------------------------------------
|
||||
dnl Macro to check for ICU of sufficient version by looking at icu-config
|
||||
dnl
|
||||
dnl usage:
|
||||
dnl AC_CHECK_ICU(version, action-if, action-not)
|
||||
dnl
|
||||
dnl defines ICU_LIBS, ICU_CFLAGS, ICU_CXXFLAGS, see icu-config man page
|
||||
dnl-----------------------------------------------------------------------------
|
||||
AC_DEFUN([AC_CHECK_ICU], [
|
||||
succeeded=no
|
||||
|
||||
if test -z "$ICU_CONFIG"; then
|
||||
AC_PATH_PROG(ICU_CONFIG, icu-config, no)
|
||||
fi
|
||||
|
||||
if test "$ICU_CONFIG" = "no" ; then
|
||||
echo "*** The icu-config script could not be found. Make sure it is"
|
||||
echo "*** in your path, and that taglib is properly installed."
|
||||
echo "*** Or see http://ibm.com/software/globalization/icu/"
|
||||
else
|
||||
ICU_VERSION=`$ICU_CONFIG --version`
|
||||
AC_MSG_CHECKING(for ICU >= $1)
|
||||
VERSION_CHECK=`expr $ICU_VERSION \>\= $1`
|
||||
if test "$VERSION_CHECK" = "1" ; then
|
||||
AC_MSG_RESULT(yes)
|
||||
succeeded=yes
|
||||
|
||||
AC_MSG_CHECKING(ICU_CFLAGS)
|
||||
ICU_CFLAGS=`$ICU_CONFIG --cflags`
|
||||
AC_MSG_RESULT($ICU_CFLAGS)
|
||||
|
||||
AC_MSG_CHECKING(ICU_CXXFLAGS)
|
||||
ICU_CXXFLAGS=`$ICU_CONFIG --cxxflags`
|
||||
AC_MSG_RESULT($ICU_CXXFLAGS)
|
||||
|
||||
AC_MSG_CHECKING(ICU_LIBS)
|
||||
ICU_LIBS=`$ICU_CONFIG --ldflags`
|
||||
AC_MSG_RESULT($ICU_LIBS)
|
||||
else
|
||||
ICU_CFLAGS=""
|
||||
ICU_CXXFLAGS=""
|
||||
ICU_LIBS=""
|
||||
## If we have a custom action on failure, don't print errors, but
|
||||
## do set a variable so people can do so.
|
||||
ifelse([$3], ,echo "can't find ICU >= $1",)
|
||||
fi
|
||||
|
||||
AC_SUBST(ICU_CFLAGS)
|
||||
AC_SUBST(ICU_CXXFLAGS)
|
||||
AC_SUBST(ICU_LIBS)
|
||||
fi
|
||||
|
||||
if test $succeeded = yes; then
|
||||
ifelse([$2], , :, [$2])
|
||||
else
|
||||
ifelse([$3], , AC_MSG_ERROR([Library requirements (ICU) not met.]), [$3])
|
||||
fi
|
||||
])
|
||||
|
||||
|
||||
|
||||
dnl-----------------------------------------------------------------------------
|
||||
dnl Macro to check for C++ namespaces
|
||||
dnl for more information on this macro, see
|
||||
dnl http://autoconf-archive.cryp.to/ac_cxx_namespaces.html
|
||||
dnl
|
||||
dnl usage:
|
||||
dnl If the compiler can prevent names clashes using namespaces,
|
||||
dnl define HAVE_NAMESPACES.
|
||||
dnl-----------------------------------------------------------------------------
|
||||
AC_DEFUN([AC_CXX_NAMESPACES],
|
||||
[AC_CACHE_CHECK(whether the compiler implements namespaces,
|
||||
ac_cv_cxx_namespaces,
|
||||
[AC_LANG_SAVE
|
||||
AC_LANG_CPLUSPLUS
|
||||
AC_TRY_COMPILE([namespace Outer { namespace Inner { int i = 0; }}],
|
||||
[using namespace Outer::Inner; return i;],
|
||||
ac_cv_cxx_namespaces=yes, ac_cv_cxx_namespaces=no)
|
||||
AC_LANG_RESTORE
|
||||
])
|
||||
if test "$ac_cv_cxx_namespaces" = yes; then
|
||||
AC_DEFINE(HAVE_NAMESPACES,,[define if the compiler implements namespaces])
|
||||
fi
|
||||
])
|
||||
|
||||
|
||||
dnl-----------------------------------------------------------------------------
|
||||
dnl Test for the Boost C++ libraries of a particular version (or newer).
|
||||
dnl for more information on boost, see http://www.boost.org/
|
||||
dnl for more information on this macro, see
|
||||
dnl http://autoconf-archive.cryp.to/ax_boost_base.html
|
||||
dnl
|
||||
dnl usage:
|
||||
dnl If no path to the installed boost library is given the macro searches
|
||||
dnl under ${prefix}, /usr, /usr/local, and /opt, and evaluates the $BOOST_ROOT
|
||||
dnl environment variable. Further documentation is available at
|
||||
dnl http://randspringer.de/boost/index.html
|
||||
dnl
|
||||
dnl This macro calls: AC_SUBST(BOOST_CPPFLAGS) and AC_SUBST(BOOST_LDFLAGS)
|
||||
dnl and sets: HAVE_BOOST
|
||||
dnl
|
||||
dnl Modified for Campcaster:
|
||||
dnl * --with-boost default changed to Yes;
|
||||
dnl * if the library is not found, it does not die, just prints "no", leaves
|
||||
dnl HAVE_BOOST undefined, and sets the BOOST_CPPFLAGS and BOOST_LDFLAGS
|
||||
dnl variables to "";
|
||||
dnl * ${prefix} is prepended to the search path.
|
||||
dnl
|
||||
dnl Author: Thomas Porschberg <thomas@randspringer.de>
|
||||
dnl
|
||||
dnl License:
|
||||
dnl Copyright © 2006 Thomas Porschberg <thomas@randspringer.de>
|
||||
dnl Copying and distribution of this file, with or without modification,
|
||||
dnl are permitted in any medium without royalty provided the copyright notice
|
||||
dnl and this notice are preserved.
|
||||
dnl-----------------------------------------------------------------------------
|
||||
AC_DEFUN([AX_BOOST_BASE],
|
||||
[
|
||||
AC_ARG_WITH([boost],
|
||||
AS_HELP_STRING([--with-boost@<:@=DIR@:>@], [use boost (default is Yes) - it is possible to specify the root directory for boost (optional)]),
|
||||
[
|
||||
if test "$withval" = "no"; then
|
||||
want_boost="no"
|
||||
elif test "$withval" = "yes"; then
|
||||
want_boost="yes"
|
||||
ac_boost_path=""
|
||||
else
|
||||
want_boost="yes"
|
||||
ac_boost_path="$withval"
|
||||
fi
|
||||
],
|
||||
[want_boost="yes"])
|
||||
|
||||
if test "x$want_boost" = "xyes"; then
|
||||
boost_lib_version_req=ifelse([$1], ,1.20.0,$1)
|
||||
boost_lib_version_req_shorten=`expr $boost_lib_version_req : '\([[0-9]]*\.[[0-9]]*\)'`
|
||||
boost_lib_version_req_major=`expr $boost_lib_version_req : '\([[0-9]]*\)'`
|
||||
boost_lib_version_req_minor=`expr $boost_lib_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
|
||||
boost_lib_version_req_sub_minor=`expr $boost_lib_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
|
||||
if test "x$boost_lib_version_req_sub_minor" = "x" ; then
|
||||
boost_lib_version_req_sub_minor="0"
|
||||
fi
|
||||
WANT_BOOST_VERSION=`expr $boost_lib_version_req_major \* 100000 \+ $boost_lib_version_req_minor \* 100 \+ $boost_lib_version_req_sub_minor`
|
||||
AC_MSG_CHECKING(for boostlib >= $boost_lib_version_req)
|
||||
succeeded=no
|
||||
|
||||
dnl first we check the system location for boost libraries
|
||||
dnl this location ist chosen if boost libraries are installed with the --layout=system option
|
||||
dnl or if you install boost with RPM
|
||||
if test "$ac_boost_path" != ""; then
|
||||
BOOST_LDFLAGS="-L$ac_boost_path/lib"
|
||||
BOOST_CPPFLAGS="-I$ac_boost_path/include"
|
||||
else
|
||||
for ac_boost_path_tmp in ${prefix} /usr /usr/local /opt ; do
|
||||
if test -d "$ac_boost_path_tmp/include/boost" && test -r "$ac_boost_path_tmp/include/boost"; then
|
||||
BOOST_LDFLAGS="-L$ac_boost_path_tmp/lib"
|
||||
BOOST_CPPFLAGS="-I$ac_boost_path_tmp/include"
|
||||
break;
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
CPPFLAGS_SAVED="$CPPFLAGS"
|
||||
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
|
||||
export CPPFLAGS
|
||||
|
||||
LDFLAGS_SAVED="$LDFLAGS"
|
||||
LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
|
||||
export LDFLAGS
|
||||
|
||||
AC_LANG_PUSH(C++)
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
||||
@%:@include <boost/version.hpp>
|
||||
]], [[
|
||||
#if BOOST_VERSION >= $WANT_BOOST_VERSION
|
||||
// Everything is okay
|
||||
#else
|
||||
# error Boost version is too old
|
||||
#endif
|
||||
]])],[
|
||||
AC_MSG_RESULT(yes)
|
||||
succeeded=yes
|
||||
found_system=yes
|
||||
],[
|
||||
])
|
||||
AC_LANG_POP([C++])
|
||||
|
||||
|
||||
|
||||
dnl if we found no boost with system layout we search for boost libraries
|
||||
dnl built and installed without the --layout=system option or for a staged(not installed) version
|
||||
if test "x$succeeded" != "xyes"; then
|
||||
_version=0
|
||||
if test "$ac_boost_path" != ""; then
|
||||
BOOST_LDFLAGS="-L$ac_boost_path/lib"
|
||||
if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
|
||||
for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do
|
||||
_version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
|
||||
V_CHECK=`expr $_version_tmp \> $_version`
|
||||
if test "$V_CHECK" = "1" ; then
|
||||
_version=$_version_tmp
|
||||
fi
|
||||
VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
|
||||
BOOST_CPPFLAGS="-I$ac_boost_path/include/boost-$VERSION_UNDERSCORE"
|
||||
done
|
||||
fi
|
||||
else
|
||||
for ac_boost_path in /usr /usr/local /opt ; do
|
||||
if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
|
||||
for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do
|
||||
_version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
|
||||
V_CHECK=`expr $_version_tmp \> $_version`
|
||||
if test "$V_CHECK" = "1" ; then
|
||||
_version=$_version_tmp
|
||||
best_path=$ac_boost_path
|
||||
fi
|
||||
done
|
||||
fi
|
||||
done
|
||||
|
||||
VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
|
||||
BOOST_CPPFLAGS="-I$best_path/include/boost-$VERSION_UNDERSCORE"
|
||||
BOOST_LDFLAGS="-L$best_path/lib"
|
||||
|
||||
if test "x$BOOST_ROOT" != "x"; then
|
||||
if test -d "$BOOST_ROOT" && test -r "$BOOST_ROOT" && test -d "$BOOST_ROOT/stage/lib" && test -r "$BOOST_ROOT/stage/lib"; then
|
||||
version_dir=`expr //$BOOST_ROOT : '.*/\(.*\)'`
|
||||
stage_version=`echo $version_dir | sed 's/boost_//' | sed 's/_/./g'`
|
||||
stage_version_shorten=`expr $stage_version : '\([[0-9]]*\.[[0-9]]*\)'`
|
||||
V_CHECK=`expr $stage_version_shorten \>\= $_version`
|
||||
if test "$V_CHECK" = "1" ; then
|
||||
AC_MSG_NOTICE(We will use a staged boost library from $BOOST_ROOT)
|
||||
BOOST_CPPFLAGS="-I$BOOST_ROOT"
|
||||
BOOST_LDFLAGS="-L$BOOST_ROOT/stage/lib"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
|
||||
export CPPFLAGS
|
||||
LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
|
||||
export LDFLAGS
|
||||
|
||||
AC_LANG_PUSH(C++)
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
||||
@%:@include <boost/version.hpp>
|
||||
]], [[
|
||||
#if BOOST_VERSION >= $WANT_BOOST_VERSION
|
||||
// Everything is okay
|
||||
#else
|
||||
# error Boost version is too old
|
||||
#endif
|
||||
]])],[
|
||||
AC_MSG_RESULT(yes)
|
||||
succeeded=yes
|
||||
found_system=yes
|
||||
],[
|
||||
])
|
||||
AC_LANG_POP([C++])
|
||||
fi
|
||||
|
||||
if test "$succeeded" != "yes" ; then
|
||||
BOOST_CPPFLAGS=""
|
||||
BOOST_LDFLAGS=""
|
||||
AC_MSG_RESULT(no)
|
||||
else
|
||||
AC_SUBST(BOOST_CPPFLAGS)
|
||||
AC_SUBST(BOOST_LDFLAGS)
|
||||
AC_DEFINE(HAVE_BOOST,,[define if the Boost library is available])
|
||||
fi
|
||||
|
||||
CPPFLAGS="$CPPFLAGS_SAVED"
|
||||
LDFLAGS="$LDFLAGS_SAVED"
|
||||
fi
|
||||
|
||||
])
|
||||
|
||||
|
||||
dnl-----------------------------------------------------------------------------
|
||||
dnl Test for Date_Time library from the Boost C++ libraries.
|
||||
dnl for more information on boost, see http://www.boost.org/
|
||||
dnl for more information on this macro, see
|
||||
dnl http://autoconf-archive.cryp.to/ax_boost_date_time.html
|
||||
dnl
|
||||
dnl usage:
|
||||
dnl The macro requires a preceding call to AX_BOOST_BASE.
|
||||
dnl Further documentation is available at
|
||||
dnl <http://randspringer.de/boost/index.html>.
|
||||
dnl
|
||||
dnl This macro calls: AC_SUBST(BOOST_DATE_TIME_LIB)
|
||||
dnl and sets: HAVE_BOOST_DATE_TIME
|
||||
dnl
|
||||
dnl Modified for Campcaster:
|
||||
dnl * --with-boost-date-time default changed to Yes.
|
||||
dnl * added some more recognized suffixes to the library's name, incl. "-st".
|
||||
dnl
|
||||
dnl Authors:
|
||||
dnl Thomas Porschberg <thomas@randspringer.de>
|
||||
dnl Michael Tindal <mtindal@paradoxpoint.com>
|
||||
dnl
|
||||
dnl License:
|
||||
dnl Copyright © 2006 Thomas Porschberg <thomas@randspringer.de>
|
||||
dnl Copying and distribution of this file, with or without modification,
|
||||
dnl are permitted in any medium without royalty provided the copyright notice
|
||||
dnl and this notice are preserved.
|
||||
dnl-----------------------------------------------------------------------------
|
||||
AC_DEFUN([AX_BOOST_DATE_TIME],
|
||||
[
|
||||
AC_ARG_WITH([boost-date-time],
|
||||
AS_HELP_STRING([--with-boost-date-time@<:@=special-lib@:>@],
|
||||
[use the Date_Time library from boost - it is possible to specify a certain library for the linker
|
||||
e.g. --with-boost-date-time=boost_date_time-gcc-mt-d-1_33_1 ]),
|
||||
[
|
||||
if test "$withval" = "no"; then
|
||||
want_boost="no"
|
||||
elif test "$withval" = "yes"; then
|
||||
want_boost="yes"
|
||||
ax_boost_user_date_time_lib=""
|
||||
else
|
||||
want_boost="yes"
|
||||
ax_boost_user_date_time_lib="$withval"
|
||||
fi
|
||||
],
|
||||
[want_boost="yes"]
|
||||
)
|
||||
|
||||
if test "x$want_boost" = "xyes"; then
|
||||
AC_REQUIRE([AC_PROG_CC])
|
||||
CPPFLAGS_SAVED="$CPPFLAGS"
|
||||
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
|
||||
export CPPFLAGS
|
||||
|
||||
LDFLAGS_SAVED="$LDFLAGS"
|
||||
LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
|
||||
export LDFLAGS
|
||||
|
||||
AC_CACHE_CHECK(whether the Boost::Date_Time library is available,
|
||||
ax_cv_boost_date_time,
|
||||
[AC_LANG_PUSH([C++])
|
||||
AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[@%:@include <boost/date_time/gregorian/gregorian_types.hpp>]],
|
||||
[[using namespace boost::gregorian; date d(2002,Jan,10);
|
||||
return 0;
|
||||
]]),
|
||||
ax_cv_boost_date_time=yes, ax_cv_boost_date_time=no)
|
||||
AC_LANG_POP([C++])
|
||||
])
|
||||
if test "x$ax_cv_boost_date_time" = "xyes"; then
|
||||
AC_DEFINE(HAVE_BOOST_DATE_TIME,,[define if the Boost::Date_Time library is available])
|
||||
BN=boost_date_time
|
||||
if test "x$ax_boost_user_date_time_lib" = "x"; then
|
||||
for ax_lib in $BN $BN-st $BN-mt $BN-mt-s $BN-s \
|
||||
$BN-$CC $BN-$CC-st $BN-$CC-mt $BN-$CC-mt-s $BN-$CC-s \
|
||||
lib$BN lib$BN-st lib$BN-mt lib$BN-mt-s lib$BN-s \
|
||||
lib$BN-$CC lib$BN-$CC-st lib$BN-$CC-mt lib$BN-$CC-mt-s lib$BN-$CC-s \
|
||||
$BN-mgw $BN-mgw $BN-mgw-st $BN-mgw-mt $BN-mgw-mt-s $BN-mgw-s ; do
|
||||
AC_CHECK_LIB($ax_lib, main, [BOOST_DATE_TIME_LIB="-l$ax_lib" AC_SUBST(BOOST_DATE_TIME_LIB) link_date_time="yes" break],
|
||||
[link_date_time="no"])
|
||||
done
|
||||
else
|
||||
for ax_lib in $ax_boost_user_date_time_lib $BN-$ax_boost_user_date_time_lib; do
|
||||
AC_CHECK_LIB($ax_lib, main,
|
||||
[BOOST_DATE_TIME_LIB="-l$ax_lib" AC_SUBST(BOOST_DATE_TIME_LIB) link_date_time="yes" break],
|
||||
[link_date_time="no"])
|
||||
done
|
||||
|
||||
fi
|
||||
if test "x$link_date_time" = "xno"; then
|
||||
AC_MSG_ERROR(Could not link against $ax_lib !)
|
||||
fi
|
||||
fi
|
||||
|
||||
CPPFLAGS="$CPPFLAGS_SAVED"
|
||||
LDFLAGS="$LDFLAGS_SAVED"
|
||||
fi
|
||||
])
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE audioPlayer [
|
||||
|
||||
<!ELEMENT audioPlayer (gstreamerPlayer) >
|
||||
|
||||
<!ELEMENT gstreamerPlayer EMPTY >
|
||||
<!ATTLIST gstreamerPlayer audioDevice CDATA #IMPLIED >
|
||||
]>
|
||||
<audioPlayer>
|
||||
<gstreamerPlayer audioDevice = "default" />
|
||||
</audioPlayer>
|
|
@ -1,133 +0,0 @@
|
|||
dnl-----------------------------------------------------------------------------
|
||||
dnl Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
dnl
|
||||
dnl This file is part of the Campcaster project.
|
||||
dnl http://campcaster.sourcefabric.org/
|
||||
dnl
|
||||
dnl Campcaster is free software; you can redistribute it and/or modify
|
||||
dnl it under the terms of the GNU General Public License as published by
|
||||
dnl the Free Software Foundation; either version 2 of the License, or
|
||||
dnl (at your option) any later version.
|
||||
dnl
|
||||
dnl Campcaster is distributed in the hope that it will be useful,
|
||||
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
dnl GNU General Public License for more details.
|
||||
dnl
|
||||
dnl You should have received a copy of the GNU General Public License
|
||||
dnl along with Campcaster; if not, write to the Free Software
|
||||
dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
dnl
|
||||
dnl-----------------------------------------------------------------------------
|
||||
|
||||
dnl-----------------------------------------------------------------------------
|
||||
dnl NOTE: Run all configure related scripts from the tmp directory of the
|
||||
dnl project.
|
||||
dnl This is due to the fact that configure spreads a lot of trash around,
|
||||
dnl like atom4te cache directories, config.* files, etc. into the directory
|
||||
dnl it is being run from. We clearly don't want these in our base directory.
|
||||
dnl-----------------------------------------------------------------------------
|
||||
AC_INIT(PlaylistExecutor, 0.0, bugs@campware.org)
|
||||
AC_PREREQ(2.59)
|
||||
AC_COPYRIGHT([Copyright (c) 2010 Sourcefabric O.P.S. under the GNU GPL])
|
||||
AC_REVISION($Revision$)
|
||||
|
||||
AC_CONFIG_SRCDIR(../src/AudioPlayerFactory.cxx)
|
||||
|
||||
AC_CONFIG_HEADERS(configure.h)
|
||||
AC_PROG_CXX()
|
||||
|
||||
AC_CHECK_HEADERS(getopt.h sys/time.h)
|
||||
|
||||
|
||||
dnl-----------------------------------------------------------------------------
|
||||
dnl specify whether debug info should be compiled into the executable
|
||||
dnl-----------------------------------------------------------------------------
|
||||
AC_SUBST(CXXFLAGS)
|
||||
|
||||
AC_ARG_ENABLE([debug],
|
||||
AC_HELP_STRING([--enable-debug], [compile with debug info (no)]),
|
||||
[],
|
||||
[enable_debug=no])
|
||||
|
||||
if test "x${enable_debug}" = "xyes"; then
|
||||
CXXFLAGS="-g -O0"
|
||||
AC_DEFINE( YDEBUG, 1, [Debug is on] )
|
||||
else
|
||||
CXXFLAGS="-O3"
|
||||
fi
|
||||
|
||||
AC_MSG_RESULT([using compiler options: ${CXXFLAGS}])
|
||||
|
||||
|
||||
dnl-----------------------------------------------------------------------------
|
||||
dnl specify the pkg-config path
|
||||
dnl-----------------------------------------------------------------------------
|
||||
AC_ARG_WITH([pkg-config-path],
|
||||
AC_HELP_STRING([--with-pkg-config-path],
|
||||
[use the pkg-config path (prefix/lib/pkgconfig)]),
|
||||
[PKG_CONFIG_PATH=${withval}],
|
||||
[PKG_CONFIG_PATH=${prefix}/lib/pkgconfig:$PKG_CONFIG_PATH])
|
||||
|
||||
AC_MSG_RESULT([using pkg-config path: ${PKG_CONFIG_PATH}])
|
||||
|
||||
export PKG_CONFIG_PATH
|
||||
|
||||
export PATH=${prefix}/bin:${PATH}
|
||||
|
||||
|
||||
AX_BOOST_BASE([1.33.1])
|
||||
if test "x${BOOST_CPPFLAGS}" != "x"; then
|
||||
AX_BOOST_DATE_TIME
|
||||
if test "x${BOOST_DATE_TIME_LIB}" = "x"; then
|
||||
AC_MSG_ERROR([Boost date-time library not found])
|
||||
fi
|
||||
else
|
||||
AC_MSG_ERROR([Boost library >= 1.33.1 not found])
|
||||
fi
|
||||
|
||||
PKG_CHECK_MODULES(LIBXMLPP,[libxml++-2.6 >= 2.8.1])
|
||||
AC_SUBST(LIBXMLPP_CFLAGS)
|
||||
AC_SUBST(LIBXMLPP_LIBS)
|
||||
|
||||
PKG_CHECK_MODULES(GSTREAMER,[gstreamer-0.10 >= 0.10])
|
||||
AC_SUBST(GSTREAMER_CFLAGS)
|
||||
AC_SUBST(GSTREAMER_LIBS)
|
||||
|
||||
PKG_CHECK_MODULES(GSTCONTROLLER,[gstreamer-controller-0.10 >= 0.10])
|
||||
AC_SUBST(GSTCONTROLLER_CFLAGS)
|
||||
AC_SUBST(GSTCONTROLLER_LIBS)
|
||||
|
||||
AC_CHECK_TAGLIB(1.3.1)
|
||||
AC_SUBST(TAGLIB_CFLAGS)
|
||||
AC_SUBST(TAGLIB_LIBS)
|
||||
|
||||
AC_CHECK_ICU(3.0)
|
||||
AC_SUBST(ICU_CFLAGS)
|
||||
AC_SUBST(ICU_CXXFLAGS)
|
||||
AC_SUBST(ICU_LIBS)
|
||||
|
||||
AC_PATH_PROG(GENRB, genrb)
|
||||
AC_SUBST(GENRB)
|
||||
|
||||
|
||||
dnl-----------------------------------------------------------------------------
|
||||
dnl enable compilaton for code coverage data
|
||||
dnl-----------------------------------------------------------------------------
|
||||
AC_SUBST(COVERAGE_CXXFLAGS)
|
||||
|
||||
AC_ARG_ENABLE( coverage,
|
||||
[ --enable-coverage enable code coverage data generaton (no) ],
|
||||
ENABLE_COVERAGE=${enableval}, ENABLE_COVERAGE="no" )
|
||||
|
||||
if test "x${ENABLE_COVERAGE}" == "xyes" ; then
|
||||
COVERAGE_CXXFLAGS="-fprofile-arcs -ftest-coverage"
|
||||
AC_MSG_RESULT([compiling in code coverage mode])
|
||||
else
|
||||
AC_MSG_RESULT([not compiling in code coverage mode])
|
||||
fi
|
||||
|
||||
|
||||
AC_CONFIG_FILES(../Makefile:../etc/Makefile.in)
|
||||
|
||||
AC_OUTPUT()
|
File diff suppressed because it is too large
Load Diff
|
@ -1,8 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE gstreamerPlayer [
|
||||
|
||||
<!ELEMENT gstreamerPlayer EMPTY >
|
||||
<!ATTLIST gstreamerPlayer audioDevice CDATA #IMPLIED >
|
||||
]>
|
||||
<gstreamerPlayer audioDevice = "default"
|
||||
/>
|
|
@ -1,58 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE playlist [
|
||||
|
||||
<!ELEMENT playlist (playlistElement*) >
|
||||
<!ATTLIST playlist id NMTOKEN #REQUIRED >
|
||||
<!ATTLIST playlist title CDATA "" >
|
||||
<!ATTLIST playlist playlength NMTOKEN #REQUIRED >
|
||||
|
||||
<!ELEMENT playlistElement ((audioClip|playlist), fadeInfo?) >
|
||||
<!ATTLIST playlistElement id NMTOKEN #REQUIRED >
|
||||
<!ATTLIST playlistElement relativeOffset NMTOKEN #REQUIRED >
|
||||
|
||||
<!ELEMENT audioClip EMPTY >
|
||||
<!ATTLIST audioClip id NMTOKEN #REQUIRED >
|
||||
<!ATTLIST audioClip playlength NMTOKEN #REQUIRED >
|
||||
<!ATTLIST audioClip title CDATA #REQUIRED >
|
||||
<!ATTLIST audioClip uri CDATA #IMPLIED >
|
||||
|
||||
<!ELEMENT fadeInfo EMPTY >
|
||||
<!ATTLIST fadeInfo id NMTOKEN #REQUIRED >
|
||||
<!ATTLIST fadeInfo fadeIn NMTOKEN #REQUIRED >
|
||||
<!ATTLIST fadeInfo fadeOut NMTOKEN #REQUIRED >
|
||||
]>
|
||||
|
||||
<playlist id="0000000000000001"
|
||||
title="My First Playlist"
|
||||
playlength="00:00:34.000" >
|
||||
<playlistElement id="0000000000000101"
|
||||
relativeOffset="0" >
|
||||
<audioClip id="0000000000010001"
|
||||
playlength="00:00:11"
|
||||
title = "one"
|
||||
uri="file:var/test10001.mp3" />
|
||||
<fadeInfo id="0000000000009901"
|
||||
fadeIn="0"
|
||||
fadeOut="00:00:05" />
|
||||
</playlistElement>
|
||||
<playlistElement id="0000000000000102"
|
||||
relativeOffset="00:00:06" >
|
||||
<audioClip id="0000000000010002"
|
||||
playlength="00:00:12.200000"
|
||||
title = "two"
|
||||
uri="file:var/test10002.mp3" />
|
||||
<fadeInfo id="0000000000009902"
|
||||
fadeIn="00:00:05"
|
||||
fadeOut="0" />
|
||||
</playlistElement>
|
||||
<playlistElement id="0000000000000103"
|
||||
relativeOffset="00:00:18.200000" >
|
||||
<audioClip id="0000000000010003"
|
||||
playlength="00:00:11.500000"
|
||||
title = "three"
|
||||
uri="file:var/test10003.mp3" />
|
||||
<fadeInfo id="0000000000009903"
|
||||
fadeIn="00:00:03"
|
||||
fadeOut="00:00:03" />
|
||||
</playlistElement>
|
||||
</playlist>
|
|
@ -1,63 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<xsl:stylesheet version="1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
||||
|
||||
<xsl:template match="/">
|
||||
<html>
|
||||
<head>
|
||||
<title>Campcaster unit test results</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Preface</h1>
|
||||
This document is part of the
|
||||
<a href="http://campcaster.sourcefabric.org/">Campcaster</a>
|
||||
project, Copyright © 2004 <a href="http://www.mdlf.org/">Media
|
||||
Development Loan Fund</a>, under the GNU
|
||||
<a href="http://www.gnu.org/licenses/gpl.html">GPL</a>.
|
||||
<br/>
|
||||
This is an automatically generated document.
|
||||
<h1>Scope</h1>
|
||||
This document contains the generated unit test results for the
|
||||
<a href="http://campcaster.sourcefabric.org/">Campcaster</a> project.
|
||||
<h1>Summary</h1>
|
||||
<xsl:for-each select="//Statistics">
|
||||
<table>
|
||||
<tr>
|
||||
<td><b>Total number of tests:</b></td>
|
||||
<td><xsl:value-of select="Tests"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>Tests passed:</b></td>
|
||||
<td><xsl:value-of select="count(/*/SuccessfulTests/Test)"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>Tests failed:</b></td>
|
||||
<td><xsl:value-of select="Failures"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>Test errors:</b></td>
|
||||
<td><xsl:value-of select="Errors"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
</xsl:for-each>
|
||||
<h1>Tests</h1>
|
||||
<table>
|
||||
<tr>
|
||||
<th>test name</th>
|
||||
<th>test status</th>
|
||||
</tr>
|
||||
<xsl:for-each select="//Test | //FailedTest">
|
||||
<xsl:sort select="Name"/>
|
||||
<tr>
|
||||
<td><xsl:value-of select="Name"/></td>
|
||||
<xsl:if test="ancestor::FailedTests"><td bgcolor="red">failed</td></xsl:if>
|
||||
<xsl:if test="ancestor::SuccessfulTests"><td bgcolor="lightblue">passed</td></xsl:if>
|
||||
</tr>
|
||||
</xsl:for-each>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE twoGstreamerPlayers [
|
||||
|
||||
<!ELEMENT twoGstreamerPlayers (gstreamerPlayer,gstreamerPlayer) >
|
||||
|
||||
<!ELEMENT gstreamerPlayer EMPTY >
|
||||
<!ATTLIST gstreamerPlayer audioDevice CDATA #IMPLIED >
|
||||
]>
|
||||
<twoGstreamerPlayers>
|
||||
<gstreamerPlayer audioDevice = "plughw:0,0" />
|
||||
<gstreamerPlayer audioDevice = "plughw:1,0" />
|
||||
</twoGstreamerPlayers>
|
|
@ -1,110 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
|
||||
This file is part of the Campcaster project.
|
||||
http://campcaster.sourcefabric.org/
|
||||
|
||||
Campcaster is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Campcaster is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Campcaster; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef LiveSupport_PlaylistExecutor_AudioPlayerEventListener_h
|
||||
#define LiveSupport_PlaylistExecutor_AudioPlayerEventListener_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
#endif
|
||||
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <exception>
|
||||
#include <stdexcept>
|
||||
#include <glibmm/ustring.h>
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace PlaylistExecutor {
|
||||
|
||||
using namespace boost;
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
||||
/* =================================================================== macros */
|
||||
|
||||
|
||||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* An event listener interface, for catching events of an audio player.
|
||||
*
|
||||
* @see AudioPlayerInterface
|
||||
*/
|
||||
class AudioPlayerEventListener
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* A virtual destructor, as this class has virtual functions.
|
||||
*/
|
||||
virtual
|
||||
~AudioPlayerEventListener(void) throw ()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Catch the event when playing has stopped.
|
||||
* This will happen probably due to the fact that the
|
||||
* audio clip has been played to its end.
|
||||
*
|
||||
* @param errorMessage is a 0 pointer if the player stopped normally
|
||||
*/
|
||||
virtual void
|
||||
onStop(Ptr<const Glib::ustring>::Ref errorMessage)
|
||||
throw () = 0;
|
||||
|
||||
/**
|
||||
* Catch the event when playback started.
|
||||
* Every time player plays a new file, it sends this event at the beginning.
|
||||
* App should use this to synchronize playback
|
||||
*
|
||||
* @param id represents the file that just started
|
||||
*/
|
||||
virtual void
|
||||
onStart(gint64 id)
|
||||
throw () = 0;
|
||||
};
|
||||
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
||||
|
||||
/* ====================================================== function prototypes */
|
||||
|
||||
|
||||
} // namespace PlaylistExecutor
|
||||
} // namespace LiveSupport
|
||||
|
||||
|
||||
#endif // LiveSupport_PlaylistExecutor_AudioPlayerEventListener_h
|
||||
|
|
@ -1,180 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
|
||||
This file is part of the Campcaster project.
|
||||
http://campcaster.sourcefabric.org/
|
||||
|
||||
Campcaster is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Campcaster is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Campcaster; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef LiveSupport_PlaylistExecutor_AudioPlayerFactory_h
|
||||
#define LiveSupport_PlaylistExecutor_AudioPlayerFactory_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
#endif
|
||||
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
#include "LiveSupport/Core/Configurable.h"
|
||||
#include "LiveSupport/PlaylistExecutor/AudioPlayerInterface.h"
|
||||
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace PlaylistExecutor {
|
||||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
||||
/* =================================================================== macros */
|
||||
|
||||
|
||||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* The factory to create appropriate AudioPlayer objects.
|
||||
* This singleton class has to be configured with an XML element,
|
||||
* describing the AudioPlayerInterface that it should build
|
||||
* and maintain. This is done by including the configuration element
|
||||
* for the desired type of connection manager inside the configuration
|
||||
* element for the factory.
|
||||
*
|
||||
* Currently only the GstreamerAudioPlayer is supported, thus a
|
||||
* configuration file may look like this:
|
||||
*
|
||||
* <pre><code>
|
||||
* <audioPlayer>
|
||||
<gstreamerPlayer audioDevice = "default" />
|
||||
* </audioPlayer>
|
||||
* </code></pre>
|
||||
*
|
||||
* The DTD for the above XML structure is:
|
||||
*
|
||||
* <pre><code>
|
||||
* <!ELEMENT audioPlayer (gstreamerPlayer) >
|
||||
* </code></pre>
|
||||
*
|
||||
* For the DTD and details of the gstreamerPlayer configuration
|
||||
* element, see the GstreamerPlayer documentation.
|
||||
*
|
||||
* @see GstreamerPlayer
|
||||
*/
|
||||
class AudioPlayerFactory :
|
||||
virtual public Configurable
|
||||
{
|
||||
private:
|
||||
/**
|
||||
* The name of the configuration XML elmenent used by this object.
|
||||
*/
|
||||
static const std::string configElementNameStr;
|
||||
|
||||
/**
|
||||
* The singleton instance of this object.
|
||||
*/
|
||||
static Ptr<AudioPlayerFactory>::Ref singleton;
|
||||
|
||||
/**
|
||||
* The audio player created by this factory.
|
||||
*/
|
||||
Ptr<AudioPlayerInterface>::Ref audioPlayer;
|
||||
|
||||
/**
|
||||
* The default constructor.
|
||||
*/
|
||||
AudioPlayerFactory(void) throw ()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
/**
|
||||
* A virtual destructor, as this class has virtual functions.
|
||||
*/
|
||||
virtual
|
||||
~AudioPlayerFactory(void) throw ()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name of the XML element this object expects
|
||||
* to be sent to a call to configure().
|
||||
*
|
||||
* @return the name of the expected XML configuration element.
|
||||
*/
|
||||
static const std::string
|
||||
getConfigElementName(void) throw ()
|
||||
{
|
||||
return configElementNameStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the singleton instance of this object.
|
||||
*
|
||||
* @return the singleton instance of this object.
|
||||
*/
|
||||
static Ptr<AudioPlayerFactory>::Ref
|
||||
getInstance() throw ();
|
||||
|
||||
/**
|
||||
* Configure the object based on the XML element supplied.
|
||||
*
|
||||
* @param element the XML element to configure the object from.
|
||||
* @exception std::invalid_argument if the supplied XML element
|
||||
* contains bad configuraiton information
|
||||
* @exception std::logic_error if the object has already
|
||||
* been configured, and can not be reconfigured.
|
||||
*/
|
||||
virtual void
|
||||
configure(const xmlpp::Element & element)
|
||||
throw (std::invalid_argument,
|
||||
std::logic_error);
|
||||
|
||||
/**
|
||||
* Return an audio player.
|
||||
* The returned player will already have been initialized.
|
||||
*
|
||||
* @return the appropriate audio player, according to the
|
||||
* configuration of this factory.
|
||||
*/
|
||||
Ptr<AudioPlayerInterface>::Ref
|
||||
getAudioPlayer(void) throw ()
|
||||
{
|
||||
return audioPlayer;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
||||
|
||||
/* ====================================================== function prototypes */
|
||||
|
||||
|
||||
} // namespace PlaylistExecutor
|
||||
} // namespace LiveSupport
|
||||
|
||||
#endif // LiveSupport_PlaylistExecutor_AudioPlayerFactory_h
|
||||
|
|
@ -1,258 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
|
||||
This file is part of the Campcaster project.
|
||||
http://campcaster.sourcefabric.org/
|
||||
|
||||
Campcaster is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Campcaster is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Campcaster; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef LiveSupport_PlaylistExecutor_AudioPlayerInterface_h
|
||||
#define LiveSupport_PlaylistExecutor_AudioPlayerInterface_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
#endif
|
||||
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <exception>
|
||||
#include <stdexcept>
|
||||
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
#include "LiveSupport/Core/Playlist.h"
|
||||
|
||||
#include "LiveSupport/PlaylistExecutor/AudioPlayerEventListener.h"
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace PlaylistExecutor {
|
||||
|
||||
using namespace boost;
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
||||
/* =================================================================== macros */
|
||||
|
||||
|
||||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* A generic interface for playing audio files.
|
||||
*/
|
||||
class AudioPlayerInterface
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* A virtual destructor, as this class has virtual functions.
|
||||
*/
|
||||
virtual
|
||||
~AudioPlayerInterface(void) throw ()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the Player object, so that it is ready to
|
||||
* play audio files.
|
||||
*
|
||||
* @exception std::exception on initialization problems.
|
||||
*/
|
||||
virtual void
|
||||
initialize(void) throw (std::exception) = 0;
|
||||
|
||||
/**
|
||||
* De-initialize the Player object.
|
||||
*/
|
||||
virtual void
|
||||
deInitialize(void) throw () = 0;
|
||||
|
||||
/**
|
||||
* Attach an event listener for this audio player.
|
||||
* After this call, the supplied event listener object will recieve
|
||||
* all events related to this audio player.
|
||||
*
|
||||
* Currently, there is only one event emitted by the audio player:
|
||||
* if the audio clip or playlist has finished playing naturally,
|
||||
* the onStop() method of the listener is called.
|
||||
* Note that this event is not emitted if playing was stopped by
|
||||
* a call to stop() or pause();
|
||||
* and also that for a playlist, the event is only fired once,
|
||||
* at the end, and not for each item inside the playlist.
|
||||
*
|
||||
* @param eventListener the event listener to register.
|
||||
* @see #detachListener
|
||||
*/
|
||||
virtual void
|
||||
attachListener(AudioPlayerEventListener* eventListener)
|
||||
throw () = 0;
|
||||
|
||||
/**
|
||||
* Detach an event listener for this audio player.
|
||||
* It is not necessary to call detach if the player is destroyed.
|
||||
* In that case, the listeners are detached automatically.
|
||||
*
|
||||
* @param eventListener the event listener to unregister.
|
||||
* @exception std::invalid_argument if the supplied event listener
|
||||
* has not been previously registered.
|
||||
* @see #attachListener
|
||||
*/
|
||||
virtual void
|
||||
detachListener(AudioPlayerEventListener* eventListener)
|
||||
throw (std::invalid_argument) = 0;
|
||||
|
||||
virtual void
|
||||
preload(const std::string fileUrl) throw (std::invalid_argument,
|
||||
std::runtime_error)
|
||||
= 0;
|
||||
/**
|
||||
* Specify which audio resource to play.
|
||||
* The file may be a playlist, referencing other files, which
|
||||
* will be accessed automatically.
|
||||
* Note: this call will <b>not</b> start playing! You will
|
||||
* have to call the start() function to begin playing.
|
||||
* Always close any opened resources with a call to close().
|
||||
*
|
||||
* @param fileUrl a URL to a file
|
||||
* @exception std::invalid_argument if the supplied fileUrl
|
||||
* seems to be invalid.
|
||||
* @exception std::runtime_error if the file could not be openned,
|
||||
* for example because the audio device of the player
|
||||
* is being exclusively used by an other process.
|
||||
* @see #close
|
||||
* @see #start
|
||||
*/
|
||||
virtual bool
|
||||
open(const std::string fileUrl, gint64 id, gint64 offset)
|
||||
throw (std::invalid_argument, std::runtime_error) = 0;
|
||||
|
||||
/**
|
||||
* Tell if the audio player has been openned.
|
||||
*
|
||||
* @return true if the audio player is openned, false otherwise.
|
||||
* @see #open
|
||||
*/
|
||||
virtual bool
|
||||
isOpen(void) throw () = 0;
|
||||
|
||||
/**
|
||||
* Close an audio source that was opened.
|
||||
*
|
||||
* @see #open
|
||||
*/
|
||||
virtual void
|
||||
close(void) throw (std::logic_error) = 0;
|
||||
|
||||
/**
|
||||
* Get the length of the currently opened audio clip.
|
||||
* This function waits as long as necessary to get the length.
|
||||
*
|
||||
* @return the length of the currently playing audio clip
|
||||
* @exception std::logic_error if there is no audio file open.
|
||||
*/
|
||||
virtual Ptr<posix_time::time_duration>::Ref
|
||||
getPlaylength(void) throw (std::logic_error) = 0;
|
||||
|
||||
/**
|
||||
* Return the current time position in the audio file.
|
||||
*
|
||||
* @return the current time position in the currently open audio file.
|
||||
* @exception std::logic_error if there is no audio file open.
|
||||
*/
|
||||
virtual Ptr<posix_time::time_duration>::Ref
|
||||
getPosition(void) throw (std::logic_error) = 0;
|
||||
|
||||
/**
|
||||
* Start playing.
|
||||
* This call will start playing the active playlist, which was
|
||||
* set by a previous call to open().
|
||||
* Playing can be stopped by calling stop().
|
||||
*
|
||||
* @exception std::logic_error if there was no previous call to
|
||||
* playThis().
|
||||
* @see #open
|
||||
* @see #stop
|
||||
*/
|
||||
virtual void
|
||||
start() throw (std::logic_error)
|
||||
= 0;
|
||||
|
||||
/**
|
||||
* Pause the player. Playing can be resumed by calling start().
|
||||
*
|
||||
* This will not trigger a call to onStop() of the attached listeners.
|
||||
*
|
||||
* @exception std::logic_error if there was no previous call to
|
||||
* open().
|
||||
* @see #open
|
||||
* @see #start
|
||||
*/
|
||||
virtual void
|
||||
pause(void) throw (std::logic_error)
|
||||
= 0;
|
||||
|
||||
/**
|
||||
* Tell if we're currently playing.
|
||||
*
|
||||
* @return true of the player is currently playing, false
|
||||
* otherwise.
|
||||
*/
|
||||
virtual bool
|
||||
isPlaying(void) throw () = 0;
|
||||
|
||||
/**
|
||||
* Stop playing.
|
||||
* This will not trigger a call to onStop() of the attached listeners.
|
||||
*
|
||||
* @exception std::logic_error if there was no previous call to
|
||||
* start()
|
||||
*/
|
||||
virtual void
|
||||
stop(void) throw (std::logic_error)
|
||||
= 0;
|
||||
|
||||
/**
|
||||
* Set the audio device used for playback.
|
||||
*
|
||||
* @param deviceName the new device name, e.g., /dev/dsp
|
||||
* @return true if successful, false if not
|
||||
*/
|
||||
virtual bool
|
||||
setAudioDevice(const std::string &deviceName)
|
||||
throw () = 0;
|
||||
};
|
||||
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
||||
|
||||
/* ====================================================== function prototypes */
|
||||
|
||||
|
||||
} // namespace PlaylistExecutor
|
||||
} // namespace LiveSupport
|
||||
|
||||
|
||||
#endif // LiveSupport_PlaylistExecutor_AudioPlayerInterface_h
|
||||
|
|
@ -1 +0,0 @@
|
|||
keep me
|
|
@ -1,106 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
|
||||
This file is part of the Campcaster project.
|
||||
http://campcaster.sourcefabric.org/
|
||||
|
||||
Campcaster is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Campcaster is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Campcaster; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include "LiveSupport/PlaylistExecutor/AudioPlayerFactory.h"
|
||||
#include "GstreamerPlayer.h"
|
||||
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::PlaylistExecutor;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the config element for this class
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string AudioPlayerFactory::configElementNameStr =
|
||||
"audioPlayer";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The singleton instance of AudioPlayerFactory
|
||||
*----------------------------------------------------------------------------*/
|
||||
Ptr<AudioPlayerFactory>::Ref AudioPlayerFactory::singleton;
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Return the singleton instance to AudioPlayerFactory
|
||||
*----------------------------------------------------------------------------*/
|
||||
Ptr<AudioPlayerFactory>::Ref
|
||||
AudioPlayerFactory :: getInstance(void) throw ()
|
||||
{
|
||||
if (!singleton.get()) {
|
||||
singleton.reset(new AudioPlayerFactory());
|
||||
}
|
||||
|
||||
return singleton;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Configure the connection manager factory.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
AudioPlayerFactory :: configure(const xmlpp::Element & element)
|
||||
throw (std::invalid_argument,
|
||||
std::logic_error)
|
||||
{
|
||||
if (element.get_name() != configElementNameStr) {
|
||||
std::string eMsg = "Bad configuration element ";
|
||||
eMsg += element.get_name();
|
||||
throw std::invalid_argument(eMsg);
|
||||
}
|
||||
|
||||
audioPlayer.reset();
|
||||
|
||||
xmlpp::Node::NodeList nodes;
|
||||
|
||||
// try to look for a GstreamerPlayer configuration element
|
||||
nodes = element.get_children(GstreamerPlayer::getConfigElementName());
|
||||
if (nodes.size() >= 1) {
|
||||
const xmlpp::Element * configElement =
|
||||
dynamic_cast<const xmlpp::Element*> (*(nodes.begin()));
|
||||
Ptr<GstreamerPlayer>::Ref gp(new GstreamerPlayer());
|
||||
gp->configure(*configElement);
|
||||
audioPlayer = gp;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
throw std::invalid_argument("no audio player factories to configure");
|
||||
}
|
||||
|
||||
|
|
@ -1,196 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
|
||||
This file is part of the Campcaster project.
|
||||
http://campcaster.sourcefabric.org/
|
||||
|
||||
Campcaster is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Campcaster is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Campcaster; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#else
|
||||
#error "Need unistd.h"
|
||||
#endif
|
||||
|
||||
#include <glib.h>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
#include "LiveSupport/Core/TimeConversion.h"
|
||||
|
||||
#include "AudioPlayerFactoryGstreamerTest.h"
|
||||
|
||||
|
||||
using namespace LiveSupport::PlaylistExecutor;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(AudioPlayerFactoryGstreamerTest);
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the audio player.
|
||||
*/
|
||||
static const std::string configFileName = "etc/audioPlayerGstreamer.xml";
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Set up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
AudioPlayerFactoryGstreamerTest :: setUp(void) throw ()
|
||||
{
|
||||
try {
|
||||
Ptr<xmlpp::DomParser>::Ref parser(
|
||||
new xmlpp::DomParser(configFileName, true));
|
||||
const xmlpp::Document * document = parser->get_document();
|
||||
const xmlpp::Element * root = document->get_root_node();
|
||||
|
||||
Ptr<AudioPlayerFactory>::Ref audioPlayerFactory;
|
||||
|
||||
audioPlayerFactory = AudioPlayerFactory::getInstance();
|
||||
audioPlayerFactory->configure(*root);
|
||||
|
||||
// initialize the audio player configured by the factory
|
||||
Ptr<AudioPlayerInterface>::Ref audioPlayer;
|
||||
audioPlayer = audioPlayerFactory->getAudioPlayer();
|
||||
audioPlayer->initialize();
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << "semantic error in configuration file" << std::endl;
|
||||
} catch (xmlpp::exception &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Clean up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
AudioPlayerFactoryGstreamerTest :: tearDown(void) throw ()
|
||||
{
|
||||
try {
|
||||
Ptr<AudioPlayerFactory>::Ref audioPlayerFactory;
|
||||
audioPlayerFactory = AudioPlayerFactory::getInstance();
|
||||
|
||||
// de-initialize the audio player configured by the factory
|
||||
Ptr<AudioPlayerInterface>::Ref audioPlayer;
|
||||
audioPlayer = audioPlayerFactory->getAudioPlayer();
|
||||
audioPlayer->deInitialize();
|
||||
} catch (xmlpp::exception &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Test to see if the audio player engine can be started and stopped
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
AudioPlayerFactoryGstreamerTest :: firstTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
Ptr<AudioPlayerFactory>::Ref audioPlayerFactory;
|
||||
|
||||
audioPlayerFactory = AudioPlayerFactory::getInstance();
|
||||
CPPUNIT_ASSERT(audioPlayerFactory.get());
|
||||
|
||||
Ptr<AudioPlayerInterface>::Ref audioPlayer;
|
||||
|
||||
audioPlayer = audioPlayerFactory->getAudioPlayer();
|
||||
CPPUNIT_ASSERT(audioPlayer.get());
|
||||
CPPUNIT_ASSERT(!audioPlayer->isPlaying());
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Play something simple
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
AudioPlayerFactoryGstreamerTest :: simplePlayTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
Ptr<AudioPlayerFactory>::Ref audioPlayerFactory;
|
||||
Ptr<AudioPlayerInterface>::Ref audioPlayer;
|
||||
Ptr<time_duration>::Ref sleepT;
|
||||
|
||||
|
||||
GMainLoop *loop=g_main_loop_new(NULL, FALSE);
|
||||
|
||||
audioPlayerFactory = AudioPlayerFactory::getInstance();
|
||||
audioPlayer = audioPlayerFactory->getAudioPlayer();
|
||||
|
||||
// CPPUNIT_ASSERT_NO_THROW(
|
||||
audioPlayer->open("file:///tmp/campcaster/simple.smil", 0L, 0L);
|
||||
// );
|
||||
// CPPUNIT_ASSERT(!audioPlayer->isPlaying());
|
||||
// CPPUNIT_ASSERT_NO_THROW(
|
||||
audioPlayer->start();
|
||||
|
||||
|
||||
g_main_loop_run(loop);
|
||||
|
||||
|
||||
// );
|
||||
// CPPUNIT_ASSERT(
|
||||
audioPlayer->isPlaying();
|
||||
// );
|
||||
/*
|
||||
sleepT.reset(new time_duration(seconds(5)));
|
||||
TimeConversion::sleep(sleepT);
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
audioPlayer->pause();
|
||||
);
|
||||
sleepT.reset(new time_duration(seconds(1)));
|
||||
TimeConversion::sleep(sleepT);
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
audioPlayer->start();
|
||||
);
|
||||
sleepT.reset(new time_duration(seconds(2)));
|
||||
TimeConversion::sleep(sleepT);
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
audioPlayer->pause();
|
||||
);
|
||||
sleepT.reset(new time_duration(seconds(1)));
|
||||
TimeConversion::sleep(sleepT);
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
audioPlayer->start();
|
||||
);
|
||||
|
||||
sleepT.reset(new time_duration(microseconds(10)));
|
||||
while (audioPlayer->isPlaying()) {
|
||||
TimeConversion::sleep(sleepT);
|
||||
}
|
||||
CPPUNIT_ASSERT(!audioPlayer->isPlaying());
|
||||
*/ audioPlayer->close();
|
||||
}
|
||||
|
|
@ -1,108 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
|
||||
This file is part of the Campcaster project.
|
||||
http://campcaster.sourcefabric.org/
|
||||
|
||||
Campcaster is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Campcaster is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Campcaster; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
#ifndef AudioPlayerFactoryGstreamerTest_h
|
||||
#define AudioPlayerFactoryGstreamerTest_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
#endif
|
||||
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include "LiveSupport/PlaylistExecutor/AudioPlayerFactory.h"
|
||||
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace PlaylistExecutor {
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
||||
/* =================================================================== macros */
|
||||
|
||||
|
||||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* Unit test for the AudioPlayerFactory class.
|
||||
*
|
||||
* @see AudioPlayerFactory
|
||||
*/
|
||||
class AudioPlayerFactoryGstreamerTest : public CPPUNIT_NS::TestFixture
|
||||
{
|
||||
CPPUNIT_TEST_SUITE(AudioPlayerFactoryGstreamerTest);
|
||||
// CPPUNIT_TEST(firstTest);
|
||||
CPPUNIT_TEST(simplePlayTest);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* A simple test.
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
firstTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
/**
|
||||
* Play something simple.
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
simplePlayTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Set up the environment for the test case.
|
||||
*/
|
||||
void
|
||||
setUp(void) throw ();
|
||||
|
||||
/**
|
||||
* Clean up the environment after the test case.
|
||||
*/
|
||||
void
|
||||
tearDown(void) throw ();
|
||||
};
|
||||
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
||||
|
||||
/* ====================================================== function prototypes */
|
||||
|
||||
|
||||
} // namespace PlaylistExecutor
|
||||
} // namespace LiveSupport
|
||||
|
||||
#endif // AudioPlayerFactoryGstreamerTest_h
|
||||
|
|
@ -1,428 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
|
||||
This file is part of the Campcaster project.
|
||||
http://campcaster.sourcefabric.org/
|
||||
|
||||
Campcaster is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Campcaster is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Campcaster; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef GstreamerPlayContext_h
|
||||
#define GstreamerPlayContext_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
#endif
|
||||
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include <gst/controller/gstcontroller.h>
|
||||
#include <gst/controller/gstinterpolationcontrolsource.h>
|
||||
|
||||
#include "SmilHandler.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* User of this class must implement my_bus_callback function to receive bus callbacks.
|
||||
*----------------------------------------------------------------------------*/
|
||||
static gboolean
|
||||
my_bus_callback (GstBus *bus,
|
||||
GstMessage *message,
|
||||
gpointer data);
|
||||
|
||||
/**
|
||||
* A class to play audio files using Gstreamer library.
|
||||
*
|
||||
* Usage sequence:
|
||||
*
|
||||
* create an instance of GstreamerPlayContext object
|
||||
* call setParentData to provide data to be returned by my_bus_callback
|
||||
* call setAudioDevice on it
|
||||
* call openSource on it
|
||||
* call playContext on it
|
||||
*
|
||||
* when done, call closeContext on it
|
||||
* destroy instance
|
||||
*
|
||||
*/
|
||||
class GstreamerPlayContext
|
||||
{
|
||||
GstElement *m_pipeline;
|
||||
GstElement *m_source;
|
||||
GstElement *m_decoder;
|
||||
GstElement *m_sink;
|
||||
GstController *m_ctrl;
|
||||
GstElement *m_volume;
|
||||
GstInterpolationControlSource *m_ics;
|
||||
gpointer m_data;
|
||||
AudioDescription *m_audioDescription;
|
||||
std::string m_audioDevice;
|
||||
gint64 m_clipOffset;
|
||||
|
||||
public:
|
||||
|
||||
GstreamerPlayContext(){
|
||||
m_pipeline = NULL;
|
||||
m_source = NULL;
|
||||
m_decoder = NULL;
|
||||
m_sink = NULL;
|
||||
m_ctrl = NULL;
|
||||
m_volume = NULL;
|
||||
m_ics = NULL;
|
||||
m_data = NULL;
|
||||
m_audioDescription = NULL;
|
||||
m_audioDevice = "default";
|
||||
m_clipOffset = 0;
|
||||
}
|
||||
|
||||
~GstreamerPlayContext(){
|
||||
}
|
||||
|
||||
void closeContext(){
|
||||
stopContext();
|
||||
if(m_ctrl != NULL){
|
||||
g_object_unref(G_OBJECT(m_ctrl));
|
||||
m_ctrl = NULL;
|
||||
}
|
||||
if(m_ics != NULL){
|
||||
g_object_unref(G_OBJECT(m_ics));
|
||||
m_ics = NULL;
|
||||
}
|
||||
if(m_pipeline != NULL){
|
||||
gst_element_set_state (m_pipeline, GST_STATE_NULL);
|
||||
gst_bin_remove (GST_BIN (m_pipeline), m_sink);
|
||||
m_sink=NULL;
|
||||
gst_object_unref(GST_OBJECT(m_pipeline));
|
||||
m_source = NULL;
|
||||
m_decoder = NULL;
|
||||
m_volume = NULL;
|
||||
m_pipeline = NULL;
|
||||
}
|
||||
if(m_sink != NULL){
|
||||
gst_object_unref(GST_OBJECT(m_sink));
|
||||
m_sink=NULL;
|
||||
}
|
||||
if(m_audioDescription != NULL){
|
||||
m_audioDescription->release();
|
||||
delete m_audioDescription;
|
||||
m_audioDescription = NULL;
|
||||
}
|
||||
m_clipOffset = 0;
|
||||
}
|
||||
|
||||
void playContext(){
|
||||
GstStateChangeReturn st = gst_element_set_state (m_pipeline, GST_STATE_PLAYING);
|
||||
if(NULL != m_audioDescription)
|
||||
{
|
||||
//enforce PLAYING state in case this was an asynch state change
|
||||
//this is essential for seek to succeed
|
||||
if(GST_STATE_CHANGE_ASYNC == st)
|
||||
{
|
||||
GstState state, pending;
|
||||
gst_element_get_state (m_pipeline, &state, &pending, 2000000000);//just in case, do not wait for more than 2 sec
|
||||
}
|
||||
gst_element_seek(m_pipeline, 1.0, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH, GST_SEEK_TYPE_SET,
|
||||
std::max(m_clipOffset, m_audioDescription->m_clipBegin)*GST_NSECOND, GST_SEEK_TYPE_SET, m_audioDescription->m_clipEnd*GST_NSECOND);
|
||||
m_clipOffset = 0;//reset clipOffset after it's been used
|
||||
}
|
||||
g_object_set(G_OBJECT(m_volume), "volume", 1.0, NULL);
|
||||
}
|
||||
|
||||
void pauseContext(){
|
||||
g_object_set(G_OBJECT(m_volume), "volume", 0.0, NULL);
|
||||
gst_element_set_state (m_pipeline, GST_STATE_PAUSED);
|
||||
}
|
||||
|
||||
void stopContext(){
|
||||
if(GST_IS_ELEMENT(m_volume)) g_object_set(G_OBJECT(m_volume), "volume", 0.0, NULL);
|
||||
if(GST_IS_ELEMENT(m_volume)) gst_element_set_state (m_pipeline, GST_STATE_READY);
|
||||
}
|
||||
|
||||
void setParentData(gpointer data){
|
||||
m_data = data;
|
||||
}
|
||||
|
||||
void forceEOS(){
|
||||
GstBus *bus = gst_pipeline_get_bus (GST_PIPELINE (m_pipeline));
|
||||
gst_bus_post (bus, gst_message_new_eos(GST_OBJECT(m_sink)));
|
||||
gst_object_unref (bus);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Set the audio device.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void setAudioDevice(const std::string &deviceName) {
|
||||
m_audioDevice = deviceName;
|
||||
}
|
||||
/*------------------------------------------------------------------------------
|
||||
* Set the audio device.
|
||||
*----------------------------------------------------------------------------*/
|
||||
GstElement* getAudioBin() {
|
||||
return m_sink;
|
||||
}
|
||||
/*------------------------------------------------------------------------------
|
||||
* Opens source element for the file name given.
|
||||
*----------------------------------------------------------------------------*/
|
||||
bool openSource(const gchar *fileUri) throw() {
|
||||
m_source = gst_element_make_from_uri (GST_URI_SRC, fileUri, NULL);
|
||||
if(m_source == NULL){
|
||||
return false;
|
||||
}
|
||||
|
||||
prepareAudioDevice();
|
||||
|
||||
if(m_sink==NULL){
|
||||
std::cerr << "openSource: Failed to create sink!" << std::endl;
|
||||
gst_object_unref (m_source);
|
||||
m_source = NULL;
|
||||
return false;
|
||||
}
|
||||
if(!prepareDecodebin()){
|
||||
std::cerr << "openSource: Failed to create decodebin!" << std::endl;
|
||||
if(m_sink){
|
||||
gst_object_unref (m_sink);
|
||||
m_sink = NULL;
|
||||
}
|
||||
gst_object_unref (m_source);
|
||||
m_source = NULL;
|
||||
return false;
|
||||
}
|
||||
if(!preparePipeline()){
|
||||
std::cerr << "openSource: Failed to create pipeline!" << std::endl;
|
||||
if(m_sink){
|
||||
gst_object_unref (m_sink);
|
||||
m_sink = NULL;
|
||||
}
|
||||
gst_object_unref (m_decoder);
|
||||
m_decoder = NULL;
|
||||
gst_object_unref (m_source);
|
||||
m_source = NULL;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/*------------------------------------------------------------------------------
|
||||
* Opens source element for the file name given.
|
||||
*----------------------------------------------------------------------------*/
|
||||
bool openSource(AudioDescription *audioDescription) throw() {
|
||||
if(audioDescription == NULL) return false;
|
||||
m_audioDescription = audioDescription;
|
||||
return openSource(m_audioDescription->m_src);
|
||||
}
|
||||
/*------------------------------------------------------------------------------
|
||||
* Returns current stream's duration.
|
||||
*----------------------------------------------------------------------------*/
|
||||
gint64 getPlayLength() throw() {
|
||||
gint64 ns = 0LL;
|
||||
if(m_pipeline!=NULL){
|
||||
GstFormat format = GST_FORMAT_TIME;
|
||||
gst_element_query_duration(m_pipeline, &format, &ns);
|
||||
if(format != GST_FORMAT_TIME){
|
||||
ns = 0LL;
|
||||
}
|
||||
}
|
||||
return ns;
|
||||
}
|
||||
/*------------------------------------------------------------------------------
|
||||
* Offsets playback within the clip
|
||||
*---------------------------------------------------------------------------*/
|
||||
void setClipOffset(gint64 startTime){
|
||||
m_clipOffset = startTime;
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Returns current stream's position.
|
||||
*----------------------------------------------------------------------------*/
|
||||
gint64 getPosition() throw() {
|
||||
gint64 ns = 0LL;
|
||||
if(m_pipeline!=NULL){
|
||||
GstFormat format = GST_FORMAT_TIME;
|
||||
gst_element_query_position(m_pipeline, &format, &ns);
|
||||
if(format != GST_FORMAT_TIME){
|
||||
ns = 0LL;
|
||||
}
|
||||
}
|
||||
return ns;
|
||||
}
|
||||
/*------------------------------------------------------------------------------
|
||||
* Checks if the stream is currently playing.
|
||||
*----------------------------------------------------------------------------*/
|
||||
bool isPlaying() throw() {
|
||||
GstState state;
|
||||
GstState pending;
|
||||
gst_element_get_state(m_pipeline, &state, &pending, 50000000);
|
||||
return state == GST_STATE_PLAYING;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Prepare audio device from the name provided previously.
|
||||
*----------------------------------------------------------------------------*/
|
||||
bool prepareAudioDevice() throw() {
|
||||
if(m_sink != NULL){
|
||||
gst_object_unref(GST_OBJECT(m_sink));
|
||||
m_sink=NULL;
|
||||
}
|
||||
|
||||
GstPad *audiopad;
|
||||
|
||||
// this constant checks if the audio device configuration contains the string
|
||||
// "/dev", if so the below pipeline definition uses oss.
|
||||
// Perhaps the logic can go three ways and check if the device is labled jack.
|
||||
// Or keep the if-else logic and eliminate OSS as an option as it is obsolete anyway
|
||||
// and ALSA can emulate it.
|
||||
// const bool oss = m_audioDevice.find("/dev") == 0;
|
||||
const bool autosink = m_audioDevice.find("auto") == 0;
|
||||
|
||||
m_sink = gst_bin_new ("audiobin");
|
||||
if(m_sink == NULL){
|
||||
return false;
|
||||
}
|
||||
GstElement *conv = gst_element_factory_make ("audioconvert", "aconv");
|
||||
audiopad = gst_element_get_pad (conv, "sink");
|
||||
|
||||
// set the string to be sent to gstreamer. the option here is to set it to autoaudiosink.
|
||||
GstElement *sink = (autosink ? gst_element_factory_make("autoaudiosink", NULL) : gst_element_factory_make("alsasink", NULL));
|
||||
if(sink == NULL){
|
||||
return false;
|
||||
}
|
||||
g_object_set(G_OBJECT(sink), "device", m_audioDevice.c_str(), NULL);
|
||||
|
||||
m_volume = gst_element_factory_make("volume", NULL);
|
||||
g_object_set(G_OBJECT(m_volume), "volume", 0.0, NULL);
|
||||
|
||||
gst_bin_add_many (GST_BIN (m_sink), conv, m_volume, sink, NULL);
|
||||
gst_element_link (conv, m_volume);
|
||||
gst_element_link (m_volume, sink);
|
||||
gst_element_add_pad (m_sink, gst_ghost_pad_new ("sink", audiopad));
|
||||
gst_object_unref (audiopad);
|
||||
return true;
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Prepare empty pipeline.
|
||||
*----------------------------------------------------------------------------*/
|
||||
bool preparePipeline(){
|
||||
if(m_pipeline!=NULL){
|
||||
return false;//pipeline can only be created once per instance
|
||||
}
|
||||
m_pipeline = gst_pipeline_new ("pipeline");
|
||||
if(m_pipeline==NULL){
|
||||
return false;
|
||||
}
|
||||
|
||||
GstBus *bus = gst_pipeline_get_bus (GST_PIPELINE (m_pipeline));
|
||||
gst_bus_add_watch (bus, my_bus_callback, m_data);
|
||||
gst_object_unref (bus);
|
||||
|
||||
//link up all elements in the pipeline
|
||||
gst_bin_add_many (GST_BIN (m_pipeline), m_source, m_decoder, NULL);
|
||||
gst_element_link (m_source, m_decoder);
|
||||
gst_bin_add (GST_BIN (m_pipeline), m_sink);
|
||||
//lastly prepare animations if desired
|
||||
prepareAnimations();
|
||||
return true;
|
||||
}
|
||||
/*------------------------------------------------------------------------------
|
||||
* Prepare decode bin.
|
||||
*----------------------------------------------------------------------------*/
|
||||
bool prepareDecodebin(){
|
||||
if(m_pipeline!=NULL){
|
||||
return false;//pipeline can only be created once per instance
|
||||
}
|
||||
m_decoder = gst_element_factory_make ("decodebin", NULL);
|
||||
g_signal_connect (m_decoder, "new-decoded-pad", G_CALLBACK (cb_newpad), this);
|
||||
return true;
|
||||
}
|
||||
/*------------------------------------------------------------------------------
|
||||
* Prepare animations bin.
|
||||
*----------------------------------------------------------------------------*/
|
||||
bool prepareAnimations(){
|
||||
if(m_audioDescription && m_audioDescription->m_animations.size() > 0){
|
||||
m_ctrl = gst_controller_new (G_OBJECT (m_volume), "volume", NULL);
|
||||
if (m_ctrl == NULL) {
|
||||
return false;
|
||||
}
|
||||
GValue vol = { 0, };
|
||||
m_ics = gst_interpolation_control_source_new ();
|
||||
gst_controller_set_control_source (m_ctrl, "volume", GST_CONTROL_SOURCE (m_ics));
|
||||
// Set interpolation mode
|
||||
gst_interpolation_control_source_set_interpolation_mode (m_ics, GST_INTERPOLATE_LINEAR);//GST_INTERPOLATE_CUBIC);
|
||||
// set control values, first fade in
|
||||
g_value_init (&vol, G_TYPE_DOUBLE);
|
||||
if(m_audioDescription->m_animations[0] != NULL){
|
||||
g_value_set_double (&vol, m_audioDescription->m_animations[0]->m_from);
|
||||
gst_interpolation_control_source_set (m_ics, m_audioDescription->m_animations[0]->m_begin, &vol);
|
||||
g_value_set_double (&vol, m_audioDescription->m_animations[0]->m_to);
|
||||
gst_interpolation_control_source_set (m_ics, m_audioDescription->m_animations[0]->m_end, &vol);
|
||||
g_print("prepareAnimations: animation set begin=%d, end=%d, from=%f, to=%f\n",
|
||||
m_audioDescription->m_animations[0]->m_begin,
|
||||
m_audioDescription->m_animations[0]->m_end,
|
||||
m_audioDescription->m_animations[0]->m_from,
|
||||
m_audioDescription->m_animations[0]->m_to);
|
||||
}
|
||||
if(m_audioDescription->m_animations.size() > 1){
|
||||
if(m_audioDescription->m_animations[1] != NULL){
|
||||
//set fade out, between fadein and fadeout we have a hold period
|
||||
g_value_set_double (&vol, m_audioDescription->m_animations[1]->m_from);
|
||||
gst_interpolation_control_source_set (m_ics, m_audioDescription->m_animations[1]->m_begin, &vol);
|
||||
g_value_set_double (&vol, m_audioDescription->m_animations[1]->m_to);
|
||||
gst_interpolation_control_source_set (m_ics, m_audioDescription->m_animations[1]->m_end, &vol);
|
||||
g_print("prepareAnimations: animation set begin=%d, end=%d, from=%f, to=%f\n",
|
||||
m_audioDescription->m_animations[1]->m_begin,
|
||||
m_audioDescription->m_animations[1]->m_end,
|
||||
m_audioDescription->m_animations[1]->m_from,
|
||||
m_audioDescription->m_animations[1]->m_to);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/*------------------------------------------------------------------------------
|
||||
* New pad signal callback.
|
||||
*----------------------------------------------------------------------------*/
|
||||
static void cb_newpad (GstElement *decodebin, GstPad *pad, gboolean last, gpointer data)
|
||||
{
|
||||
GstCaps *caps;
|
||||
GstStructure *str;
|
||||
GstPad *audiopad;
|
||||
audiopad = gst_element_get_pad (((GstreamerPlayContext*)data)->getAudioBin(), "sink");
|
||||
if (GST_PAD_IS_LINKED (audiopad)) {
|
||||
g_object_unref (audiopad);
|
||||
return;
|
||||
}
|
||||
caps = gst_pad_get_caps (pad);
|
||||
str = gst_caps_get_structure (caps, 0);
|
||||
if (!g_strrstr (gst_structure_get_name (str), "audio")) {
|
||||
gst_caps_unref (caps);
|
||||
gst_object_unref (audiopad);
|
||||
return;
|
||||
}
|
||||
gst_caps_unref (caps);
|
||||
gst_pad_link (pad, audiopad);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // GstreamerPlayContext_h
|
||||
|
|
@ -1,503 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
|
||||
This file is part of the Campcaster project.
|
||||
http://campcaster.sourcefabric.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
Campcaster is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Campcaster is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Campcaster; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: Kapil Agrawal$
|
||||
Version : $Revision$
|
||||
Location : $URL$
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#define DEBUG_PREFIX "GstreamerPlayer"
|
||||
#include "LiveSupport/Core/Debug.h"
|
||||
|
||||
#include "LiveSupport/Core/TimeConversion.h"
|
||||
|
||||
#include "GstreamerPlayer.h"
|
||||
|
||||
|
||||
using namespace boost::posix_time;
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::PlaylistExecutor;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
/**
|
||||
* The name of the config element for this class
|
||||
*/
|
||||
const std::string GstreamerPlayer::configElementNameStr = "gstreamerPlayer";
|
||||
|
||||
/**
|
||||
* The name of the audio device attribute.
|
||||
*/
|
||||
static const std::string audioDeviceName = "audioDevice";
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
static gboolean my_bus_callback (GstBus *bus, GstMessage *message, gpointer data)
|
||||
{
|
||||
|
||||
GstreamerPlayer* const player = (GstreamerPlayer*) data;
|
||||
|
||||
switch (GST_MESSAGE_TYPE (message)) {
|
||||
//we shall handle errors as non critical events as we should not stop playback in any case
|
||||
case GST_MESSAGE_ERROR:
|
||||
case GST_MESSAGE_EOS:
|
||||
if(player->playNextSmil()){
|
||||
break;
|
||||
}
|
||||
player->close();
|
||||
// Important: We *must* use an idle function call here, so that the signal handler returns
|
||||
// before fireOnStopEvent() is executed.
|
||||
g_idle_add(GstreamerPlayer::fireOnStopEvent, data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Configure the Audio Player.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
GstreamerPlayer :: configure(const xmlpp::Element & element)
|
||||
throw (std::invalid_argument,
|
||||
std::logic_error)
|
||||
{
|
||||
DEBUG_FUNC_INFO
|
||||
|
||||
if (element.get_name() != configElementNameStr) {
|
||||
std::string eMsg = "Bad configuration element ";
|
||||
eMsg += element.get_name();
|
||||
throw std::invalid_argument(eMsg);
|
||||
}
|
||||
|
||||
const xmlpp::Attribute * attribute = 0;
|
||||
|
||||
if ((attribute = element.get_attribute(audioDeviceName))) {
|
||||
m_audioDevice = attribute->get_value();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Initialize the Audio Player
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
GstreamerPlayer :: initialize(void) throw (std::exception)
|
||||
{
|
||||
DEBUG_FUNC_INFO
|
||||
|
||||
if (m_initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
// initialize the gstreamer library
|
||||
if (!gst_init_check(0, 0, 0)) {
|
||||
throw std::runtime_error("couldn't initialize the gstreamer library");
|
||||
}
|
||||
|
||||
m_playContext = new GstreamerPlayContext();
|
||||
|
||||
m_playContext->setParentData(this);
|
||||
|
||||
// set up other variables
|
||||
m_initialized = true;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* De-initialize the Gstreamer Player
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
GstreamerPlayer :: deInitialize(void) throw ()
|
||||
{
|
||||
DEBUG_FUNC_INFO
|
||||
|
||||
if (m_initialized) {
|
||||
m_playContext->closeContext();
|
||||
delete m_playContext;
|
||||
m_playContext = NULL;
|
||||
m_initialized = false;
|
||||
}
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Attach an event listener.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
GstreamerPlayer :: attachListener(AudioPlayerEventListener* eventListener)
|
||||
throw ()
|
||||
{
|
||||
m_listeners.push_back(eventListener);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Detach an event listener.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
GstreamerPlayer :: detachListener(AudioPlayerEventListener* eventListener)
|
||||
throw (std::invalid_argument)
|
||||
{
|
||||
ListenerVector::iterator it = m_listeners.begin();
|
||||
ListenerVector::iterator end = m_listeners.end();
|
||||
|
||||
while (it != end) {
|
||||
if (*it == eventListener) {
|
||||
m_listeners.erase(it);
|
||||
return;
|
||||
}
|
||||
++it;
|
||||
}
|
||||
|
||||
throw std::invalid_argument("supplied event listener not found");
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Send the onStop event to all attached listeners.
|
||||
*----------------------------------------------------------------------------*/
|
||||
gboolean
|
||||
GstreamerPlayer :: fireOnStopEvent(gpointer self) throw ()
|
||||
{
|
||||
DEBUG_BLOCK
|
||||
|
||||
|
||||
GstreamerPlayer* const player = (GstreamerPlayer*) self;
|
||||
|
||||
ListenerVector::iterator it = player->m_listeners.begin();
|
||||
ListenerVector::iterator end = player->m_listeners.end();
|
||||
while (it != end) {
|
||||
(*it)->onStop(player->m_errorMessage);
|
||||
++it;
|
||||
}
|
||||
|
||||
player->m_errorMessage.reset();
|
||||
|
||||
// false == Don't call this idle function again
|
||||
return false;
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Send the onStart event to all attached listeners.
|
||||
*----------------------------------------------------------------------------*/
|
||||
gboolean
|
||||
GstreamerPlayer :: fireOnStartEvent(gpointer self) throw ()
|
||||
{
|
||||
DEBUG_BLOCK
|
||||
|
||||
|
||||
GstreamerPlayer* const player = (GstreamerPlayer*) self;
|
||||
|
||||
ListenerVector::iterator it = player->m_listeners.begin();
|
||||
ListenerVector::iterator end = player->m_listeners.end();
|
||||
while (it != end) {
|
||||
(*it)->onStart(player->m_Id);
|
||||
++it;
|
||||
}
|
||||
|
||||
// false == Don't call this idle function again
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Preload a file, to speed up the subsequent open() call.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
GstreamerPlayer :: preload(const std::string fileUrl)
|
||||
throw (std::invalid_argument,
|
||||
std::runtime_error)
|
||||
{
|
||||
DEBUG_BLOCK
|
||||
//According to the Gstreamer documentation, stream buffering happens
|
||||
//automatically when the pipeline is set to GST_STATE_PAUSED.
|
||||
//As this state is now set automatically in the open function,
|
||||
//we no longer have a need for preloading.
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Specify which file to play
|
||||
*----------------------------------------------------------------------------*/
|
||||
bool
|
||||
GstreamerPlayer :: open(const std::string fileUri, gint64 id, gint64 offset)
|
||||
throw (std::invalid_argument, std::runtime_error)
|
||||
{
|
||||
DEBUG_BLOCK
|
||||
|
||||
if (isOpen()) {
|
||||
close();
|
||||
}
|
||||
|
||||
m_smilOffset = 0L;
|
||||
|
||||
debug() << "Opening URL: " << fileUri << endl;
|
||||
debug() << "Timestamp: " << *TimeConversion::now() << endl;
|
||||
|
||||
m_errorMessage.reset();
|
||||
m_errorWasRaised = false;
|
||||
|
||||
m_playContext->setAudioDevice(m_audioDevice);
|
||||
if (fileUri.find(std::string(".smil")) != std::string::npos) {
|
||||
m_smilHandler = new SmilHandler();
|
||||
m_smilHandler->openSmilFile(fileUri.c_str(), offset);
|
||||
AudioDescription *audioDescription = m_smilHandler->getNext();
|
||||
gint64 clipOffset = m_smilHandler->getClipOffset();
|
||||
m_playContext->setClipOffset(clipOffset);
|
||||
m_Id = audioDescription->m_Id;
|
||||
m_open=m_playContext->openSource(audioDescription);
|
||||
m_url = (const char*) audioDescription->m_src;
|
||||
}else{
|
||||
m_open=m_playContext->openSource(fileUri.c_str());
|
||||
m_url = fileUri;
|
||||
m_Id = id;
|
||||
}
|
||||
|
||||
if(!m_open){
|
||||
close();
|
||||
deInitialize();
|
||||
initialize();
|
||||
m_playContext->forceEOS();
|
||||
return false;
|
||||
}
|
||||
g_idle_add(GstreamerPlayer::fireOnStartEvent, this);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
GstreamerPlayer :: playNextSmil(void) throw ()
|
||||
{
|
||||
DEBUG_BLOCK
|
||||
if(NULL == m_playContext)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
m_playContext->closeContext();
|
||||
if(m_smilHandler == NULL){
|
||||
return false;
|
||||
}
|
||||
AudioDescription *audioDescription = m_smilHandler->getNext();
|
||||
if(audioDescription == NULL){//no more audio entries to play
|
||||
delete m_smilHandler;
|
||||
m_smilHandler = NULL;
|
||||
return false;
|
||||
}
|
||||
if(!m_playContext->openSource(audioDescription)){
|
||||
m_playContext->stopContext();
|
||||
m_playContext->closeContext();
|
||||
m_open = false;
|
||||
deInitialize();
|
||||
initialize();
|
||||
m_playContext->forceEOS();
|
||||
return true;
|
||||
}
|
||||
m_Id = audioDescription->m_Id;
|
||||
m_url = (const char*) audioDescription->m_src;
|
||||
g_idle_add(GstreamerPlayer::fireOnStartEvent, this);
|
||||
m_smilOffset = audioDescription->m_begin;
|
||||
m_playContext->playContext();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Tell if we've been opened.
|
||||
*----------------------------------------------------------------------------*/
|
||||
bool
|
||||
GstreamerPlayer :: isOpen(void) throw ()
|
||||
{
|
||||
return m_open;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Get the length of the current audio clip.
|
||||
* Currently not used by the Studio, but may be used later on.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Ptr<time_duration>::Ref
|
||||
GstreamerPlayer :: getPlaylength(void) throw (std::logic_error)
|
||||
{
|
||||
DEBUG_BLOCK
|
||||
|
||||
if (!isOpen()) {
|
||||
throw std::logic_error("player not open");
|
||||
}
|
||||
|
||||
Ptr<time_duration>::Ref length;
|
||||
|
||||
gint64 ns = m_playContext->getPlayLength();
|
||||
|
||||
length.reset(new time_duration(microsec(ns / 1000LL)));
|
||||
|
||||
debug() << "playlength is: " << *length << endl;
|
||||
return length;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Get the current position of the current audio clip.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Ptr<time_duration>::Ref
|
||||
GstreamerPlayer :: getPosition(void) throw (std::logic_error)
|
||||
{
|
||||
Ptr<time_duration>::Ref length;
|
||||
|
||||
if (!isOpen()) {
|
||||
throw std::logic_error("player not open");
|
||||
}
|
||||
|
||||
gint64 ns = m_playContext->getPosition();
|
||||
length.reset(new time_duration(microseconds((m_smilOffset + ns) / 1000LL)));
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Start playing
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
GstreamerPlayer :: start() throw (std::logic_error)
|
||||
{
|
||||
DEBUG_BLOCK
|
||||
if (!isOpen()) {
|
||||
throw std::logic_error("GstreamerPlayer not opened yet");
|
||||
}
|
||||
|
||||
if (!isPlaying()) {
|
||||
m_playContext->playContext();
|
||||
}else{
|
||||
error() << "Already playing!" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Pause the player
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
GstreamerPlayer :: pause(void) throw (std::logic_error)
|
||||
{
|
||||
DEBUG_BLOCK
|
||||
|
||||
if (isPlaying()) {
|
||||
m_playContext->pauseContext();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Tell if we're playing
|
||||
*----------------------------------------------------------------------------*/
|
||||
bool
|
||||
GstreamerPlayer :: isPlaying(void) throw ()
|
||||
{
|
||||
return m_playContext->isPlaying();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Stop playing
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
GstreamerPlayer :: stop(void) throw (std::logic_error)
|
||||
{
|
||||
DEBUG_BLOCK
|
||||
|
||||
if (!isOpen()) {
|
||||
throw std::logic_error("GstreamerPlayer not opened yet");
|
||||
}
|
||||
|
||||
if (isPlaying()) {
|
||||
m_playContext->stopContext();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Close the currently opened audio file.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
GstreamerPlayer :: close(void) throw (std::logic_error)
|
||||
{
|
||||
DEBUG_BLOCK
|
||||
m_playContext->stopContext();
|
||||
m_playContext->closeContext();
|
||||
if(m_smilHandler != NULL){
|
||||
delete m_smilHandler;
|
||||
m_smilHandler = NULL;
|
||||
}
|
||||
m_open = false;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Get the volume of the player. *Unimplemented*: Feature is currently not used.
|
||||
*----------------------------------------------------------------------------*/
|
||||
unsigned int
|
||||
GstreamerPlayer :: getVolume(void) throw ()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Set the volume of the player. *Unimplemented*: Feature is currently not used.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
GstreamerPlayer :: setVolume(unsigned int volume) throw ()
|
||||
{}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Set the audio device.
|
||||
*----------------------------------------------------------------------------*/
|
||||
bool
|
||||
GstreamerPlayer :: setAudioDevice(const std::string &deviceName)
|
||||
throw ()
|
||||
{
|
||||
DEBUG_BLOCK
|
||||
|
||||
debug() << "Using device: " << deviceName << endl;
|
||||
|
||||
if (deviceName.size() == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_playContext->setAudioDevice(deviceName);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -1,404 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
|
||||
This file is part of the Campcaster project.
|
||||
http://campcaster.sourcefabric.org/
|
||||
|
||||
Campcaster is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Campcaster is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Campcaster; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef GstreamerPlayer_h
|
||||
#define GstreamerPlayer_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
#endif
|
||||
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <list>
|
||||
|
||||
#include <gst/gst.h>
|
||||
|
||||
#include "LiveSupport/Core/Configurable.h"
|
||||
#include "LiveSupport/PlaylistExecutor/AudioPlayerInterface.h"
|
||||
#include "LiveSupport/Core/Thread.h"
|
||||
|
||||
#include "LiveSupport/Core/Playlist.h"
|
||||
|
||||
#include "GstreamerPlayContext.h"
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace PlaylistExecutor {
|
||||
|
||||
using namespace boost::posix_time;
|
||||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
||||
/* =================================================================== macros */
|
||||
|
||||
|
||||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* A class to play audio files and some SMIL files through the Gstreamer
|
||||
* library.
|
||||
* This class can be configured with the following XML element.
|
||||
*
|
||||
* <pre><code>
|
||||
* <gstreamerPlayer audioDevice = "default" />
|
||||
* </code></pre>
|
||||
*
|
||||
* where the optional audioDevice argument specifies the audio device
|
||||
* (currently ALSA device) to use for playing.
|
||||
*
|
||||
* The DTD for the above configuration is the following:
|
||||
*
|
||||
* <pre><code>
|
||||
* <!ELEMENT gstreamerPlayer EMPTY >
|
||||
* <!ATTLIST gstreamerPlayer audioDevice CDATA #IMPLIED >
|
||||
* </code></pre>
|
||||
*
|
||||
*/
|
||||
class GstreamerPlayer : virtual public Configurable,
|
||||
virtual public AudioPlayerInterface
|
||||
{
|
||||
|
||||
private:
|
||||
/**
|
||||
* The name of the configuration XML elmenent used by GstreamerPlayer
|
||||
*/
|
||||
static const std::string configElementNameStr;
|
||||
|
||||
/**
|
||||
* The pipeline inside the player
|
||||
*/
|
||||
GstreamerPlayContext *m_playContext;
|
||||
SmilHandler *m_smilHandler;
|
||||
|
||||
|
||||
/**
|
||||
* The URL to play.
|
||||
*/
|
||||
std::string m_url;
|
||||
|
||||
/**
|
||||
* Flag to indicate if this object has been initialized.
|
||||
*/
|
||||
bool m_initialized;
|
||||
bool m_open;
|
||||
|
||||
/**
|
||||
* The audio device to play on.
|
||||
*/
|
||||
std::string m_audioDevice;
|
||||
|
||||
gint64 m_smilOffset;
|
||||
gint64 m_currentPlayLength;
|
||||
gint64 m_Id;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Contains runtime error messages from GStreamer.
|
||||
*/
|
||||
Ptr<const Glib::ustring>::Ref m_errorMessage;
|
||||
|
||||
/**
|
||||
* Flag that indicates that a GStreamer error had previously occured.
|
||||
*/
|
||||
bool m_errorWasRaised;
|
||||
|
||||
/**
|
||||
* The type for the vector of listeners.
|
||||
* Just a shorthand notation, to make reference to the type
|
||||
* easier.
|
||||
*/
|
||||
typedef std::vector<AudioPlayerEventListener*>
|
||||
ListenerVector;
|
||||
|
||||
/**
|
||||
* A vector of event listeners, which are interested in events
|
||||
* related to this player.
|
||||
*/
|
||||
ListenerVector m_listeners;
|
||||
|
||||
|
||||
/**
|
||||
* Send the onStop event to all attached listeners.
|
||||
*/
|
||||
static gboolean
|
||||
fireOnStopEvent(gpointer self) throw ();
|
||||
|
||||
/**
|
||||
* Send the onStart event to all attached listeners.
|
||||
*/
|
||||
static gboolean
|
||||
fireOnStartEvent(gpointer self) throw ();
|
||||
|
||||
public:
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
GstreamerPlayer(void) throw ()
|
||||
{
|
||||
m_playContext = 0;
|
||||
m_open = false;
|
||||
m_initialized = false;
|
||||
m_smilHandler = NULL;
|
||||
m_smilOffset = 0L;
|
||||
m_currentPlayLength = 0L;
|
||||
}
|
||||
|
||||
/**
|
||||
* A virtual destructor, as this class has virtual functions.
|
||||
*/
|
||||
virtual
|
||||
~GstreamerPlayer(void) throw ()
|
||||
{
|
||||
deInitialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name of the XML element this object expects
|
||||
* to be sent to a call to configure().
|
||||
*
|
||||
* @return the name of the expected XML configuration element.
|
||||
*/
|
||||
static const std::string
|
||||
getConfigElementName(void) throw ()
|
||||
{
|
||||
return configElementNameStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the object based on the XML element supplied.
|
||||
*
|
||||
* @param element the XML element to configure the object from.
|
||||
* @exception std::invalid_argument if the supplied XML element
|
||||
* contains bad configuraiton information
|
||||
* @exception std::logic_error if the scheduler daemon has already
|
||||
* been configured, and can not be reconfigured.
|
||||
*/
|
||||
virtual void
|
||||
configure(const xmlpp::Element & element)
|
||||
throw (std::invalid_argument,
|
||||
std::logic_error);
|
||||
|
||||
/**
|
||||
* Initialize the Audio Player object, so that it is ready to
|
||||
* play audio files.
|
||||
*
|
||||
* @exception std::exception on initialization problems.
|
||||
*/
|
||||
virtual void
|
||||
initialize(void) throw (std::exception);
|
||||
|
||||
/**
|
||||
* De-initialize the Audio Player object.
|
||||
*/
|
||||
virtual void
|
||||
deInitialize(void) throw ();
|
||||
|
||||
/**
|
||||
* Attach an event listener for this audio player.
|
||||
* After this call, the supplied event will recieve all events
|
||||
* related to this audio player.
|
||||
*
|
||||
* @param eventListener the event listener to register.
|
||||
* @see #detach
|
||||
*/
|
||||
virtual void
|
||||
attachListener(AudioPlayerEventListener* eventListener)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* Detach an event listener for this audio player.
|
||||
*
|
||||
* @param eventListener the event listener to unregister.
|
||||
* @exception std::invalid_argument if the supplied event listener
|
||||
* has not been previously registered.
|
||||
* @see #attach
|
||||
*/
|
||||
virtual void
|
||||
detachListener(AudioPlayerEventListener* eventListener)
|
||||
throw (std::invalid_argument);
|
||||
|
||||
/**
|
||||
* Set the audio device used for playback.
|
||||
*
|
||||
* @param deviceName the new device name, e.g., /dev/dsp or
|
||||
* plughw:0,0
|
||||
* @return true if successful, false if not
|
||||
*/
|
||||
virtual bool
|
||||
setAudioDevice(const std::string &deviceName)
|
||||
throw ();
|
||||
|
||||
virtual void
|
||||
preload(const std::string fileUrl) throw (std::invalid_argument,
|
||||
std::runtime_error);
|
||||
|
||||
/**
|
||||
* Specify which audio resource to play.
|
||||
* The file may be a playlist, referencing other files, which
|
||||
* will be accessed automatically.
|
||||
* Note: this call will <b>not</b> start playing! You will
|
||||
* have to call the start() function to begin playing.
|
||||
* Always close any opened resource with a call to close().
|
||||
*
|
||||
* @param fileUrl a URL to a file
|
||||
* @exception std::invalid_argument if the supplied fileUrl
|
||||
* seems to be invalid.
|
||||
* @exception std::runtime_error if the file could not be openned,
|
||||
* for example because the audio device of the player
|
||||
* is being exclusively used by an other process.
|
||||
* @see #close
|
||||
* @see #start
|
||||
*/
|
||||
virtual bool
|
||||
open(const std::string fileUrl, gint64 id, gint64 offset)
|
||||
throw (std::invalid_argument, std::runtime_error);
|
||||
|
||||
/**
|
||||
* Tell if the object is currently opened (has a file source to
|
||||
* read.)
|
||||
*
|
||||
* @return true if the object is currently opened, false otherwise.
|
||||
*/
|
||||
virtual bool
|
||||
isOpen(void) throw ();
|
||||
|
||||
/**
|
||||
* Plays next audio from current smil sequence
|
||||
*
|
||||
*
|
||||
* @return true if next smil is available, false otherwise.
|
||||
*/
|
||||
virtual bool
|
||||
playNextSmil(void) throw ();
|
||||
|
||||
/**
|
||||
* Close an audio source that was opened.
|
||||
*
|
||||
* @see #open
|
||||
*/
|
||||
virtual void
|
||||
close(void) throw (std::logic_error);
|
||||
|
||||
/**
|
||||
* Start playing.
|
||||
* This call will start playing the active playlist, which was
|
||||
* set by a previous call to open().
|
||||
* Playing can be stopped by calling stop().
|
||||
*
|
||||
* @exception std::logic_error if there was no previous call to
|
||||
* open().
|
||||
* @see #open
|
||||
* @see #stop
|
||||
*/
|
||||
virtual void
|
||||
start() throw (std::logic_error);
|
||||
|
||||
/**
|
||||
* Pause the player.
|
||||
* Playing can be resumed by calling start().
|
||||
*
|
||||
* @exception std::logic_error if there was no previous call to
|
||||
* open().
|
||||
* @see #open
|
||||
* @see #start
|
||||
*/
|
||||
virtual void
|
||||
pause(void) throw (std::logic_error);
|
||||
|
||||
/**
|
||||
* Tell if we're currently playing.
|
||||
*
|
||||
* @return true of the player is currently playing, false
|
||||
* otherwise.
|
||||
*/
|
||||
virtual bool
|
||||
isPlaying(void) throw ();
|
||||
|
||||
/**
|
||||
* Stop playing.
|
||||
*
|
||||
* @exception std::logic_error if there was no previous call to
|
||||
* start()
|
||||
*/
|
||||
virtual void
|
||||
stop(void) throw (std::logic_error);
|
||||
|
||||
/**
|
||||
* Get the length of the currently opened audio clip.
|
||||
* This function waits as long as necessary to get the length.
|
||||
*
|
||||
* @return the length of the currently playing audio clip
|
||||
* @exception std::logic_error if there is no audio file open.
|
||||
*/
|
||||
virtual Ptr<posix_time::time_duration>::Ref
|
||||
getPlaylength(void) throw (std::logic_error);
|
||||
|
||||
/**
|
||||
* Return the current time position in the audio file.
|
||||
*
|
||||
* @return the current time position in the currently open audio file.
|
||||
* @exception std::logic_error if there is no audio file open.
|
||||
*/
|
||||
virtual Ptr<posix_time::time_duration>::Ref
|
||||
getPosition(void) throw (std::logic_error);
|
||||
|
||||
/**
|
||||
* Get the volume of the player. *Unimplemented*
|
||||
*
|
||||
* @return the volume, from 1 to 100.
|
||||
*/
|
||||
virtual unsigned int
|
||||
getVolume(void) throw ();
|
||||
|
||||
/**
|
||||
* Set the volume of the player. *Unimplemented*
|
||||
*
|
||||
* @param volume the new volume, from 1 to 100.
|
||||
*/
|
||||
virtual void
|
||||
setVolume(unsigned int volume) throw ();
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
||||
|
||||
/* ====================================================== function prototypes */
|
||||
|
||||
|
||||
} // namespace PlaylistExecutor
|
||||
} // namespace LiveSupport
|
||||
|
||||
|
||||
#endif // GstreamerPlayer_h
|
||||
|
|
@ -1,831 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
|
||||
This file is part of the Campcaster project.
|
||||
http://campcaster.sourcefabric.org/
|
||||
|
||||
Campcaster is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Campcaster is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Campcaster; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#else
|
||||
#error "Need unistd.h"
|
||||
#endif
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
#include "LiveSupport/Core/TimeConversion.h"
|
||||
|
||||
#include "GstreamerPlayer.h"
|
||||
#include "TestEventListener.h"
|
||||
#include "GstreamerPlayerTest.h"
|
||||
|
||||
|
||||
using namespace LiveSupport::PlaylistExecutor;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(GstreamerPlayerTest);
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the audio player.
|
||||
*/
|
||||
static const std::string configFileName = "etc/gstreamerPlayer.xml";
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Set up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
GstreamerPlayerTest :: setUp(void) throw ()
|
||||
{
|
||||
try {
|
||||
Ptr<xmlpp::DomParser>::Ref parser(
|
||||
new xmlpp::DomParser(configFileName, true));
|
||||
const xmlpp::Document * document = parser->get_document();
|
||||
const xmlpp::Element * root = document->get_root_node();
|
||||
|
||||
player.reset(new GstreamerPlayer());
|
||||
player->configure(*root);
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << "semantic error in configuration file" << std::endl;
|
||||
} catch (xmlpp::exception &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Clean up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
GstreamerPlayerTest :: tearDown(void) throw ()
|
||||
{
|
||||
player.reset();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Test to see if the GstreamerPlayer engine can be started and stopped
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
GstreamerPlayerTest :: firstTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->initialize();
|
||||
);
|
||||
CPPUNIT_ASSERT(!player->isPlaying());
|
||||
player->deInitialize();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Play something simple
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
GstreamerPlayerTest :: simplePlayTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
Ptr<time_duration>::Ref sleepT(new time_duration(microseconds(10)));
|
||||
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->initialize();
|
||||
);
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->open("file:///tmp/campcaster/test.mp3");
|
||||
);
|
||||
CPPUNIT_ASSERT(!player->isPlaying());
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->start();
|
||||
);
|
||||
CPPUNIT_ASSERT(player->isPlaying());
|
||||
while (player->isPlaying()) {
|
||||
TimeConversion::sleep(sleepT);
|
||||
}
|
||||
|
||||
Ptr<time_duration>::Ref playlength = player->getPlaylength();
|
||||
CPPUNIT_ASSERT(playlength.get());
|
||||
CPPUNIT_ASSERT(playlength->seconds() == 14);
|
||||
CPPUNIT_ASSERT(playlength->fractional_seconds() == 785187);
|
||||
|
||||
CPPUNIT_ASSERT(!player->isPlaying());
|
||||
player->close();
|
||||
player->deInitialize();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Check the getPosition() function
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
GstreamerPlayerTest :: getPositionTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
Ptr<time_duration>::Ref sleepT(new time_duration(microseconds(100)));
|
||||
Ptr<ptime>::Ref start;
|
||||
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->initialize();
|
||||
);
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->open("file:///tmp/campcaster/test.mp3");
|
||||
);
|
||||
CPPUNIT_ASSERT(!player->isPlaying());
|
||||
start = TimeConversion::now();
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->start();
|
||||
);
|
||||
CPPUNIT_ASSERT(player->isPlaying());
|
||||
while (player->isPlaying()) {
|
||||
Ptr<ptime>::Ref now = TimeConversion::now();
|
||||
Ptr<time_duration>::Ref offset(new time_duration(*now - *start));
|
||||
Ptr<time_duration>::Ref position;
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
position = player->getPosition()
|
||||
);
|
||||
|
||||
TimeConversion::sleep(sleepT);
|
||||
// TODO: check here for abs(position - offset) < epsilon
|
||||
// but unforunately seeking / position reporting with the mad
|
||||
// plugin is quite off the scale
|
||||
}
|
||||
|
||||
Ptr<time_duration>::Ref playlength = player->getPlaylength();
|
||||
CPPUNIT_ASSERT(playlength.get());
|
||||
CPPUNIT_ASSERT(playlength->seconds() == 14);
|
||||
CPPUNIT_ASSERT(playlength->fractional_seconds() == 785187);
|
||||
|
||||
CPPUNIT_ASSERT(!player->isPlaying());
|
||||
player->close();
|
||||
player->deInitialize();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Check if the setDevice() function works are advertized.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
GstreamerPlayerTest :: setDeviceTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
Ptr<time_duration>::Ref sleepT(new time_duration(microseconds(10)));
|
||||
Ptr<time_duration>::Ref playlength;
|
||||
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->initialize();
|
||||
);
|
||||
|
||||
// check on an ALSA device
|
||||
CPPUNIT_ASSERT(player->setAudioDevice("plughw:0,0"));
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->open("file:///tmp/campcaster/test-short.mp3");
|
||||
);
|
||||
CPPUNIT_ASSERT(!player->isPlaying());
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->start();
|
||||
);
|
||||
CPPUNIT_ASSERT(player->isPlaying());
|
||||
while (player->isPlaying()) {
|
||||
TimeConversion::sleep(sleepT);
|
||||
}
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
playlength = player->getPlaylength();
|
||||
);
|
||||
CPPUNIT_ASSERT(playlength.get());
|
||||
CPPUNIT_ASSERT(playlength->seconds() == 2);
|
||||
CPPUNIT_ASSERT(!player->isPlaying());
|
||||
|
||||
// check on an OSS DSP device
|
||||
CPPUNIT_ASSERT(player->setAudioDevice("/dev/dsp"));
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->open("file:///tmp/campcaster/test-short.mp3");
|
||||
);
|
||||
CPPUNIT_ASSERT(!player->isPlaying());
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->start();
|
||||
);
|
||||
CPPUNIT_ASSERT(player->isPlaying());
|
||||
while (player->isPlaying()) {
|
||||
TimeConversion::sleep(sleepT);
|
||||
}
|
||||
playlength = player->getPlaylength();
|
||||
CPPUNIT_ASSERT(playlength.get());
|
||||
CPPUNIT_ASSERT(playlength->seconds() == 2);
|
||||
CPPUNIT_ASSERT(!player->isPlaying());
|
||||
|
||||
// check changing from ALSA to OSS after opening
|
||||
CPPUNIT_ASSERT(player->setAudioDevice("plughw:0,0"));
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->open("file:///tmp/campcaster/test-short.mp3");
|
||||
);
|
||||
CPPUNIT_ASSERT(player->setAudioDevice("/dev/dsp"));
|
||||
CPPUNIT_ASSERT(!player->isPlaying());
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->start();
|
||||
);
|
||||
CPPUNIT_ASSERT(player->isPlaying());
|
||||
while (player->isPlaying()) {
|
||||
TimeConversion::sleep(sleepT);
|
||||
}
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
playlength = player->getPlaylength();
|
||||
);
|
||||
CPPUNIT_ASSERT(playlength.get());
|
||||
CPPUNIT_ASSERT(playlength->seconds() == 2);
|
||||
CPPUNIT_ASSERT(!player->isPlaying());
|
||||
|
||||
// test playing on ALSA after playing on OSS
|
||||
player->close();
|
||||
CPPUNIT_ASSERT(player->setAudioDevice("plughw:0,0"));
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->open("file:///tmp/campcaster/test-short.mp3")
|
||||
);
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->start();
|
||||
);
|
||||
while (player->isPlaying()) {
|
||||
TimeConversion::sleep(sleepT);
|
||||
}
|
||||
CPPUNIT_ASSERT(!player->isPlaying());
|
||||
|
||||
player->close();
|
||||
player->deInitialize();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Play a simple SMIL file
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
GstreamerPlayerTest :: simpleSmilTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
Ptr<time_duration>::Ref sleepT(new time_duration(microseconds(10)));
|
||||
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->initialize();
|
||||
);
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->open("file:///tmp/campcaster/simpleSmil.smil");
|
||||
);
|
||||
CPPUNIT_ASSERT(!player->isPlaying());
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->start();
|
||||
);
|
||||
CPPUNIT_ASSERT(player->isPlaying());
|
||||
while (player->isPlaying()) {
|
||||
TimeConversion::sleep(sleepT);
|
||||
}
|
||||
CPPUNIT_ASSERT(!player->isPlaying());
|
||||
player->close();
|
||||
player->deInitialize();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Play a more complicated SMIL file
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
GstreamerPlayerTest :: secondSmilTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
Ptr<time_duration>::Ref sleepT(new time_duration(microseconds(10)));
|
||||
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->initialize();
|
||||
);
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->open("file:///tmp/campcaster/sequentialSmil.smil");
|
||||
);
|
||||
CPPUNIT_ASSERT(!player->isPlaying());
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->start();
|
||||
);
|
||||
CPPUNIT_ASSERT(player->isPlaying());
|
||||
while (player->isPlaying()) {
|
||||
TimeConversion::sleep(sleepT);
|
||||
}
|
||||
CPPUNIT_ASSERT(!player->isPlaying());
|
||||
player->close();
|
||||
player->deInitialize();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Play a SMIL file with sound animation
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
GstreamerPlayerTest :: animatedSmilTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
Ptr<time_duration>::Ref sleepT(new time_duration(microseconds(10)));
|
||||
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->initialize();
|
||||
);
|
||||
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->open("file:///tmp/campcaster/animatedSmil.smil");
|
||||
);
|
||||
CPPUNIT_ASSERT(!player->isPlaying());
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->start();
|
||||
);
|
||||
CPPUNIT_ASSERT(player->isPlaying());
|
||||
while (player->isPlaying()) {
|
||||
TimeConversion::sleep(sleepT);
|
||||
}
|
||||
CPPUNIT_ASSERT(!player->isPlaying());
|
||||
player->close();
|
||||
|
||||
player->deInitialize();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Check for error conditions
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
GstreamerPlayerTest :: checkErrorConditions(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->initialize();
|
||||
);
|
||||
|
||||
bool gotException;
|
||||
|
||||
CPPUNIT_ASSERT(!player->isPlaying());
|
||||
|
||||
gotException = false;
|
||||
try {
|
||||
player->start();
|
||||
} catch (std::logic_error &e) {
|
||||
gotException = true;
|
||||
}
|
||||
CPPUNIT_ASSERT(gotException);
|
||||
|
||||
gotException = false;
|
||||
try {
|
||||
player->stop();
|
||||
} catch (std::logic_error &e) {
|
||||
gotException = true;
|
||||
}
|
||||
CPPUNIT_ASSERT(gotException);
|
||||
|
||||
gotException = false;
|
||||
try {
|
||||
player->open("totally/bad/URL");
|
||||
} catch (std::invalid_argument &e) {
|
||||
gotException = true;
|
||||
} catch (std::runtime_error &e) {
|
||||
CPPUNIT_FAIL(e.what());
|
||||
}
|
||||
CPPUNIT_ASSERT(gotException);
|
||||
|
||||
gotException = false;
|
||||
try {
|
||||
player->start();
|
||||
} catch (std::logic_error &e) {
|
||||
gotException = true;
|
||||
}
|
||||
CPPUNIT_ASSERT(gotException);
|
||||
|
||||
// check for opening a wrong URL after opening a proper one
|
||||
try {
|
||||
player->open("file:///tmp/campcaster/test.mp3");
|
||||
} catch (std::invalid_argument &e) {
|
||||
CPPUNIT_FAIL(e.what());
|
||||
} catch (std::runtime_error &e) {
|
||||
CPPUNIT_FAIL(e.what());
|
||||
}
|
||||
player->close();
|
||||
gotException = false;
|
||||
try {
|
||||
player->open("totally/bad/URL");
|
||||
} catch (std::invalid_argument &e) {
|
||||
gotException = true;
|
||||
} catch (std::runtime_error &e) {
|
||||
CPPUNIT_FAIL(e.what());
|
||||
}
|
||||
CPPUNIT_ASSERT(gotException);
|
||||
|
||||
player->deInitialize();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Test to see if attaching and detaching event listeners works.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
GstreamerPlayerTest :: eventListenerAttachTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
CPPUNIT_ASSERT_NO_THROW(player->initialize());
|
||||
|
||||
Ptr<TestEventListener>::Ref listener1(new TestEventListener());
|
||||
Ptr<TestEventListener>::Ref listener2(new TestEventListener());
|
||||
|
||||
// try with one listener
|
||||
player->attachListener(listener1.get());
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->detachListener(listener1.get())
|
||||
);
|
||||
CPPUNIT_ASSERT_THROW(
|
||||
player->detachListener(listener1.get()),
|
||||
std::invalid_argument
|
||||
);
|
||||
|
||||
// try with two listeners
|
||||
player->attachListener(listener1.get());
|
||||
CPPUNIT_ASSERT_THROW(
|
||||
player->detachListener(listener2.get()),
|
||||
std::invalid_argument
|
||||
);
|
||||
player->attachListener(listener2.get());
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->detachListener(listener1.get());
|
||||
);
|
||||
|
||||
player->deInitialize();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Test to see if the player event listener mechanism works.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
GstreamerPlayerTest :: eventListenerTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
CPPUNIT_ASSERT_NO_THROW(player->initialize());
|
||||
|
||||
Ptr<time_duration>::Ref sleepT(new time_duration(microseconds(10)));
|
||||
Ptr<TestEventListener>::Ref listener1(new TestEventListener());
|
||||
player->attachListener(listener1.get());
|
||||
|
||||
// try with one listener
|
||||
CPPUNIT_ASSERT(!listener1->stopFlag);
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->open("file:///tmp/campcaster/test.mp3");
|
||||
);
|
||||
CPPUNIT_ASSERT(!player->isPlaying());
|
||||
CPPUNIT_ASSERT(!listener1->stopFlag);
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->start();
|
||||
);
|
||||
CPPUNIT_ASSERT(player->isPlaying());
|
||||
CPPUNIT_ASSERT(!listener1->stopFlag);
|
||||
while (player->isPlaying()) {
|
||||
CPPUNIT_ASSERT(!listener1->stopFlag);
|
||||
TimeConversion::sleep(sleepT);
|
||||
}
|
||||
CPPUNIT_ASSERT(!player->isPlaying());
|
||||
CPPUNIT_ASSERT(listener1->stopFlag);
|
||||
listener1->stopFlag = false;
|
||||
player->close();
|
||||
|
||||
// try with two listeners
|
||||
Ptr<TestEventListener>::Ref listener2(new TestEventListener());
|
||||
player->attachListener(listener2.get());
|
||||
|
||||
CPPUNIT_ASSERT(!listener1->stopFlag);
|
||||
CPPUNIT_ASSERT(!listener2->stopFlag);
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->open("file:///tmp/campcaster/test.mp3");
|
||||
);
|
||||
CPPUNIT_ASSERT(!player->isPlaying());
|
||||
CPPUNIT_ASSERT(!listener1->stopFlag);
|
||||
CPPUNIT_ASSERT(!listener2->stopFlag);
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->start();
|
||||
);
|
||||
CPPUNIT_ASSERT(player->isPlaying());
|
||||
CPPUNIT_ASSERT(!listener1->stopFlag);
|
||||
CPPUNIT_ASSERT(!listener2->stopFlag);
|
||||
while (player->isPlaying()) {
|
||||
CPPUNIT_ASSERT(!listener1->stopFlag);
|
||||
CPPUNIT_ASSERT(!listener2->stopFlag);
|
||||
TimeConversion::sleep(sleepT);
|
||||
}
|
||||
CPPUNIT_ASSERT(!player->isPlaying());
|
||||
CPPUNIT_ASSERT(listener1->stopFlag);
|
||||
CPPUNIT_ASSERT(listener2->stopFlag);
|
||||
listener1->stopFlag = false;
|
||||
listener2->stopFlag = false;
|
||||
player->close();
|
||||
|
||||
// try with only the second listener
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->detachListener(listener1.get());
|
||||
);
|
||||
CPPUNIT_ASSERT(!listener2->stopFlag);
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->open("file:///tmp/campcaster/test.mp3");
|
||||
);
|
||||
CPPUNIT_ASSERT(!player->isPlaying());
|
||||
CPPUNIT_ASSERT(!listener2->stopFlag);
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->start();
|
||||
);
|
||||
CPPUNIT_ASSERT(player->isPlaying());
|
||||
CPPUNIT_ASSERT(!listener2->stopFlag);
|
||||
while (player->isPlaying()) {
|
||||
CPPUNIT_ASSERT(!listener2->stopFlag);
|
||||
TimeConversion::sleep(sleepT);
|
||||
}
|
||||
CPPUNIT_ASSERT(!player->isPlaying());
|
||||
CPPUNIT_ASSERT(listener2->stopFlag);
|
||||
listener2->stopFlag = false;
|
||||
player->close();
|
||||
|
||||
player->deInitialize();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Another, more realistic test of the event listener mechanism.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
GstreamerPlayerTest :: eventListenerOnStopTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
CPPUNIT_ASSERT_NO_THROW(player->initialize());
|
||||
player->attachListener(this);
|
||||
|
||||
// start the first clip
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->open("file:///tmp/campcaster/test-short.mp3");
|
||||
);
|
||||
CPPUNIT_ASSERT(!player->isPlaying());
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->start();
|
||||
);
|
||||
CPPUNIT_ASSERT(player->isPlaying());
|
||||
startNewClipFlag = true;
|
||||
|
||||
// sleep for a while; in the meantime, onStop() starts the second clip
|
||||
Ptr<time_duration>::Ref sleepT(new time_duration(seconds(7)));
|
||||
TimeConversion::sleep(sleepT);
|
||||
|
||||
// the second clip should be over by now
|
||||
CPPUNIT_ASSERT(!player->isPlaying());
|
||||
player->close();
|
||||
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->detachListener(this);
|
||||
);
|
||||
player->deInitialize();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Another, more realistic test of the event listener mechanism.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
GstreamerPlayerTest :: onStop(Ptr<const Glib::ustring>::Ref errorMessage)
|
||||
throw ()
|
||||
{
|
||||
if (!startNewClipFlag) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->close();
|
||||
);
|
||||
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->open("file:///tmp/campcaster/test-short.mp3");
|
||||
);
|
||||
CPPUNIT_ASSERT(!player->isPlaying());
|
||||
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->start();
|
||||
);
|
||||
CPPUNIT_ASSERT(player->isPlaying());
|
||||
} catch (CPPUNIT_NS::Exception &e) {
|
||||
std::cerr << "Exception in onStop(): " << e.what() << std::endl;
|
||||
}
|
||||
|
||||
startNewClipFlag = false;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Time how long it takes to open, play and close files.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
GstreamerPlayerTest :: timeSteps(const std::string fileName)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
Ptr<ptime>::Ref start;
|
||||
Ptr<ptime>::Ref end;
|
||||
Ptr<time_duration>::Ref openTime;
|
||||
Ptr<time_duration>::Ref startTime;
|
||||
Ptr<time_duration>::Ref stopTime;
|
||||
Ptr<time_duration>::Ref closeTime;
|
||||
|
||||
start = TimeConversion::now();
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->open(fileName);
|
||||
);
|
||||
end = TimeConversion::now();
|
||||
openTime.reset(new time_duration(*end - *start));
|
||||
|
||||
CPPUNIT_ASSERT(!player->isPlaying());
|
||||
start = TimeConversion::now();
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->start();
|
||||
);
|
||||
end = TimeConversion::now();
|
||||
startTime.reset(new time_duration(*end - *start));
|
||||
|
||||
CPPUNIT_ASSERT(player->isPlaying());
|
||||
|
||||
start = TimeConversion::now();
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->stop();
|
||||
);
|
||||
end = TimeConversion::now();
|
||||
stopTime.reset(new time_duration(*end - *start));
|
||||
|
||||
CPPUNIT_ASSERT(!player->isPlaying());
|
||||
|
||||
start = TimeConversion::now();
|
||||
player->close();
|
||||
end = TimeConversion::now();
|
||||
closeTime.reset(new time_duration(*end - *start));
|
||||
|
||||
// TODO: somehow assert on the time values
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Test how long it takes to open and play files.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
GstreamerPlayerTest :: openTimeTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->initialize();
|
||||
);
|
||||
|
||||
timeSteps("file:///tmp/campcaster/test.mp3");
|
||||
|
||||
timeSteps("file:///tmp/campcaster/simpleSmil.smil");
|
||||
|
||||
timeSteps("file:///tmp/campcaster/sequentialSmil.smil");
|
||||
|
||||
player->deInitialize();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Test pausing and resuming.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
GstreamerPlayerTest :: pauseResumeTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
Ptr<time_duration>::Ref sleepT;
|
||||
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->initialize();
|
||||
);
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->open("file:///tmp/campcaster/test10001.mp3");
|
||||
);
|
||||
CPPUNIT_ASSERT(!player->isPlaying());
|
||||
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->start();
|
||||
);
|
||||
CPPUNIT_ASSERT(player->isPlaying());
|
||||
|
||||
sleepT.reset(new time_duration(seconds(2)));
|
||||
TimeConversion::sleep(sleepT);
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->pause();
|
||||
);
|
||||
CPPUNIT_ASSERT(!player->isPlaying());
|
||||
|
||||
sleepT.reset(new time_duration(seconds(10)));
|
||||
TimeConversion::sleep(sleepT);
|
||||
CPPUNIT_ASSERT(!player->isPlaying());
|
||||
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->start();
|
||||
);
|
||||
CPPUNIT_ASSERT(player->isPlaying());
|
||||
|
||||
sleepT.reset(new time_duration(seconds(1)));
|
||||
TimeConversion::sleep(sleepT);
|
||||
CPPUNIT_ASSERT(player->isPlaying());
|
||||
|
||||
sleepT.reset(new time_duration(microseconds(10)));
|
||||
while (player->isPlaying()) {
|
||||
TimeConversion::sleep(sleepT);
|
||||
}
|
||||
|
||||
CPPUNIT_ASSERT(!player->isPlaying());
|
||||
player->close();
|
||||
player->deInitialize();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Open the same soundcard twice, thus force an error
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
GstreamerPlayerTest :: openSoundcardTwiceTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
Ptr<time_duration>::Ref sleepT(new time_duration(microseconds(10)));
|
||||
Ptr<GstreamerPlayer>::Ref player2;
|
||||
|
||||
// create a second player, with the same config as our usual player
|
||||
try {
|
||||
Ptr<xmlpp::DomParser>::Ref parser(
|
||||
new xmlpp::DomParser(configFileName, true));
|
||||
const xmlpp::Document * document = parser->get_document();
|
||||
const xmlpp::Element * root = document->get_root_node();
|
||||
|
||||
player2.reset(new GstreamerPlayer());
|
||||
player2->configure(*root);
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
CPPUNIT_FAIL("semantic error in configuration file");
|
||||
} catch (xmlpp::exception &e) {
|
||||
CPPUNIT_FAIL(e.what());
|
||||
}
|
||||
|
||||
// initialize & start playing on the first player
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->initialize();
|
||||
);
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->open("file:///tmp/campcaster/test.mp3");
|
||||
);
|
||||
CPPUNIT_ASSERT(!player->isPlaying());
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->start();
|
||||
);
|
||||
CPPUNIT_ASSERT(player->isPlaying());
|
||||
|
||||
// now open the same again in the second one
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player2->initialize();
|
||||
);
|
||||
try {
|
||||
player2->open("file:///tmp/campcaster/test.mp3");
|
||||
} catch (std::invalid_argument &e) {
|
||||
CPPUNIT_FAIL(e.what());
|
||||
} catch (std::runtime_error &e) {
|
||||
// this is what we're expecting, if open failed for the reason of
|
||||
// the soundcard being blocked. this doesn't always happen with
|
||||
// ALSA drivers (with dmix, for example)
|
||||
}
|
||||
CPPUNIT_ASSERT(!player2->isPlaying());
|
||||
|
||||
// close everything
|
||||
player2->close();
|
||||
player2->deInitialize();
|
||||
player->close();
|
||||
player->deInitialize();
|
||||
}
|
||||
|
|
@ -1,258 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
|
||||
This file is part of the Campcaster project.
|
||||
http://campcaster.sourcefabric.org/
|
||||
|
||||
Campcaster is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Campcaster is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Campcaster; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef GstreamerPlayerTest_h
|
||||
#define GstreamerPlayerTest_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
#endif
|
||||
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace PlaylistExecutor {
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
||||
/* =================================================================== macros */
|
||||
|
||||
|
||||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* Unit test for the GstreamerPlayer class.
|
||||
*
|
||||
* @see GstreamerPlayer
|
||||
*/
|
||||
class GstreamerPlayerTest : public CPPUNIT_NS::TestFixture,
|
||||
public AudioPlayerEventListener
|
||||
{
|
||||
/* CPPUNIT_TEST_SUITE(GstreamerPlayerTest);
|
||||
CPPUNIT_TEST(firstTest);
|
||||
CPPUNIT_TEST(simplePlayTest);
|
||||
CPPUNIT_TEST(getPositionTest);
|
||||
CPPUNIT_TEST(setDeviceTest);
|
||||
CPPUNIT_TEST(simpleSmilTest);
|
||||
CPPUNIT_TEST(secondSmilTest);
|
||||
CPPUNIT_TEST(animatedSmilTest);
|
||||
CPPUNIT_TEST(checkErrorConditions);
|
||||
CPPUNIT_TEST(eventListenerAttachTest);
|
||||
CPPUNIT_TEST(eventListenerTest);
|
||||
CPPUNIT_TEST(eventListenerOnStopTest);
|
||||
CPPUNIT_TEST(openTimeTest);
|
||||
CPPUNIT_TEST(pauseResumeTest);
|
||||
CPPUNIT_TEST(openSoundcardTwiceTest);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
*/
|
||||
private:
|
||||
|
||||
/**
|
||||
* The player to use for the tests.
|
||||
*/
|
||||
Ptr<GstreamerPlayer>::Ref player;
|
||||
|
||||
/**
|
||||
* Time how long it takes to open, play, stop and close files.
|
||||
*
|
||||
* @param fileName the name of the file to take a look at.
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
timeSteps(const std::string fileName)
|
||||
throw (CPPUNIT_NS::Exception);
|
||||
|
||||
/**
|
||||
* A flag set to true if onStop() should start playing a new clip.
|
||||
*/
|
||||
bool startNewClipFlag;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* A simple test.
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
firstTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
/**
|
||||
* A simple play test.
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
simplePlayTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
/**
|
||||
* Test the getPosition() function.
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
getPositionTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
/**
|
||||
* Test the setDevice() function, with ALSA and OSS devices.
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
setDeviceTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
/**
|
||||
* Play a simple SMIL file.
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
simpleSmilTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
/**
|
||||
* Play a more complicated SMIL file.
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
secondSmilTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
/**
|
||||
* Play a SMIL file with sound animation.
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
animatedSmilTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
/**
|
||||
* Check for error conditions.
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
checkErrorConditions(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
/**
|
||||
* Test to see if attaching and detaching event listeners works.
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
eventListenerAttachTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
/**
|
||||
* Test to see if the player event listener mechanism works.
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
eventListenerTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
/**
|
||||
* Another, more realistic test of the event listener mechanism.
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
eventListenerOnStopTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
/**
|
||||
* Test how long it takes to open and play files.
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
openTimeTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
/**
|
||||
* Test pausing and resuming.
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
pauseResumeTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
/**
|
||||
* Test for opening the same sound card twice
|
||||
* (thus forcing an error)
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
openSoundcardTwiceTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* A virtual destructor, necessary because of onStop().
|
||||
*/
|
||||
virtual
|
||||
~GstreamerPlayerTest(void) throw ()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up the environment for the test case.
|
||||
*/
|
||||
void
|
||||
setUp(void) throw ();
|
||||
|
||||
/**
|
||||
* Clean up the environment after the test case.
|
||||
*/
|
||||
void
|
||||
tearDown(void) throw ();
|
||||
|
||||
/**
|
||||
* Event handler for the "player has stopped" event.
|
||||
*
|
||||
* @param errorMessage is a 0 pointer if the player stopped normally
|
||||
*/
|
||||
virtual void
|
||||
onStop(Ptr<const Glib::ustring>::Ref errorMessage)
|
||||
throw ();
|
||||
};
|
||||
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
||||
|
||||
/* ====================================================== function prototypes */
|
||||
|
||||
|
||||
} // namespace PlaylistExecutor
|
||||
} // namespace LiveSupport
|
||||
|
||||
#endif // GstreamerPlayerTest_h
|
||||
|
|
@ -1,672 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
|
||||
This file is part of the Campcaster project.
|
||||
http://campcaster.sourcefabric.org/
|
||||
|
||||
Campcaster is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Campcaster is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Campcaster; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef SmilHandler_h
|
||||
#define SmilHandler_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
#endif
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#else
|
||||
#error need string.h
|
||||
#endif
|
||||
|
||||
#include <libxml/parser.h>
|
||||
#include <libxml/tree.h>
|
||||
|
||||
#include <list>
|
||||
|
||||
#define NSEC_PER_SEC 1000000000LL
|
||||
#define SEC_PER_MIN 60
|
||||
#define SEC_PER_HOUR 3600
|
||||
#define NSEC_PER_SEC_FLOAT 1000000000.0
|
||||
#define SEC_PER_MIN_FLOAT 60.0
|
||||
#define SEC_PER_HOUR_FLOAT 3600.0
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
/**
|
||||
* The AnimationDescription class.
|
||||
*
|
||||
* It is assumed that thic class supports only animations that have
|
||||
*
|
||||
* attributeName="soundLevel",
|
||||
* calcMode="linear" and
|
||||
* fill="freeze"
|
||||
*
|
||||
* If these conditions are not met, the entire animate entry in xml will
|
||||
* be ignored and this object will never be created.
|
||||
*/
|
||||
class AnimationDescription {
|
||||
public:
|
||||
double m_from;
|
||||
double m_to;
|
||||
guint64 m_begin;
|
||||
guint64 m_end;
|
||||
|
||||
AnimationDescription():
|
||||
m_from(0.0),
|
||||
m_to(0.0),
|
||||
m_begin(0),
|
||||
m_end(0)
|
||||
{
|
||||
}
|
||||
~AnimationDescription()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The AudioDescription class.
|
||||
*/
|
||||
class AudioDescription {
|
||||
public:
|
||||
gchar *m_src;
|
||||
gint64 m_begin;
|
||||
gint64 m_clipBegin;
|
||||
gint64 m_clipEnd;
|
||||
gint64 m_clipLength;
|
||||
gint64 m_Id;
|
||||
std::vector<AnimationDescription*> m_animations;
|
||||
|
||||
AudioDescription():
|
||||
m_src(NULL),
|
||||
m_begin(0),
|
||||
m_clipBegin(0),
|
||||
m_clipEnd(0),
|
||||
m_clipLength(0),
|
||||
m_Id(0)
|
||||
{
|
||||
}
|
||||
~AudioDescription()
|
||||
{
|
||||
}
|
||||
|
||||
void release()
|
||||
{
|
||||
for(int i = m_animations.size(); i > 0; i--){
|
||||
delete m_animations[i-1];
|
||||
}
|
||||
m_animations.clear();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* A class to parse SMIL file and return playback info in sequence.
|
||||
*
|
||||
* Usage sequence:
|
||||
*
|
||||
* create an instance of GstreamerPlayContext object
|
||||
* call setParentData to provide data to be returned by my_bus_callback
|
||||
* call setAudioDevice on it
|
||||
* call openSource on it
|
||||
* call playContext on it
|
||||
*
|
||||
* when done, call closeContext on it
|
||||
* destroy instance
|
||||
*
|
||||
*/
|
||||
class SmilHandler
|
||||
{
|
||||
xmlDocPtr m_document;
|
||||
xmlNode *m_bodyChildren;
|
||||
xmlNode *m_parChildren;
|
||||
SmilHandler *m_subSmil;
|
||||
gint64 m_smilOffset;
|
||||
|
||||
public:
|
||||
|
||||
SmilHandler(){
|
||||
m_document = NULL;
|
||||
m_bodyChildren = NULL;
|
||||
m_parChildren = NULL;
|
||||
m_subSmil = NULL;
|
||||
m_smilOffset = 0L;
|
||||
}
|
||||
|
||||
~SmilHandler(){
|
||||
xmlCleanupParser();
|
||||
if(m_document != NULL){
|
||||
xmlFreeDoc(m_document);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the sink input as a SMIL file.
|
||||
* The bin container inside the MinimalAudioSmil object will be filled
|
||||
* with gstreamer elements, playing audio as described by the SMIL file.
|
||||
*
|
||||
* @para smil a MinimalAudioSmil object.
|
||||
* @return TRUE if processing was successful, FALSE otherwise.
|
||||
*/
|
||||
gboolean openSmilFile(const gchar *xmlFile, gint64 offset){
|
||||
xmlNode *node;
|
||||
m_smilOffset = offset;
|
||||
|
||||
/* parse the XML files */
|
||||
m_document = xmlReadFile(xmlFile, NULL, XML_PARSE_RECOVER);
|
||||
if (!m_document || !(node = getBodyElement(m_document))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_bodyChildren = node->children;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch next audio entry in sequence.
|
||||
* @return AudioDescription object if processing was successful, NULL otherwise.
|
||||
*/
|
||||
AudioDescription *getNext(){
|
||||
emptysmilrecovery:
|
||||
AudioDescription *audioDescription = NULL;
|
||||
if(m_subSmil != NULL){
|
||||
audioDescription = m_subSmil->getNextInternal();
|
||||
if(audioDescription == NULL){
|
||||
delete m_subSmil;
|
||||
m_subSmil = NULL;
|
||||
}else{
|
||||
gint64 actualLength = audioDescription->m_clipEnd != -1 ?
|
||||
audioDescription->m_clipEnd - audioDescription->m_clipBegin :
|
||||
audioDescription->m_clipLength - audioDescription->m_clipBegin;
|
||||
if(m_smilOffset >= actualLength)
|
||||
{
|
||||
m_smilOffset -= actualLength;
|
||||
goto emptysmilrecovery;
|
||||
}
|
||||
return audioDescription;
|
||||
}
|
||||
}
|
||||
|
||||
if(m_parChildren){//we are currently traversing par segment
|
||||
audioDescription = getNextPar();
|
||||
}
|
||||
|
||||
if(audioDescription == NULL && m_bodyChildren){//par exaused, see if there is more in the body segment
|
||||
for (; m_bodyChildren; m_bodyChildren = m_bodyChildren->next) {
|
||||
if (m_bodyChildren->type == XML_ELEMENT_NODE) {
|
||||
if (!strcmp((const char*)m_bodyChildren->name, "par")) {
|
||||
m_parChildren = m_bodyChildren->children;
|
||||
audioDescription = getNextPar();
|
||||
if(audioDescription != NULL){
|
||||
m_bodyChildren = m_bodyChildren->next;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
GST_WARNING("unsupported SMIL element %s found", m_bodyChildren->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(audioDescription != NULL && std::string(audioDescription->m_src).find(".smil") != std::string::npos){//we have a sub smil
|
||||
m_subSmil = new SmilHandler();
|
||||
m_subSmil->openSmilFile(audioDescription->m_src, m_smilOffset);
|
||||
delete audioDescription;
|
||||
audioDescription = m_subSmil->getNextInternal();
|
||||
if(audioDescription == NULL){
|
||||
delete m_subSmil;
|
||||
m_subSmil = NULL;
|
||||
goto emptysmilrecovery;
|
||||
}
|
||||
}
|
||||
if(audioDescription != NULL)
|
||||
{
|
||||
gint64 actualLength = audioDescription->m_clipEnd != -1 ?
|
||||
audioDescription->m_clipEnd - audioDescription->m_clipBegin :
|
||||
audioDescription->m_clipLength - audioDescription->m_clipBegin;
|
||||
if(m_smilOffset >= actualLength)
|
||||
{
|
||||
m_smilOffset -= actualLength;
|
||||
goto emptysmilrecovery;
|
||||
}
|
||||
}
|
||||
|
||||
return audioDescription;
|
||||
}
|
||||
|
||||
gint64 getClipOffset() {
|
||||
gint64 offset = m_smilOffset;
|
||||
m_smilOffset = 0L;//offset only valid after the first getNext
|
||||
return offset;
|
||||
}
|
||||
|
||||
gint64 getPlayLength() throw() {
|
||||
gint64 ns = 0LL;
|
||||
//TODO: calculate proper playlist length
|
||||
return ns;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* Fetch next audio entry in sequence.
|
||||
* @return AudioDescription object if processing was successful, NULL otherwise.
|
||||
*/
|
||||
AudioDescription *getNextInternal(){
|
||||
emptysmilrecoveryint:
|
||||
AudioDescription *audioDescription = NULL;
|
||||
if(m_subSmil != NULL){
|
||||
audioDescription = m_subSmil->getNextInternal();
|
||||
if(audioDescription == NULL){
|
||||
delete m_subSmil;
|
||||
m_subSmil = NULL;
|
||||
}else{
|
||||
return audioDescription;
|
||||
}
|
||||
}
|
||||
|
||||
if(m_parChildren){//we are currently traversing par segment
|
||||
audioDescription = getNextPar();
|
||||
}
|
||||
|
||||
if(audioDescription == NULL && m_bodyChildren){//par exaused, see if there is more in the body segment
|
||||
for (; m_bodyChildren; m_bodyChildren = m_bodyChildren->next) {
|
||||
if (m_bodyChildren->type == XML_ELEMENT_NODE) {
|
||||
if (!strcmp((const char*)m_bodyChildren->name, "par")) {
|
||||
m_parChildren = m_bodyChildren->children;
|
||||
audioDescription = getNextPar();
|
||||
if(audioDescription != NULL){
|
||||
m_bodyChildren = m_bodyChildren->next;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
GST_WARNING("unsupported SMIL element %s found", m_bodyChildren->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(audioDescription != NULL && std::string(audioDescription->m_src).find(".smil") != std::string::npos){//we have a sub smil
|
||||
m_subSmil = new SmilHandler();
|
||||
m_subSmil->openSmilFile(audioDescription->m_src, m_smilOffset);
|
||||
delete audioDescription;
|
||||
audioDescription = m_subSmil->getNextInternal();
|
||||
if(audioDescription == NULL){
|
||||
delete m_subSmil;
|
||||
m_subSmil = NULL;
|
||||
goto emptysmilrecoveryint;
|
||||
}
|
||||
}
|
||||
|
||||
return audioDescription;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch next audio entry from "<par>" SMIL segment.
|
||||
*
|
||||
* @return AudioDescription object if processing was successful, NULL otherwise..
|
||||
*/
|
||||
AudioDescription *getNextPar(){
|
||||
AudioDescription *audioDescription = NULL;
|
||||
for (; m_parChildren; m_parChildren = m_parChildren->next) {
|
||||
if (m_parChildren->type == XML_ELEMENT_NODE) {
|
||||
if (!strcmp((const char*)m_parChildren->name, "audio")) {
|
||||
audioDescription = getNextAudio(m_parChildren);
|
||||
if(audioDescription != NULL){
|
||||
m_parChildren = m_parChildren->next;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
GST_WARNING("unsupported SMIL element %s found inside a par", m_parChildren->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
return audioDescription;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch next audio entry from "<audio>" SMIL segment.
|
||||
*
|
||||
* @param audio an "<audio>" SMIL element.
|
||||
* @return AudioDescription object if processing was successful, NULL otherwise..
|
||||
*/
|
||||
AudioDescription *getNextAudio(xmlNode *audio){
|
||||
AudioDescription *audioDescription = NULL;
|
||||
|
||||
xmlNode * node;
|
||||
xmlAttribute * attr;
|
||||
gchar * src = 0;
|
||||
gchar * begin = 0;
|
||||
gchar * clipBegin = 0;
|
||||
gchar * clipEnd = 0;
|
||||
gchar * clipLength = 0;
|
||||
gchar * idStr = 0;
|
||||
|
||||
/* handle the attributes */
|
||||
for (attr = ((xmlElement*)audio)->attributes; attr; attr = (xmlAttribute*) attr->next) {
|
||||
/* TODO: support attribute values that are represented with
|
||||
* more than one text node, in all content assignments below */
|
||||
if (!strcmp((const char*)attr->name, "src")) {
|
||||
if ((node = attr->children) && node->type == XML_TEXT_NODE) {
|
||||
src = (gchar*) node->content;
|
||||
}
|
||||
} else if (!strcmp((const char*)attr->name, "id")) {
|
||||
if ((node = attr->children) && node->type == XML_TEXT_NODE) {
|
||||
idStr = (gchar*) node->content;
|
||||
}
|
||||
} else if (!strcmp((const char*)attr->name, "begin")) {
|
||||
if ((node = attr->children) && node->type == XML_TEXT_NODE) {
|
||||
begin = (gchar*) node->content;
|
||||
}
|
||||
} else if (!strcmp((const char*)attr->name, "clipBegin")) {
|
||||
if ((node = attr->children) && node->type == XML_TEXT_NODE) {
|
||||
clipBegin = (gchar*) node->content;
|
||||
}
|
||||
} else if (!strcmp((const char*)attr->name, "clipEnd")) {
|
||||
if ((node = attr->children) && node->type == XML_TEXT_NODE) {
|
||||
clipEnd = (gchar*) node->content;
|
||||
}
|
||||
} else if (!strcmp((const char*)attr->name, "clipLength")) {
|
||||
if ((node = attr->children) && node->type == XML_TEXT_NODE) {
|
||||
clipLength = (gchar*) node->content;
|
||||
}
|
||||
} else {
|
||||
GST_WARNING("unsupported SMIL audio element attribute: %s",
|
||||
attr->name);
|
||||
}
|
||||
}
|
||||
|
||||
audioDescription = new AudioDescription();
|
||||
if(begin)
|
||||
{
|
||||
audioDescription->m_begin = su_smil_clock_value_to_nanosec(begin);
|
||||
}
|
||||
if(clipBegin)
|
||||
{
|
||||
audioDescription->m_clipBegin = su_smil_clock_value_to_nanosec(clipBegin);
|
||||
}
|
||||
if(clipEnd)
|
||||
{
|
||||
audioDescription->m_clipEnd = su_smil_clock_value_to_nanosec(clipEnd);
|
||||
if(audioDescription->m_clipEnd <= 0)//clip end can never be 0, force it to -1
|
||||
{
|
||||
audioDescription->m_clipEnd = -1;
|
||||
}
|
||||
}
|
||||
if(clipLength)
|
||||
{
|
||||
audioDescription->m_clipLength = su_smil_clock_value_to_nanosec(clipLength);
|
||||
}
|
||||
if(idStr)
|
||||
{
|
||||
std::stringstream idReader(idStr);
|
||||
idReader >> audioDescription->m_Id;
|
||||
}
|
||||
audioDescription->m_src = src;
|
||||
// now handle the possible animate elements inside this audio element
|
||||
for (node = audio->children; node; node = node->next) {
|
||||
if (node->type == XML_ELEMENT_NODE) {
|
||||
if (!strcmp((const char*)node->name, "animate")) {
|
||||
AnimationDescription *anim = getNextAnimate(audioDescription->m_begin, node);
|
||||
if(anim != NULL){
|
||||
audioDescription->m_animations.push_back(anim);
|
||||
}
|
||||
} else {
|
||||
GST_WARNING("unsupported SMIL element %s found inside a audio", node->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
return audioDescription;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an "<animate>" element.
|
||||
*
|
||||
* @param offset the offset in nanoseconds that the animation should
|
||||
* begin at. this is usually the begin="xx" attribute value
|
||||
* of the containing element.
|
||||
* @param animate the "<animate>" element to handle.
|
||||
* @return AnimationDescription object if processing was successful, NULL otherwise..
|
||||
*/
|
||||
AnimationDescription *getNextAnimate(gint64 offset, xmlNode *animate){
|
||||
xmlAttribute * attr;
|
||||
double from = 0.0;
|
||||
double to = 0.0;
|
||||
guint64 begin = 0;
|
||||
guint64 end = 0;
|
||||
|
||||
/* handle the attributes */
|
||||
for (attr = ((xmlElement*)animate)->attributes; attr; attr = (xmlAttribute*) attr->next) {
|
||||
|
||||
xmlNode * node;
|
||||
|
||||
/* TODO: support attribute values that are represented with
|
||||
* more than one text node, in all content assignments below */
|
||||
if (!strcmp((const char*)attr->name, "attributeName")) {
|
||||
if ((node = attr->children) && node->type == XML_TEXT_NODE) {
|
||||
gchar* cstr = (gchar*) node->content;
|
||||
/* we only support soundLevel animation at the moment */
|
||||
if (strcmp(cstr, "soundLevel")) {
|
||||
GST_WARNING("unsupported animate attribute: %s", cstr);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
} else if (!strcmp((const char*)attr->name, "calcMode")) {
|
||||
if ((node = attr->children) && node->type == XML_TEXT_NODE) {
|
||||
gchar* cstr = (gchar*) node->content;
|
||||
/* we only support linear calc mode at the moment */
|
||||
if (strcmp(cstr, "linear")) {
|
||||
GST_WARNING("unsupported animate calcMode: %s", cstr);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
} else if (!strcmp((const char*)attr->name, "fill")) {
|
||||
if ((node = attr->children) && node->type == XML_TEXT_NODE) {
|
||||
gchar* cstr = (gchar*) node->content;
|
||||
/* we only support freeze fill at the moment */
|
||||
if (strcmp(cstr, "freeze")) {
|
||||
GST_WARNING("unsupported animate fill: %s", cstr);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
} else if (!strcmp((const char*)attr->name, "from")) {
|
||||
if ((node = attr->children) && node->type == XML_TEXT_NODE) {
|
||||
gchar* cstr = (gchar*) node->content;
|
||||
if (!su_smil_parse_percent(cstr, &from)) {
|
||||
GST_WARNING("bad from value: %s", cstr);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
} else if (!strcmp((const char*)attr->name, "to")) {
|
||||
if ((node = attr->children) && node->type == XML_TEXT_NODE) {
|
||||
gchar* cstr = (gchar*) node->content;
|
||||
if (!su_smil_parse_percent(cstr, &to)) {
|
||||
GST_WARNING("bad to value: %s", cstr);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
} else if (!strcmp((const char*)attr->name, "begin")) {
|
||||
if ((node = attr->children) && node->type == XML_TEXT_NODE) {
|
||||
gint64 i;
|
||||
gchar* cstr = (gchar*) node->content;
|
||||
begin = su_smil_clock_value_to_nanosec(cstr);// + offset;
|
||||
// begin = ((double) i) / NSEC_PER_SEC_FLOAT;
|
||||
}
|
||||
} else if (!strcmp((const char*)attr->name, "end")) {
|
||||
if ((node = attr->children) && node->type == XML_TEXT_NODE) {
|
||||
gint64 i;
|
||||
gchar* cstr = (gchar*) node->content;
|
||||
end = su_smil_clock_value_to_nanosec(cstr);// + offset;
|
||||
// end = ((double) i) / NSEC_PER_SEC_FLOAT;
|
||||
}
|
||||
} else {
|
||||
GST_WARNING("unsupported SMIL audio element attribute: %s",
|
||||
attr->name);
|
||||
}
|
||||
}
|
||||
|
||||
if (from == 0.0 && to == 0.0 && begin == 0.0 && end == 0.0) {
|
||||
GST_WARNING("some required animate attribute missing");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (begin >= end) {
|
||||
GST_WARNING("begin value in animate greater than end value");
|
||||
return 0;
|
||||
}
|
||||
AnimationDescription *animDesc = new AnimationDescription();
|
||||
animDesc->m_from = from;
|
||||
animDesc->m_to = to;
|
||||
animDesc->m_begin = begin;
|
||||
animDesc->m_end = end;
|
||||
return animDesc;
|
||||
}
|
||||
|
||||
xmlNode *getBodyElement(xmlDocPtr document){
|
||||
xmlNode * node = document->children;
|
||||
if (!node || strcmp((const char*)node->name, "smil")) {
|
||||
return 0;
|
||||
}
|
||||
for (node = node->children; node; node = node->next) {
|
||||
if (node->type == XML_ELEMENT_NODE
|
||||
&& !strcmp((const char*)node->name, "body")) {
|
||||
return node;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*------------------------------------------------------------------------------
|
||||
* Convert a hour-minute-second triplet to nanoseconds
|
||||
*----------------------------------------------------------------------------*/
|
||||
static gint64
|
||||
su_hms_to_nanosec(int hours,
|
||||
int minutes,
|
||||
double seconds)
|
||||
{
|
||||
gint64 nanosec;
|
||||
double nsec;
|
||||
|
||||
nsec = seconds * NSEC_PER_SEC_FLOAT;
|
||||
|
||||
nanosec = (gint64) nsec;
|
||||
nanosec += ((gint64) hours) * NSEC_PER_SEC;
|
||||
nanosec += ((gint64) minutes) * SEC_PER_MIN * NSEC_PER_SEC;
|
||||
|
||||
return nanosec;
|
||||
}
|
||||
/**
|
||||
* Parse the clock value according to the SMIL clock spec
|
||||
*
|
||||
* see http://www.w3.org/TR/2005/REC-SMIL2-20050107/smil-timing.html#Timing-ClockValueSyntax
|
||||
*
|
||||
* the BNF for the value is:
|
||||
*
|
||||
* <pre><code>
|
||||
* Clock-value ::= ( Full-clock-value | Partial-clock-value
|
||||
* | Timecount-value )
|
||||
* Full-clock-value ::= Hours ":" Minutes ":" Seconds ("." Fraction)?
|
||||
* Partial-clock-value ::= Minutes ":" Seconds ("." Fraction)?
|
||||
* Timecount-value ::= Timecount ("." Fraction)? (Metric)?
|
||||
* Metric ::= "h" | "min" | "s" | "ms"
|
||||
* Hours ::= DIGIT+; any positive number
|
||||
* Minutes ::= 2DIGIT; range from 00 to 59
|
||||
* Seconds ::= 2DIGIT; range from 00 to 59
|
||||
* Fraction ::= DIGIT+
|
||||
* Timecount ::= DIGIT+
|
||||
* 2DIGIT ::= DIGIT DIGIT
|
||||
* DIGIT ::= [0-9]
|
||||
* </code></pre>
|
||||
*
|
||||
* @param value the SMIL clock value in string form
|
||||
* @return the clock value in nanoseconds
|
||||
*/
|
||||
guint64
|
||||
su_smil_clock_value_to_nanosec(const gchar * value)
|
||||
{
|
||||
int hours;
|
||||
int minutes;
|
||||
double seconds;
|
||||
|
||||
/* see if it's a full-clock-value */
|
||||
if (sscanf(value, "%2d:%2d:%lf", &hours, &minutes, &seconds) == 3) {
|
||||
return su_hms_to_nanosec(hours, minutes, seconds);
|
||||
}
|
||||
|
||||
/* see if it's a partial-clock-value */
|
||||
if (sscanf(value, "%2d:%lf", &minutes, &seconds) == 2) {
|
||||
return su_hms_to_nanosec(0, minutes, seconds);
|
||||
}
|
||||
|
||||
/* see if it's a timecount-value, in hours */
|
||||
if (g_str_has_suffix(value, "h")
|
||||
&& sscanf(value, "%lfh", &seconds) == 1) {
|
||||
return su_hms_to_nanosec(0, 0, seconds * SEC_PER_HOUR_FLOAT);
|
||||
}
|
||||
|
||||
/* see if it's a timecount-value, in minutes */
|
||||
if (g_str_has_suffix(value, "min")
|
||||
&& sscanf(value, "%lfmin", &seconds) == 1) {
|
||||
return su_hms_to_nanosec(0, 0, seconds * SEC_PER_MIN_FLOAT);
|
||||
}
|
||||
|
||||
/* see if it's a timecount-value, in millisecs */
|
||||
if (g_str_has_suffix(value, "ms")
|
||||
&& sscanf(value, "%lfms", &seconds) == 1) {
|
||||
return su_hms_to_nanosec(0, 0, seconds / 100.0);
|
||||
}
|
||||
|
||||
/* it's a timecount-value, either with no metric, or explicit seconds */
|
||||
if (sscanf(value, "%lfs", &seconds) == 1) {
|
||||
return su_hms_to_nanosec(0, 0, seconds);
|
||||
}
|
||||
|
||||
return -1LL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Parse a string as a percentage value, and return the result as a
|
||||
* float. Indicate parse error.
|
||||
*
|
||||
* @param str the string to parse.
|
||||
* @param value the parsed value (out parameter).
|
||||
* @return TRUE if parsing went OK, FALSE otherwise.
|
||||
*/
|
||||
gboolean
|
||||
su_smil_parse_percent(const gchar * str,
|
||||
double * value)
|
||||
{
|
||||
double val;
|
||||
|
||||
if (g_str_has_suffix(str, "%")
|
||||
&& sscanf(str, "%lf%%", &val) == 1) {
|
||||
*value = val / 100.0;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // SmilHandler_h
|
||||
|
|
@ -1,109 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
|
||||
This file is part of the Campcaster project.
|
||||
http://campcaster.sourcefabric.org/
|
||||
|
||||
Campcaster is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Campcaster is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Campcaster; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef TestEventListener_h
|
||||
#define TestEventListener_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
#endif
|
||||
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include "LiveSupport/PlaylistExecutor/AudioPlayerEventListener.h"
|
||||
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace PlaylistExecutor {
|
||||
|
||||
using namespace boost;
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
||||
/* =================================================================== macros */
|
||||
|
||||
|
||||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* A simple event listener, used for testing.
|
||||
*/
|
||||
class TestEventListener : public AudioPlayerEventListener
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* A flag set by the onStop() event to true.
|
||||
*/
|
||||
bool stopFlag;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
TestEventListener(void) throw ()
|
||||
{
|
||||
stopFlag = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* A virtual destructor, as this class has virtual functions.
|
||||
*/
|
||||
virtual
|
||||
~TestEventListener(void) throw ()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Catch the event when playing has stopped.
|
||||
* This will happen probably due to the fact that the
|
||||
* audio clip has been played to its end.
|
||||
*
|
||||
* @param errorMessage is a 0 pointer if the player stopped normally
|
||||
*/
|
||||
virtual void
|
||||
onStop(Ptr<const Glib::ustring>::Ref errorMessage)
|
||||
throw ()
|
||||
{
|
||||
stopFlag = true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
||||
|
||||
/* ====================================================== function prototypes */
|
||||
|
||||
|
||||
} // namespace PlaylistExecutor
|
||||
} // namespace LiveSupport
|
||||
|
||||
|
||||
#endif // TestEventListener_h
|
||||
|
|
@ -1,575 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
|
||||
This file is part of the Campcaster project.
|
||||
http://campcaster.sourcefabric.org/
|
||||
|
||||
Campcaster is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Campcaster is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Campcaster; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#else
|
||||
#error "Need unistd.h"
|
||||
#endif
|
||||
|
||||
#if HAVE_GETOPT_H
|
||||
#include <getopt.h>
|
||||
#else
|
||||
#error "Need getopt.h"
|
||||
#endif
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include <gst/controller/gstcontroller.h>
|
||||
#include <gst/controller/gstinterpolationcontrolsource.h>
|
||||
|
||||
|
||||
#include <cppunit/BriefTestProgressListener.h>
|
||||
#include <cppunit/CompilerOutputter.h>
|
||||
#include <cppunit/XmlOutputter.h>
|
||||
#include <cppunit/extensions/TestFactoryRegistry.h>
|
||||
#include <cppunit/TestResult.h>
|
||||
#include <cppunit/TestResultCollector.h>
|
||||
#include <cppunit/TestRunner.h>
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
|
||||
#include "GstreamerPlayContext.h"
|
||||
#include "SmilHandler.h"
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
/**
|
||||
* Our copyright notice, should be at most 80 columns
|
||||
*/
|
||||
static const char copyrightNotice[] =
|
||||
"Copyright (c) 2010 Sourcefabric O.P.S. under the GNU GPL";
|
||||
|
||||
/**
|
||||
* String describing the short options.
|
||||
*/
|
||||
static const char options[] = "ho:s:v";
|
||||
|
||||
/**
|
||||
* Structure describing the long options
|
||||
*/
|
||||
static const struct option longOptions[] = {
|
||||
{ "help", no_argument, 0, 'h' },
|
||||
{ "output", required_argument, 0, 'o' },
|
||||
{ "stylesheet", required_argument, 0, 's' },
|
||||
{ "version", no_argument, 0, 'v' },
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
/**
|
||||
* The encoding to use for the output file.
|
||||
*/
|
||||
static const std::string encoding = "utf-8";
|
||||
|
||||
/**
|
||||
* The output XML file name.
|
||||
*/
|
||||
static Ptr<std::string>::Ref xmlOutFileName;
|
||||
|
||||
/**
|
||||
* The XSLT attached to the output file.
|
||||
*/
|
||||
static Ptr<std::string>::Ref xsltFileName;
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
/**
|
||||
* Print program version.
|
||||
*
|
||||
* @param os the std::ostream to print to.
|
||||
*/
|
||||
static void
|
||||
printVersion ( std::ostream & os );
|
||||
|
||||
/**
|
||||
* Print program usage information.
|
||||
*
|
||||
* @param invocation the command line command used to invoke this program.
|
||||
* @param os the std::ostream to print to.
|
||||
*/
|
||||
static void
|
||||
printUsage ( const char invocation[],
|
||||
std::ostream & os );
|
||||
|
||||
/**
|
||||
* Process command line arguments.
|
||||
*
|
||||
* @param argc the number of arguments.
|
||||
* @param argv the arguments themselves.
|
||||
* @return true of all went well, false in case the program should exit
|
||||
* after this call.
|
||||
*/
|
||||
static bool
|
||||
processArguments(int argc, char *argv[]);
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Run all tests
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
static GMainLoop *loop;
|
||||
static GstElement *play=NULL;
|
||||
|
||||
|
||||
static GstreamerPlayContext *pContext=NULL;
|
||||
static GstreamerPlayContext *pContextNext=NULL;
|
||||
|
||||
static SmilHandler *smil = NULL;
|
||||
|
||||
|
||||
static int cnt=0;
|
||||
|
||||
static gboolean
|
||||
my_bus_callback (GstBus *bus,
|
||||
GstMessage *message,
|
||||
gpointer data)
|
||||
{
|
||||
g_print ("Got %s message\n", GST_MESSAGE_TYPE_NAME (message));
|
||||
|
||||
switch (GST_MESSAGE_TYPE (message)) {
|
||||
case GST_MESSAGE_ERROR: {
|
||||
GError *err;
|
||||
gchar *debug;
|
||||
|
||||
gst_message_parse_error (message, &err, &debug);
|
||||
g_print ("Error: %s\n", err->message);
|
||||
g_error_free (err);
|
||||
g_free (debug);
|
||||
|
||||
g_main_loop_quit (loop);
|
||||
break;
|
||||
}
|
||||
case GST_MESSAGE_EOS:
|
||||
if(cnt<0){
|
||||
// if(cnt<5){
|
||||
char tmp[255]={0};
|
||||
sprintf(tmp, "file:///tmp/campcaster/%d.ogg", cnt+1);//use when file name needed
|
||||
if(pContext){
|
||||
pContext->closeContext();
|
||||
delete pContext;
|
||||
pContext = NULL;
|
||||
}
|
||||
|
||||
/* if(pContextNext){
|
||||
pContext=pContextNext;
|
||||
pContextNext=new GstreamerPlayContext(tmp);
|
||||
}
|
||||
*/
|
||||
|
||||
pContext=new GstreamerPlayContext();
|
||||
// pContext->setAudioDevice("default");
|
||||
pContext->openSource(tmp);
|
||||
|
||||
|
||||
|
||||
if(pContext){
|
||||
pContext->playContext();
|
||||
}
|
||||
|
||||
cnt++;
|
||||
}else if(smil != NULL){
|
||||
pContext->closeContext();
|
||||
AudioDescription *audioDescription = smil->getNext();
|
||||
if(audioDescription == NULL){//no more audio entries to play
|
||||
delete smil;
|
||||
smil = NULL;
|
||||
delete pContext;
|
||||
g_main_loop_quit (loop);
|
||||
break;
|
||||
}
|
||||
pContext->openSource(audioDescription);
|
||||
pContext->playContext();
|
||||
}else{
|
||||
if(pContext){
|
||||
pContext->closeContext();
|
||||
delete pContext;
|
||||
pContext = NULL;
|
||||
}
|
||||
g_main_loop_quit (loop);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
//we want to be notified again the next time there is a message
|
||||
//on the bus, so returning TRUE (FALSE means we want to stop watching
|
||||
//for messages on the bus and our callback should not be called again)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main( int argc,
|
||||
char * argv[] ) throw ()
|
||||
{
|
||||
// sleep(10);//hook for debugging, allows time to attach kdbg
|
||||
|
||||
/*
|
||||
gint res = 1;
|
||||
GstElement *src, *sink;
|
||||
GstElement *bin;
|
||||
GstController *ctrl;
|
||||
GstInterpolationControlSource *csource1;//, *csource2;
|
||||
GstClock *clock;
|
||||
GstClockID clock_id;
|
||||
GstClockReturn wait_ret;
|
||||
GValue vol = { 0, };
|
||||
|
||||
gst_init (&argc, &argv);
|
||||
gst_controller_init (&argc, &argv);
|
||||
|
||||
// build pipeline
|
||||
bin = gst_pipeline_new ("pipeline");
|
||||
clock = gst_pipeline_get_clock (GST_PIPELINE (bin));
|
||||
src = gst_element_factory_make ("audiotestsrc", "gen_audio");
|
||||
// src = gst_element_make_from_uri (GST_URI_SRC, "file:///tmp/campcaster/login.ogg", NULL);
|
||||
sink = gst_element_factory_make ("alsasink", "play_audio");
|
||||
gst_bin_add_many (GST_BIN (bin), src, sink, NULL);
|
||||
if (!gst_element_link (src, sink)) {
|
||||
GST_WARNING ("can't link elements");
|
||||
goto Error;
|
||||
}
|
||||
|
||||
// square wave
|
||||
// g_object_set (G_OBJECT(src), "wave", 1, NULL);
|
||||
|
||||
// add a controller to the source
|
||||
// if (!(ctrl = gst_controller_new (G_OBJECT (src), "freq", "volume", NULL))) {
|
||||
if (!(ctrl = gst_controller_new (G_OBJECT (src), "volume", NULL))) {
|
||||
GST_WARNING ("can't control source element");
|
||||
goto Error;
|
||||
}
|
||||
|
||||
csource1 = gst_interpolation_control_source_new ();
|
||||
// csource2 = gst_interpolation_control_source_new ();
|
||||
|
||||
gst_controller_set_control_source (ctrl, "volume", GST_CONTROL_SOURCE (csource1));
|
||||
// gst_controller_set_control_source (ctrl, "freq", GST_CONTROL_SOURCE (csource2));
|
||||
|
||||
// Set interpolation mode
|
||||
|
||||
gst_interpolation_control_source_set_interpolation_mode (csource1, GST_INTERPOLATE_LINEAR);
|
||||
// gst_interpolation_control_source_set_interpolation_mode (csource2, GST_INTERPOLATE_LINEAR);
|
||||
|
||||
// set control values
|
||||
g_value_init (&vol, G_TYPE_DOUBLE);
|
||||
|
||||
g_value_set_double (&vol, 0.0);
|
||||
gst_interpolation_control_source_set (csource1, 0 * GST_SECOND, &vol);
|
||||
g_value_set_double (&vol, 1.0);
|
||||
gst_interpolation_control_source_set (csource1, 1 * GST_SECOND, &vol);
|
||||
|
||||
g_value_set_double (&vol, 1.0);
|
||||
gst_interpolation_control_source_set (csource1, 2 * GST_SECOND, &vol);
|
||||
g_value_set_double (&vol, 0.0);
|
||||
gst_interpolation_control_source_set (csource1, 3 * GST_SECOND, &vol);
|
||||
|
||||
g_object_unref (csource1);
|
||||
|
||||
// g_value_set_double (&vol, 220.0);
|
||||
// gst_interpolation_control_source_set (csource2, 0 * GST_SECOND, &vol);
|
||||
// g_value_set_double (&vol, 3520.0);
|
||||
// gst_interpolation_control_source_set (csource2, 3 * GST_SECOND, &vol);
|
||||
// g_value_set_double (&vol, 440.0);
|
||||
// gst_interpolation_control_source_set (csource2, 6 * GST_SECOND, &vol);
|
||||
//
|
||||
// g_object_unref (csource2);
|
||||
|
||||
clock_id =
|
||||
gst_clock_new_single_shot_id (clock,
|
||||
gst_clock_get_time (clock) + (6 * GST_SECOND));
|
||||
|
||||
// run for 7 seconds
|
||||
if (gst_element_set_state (bin, GST_STATE_PLAYING)) {
|
||||
if ((wait_ret = gst_clock_id_wait (clock_id, NULL)) != GST_CLOCK_OK) {
|
||||
GST_WARNING ("clock_id_wait returned: %d", wait_ret);
|
||||
}
|
||||
gst_element_set_state (bin, GST_STATE_NULL);
|
||||
}
|
||||
|
||||
// cleanup
|
||||
g_object_unref (G_OBJECT (ctrl));
|
||||
gst_object_unref (G_OBJECT (clock));
|
||||
gst_object_unref (G_OBJECT (bin));
|
||||
res = 0;
|
||||
Error:
|
||||
return (res);
|
||||
*/
|
||||
/*
|
||||
//quick gnonlin playback test
|
||||
gst_init (NULL, NULL);
|
||||
loop = g_main_loop_new (NULL, FALSE);
|
||||
|
||||
|
||||
GstElement *composition = gst_element_factory_make("gnlcomposition", NULL);
|
||||
// GstElement *silentGnlSource = gst_element_factory_make("gnlsource", NULL);
|
||||
// GstElement *silenceAudioSource = gst_element_factory_make("audiotestsrc", NULL);
|
||||
|
||||
GstElement *volumeFadeBin = gst_element_factory_make("bin", "Volume_fades_bin");
|
||||
GstElement *volumeFadeElement = gst_element_factory_make("volume", "Volume_Fade_Element");
|
||||
GstElement *volumeFadeStartConvert = gst_element_factory_make("audioconvert", "Start_fadebin_converter");
|
||||
GstElement *volumeFadeEndConvert = gst_element_factory_make("audioconvert", "End_fadebin_converter");
|
||||
GstElement *volumeFadeOperation = gst_element_factory_make("gnloperation", "gnloperation");
|
||||
GstController *volumeFadeController = gst_controller_new(G_OBJECT(volumeFadeElement), "volume");
|
||||
|
||||
gst_bin_add(GST_BIN(volumeFadeBin), volumeFadeElement);
|
||||
gst_bin_add(GST_BIN(volumeFadeBin), volumeFadeStartConvert);
|
||||
gst_bin_add(GST_BIN(volumeFadeBin), volumeFadeEndConvert);
|
||||
GstPad *volumeFadeBinSink = gst_ghost_pad_new("sink", gst_element_get_pad(volumeFadeStartConvert, "sink"));
|
||||
gst_element_add_pad(volumeFadeBin, volumeFadeBinSink);
|
||||
GstPad *volumeFadeBinSrc = gst_ghost_pad_new("src", gst_element_get_pad(volumeFadeEndConvert, "src"));
|
||||
gst_element_add_pad(volumeFadeBin, volumeFadeBinSrc);
|
||||
|
||||
// g_object_set(G_OBJECT(silenceAudioSource), "wave", 4, NULL); //4 is silence
|
||||
|
||||
// g_object_set(G_OBJECT(silentGnlSource), "priority", (2 ^ 32 - 1), NULL);
|
||||
// g_object_set(G_OBJECT(silentGnlSource), "start", 0, NULL);
|
||||
// g_object_set(G_OBJECT(silentGnlSource), "duration", 1000 * GST_SECOND, NULL);
|
||||
// g_object_set(G_OBJECT(silentGnlSource), "media-start", 0, NULL);
|
||||
// g_object_set(G_OBJECT(silentGnlSource), "media-duration", 1000 * GST_SECOND, NULL);
|
||||
|
||||
g_object_set(G_OBJECT(volumeFadeOperation), "start", long(0) * GST_SECOND, NULL);
|
||||
g_object_set(G_OBJECT(volumeFadeOperation), "duration", long(20) * GST_SECOND, NULL);
|
||||
g_object_set(G_OBJECT(volumeFadeOperation), "priority", 1, NULL);
|
||||
|
||||
gst_controller_set_interpolation_mode(volumeFadeController, "volume", GST_INTERPOLATE_LINEAR);
|
||||
|
||||
gst_bin_add(GST_BIN(volumeFadeOperation), volumeFadeBin);
|
||||
// gst_bin_add(GST_BIN(silentGnlSource), silenceAudioSource);
|
||||
// gst_bin_add(GST_BIN(composition), silentGnlSource);
|
||||
gst_bin_add(GST_BIN(composition), volumeFadeOperation);//this is where we hook up to the rest of the pipeline
|
||||
|
||||
gst_element_link(volumeFadeStartConvert, volumeFadeElement);
|
||||
gst_element_link(volumeFadeElement, volumeFadeEndConvert);
|
||||
|
||||
|
||||
g_main_loop_run (loop);
|
||||
|
||||
return 0;
|
||||
*/
|
||||
|
||||
//quick smil playback test
|
||||
gst_init (NULL, NULL);
|
||||
loop = g_main_loop_new (NULL, FALSE);
|
||||
//quick test for smil parser
|
||||
smil = new SmilHandler();
|
||||
smil->openSmilFile("file:///tmp/campcaster/animatedSmil.smil");
|
||||
|
||||
pContext=new GstreamerPlayContext();
|
||||
pContext->setParentData((gpointer)pContext);
|
||||
|
||||
AudioDescription *audDesc = smil->getNext();
|
||||
pContext->openSource(audDesc);
|
||||
pContext->playContext();
|
||||
|
||||
g_main_loop_run (loop);
|
||||
|
||||
return 0;
|
||||
|
||||
/*
|
||||
//quick test for play context
|
||||
gst_init (NULL, NULL);
|
||||
loop = g_main_loop_new (NULL, FALSE);
|
||||
|
||||
pContext=new GstreamerPlayContext();
|
||||
pContext->setParentData((gpointer)pContext);
|
||||
// pContext->setAudioDevice("default");
|
||||
// pContext->openSource("file:///tmp/campcaster/login.ogg");
|
||||
pContext->openSource("file:///tmp/campcaster/introduction.ogg");
|
||||
// pContext->openSource("file:///tmp/campcaster/starter.ogg");
|
||||
|
||||
// pContext->openSource("http://www.sicksiteradio.com/contents/radio_shows/sicksiteradio57.mp3");
|
||||
|
||||
// pContext->openSource("file:///tmp/campcaster/test-short.mp3");
|
||||
// pContextNext=new GstreamerPlayContext("file:///tmp/campcaster/test.mp3");
|
||||
// cnt++;
|
||||
pContext->playContext();
|
||||
|
||||
|
||||
g_main_loop_run (loop);
|
||||
|
||||
if(pContext){
|
||||
pContext->closeContext();
|
||||
delete pContext;
|
||||
}
|
||||
|
||||
return 0; // initialize the gst parameters
|
||||
*/
|
||||
/*
|
||||
gst_init(&argc, &argv);
|
||||
|
||||
if (!processArguments(argc, argv)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Create the event manager and test controller
|
||||
CPPUNIT_NS::TestResult controller;
|
||||
|
||||
// Add a listener that colllects test result
|
||||
CPPUNIT_NS::TestResultCollector result;
|
||||
controller.addListener( &result );
|
||||
|
||||
// Add a listener that print dots as test run.
|
||||
CPPUNIT_NS::BriefTestProgressListener progress;
|
||||
controller.addListener( &progress );
|
||||
|
||||
// Add the top suite to the test runner
|
||||
CPPUNIT_NS::TestRunner runner;
|
||||
runner.addTest( CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest() );
|
||||
runner.run( controller );
|
||||
|
||||
// Print test in a compiler compatible format.
|
||||
CPPUNIT_NS::CompilerOutputter outputter( &result, std::cerr );
|
||||
outputter.setLocationFormat("%p:%l:");
|
||||
outputter.write();
|
||||
|
||||
// also generate an XML document as an output
|
||||
std::ofstream xmlOutFile(xmlOutFileName->c_str());
|
||||
CPPUNIT_NS::XmlOutputter xmlOutputter(&result, xmlOutFile, encoding);
|
||||
xmlOutputter.setStandalone(false);
|
||||
if (xsltFileName) {
|
||||
xmlOutputter.setStyleSheet(*xsltFileName);
|
||||
}
|
||||
xmlOutputter.write();
|
||||
xmlOutFile.flush();
|
||||
xmlOutFile.close();
|
||||
|
||||
return result.wasSuccessful() ? 0 : 1;
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Process command line arguments.
|
||||
*----------------------------------------------------------------------------*/
|
||||
static bool
|
||||
processArguments(int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
|
||||
while ((i = getopt_long(argc, argv, options, longOptions, 0)) != -1) {
|
||||
switch (i) {
|
||||
case 'h':
|
||||
printUsage(argv[0], std::cout);
|
||||
return false;
|
||||
|
||||
case 'o':
|
||||
xmlOutFileName.reset(new std::string(optarg));
|
||||
break;
|
||||
|
||||
case 's':
|
||||
xsltFileName.reset(new std::string(optarg));
|
||||
break;
|
||||
|
||||
case 'v':
|
||||
printVersion(std::cout);
|
||||
return false;
|
||||
|
||||
default:
|
||||
printUsage(argv[0], std::cout);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (optind < argc) {
|
||||
std::cerr << "error processing command line arguments" << std::endl;
|
||||
printUsage(argv[0], std::cout);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!xmlOutFileName) {
|
||||
std::cerr << "mandatory option output file name not specified"
|
||||
<< std::endl;
|
||||
printUsage(argv[0], std::cout);
|
||||
return false;
|
||||
}
|
||||
|
||||
std::cerr << "writing output to '" << *xmlOutFileName << '\'' << std::endl;
|
||||
if (xsltFileName) {
|
||||
std::cerr << "using XSLT file '" << *xsltFileName << '\'' << std::endl;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Print program version.
|
||||
*----------------------------------------------------------------------------*/
|
||||
static void
|
||||
printVersion ( std::ostream & os )
|
||||
{
|
||||
os << PACKAGE_NAME << ' ' << PACKAGE_VERSION << std::endl
|
||||
<< "Unit test runner" << std::endl
|
||||
<< copyrightNotice << std::endl;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Print program usage.
|
||||
*----------------------------------------------------------------------------*/
|
||||
static void
|
||||
printUsage ( const char invocation[],
|
||||
std::ostream & os )
|
||||
{
|
||||
os << PACKAGE_NAME << ' ' << PACKAGE_VERSION << std::endl
|
||||
<< "Unit test runner" << std::endl
|
||||
<< std::endl
|
||||
<< "Usage: " << invocation << " [OPTION]"
|
||||
<< std::endl
|
||||
<< " mandatory options:" << std::endl
|
||||
<< " -o, --output=file.name write test results into this XML file"
|
||||
<< std::endl
|
||||
<< " optional options:" << std::endl
|
||||
<< " -s, --stylesheet specify this XSLT for the output file"
|
||||
<< std::endl
|
||||
<< " this is either an absolute URI, or a"
|
||||
<< std::endl
|
||||
<< " relative path for the output document"
|
||||
<< std::endl
|
||||
<< " -h, --help display this help and exit" << std::endl
|
||||
<< " -v, --version display version information and exit"
|
||||
<< std::endl
|
||||
<< std::endl
|
||||
<< "Report bugs to " << PACKAGE_BUGREPORT << std::endl;
|
||||
}
|
||||
|
|
@ -1,241 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
|
||||
This file is part of the Campcaster project.
|
||||
http://campcaster.sourcefabric.org/
|
||||
|
||||
Campcaster is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Campcaster is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Campcaster; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#else
|
||||
#error "Need unistd.h"
|
||||
#endif
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
#include "LiveSupport/Core/TimeConversion.h"
|
||||
|
||||
#include "GstreamerPlayer.h"
|
||||
#include "TestEventListener.h"
|
||||
#include "TwoGstreamerPlayersTest.h"
|
||||
|
||||
|
||||
using namespace LiveSupport::PlaylistExecutor;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(TwoGstreamerPlayersTest);
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the audio player.
|
||||
*/
|
||||
static const std::string configFileName = "etc/twoGstreamerPlayers.xml";
|
||||
|
||||
/**
|
||||
* The name of the root XML element in the configuration file.
|
||||
*/
|
||||
static const std::string rootElementName = "twoGstreamerPlayers";
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Set up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
TwoGstreamerPlayersTest :: setUp(void) throw ()
|
||||
{
|
||||
try {
|
||||
Ptr<xmlpp::DomParser>::Ref parser(
|
||||
new xmlpp::DomParser(configFileName, true));
|
||||
const xmlpp::Document * document = parser->get_document();
|
||||
const xmlpp::Element * root = document->get_root_node();
|
||||
|
||||
xmlpp::Node::NodeList children;
|
||||
const xmlpp::Element * element;
|
||||
|
||||
children = root->get_children(GstreamerPlayer::getConfigElementName());
|
||||
|
||||
element = dynamic_cast<const xmlpp::Element*> (*(children.begin()));
|
||||
player1.reset(new GstreamerPlayer());
|
||||
player1->configure(*element);
|
||||
|
||||
children.pop_front();
|
||||
element = dynamic_cast<const xmlpp::Element*> (*(children.begin()));
|
||||
player2.reset(new GstreamerPlayer());
|
||||
player2->configure(*element);
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << "semantic error in configuration file" << std::endl;
|
||||
} catch (xmlpp::exception &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Clean up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
TwoGstreamerPlayersTest :: tearDown(void) throw ()
|
||||
{
|
||||
player2.reset();
|
||||
player1.reset();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Test to see if the GstreamerPlayer engine can be started and stopped
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
TwoGstreamerPlayersTest :: firstTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
try {
|
||||
player1->initialize();
|
||||
player2->initialize();
|
||||
CPPUNIT_ASSERT(!player1->isPlaying());
|
||||
CPPUNIT_ASSERT(!player2->isPlaying());
|
||||
player2->deInitialize();
|
||||
player1->deInitialize();
|
||||
} catch (std::exception &e) {
|
||||
CPPUNIT_FAIL("failed to initialize or de-initialize GstreamerPlayer");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Play something simple on player #1
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
TwoGstreamerPlayersTest :: simplePlay1Test(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
Ptr<time_duration>::Ref sleepT(new time_duration(microseconds(10)));
|
||||
|
||||
player1->initialize();
|
||||
try {
|
||||
player1->open("file:///tmp/campcaster/test10001.mp3");
|
||||
} catch (std::invalid_argument &e) {
|
||||
CPPUNIT_FAIL(e.what());
|
||||
}
|
||||
CPPUNIT_ASSERT(!player1->isPlaying());
|
||||
player1->start();
|
||||
CPPUNIT_ASSERT(player1->isPlaying());
|
||||
while (player1->isPlaying()) {
|
||||
TimeConversion::sleep(sleepT);
|
||||
}
|
||||
CPPUNIT_ASSERT(!player1->isPlaying());
|
||||
player1->close();
|
||||
player1->deInitialize();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Play something simple on player #2
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
TwoGstreamerPlayersTest :: simplePlay2Test(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
Ptr<time_duration>::Ref sleepT(new time_duration(microseconds(10)));
|
||||
|
||||
player2->initialize();
|
||||
try {
|
||||
player2->open("file:///tmp/campcaster/test.mp3");
|
||||
} catch (std::invalid_argument &e) {
|
||||
CPPUNIT_FAIL(e.what());
|
||||
}
|
||||
CPPUNIT_ASSERT(!player2->isPlaying());
|
||||
player2->start();
|
||||
CPPUNIT_ASSERT(player2->isPlaying());
|
||||
while (player2->isPlaying()) {
|
||||
TimeConversion::sleep(sleepT);
|
||||
}
|
||||
CPPUNIT_ASSERT(!player2->isPlaying());
|
||||
player2->close();
|
||||
player2->deInitialize();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Play something simple on both players
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
TwoGstreamerPlayersTest :: playBothTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
Ptr<time_duration>::Ref sleepT(new time_duration(microseconds(10)));
|
||||
|
||||
player1->initialize();
|
||||
player2->initialize();
|
||||
|
||||
// start playing on player1
|
||||
try {
|
||||
player1->open("file:///tmp/campcaster/test10001.mp3");
|
||||
} catch (std::invalid_argument &e) {
|
||||
CPPUNIT_FAIL(e.what());
|
||||
}
|
||||
CPPUNIT_ASSERT(!player1->isPlaying());
|
||||
player1->start();
|
||||
CPPUNIT_ASSERT(player1->isPlaying());
|
||||
|
||||
// sleep some time
|
||||
for (unsigned i = 0; i < 100; ++i) {
|
||||
TimeConversion::sleep(sleepT);
|
||||
}
|
||||
|
||||
// start playing on player2
|
||||
try {
|
||||
player2->open("file:///tmp/campcaster/test.mp3");
|
||||
} catch (std::invalid_argument &e) {
|
||||
CPPUNIT_FAIL(e.what());
|
||||
}
|
||||
CPPUNIT_ASSERT(!player2->isPlaying());
|
||||
player2->start();
|
||||
CPPUNIT_ASSERT(player2->isPlaying());
|
||||
|
||||
// wait for both players to finish
|
||||
while (player1->isPlaying() || player2->isPlaying()) {
|
||||
TimeConversion::sleep(sleepT);
|
||||
}
|
||||
CPPUNIT_ASSERT(!player1->isPlaying());
|
||||
CPPUNIT_ASSERT(!player2->isPlaying());
|
||||
|
||||
player2->close();
|
||||
player1->close();
|
||||
player2->deInitialize();
|
||||
player1->deInitialize();
|
||||
}
|
||||
|
||||
|
|
@ -1,153 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
|
||||
This file is part of the Campcaster project.
|
||||
http://campcaster.sourcefabric.org/
|
||||
|
||||
Campcaster is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Campcaster is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Campcaster; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef TwoGstreamerPlayersTest_h
|
||||
#define TwoGstreamerPlayersTest_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
#endif
|
||||
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace PlaylistExecutor {
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
||||
/* =================================================================== macros */
|
||||
|
||||
|
||||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* Unit test for the GstreamerPlayer class, two see if two audio players,
|
||||
* playing on two different sound cards work correctly.
|
||||
*
|
||||
* @see GstreamerPlayer
|
||||
*/
|
||||
class TwoGstreamerPlayersTest : public CPPUNIT_NS::TestFixture
|
||||
{
|
||||
CPPUNIT_TEST_SUITE(TwoGstreamerPlayersTest);
|
||||
CPPUNIT_TEST(firstTest);
|
||||
CPPUNIT_TEST(simplePlay1Test);
|
||||
CPPUNIT_TEST(simplePlay2Test);
|
||||
CPPUNIT_TEST(playBothTest);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* Audio player #1 to use for the tests.
|
||||
*/
|
||||
Ptr<GstreamerPlayer>::Ref player1;
|
||||
|
||||
/**
|
||||
* Audio player #2 to use for the tests.
|
||||
*/
|
||||
Ptr<GstreamerPlayer>::Ref player2;
|
||||
|
||||
/**
|
||||
* Play a specific file.
|
||||
*
|
||||
* @param fileName the name of the file to play.
|
||||
* @param player the player to use for playing the file.
|
||||
* @exception CPPUNIT_NS::Exception on playing failures
|
||||
*/
|
||||
void
|
||||
playFile(const std::string & fileName,
|
||||
Ptr<GstreamerPlayer>::Ref player)
|
||||
throw (CPPUNIT_NS::Exception);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* A simple test.
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
firstTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
|
||||
/**
|
||||
* Play something on player #1.
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
simplePlay1Test(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
/**
|
||||
* Play something on player #2.
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
simplePlay2Test(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
/**
|
||||
* Play something on both players, at the same time.
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
playBothTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Set up the environment for the test case.
|
||||
*/
|
||||
void
|
||||
setUp(void) throw ();
|
||||
|
||||
/**
|
||||
* Clean up the environment after the test case.
|
||||
*/
|
||||
void
|
||||
tearDown(void) throw ();
|
||||
};
|
||||
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
||||
|
||||
/* ====================================================== function prototypes */
|
||||
|
||||
|
||||
} // namespace PlaylistExecutor
|
||||
} // namespace LiveSupport
|
||||
|
||||
#endif // TwoGstreamerPlayersTest_h
|
||||
|
|
@ -1 +0,0 @@
|
|||
keep me
|
|
@ -1,29 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<smil xmlns = "http://www.w3.org/2001/SMIL20/Language">
|
||||
<body>
|
||||
<par>
|
||||
<audio src="file:///tmp/campcaster/test10001.mp3" begin="0s">
|
||||
<animate attributeName = "soundLevel"
|
||||
from = "100%"
|
||||
to = "0%"
|
||||
calcMode = "linear"
|
||||
begin = "6.23s"
|
||||
end = "11.23s"
|
||||
fill = "freeze"
|
||||
/>
|
||||
</audio>
|
||||
<audio src="file:///tmp/campcaster/test10002.mp3" begin="6.23s">
|
||||
<animate attributeName = "soundLevel"
|
||||
from = "0%"
|
||||
to = "100%"
|
||||
calcMode = "linear"
|
||||
begin = "0s"
|
||||
end = "5s"
|
||||
fill = "freeze"
|
||||
/>
|
||||
</audio>
|
||||
<audio src="file:///tmp/campcaster/test10003.mp3" begin="18.45s">
|
||||
</audio>
|
||||
</par>
|
||||
</body>
|
||||
</smil>
|
|
@ -1,70 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<smil xmlns = "http://www.w3.org/2001/SMIL20/Language">
|
||||
<body>
|
||||
<par>
|
||||
<!-- clip info:
|
||||
full length = 6.23
|
||||
-->
|
||||
<audio src="file:///tmp/campcaster/test10001.mp3" begin="0s" clipBegin="0s" clipEnd="6.23s">
|
||||
<animate attributeName = "soundLevel"
|
||||
from = "0%"
|
||||
to = "100%"
|
||||
calcMode = "linear"
|
||||
begin = "0s"
|
||||
end = "3s"
|
||||
fill = "freeze"
|
||||
/>
|
||||
<animate attributeName = "soundLevel"
|
||||
from = "100%"
|
||||
to = "0%"
|
||||
calcMode = "linear"
|
||||
begin = "3.0s"
|
||||
end = "6.23s"
|
||||
fill = "freeze"
|
||||
/>
|
||||
</audio>
|
||||
<!-- clip info:
|
||||
full length = 12.22
|
||||
-->
|
||||
<audio src="file:///tmp/campcaster/test10002.mp3" begin="6.23s" clipBegin="4s" clipEnd="8s">
|
||||
<animate attributeName = "soundLevel"
|
||||
from = "0%"
|
||||
to = "100%"
|
||||
calcMode = "linear"
|
||||
begin = "4s"
|
||||
end = "6s"
|
||||
fill = "freeze"
|
||||
/>
|
||||
<animate attributeName = "soundLevel"
|
||||
from = "100%"
|
||||
to = "0%"
|
||||
calcMode = "linear"
|
||||
begin = "6s"
|
||||
end = "8s"
|
||||
fill = "freeze"
|
||||
/>
|
||||
</audio>
|
||||
<!-- clip info:
|
||||
full length = 12.22
|
||||
-->
|
||||
<audio src="file:///tmp/campcaster/test10003.mp3" begin="10.23s" clipBegin="0s" clipEnd="12.22s">
|
||||
<animate attributeName = "soundLevel"
|
||||
from = "0%"
|
||||
to = "100%"
|
||||
calcMode = "linear"
|
||||
begin = "0s"
|
||||
end = "5s"
|
||||
fill = "freeze"
|
||||
/>
|
||||
<animate attributeName = "soundLevel"
|
||||
from = "100%"
|
||||
to = "0%"
|
||||
calcMode = "linear"
|
||||
begin = "7.22s"
|
||||
end = "12.22s"
|
||||
fill = "freeze"
|
||||
/>
|
||||
</audio>
|
||||
</par>
|
||||
</body>
|
||||
</smil>
|
Binary file not shown.
Binary file not shown.
|
@ -1,10 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<smil xmlns = "http://www.w3.org/2001/SMIL20/Language">
|
||||
<body>
|
||||
<par>
|
||||
<audio src="file:///tmp/campcaster/test10001.mp3" begin="0s"/>
|
||||
<audio src="file:///tmp/campcaster/test10002.mp3" begin="11.23s"/>
|
||||
<audio src="file:///tmp/campcaster/test10003.mp3" begin="23.45s"/>
|
||||
</par>
|
||||
</body>
|
||||
</smil>
|
|
@ -1,8 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<smil xmlns = "http://www.w3.org/2001/SMIL20/Language">
|
||||
<body>
|
||||
<par>
|
||||
<audio src="file:///tmp/campcaster/test-short.mp3"/>
|
||||
</par>
|
||||
</body>
|
||||
</smil>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,90 +0,0 @@
|
|||
#!/bin/bash
|
||||
#-------------------------------------------------------------------------------
|
||||
# Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
#
|
||||
# This file is part of the Campcaster project.
|
||||
# http://campcaster.sourcefabric.org/
|
||||
#
|
||||
# Campcaster is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Campcaster is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Campcaster; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Run this to set up the build system: configure, makefiles, etc.
|
||||
# (based on the version in enlightenment's cvs)
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
package="SchedulerClient"
|
||||
|
||||
# assume we're in $basedir/bin
|
||||
reldir=`dirname $0`/..
|
||||
basedir=`cd $reldir; pwd;`
|
||||
test -z "$basedir" && basedir=.
|
||||
usrdir=`cd $basedir/../../../usr; pwd;`
|
||||
|
||||
bindir=$basedir/bin
|
||||
etcdir=$basedir/etc
|
||||
tmpdir=$basedir/tmp
|
||||
|
||||
cd "$tmpdir"
|
||||
DIE=0
|
||||
|
||||
(autoheader --version) < /dev/null > /dev/null 2>&1 || {
|
||||
echo
|
||||
echo "You must have autoconf installed to compile $package."
|
||||
echo "Download the appropriate package for your distribution,"
|
||||
echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
|
||||
DIE=1
|
||||
}
|
||||
|
||||
(autoconf --version) < /dev/null > /dev/null 2>&1 || {
|
||||
echo
|
||||
echo "You must have autoconf installed to compile $package."
|
||||
echo "Download the appropriate package for your distribution,"
|
||||
echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
|
||||
DIE=1
|
||||
}
|
||||
|
||||
if test "$DIE" -eq 1; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if test -z "$*"; then
|
||||
echo "I am going to run ./configure with no arguments - if you wish "
|
||||
echo "to pass any to it, please specify them on the $0 command line."
|
||||
fi
|
||||
|
||||
echo "Generating configuration files for $package, please wait...."
|
||||
|
||||
configure_ac=${etcdir}/configure.ac
|
||||
configure=${tmpdir}/configure
|
||||
aclocal_m4=${tmpdir}/aclocal.m4
|
||||
|
||||
# copy over configure.ac and acinlclude.m4 from etc to tmp,
|
||||
# as aclocal >= 1.8 is sooo unbelivably stupid that it will simply try to
|
||||
# look for configure.ac in the current directory, and include acinclude.m4
|
||||
# in aclocal.m4 it without a directory path in front
|
||||
ACLOCAL_FLAGS="-I ${tmpdir} --acdir=${tmpdir} --output=${aclocal_m4}"
|
||||
echo " aclocal $ACLOCAL_FLAGS"
|
||||
cp -f ${configure_ac} ${tmpdir}
|
||||
cp -f ${etcdir}/acinclude.m4 ${tmpdir}
|
||||
aclocal $ACLOCAL_FLAGS
|
||||
|
||||
echo " autoheader ${configure_ac}"
|
||||
autoheader ${configure_ac}
|
||||
|
||||
echo " autoconf -I ${tmpdir} -o ${configure} ${configure_ac}"
|
||||
autoconf -I ${tmpdir} -o ${configure} ${configure_ac}
|
||||
|
|
@ -1,75 +0,0 @@
|
|||
#!/bin/bash
|
||||
#-------------------------------------------------------------------------------
|
||||
# Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
#
|
||||
# This file is part of the Campcaster project.
|
||||
# http://campcaster.sourcefabric.org/
|
||||
#
|
||||
# Campcaster is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Campcaster is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Campcaster; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
#-------------------------------------------------------------------------------
|
||||
# This script generates code coverage data for the module
|
||||
#-------------------------------------------------------------------------------
|
||||
module="Campcaster SchedulerClient"
|
||||
|
||||
reldir=`dirname $0`/..
|
||||
basedir=`cd $reldir; pwd;`
|
||||
bindir=$basedir/bin
|
||||
docdir=$basedir/doc
|
||||
tmpdir=$basedir/tmp
|
||||
|
||||
usrdir=`cd $basedir/../../../usr; pwd;`
|
||||
|
||||
coverage_report_dir=$docdir/coverage
|
||||
|
||||
raw_coverage_file=$tmpdir/raw_coverage.info
|
||||
coverage_file=$tmpdir/coverage.info
|
||||
|
||||
lcov=$usrdir/bin/lcov
|
||||
genhtml=$usrdir/bin/genhtml
|
||||
|
||||
|
||||
cd $basedir
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Re-configure with covarege collection enabled, compile and run the tests
|
||||
#-------------------------------------------------------------------------------
|
||||
$bindir/autogen.sh --enable-coverage
|
||||
make clean
|
||||
make check
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Generate some symlinks so that the sources are visible from tmpdir
|
||||
#-------------------------------------------------------------------------------
|
||||
ln -s $basedir/include $tmpdir/include
|
||||
ln -s $basedir/src $tmpdir/src
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Use lcov to generate an HTML report on the coverage data
|
||||
#-------------------------------------------------------------------------------
|
||||
$lcov -d $tmpdir -c > $raw_coverage_file
|
||||
$lcov -e $raw_coverage_file "$tmpdir/*" > $coverage_file
|
||||
rm -rf $coverage_report_dir
|
||||
mkdir -p $coverage_report_dir
|
||||
$genhtml -t "$module" -o $coverage_report_dir $coverage_file
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Clean up
|
||||
#-------------------------------------------------------------------------------
|
||||
rm -f $tmpdir/include
|
||||
rm -f $tmpdir/src
|
|
@ -1,47 +0,0 @@
|
|||
#!/bin/sh
|
||||
#-------------------------------------------------------------------------------
|
||||
# Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
#
|
||||
# This file is part of the Campcaster project.
|
||||
# http://campcaster.campware.org/
|
||||
#
|
||||
# Campcaster is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Campcaster is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Campcaster; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Run this script to configure the environment.
|
||||
#
|
||||
# This script in effect calls the real automake / autoconf configure script
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
# assume we're in $basedir
|
||||
reldir=`dirname $0`
|
||||
basedir=`cd $reldir; pwd;`
|
||||
test -z "$basedir" && basedir=.
|
||||
|
||||
bindir=$basedir/bin
|
||||
tmpdir=$basedir/tmp
|
||||
|
||||
|
||||
autogen=$bindir/autogen.sh
|
||||
configure=$tmpdir/configure
|
||||
|
||||
if [ ! -x $configure ]; then
|
||||
(cd $basedir && $autogen $*)
|
||||
fi
|
||||
|
||||
(cd $tmpdir && $configure $*)
|
||||
|
|
@ -1 +0,0 @@
|
|||
keep me
|
|
@ -1,235 +0,0 @@
|
|||
#-------------------------------------------------------------------------------
|
||||
# Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
#
|
||||
# This file is part of the Campcaster project.
|
||||
# http://campcaster.sourcefabric.org/
|
||||
#
|
||||
# Campcaster is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Campcaster is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Campcaster; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
# @configure_input@
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# General command definitions
|
||||
#-------------------------------------------------------------------------------
|
||||
MKDIR = mkdir -p
|
||||
RM = rm -f
|
||||
RMDIR = rm -rf
|
||||
DOXYGEN = doxygen
|
||||
CP = cp -f
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Basic directory and file definitions
|
||||
#-------------------------------------------------------------------------------
|
||||
BASE_DIR = @builddir@
|
||||
DOC_DIR = ${BASE_DIR}/doc
|
||||
DOXYGEN_DIR = ${DOC_DIR}/doxygen
|
||||
COVERAGE_DIR = ${DOC_DIR}/coverage
|
||||
ETC_DIR = ${BASE_DIR}/etc
|
||||
INCLUDE_DIR = ${BASE_DIR}/include
|
||||
LIB_DIR = ${BASE_DIR}/lib
|
||||
SRC_DIR = ${BASE_DIR}/src
|
||||
TMP_DIR = ${BASE_DIR}/tmp
|
||||
|
||||
prefix = @prefix@
|
||||
|
||||
USR_DIR = ${prefix}
|
||||
USR_INCLUDE_DIR = ${USR_DIR}/include
|
||||
USR_LIB_DIR = ${USR_DIR}/lib
|
||||
|
||||
MODULES_DIR = ${BASE_DIR}/..
|
||||
|
||||
CORE_DIR = ${MODULES_DIR}/core
|
||||
CORE_INCLUDE_DIR = ${CORE_DIR}/include
|
||||
CORE_LIB_DIR = ${CORE_DIR}/lib
|
||||
CORE_LIB = livesupport_core
|
||||
CORE_LIB_FILE = ${CORE_LIB_DIR}/lib${CORE_LIB}.a
|
||||
|
||||
AUTHENTICATION_DIR = ${MODULES_DIR}/authentication
|
||||
AUTHENTICATION_INCLUDE_DIR = ${AUTHENTICATION_DIR}/include
|
||||
AUTHENTICATION_LIB_DIR = ${AUTHENTICATION_DIR}/lib
|
||||
AUTHENTICATION_LIB = livesupport_authentication
|
||||
AUTHENTICATION_LIB_FILE = ${AUTHENTICATION_LIB_DIR}/lib${AUTHENTICATION_LIB}.a
|
||||
|
||||
PRODUCTS_DIR = ${BASE_DIR}/../../products
|
||||
|
||||
SCHEDULER_DIR = ${PRODUCTS_DIR}/scheduler
|
||||
SCHEDULER_EXE = ${SCHEDULER_DIR}/tmp/scheduler
|
||||
|
||||
|
||||
VPATH = ${SRC_DIR}
|
||||
|
||||
BOOST_CFLAGS=@BOOST_CPPFLAGS@
|
||||
BOOST_LIBS=@BOOST_LDFLAGS@
|
||||
BOOST_DATE_TIME_LIB=@BOOST_DATE_TIME_LIB@
|
||||
|
||||
LIBXMLPP_CFLAGS=@LIBXMLPP_CFLAGS@
|
||||
LIBXMLPP_LIBS=@LIBXMLPP_LIBS@
|
||||
|
||||
CURL_CFLAGS=@CURL_CFLAGS@
|
||||
CURL_LIBS=@CURL_LIBS@
|
||||
|
||||
ICU_CFLAGS=@ICU_CFLAGS@
|
||||
ICU_CXXFLAGS=@ICU_CXXFLAGS@
|
||||
ICU_LIBS=@ICU_LIBS@
|
||||
|
||||
TAGLIB_CFLAGS=@TAGLIB_CFLAGS@
|
||||
TAGLIB_LIBS=@TAGLIB_LIBS@
|
||||
|
||||
TEST_RESULTS = ${DOC_DIR}/testResults.xml
|
||||
# the text result XSLT has to be relative to the test result file, e.g. TMP_DIR
|
||||
TEST_XSLT = ../etc/testResultToHtml.xsl
|
||||
|
||||
SCHEDULER_CLIENT_LIB = livesupport_scheduler_client
|
||||
SCHEDULER_CLIENT_LIB_FILE = ${LIB_DIR}/lib${SCHEDULER_CLIENT_LIB}.a
|
||||
TEST_RUNNER = ${TMP_DIR}/testRunner
|
||||
|
||||
DOXYGEN_CONFIG = ${ETC_DIR}/doxygen.config
|
||||
|
||||
export LD_LIBRARY_PATH:=${USR_LIB_DIR}:${LD_LIBRARY_PATH}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Configuration parameters
|
||||
#-------------------------------------------------------------------------------
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CXXFLAGS = @CXXFLAGS@ @DEFS@ @COVERAGE_CXXFLAGS@ -pthread \
|
||||
-pedantic -Wall -Wno-long-long \
|
||||
${BOOST_CFLAGS} \
|
||||
${LIBXMLPP_CFLAGS} \
|
||||
${LIBTAR_CFLAGS} \
|
||||
-I${USR_INCLUDE_DIR} \
|
||||
-I${CORE_INCLUDE_DIR} \
|
||||
-I${AUTHENTICATION_INCLUDE_DIR} \
|
||||
-I${INCLUDE_DIR} -I${TMP_DIR}
|
||||
LDFLAGS = @LDFLAGS@ -pthread \
|
||||
${BOOST_LIBS} \
|
||||
${LIBXMLPP_LIBS} \
|
||||
${CURL_LIBS} \
|
||||
${ICU_LIBS} \
|
||||
${TAGLIB_LIBS} \
|
||||
${LIBTAR_LIBS} \
|
||||
-L${USR_LIB_DIR} \
|
||||
-L${CORE_LIB_DIR} \
|
||||
-L${AUTHENTICATION_LIB_DIR} \
|
||||
-L${LIB_DIR}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Dependencies
|
||||
#-------------------------------------------------------------------------------
|
||||
SCHEDULER_CLIENT_LIB_OBJS = ${TMP_DIR}/SchedulerDaemonXmlRpcClient.o \
|
||||
${TMP_DIR}/SchedulerClientFactory.o
|
||||
|
||||
TEST_RUNNER_OBJS = ${TMP_DIR}/TestRunner.o \
|
||||
${TMP_DIR}/SchedulerDaemonXmlRpcClientTest.o \
|
||||
${TMP_DIR}/SchedulerClientFactoryTest.o
|
||||
|
||||
TEST_RUNNER_LIBS = -l${SCHEDULER_CLIENT_LIB} \
|
||||
-l${CORE_LIB} \
|
||||
-l${AUTHENTICATION_LIB} \
|
||||
${BOOST_DATE_TIME_LIB} \
|
||||
-lcppunit -ldl -lxmlrpc++ -lssl -ltar
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Targets
|
||||
#-------------------------------------------------------------------------------
|
||||
.PHONY: all dir_setup doc clean docclean depclean distclean
|
||||
.PHONY: check install init start run_tests stop deinit
|
||||
|
||||
all: dir_setup ${SCHEDULER_CLIENT_LIB_FILE}
|
||||
|
||||
dir_setup: ${TMP_DIR} ${DOXYGEN_DIR}
|
||||
|
||||
doc:
|
||||
${DOXYGEN} ${DOXYGEN_CONFIG}
|
||||
|
||||
clean:
|
||||
${RM} ${SCHEDULER_CLIENT_LIB_OBJS} ${SCHEDULER_CLIENT_LIB_FILE}
|
||||
${RM} ${TEST_RUNNER_OBJS} ${TEST_RUNNER}
|
||||
${RM} ${TMP_DIR}/*.bb ${TMP_DIR}/*.bbg ${TMP_DIR}/*.da ${TMP_DIR}/*.info
|
||||
|
||||
docclean:
|
||||
${RMDIR} ${DOXYGEN_DIR}/html
|
||||
${RMDIR} ${COVERAGE_DIR}/*
|
||||
${RM} ${TEST_RESULTS}
|
||||
|
||||
depclean: clean
|
||||
${MAKE} -C ${AUTHENTICATION_DIR} clean
|
||||
${MAKE} -C ${CORE_DIR} clean
|
||||
|
||||
distclean: clean docclean
|
||||
${RMDIR} ${TMP_DIR}/config* ${TMP_DIR}/autom4te* ${TMP_DIR}/ac*.m4
|
||||
|
||||
check: all ${TEST_RUNNER} init start run_tests stop deinit
|
||||
|
||||
run_tests: ${TEST_RUNNER}
|
||||
-${TEST_RUNNER} -o ${TEST_RESULTS} -s ${TEST_XSLT}
|
||||
|
||||
init: ${SCHEDULER_EXE} storage_server_init
|
||||
${MAKE} -C ${SCHEDULER_DIR} init
|
||||
|
||||
start: ${SCHEDULER_EXE}
|
||||
${MAKE} -C ${SCHEDULER_DIR} start
|
||||
|
||||
stop: ${SCHEDULER_EXE}
|
||||
${MAKE} -C ${SCHEDULER_DIR} stop
|
||||
|
||||
deinit: ${SCHEDULER_EXE}
|
||||
${MAKE} -C ${SCHEDULER_DIR} deinit
|
||||
|
||||
install: all
|
||||
${MKDIR} ${USR_INCLUDE_DIR}/LiveSupport/SchedulerClient
|
||||
${CP} ${INCLUDE_DIR}/LiveSupport/SchedulerClient/*.h \
|
||||
${USR_INCLUDE_DIR}/LiveSupport/SchedulerClient
|
||||
${CP} ${SCHEDULER_CLIENT_LIB_FILE} ${USR_LIB_DIR}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Specific targets
|
||||
#-------------------------------------------------------------------------------
|
||||
${SCHEDULER_CLIENT_LIB_FILE}: ${SCHEDULER_CLIENT_LIB_OBJS}
|
||||
${AR} crus $@ $^
|
||||
|
||||
${TMP_DIR}:
|
||||
${MKDIR} ${TMP_DIR}
|
||||
|
||||
${DOXYGEN_DIR}:
|
||||
${MKDIR} ${DOXYGEN_DIR}
|
||||
|
||||
${TEST_RUNNER}: ${CORE_LIB_FILE} ${TEST_RUNNER_OBJS} ${SCHEDULER_CLIENT_LIB_FILE}
|
||||
${CXX} ${LDFLAGS} -o $@ ${TEST_RUNNER_OBJS} ${TEST_RUNNER_LIBS}
|
||||
|
||||
${CORE_LIB_FILE}:
|
||||
${MAKE} -C ${CORE_DIR}
|
||||
|
||||
${AUTHENTICATION_LIB_FILE}:
|
||||
${MAKE} -C ${AUTHENTICATION_DIR}
|
||||
|
||||
${SCHEDULER_EXE}:
|
||||
${MAKE} -C ${SCHEDULER_DIR}
|
||||
|
||||
storage_server_init:
|
||||
${MAKE} -C ${BASE_DIR}/../storageServer
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Pattern rules
|
||||
#-------------------------------------------------------------------------------
|
||||
${TMP_DIR}/%.o : ${SRC_DIR}/%.cxx
|
||||
${CXX} ${CPPFLAGS} ${CXXFLAGS} -c -o $@ $<
|
||||
|
|
@ -1,575 +0,0 @@
|
|||
dnl-----------------------------------------------------------------------------
|
||||
dnl Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
dnl
|
||||
dnl This file is part of the Campcaster project.
|
||||
dnl http://campcaster.sourcefabric.org/
|
||||
dnl
|
||||
dnl Campcaster is free software; you can redistribute it and/or modify
|
||||
dnl it under the terms of the GNU General Public License as published by
|
||||
dnl the Free Software Foundation; either version 2 of the License, or
|
||||
dnl (at your option) any later version.
|
||||
dnl
|
||||
dnl Campcaster is distributed in the hope that it will be useful,
|
||||
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
dnl GNU General Public License for more details.
|
||||
dnl
|
||||
dnl You should have received a copy of the GNU General Public License
|
||||
dnl along with Campcaster; if not, write to the Free Software
|
||||
dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
dnl
|
||||
dnl-----------------------------------------------------------------------------
|
||||
|
||||
dnl-----------------------------------------------------------------------------
|
||||
dnl Macro to check for available modules using pkg-conf
|
||||
dnl
|
||||
dnl usage:
|
||||
dnl PKG_CHECK_MODULES(GSTUFF,[gtk+-2.0 >= 1.3], action-if, action-not)
|
||||
dnl
|
||||
dnl defines GSTUFF_LIBS, GSTUFF_CFLAGS, see pkg-config man page
|
||||
dnl also defines GSTUFF_PKG_ERRORS on error
|
||||
dnl
|
||||
dnl This function was taken from the glade-- project
|
||||
dnl-----------------------------------------------------------------------------
|
||||
AC_DEFUN([PKG_CHECK_MODULES], [
|
||||
succeeded=no
|
||||
|
||||
if test -z "$PKG_CONFIG"; then
|
||||
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
|
||||
fi
|
||||
|
||||
if test "$PKG_CONFIG" = "no" ; then
|
||||
echo "*** The pkg-config script could not be found. Make sure it is"
|
||||
echo "*** in your path, or set the PKG_CONFIG environment variable"
|
||||
echo "*** to the full path to pkg-config."
|
||||
echo "*** Or see http://www.freedesktop.org/software/pkgconfig to get pkg-config."
|
||||
else
|
||||
PKG_CONFIG_MIN_VERSION=0.9.0
|
||||
if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
|
||||
AC_MSG_CHECKING(for $2)
|
||||
|
||||
if $PKG_CONFIG --exists "$2" ; then
|
||||
AC_MSG_RESULT(yes)
|
||||
succeeded=yes
|
||||
|
||||
AC_MSG_CHECKING($1_CFLAGS)
|
||||
$1_CFLAGS=`$PKG_CONFIG --cflags "$2"`
|
||||
AC_MSG_RESULT($$1_CFLAGS)
|
||||
|
||||
AC_MSG_CHECKING($1_LIBS)
|
||||
$1_LIBS=`$PKG_CONFIG --libs "$2"`
|
||||
AC_MSG_RESULT($$1_LIBS)
|
||||
else
|
||||
$1_CFLAGS=""
|
||||
$1_LIBS=""
|
||||
## If we have a custom action on failure, don't print errors, but
|
||||
## do set a variable so people can do so.
|
||||
$1_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"`
|
||||
ifelse([$4], ,echo $$1_PKG_ERRORS,)
|
||||
fi
|
||||
|
||||
AC_SUBST($1_CFLAGS)
|
||||
AC_SUBST($1_LIBS)
|
||||
else
|
||||
echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
|
||||
echo "*** See http://www.freedesktop.org/software/pkgconfig"
|
||||
fi
|
||||
fi
|
||||
|
||||
if test $succeeded = yes; then
|
||||
ifelse([$3], , :, [$3])
|
||||
else
|
||||
ifelse([$4], , AC_MSG_ERROR([Library requirements ($2) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them.]), [$4])
|
||||
fi
|
||||
])
|
||||
|
||||
|
||||
|
||||
dnl-----------------------------------------------------------------------------
|
||||
dnl Macro to check for taglib of sufficient version by looking at taglib-config
|
||||
dnl
|
||||
dnl usage:
|
||||
dnl AC_CHECK_TAGLIB(version, action-if, action-not)
|
||||
dnl
|
||||
dnl defines TAGLIB_LIBS, TAGLIB_CFLAGS, see taglib-config man page
|
||||
dnl-----------------------------------------------------------------------------
|
||||
AC_DEFUN([AC_CHECK_TAGLIB], [
|
||||
succeeded=no
|
||||
|
||||
if test -z "$TAGLIB_CONFIG"; then
|
||||
AC_PATH_PROG(TAGLIB_CONFIG, taglib-config, no)
|
||||
fi
|
||||
|
||||
if test "$TAGLIB_CONFIG" = "no" ; then
|
||||
echo "*** The taglib-config script could not be found. Make sure it is"
|
||||
echo "*** in your path, and that taglib is properly installed."
|
||||
echo "*** Or see http://developer.kde.org/~wheeler/taglib.html"
|
||||
else
|
||||
TAGLIB_VERSION=`$TAGLIB_CONFIG --version`
|
||||
AC_MSG_CHECKING(for taglib >= $1)
|
||||
VERSION_CHECK=`expr $TAGLIB_VERSION \>\= $1`
|
||||
if test "$VERSION_CHECK" = "1" ; then
|
||||
AC_MSG_RESULT(yes)
|
||||
succeeded=yes
|
||||
|
||||
AC_MSG_CHECKING(TAGLIB_CFLAGS)
|
||||
TAGLIB_CFLAGS=`$TAGLIB_CONFIG --cflags`
|
||||
AC_MSG_RESULT($TAGLIB_CFLAGS)
|
||||
|
||||
AC_MSG_CHECKING(TAGLIB_LIBS)
|
||||
TAGLIB_LIBS=`$TAGLIB_CONFIG --libs`
|
||||
AC_MSG_RESULT($TAGLIB_LIBS)
|
||||
else
|
||||
TAGLIB_CFLAGS=""
|
||||
TAGLIB_LIBS=""
|
||||
## If we have a custom action on failure, don't print errors, but
|
||||
## do set a variable so people can do so.
|
||||
ifelse([$3], ,echo "can't find taglib >= $1",)
|
||||
fi
|
||||
|
||||
AC_SUBST(TAGLIB_CFLAGS)
|
||||
AC_SUBST(TAGLIB_LIBS)
|
||||
fi
|
||||
|
||||
if test $succeeded = yes; then
|
||||
ifelse([$2], , :, [$2])
|
||||
else
|
||||
ifelse([$3], , AC_MSG_ERROR([Library requirements (taglib) not met.]), [$3])
|
||||
fi
|
||||
])
|
||||
|
||||
|
||||
|
||||
dnl-----------------------------------------------------------------------------
|
||||
dnl Macro to check for ICU of sufficient version by looking at icu-config
|
||||
dnl
|
||||
dnl usage:
|
||||
dnl AC_CHECK_ICU(version, action-if, action-not)
|
||||
dnl
|
||||
dnl defines ICU_LIBS, ICU_CFLAGS, ICU_CXXFLAGS, see icu-config man page
|
||||
dnl-----------------------------------------------------------------------------
|
||||
AC_DEFUN([AC_CHECK_ICU], [
|
||||
succeeded=no
|
||||
|
||||
if test -z "$ICU_CONFIG"; then
|
||||
AC_PATH_PROG(ICU_CONFIG, icu-config, no)
|
||||
fi
|
||||
|
||||
if test "$ICU_CONFIG" = "no" ; then
|
||||
echo "*** The icu-config script could not be found. Make sure it is"
|
||||
echo "*** in your path, and that taglib is properly installed."
|
||||
echo "*** Or see http://ibm.com/software/globalization/icu/"
|
||||
else
|
||||
ICU_VERSION=`$ICU_CONFIG --version`
|
||||
AC_MSG_CHECKING(for ICU >= $1)
|
||||
VERSION_CHECK=`expr $ICU_VERSION \>\= $1`
|
||||
if test "$VERSION_CHECK" = "1" ; then
|
||||
AC_MSG_RESULT(yes)
|
||||
succeeded=yes
|
||||
|
||||
AC_MSG_CHECKING(ICU_CFLAGS)
|
||||
ICU_CFLAGS=`$ICU_CONFIG --cflags`
|
||||
AC_MSG_RESULT($ICU_CFLAGS)
|
||||
|
||||
AC_MSG_CHECKING(ICU_CXXFLAGS)
|
||||
ICU_CXXFLAGS=`$ICU_CONFIG --cxxflags`
|
||||
AC_MSG_RESULT($ICU_CXXFLAGS)
|
||||
|
||||
AC_MSG_CHECKING(ICU_LIBS)
|
||||
ICU_LIBS=`$ICU_CONFIG --ldflags`
|
||||
AC_MSG_RESULT($ICU_LIBS)
|
||||
else
|
||||
ICU_CFLAGS=""
|
||||
ICU_CXXFLAGS=""
|
||||
ICU_LIBS=""
|
||||
## If we have a custom action on failure, don't print errors, but
|
||||
## do set a variable so people can do so.
|
||||
ifelse([$3], ,echo "can't find ICU >= $1",)
|
||||
fi
|
||||
|
||||
AC_SUBST(ICU_CFLAGS)
|
||||
AC_SUBST(ICU_CXXFLAGS)
|
||||
AC_SUBST(ICU_LIBS)
|
||||
fi
|
||||
|
||||
if test $succeeded = yes; then
|
||||
ifelse([$2], , :, [$2])
|
||||
else
|
||||
ifelse([$3], , AC_MSG_ERROR([Library requirements (ICU) not met.]), [$3])
|
||||
fi
|
||||
])
|
||||
|
||||
|
||||
|
||||
dnl-----------------------------------------------------------------------------
|
||||
dnl Macro to check for curl of sufficient version by looking at curl-config
|
||||
dnl
|
||||
dnl usage:
|
||||
dnl AC_CHECK_CURL(version, action-if, action-not)
|
||||
dnl
|
||||
dnl defines CURL_LIBS, CURL_CFLAGS, see curl-config man page
|
||||
dnl-----------------------------------------------------------------------------
|
||||
AC_DEFUN([AC_CHECK_CURL], [
|
||||
succeeded=no
|
||||
|
||||
if test -z "$CURL_CONFIG"; then
|
||||
AC_PATH_PROG(CURL_CONFIG, curl-config, no)
|
||||
fi
|
||||
|
||||
if test "$CURL_CONFIG" = "no" ; then
|
||||
echo "*** The curl-config script could not be found. Make sure it is"
|
||||
echo "*** in your path, and that curl is properly installed."
|
||||
echo "*** Or see http://curl.haxx.se/"
|
||||
else
|
||||
dnl curl-config --version returns "libcurl <version>", thus cut the number
|
||||
CURL_VERSION=`$CURL_CONFIG --version | cut -d" " -f2`
|
||||
AC_MSG_CHECKING(for curl >= $1)
|
||||
VERSION_CHECK=`expr $CURL_VERSION \>\= $1`
|
||||
if test "$VERSION_CHECK" = "1" ; then
|
||||
AC_MSG_RESULT(yes)
|
||||
succeeded=yes
|
||||
|
||||
AC_MSG_CHECKING(CURL_CFLAGS)
|
||||
CURL_CFLAGS=`$CURL_CONFIG --cflags`
|
||||
AC_MSG_RESULT($CURL_CFLAGS)
|
||||
|
||||
AC_MSG_CHECKING(CURL_LIBS)
|
||||
CURL_LIBS=`$CURL_CONFIG --libs`
|
||||
AC_MSG_RESULT($CURL_LIBS)
|
||||
else
|
||||
CURL_CFLAGS=""
|
||||
CURL_LIBS=""
|
||||
## If we have a custom action on failure, don't print errors, but
|
||||
## do set a variable so people can do so.
|
||||
ifelse([$3], ,echo "can't find curl >= $1",)
|
||||
fi
|
||||
|
||||
AC_SUBST(CURL_CFLAGS)
|
||||
AC_SUBST(CURL_LIBS)
|
||||
fi
|
||||
|
||||
if test $succeeded = yes; then
|
||||
ifelse([$2], , :, [$2])
|
||||
else
|
||||
ifelse([$3], , AC_MSG_ERROR([Library requirements (curl) not met.]), [$3])
|
||||
fi
|
||||
])
|
||||
|
||||
|
||||
|
||||
dnl-----------------------------------------------------------------------------
|
||||
dnl Macro to check for C++ namespaces
|
||||
dnl for more information on this macro, see
|
||||
dnl http://autoconf-archive.cryp.to/ac_cxx_namespaces.html
|
||||
dnl
|
||||
dnl usage:
|
||||
dnl If the compiler can prevent names clashes using namespaces,
|
||||
dnl define HAVE_NAMESPACES.
|
||||
dnl-----------------------------------------------------------------------------
|
||||
AC_DEFUN([AC_CXX_NAMESPACES],
|
||||
[AC_CACHE_CHECK(whether the compiler implements namespaces,
|
||||
ac_cv_cxx_namespaces,
|
||||
[AC_LANG_SAVE
|
||||
AC_LANG_CPLUSPLUS
|
||||
AC_TRY_COMPILE([namespace Outer { namespace Inner { int i = 0; }}],
|
||||
[using namespace Outer::Inner; return i;],
|
||||
ac_cv_cxx_namespaces=yes, ac_cv_cxx_namespaces=no)
|
||||
AC_LANG_RESTORE
|
||||
])
|
||||
if test "$ac_cv_cxx_namespaces" = yes; then
|
||||
AC_DEFINE(HAVE_NAMESPACES,,[define if the compiler implements namespaces])
|
||||
fi
|
||||
])
|
||||
|
||||
|
||||
dnl-----------------------------------------------------------------------------
|
||||
dnl Test for the Boost C++ libraries of a particular version (or newer).
|
||||
dnl for more information on boost, see http://www.boost.org/
|
||||
dnl for more information on this macro, see
|
||||
dnl http://autoconf-archive.cryp.to/ax_boost_base.html
|
||||
dnl
|
||||
dnl usage:
|
||||
dnl If no path to the installed boost library is given the macro searches
|
||||
dnl under ${prefix}, /usr, /usr/local, and /opt, and evaluates the $BOOST_ROOT
|
||||
dnl environment variable. Further documentation is available at
|
||||
dnl http://randspringer.de/boost/index.html
|
||||
dnl
|
||||
dnl This macro calls: AC_SUBST(BOOST_CPPFLAGS) and AC_SUBST(BOOST_LDFLAGS)
|
||||
dnl and sets: HAVE_BOOST
|
||||
dnl
|
||||
dnl Modified for Campcaster:
|
||||
dnl * --with-boost default changed to Yes;
|
||||
dnl * if the library is not found, it does not die, just prints "no", leaves
|
||||
dnl HAVE_BOOST undefined, and sets the BOOST_CPPFLAGS and BOOST_LDFLAGS
|
||||
dnl variables to "";
|
||||
dnl * ${prefix} is prepended to the search path.
|
||||
dnl
|
||||
dnl Author: Thomas Porschberg <thomas@randspringer.de>
|
||||
dnl
|
||||
dnl License:
|
||||
dnl Copyright © 2006 Thomas Porschberg <thomas@randspringer.de>
|
||||
dnl Copying and distribution of this file, with or without modification,
|
||||
dnl are permitted in any medium without royalty provided the copyright notice
|
||||
dnl and this notice are preserved.
|
||||
dnl-----------------------------------------------------------------------------
|
||||
AC_DEFUN([AX_BOOST_BASE],
|
||||
[
|
||||
AC_ARG_WITH([boost],
|
||||
AS_HELP_STRING([--with-boost@<:@=DIR@:>@], [use boost (default is Yes) - it is possible to specify the root directory for boost (optional)]),
|
||||
[
|
||||
if test "$withval" = "no"; then
|
||||
want_boost="no"
|
||||
elif test "$withval" = "yes"; then
|
||||
want_boost="yes"
|
||||
ac_boost_path=""
|
||||
else
|
||||
want_boost="yes"
|
||||
ac_boost_path="$withval"
|
||||
fi
|
||||
],
|
||||
[want_boost="yes"])
|
||||
|
||||
if test "x$want_boost" = "xyes"; then
|
||||
boost_lib_version_req=ifelse([$1], ,1.20.0,$1)
|
||||
boost_lib_version_req_shorten=`expr $boost_lib_version_req : '\([[0-9]]*\.[[0-9]]*\)'`
|
||||
boost_lib_version_req_major=`expr $boost_lib_version_req : '\([[0-9]]*\)'`
|
||||
boost_lib_version_req_minor=`expr $boost_lib_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
|
||||
boost_lib_version_req_sub_minor=`expr $boost_lib_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
|
||||
if test "x$boost_lib_version_req_sub_minor" = "x" ; then
|
||||
boost_lib_version_req_sub_minor="0"
|
||||
fi
|
||||
WANT_BOOST_VERSION=`expr $boost_lib_version_req_major \* 100000 \+ $boost_lib_version_req_minor \* 100 \+ $boost_lib_version_req_sub_minor`
|
||||
AC_MSG_CHECKING(for boostlib >= $boost_lib_version_req)
|
||||
succeeded=no
|
||||
|
||||
dnl first we check the system location for boost libraries
|
||||
dnl this location ist chosen if boost libraries are installed with the --layout=system option
|
||||
dnl or if you install boost with RPM
|
||||
if test "$ac_boost_path" != ""; then
|
||||
BOOST_LDFLAGS="-L$ac_boost_path/lib"
|
||||
BOOST_CPPFLAGS="-I$ac_boost_path/include"
|
||||
else
|
||||
for ac_boost_path_tmp in ${prefix} /usr /usr/local /opt ; do
|
||||
if test -d "$ac_boost_path_tmp/include/boost" && test -r "$ac_boost_path_tmp/include/boost"; then
|
||||
BOOST_LDFLAGS="-L$ac_boost_path_tmp/lib"
|
||||
BOOST_CPPFLAGS="-I$ac_boost_path_tmp/include"
|
||||
break;
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
CPPFLAGS_SAVED="$CPPFLAGS"
|
||||
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
|
||||
export CPPFLAGS
|
||||
|
||||
LDFLAGS_SAVED="$LDFLAGS"
|
||||
LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
|
||||
export LDFLAGS
|
||||
|
||||
AC_LANG_PUSH(C++)
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
||||
@%:@include <boost/version.hpp>
|
||||
]], [[
|
||||
#if BOOST_VERSION >= $WANT_BOOST_VERSION
|
||||
// Everything is okay
|
||||
#else
|
||||
# error Boost version is too old
|
||||
#endif
|
||||
]])],[
|
||||
AC_MSG_RESULT(yes)
|
||||
succeeded=yes
|
||||
found_system=yes
|
||||
],[
|
||||
])
|
||||
AC_LANG_POP([C++])
|
||||
|
||||
|
||||
|
||||
dnl if we found no boost with system layout we search for boost libraries
|
||||
dnl built and installed without the --layout=system option or for a staged(not installed) version
|
||||
if test "x$succeeded" != "xyes"; then
|
||||
_version=0
|
||||
if test "$ac_boost_path" != ""; then
|
||||
BOOST_LDFLAGS="-L$ac_boost_path/lib"
|
||||
if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
|
||||
for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do
|
||||
_version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
|
||||
V_CHECK=`expr $_version_tmp \> $_version`
|
||||
if test "$V_CHECK" = "1" ; then
|
||||
_version=$_version_tmp
|
||||
fi
|
||||
VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
|
||||
BOOST_CPPFLAGS="-I$ac_boost_path/include/boost-$VERSION_UNDERSCORE"
|
||||
done
|
||||
fi
|
||||
else
|
||||
for ac_boost_path in /usr /usr/local /opt ; do
|
||||
if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
|
||||
for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do
|
||||
_version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
|
||||
V_CHECK=`expr $_version_tmp \> $_version`
|
||||
if test "$V_CHECK" = "1" ; then
|
||||
_version=$_version_tmp
|
||||
best_path=$ac_boost_path
|
||||
fi
|
||||
done
|
||||
fi
|
||||
done
|
||||
|
||||
VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
|
||||
BOOST_CPPFLAGS="-I$best_path/include/boost-$VERSION_UNDERSCORE"
|
||||
BOOST_LDFLAGS="-L$best_path/lib"
|
||||
|
||||
if test "x$BOOST_ROOT" != "x"; then
|
||||
if test -d "$BOOST_ROOT" && test -r "$BOOST_ROOT" && test -d "$BOOST_ROOT/stage/lib" && test -r "$BOOST_ROOT/stage/lib"; then
|
||||
version_dir=`expr //$BOOST_ROOT : '.*/\(.*\)'`
|
||||
stage_version=`echo $version_dir | sed 's/boost_//' | sed 's/_/./g'`
|
||||
stage_version_shorten=`expr $stage_version : '\([[0-9]]*\.[[0-9]]*\)'`
|
||||
V_CHECK=`expr $stage_version_shorten \>\= $_version`
|
||||
if test "$V_CHECK" = "1" ; then
|
||||
AC_MSG_NOTICE(We will use a staged boost library from $BOOST_ROOT)
|
||||
BOOST_CPPFLAGS="-I$BOOST_ROOT"
|
||||
BOOST_LDFLAGS="-L$BOOST_ROOT/stage/lib"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
|
||||
export CPPFLAGS
|
||||
LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
|
||||
export LDFLAGS
|
||||
|
||||
AC_LANG_PUSH(C++)
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
||||
@%:@include <boost/version.hpp>
|
||||
]], [[
|
||||
#if BOOST_VERSION >= $WANT_BOOST_VERSION
|
||||
// Everything is okay
|
||||
#else
|
||||
# error Boost version is too old
|
||||
#endif
|
||||
]])],[
|
||||
AC_MSG_RESULT(yes)
|
||||
succeeded=yes
|
||||
found_system=yes
|
||||
],[
|
||||
])
|
||||
AC_LANG_POP([C++])
|
||||
fi
|
||||
|
||||
if test "$succeeded" != "yes" ; then
|
||||
BOOST_CPPFLAGS=""
|
||||
BOOST_LDFLAGS=""
|
||||
AC_MSG_RESULT(no)
|
||||
else
|
||||
AC_SUBST(BOOST_CPPFLAGS)
|
||||
AC_SUBST(BOOST_LDFLAGS)
|
||||
AC_DEFINE(HAVE_BOOST,,[define if the Boost library is available])
|
||||
fi
|
||||
|
||||
CPPFLAGS="$CPPFLAGS_SAVED"
|
||||
LDFLAGS="$LDFLAGS_SAVED"
|
||||
fi
|
||||
|
||||
])
|
||||
|
||||
|
||||
dnl-----------------------------------------------------------------------------
|
||||
dnl Test for Date_Time library from the Boost C++ libraries.
|
||||
dnl for more information on boost, see http://www.boost.org/
|
||||
dnl for more information on this macro, see
|
||||
dnl http://autoconf-archive.cryp.to/ax_boost_date_time.html
|
||||
dnl
|
||||
dnl usage:
|
||||
dnl The macro requires a preceding call to AX_BOOST_BASE.
|
||||
dnl Further documentation is available at
|
||||
dnl <http://randspringer.de/boost/index.html>.
|
||||
dnl
|
||||
dnl This macro calls: AC_SUBST(BOOST_DATE_TIME_LIB)
|
||||
dnl and sets: HAVE_BOOST_DATE_TIME
|
||||
dnl
|
||||
dnl Modified for Campcaster:
|
||||
dnl * --with-boost-date-time default changed to Yes.
|
||||
dnl * added some more recognized suffixes to the library's name, incl. "-st".
|
||||
dnl
|
||||
dnl Authors:
|
||||
dnl Thomas Porschberg <thomas@randspringer.de>
|
||||
dnl Michael Tindal <mtindal@paradoxpoint.com>
|
||||
dnl
|
||||
dnl License:
|
||||
dnl Copyright © 2006 Thomas Porschberg <thomas@randspringer.de>
|
||||
dnl Copying and distribution of this file, with or without modification,
|
||||
dnl are permitted in any medium without royalty provided the copyright notice
|
||||
dnl and this notice are preserved.
|
||||
dnl-----------------------------------------------------------------------------
|
||||
AC_DEFUN([AX_BOOST_DATE_TIME],
|
||||
[
|
||||
AC_ARG_WITH([boost-date-time],
|
||||
AS_HELP_STRING([--with-boost-date-time@<:@=special-lib@:>@],
|
||||
[use the Date_Time library from boost - it is possible to specify a certain library for the linker
|
||||
e.g. --with-boost-date-time=boost_date_time-gcc-mt-d-1_33_1 ]),
|
||||
[
|
||||
if test "$withval" = "no"; then
|
||||
want_boost="no"
|
||||
elif test "$withval" = "yes"; then
|
||||
want_boost="yes"
|
||||
ax_boost_user_date_time_lib=""
|
||||
else
|
||||
want_boost="yes"
|
||||
ax_boost_user_date_time_lib="$withval"
|
||||
fi
|
||||
],
|
||||
[want_boost="yes"]
|
||||
)
|
||||
|
||||
if test "x$want_boost" = "xyes"; then
|
||||
AC_REQUIRE([AC_PROG_CC])
|
||||
CPPFLAGS_SAVED="$CPPFLAGS"
|
||||
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
|
||||
export CPPFLAGS
|
||||
|
||||
LDFLAGS_SAVED="$LDFLAGS"
|
||||
LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
|
||||
export LDFLAGS
|
||||
|
||||
AC_CACHE_CHECK(whether the Boost::Date_Time library is available,
|
||||
ax_cv_boost_date_time,
|
||||
[AC_LANG_PUSH([C++])
|
||||
AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[@%:@include <boost/date_time/gregorian/gregorian_types.hpp>]],
|
||||
[[using namespace boost::gregorian; date d(2002,Jan,10);
|
||||
return 0;
|
||||
]]),
|
||||
ax_cv_boost_date_time=yes, ax_cv_boost_date_time=no)
|
||||
AC_LANG_POP([C++])
|
||||
])
|
||||
if test "x$ax_cv_boost_date_time" = "xyes"; then
|
||||
AC_DEFINE(HAVE_BOOST_DATE_TIME,,[define if the Boost::Date_Time library is available])
|
||||
BN=boost_date_time
|
||||
if test "x$ax_boost_user_date_time_lib" = "x"; then
|
||||
for ax_lib in $BN $BN-st $BN-mt $BN-mt-s $BN-s \
|
||||
$BN-$CC $BN-$CC-st $BN-$CC-mt $BN-$CC-mt-s $BN-$CC-s \
|
||||
lib$BN lib$BN-st lib$BN-mt lib$BN-mt-s lib$BN-s \
|
||||
lib$BN-$CC lib$BN-$CC-st lib$BN-$CC-mt lib$BN-$CC-mt-s lib$BN-$CC-s \
|
||||
$BN-mgw $BN-mgw $BN-mgw-st $BN-mgw-mt $BN-mgw-mt-s $BN-mgw-s ; do
|
||||
AC_CHECK_LIB($ax_lib, main, [BOOST_DATE_TIME_LIB="-l$ax_lib" AC_SUBST(BOOST_DATE_TIME_LIB) link_date_time="yes" break],
|
||||
[link_date_time="no"])
|
||||
done
|
||||
else
|
||||
for ax_lib in $ax_boost_user_date_time_lib $BN-$ax_boost_user_date_time_lib; do
|
||||
AC_CHECK_LIB($ax_lib, main,
|
||||
[BOOST_DATE_TIME_LIB="-l$ax_lib" AC_SUBST(BOOST_DATE_TIME_LIB) link_date_time="yes" break],
|
||||
[link_date_time="no"])
|
||||
done
|
||||
|
||||
fi
|
||||
if test "x$link_date_time" = "xno"; then
|
||||
AC_MSG_ERROR(Could not link against $ax_lib !)
|
||||
fi
|
||||
fi
|
||||
|
||||
CPPFLAGS="$CPPFLAGS_SAVED"
|
||||
LDFLAGS="$LDFLAGS_SAVED"
|
||||
fi
|
||||
])
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE authenticationClientFactory [
|
||||
|
||||
<!ELEMENT authenticationClientFactory (testAuthentication|
|
||||
webAuthentication)>
|
||||
|
||||
<!ELEMENT testAuthentication (user) >
|
||||
|
||||
<!ELEMENT user EMPTY >
|
||||
<!ATTLIST user login CDATA #REQUIRED >
|
||||
<!ATTLIST user password CDATA #REQUIRED >
|
||||
|
||||
]>
|
||||
<authenticationClientFactory>
|
||||
<testAuthentication>
|
||||
<user login="root" password="q" />
|
||||
</testAuthentication>
|
||||
</authenticationClientFactory>
|
|
@ -1,132 +0,0 @@
|
|||
dnl-----------------------------------------------------------------------------
|
||||
dnl Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
dnl
|
||||
dnl This file is part of the Campcaster project.
|
||||
dnl http://campcaster.sourcefabric.org/
|
||||
dnl
|
||||
dnl Campcaster is free software; you can redistribute it and/or modify
|
||||
dnl it under the terms of the GNU General Public License as published by
|
||||
dnl the Free Software Foundation; either version 2 of the License, or
|
||||
dnl (at your option) any later version.
|
||||
dnl
|
||||
dnl Campcaster is distributed in the hope that it will be useful,
|
||||
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
dnl GNU General Public License for more details.
|
||||
dnl
|
||||
dnl You should have received a copy of the GNU General Public License
|
||||
dnl along with Campcaster; if not, write to the Free Software
|
||||
dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
dnl
|
||||
dnl-----------------------------------------------------------------------------
|
||||
|
||||
dnl-----------------------------------------------------------------------------
|
||||
dnl NOTE: Run all configure related scripts from the tmp directory of the
|
||||
dnl project.
|
||||
dnl This is due to the fact that configure spreads a lot of trash around,
|
||||
dnl like atom4te cache directories, config.* files, etc. into the directory
|
||||
dnl it is being run from. We clearly don't want these in our base directory.
|
||||
dnl-----------------------------------------------------------------------------
|
||||
AC_INIT(StorageClient, 0.0, bugs@campware.org)
|
||||
AC_PREREQ(2.59)
|
||||
AC_COPYRIGHT([Copyright (c) 2010 Sourcefabric O.P.S. under the GNU GPL])
|
||||
AC_REVISION($Revision$)
|
||||
|
||||
AC_CONFIG_SRCDIR(../include/LiveSupport/SchedulerClient/SchedulerClientFactory.h)
|
||||
|
||||
AC_CONFIG_HEADERS(configure.h)
|
||||
AC_PROG_CXX()
|
||||
|
||||
AC_CHECK_HEADERS(getopt.h sys/time.h)
|
||||
|
||||
AC_CHECK_HEADERS(libtar.h)
|
||||
|
||||
|
||||
dnl-----------------------------------------------------------------------------
|
||||
dnl specify whether debug info should be compiled into the executable
|
||||
dnl-----------------------------------------------------------------------------
|
||||
AC_SUBST(CXXFLAGS)
|
||||
|
||||
AC_ARG_ENABLE([debug],
|
||||
AC_HELP_STRING([--enable-debug], [compile with debug info (no)]),
|
||||
[],
|
||||
[enable_debug=no])
|
||||
|
||||
if test "x${enable_debug}" = "xyes"; then
|
||||
CXXFLAGS="-g -O0"
|
||||
AC_DEFINE( YDEBUG, 1, [Debug is on] )
|
||||
else
|
||||
CXXFLAGS="-O3"
|
||||
fi
|
||||
|
||||
|
||||
AC_MSG_RESULT([using compiler options: ${CXXFLAGS}])
|
||||
|
||||
|
||||
dnl-----------------------------------------------------------------------------
|
||||
dnl specify the pkg-config path
|
||||
dnl-----------------------------------------------------------------------------
|
||||
AC_ARG_WITH([pkg-config-path],
|
||||
AC_HELP_STRING([--with-pkg-config-path],
|
||||
[use the pkg-config path (prefix/lib/pkgconfig)]),
|
||||
[PKG_CONFIG_PATH=${withval}],
|
||||
[PKG_CONFIG_PATH=${prefix}/lib/pkgconfig:$PKG_CONFIG_PATH])
|
||||
|
||||
AC_MSG_RESULT([using pkg-config path: ${PKG_CONFIG_PATH}])
|
||||
|
||||
export PKG_CONFIG_PATH
|
||||
|
||||
export PATH=${prefix}/bin:${PATH}
|
||||
|
||||
|
||||
AX_BOOST_BASE([1.33.1])
|
||||
if test "x${BOOST_CPPFLAGS}" != "x"; then
|
||||
AX_BOOST_DATE_TIME
|
||||
if test "x${BOOST_DATE_TIME_LIB}" = "x"; then
|
||||
AC_MSG_ERROR([Boost date-time library not found])
|
||||
fi
|
||||
else
|
||||
AC_MSG_ERROR([Boost library >= 1.33.1 not found])
|
||||
fi
|
||||
|
||||
PKG_CHECK_MODULES(LIBXMLPP,[libxml++-2.6 >= 2.8.1])
|
||||
AC_SUBST(LIBXMLPP_CFLAGS)
|
||||
AC_SUBST(LIBXMLPP_LIBS)
|
||||
|
||||
AC_CHECK_CURL(7.12.3)
|
||||
AC_SUBST(CURL_CFLAGS)
|
||||
AC_SUBST(CURL_LIBS)
|
||||
|
||||
AC_CHECK_TAGLIB(1.3.1)
|
||||
AC_SUBST(TAGLIB_CFLAGS)
|
||||
AC_SUBST(TAGLIB_LIBS)
|
||||
|
||||
AC_CHECK_ICU(3.0)
|
||||
AC_SUBST(ICU_CFLAGS)
|
||||
AC_SUBST(ICU_CXXFLAGS)
|
||||
AC_SUBST(ICU_LIBS)
|
||||
|
||||
AC_PATH_PROG(GENRB, genrb)
|
||||
AC_SUBST(GENRB)
|
||||
|
||||
|
||||
dnl-----------------------------------------------------------------------------
|
||||
dnl enable compilaton for code coverage data
|
||||
dnl-----------------------------------------------------------------------------
|
||||
AC_SUBST(COVERAGE_CXXFLAGS)
|
||||
|
||||
AC_ARG_ENABLE( coverage,
|
||||
[ --enable-coverage enable code coverage data generaton (no) ],
|
||||
ENABLE_COVERAGE=${enableval}, ENABLE_COVERAGE="no" )
|
||||
|
||||
if test "x${ENABLE_COVERAGE}" == "xyes" ; then
|
||||
COVERAGE_CXXFLAGS="-fprofile-arcs -ftest-coverage"
|
||||
AC_MSG_RESULT([compiling in code coverage mode])
|
||||
else
|
||||
AC_MSG_RESULT([not compiling in code coverage mode])
|
||||
fi
|
||||
|
||||
|
||||
AC_CONFIG_FILES(../Makefile:../etc/Makefile.in)
|
||||
|
||||
AC_OUTPUT()
|
File diff suppressed because it is too large
Load Diff
|
@ -1,18 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE schedulerClientFactory [
|
||||
|
||||
<!ELEMENT schedulerClientFactory (schedulerDaemonXmlRpcClient) >
|
||||
|
||||
<!ELEMENT schedulerDaemonXmlRpcClient EMPTY >
|
||||
<!ATTLIST schedulerDaemonXmlRpcClient xmlRpcHost CDATA #REQUIRED >
|
||||
<!ATTLIST schedulerDaemonXmlRpcClient xmlRpcPort NMTOKEN #REQUIRED >
|
||||
<!ATTLIST schedulerDaemonXmlRpcClient xmlRpcUri CDATA #REQUIRED >
|
||||
|
||||
]>
|
||||
<schedulerClientFactory>
|
||||
<schedulerDaemonXmlRpcClient xmlRpcHost = "localhost"
|
||||
xmlRpcPort = "3344"
|
||||
xmlRpcUri = "/RC2"
|
||||
/>
|
||||
</schedulerClientFactory>
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE schedulerClientFactory [
|
||||
|
||||
<!ELEMENT schedulerClientFactory (schedulerDaemonXmlRpcClient) >
|
||||
|
||||
<!ELEMENT schedulerDaemonXmlRpcClient EMPTY >
|
||||
<!ATTLIST schedulerDaemonXmlRpcClient xmlRpcHost CDATA #REQUIRED >
|
||||
<!ATTLIST schedulerDaemonXmlRpcClient xmlRpcPort NMTOKEN #REQUIRED >
|
||||
<!ATTLIST schedulerDaemonXmlRpcClient xmlRpcUri CDATA #REQUIRED >
|
||||
|
||||
]>
|
||||
<schedulerClientFactory>
|
||||
<schedulerDaemonXmlRpcClient xmlRpcHost = "ls_scheduler_host"
|
||||
xmlRpcPort = "ls_scheduler_port"
|
||||
xmlRpcUri = "/ls_scheduler_xmlRpcPrefix"
|
||||
/>
|
||||
</schedulerClientFactory>
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE schedulerDaemonXmlRpcClient [
|
||||
|
||||
<!ELEMENT schedulerDaemonXmlRpcClient EMPTY >
|
||||
<!ATTLIST schedulerDaemonXmlRpcClient xmlRpcHost CDATA #REQUIRED >
|
||||
<!ATTLIST schedulerDaemonXmlRpcClient xmlRpcPort NMTOKEN #REQUIRED >
|
||||
<!ATTLIST schedulerDaemonXmlRpcClient xmlRpcUri CDATA #REQUIRED >
|
||||
|
||||
]>
|
||||
<schedulerDaemonXmlRpcClient xmlRpcHost = "localhost"
|
||||
xmlRpcPort = "3344"
|
||||
xmlRpcUri = "/RC2"
|
||||
/>
|
|
@ -1,13 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE schedulerDaemonXmlRpcClient [
|
||||
|
||||
<!ELEMENT schedulerDaemonXmlRpcClient EMPTY >
|
||||
<!ATTLIST schedulerDaemonXmlRpcClient xmlRpcHost CDATA #REQUIRED >
|
||||
<!ATTLIST schedulerDaemonXmlRpcClient xmlRpcPort NMTOKEN #REQUIRED >
|
||||
<!ATTLIST schedulerDaemonXmlRpcClient xmlRpcUri CDATA #REQUIRED >
|
||||
|
||||
]>
|
||||
<schedulerDaemonXmlRpcClient xmlRpcHost = "ls_scheduler_host"
|
||||
xmlRpcPort = "ls_scheduler_port"
|
||||
xmlRpcUri = "/ls_scheduler_xmlRpcPrefix"
|
||||
/>
|
|
@ -1,182 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
|
||||
This file is part of the Campcaster project.
|
||||
http://campcaster.sourcefabric.org/
|
||||
|
||||
Campcaster is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Campcaster is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Campcaster; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef LiveSupport_SchedulerClient_SchedulerClientFactory_h
|
||||
#define LiveSupport_SchedulerClient_SchedulerClientFactory_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
#endif
|
||||
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
#include "LiveSupport/Core/Configurable.h"
|
||||
#include "LiveSupport/SchedulerClient/SchedulerClientInterface.h"
|
||||
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace SchedulerClient {
|
||||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
||||
/* =================================================================== macros */
|
||||
|
||||
|
||||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* The factory to create SchedulerClientInterface objects.
|
||||
*
|
||||
* This object has to be configured with an XML configuration element
|
||||
* called schedulerClientFactory. This element contains a child element
|
||||
* specifying and configuring the kind of SchedulerClient that the
|
||||
* factory builds.
|
||||
* Currently only one kind of client, SchedulerDaemonXmlRpcClient is
|
||||
* supported by this factory.
|
||||
*
|
||||
* An schedulerClientFactory configuration element may look like
|
||||
* the following:
|
||||
*
|
||||
* <pre><code>
|
||||
* <schedulerClientFactory>
|
||||
* <schedulerDaemonXmlRpcClient>
|
||||
* ...
|
||||
* </schedulerDaemonXmlRpcClient>
|
||||
* </schedulerClientFactory>
|
||||
* </code></pre>
|
||||
*
|
||||
* For detais of the schedulerDaemonXmlRpcClient element, see the
|
||||
* documentation for the SchedulerDaemonXmlRpcClient class.
|
||||
*
|
||||
* The DTD for the above element is:
|
||||
*
|
||||
* <pre><code>
|
||||
* <!ELEMENT schedulerClientFactory (schedulerDaemonXmlRpcClient) >
|
||||
* </code></pre>
|
||||
*
|
||||
* @see SchedulerDaemonXmlRpcClient
|
||||
*/
|
||||
class SchedulerClientFactory : virtual public Configurable
|
||||
{
|
||||
private:
|
||||
/**
|
||||
* The name of the configuration XML elmenent used by this object.
|
||||
*/
|
||||
static const std::string configElementNameStr;
|
||||
|
||||
/**
|
||||
* The singleton instance of this object.
|
||||
*/
|
||||
static Ptr<SchedulerClientFactory>::Ref singleton;
|
||||
|
||||
/**
|
||||
* The authentication client created by this factory.
|
||||
*/
|
||||
Ptr<SchedulerClientInterface>::Ref schedulerClient;
|
||||
|
||||
/**
|
||||
* The default constructor.
|
||||
*/
|
||||
SchedulerClientFactory(void) throw ()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
/**
|
||||
* A virtual destructor, as this class has virtual functions.
|
||||
*/
|
||||
virtual
|
||||
~SchedulerClientFactory(void) throw ()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name of the XML element this object expects
|
||||
* to be sent to a call to configure().
|
||||
*
|
||||
* @return the name of the expected XML configuration element.
|
||||
*/
|
||||
static const std::string
|
||||
getConfigElementName(void) throw ()
|
||||
{
|
||||
return configElementNameStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the singleton instance of this object.
|
||||
*
|
||||
* @return the singleton instance of this object.
|
||||
*/
|
||||
static Ptr<SchedulerClientFactory>::Ref
|
||||
getInstance() throw ();
|
||||
|
||||
/**
|
||||
* Configure the object based on the XML element supplied.
|
||||
*
|
||||
* @param element the XML element to configure the object from.
|
||||
* @exception std::invalid_argument if the supplied XML element
|
||||
* contains bad configuraiton information
|
||||
* @exception std::logic_error if the object has already
|
||||
* been configured, and can not be reconfigured.
|
||||
*/
|
||||
virtual void
|
||||
configure(const xmlpp::Element & element)
|
||||
throw (std::invalid_argument,
|
||||
std::logic_error);
|
||||
|
||||
/**
|
||||
* Return a scheduler client.
|
||||
*
|
||||
* @return the appropriate scheduler client, according to the
|
||||
* configuration of this factory.
|
||||
*/
|
||||
Ptr<SchedulerClientInterface>::Ref
|
||||
getSchedulerClient(void) throw ()
|
||||
{
|
||||
return schedulerClient;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
||||
|
||||
/* ====================================================== function prototypes */
|
||||
|
||||
|
||||
} // namespace SchedulerClient
|
||||
} // namespace LiveSupport
|
||||
|
||||
#endif // LiveSupport_SchedulerClient_SchedulerClientFactory_h
|
||||
|
|
@ -1,276 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
|
||||
This file is part of the Campcaster project.
|
||||
http://campcaster.sourcefabric.org/
|
||||
|
||||
Campcaster is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Campcaster is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Campcaster; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef LiveSupport_SchedulerClient_SchedulerClientInterface_h
|
||||
#define LiveSupport_SchedulerClient_SchedulerClientInterface_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
#endif
|
||||
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <stdexcept>
|
||||
#include <vector>
|
||||
#include "boost/date_time/posix_time/posix_time.hpp"
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
#include "LiveSupport/Core/UniqueId.h"
|
||||
#include "LiveSupport/Core/SessionId.h"
|
||||
#include "LiveSupport/Core/ScheduleEntry.h"
|
||||
#include "LiveSupport/Core/XmlRpcException.h"
|
||||
#include "LiveSupport/Core/Playlist.h"
|
||||
#include "LiveSupport/Core/SearchCriteria.h"
|
||||
#include "LiveSupport/Core/AsyncState.h"
|
||||
#include "LiveSupport/Core/SearchCriteria.h"
|
||||
#include "LiveSupport/Core/AsyncState.h"
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace SchedulerClient {
|
||||
|
||||
using namespace boost::posix_time;
|
||||
using namespace LiveSupport::Core;
|
||||
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
||||
/* =================================================================== macros */
|
||||
|
||||
|
||||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* An interface to access the scheduler daemon as a client.
|
||||
*/
|
||||
class SchedulerClientInterface
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Return the XML-RPC host the client connects to.
|
||||
*
|
||||
* @return the XML-RPC host the client connects to.
|
||||
*/
|
||||
virtual Ptr<const std::string>::Ref
|
||||
getXmlRpcHost(void) const throw () = 0;
|
||||
|
||||
/**
|
||||
* Return the XML-RPC port the client connects to.
|
||||
*
|
||||
* @return the XML-RPC port the client connects to.
|
||||
*/
|
||||
virtual unsigned int
|
||||
getXmlRpcPort(void) const throw () = 0;
|
||||
|
||||
/**
|
||||
* Return the XML-RPC URI prefix used when connecting to the scheduler.
|
||||
*
|
||||
* @return the XML-RPC URI prefix.
|
||||
*/
|
||||
virtual Ptr<const std::string>::Ref
|
||||
getXmlRpcUriPrefix(void) const throw () = 0;
|
||||
|
||||
/**
|
||||
* Return the version string for the scheduler this client
|
||||
* is connected to.
|
||||
*
|
||||
* @return the version string of the scheduler daemon.
|
||||
* @exception XmlRpcException in case of XML-RPC errors.
|
||||
*/
|
||||
virtual Ptr<const std::string>::Ref
|
||||
getVersion(void) throw (XmlRpcException)
|
||||
= 0;
|
||||
|
||||
/**
|
||||
* Return the current time at the scheduler server.
|
||||
*
|
||||
* @return the current time at the scheduler server.
|
||||
* @exception XmlRpcException in case of XML-RPC errors.
|
||||
*/
|
||||
virtual Ptr<const ptime>::Ref
|
||||
getSchedulerTime(void) throw (XmlRpcException)
|
||||
= 0;
|
||||
|
||||
/**
|
||||
* Schedule a playlist at a given time.
|
||||
*
|
||||
* @param sessionId a valid, authenticated session id.
|
||||
* @param playlistId the id of the playlist to schedule.
|
||||
* @param playtime the time for which to schedule.
|
||||
* @return the schedule entry id for which the playlist has been
|
||||
* scheduled.
|
||||
* @exception XmlRpcException in case of XML-RPC errors.
|
||||
*/
|
||||
virtual Ptr<UniqueId>::Ref
|
||||
uploadPlaylist(Ptr<SessionId>::Ref sessionId,
|
||||
Ptr<UniqueId>::Ref playlistId,
|
||||
Ptr<ptime>::Ref playtime)
|
||||
throw (XmlRpcException)
|
||||
= 0;
|
||||
|
||||
/**
|
||||
* Return the scheduled entries for a specified time interval.
|
||||
*
|
||||
* @param sessionId a valid, authenticated session id.
|
||||
* @param from the start of the interval, inclusive
|
||||
* @param to the end of the interval, exclusive
|
||||
* @return a vector of the schedule entries for the time period.
|
||||
* @exception XmlRpcException in case of XML-RPC errors.
|
||||
*/
|
||||
virtual Ptr<std::vector<Ptr<ScheduleEntry>::Ref> >::Ref
|
||||
displaySchedule(Ptr<SessionId>::Ref sessionId,
|
||||
Ptr<ptime>::Ref from,
|
||||
Ptr<ptime>::Ref to)
|
||||
throw (XmlRpcException)
|
||||
= 0;
|
||||
|
||||
/**
|
||||
* Remove a scheduled item.
|
||||
*
|
||||
* @param sessionId a valid, authenticated session id.
|
||||
* @param scheduledEntryId the id of the scheduled entry to remove.
|
||||
* @exception XmlRpcException in case of XML-RPC errors.
|
||||
*/
|
||||
virtual void
|
||||
removeFromSchedule(Ptr<SessionId>::Ref sessionId,
|
||||
Ptr<UniqueId>::Ref scheduleEntryId)
|
||||
throw (XmlRpcException)
|
||||
= 0;
|
||||
|
||||
/**
|
||||
* Start the schedule backup creation process.
|
||||
* This will produce a combined backup, including a storage portion.
|
||||
* The scheduler daemon first calls the storage server, and gets
|
||||
* a storage backup archive file from it; then it adds the schedule
|
||||
* backup to this archive file.
|
||||
*
|
||||
* @param sessionId a valid, authenticated session id.
|
||||
* @param criteria the search criteria for the storage portion
|
||||
* of the backup.
|
||||
* @param fromTime entries are included in the schedule backup
|
||||
* starting from this time.
|
||||
* @param toTime entries are included in the schedule backup
|
||||
* up to but not including this time.
|
||||
* @return a token which can be used to query the backup process.
|
||||
* @exception XmlRpcException if there is a problem with the XML-RPC
|
||||
* call.
|
||||
*/
|
||||
virtual Ptr<Glib::ustring>::Ref
|
||||
createBackupOpen(Ptr<SessionId>::Ref sessionId,
|
||||
Ptr<SearchCriteria>::Ref criteria,
|
||||
Ptr<ptime>::Ref fromTime,
|
||||
Ptr<ptime>::Ref toTime) const
|
||||
throw (XmlRpcException)
|
||||
= 0;
|
||||
|
||||
/**
|
||||
* Check on the progress of the schedule backup creation process.
|
||||
*
|
||||
* @param token the token obtained from createBackupOpen().
|
||||
* @param url return parameter;
|
||||
* if a finishedState is returned, it contains the
|
||||
* URL of the created backup file.
|
||||
* @param path return parameter;
|
||||
* if a finishedState is returned, it contains the
|
||||
* local access path of the created backup file.
|
||||
* @param errorMessage return parameter;
|
||||
* if a failedState is returned, it contains the
|
||||
* fault string.
|
||||
* @return the state of the backup process: one of pendingState,
|
||||
* finishedState, or failedState.
|
||||
* @exception XmlRpcException if there is a problem with the XML-RPC
|
||||
* call.
|
||||
*/
|
||||
virtual AsyncState
|
||||
createBackupCheck(const Glib::ustring & token,
|
||||
Ptr<const Glib::ustring>::Ref & url,
|
||||
Ptr<const Glib::ustring>::Ref & path,
|
||||
Ptr<const Glib::ustring>::Ref & errorMessage) const
|
||||
throw (XmlRpcException)
|
||||
= 0;
|
||||
|
||||
/**
|
||||
* Close the schedule backup creation process.
|
||||
*
|
||||
* @param token the token obtained from createBackupOpen().
|
||||
* @exception XmlRpcException if there is a problem with the XML-RPC
|
||||
* call.
|
||||
*/
|
||||
virtual void
|
||||
createBackupClose(const Glib::ustring & token) const
|
||||
throw (XmlRpcException)
|
||||
= 0;
|
||||
|
||||
/**
|
||||
* Restore a schedule backup.
|
||||
*
|
||||
* All playlist IDs contained in the backup should already be in the
|
||||
* storage. If this is a combined backup, with both storage and
|
||||
* schedule components, then restore this backup to the storage
|
||||
* first, and then call this function.
|
||||
*
|
||||
* @param sessionId a valid session ID to identify the user.
|
||||
* @param path the location of the archive to upload.
|
||||
* @exception XmlRpcException if there is an error.
|
||||
*/
|
||||
virtual void
|
||||
restoreBackup(Ptr<SessionId>::Ref sessionId,
|
||||
Ptr<const Glib::ustring>::Ref path)
|
||||
throw (XmlRpcException)
|
||||
= 0;
|
||||
|
||||
/**
|
||||
* Stop the scheduler's audio player.
|
||||
*
|
||||
* @param sessionId a valid session ID to identify the user.
|
||||
* @exception XmlRpcException if there is an error.
|
||||
*/
|
||||
virtual void
|
||||
stopCurrentlyPlaying(Ptr<SessionId>::Ref sessionId)
|
||||
throw (XmlRpcException) = 0;
|
||||
|
||||
/**
|
||||
* A virtual destructor, as this class has virtual functions.
|
||||
*/
|
||||
virtual
|
||||
~SchedulerClientInterface(void) throw ()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
||||
|
||||
/* ====================================================== function prototypes */
|
||||
|
||||
|
||||
} // namespace SchedulerClient
|
||||
} // namespace LiveSupport
|
||||
|
||||
#endif // LiveSupport_SchedulerClient_SchedulerClientInterface_h
|
||||
|
|
@ -1 +0,0 @@
|
|||
keep me
|
|
@ -1,107 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
|
||||
This file is part of the Campcaster project.
|
||||
http://campcaster.sourcefabric.org/
|
||||
|
||||
Campcaster is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Campcaster is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Campcaster; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include "LiveSupport/SchedulerClient/SchedulerClientFactory.h"
|
||||
#include "SchedulerDaemonXmlRpcClient.h"
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::SchedulerClient;
|
||||
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the config element for this class
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string SchedulerClientFactory::configElementNameStr =
|
||||
"schedulerClientFactory";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The singleton instance of SchedulerClientFactory
|
||||
*----------------------------------------------------------------------------*/
|
||||
Ptr<SchedulerClientFactory>::Ref SchedulerClientFactory::singleton;
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Return the singleton instance to SchedulerClientFactory
|
||||
*----------------------------------------------------------------------------*/
|
||||
Ptr<SchedulerClientFactory>::Ref
|
||||
SchedulerClientFactory :: getInstance(void) throw ()
|
||||
{
|
||||
if (!singleton.get()) {
|
||||
singleton.reset(new SchedulerClientFactory());
|
||||
}
|
||||
|
||||
return singleton;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Configure the test authentication client.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SchedulerClientFactory :: configure(const xmlpp::Element & element)
|
||||
throw (std::invalid_argument,
|
||||
std::logic_error)
|
||||
{
|
||||
if (element.get_name() != configElementNameStr) {
|
||||
std::string eMsg = "Bad configuration element ";
|
||||
eMsg += element.get_name();
|
||||
throw std::invalid_argument(eMsg);
|
||||
}
|
||||
|
||||
schedulerClient.reset();
|
||||
|
||||
// try to look for a SchedulerDaemonXmlRpcClient configuration element
|
||||
xmlpp::Node::NodeList nodes =
|
||||
element.get_children(
|
||||
SchedulerDaemonXmlRpcClient::getConfigElementName());
|
||||
if (nodes.size() >= 1) {
|
||||
const xmlpp::Element * configElement =
|
||||
dynamic_cast<const xmlpp::Element*> (*(nodes.begin()));
|
||||
|
||||
Ptr<SchedulerDaemonXmlRpcClient>::Ref client;
|
||||
client.reset(new SchedulerDaemonXmlRpcClient());
|
||||
client->configure(*configElement);
|
||||
|
||||
schedulerClient = client;
|
||||
return;
|
||||
}
|
||||
|
||||
throw std::invalid_argument("no scheduler client configuration found");
|
||||
}
|
||||
|
|
@ -1,114 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
|
||||
This file is part of the Campcaster project.
|
||||
http://campcaster.sourcefabric.org/
|
||||
|
||||
Campcaster is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Campcaster is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Campcaster; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#else
|
||||
#error "Need unistd.h"
|
||||
#endif
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
#include "SchedulerClientFactoryTest.h"
|
||||
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::SchedulerClient;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(SchedulerClientFactoryTest);
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the scheduler client.
|
||||
*/
|
||||
static const std::string configFileName = "schedulerClientFactory.xml";
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Set up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SchedulerClientFactoryTest :: setUp(void) throw ()
|
||||
{
|
||||
schedulerClientFactory = SchedulerClientFactory::getInstance();
|
||||
|
||||
// TODO: only configure, if not configured earlier
|
||||
try {
|
||||
xmlpp::DomParser parser;
|
||||
const xmlpp::Document * document = getConfigDocument(parser,
|
||||
configFileName);
|
||||
const xmlpp::Element * root = document->get_root_node();
|
||||
|
||||
schedulerClientFactory->configure(*root);
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
CPPUNIT_FAIL("semantic error in configuration file");
|
||||
} catch (xmlpp::exception &e) {
|
||||
CPPUNIT_FAIL("error parsing configuration file");
|
||||
}
|
||||
|
||||
schedulerClient = schedulerClientFactory->getSchedulerClient();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Clean up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SchedulerClientFactoryTest :: tearDown(void) throw ()
|
||||
{
|
||||
schedulerClientFactory.reset();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Test to see if we can log on and off
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SchedulerClientFactoryTest :: firstTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
CPPUNIT_ASSERT(schedulerClient.get());
|
||||
|
||||
Ptr<const std::string>::Ref version = schedulerClient->getVersion();
|
||||
CPPUNIT_ASSERT(version.get());
|
||||
}
|
||||
|
|
@ -1,113 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
|
||||
This file is part of the Campcaster project.
|
||||
http://campcaster.sourcefabric.org/
|
||||
|
||||
Campcaster is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Campcaster is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Campcaster; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef SchedulerClientFactoryTest_h
|
||||
#define SchedulerClientFactoryTest_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
#endif
|
||||
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include "LiveSupport/Core/BaseTestMethod.h"
|
||||
#include "LiveSupport/SchedulerClient/SchedulerClientFactory.h"
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace SchedulerClient {
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
||||
/* =================================================================== macros */
|
||||
|
||||
|
||||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* Unit test for the SchedulerClientFactoryTest class.
|
||||
*
|
||||
* @see SchedulerClientFactoryTest
|
||||
*/
|
||||
class SchedulerClientFactoryTest : public BaseTestMethod
|
||||
{
|
||||
CPPUNIT_TEST_SUITE(SchedulerClientFactoryTest);
|
||||
CPPUNIT_TEST(firstTest);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
private:
|
||||
/**
|
||||
* The SchedulerClientFactory instance to test.
|
||||
*/
|
||||
Ptr<SchedulerClientFactory>::Ref schedulerClientFactory;
|
||||
|
||||
/**
|
||||
* The SchedulerClientInterface returned by the factory.
|
||||
*/
|
||||
Ptr<SchedulerClientInterface>::Ref schedulerClient;
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* A simple test.
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
firstTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Set up the environment for the test case.
|
||||
*/
|
||||
void
|
||||
setUp(void) throw ();
|
||||
|
||||
/**
|
||||
* Clean up the environment after the test case.
|
||||
*/
|
||||
void
|
||||
tearDown(void) throw ();
|
||||
};
|
||||
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
||||
|
||||
/* ====================================================== function prototypes */
|
||||
|
||||
|
||||
} // namespace SchedulerClient
|
||||
} // namespace LiveSupport
|
||||
|
||||
#endif // SchedulerClientFactoryTest_h
|
||||
|
|
@ -1,589 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
|
||||
This file is part of the Campcaster project.
|
||||
http://campcaster.sourcefabric.org/
|
||||
|
||||
Campcaster is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Campcaster is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Campcaster; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
#include <XmlRpcClient.h>
|
||||
#include <XmlRpcValue.h>
|
||||
|
||||
#include "LiveSupport/Core/TimeConversion.h"
|
||||
#include "LiveSupport/Core/XmlRpcTools.h"
|
||||
#include "LiveSupport/Core/XmlRpcInvalidArgumentException.h"
|
||||
#include "LiveSupport/Core/XmlRpcCommunicationException.h"
|
||||
#include "LiveSupport/Core/XmlRpcMethodFaultException.h"
|
||||
#include "LiveSupport/Core/XmlRpcMethodResponseException.h"
|
||||
#include "SchedulerDaemonXmlRpcClient.h"
|
||||
|
||||
using namespace boost::posix_time;
|
||||
using namespace XmlRpc;
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::SchedulerClient;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ configuration file constants */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the config element for this class
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string SchedulerDaemonXmlRpcClient::configElementNameStr
|
||||
= "schedulerDaemonXmlRpcClient";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the config element attribute for the XML-RPC host
|
||||
*----------------------------------------------------------------------------*/
|
||||
static const std::string xmlRpcHostAttrName = "xmlRpcHost";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the config element attribute for the XML-RPC port
|
||||
*----------------------------------------------------------------------------*/
|
||||
static const std::string xmlRpcPortAttrName = "xmlRpcPort";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the config element attribute for the XML-RPC URI
|
||||
*----------------------------------------------------------------------------*/
|
||||
static const std::string xmlRpcUriAttrName = "xmlRpcUri";
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Configure the test storage client.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SchedulerDaemonXmlRpcClient :: configure(const xmlpp::Element & element)
|
||||
throw (std::invalid_argument,
|
||||
std::logic_error)
|
||||
{
|
||||
if (element.get_name() != configElementNameStr) {
|
||||
std::string eMsg = "Bad configuration element ";
|
||||
eMsg += element.get_name();
|
||||
throw std::invalid_argument(eMsg);
|
||||
}
|
||||
|
||||
const xmlpp::Attribute * attribute = 0;
|
||||
std::stringstream strStr;
|
||||
|
||||
// get the XML-RPC host name
|
||||
if (!(attribute = element.get_attribute(xmlRpcHostAttrName))) {
|
||||
std::string eMsg = "Missing attribute ";
|
||||
eMsg += xmlRpcHostAttrName;
|
||||
throw std::invalid_argument(eMsg);
|
||||
}
|
||||
xmlRpcHost.reset(new std::string(attribute->get_value()));
|
||||
|
||||
// get the XML-RPC port
|
||||
if (!(attribute = element.get_attribute(xmlRpcPortAttrName))) {
|
||||
std::string eMsg = "Missing attribute ";
|
||||
eMsg += xmlRpcPortAttrName;
|
||||
throw std::invalid_argument(eMsg);
|
||||
}
|
||||
strStr.str(attribute->get_value());
|
||||
strStr >> xmlRpcPort;
|
||||
|
||||
// get the XML-RPC URI
|
||||
if (!(attribute = element.get_attribute(xmlRpcUriAttrName))) {
|
||||
std::string eMsg = "Missing attribute ";
|
||||
eMsg += xmlRpcUriAttrName;
|
||||
throw std::invalid_argument(eMsg);
|
||||
}
|
||||
xmlRpcUri.reset(new std::string(attribute->get_value()));
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Get the version string from the scheduler daemon
|
||||
*----------------------------------------------------------------------------*/
|
||||
Ptr<const std::string>::Ref
|
||||
SchedulerDaemonXmlRpcClient :: getVersion(void)
|
||||
throw (Core::XmlRpcException)
|
||||
{
|
||||
XmlRpcValue xmlRpcParams;
|
||||
XmlRpcValue xmlRpcResult;
|
||||
Ptr<std::string>::Ref result;
|
||||
|
||||
XmlRpcClient xmlRpcClient(xmlRpcHost->c_str(),
|
||||
xmlRpcPort,
|
||||
xmlRpcUri->c_str(),
|
||||
false);
|
||||
|
||||
xmlRpcResult.clear();
|
||||
if (!xmlRpcClient.execute("getVersion", xmlRpcParams, xmlRpcResult)) {
|
||||
throw Core::XmlRpcCommunicationException(
|
||||
"cannot execute XML-RPC method 'getVersion'");
|
||||
}
|
||||
|
||||
if (xmlRpcClient.isFault()) {
|
||||
std::stringstream eMsg;
|
||||
eMsg << "XML-RPC method 'getVersion' returned error message:\n"
|
||||
<< xmlRpcResult;
|
||||
throw Core::XmlRpcMethodFaultException(eMsg.str());
|
||||
}
|
||||
|
||||
xmlRpcClient.close();
|
||||
|
||||
if (!xmlRpcResult.hasMember("version")
|
||||
|| xmlRpcResult["version"].getType() != XmlRpcValue::TypeString) {
|
||||
std::stringstream eMsg;
|
||||
eMsg << "XML-RPC method 'getVersion' returned unexpected value:\n"
|
||||
<< xmlRpcResult;
|
||||
throw Core::XmlRpcMethodResponseException(eMsg.str());
|
||||
}
|
||||
|
||||
result.reset(new std::string(xmlRpcResult["version"]));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Get the current time from the server.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Ptr<const ptime>::Ref
|
||||
SchedulerDaemonXmlRpcClient :: getSchedulerTime(void)
|
||||
throw (Core::XmlRpcException)
|
||||
{
|
||||
XmlRpcValue xmlRpcParams;
|
||||
XmlRpcValue xmlRpcResult;
|
||||
Ptr<const ptime>::Ref result;
|
||||
|
||||
XmlRpcClient xmlRpcClient(xmlRpcHost->c_str(),
|
||||
xmlRpcPort,
|
||||
xmlRpcUri->c_str(),
|
||||
false);
|
||||
|
||||
xmlRpcResult.clear();
|
||||
if (!xmlRpcClient.execute("getSchedulerTime", xmlRpcParams, xmlRpcResult)) {
|
||||
throw Core::XmlRpcCommunicationException(
|
||||
"cannot execute XML-RPC method 'getSchedulerTime'");
|
||||
}
|
||||
|
||||
if (xmlRpcClient.isFault()) {
|
||||
std::stringstream eMsg;
|
||||
eMsg << "XML-RPC method 'getSchedulerTime' returned error message:\n"
|
||||
<< xmlRpcResult;
|
||||
throw Core::XmlRpcMethodFaultException(eMsg.str());
|
||||
}
|
||||
|
||||
xmlRpcClient.close();
|
||||
|
||||
if (!xmlRpcResult.hasMember("schedulerTime")
|
||||
|| xmlRpcResult["schedulerTime"].getType() != XmlRpcValue::TypeDateTime) {
|
||||
std::stringstream eMsg;
|
||||
eMsg << "XML-RPC method 'getSchedulerTime' returned unexpected value:\n"
|
||||
<< xmlRpcResult;
|
||||
throw Core::XmlRpcMethodResponseException(eMsg.str());
|
||||
}
|
||||
|
||||
struct tm time = xmlRpcResult["schedulerTime"];
|
||||
|
||||
try {
|
||||
result = TimeConversion::tmToPtime(&time);
|
||||
} catch (std::out_of_range &e) {
|
||||
throw Core::XmlRpcException("time conversion error", e);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Schedule a playlist in the scheduler.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Ptr<UniqueId>::Ref
|
||||
SchedulerDaemonXmlRpcClient :: uploadPlaylist(
|
||||
Ptr<SessionId>::Ref sessionId,
|
||||
Ptr<UniqueId>::Ref playlistId,
|
||||
Ptr<boost::posix_time::ptime>::Ref playtime)
|
||||
throw (Core::XmlRpcException)
|
||||
{
|
||||
Ptr<UniqueId>::Ref scheduleEntryId;
|
||||
|
||||
XmlRpcValue xmlRpcParams;
|
||||
XmlRpcValue xmlRpcResult;
|
||||
|
||||
XmlRpcClient xmlRpcClient(xmlRpcHost->c_str(),
|
||||
xmlRpcPort,
|
||||
xmlRpcUri->c_str(),
|
||||
false);
|
||||
|
||||
XmlRpcTools::sessionIdToXmlRpcValue(sessionId, xmlRpcParams);
|
||||
XmlRpcTools::playlistIdToXmlRpcValue(playlistId, xmlRpcParams);
|
||||
XmlRpcTools::playtimeToXmlRpcValue(playtime, xmlRpcParams);
|
||||
|
||||
xmlRpcResult.clear();
|
||||
if (!xmlRpcClient.execute("uploadPlaylist", xmlRpcParams, xmlRpcResult)) {
|
||||
throw Core::XmlRpcCommunicationException(
|
||||
"cannot execute XML-RPC method 'uploadPlaylist'");
|
||||
}
|
||||
|
||||
if (xmlRpcClient.isFault()) {
|
||||
std::stringstream eMsg;
|
||||
eMsg << "XML-RPC method 'uploadPlaylist' returned error message:\n"
|
||||
<< xmlRpcResult;
|
||||
throw Core::XmlRpcMethodFaultException(eMsg.str());
|
||||
}
|
||||
|
||||
xmlRpcClient.close();
|
||||
|
||||
try {
|
||||
scheduleEntryId = XmlRpcTools::extractScheduleEntryId(xmlRpcResult);
|
||||
} catch (std::invalid_argument &e) {
|
||||
throw Core::XmlRpcInvalidArgumentException(e);
|
||||
}
|
||||
|
||||
return scheduleEntryId;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Return the scheduled items for a time interval
|
||||
*----------------------------------------------------------------------------*/
|
||||
Ptr<std::vector<Ptr<ScheduleEntry>::Ref> >::Ref
|
||||
SchedulerDaemonXmlRpcClient :: displaySchedule(
|
||||
Ptr<SessionId>::Ref sessionId,
|
||||
Ptr<ptime>::Ref from,
|
||||
Ptr<ptime>::Ref to)
|
||||
throw (Core::XmlRpcException)
|
||||
{
|
||||
Ptr<std::vector<Ptr<ScheduleEntry>::Ref> >::Ref entries;
|
||||
|
||||
XmlRpcValue xmlRpcParams;
|
||||
XmlRpcValue xmlRpcResult;
|
||||
|
||||
XmlRpcClient xmlRpcClient(xmlRpcHost->c_str(),
|
||||
xmlRpcPort,
|
||||
xmlRpcUri->c_str(),
|
||||
false);
|
||||
|
||||
XmlRpcTools::sessionIdToXmlRpcValue(sessionId, xmlRpcParams);
|
||||
XmlRpcTools::fromTimeToXmlRpcValue(from, xmlRpcParams);
|
||||
XmlRpcTools::toTimeToXmlRpcValue(to, xmlRpcParams);
|
||||
|
||||
xmlRpcResult.clear();
|
||||
if (!xmlRpcClient.execute("displaySchedule", xmlRpcParams, xmlRpcResult)) {
|
||||
throw Core::XmlRpcCommunicationException(
|
||||
"cannot execute XML-RPC method 'displaySchedule'");
|
||||
}
|
||||
|
||||
if (xmlRpcClient.isFault()) {
|
||||
std::stringstream eMsg;
|
||||
eMsg << "XML-RPC method 'displaySchedule' returned error message:\n"
|
||||
<< xmlRpcResult;
|
||||
throw Core::XmlRpcMethodFaultException(eMsg.str());
|
||||
}
|
||||
|
||||
xmlRpcClient.close();
|
||||
|
||||
try {
|
||||
entries = XmlRpcTools::extractScheduleEntries(xmlRpcResult);
|
||||
std::cout << "SchedulerDaemonXmlRpcClient::displaySchedule entries: " << entries->size() << std::endl;
|
||||
} catch (std::invalid_argument &e) {
|
||||
throw Core::XmlRpcInvalidArgumentException(e);
|
||||
}
|
||||
|
||||
return entries;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Remove a scheduled entry from the schedule.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SchedulerDaemonXmlRpcClient :: removeFromSchedule(
|
||||
Ptr<SessionId>::Ref sessionId,
|
||||
Ptr<UniqueId>::Ref scheduleEntryId)
|
||||
throw (Core::XmlRpcException)
|
||||
{
|
||||
XmlRpcValue xmlRpcParams;
|
||||
XmlRpcValue xmlRpcResult;
|
||||
|
||||
XmlRpcClient xmlRpcClient(xmlRpcHost->c_str(),
|
||||
xmlRpcPort,
|
||||
xmlRpcUri->c_str(),
|
||||
false);
|
||||
|
||||
XmlRpcTools::sessionIdToXmlRpcValue(sessionId, xmlRpcParams);
|
||||
XmlRpcTools::scheduleEntryIdToXmlRpcValue(scheduleEntryId, xmlRpcParams);
|
||||
|
||||
xmlRpcResult.clear();
|
||||
if (!xmlRpcClient.execute("removeFromSchedule",
|
||||
xmlRpcParams,
|
||||
xmlRpcResult)) {
|
||||
throw Core::XmlRpcCommunicationException(
|
||||
"cannot execute XML-RPC method 'removeFromSchedule'");
|
||||
}
|
||||
|
||||
if (xmlRpcClient.isFault()) {
|
||||
std::stringstream eMsg;
|
||||
eMsg << "XML-RPC method 'removeFromSchedule' returned error message:\n"
|
||||
<< xmlRpcResult;
|
||||
throw Core::XmlRpcMethodFaultException(eMsg.str());
|
||||
}
|
||||
|
||||
xmlRpcClient.close();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Start the schedule backup creation process.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Ptr<Glib::ustring>::Ref
|
||||
SchedulerDaemonXmlRpcClient :: createBackupOpen(
|
||||
Ptr<SessionId>::Ref sessionId,
|
||||
Ptr<SearchCriteria>::Ref criteria,
|
||||
Ptr<ptime>::Ref fromTime,
|
||||
Ptr<ptime>::Ref toTime) const
|
||||
throw (Core::XmlRpcException)
|
||||
{
|
||||
XmlRpcValue xmlRpcParams;
|
||||
XmlRpcValue xmlRpcResult;
|
||||
|
||||
XmlRpcClient xmlRpcClient(xmlRpcHost->c_str(),
|
||||
xmlRpcPort,
|
||||
xmlRpcUri->c_str(),
|
||||
false);
|
||||
|
||||
XmlRpcTools::sessionIdToXmlRpcValue(sessionId, xmlRpcParams);
|
||||
XmlRpcTools::searchCriteriaToXmlRpcValue(criteria, xmlRpcParams);
|
||||
XmlRpcTools::fromTimeToXmlRpcValue(fromTime, xmlRpcParams);
|
||||
XmlRpcTools::toTimeToXmlRpcValue(toTime, xmlRpcParams);
|
||||
|
||||
if (!xmlRpcClient.execute("createBackupOpen",
|
||||
xmlRpcParams,
|
||||
xmlRpcResult)) {
|
||||
throw Core::XmlRpcCommunicationException(
|
||||
"cannot execute XML-RPC method 'createBackupOpen'");
|
||||
}
|
||||
|
||||
if (xmlRpcClient.isFault()) {
|
||||
std::stringstream eMsg;
|
||||
eMsg << "XML-RPC method 'createBackupOpen' returned error message:\n"
|
||||
<< xmlRpcResult;
|
||||
throw Core::XmlRpcMethodFaultException(eMsg.str());
|
||||
}
|
||||
|
||||
xmlRpcClient.close();
|
||||
|
||||
Ptr<Glib::ustring>::Ref token;
|
||||
try {
|
||||
token = XmlRpcTools::extractToken(xmlRpcResult);
|
||||
} catch (std::invalid_argument &e) {
|
||||
throw Core::XmlRpcMethodResponseException(e);
|
||||
}
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Check on the progress of the schedule backup creation process.
|
||||
*----------------------------------------------------------------------------*/
|
||||
AsyncState
|
||||
SchedulerDaemonXmlRpcClient :: createBackupCheck(
|
||||
const Glib::ustring & token,
|
||||
Ptr<const Glib::ustring>::Ref & url,
|
||||
Ptr<const Glib::ustring>::Ref & path,
|
||||
Ptr<const Glib::ustring>::Ref & errorMessage) const
|
||||
throw (Core::XmlRpcException)
|
||||
{
|
||||
XmlRpcValue xmlRpcParams;
|
||||
XmlRpcValue xmlRpcResult;
|
||||
|
||||
XmlRpcClient xmlRpcClient(xmlRpcHost->c_str(),
|
||||
xmlRpcPort,
|
||||
xmlRpcUri->c_str(),
|
||||
false);
|
||||
|
||||
Ptr<const Glib::ustring>::Ref tokenPtr(new const Glib::ustring(token));
|
||||
XmlRpcTools::tokenToXmlRpcValue(tokenPtr, xmlRpcParams);
|
||||
|
||||
if (!xmlRpcClient.execute("createBackupCheck",
|
||||
xmlRpcParams,
|
||||
xmlRpcResult)) {
|
||||
throw Core::XmlRpcCommunicationException(
|
||||
"cannot execute XML-RPC method 'createBackupCheck'");
|
||||
}
|
||||
|
||||
if (xmlRpcClient.isFault()) {
|
||||
std::stringstream eMsg;
|
||||
eMsg << "XML-RPC method 'createBackupCheck' returned error message:\n"
|
||||
<< xmlRpcResult;
|
||||
throw Core::XmlRpcMethodFaultException(eMsg.str());
|
||||
}
|
||||
|
||||
xmlRpcClient.close();
|
||||
|
||||
AsyncState state;
|
||||
try {
|
||||
state = XmlRpcTools::extractBackupStatus(xmlRpcResult);
|
||||
} catch (std::invalid_argument &e) {
|
||||
throw Core::XmlRpcMethodResponseException(e);
|
||||
}
|
||||
|
||||
if (state == AsyncState::finishedState) {
|
||||
try {
|
||||
url = XmlRpcTools::extractUrl(xmlRpcResult);
|
||||
path = XmlRpcTools::extractPath(xmlRpcResult);
|
||||
} catch (std::invalid_argument &e) {
|
||||
throw Core::XmlRpcMethodResponseException(e);
|
||||
}
|
||||
} else if (state == AsyncState::failedState) {
|
||||
try {
|
||||
errorMessage = XmlRpcTools::extractFaultString(xmlRpcResult);
|
||||
} catch (std::invalid_argument &e) {
|
||||
throw Core::XmlRpcMethodResponseException(e);
|
||||
}
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
*
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SchedulerDaemonXmlRpcClient :: createBackupClose(
|
||||
const Glib::ustring & token) const
|
||||
throw (Core::XmlRpcException)
|
||||
{
|
||||
XmlRpcValue xmlRpcParams;
|
||||
XmlRpcValue xmlRpcResult;
|
||||
|
||||
XmlRpcClient xmlRpcClient(xmlRpcHost->c_str(),
|
||||
xmlRpcPort,
|
||||
xmlRpcUri->c_str(),
|
||||
false);
|
||||
|
||||
Ptr<const Glib::ustring>::Ref tokenPtr(new const Glib::ustring(token));
|
||||
XmlRpcTools::tokenToXmlRpcValue(tokenPtr, xmlRpcParams);
|
||||
|
||||
if (!xmlRpcClient.execute("createBackupClose",
|
||||
xmlRpcParams,
|
||||
xmlRpcResult)) {
|
||||
throw Core::XmlRpcCommunicationException(
|
||||
"cannot execute XML-RPC method 'createBackupClose'");
|
||||
}
|
||||
|
||||
if (xmlRpcClient.isFault()) {
|
||||
std::stringstream eMsg;
|
||||
eMsg << "XML-RPC method 'createBackupClose' returned error message:\n"
|
||||
<< xmlRpcResult;
|
||||
throw Core::XmlRpcMethodFaultException(eMsg.str());
|
||||
}
|
||||
|
||||
xmlRpcClient.close();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Restore a schedule backup.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SchedulerDaemonXmlRpcClient :: restoreBackup(
|
||||
Ptr<SessionId>::Ref sessionId,
|
||||
Ptr<const Glib::ustring>::Ref path)
|
||||
throw (Core::XmlRpcException)
|
||||
{
|
||||
XmlRpcValue xmlRpcParams;
|
||||
XmlRpcValue xmlRpcResult;
|
||||
|
||||
XmlRpcClient xmlRpcClient(xmlRpcHost->c_str(),
|
||||
xmlRpcPort,
|
||||
xmlRpcUri->c_str(),
|
||||
false);
|
||||
|
||||
XmlRpcTools::sessionIdToXmlRpcValue(sessionId, xmlRpcParams);
|
||||
XmlRpcTools::pathToXmlRpcValue(path, xmlRpcParams);
|
||||
|
||||
xmlRpcResult.clear();
|
||||
if (!xmlRpcClient.execute("restoreBackup",
|
||||
xmlRpcParams,
|
||||
xmlRpcResult)) {
|
||||
throw Core::XmlRpcCommunicationException(
|
||||
"cannot execute XML-RPC method 'restoreBackup'");
|
||||
}
|
||||
|
||||
if (xmlRpcClient.isFault()) {
|
||||
std::stringstream eMsg;
|
||||
eMsg << "XML-RPC method 'restoreBackup' returned error message:\n"
|
||||
<< xmlRpcResult;
|
||||
throw Core::XmlRpcMethodFaultException(eMsg.str());
|
||||
}
|
||||
|
||||
xmlRpcClient.close();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Stop the scheduler's audio player.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SchedulerDaemonXmlRpcClient :: stopCurrentlyPlaying(
|
||||
Ptr<SessionId>::Ref sessionId)
|
||||
throw (Core::XmlRpcException)
|
||||
{
|
||||
XmlRpcValue xmlRpcParams;
|
||||
XmlRpcValue xmlRpcResult;
|
||||
|
||||
XmlRpcClient xmlRpcClient(xmlRpcHost->c_str(),
|
||||
xmlRpcPort,
|
||||
xmlRpcUri->c_str(),
|
||||
false);
|
||||
|
||||
XmlRpcTools::sessionIdToXmlRpcValue(sessionId, xmlRpcParams);
|
||||
|
||||
xmlRpcResult.clear();
|
||||
if (!xmlRpcClient.execute("stopCurrentlyPlaying",
|
||||
xmlRpcParams,
|
||||
xmlRpcResult)) {
|
||||
throw Core::XmlRpcCommunicationException(
|
||||
"cannot execute XML-RPC method 'stopCurrentlyPlaying'");
|
||||
}
|
||||
|
||||
if (xmlRpcClient.isFault()) {
|
||||
std::stringstream eMsg;
|
||||
eMsg << "XML-RPC method 'stopCurrentlyPlaying'"
|
||||
<< " returned error message:\n"
|
||||
<< xmlRpcResult;
|
||||
throw Core::XmlRpcMethodFaultException(eMsg.str());
|
||||
}
|
||||
|
||||
xmlRpcClient.close();
|
||||
}
|
||||
|
|
@ -1,348 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
|
||||
This file is part of the Campcaster project.
|
||||
http://campcaster.sourcefabric.org/
|
||||
|
||||
Campcaster is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Campcaster is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Campcaster; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef SchedulerDaemonXmlRpcClient_h
|
||||
#define SchedulerDaemonXmlRpcClient_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
#endif
|
||||
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <XmlRpcClient.h>
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
#include "LiveSupport/Core/Configurable.h"
|
||||
#include "LiveSupport/Core/Playlist.h"
|
||||
#include "LiveSupport/Core/AudioClip.h"
|
||||
|
||||
#include "LiveSupport/SchedulerClient/SchedulerClientInterface.h"
|
||||
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace SchedulerClient {
|
||||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
||||
/* =================================================================== macros */
|
||||
|
||||
|
||||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* An XML-RPC client to the Scheduler Daemon.
|
||||
*
|
||||
* This object has to be configured with an XML configuration element
|
||||
* called schedulerDaemonXmlRpcClient.
|
||||
*
|
||||
* A schedulerDaemonXmlRpcClient configuration element may look like the
|
||||
* following:
|
||||
*
|
||||
* <pre><code>
|
||||
* <schedulerDaemonXmlRpcClient xmlRpcHost = "localhost"
|
||||
* xmlRpcPort = "3344"
|
||||
* xmlRpcUri = "/RC2"
|
||||
* />
|
||||
* </code></pre>
|
||||
*
|
||||
* The DTD for the above element is:
|
||||
*
|
||||
* <pre><code>
|
||||
* <!ELEMENT schedulerDaemonXmlRpcClient EMPTY >
|
||||
* <!ATTLIST schedulerDaemonXmlRpcClient xmlRpcHost CDATA #REQUIRED >
|
||||
* <!ATTLIST schedulerDaemonXmlRpcClient xmlRpcPort NMTOKEN #REQUIRED >
|
||||
* <!ATTLIST schedulerDaemonXmlRpcClient xmlRpcUri CDATA #REQUIRED >
|
||||
* </code></pre>
|
||||
*
|
||||
*/
|
||||
class SchedulerDaemonXmlRpcClient :
|
||||
virtual public Configurable,
|
||||
virtual public SchedulerClientInterface
|
||||
{
|
||||
private:
|
||||
/**
|
||||
* The name of the configuration XML elmenent used by
|
||||
* SchedulerDaemonXmlRpcClient
|
||||
*/
|
||||
static const std::string configElementNameStr;
|
||||
|
||||
/**
|
||||
* The host name of the schedulers XML-RPC interface.
|
||||
*/
|
||||
Ptr<std::string>::Ref xmlRpcHost;
|
||||
|
||||
/**
|
||||
* The port of the schedulers XML-RPC interface.
|
||||
*/
|
||||
unsigned int xmlRpcPort;
|
||||
|
||||
/**
|
||||
* The URI to send to the schedulers XML-RPC interface.
|
||||
*/
|
||||
Ptr<std::string>::Ref xmlRpcUri;
|
||||
|
||||
|
||||
public:
|
||||
/**
|
||||
* A virtual destructor, as this class has virtual functions.
|
||||
*/
|
||||
virtual
|
||||
~SchedulerDaemonXmlRpcClient(void) throw ()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name of the XML element this object expects
|
||||
* to be sent to a call to configure().
|
||||
*
|
||||
* @return the name of the expected XML configuration element.
|
||||
*/
|
||||
static const std::string
|
||||
getConfigElementName(void) throw ()
|
||||
{
|
||||
return configElementNameStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the object based on the XML element supplied.
|
||||
*
|
||||
* @param element the XML element to configure the object from.
|
||||
* @exception std::invalid_argument if the supplied XML element
|
||||
* contains bad configuraiton information
|
||||
* @exception std::logic_error if the scheduler daemon has already
|
||||
* been configured, and can not be reconfigured.
|
||||
*/
|
||||
virtual void
|
||||
configure(const xmlpp::Element & element)
|
||||
throw (std::invalid_argument,
|
||||
std::logic_error);
|
||||
|
||||
/**
|
||||
* Return the XML-RPC host the client connects to.
|
||||
*
|
||||
* @return the XML-RPC host the client connects to.
|
||||
*/
|
||||
virtual Ptr<const std::string>::Ref
|
||||
getXmlRpcHost(void) const throw ()
|
||||
{
|
||||
return xmlRpcHost;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the XML-RPC port the client connects to.
|
||||
*
|
||||
* @return the XML-RPC port the client connects to.
|
||||
*/
|
||||
virtual unsigned int
|
||||
getXmlRpcPort(void) const throw ()
|
||||
{
|
||||
return xmlRpcPort;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the XML-RPC URI prefix used when connecting to the scheduler.
|
||||
*
|
||||
* @return the XML-RPC URI prefix.
|
||||
*/
|
||||
virtual Ptr<const std::string>::Ref
|
||||
getXmlRpcUriPrefix(void) const throw ()
|
||||
{
|
||||
return xmlRpcUri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the version string for the scheduler this client
|
||||
* is connected to.
|
||||
*
|
||||
* @return the version string of the scheduler daemon.
|
||||
* @exception XmlRpcException in case of XML-RPC errors.
|
||||
*/
|
||||
virtual Ptr<const std::string>::Ref
|
||||
getVersion(void) throw (XmlRpcException);
|
||||
|
||||
/**
|
||||
* Return the current time at the scheduler server.
|
||||
*
|
||||
* @return the current time at the scheduler server.
|
||||
* @exception XmlRpcException in case of XML-RPC errors.
|
||||
*/
|
||||
virtual Ptr<const boost::posix_time::ptime>::Ref
|
||||
getSchedulerTime(void) throw (XmlRpcException);
|
||||
|
||||
/**
|
||||
* Schedule a playlist at a given time.
|
||||
*
|
||||
* @param sessionId a valid, authenticated session id.
|
||||
* @param playlistId the id of the playlist to schedule.
|
||||
* @param playtime the time for which to schedule.
|
||||
* @return the schedule entry id for which the playlist has been
|
||||
* scheduled.
|
||||
* @exception XmlRpcException in case of XML-RPC errors.
|
||||
*/
|
||||
virtual Ptr<UniqueId>::Ref
|
||||
uploadPlaylist(Ptr<SessionId>::Ref sessionId,
|
||||
Ptr<UniqueId>::Ref playlistId,
|
||||
Ptr<boost::posix_time::ptime>::Ref playtime)
|
||||
throw (XmlRpcException);
|
||||
|
||||
/**
|
||||
* Return the scheduled entries for a specified time interval.
|
||||
*
|
||||
* @param sessionId a valid, authenticated session id.
|
||||
* @param from the start of the interval, inclusive
|
||||
* @param to the end of the interval, exclusive
|
||||
* @return a vector of the schedule entries for the time period.
|
||||
* @exception XmlRpcException in case of XML-RPC errors.
|
||||
*/
|
||||
virtual Ptr<std::vector<Ptr<ScheduleEntry>::Ref> >::Ref
|
||||
displaySchedule(Ptr<SessionId>::Ref sessionId,
|
||||
Ptr<boost::posix_time::ptime>::Ref from,
|
||||
Ptr<boost::posix_time::ptime>::Ref to)
|
||||
throw (XmlRpcException);
|
||||
|
||||
/**
|
||||
* Remove a scheduled item.
|
||||
*
|
||||
* @param sessionId a valid, authenticated session id.
|
||||
* @param scheduledEntryId the id of the scheduled entry to remove.
|
||||
* @exception XmlRpcException in case of XML-RPC errors.
|
||||
*/
|
||||
virtual void
|
||||
removeFromSchedule(Ptr<SessionId>::Ref sessionId,
|
||||
Ptr<UniqueId>::Ref scheduleEntryId)
|
||||
throw (XmlRpcException);
|
||||
|
||||
/**
|
||||
* Start the schedule backup creation process.
|
||||
* This will produce a combined backup, including a storage portion.
|
||||
* The scheduler daemon first calls the storage server, and gets
|
||||
* a storage backup archive file from it; then it adds the schedule
|
||||
* backup to this archive file.
|
||||
*
|
||||
* @param sessionId a valid, authenticated session id.
|
||||
* @param criteria the search criteria for the storage portion
|
||||
* of the backup.
|
||||
* @param fromTime entries are included in the schedule backup
|
||||
* starting from this time.
|
||||
* @param toTime entries are included in the schedule backup
|
||||
* up to but not including this time.
|
||||
* @return a token which can be used to query the backup process.
|
||||
* @exception XmlRpcException if there is a problem with the XML-RPC
|
||||
* call.
|
||||
*/
|
||||
virtual Ptr<Glib::ustring>::Ref
|
||||
createBackupOpen(Ptr<SessionId>::Ref sessionId,
|
||||
Ptr<SearchCriteria>::Ref criteria,
|
||||
Ptr<ptime>::Ref fromTime,
|
||||
Ptr<ptime>::Ref toTime) const
|
||||
throw (XmlRpcException);
|
||||
|
||||
/**
|
||||
* Check on the progress of the schedule backup creation process.
|
||||
*
|
||||
* @param token the token obtained from createBackupOpen().
|
||||
* @param url return parameter;
|
||||
* if a finishedState is returned, it contains the
|
||||
* URL of the created backup file.
|
||||
* @param path return parameter;
|
||||
* if a finishedState is returned, it contains the
|
||||
* local access path of the created backup file.
|
||||
* @param errorMessage return parameter;
|
||||
* if a failedState is returned, it contains the
|
||||
* fault string.
|
||||
* @return the state of the backup process: one of pendingState,
|
||||
* finishedState, or failedState.
|
||||
* @exception XmlRpcException if there is a problem with the XML-RPC
|
||||
* call.
|
||||
*/
|
||||
virtual AsyncState
|
||||
createBackupCheck(const Glib::ustring & token,
|
||||
Ptr<const Glib::ustring>::Ref & url,
|
||||
Ptr<const Glib::ustring>::Ref & path,
|
||||
Ptr<const Glib::ustring>::Ref & errorMessage) const
|
||||
throw (XmlRpcException);
|
||||
|
||||
/**
|
||||
* Close the schedule backup creation process.
|
||||
*
|
||||
* @param token the token obtained from createBackupOpen().
|
||||
* @exception XmlRpcException if there is a problem with the XML-RPC
|
||||
* call.
|
||||
*/
|
||||
virtual void
|
||||
createBackupClose(const Glib::ustring & token) const
|
||||
throw (XmlRpcException);
|
||||
|
||||
/**
|
||||
* Restore a schedule backup.
|
||||
*
|
||||
* All playlist IDs contained in the backup should already be in the
|
||||
* storage. If this is a combined backup, with both storage and
|
||||
* schedule components, then restore this backup to the storage
|
||||
* first, and then call this function.
|
||||
*
|
||||
* @param sessionId a valid session ID to identify the user.
|
||||
* @param path the location of the archive to upload.
|
||||
* @exception XmlRpcException if there is an error.
|
||||
*/
|
||||
virtual void
|
||||
restoreBackup(Ptr<SessionId>::Ref sessionId,
|
||||
Ptr<const Glib::ustring>::Ref path)
|
||||
throw (XmlRpcException);
|
||||
|
||||
/**
|
||||
* Stop the scheduler's audio player.
|
||||
*
|
||||
* @param sessionId a valid session ID to identify the user.
|
||||
* @exception XmlRpcException if there is an error.
|
||||
*/
|
||||
virtual void
|
||||
stopCurrentlyPlaying(Ptr<SessionId>::Ref sessionId)
|
||||
throw (XmlRpcException);
|
||||
};
|
||||
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
||||
|
||||
/* ====================================================== function prototypes */
|
||||
|
||||
|
||||
} // namespace SchedulerClient
|
||||
} // namespace LiveSupport
|
||||
|
||||
#endif // SchedulerDaemonXmlRpcClient_h
|
||||
|
|
@ -1,463 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
|
||||
This file is part of the Campcaster project.
|
||||
http://campcaster.sourcefabric.org/
|
||||
|
||||
Campcaster is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Campcaster is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Campcaster; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#else
|
||||
#error "Need unistd.h"
|
||||
#endif
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <XmlRpcClient.h>
|
||||
#include <XmlRpcValue.h>
|
||||
|
||||
#include "LiveSupport/Core/TimeConversion.h"
|
||||
#include "LiveSupport/Core/XmlRpcMethodFaultException.h"
|
||||
#include "LiveSupport/Core/FileTools.h"
|
||||
#include "LiveSupport/Authentication/AuthenticationClientFactory.h"
|
||||
#include "SchedulerDaemonXmlRpcClientTest.h"
|
||||
|
||||
|
||||
using namespace boost::posix_time;
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Authentication;
|
||||
using namespace LiveSupport::SchedulerClient;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(SchedulerDaemonXmlRpcClientTest);
|
||||
|
||||
namespace {
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the scheduler client.
|
||||
*/
|
||||
const std::string configFileName = "schedulerDaemonXmlRpcClient.xml";
|
||||
|
||||
/**
|
||||
* The location of the temporary backup file
|
||||
*/
|
||||
const std::string tempBackupTarFileName = "tmp/scheduleBackup.tar";
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Set up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SchedulerDaemonXmlRpcClientTest :: setUp(void) throw ()
|
||||
{
|
||||
try {
|
||||
xmlpp::DomParser parser;
|
||||
const xmlpp::Document * document = getConfigDocument(parser,
|
||||
configFileName);
|
||||
const xmlpp::Element * root = document->get_root_node();
|
||||
|
||||
schedulerClient.reset(new SchedulerDaemonXmlRpcClient());
|
||||
schedulerClient->configure(*root);
|
||||
} catch (std::invalid_argument &e) {
|
||||
CPPUNIT_FAIL("semantic error in configuration file");
|
||||
} catch (xmlpp::exception &e) {
|
||||
CPPUNIT_FAIL("error parsing configuration file");
|
||||
}
|
||||
|
||||
XmlRpc::XmlRpcValue parameters;
|
||||
XmlRpc::XmlRpcValue result;
|
||||
|
||||
XmlRpc::XmlRpcClient xmlRpcClient(
|
||||
schedulerClient->getXmlRpcHost()->c_str(),
|
||||
schedulerClient->getXmlRpcPort(),
|
||||
schedulerClient->getXmlRpcUriPrefix()->c_str(),
|
||||
false);
|
||||
|
||||
CPPUNIT_ASSERT(xmlRpcClient.execute("resetStorage", parameters, result));
|
||||
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
|
||||
|
||||
parameters["login"] = "root";
|
||||
parameters["password"] = "q";
|
||||
CPPUNIT_ASSERT(xmlRpcClient.execute("login", parameters, result));
|
||||
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
|
||||
CPPUNIT_ASSERT(result.hasMember("sessionId"));
|
||||
|
||||
xmlRpcClient.close();
|
||||
|
||||
sessionId.reset(new SessionId(std::string(result["sessionId"])));
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Clean up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SchedulerDaemonXmlRpcClientTest :: tearDown(void) throw ()
|
||||
{
|
||||
XmlRpc::XmlRpcValue parameters;
|
||||
XmlRpc::XmlRpcValue result;
|
||||
|
||||
XmlRpc::XmlRpcClient xmlRpcClient(
|
||||
schedulerClient->getXmlRpcHost()->c_str(),
|
||||
schedulerClient->getXmlRpcPort(),
|
||||
schedulerClient->getXmlRpcUriPrefix()->c_str(),
|
||||
false);
|
||||
|
||||
parameters["sessionId"] = sessionId->getId();
|
||||
CPPUNIT_ASSERT(xmlRpcClient.execute("logout", parameters, result));
|
||||
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
|
||||
|
||||
xmlRpcClient.close();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Test to see if we can get the version string of the scheduler.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SchedulerDaemonXmlRpcClientTest :: getVersionTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
try {
|
||||
Ptr<const std::string>::Ref version = schedulerClient->getVersion();
|
||||
|
||||
CPPUNIT_ASSERT(version.get());
|
||||
} catch (Core::XmlRpcException &e) {
|
||||
CPPUNIT_FAIL(e.what());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Test to see if we can get the time of the scheduler.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SchedulerDaemonXmlRpcClientTest :: getSchedulerTimeTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
try {
|
||||
Ptr<const ptime>::Ref time = schedulerClient->getSchedulerTime();
|
||||
Ptr<const ptime>::Ref now = TimeConversion::now();
|
||||
|
||||
CPPUNIT_ASSERT(time.get());
|
||||
// assume that the scheduler and the client is in the same year
|
||||
// this can break at new year's eve - so don't run the test then :)
|
||||
CPPUNIT_ASSERT(time->date().year() == now->date().year());
|
||||
} catch (Core::XmlRpcException &e) {
|
||||
CPPUNIT_FAIL(e.what());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Test the displaySchedule XML-RPC method, when the schedule is empty
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SchedulerDaemonXmlRpcClientTest :: displayScheduleEmptyTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
try {
|
||||
Ptr<std::vector<Ptr<ScheduleEntry>::Ref> >::Ref entries;
|
||||
Ptr<ptime>::Ref from;
|
||||
Ptr<ptime>::Ref to;
|
||||
|
||||
// check from now until 1 hour later
|
||||
from = TimeConversion::now();
|
||||
to.reset(new ptime(*from + hours(1)));
|
||||
|
||||
entries = schedulerClient->displaySchedule(sessionId, from, to);
|
||||
CPPUNIT_ASSERT(entries->empty());
|
||||
} catch (Core::XmlRpcException &e) {
|
||||
CPPUNIT_FAIL(e.what());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Test playlist management functions.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SchedulerDaemonXmlRpcClientTest :: playlistMgmtTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
try {
|
||||
Ptr<std::vector<Ptr<ScheduleEntry>::Ref> >::Ref entries;
|
||||
Ptr<ScheduleEntry>::Ref entry;
|
||||
Ptr<UniqueId>::Ref entryId;
|
||||
Ptr<UniqueId>::Ref playlistId;
|
||||
Ptr<ptime>::Ref now;
|
||||
Ptr<ptime>::Ref playtime;
|
||||
Ptr<ptime>::Ref from;
|
||||
Ptr<ptime>::Ref to;
|
||||
|
||||
now = TimeConversion::now();
|
||||
// make sure now is only second resolution, not micro-second
|
||||
long fsec = now->time_of_day().fractional_seconds();
|
||||
now.reset(new ptime(*now - microsec(fsec)));
|
||||
|
||||
// the test assumes that there's a playlist with the id of 1 in
|
||||
// the storage accessed by the scheduler
|
||||
|
||||
// schedule playlist #1 for one hour from now
|
||||
playlistId.reset(new UniqueId(1));
|
||||
playtime.reset(new ptime(*now + hours(1)));
|
||||
|
||||
entryId = schedulerClient->uploadPlaylist(sessionId,
|
||||
playlistId,
|
||||
playtime);
|
||||
|
||||
// now check if our playlist has indeed been scheduled
|
||||
from = now;
|
||||
to.reset(new ptime(*from + hours(2)));
|
||||
|
||||
entries = schedulerClient->displaySchedule(sessionId, from, to);
|
||||
CPPUNIT_ASSERT(entries->size() == 1);
|
||||
entry = (*entries)[0];
|
||||
CPPUNIT_ASSERT(*entry->getId() == *entryId);
|
||||
CPPUNIT_ASSERT(*entry->getPlaylistId() == *playlistId);
|
||||
CPPUNIT_ASSERT(*entry->getStartTime() == *playtime);
|
||||
|
||||
|
||||
// and now, remove the entry, and see that it's not there anymore
|
||||
schedulerClient->removeFromSchedule(sessionId, entryId);
|
||||
entries = schedulerClient->displaySchedule(sessionId, from, to);
|
||||
CPPUNIT_ASSERT(entries->empty());
|
||||
} catch (Core::XmlRpcException &e) {
|
||||
CPPUNIT_FAIL(e.what());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Test for some XML-RPC error conditions
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SchedulerDaemonXmlRpcClientTest :: xmlRpcErrorTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
Ptr<std::vector<Ptr<ScheduleEntry>::Ref> >::Ref entries;
|
||||
Ptr<ScheduleEntry>::Ref entry;
|
||||
Ptr<UniqueId>::Ref entryId;
|
||||
Ptr<UniqueId>::Ref playlistId;
|
||||
Ptr<ptime>::Ref now;
|
||||
Ptr<ptime>::Ref playtime;
|
||||
bool gotException;
|
||||
|
||||
try {
|
||||
now = TimeConversion::now();
|
||||
// make sure now is only second resolution, not micro-second
|
||||
long fsec = now->time_of_day().fractional_seconds();
|
||||
now.reset(new ptime(*now - microsec(fsec)));
|
||||
|
||||
// the test assumes that there's a playlist with the id of 1 in
|
||||
// the storage accessed by the scheduler
|
||||
|
||||
// schedule playlist #1 for one hour from now
|
||||
playlistId.reset(new UniqueId(1));
|
||||
playtime.reset(new ptime(*now + hours(1)));
|
||||
|
||||
entryId = schedulerClient->uploadPlaylist(sessionId,
|
||||
playlistId,
|
||||
playtime);
|
||||
} catch (Core::XmlRpcException &e) {
|
||||
CPPUNIT_FAIL(e.what());
|
||||
}
|
||||
|
||||
gotException = false;
|
||||
try {
|
||||
// try to upload the same entry again, for the same time
|
||||
// this should result in an error
|
||||
schedulerClient->uploadPlaylist(sessionId, playlistId, playtime);
|
||||
} catch (Core::XmlRpcMethodFaultException &e) {
|
||||
gotException = true;
|
||||
} catch (Core::XmlRpcException &e) {
|
||||
CPPUNIT_FAIL(e.what());
|
||||
}
|
||||
CPPUNIT_ASSERT(gotException);
|
||||
|
||||
try {
|
||||
// and now, remove the entry, and see that it's not there anymore
|
||||
Ptr<ptime>::Ref from = now;
|
||||
Ptr<ptime>::Ref to(new ptime(*from + hours(2)));
|
||||
|
||||
schedulerClient->removeFromSchedule(sessionId, entryId);
|
||||
entries = schedulerClient->displaySchedule(sessionId, from, to);
|
||||
CPPUNIT_ASSERT(entries->empty());
|
||||
} catch (Core::XmlRpcException &e) {
|
||||
CPPUNIT_FAIL(e.what());
|
||||
}
|
||||
|
||||
gotException = false;
|
||||
try {
|
||||
// and now, try to remove it again, which should result in an
|
||||
// exception
|
||||
schedulerClient->removeFromSchedule(sessionId, entryId);
|
||||
} catch (Core::XmlRpcMethodFaultException &e) {
|
||||
gotException = true;
|
||||
} catch (Core::XmlRpcException &e) {
|
||||
CPPUNIT_FAIL(e.what());
|
||||
}
|
||||
CPPUNIT_ASSERT(gotException);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Create the backup.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SchedulerDaemonXmlRpcClientTest :: createBackup(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
Ptr<SearchCriteria>::Ref criteria(new SearchCriteria);
|
||||
criteria->setLimit(10);
|
||||
Ptr<ptime>::Ref from(new ptime(time_from_string("2004-07-23 10:00:00")));
|
||||
Ptr<ptime>::Ref to(new ptime(time_from_string("2004-07-23 11:00:00")));
|
||||
|
||||
Ptr<const Glib::ustring>::Ref token;
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
token = schedulerClient->createBackupOpen(sessionId,
|
||||
criteria,
|
||||
from,
|
||||
to);
|
||||
);
|
||||
CPPUNIT_ASSERT(token);
|
||||
|
||||
Ptr<const Glib::ustring>::Ref url;
|
||||
Ptr<const Glib::ustring>::Ref path;
|
||||
Ptr<const Glib::ustring>::Ref errorMessage;
|
||||
AsyncState status;
|
||||
int iterations = 20;
|
||||
do {
|
||||
std::cerr << "-/|\\"[iterations%4] << '\b';
|
||||
sleep(1);
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
status = schedulerClient->createBackupCheck(*token,
|
||||
url,
|
||||
path,
|
||||
errorMessage);
|
||||
);
|
||||
CPPUNIT_ASSERT(status == AsyncState::pendingState
|
||||
|| status == AsyncState::finishedState
|
||||
|| status == AsyncState::failedState);
|
||||
} while (--iterations && status == AsyncState::pendingState);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(AsyncState::finishedState, status);
|
||||
CPPUNIT_ASSERT(url);
|
||||
CPPUNIT_ASSERT(path);
|
||||
|
||||
// copy the backup file
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
remove(tempBackupTarFileName.c_str());
|
||||
std::ifstream ifs(path->c_str(), std::ios::binary);
|
||||
std::ofstream ofs(tempBackupTarFileName.c_str(), std::ios::binary);
|
||||
ofs << ifs.rdbuf();
|
||||
);
|
||||
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
schedulerClient->createBackupClose(*token);
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Test the backup functions.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SchedulerDaemonXmlRpcClientTest :: createBackupTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
createBackup()
|
||||
);
|
||||
|
||||
bool exists;
|
||||
std::string schedulerBackupInTarball = "meta-inf/scheduler.xml";
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
exists = FileTools::existsInTarball(tempBackupTarFileName,
|
||||
schedulerBackupInTarball)
|
||||
);
|
||||
CPPUNIT_ASSERT(exists);
|
||||
|
||||
std::string extractedTempFileName = "tmp/scheduler.tmp.xml";
|
||||
FILE * file;
|
||||
|
||||
remove(extractedTempFileName.c_str());
|
||||
file = fopen(extractedTempFileName.c_str(), "r");
|
||||
CPPUNIT_ASSERT(file == 0);
|
||||
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
FileTools::extractFileFromTarball(tempBackupTarFileName,
|
||||
schedulerBackupInTarball,
|
||||
extractedTempFileName)
|
||||
);
|
||||
|
||||
file = fopen(extractedTempFileName.c_str(), "r");
|
||||
CPPUNIT_ASSERT(file != 0);
|
||||
CPPUNIT_ASSERT(fclose(file) == 0);
|
||||
|
||||
CPPUNIT_ASSERT(remove(extractedTempFileName.c_str()) == 0);
|
||||
file = fopen(extractedTempFileName.c_str(), "r");
|
||||
CPPUNIT_ASSERT(file == 0);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Test to see if we can restore backups.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SchedulerDaemonXmlRpcClientTest :: restoreBackupTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
createBackup()
|
||||
);
|
||||
|
||||
Ptr<Glib::ustring>::Ref backupFile(new Glib::ustring());
|
||||
char * currentDirName = get_current_dir_name();
|
||||
backupFile->append(currentDirName);
|
||||
backupFile->append("/");
|
||||
backupFile->append(tempBackupTarFileName);
|
||||
free(currentDirName);
|
||||
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
schedulerClient->restoreBackup(sessionId, backupFile)
|
||||
);
|
||||
// TODO: try this with a non-empty backup file, too
|
||||
}
|
||||
|
|
@ -1,178 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
|
||||
This file is part of the Campcaster project.
|
||||
http://campcaster.sourcefabric.org/
|
||||
|
||||
Campcaster is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Campcaster is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Campcaster; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef SchedulerDaemonXmlRpcClientTest_h
|
||||
#define SchedulerDaemonXmlRpcClientTest_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
#endif
|
||||
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include "LiveSupport/Core/BaseTestMethod.h"
|
||||
#include "LiveSupport/Authentication/AuthenticationClientInterface.h"
|
||||
#include "SchedulerDaemonXmlRpcClient.h"
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace SchedulerClient {
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Authentication;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
||||
/* =================================================================== macros */
|
||||
|
||||
|
||||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* Unit test for the SchedulerDaemonXmlRpcClient class.
|
||||
*
|
||||
* @see SchedulerDaemonXmlRpcClient
|
||||
*/
|
||||
class SchedulerDaemonXmlRpcClientTest : public BaseTestMethod
|
||||
{
|
||||
CPPUNIT_TEST_SUITE(SchedulerDaemonXmlRpcClientTest);
|
||||
CPPUNIT_TEST(getVersionTest);
|
||||
CPPUNIT_TEST(getSchedulerTimeTest);
|
||||
CPPUNIT_TEST(displayScheduleEmptyTest);
|
||||
CPPUNIT_TEST(playlistMgmtTest);
|
||||
CPPUNIT_TEST(xmlRpcErrorTest);
|
||||
CPPUNIT_TEST(createBackupTest);
|
||||
CPPUNIT_TEST(restoreBackupTest);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
private:
|
||||
/**
|
||||
* The SchedulerDaemonXmlRpcClient instance to test.
|
||||
*/
|
||||
Ptr<SchedulerDaemonXmlRpcClient>::Ref schedulerClient;
|
||||
|
||||
/**
|
||||
* A session ID from the authentication client login() method.
|
||||
*/
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
|
||||
/**
|
||||
* Auxiliary method: create the backup file. Used by both backup tests.
|
||||
*/
|
||||
void
|
||||
createBackup(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* A simple test, just to get the version string from the scheduler.
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
getVersionTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
/**
|
||||
* A test to check the getSchedulerTime XML-RPC method.
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
getSchedulerTimeTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
/**
|
||||
* A test to check the displaySchedule XML-RPC method, when
|
||||
* the schedule is empty.
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
displayScheduleEmptyTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
/**
|
||||
* Test playlist management.
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
playlistMgmtTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
/**
|
||||
* Test for some XML-RPC error conditions.
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
xmlRpcErrorTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
/**
|
||||
* Test the create backup functions.
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
createBackupTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
/**
|
||||
* Test the restore backup function.
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
restoreBackupTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Set up the environment for the test case.
|
||||
*/
|
||||
void
|
||||
setUp(void) throw ();
|
||||
|
||||
/**
|
||||
* Clean up the environment after the test case.
|
||||
*/
|
||||
void
|
||||
tearDown(void) throw ();
|
||||
};
|
||||
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
||||
|
||||
/* ====================================================== function prototypes */
|
||||
|
||||
|
||||
} // namespace SchedulerClient
|
||||
} // namespace LiveSupport
|
||||
|
||||
#endif // SchedulerDaemonXmlRpcClientTest_h
|
||||
|
|
@ -1,275 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
|
||||
This file is part of the Campcaster project.
|
||||
http://campcaster.sourcefabric.org/
|
||||
|
||||
Campcaster is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Campcaster is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Campcaster; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#else
|
||||
#error "Need unistd.h"
|
||||
#endif
|
||||
|
||||
#if HAVE_GETOPT_H
|
||||
#include <getopt.h>
|
||||
#else
|
||||
#error "Need getopt.h"
|
||||
#endif
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#include <cppunit/BriefTestProgressListener.h>
|
||||
#include <cppunit/CompilerOutputter.h>
|
||||
#include <cppunit/XmlOutputter.h>
|
||||
#include <cppunit/extensions/TestFactoryRegistry.h>
|
||||
#include <cppunit/TestResult.h>
|
||||
#include <cppunit/TestResultCollector.h>
|
||||
#include <cppunit/TestRunner.h>
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
/**
|
||||
* Our copyright notice, should be at most 80 columns
|
||||
*/
|
||||
static const char copyrightNotice[] =
|
||||
"Copyright (c) 2010 Sourcefabric O.P.S. under the GNU GPL";
|
||||
|
||||
/**
|
||||
* String describing the short options.
|
||||
*/
|
||||
static const char options[] = "ho:s:v";
|
||||
|
||||
/**
|
||||
* Structure describing the long options
|
||||
*/
|
||||
static const struct option longOptions[] = {
|
||||
{ "help", no_argument, 0, 'h' },
|
||||
{ "output", required_argument, 0, 'o' },
|
||||
{ "stylesheet", required_argument, 0, 's' },
|
||||
{ "version", no_argument, 0, 'v' },
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
/**
|
||||
* The encoding to use for the output file.
|
||||
*/
|
||||
static const std::string encoding = "utf-8";
|
||||
|
||||
/**
|
||||
* The output XML file name.
|
||||
*/
|
||||
static Ptr<std::string>::Ref xmlOutFileName;
|
||||
|
||||
/**
|
||||
* The XSLT attached to the output file.
|
||||
*/
|
||||
static Ptr<std::string>::Ref xsltFileName;
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
/**
|
||||
* Print program version.
|
||||
*
|
||||
* @param os the std::ostream to print to.
|
||||
*/
|
||||
static void
|
||||
printVersion ( std::ostream & os );
|
||||
|
||||
/**
|
||||
* Print program usage information.
|
||||
*
|
||||
* @param invocation the command line command used to invoke this program.
|
||||
* @param os the std::ostream to print to.
|
||||
*/
|
||||
static void
|
||||
printUsage ( const char invocation[],
|
||||
std::ostream & os );
|
||||
|
||||
/**
|
||||
* Process command line arguments.
|
||||
*
|
||||
* @param argc the number of arguments.
|
||||
* @param argv the arguments themselves.
|
||||
* @return true of all went well, false in case the program should exit
|
||||
* after this call.
|
||||
*/
|
||||
static bool
|
||||
processArguments(int argc, char *argv[]);
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Run all tests
|
||||
*----------------------------------------------------------------------------*/
|
||||
int
|
||||
main( int argc,
|
||||
char * argv[] ) throw ()
|
||||
{
|
||||
if (!processArguments(argc, argv)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Create the event manager and test controller
|
||||
CPPUNIT_NS::TestResult controller;
|
||||
|
||||
// Add a listener that colllects test result
|
||||
CPPUNIT_NS::TestResultCollector result;
|
||||
controller.addListener( &result );
|
||||
|
||||
// Add a listener that print dots as test run.
|
||||
CPPUNIT_NS::BriefTestProgressListener progress;
|
||||
controller.addListener( &progress );
|
||||
|
||||
// Add the top suite to the test runner
|
||||
CPPUNIT_NS::TestRunner runner;
|
||||
runner.addTest( CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest() );
|
||||
runner.run( controller );
|
||||
|
||||
// Print test in a compiler compatible format.
|
||||
CPPUNIT_NS::CompilerOutputter outputter( &result, std::cerr );
|
||||
outputter.setLocationFormat("%p:%l:");
|
||||
outputter.write();
|
||||
|
||||
// also generate an XML document as an output
|
||||
std::ofstream xmlOutFile(xmlOutFileName->c_str());
|
||||
CPPUNIT_NS::XmlOutputter xmlOutputter(&result, xmlOutFile, encoding);
|
||||
xmlOutputter.setStandalone(false);
|
||||
if (xsltFileName) {
|
||||
xmlOutputter.setStyleSheet(*xsltFileName);
|
||||
}
|
||||
xmlOutputter.write();
|
||||
xmlOutFile.flush();
|
||||
xmlOutFile.close();
|
||||
|
||||
return result.wasSuccessful() ? 0 : 1;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Process command line arguments.
|
||||
*----------------------------------------------------------------------------*/
|
||||
static bool
|
||||
processArguments(int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
|
||||
while ((i = getopt_long(argc, argv, options, longOptions, 0)) != -1) {
|
||||
switch (i) {
|
||||
case 'h':
|
||||
printUsage(argv[0], std::cout);
|
||||
return false;
|
||||
|
||||
case 'o':
|
||||
xmlOutFileName.reset(new std::string(optarg));
|
||||
break;
|
||||
|
||||
case 's':
|
||||
xsltFileName.reset(new std::string(optarg));
|
||||
break;
|
||||
|
||||
case 'v':
|
||||
printVersion(std::cout);
|
||||
return false;
|
||||
|
||||
default:
|
||||
printUsage(argv[0], std::cout);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (optind < argc) {
|
||||
std::cerr << "error processing command line arguments" << std::endl;
|
||||
printUsage(argv[0], std::cout);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!xmlOutFileName) {
|
||||
std::cerr << "mandatory option output file name not specified"
|
||||
<< std::endl;
|
||||
printUsage(argv[0], std::cout);
|
||||
return false;
|
||||
}
|
||||
|
||||
std::cerr << "writing output to '" << *xmlOutFileName << '\'' << std::endl;
|
||||
if (xsltFileName) {
|
||||
std::cerr << "using XSLT file '" << *xsltFileName << '\'' << std::endl;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Print program version.
|
||||
*----------------------------------------------------------------------------*/
|
||||
static void
|
||||
printVersion ( std::ostream & os )
|
||||
{
|
||||
os << PACKAGE_NAME << ' ' << PACKAGE_VERSION << std::endl
|
||||
<< "Unit test runner" << std::endl
|
||||
<< copyrightNotice << std::endl;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Print program usage.
|
||||
*----------------------------------------------------------------------------*/
|
||||
static void
|
||||
printUsage ( const char invocation[],
|
||||
std::ostream & os )
|
||||
{
|
||||
os << PACKAGE_NAME << ' ' << PACKAGE_VERSION << std::endl
|
||||
<< "Unit test runner" << std::endl
|
||||
<< std::endl
|
||||
<< "Usage: " << invocation << " [OPTION]"
|
||||
<< std::endl
|
||||
<< " mandatory options:" << std::endl
|
||||
<< " -o, --output=file.name write test results into this XML file"
|
||||
<< std::endl
|
||||
<< " optional options:" << std::endl
|
||||
<< " -s, --stylesheet specify this XSLT for the output file"
|
||||
<< std::endl
|
||||
<< " this is either an absolute URI, or a"
|
||||
<< std::endl
|
||||
<< " relative path for the output document"
|
||||
<< std::endl
|
||||
<< " -h, --help display this help and exit" << std::endl
|
||||
<< " -v, --version display version information and exit"
|
||||
<< std::endl
|
||||
<< std::endl
|
||||
<< "Report bugs to " << PACKAGE_BUGREPORT << std::endl;
|
||||
}
|
||||
|
|
@ -1 +0,0 @@
|
|||
keep me
|
|
@ -1,89 +0,0 @@
|
|||
#!/bin/bash
|
||||
#-------------------------------------------------------------------------------
|
||||
# Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
#
|
||||
# This file is part of the Campcaster project.
|
||||
# http://campcaster.sourcefabric.org/
|
||||
#
|
||||
# Campcaster is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Campcaster is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Campcaster; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Run this to set up the build system: configure, makefiles, etc.
|
||||
# (based on the version in enlightenment's cvs)
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
package="StorageAdmin"
|
||||
|
||||
# assume we're in $basedir/bin
|
||||
reldir=`dirname $0`/..
|
||||
basedir=`cd $reldir; pwd;`
|
||||
test -z "$basedir" && basedir=.
|
||||
|
||||
bindir=$basedir/bin
|
||||
etcdir=$basedir/etc
|
||||
tmpdir=$basedir/tmp
|
||||
|
||||
cd "$tmpdir"
|
||||
DIE=0
|
||||
|
||||
(autoheader --version) < /dev/null > /dev/null 2>&1 || {
|
||||
echo
|
||||
echo "You must have autoconf installed to compile $package."
|
||||
echo "Download the appropriate package for your distribution,"
|
||||
echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
|
||||
DIE=1
|
||||
}
|
||||
|
||||
(autoconf --version) < /dev/null > /dev/null 2>&1 || {
|
||||
echo
|
||||
echo "You must have autoconf installed to compile $package."
|
||||
echo "Download the appropriate package for your distribution,"
|
||||
echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
|
||||
DIE=1
|
||||
}
|
||||
|
||||
if test "$DIE" -eq 1; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if test -z "$*"; then
|
||||
echo "I am going to run ./configure with no arguments - if you wish "
|
||||
echo "to pass any to it, please specify them on the $0 command line."
|
||||
fi
|
||||
|
||||
echo "Generating configuration files for $package, please wait...."
|
||||
|
||||
configure_ac=${etcdir}/configure.ac
|
||||
configure=${tmpdir}/configure
|
||||
aclocal_m4=${tmpdir}/aclocal.m4
|
||||
|
||||
# copy over configure.ac and acinlclude.m4 from etc to tmp,
|
||||
# as aclocal >= 1.8 is sooo unbelivably stupid that it will simply try to
|
||||
# look for configure.ac in the current directory, and include acinclude.m4
|
||||
# in aclocal.m4 it without a directory path in front
|
||||
#ACLOCAL_FLAGS="-I ${tmpdir} --acdir=${tmpdir} --output=${aclocal_m4}"
|
||||
#echo " aclocal $ACLOCAL_FLAGS"
|
||||
#cp -f ${configure_ac} ${tmpdir}
|
||||
#cp -f ${etcdir}/acinclude.m4 ${tmpdir}
|
||||
#aclocal $ACLOCAL_FLAGS
|
||||
|
||||
#echo " autoheader ${configure_ac}"
|
||||
#autoheader ${configure_ac}
|
||||
|
||||
echo " autoconf -I ${tmpdir} -o ${configure} ${configure_ac}"
|
||||
autoconf -I ${tmpdir} -o ${configure} ${configure_ac}
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
#!/bin/sh
|
||||
#-------------------------------------------------------------------------------
|
||||
# Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
#
|
||||
# This file is part of the Campcaster project.
|
||||
# http://campcaster.campware.org/
|
||||
#
|
||||
# Campcaster is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Campcaster is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Campcaster; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Run this script to configure the environment.
|
||||
#
|
||||
# This script in effect calls the real automake / autoconf configure script
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
# assume we're in $basedir
|
||||
reldir=`dirname $0`
|
||||
basedir=`cd $reldir; pwd;`
|
||||
test -z "$basedir" && basedir=.
|
||||
|
||||
bindir=$basedir/bin
|
||||
tmpdir=$basedir/tmp
|
||||
|
||||
|
||||
autogen=$bindir/autogen.sh
|
||||
configure=$tmpdir/configure
|
||||
|
||||
if [ ! -x $configure ]; then
|
||||
(cd $basedir && $autogen $*)
|
||||
fi
|
||||
|
||||
(cd $tmpdir && $configure $*)
|
||||
|
|
@ -1,150 +0,0 @@
|
|||
#-------------------------------------------------------------------------------
|
||||
# getID3 - read and writes tags in media files - see getid3.readme.txt
|
||||
# getID3 by James Heinrich <getid3@users.sourceforge.net>
|
||||
#
|
||||
# This file is part of the Campcaster project.
|
||||
# Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
#
|
||||
# Campcaster is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Campcaster is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Campcaster; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
# @configure_input@
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# General command definitions
|
||||
#-------------------------------------------------------------------------------
|
||||
SHELL = /bin/bash
|
||||
MKDIR = mkdir -p
|
||||
RM = rm -f
|
||||
RMDIR = rm -rf
|
||||
DOXYGEN = doxygen
|
||||
CP = cp -f
|
||||
SED = sed
|
||||
ECHO = echo
|
||||
CAT = cat
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Misc
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
MODULE_NAME = getid3
|
||||
TAR_C = tar -cj --exclude .svn --exclude '*~' -C ${BASE_DIR} -f
|
||||
DIST_EXT = .tgz
|
||||
DATE = `date +%y%m%d`
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Basic directory and file definitions
|
||||
#-------------------------------------------------------------------------------
|
||||
#BASE_DIR = @builddir@
|
||||
BASE_DIR = .
|
||||
DOC_DIR = ${BASE_DIR}/doc
|
||||
DOXYGEN_DIR = ${DOC_DIR}/doxygen
|
||||
ETC_DIR = ${BASE_DIR}/etc
|
||||
DOXYGEN_CONFIG = ${ETC_DIR}/doxygen.config
|
||||
INCLUDE_DIR = ${BASE_DIR}/include
|
||||
LIB_DIR = ${BASE_DIR}/lib
|
||||
SRC_DIR = ${BASE_DIR}/src
|
||||
TMP_DIR = ${BASE_DIR}/tmp
|
||||
VAR_DIR = ${BASE_DIR}/var
|
||||
BIN_DIR = ${BASE_DIR}/bin
|
||||
|
||||
prefix = @prefix@
|
||||
|
||||
USR_DIR = ${prefix}
|
||||
|
||||
DEST_DIR = ${USR_DIR}
|
||||
PHPPART_DIR = ${prefix}/var/Campcaster/storageAdmin/var
|
||||
STORAGE_SERVER = @STORAGE_SERVER@
|
||||
|
||||
PHPPART_DIR_S=$(shell ${ECHO} ${PHPPART_DIR} | ${SED} -e "s/\//\\\\\\\\\//g")
|
||||
STORAGE_SERVER_S=$(shell ${ECHO} ${STORAGE_SERVER} | ${SED} -e "s/\//\\\\\\\\\//g")
|
||||
|
||||
SED_STORAGE_SERVER="s/ls_storageServer/${STORAGE_SERVER_S}/;"
|
||||
SED_PHPPART_DIR="s/phpdir=ls_storageAdmin_phppart_dir/phpdir=${PHPPART_DIR_S}/;"
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Configuration parameters
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Dependencies
|
||||
#-------------------------------------------------------------------------------
|
||||
#HELLO_LIB_OBJS = ${TMP_DIR}/Hello.o
|
||||
#TEST_RUNNER_OBJS = ${TMP_DIR}/HelloTest.o ${TMP_DIR}/TestRunner.o
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Targets
|
||||
#-------------------------------------------------------------------------------
|
||||
.PHONY: all dir_setup doc clean docclean depclean distclean dist install
|
||||
|
||||
all: dir_setup
|
||||
|
||||
#dir_setup: ${TMP_DIR} ${DOXYGEN_DIR}
|
||||
dir_setup: ${DOXYGEN_DIR}
|
||||
|
||||
doc:
|
||||
${DOXYGEN} ${DOXYGEN_CONFIG}
|
||||
|
||||
clean:
|
||||
# ${RM} ...
|
||||
|
||||
docclean:
|
||||
${RMDIR} ${DOXYGEN_DIR}/html
|
||||
|
||||
depclean: clean
|
||||
|
||||
dist: all
|
||||
${TAR_C} ${MODULE_NAME}${DATE}${DIST_EXT} *
|
||||
|
||||
distclean: clean docclean
|
||||
# ${RMDIR} ${TMP_DIR}/config* ${TMP_DIR}/autom4te*
|
||||
|
||||
check: all
|
||||
|
||||
install:
|
||||
${MKDIR} ${DEST_DIR}/bin
|
||||
${CP} ${BIN_DIR}/campcaster-import \
|
||||
${BIN_DIR}/campcaster-backup \
|
||||
${BIN_DIR}/campcaster-restore \
|
||||
${BIN_DIR}/dumpDbSchema.sh \
|
||||
${DEST_DIR}/bin
|
||||
${SED} -i -e ${SED_PHPPART_DIR} \
|
||||
${DEST_DIR}/bin/campcaster-backup \
|
||||
${DEST_DIR}/bin/campcaster-restore \
|
||||
${DEST_DIR}/bin/dumpDbSchema.sh \
|
||||
${DEST_DIR}/bin/campcaster-import
|
||||
${MKDIR} ${PHPPART_DIR}
|
||||
${CP} ${VAR_DIR}/*.php ${PHPPART_DIR}
|
||||
${CAT} ${VAR_DIR}/conf.php.template | ${SED} -e ${SED_STORAGE_SERVER} \
|
||||
> ${PHPPART_DIR}/conf.php
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Specific targets
|
||||
#-------------------------------------------------------------------------------
|
||||
${DOXYGEN_DIR}:
|
||||
${MKDIR} ${DOXYGEN_DIR}
|
||||
|
||||
#${TEST_RUNNER}:
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Pattern rules
|
||||
#-------------------------------------------------------------------------------
|
||||
#${TMP_DIR}/%.o : ${SRC_DIR}/%.cxx
|
||||
# ${CXX} ${CPPFLAGS} ${CXXFLAGS} -c -o $@ $<
|
||||
|
|
@ -1,75 +0,0 @@
|
|||
dnl-----------------------------------------------------------------------------
|
||||
dnl Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
dnl
|
||||
dnl This file is part of the Campcaster project.
|
||||
dnl http://campcaster.sourcefabric.org/
|
||||
dnl
|
||||
dnl Campcaster is free software; you can redistribute it and/or modify
|
||||
dnl it under the terms of the GNU General Public License as published by
|
||||
dnl the Free Software Foundation; either version 2 of the License, or
|
||||
dnl (at your option) any later version.
|
||||
dnl
|
||||
dnl Campcaster is distributed in the hope that it will be useful,
|
||||
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
dnl GNU General Public License for more details.
|
||||
dnl
|
||||
dnl You should have received a copy of the GNU General Public License
|
||||
dnl along with Campcaster; if not, write to the Free Software
|
||||
dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
dnl
|
||||
dnl-----------------------------------------------------------------------------
|
||||
|
||||
dnl-----------------------------------------------------------------------------
|
||||
dnl NOTE: Run all configure related scripts from the tmp directory of the
|
||||
dnl project.
|
||||
dnl This is due to the fact that configure spreads a lot of trash around,
|
||||
dnl like atom4te cache directories, config.* files, etc. into the directory
|
||||
dnl it is being run from. We clearly don't want these in our base directory.
|
||||
dnl-----------------------------------------------------------------------------
|
||||
AC_INIT(StorageAdmin, 0.0, bugs@campware.org)
|
||||
AC_PREREQ(2.59)
|
||||
AC_COPYRIGHT([Copyright (c) 2010 Sourcefabric O.P.S. under the GNU GPL])
|
||||
AC_REVISION($Revision$)
|
||||
|
||||
AC_CONFIG_SRCDIR(../var/getStorPath.php)
|
||||
|
||||
dnl-----------------------------------------------------------------------------
|
||||
dnl specify directory with php parts of scripts
|
||||
dnl-----------------------------------------------------------------------------
|
||||
AC_SUBST(PHPPART_DIR)
|
||||
|
||||
AC_ARG_WITH([phppart-dir],
|
||||
AC_HELP_STRING([--with-phppart-dir],
|
||||
[directory with php parts of scripts]),
|
||||
[PHPPART_DIR=${withval}], [PHPPART_DIR=${prefix}/var/LiveSupport/storageAdmin/var])
|
||||
|
||||
AC_MSG_RESULT([directory with php parts of scripts: ${PHPPART_DIR}])
|
||||
|
||||
dnl-----------------------------------------------------------------------------
|
||||
dnl specify storageServer directory
|
||||
dnl-----------------------------------------------------------------------------
|
||||
AC_SUBST(STORAGE_SERVER)
|
||||
|
||||
AC_ARG_WITH([storage-server],
|
||||
AC_HELP_STRING([--with-storage-server],
|
||||
[use storageServer in given directory]),
|
||||
[STORAGE_SERVER=${withval}], [STORAGE_SERVER=${prefix}/var/LiveSupport/storageServer])
|
||||
|
||||
AC_MSG_RESULT([using storageServer at: ${STORAGE_SERVER}])
|
||||
|
||||
dnl-----------------------------------------------------------------------------
|
||||
dnl msg notice
|
||||
dnl-----------------------------------------------------------------------------
|
||||
AC_MSG_NOTICE(
|
||||
[using the following configuration settings:
|
||||
|
||||
storageServer directory: ${STORAGE_SERVER}
|
||||
php parts directory: ${PHPPART_DIR}
|
||||
|
||||
])
|
||||
|
||||
|
||||
AC_CONFIG_FILES(../Makefile:../etc/Makefile.in)
|
||||
|
||||
AC_OUTPUT()
|
|
@ -1,90 +0,0 @@
|
|||
#!/bin/bash
|
||||
#-------------------------------------------------------------------------------
|
||||
# Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
#
|
||||
# This file is part of the Campcaster project.
|
||||
# http://campcaster.sourcefabric.org/
|
||||
#
|
||||
# Campcaster is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Campcaster is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Campcaster; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Run this to set up the build system: configure, makefiles, etc.
|
||||
# (based on the version in enlightenment's cvs)
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
package="Storage"
|
||||
|
||||
# assume we're in $basedir/bin
|
||||
reldir=`dirname $0`/..
|
||||
basedir=`cd $reldir; pwd;`
|
||||
test -z "$basedir" && basedir=.
|
||||
usrdir=`cd $basedir/../../../usr; pwd;`
|
||||
|
||||
bindir=$basedir/bin
|
||||
etcdir=$basedir/etc
|
||||
tmpdir=$basedir/tmp
|
||||
|
||||
cd "$tmpdir"
|
||||
DIE=0
|
||||
|
||||
(autoheader --version) < /dev/null > /dev/null 2>&1 || {
|
||||
echo
|
||||
echo "You must have autoconf installed to compile $package."
|
||||
echo "Download the appropriate package for your distribution,"
|
||||
echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
|
||||
DIE=1
|
||||
}
|
||||
|
||||
(autoconf --version) < /dev/null > /dev/null 2>&1 || {
|
||||
echo
|
||||
echo "You must have autoconf installed to compile $package."
|
||||
echo "Download the appropriate package for your distribution,"
|
||||
echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
|
||||
DIE=1
|
||||
}
|
||||
|
||||
if test "$DIE" -eq 1; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if test -z "$*"; then
|
||||
echo "I am going to run ./configure with no arguments - if you wish "
|
||||
echo "to pass any to it, please specify them on the $0 command line."
|
||||
fi
|
||||
|
||||
echo "Generating configuration files for $package, please wait...."
|
||||
|
||||
configure_ac=${etcdir}/configure.ac
|
||||
configure=${tmpdir}/configure
|
||||
aclocal_m4=${tmpdir}/aclocal.m4
|
||||
|
||||
# copy over configure.ac and acinlclude.m4 from etc to tmp,
|
||||
# as aclocal >= 1.8 is sooo unbelivably stupid that it will simply try to
|
||||
# look for configure.ac in the current directory, and include acinclude.m4
|
||||
# in aclocal.m4 it without a directory path in front
|
||||
ACLOCAL_FLAGS="-I ${tmpdir} --acdir=${tmpdir} --output=${aclocal_m4}"
|
||||
echo " aclocal $ACLOCAL_FLAGS"
|
||||
cp -f ${configure_ac} ${tmpdir}
|
||||
cp -f ${etcdir}/acinclude.m4 ${tmpdir}
|
||||
aclocal $ACLOCAL_FLAGS
|
||||
|
||||
echo " autoheader ${configure_ac}"
|
||||
autoheader ${configure_ac}
|
||||
|
||||
echo " autoconf -I ${tmpdir} -o ${configure} ${configure_ac}"
|
||||
autoconf -I ${tmpdir} -o ${configure} ${configure_ac}
|
||||
|
|
@ -1,75 +0,0 @@
|
|||
#!/bin/bash
|
||||
#-------------------------------------------------------------------------------
|
||||
# Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
#
|
||||
# This file is part of the Campcaster project.
|
||||
# http://campcaster.sourcefabric.org/
|
||||
#
|
||||
# Campcaster is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Campcaster is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Campcaster; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
#-------------------------------------------------------------------------------
|
||||
# This script generates code coverage data for the module
|
||||
#-------------------------------------------------------------------------------
|
||||
module="Campcaster StorageClient"
|
||||
|
||||
reldir=`dirname $0`/..
|
||||
basedir=`cd $reldir; pwd;`
|
||||
bindir=$basedir/bin
|
||||
docdir=$basedir/doc
|
||||
tmpdir=$basedir/tmp
|
||||
|
||||
usrdir=`cd $basedir/../../../usr; pwd;`
|
||||
|
||||
coverage_report_dir=$docdir/coverage
|
||||
|
||||
raw_coverage_file=$tmpdir/raw_coverage.info
|
||||
coverage_file=$tmpdir/coverage.info
|
||||
|
||||
lcov=$usrdir/bin/lcov
|
||||
genhtml=$usrdir/bin/genhtml
|
||||
|
||||
|
||||
cd $basedir
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Re-configure with covarege collection enabled, compile and run the tests
|
||||
#-------------------------------------------------------------------------------
|
||||
$bindir/autogen.sh --enable-coverage
|
||||
make clean
|
||||
make check
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Generate some symlinks so that the sources are visible from tmpdir
|
||||
#-------------------------------------------------------------------------------
|
||||
ln -s $basedir/include $tmpdir/include
|
||||
ln -s $basedir/src $tmpdir/src
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Use lcov to generate an HTML report on the coverage data
|
||||
#-------------------------------------------------------------------------------
|
||||
$lcov -d $tmpdir -c > $raw_coverage_file
|
||||
$lcov -e $raw_coverage_file "$tmpdir/*" > $coverage_file
|
||||
rm -rf $coverage_report_dir
|
||||
mkdir -p $coverage_report_dir
|
||||
$genhtml -t "$module" -o $coverage_report_dir $coverage_file
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Clean up
|
||||
#-------------------------------------------------------------------------------
|
||||
rm -f $tmpdir/include
|
||||
rm -f $tmpdir/src
|
|
@ -1,47 +0,0 @@
|
|||
#!/bin/sh
|
||||
#-------------------------------------------------------------------------------
|
||||
# Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
#
|
||||
# This file is part of the Campcaster project.
|
||||
# http://campcaster.campware.org/
|
||||
#
|
||||
# Campcaster is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Campcaster is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Campcaster; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Run this script to configure the environment.
|
||||
#
|
||||
# This script in effect calls the real automake / autoconf configure script
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
# assume we're in $basedir
|
||||
reldir=`dirname $0`
|
||||
basedir=`cd $reldir; pwd;`
|
||||
test -z "$basedir" && basedir=.
|
||||
|
||||
bindir=$basedir/bin
|
||||
tmpdir=$basedir/tmp
|
||||
|
||||
|
||||
autogen=$bindir/autogen.sh
|
||||
configure=$tmpdir/configure
|
||||
|
||||
if [ ! -x $configure ]; then
|
||||
(cd $basedir && $autogen $*)
|
||||
fi
|
||||
|
||||
(cd $tmpdir && $configure $*)
|
||||
|
|
@ -1 +0,0 @@
|
|||
keep me
|
|
@ -1,209 +0,0 @@
|
|||
#-------------------------------------------------------------------------------
|
||||
# Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
#
|
||||
# This file is part of the Campcaster project.
|
||||
# http://campcaster.sourcefabric.org/
|
||||
#
|
||||
# Campcaster is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Campcaster is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Campcaster; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
# @configure_input@
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# General command definitions
|
||||
#-------------------------------------------------------------------------------
|
||||
MKDIR = mkdir -p
|
||||
RM = rm -f
|
||||
RMDIR = rm -rf
|
||||
DOXYGEN = doxygen
|
||||
CP = cp -f
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Basic directory and file definitions
|
||||
#-------------------------------------------------------------------------------
|
||||
BASE_DIR = @builddir@
|
||||
DOC_DIR = ${BASE_DIR}/doc
|
||||
DOXYGEN_DIR = ${DOC_DIR}/doxygen
|
||||
COVERAGE_DIR = ${DOC_DIR}/coverage
|
||||
ETC_DIR = ${BASE_DIR}/etc
|
||||
INCLUDE_DIR = ${BASE_DIR}/include
|
||||
LIB_DIR = ${BASE_DIR}/lib
|
||||
SRC_DIR = ${BASE_DIR}/src
|
||||
TMP_DIR = ${BASE_DIR}/tmp
|
||||
|
||||
prefix = @prefix@
|
||||
|
||||
USR_DIR = ${prefix}
|
||||
USR_INCLUDE_DIR = ${USR_DIR}/include
|
||||
USR_LIB_DIR = ${USR_DIR}/lib
|
||||
|
||||
MODULES_DIR = ${BASE_DIR}/..
|
||||
|
||||
CORE_DIR = ${MODULES_DIR}/core
|
||||
CORE_INCLUDE_DIR = ${CORE_DIR}/include
|
||||
CORE_LIB_DIR = ${CORE_DIR}/lib
|
||||
CORE_LIB = livesupport_core
|
||||
CORE_LIB_FILE = ${CORE_LIB_DIR}/lib${CORE_LIB}.a
|
||||
|
||||
AUTHENTICATION_DIR = ${MODULES_DIR}/authentication
|
||||
AUTHENTICATION_INCLUDE_DIR = ${AUTHENTICATION_DIR}/include
|
||||
AUTHENTICATION_LIB_DIR = ${AUTHENTICATION_DIR}/lib
|
||||
AUTHENTICATION_LIB = livesupport_authentication
|
||||
AUTHENTICATION_LIB_FILE = ${AUTHENTICATION_LIB_DIR}/lib${AUTHENTICATION_LIB}.a
|
||||
|
||||
VPATH = ${SRC_DIR}
|
||||
|
||||
BOOST_CFLAGS=@BOOST_CPPFLAGS@
|
||||
BOOST_LIBS=@BOOST_LDFLAGS@
|
||||
BOOST_DATE_TIME_LIB=@BOOST_DATE_TIME_LIB@
|
||||
|
||||
LIBXMLPP_CFLAGS=@LIBXMLPP_CFLAGS@
|
||||
LIBXMLPP_LIBS=@LIBXMLPP_LIBS@
|
||||
|
||||
CURL_CFLAGS=@CURL_CFLAGS@
|
||||
CURL_LIBS=@CURL_LIBS@
|
||||
|
||||
ICU_CFLAGS=@ICU_CFLAGS@
|
||||
ICU_CXXFLAGS=@ICU_CXXFLAGS@
|
||||
ICU_LIBS=@ICU_LIBS@
|
||||
|
||||
TAGLIB_CFLAGS=@TAGLIB_CFLAGS@
|
||||
TAGLIB_LIBS=@TAGLIB_LIBS@
|
||||
|
||||
TEST_RESULTS = ${DOC_DIR}/testResults.xml
|
||||
# the text result XSLT has to be relative to the test result file, e.g. TMP_DIR
|
||||
TEST_XSLT = ../etc/testResultToHtml.xsl
|
||||
|
||||
STORAGE_CLIENT_LIB = livesupport_storage_client
|
||||
STORAGE_CLIENT_LIB_FILE = ${LIB_DIR}/lib${STORAGE_CLIENT_LIB}.a
|
||||
TEST_RUNNER = ${TMP_DIR}/testRunner
|
||||
|
||||
DOXYGEN_CONFIG = ${ETC_DIR}/doxygen.config
|
||||
|
||||
export LD_LIBRARY_PATH:=${USR_LIB_DIR}:${LD_LIBRARY_PATH}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Configuration parameters
|
||||
#-------------------------------------------------------------------------------
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CXXFLAGS = @CXXFLAGS@ @DEFS@ @COVERAGE_CXXFLAGS@ -pthread \
|
||||
-pedantic -Wall -Wno-long-long \
|
||||
-I${USR_INCLUDE_DIR} \
|
||||
${BOOST_CFLAGS} \
|
||||
${LIBXMLPP_CFLAGS} \
|
||||
-I${CORE_INCLUDE_DIR} \
|
||||
-I${AUTHENTICATION_INCLUDE_DIR} \
|
||||
-I${INCLUDE_DIR} -I${TMP_DIR}
|
||||
LDFLAGS = @LDFLAGS@ -pthread \
|
||||
${BOOST_LIBS} \
|
||||
${LIBXMLPP_LIBS} \
|
||||
${ICU_LIBS} \
|
||||
${CURL_LIBS} \
|
||||
${TAGLIB_LIBS} \
|
||||
-L${USR_LIB_DIR} \
|
||||
-L${CORE_LIB_DIR} \
|
||||
-L${AUTHENTICATION_LIB_DIR} \
|
||||
-L${LIB_DIR}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Dependencies
|
||||
#-------------------------------------------------------------------------------
|
||||
STORAGE_CLIENT_LIB_OBJS = ${TMP_DIR}/StorageClientFactory.o \
|
||||
${TMP_DIR}/TestStorageClient.o \
|
||||
${TMP_DIR}/WebStorageClient.o
|
||||
|
||||
TEST_RUNNER_OBJS = ${TMP_DIR}/TestRunner.o \
|
||||
${TMP_DIR}/StorageClientFactoryTest.o \
|
||||
${TMP_DIR}/TestStorageClientTest.o \
|
||||
${TMP_DIR}/WebStorageClientTest.o
|
||||
|
||||
TEST_RUNNER_LIBS = -l${STORAGE_CLIENT_LIB} -l${CORE_LIB} \
|
||||
-l${AUTHENTICATION_LIB} \
|
||||
${BOOST_DATE_TIME_LIB} \
|
||||
-lcppunit -ldl -lxmlrpc++ -lssl -ltar
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Targets
|
||||
#-------------------------------------------------------------------------------
|
||||
.PHONY: all dir_setup doc clean docclean depclean distclean check install
|
||||
|
||||
all: dir_setup ${STORAGE_CLIENT_LIB_FILE}
|
||||
|
||||
dir_setup: ${TMP_DIR} ${DOXYGEN_DIR}
|
||||
|
||||
doc:
|
||||
${DOXYGEN} ${DOXYGEN_CONFIG}
|
||||
|
||||
clean:
|
||||
${RM} ${STORAGE_CLIENT_LIB_OBJS} ${STORAGE_CLIENT_LIB_FILE}
|
||||
${RM} ${TEST_RUNNER_OBJS} ${TEST_RUNNER}
|
||||
${RM} ${TMP_DIR}/*.bb ${TMP_DIR}/*.bbg ${TMP_DIR}/*.da ${TMP_DIR}/*.info
|
||||
|
||||
docclean:
|
||||
${RMDIR} ${DOXYGEN_DIR}/html
|
||||
${RMDIR} ${COVERAGE_DIR}/*
|
||||
${RM} ${TEST_RESULTS}
|
||||
|
||||
depclean: clean
|
||||
|
||||
distclean: clean docclean
|
||||
${RMDIR} ${TMP_DIR}/config* ${TMP_DIR}/autom4te* ${TMP_DIR}/ac*.m4
|
||||
|
||||
check: all ${TEST_RUNNER} storage_server_init
|
||||
${TEST_RUNNER} -o ${TEST_RESULTS} -s ${TEST_XSLT}
|
||||
|
||||
install: all
|
||||
${MKDIR} ${USR_INCLUDE_DIR}/LiveSupport/StorageClient
|
||||
${CP} ${INCLUDE_DIR}/LiveSupport/StorageClient/*.h \
|
||||
${USR_INCLUDE_DIR}/LiveSupport/StorageClient
|
||||
${CP} ${STORAGE_CLIENT_LIB_FILE} ${USR_LIB_DIR}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Specific targets
|
||||
#-------------------------------------------------------------------------------
|
||||
${STORAGE_CLIENT_LIB_FILE}: ${STORAGE_CLIENT_LIB_OBJS}
|
||||
${AR} crus $@ $^
|
||||
|
||||
${TMP_DIR}:
|
||||
${MKDIR} ${TMP_DIR}
|
||||
|
||||
${DOXYGEN_DIR}:
|
||||
${MKDIR} ${DOXYGEN_DIR}
|
||||
|
||||
${TEST_RUNNER}: ${CORE_LIB_FILE} ${AUTHENTICATION_LIB_FILE} \
|
||||
${TEST_RUNNER_OBJS} ${STORAGE_CLIENT_LIB_FILE}
|
||||
${CXX} ${LDFLAGS} -o $@ ${TEST_RUNNER_OBJS} ${TEST_RUNNER_LIBS}
|
||||
|
||||
${CORE_LIB_FILE}:
|
||||
${MAKE} -C ${CORE_DIR}
|
||||
|
||||
${AUTHENTICATION_LIB_FILE}:
|
||||
${MAKE} -C ${AUTHENTICATION_DIR}
|
||||
|
||||
storage_server_init:
|
||||
${MAKE} -C ${BASE_DIR}/../storageServer
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Pattern rules
|
||||
#-------------------------------------------------------------------------------
|
||||
${TMP_DIR}/%.o : ${SRC_DIR}/%.cxx
|
||||
${CXX} ${CPPFLAGS} ${CXXFLAGS} -c -o $@ $<
|
||||
|
|
@ -1,575 +0,0 @@
|
|||
dnl-----------------------------------------------------------------------------
|
||||
dnl Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
dnl
|
||||
dnl This file is part of the Campcaster project.
|
||||
dnl http://campcaster.sourcefabric.org/
|
||||
dnl
|
||||
dnl Campcaster is free software; you can redistribute it and/or modify
|
||||
dnl it under the terms of the GNU General Public License as published by
|
||||
dnl the Free Software Foundation; either version 2 of the License, or
|
||||
dnl (at your option) any later version.
|
||||
dnl
|
||||
dnl Campcaster is distributed in the hope that it will be useful,
|
||||
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
dnl GNU General Public License for more details.
|
||||
dnl
|
||||
dnl You should have received a copy of the GNU General Public License
|
||||
dnl along with Campcaster; if not, write to the Free Software
|
||||
dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
dnl
|
||||
dnl-----------------------------------------------------------------------------
|
||||
|
||||
dnl-----------------------------------------------------------------------------
|
||||
dnl Macro to check for available modules using pkg-conf
|
||||
dnl
|
||||
dnl usage:
|
||||
dnl PKG_CHECK_MODULES(GSTUFF,[gtk+-2.0 >= 1.3], action-if, action-not)
|
||||
dnl
|
||||
dnl defines GSTUFF_LIBS, GSTUFF_CFLAGS, see pkg-config man page
|
||||
dnl also defines GSTUFF_PKG_ERRORS on error
|
||||
dnl
|
||||
dnl This function was taken from the glade-- project
|
||||
dnl-----------------------------------------------------------------------------
|
||||
AC_DEFUN([PKG_CHECK_MODULES], [
|
||||
succeeded=no
|
||||
|
||||
if test -z "$PKG_CONFIG"; then
|
||||
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
|
||||
fi
|
||||
|
||||
if test "$PKG_CONFIG" = "no" ; then
|
||||
echo "*** The pkg-config script could not be found. Make sure it is"
|
||||
echo "*** in your path, or set the PKG_CONFIG environment variable"
|
||||
echo "*** to the full path to pkg-config."
|
||||
echo "*** Or see http://www.freedesktop.org/software/pkgconfig to get pkg-config."
|
||||
else
|
||||
PKG_CONFIG_MIN_VERSION=0.9.0
|
||||
if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
|
||||
AC_MSG_CHECKING(for $2)
|
||||
|
||||
if $PKG_CONFIG --exists "$2" ; then
|
||||
AC_MSG_RESULT(yes)
|
||||
succeeded=yes
|
||||
|
||||
AC_MSG_CHECKING($1_CFLAGS)
|
||||
$1_CFLAGS=`$PKG_CONFIG --cflags "$2"`
|
||||
AC_MSG_RESULT($$1_CFLAGS)
|
||||
|
||||
AC_MSG_CHECKING($1_LIBS)
|
||||
$1_LIBS=`$PKG_CONFIG --libs "$2"`
|
||||
AC_MSG_RESULT($$1_LIBS)
|
||||
else
|
||||
$1_CFLAGS=""
|
||||
$1_LIBS=""
|
||||
## If we have a custom action on failure, don't print errors, but
|
||||
## do set a variable so people can do so.
|
||||
$1_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"`
|
||||
ifelse([$4], ,echo $$1_PKG_ERRORS,)
|
||||
fi
|
||||
|
||||
AC_SUBST($1_CFLAGS)
|
||||
AC_SUBST($1_LIBS)
|
||||
else
|
||||
echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
|
||||
echo "*** See http://www.freedesktop.org/software/pkgconfig"
|
||||
fi
|
||||
fi
|
||||
|
||||
if test $succeeded = yes; then
|
||||
ifelse([$3], , :, [$3])
|
||||
else
|
||||
ifelse([$4], , AC_MSG_ERROR([Library requirements ($2) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them.]), [$4])
|
||||
fi
|
||||
])
|
||||
|
||||
|
||||
|
||||
dnl-----------------------------------------------------------------------------
|
||||
dnl Macro to check for taglib of sufficient version by looking at taglib-config
|
||||
dnl
|
||||
dnl usage:
|
||||
dnl AC_CHECK_TAGLIB(version, action-if, action-not)
|
||||
dnl
|
||||
dnl defines TAGLIB_LIBS, TAGLIB_CFLAGS, see taglib-config man page
|
||||
dnl-----------------------------------------------------------------------------
|
||||
AC_DEFUN([AC_CHECK_TAGLIB], [
|
||||
succeeded=no
|
||||
|
||||
if test -z "$TAGLIB_CONFIG"; then
|
||||
AC_PATH_PROG(TAGLIB_CONFIG, taglib-config, no)
|
||||
fi
|
||||
|
||||
if test "$TAGLIB_CONFIG" = "no" ; then
|
||||
echo "*** The taglib-config script could not be found. Make sure it is"
|
||||
echo "*** in your path, and that taglib is properly installed."
|
||||
echo "*** Or see http://developer.kde.org/~wheeler/taglib.html"
|
||||
else
|
||||
TAGLIB_VERSION=`$TAGLIB_CONFIG --version`
|
||||
AC_MSG_CHECKING(for taglib >= $1)
|
||||
VERSION_CHECK=`expr $TAGLIB_VERSION \>\= $1`
|
||||
if test "$VERSION_CHECK" = "1" ; then
|
||||
AC_MSG_RESULT(yes)
|
||||
succeeded=yes
|
||||
|
||||
AC_MSG_CHECKING(TAGLIB_CFLAGS)
|
||||
TAGLIB_CFLAGS=`$TAGLIB_CONFIG --cflags`
|
||||
AC_MSG_RESULT($TAGLIB_CFLAGS)
|
||||
|
||||
AC_MSG_CHECKING(TAGLIB_LIBS)
|
||||
TAGLIB_LIBS=`$TAGLIB_CONFIG --libs`
|
||||
AC_MSG_RESULT($TAGLIB_LIBS)
|
||||
else
|
||||
TAGLIB_CFLAGS=""
|
||||
TAGLIB_LIBS=""
|
||||
## If we have a custom action on failure, don't print errors, but
|
||||
## do set a variable so people can do so.
|
||||
ifelse([$3], ,echo "can't find taglib >= $1",)
|
||||
fi
|
||||
|
||||
AC_SUBST(TAGLIB_CFLAGS)
|
||||
AC_SUBST(TAGLIB_LIBS)
|
||||
fi
|
||||
|
||||
if test $succeeded = yes; then
|
||||
ifelse([$2], , :, [$2])
|
||||
else
|
||||
ifelse([$3], , AC_MSG_ERROR([Library requirements (taglib) not met.]), [$3])
|
||||
fi
|
||||
])
|
||||
|
||||
|
||||
|
||||
dnl-----------------------------------------------------------------------------
|
||||
dnl Macro to check for ICU of sufficient version by looking at icu-config
|
||||
dnl
|
||||
dnl usage:
|
||||
dnl AC_CHECK_ICU(version, action-if, action-not)
|
||||
dnl
|
||||
dnl defines ICU_LIBS, ICU_CFLAGS, ICU_CXXFLAGS, see icu-config man page
|
||||
dnl-----------------------------------------------------------------------------
|
||||
AC_DEFUN([AC_CHECK_ICU], [
|
||||
succeeded=no
|
||||
|
||||
if test -z "$ICU_CONFIG"; then
|
||||
AC_PATH_PROG(ICU_CONFIG, icu-config, no)
|
||||
fi
|
||||
|
||||
if test "$ICU_CONFIG" = "no" ; then
|
||||
echo "*** The icu-config script could not be found. Make sure it is"
|
||||
echo "*** in your path, and that taglib is properly installed."
|
||||
echo "*** Or see http://ibm.com/software/globalization/icu/"
|
||||
else
|
||||
ICU_VERSION=`$ICU_CONFIG --version`
|
||||
AC_MSG_CHECKING(for ICU >= $1)
|
||||
VERSION_CHECK=`expr $ICU_VERSION \>\= $1`
|
||||
if test "$VERSION_CHECK" = "1" ; then
|
||||
AC_MSG_RESULT(yes)
|
||||
succeeded=yes
|
||||
|
||||
AC_MSG_CHECKING(ICU_CFLAGS)
|
||||
ICU_CFLAGS=`$ICU_CONFIG --cflags`
|
||||
AC_MSG_RESULT($ICU_CFLAGS)
|
||||
|
||||
AC_MSG_CHECKING(ICU_CXXFLAGS)
|
||||
ICU_CXXFLAGS=`$ICU_CONFIG --cxxflags`
|
||||
AC_MSG_RESULT($ICU_CXXFLAGS)
|
||||
|
||||
AC_MSG_CHECKING(ICU_LIBS)
|
||||
ICU_LIBS=`$ICU_CONFIG --ldflags`
|
||||
AC_MSG_RESULT($ICU_LIBS)
|
||||
else
|
||||
ICU_CFLAGS=""
|
||||
ICU_CXXFLAGS=""
|
||||
ICU_LIBS=""
|
||||
## If we have a custom action on failure, don't print errors, but
|
||||
## do set a variable so people can do so.
|
||||
ifelse([$3], ,echo "can't find ICU >= $1",)
|
||||
fi
|
||||
|
||||
AC_SUBST(ICU_CFLAGS)
|
||||
AC_SUBST(ICU_CXXFLAGS)
|
||||
AC_SUBST(ICU_LIBS)
|
||||
fi
|
||||
|
||||
if test $succeeded = yes; then
|
||||
ifelse([$2], , :, [$2])
|
||||
else
|
||||
ifelse([$3], , AC_MSG_ERROR([Library requirements (ICU) not met.]), [$3])
|
||||
fi
|
||||
])
|
||||
|
||||
|
||||
|
||||
dnl-----------------------------------------------------------------------------
|
||||
dnl Macro to check for curl of sufficient version by looking at curl-config
|
||||
dnl
|
||||
dnl usage:
|
||||
dnl AC_CHECK_CURL(version, action-if, action-not)
|
||||
dnl
|
||||
dnl defines CURL_LIBS, CURL_CFLAGS, see curl-config man page
|
||||
dnl-----------------------------------------------------------------------------
|
||||
AC_DEFUN([AC_CHECK_CURL], [
|
||||
succeeded=no
|
||||
|
||||
if test -z "$CURL_CONFIG"; then
|
||||
AC_PATH_PROG(CURL_CONFIG, curl-config, no)
|
||||
fi
|
||||
|
||||
if test "$CURL_CONFIG" = "no" ; then
|
||||
echo "*** The curl-config script could not be found. Make sure it is"
|
||||
echo "*** in your path, and that curl is properly installed."
|
||||
echo "*** Or see http://curl.haxx.se/"
|
||||
else
|
||||
dnl curl-config --version returns "libcurl <version>", thus cut the number
|
||||
CURL_VERSION=`$CURL_CONFIG --version | cut -d" " -f2`
|
||||
AC_MSG_CHECKING(for curl >= $1)
|
||||
VERSION_CHECK=`expr $CURL_VERSION \>\= $1`
|
||||
if test "$VERSION_CHECK" = "1" ; then
|
||||
AC_MSG_RESULT(yes)
|
||||
succeeded=yes
|
||||
|
||||
AC_MSG_CHECKING(CURL_CFLAGS)
|
||||
CURL_CFLAGS=`$CURL_CONFIG --cflags`
|
||||
AC_MSG_RESULT($CURL_CFLAGS)
|
||||
|
||||
AC_MSG_CHECKING(CURL_LIBS)
|
||||
CURL_LIBS=`$CURL_CONFIG --libs`
|
||||
AC_MSG_RESULT($CURL_LIBS)
|
||||
else
|
||||
CURL_CFLAGS=""
|
||||
CURL_LIBS=""
|
||||
## If we have a custom action on failure, don't print errors, but
|
||||
## do set a variable so people can do so.
|
||||
ifelse([$3], ,echo "can't find curl >= $1",)
|
||||
fi
|
||||
|
||||
AC_SUBST(CURL_CFLAGS)
|
||||
AC_SUBST(CURL_LIBS)
|
||||
fi
|
||||
|
||||
if test $succeeded = yes; then
|
||||
ifelse([$2], , :, [$2])
|
||||
else
|
||||
ifelse([$3], , AC_MSG_ERROR([Library requirements (curl) not met.]), [$3])
|
||||
fi
|
||||
])
|
||||
|
||||
|
||||
|
||||
dnl-----------------------------------------------------------------------------
|
||||
dnl Macro to check for C++ namespaces
|
||||
dnl for more information on this macro, see
|
||||
dnl http://autoconf-archive.cryp.to/ac_cxx_namespaces.html
|
||||
dnl
|
||||
dnl usage:
|
||||
dnl If the compiler can prevent names clashes using namespaces,
|
||||
dnl define HAVE_NAMESPACES.
|
||||
dnl-----------------------------------------------------------------------------
|
||||
AC_DEFUN([AC_CXX_NAMESPACES],
|
||||
[AC_CACHE_CHECK(whether the compiler implements namespaces,
|
||||
ac_cv_cxx_namespaces,
|
||||
[AC_LANG_SAVE
|
||||
AC_LANG_CPLUSPLUS
|
||||
AC_TRY_COMPILE([namespace Outer { namespace Inner { int i = 0; }}],
|
||||
[using namespace Outer::Inner; return i;],
|
||||
ac_cv_cxx_namespaces=yes, ac_cv_cxx_namespaces=no)
|
||||
AC_LANG_RESTORE
|
||||
])
|
||||
if test "$ac_cv_cxx_namespaces" = yes; then
|
||||
AC_DEFINE(HAVE_NAMESPACES,,[define if the compiler implements namespaces])
|
||||
fi
|
||||
])
|
||||
|
||||
|
||||
dnl-----------------------------------------------------------------------------
|
||||
dnl Test for the Boost C++ libraries of a particular version (or newer).
|
||||
dnl for more information on boost, see http://www.boost.org/
|
||||
dnl for more information on this macro, see
|
||||
dnl http://autoconf-archive.cryp.to/ax_boost_base.html
|
||||
dnl
|
||||
dnl usage:
|
||||
dnl If no path to the installed boost library is given the macro searches
|
||||
dnl under ${prefix}, /usr, /usr/local, and /opt, and evaluates the $BOOST_ROOT
|
||||
dnl environment variable. Further documentation is available at
|
||||
dnl http://randspringer.de/boost/index.html
|
||||
dnl
|
||||
dnl This macro calls: AC_SUBST(BOOST_CPPFLAGS) and AC_SUBST(BOOST_LDFLAGS)
|
||||
dnl and sets: HAVE_BOOST
|
||||
dnl
|
||||
dnl Modified for Campcaster:
|
||||
dnl * --with-boost default changed to Yes;
|
||||
dnl * if the library is not found, it does not die, just prints "no", leaves
|
||||
dnl HAVE_BOOST undefined, and sets the BOOST_CPPFLAGS and BOOST_LDFLAGS
|
||||
dnl variables to "";
|
||||
dnl * ${prefix} is prepended to the search path.
|
||||
dnl
|
||||
dnl Author: Thomas Porschberg <thomas@randspringer.de>
|
||||
dnl
|
||||
dnl License:
|
||||
dnl Copyright © 2006 Thomas Porschberg <thomas@randspringer.de>
|
||||
dnl Copying and distribution of this file, with or without modification,
|
||||
dnl are permitted in any medium without royalty provided the copyright notice
|
||||
dnl and this notice are preserved.
|
||||
dnl-----------------------------------------------------------------------------
|
||||
AC_DEFUN([AX_BOOST_BASE],
|
||||
[
|
||||
AC_ARG_WITH([boost],
|
||||
AS_HELP_STRING([--with-boost@<:@=DIR@:>@], [use boost (default is Yes) - it is possible to specify the root directory for boost (optional)]),
|
||||
[
|
||||
if test "$withval" = "no"; then
|
||||
want_boost="no"
|
||||
elif test "$withval" = "yes"; then
|
||||
want_boost="yes"
|
||||
ac_boost_path=""
|
||||
else
|
||||
want_boost="yes"
|
||||
ac_boost_path="$withval"
|
||||
fi
|
||||
],
|
||||
[want_boost="yes"])
|
||||
|
||||
if test "x$want_boost" = "xyes"; then
|
||||
boost_lib_version_req=ifelse([$1], ,1.20.0,$1)
|
||||
boost_lib_version_req_shorten=`expr $boost_lib_version_req : '\([[0-9]]*\.[[0-9]]*\)'`
|
||||
boost_lib_version_req_major=`expr $boost_lib_version_req : '\([[0-9]]*\)'`
|
||||
boost_lib_version_req_minor=`expr $boost_lib_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
|
||||
boost_lib_version_req_sub_minor=`expr $boost_lib_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
|
||||
if test "x$boost_lib_version_req_sub_minor" = "x" ; then
|
||||
boost_lib_version_req_sub_minor="0"
|
||||
fi
|
||||
WANT_BOOST_VERSION=`expr $boost_lib_version_req_major \* 100000 \+ $boost_lib_version_req_minor \* 100 \+ $boost_lib_version_req_sub_minor`
|
||||
AC_MSG_CHECKING(for boostlib >= $boost_lib_version_req)
|
||||
succeeded=no
|
||||
|
||||
dnl first we check the system location for boost libraries
|
||||
dnl this location ist chosen if boost libraries are installed with the --layout=system option
|
||||
dnl or if you install boost with RPM
|
||||
if test "$ac_boost_path" != ""; then
|
||||
BOOST_LDFLAGS="-L$ac_boost_path/lib"
|
||||
BOOST_CPPFLAGS="-I$ac_boost_path/include"
|
||||
else
|
||||
for ac_boost_path_tmp in ${prefix} /usr /usr/local /opt ; do
|
||||
if test -d "$ac_boost_path_tmp/include/boost" && test -r "$ac_boost_path_tmp/include/boost"; then
|
||||
BOOST_LDFLAGS="-L$ac_boost_path_tmp/lib"
|
||||
BOOST_CPPFLAGS="-I$ac_boost_path_tmp/include"
|
||||
break;
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
CPPFLAGS_SAVED="$CPPFLAGS"
|
||||
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
|
||||
export CPPFLAGS
|
||||
|
||||
LDFLAGS_SAVED="$LDFLAGS"
|
||||
LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
|
||||
export LDFLAGS
|
||||
|
||||
AC_LANG_PUSH(C++)
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
||||
@%:@include <boost/version.hpp>
|
||||
]], [[
|
||||
#if BOOST_VERSION >= $WANT_BOOST_VERSION
|
||||
// Everything is okay
|
||||
#else
|
||||
# error Boost version is too old
|
||||
#endif
|
||||
]])],[
|
||||
AC_MSG_RESULT(yes)
|
||||
succeeded=yes
|
||||
found_system=yes
|
||||
],[
|
||||
])
|
||||
AC_LANG_POP([C++])
|
||||
|
||||
|
||||
|
||||
dnl if we found no boost with system layout we search for boost libraries
|
||||
dnl built and installed without the --layout=system option or for a staged(not installed) version
|
||||
if test "x$succeeded" != "xyes"; then
|
||||
_version=0
|
||||
if test "$ac_boost_path" != ""; then
|
||||
BOOST_LDFLAGS="-L$ac_boost_path/lib"
|
||||
if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
|
||||
for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do
|
||||
_version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
|
||||
V_CHECK=`expr $_version_tmp \> $_version`
|
||||
if test "$V_CHECK" = "1" ; then
|
||||
_version=$_version_tmp
|
||||
fi
|
||||
VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
|
||||
BOOST_CPPFLAGS="-I$ac_boost_path/include/boost-$VERSION_UNDERSCORE"
|
||||
done
|
||||
fi
|
||||
else
|
||||
for ac_boost_path in /usr /usr/local /opt ; do
|
||||
if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
|
||||
for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do
|
||||
_version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
|
||||
V_CHECK=`expr $_version_tmp \> $_version`
|
||||
if test "$V_CHECK" = "1" ; then
|
||||
_version=$_version_tmp
|
||||
best_path=$ac_boost_path
|
||||
fi
|
||||
done
|
||||
fi
|
||||
done
|
||||
|
||||
VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
|
||||
BOOST_CPPFLAGS="-I$best_path/include/boost-$VERSION_UNDERSCORE"
|
||||
BOOST_LDFLAGS="-L$best_path/lib"
|
||||
|
||||
if test "x$BOOST_ROOT" != "x"; then
|
||||
if test -d "$BOOST_ROOT" && test -r "$BOOST_ROOT" && test -d "$BOOST_ROOT/stage/lib" && test -r "$BOOST_ROOT/stage/lib"; then
|
||||
version_dir=`expr //$BOOST_ROOT : '.*/\(.*\)'`
|
||||
stage_version=`echo $version_dir | sed 's/boost_//' | sed 's/_/./g'`
|
||||
stage_version_shorten=`expr $stage_version : '\([[0-9]]*\.[[0-9]]*\)'`
|
||||
V_CHECK=`expr $stage_version_shorten \>\= $_version`
|
||||
if test "$V_CHECK" = "1" ; then
|
||||
AC_MSG_NOTICE(We will use a staged boost library from $BOOST_ROOT)
|
||||
BOOST_CPPFLAGS="-I$BOOST_ROOT"
|
||||
BOOST_LDFLAGS="-L$BOOST_ROOT/stage/lib"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
|
||||
export CPPFLAGS
|
||||
LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
|
||||
export LDFLAGS
|
||||
|
||||
AC_LANG_PUSH(C++)
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
||||
@%:@include <boost/version.hpp>
|
||||
]], [[
|
||||
#if BOOST_VERSION >= $WANT_BOOST_VERSION
|
||||
// Everything is okay
|
||||
#else
|
||||
# error Boost version is too old
|
||||
#endif
|
||||
]])],[
|
||||
AC_MSG_RESULT(yes)
|
||||
succeeded=yes
|
||||
found_system=yes
|
||||
],[
|
||||
])
|
||||
AC_LANG_POP([C++])
|
||||
fi
|
||||
|
||||
if test "$succeeded" != "yes" ; then
|
||||
BOOST_CPPFLAGS=""
|
||||
BOOST_LDFLAGS=""
|
||||
AC_MSG_RESULT(no)
|
||||
else
|
||||
AC_SUBST(BOOST_CPPFLAGS)
|
||||
AC_SUBST(BOOST_LDFLAGS)
|
||||
AC_DEFINE(HAVE_BOOST,,[define if the Boost library is available])
|
||||
fi
|
||||
|
||||
CPPFLAGS="$CPPFLAGS_SAVED"
|
||||
LDFLAGS="$LDFLAGS_SAVED"
|
||||
fi
|
||||
|
||||
])
|
||||
|
||||
|
||||
dnl-----------------------------------------------------------------------------
|
||||
dnl Test for Date_Time library from the Boost C++ libraries.
|
||||
dnl for more information on boost, see http://www.boost.org/
|
||||
dnl for more information on this macro, see
|
||||
dnl http://autoconf-archive.cryp.to/ax_boost_date_time.html
|
||||
dnl
|
||||
dnl usage:
|
||||
dnl The macro requires a preceding call to AX_BOOST_BASE.
|
||||
dnl Further documentation is available at
|
||||
dnl <http://randspringer.de/boost/index.html>.
|
||||
dnl
|
||||
dnl This macro calls: AC_SUBST(BOOST_DATE_TIME_LIB)
|
||||
dnl and sets: HAVE_BOOST_DATE_TIME
|
||||
dnl
|
||||
dnl Modified for Campcaster:
|
||||
dnl * --with-boost-date-time default changed to Yes.
|
||||
dnl * added some more recognized suffixes to the library's name, incl. "-st".
|
||||
dnl
|
||||
dnl Authors:
|
||||
dnl Thomas Porschberg <thomas@randspringer.de>
|
||||
dnl Michael Tindal <mtindal@paradoxpoint.com>
|
||||
dnl
|
||||
dnl License:
|
||||
dnl Copyright © 2006 Thomas Porschberg <thomas@randspringer.de>
|
||||
dnl Copying and distribution of this file, with or without modification,
|
||||
dnl are permitted in any medium without royalty provided the copyright notice
|
||||
dnl and this notice are preserved.
|
||||
dnl-----------------------------------------------------------------------------
|
||||
AC_DEFUN([AX_BOOST_DATE_TIME],
|
||||
[
|
||||
AC_ARG_WITH([boost-date-time],
|
||||
AS_HELP_STRING([--with-boost-date-time@<:@=special-lib@:>@],
|
||||
[use the Date_Time library from boost - it is possible to specify a certain library for the linker
|
||||
e.g. --with-boost-date-time=boost_date_time-gcc-mt-d-1_33_1 ]),
|
||||
[
|
||||
if test "$withval" = "no"; then
|
||||
want_boost="no"
|
||||
elif test "$withval" = "yes"; then
|
||||
want_boost="yes"
|
||||
ax_boost_user_date_time_lib=""
|
||||
else
|
||||
want_boost="yes"
|
||||
ax_boost_user_date_time_lib="$withval"
|
||||
fi
|
||||
],
|
||||
[want_boost="yes"]
|
||||
)
|
||||
|
||||
if test "x$want_boost" = "xyes"; then
|
||||
AC_REQUIRE([AC_PROG_CC])
|
||||
CPPFLAGS_SAVED="$CPPFLAGS"
|
||||
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
|
||||
export CPPFLAGS
|
||||
|
||||
LDFLAGS_SAVED="$LDFLAGS"
|
||||
LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
|
||||
export LDFLAGS
|
||||
|
||||
AC_CACHE_CHECK(whether the Boost::Date_Time library is available,
|
||||
ax_cv_boost_date_time,
|
||||
[AC_LANG_PUSH([C++])
|
||||
AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[@%:@include <boost/date_time/gregorian/gregorian_types.hpp>]],
|
||||
[[using namespace boost::gregorian; date d(2002,Jan,10);
|
||||
return 0;
|
||||
]]),
|
||||
ax_cv_boost_date_time=yes, ax_cv_boost_date_time=no)
|
||||
AC_LANG_POP([C++])
|
||||
])
|
||||
if test "x$ax_cv_boost_date_time" = "xyes"; then
|
||||
AC_DEFINE(HAVE_BOOST_DATE_TIME,,[define if the Boost::Date_Time library is available])
|
||||
BN=boost_date_time
|
||||
if test "x$ax_boost_user_date_time_lib" = "x"; then
|
||||
for ax_lib in $BN $BN-st $BN-mt $BN-mt-s $BN-s \
|
||||
$BN-$CC $BN-$CC-st $BN-$CC-mt $BN-$CC-mt-s $BN-$CC-s \
|
||||
lib$BN lib$BN-st lib$BN-mt lib$BN-mt-s lib$BN-s \
|
||||
lib$BN-$CC lib$BN-$CC-st lib$BN-$CC-mt lib$BN-$CC-mt-s lib$BN-$CC-s \
|
||||
$BN-mgw $BN-mgw $BN-mgw-st $BN-mgw-mt $BN-mgw-mt-s $BN-mgw-s ; do
|
||||
AC_CHECK_LIB($ax_lib, main, [BOOST_DATE_TIME_LIB="-l$ax_lib" AC_SUBST(BOOST_DATE_TIME_LIB) link_date_time="yes" break],
|
||||
[link_date_time="no"])
|
||||
done
|
||||
else
|
||||
for ax_lib in $ax_boost_user_date_time_lib $BN-$ax_boost_user_date_time_lib; do
|
||||
AC_CHECK_LIB($ax_lib, main,
|
||||
[BOOST_DATE_TIME_LIB="-l$ax_lib" AC_SUBST(BOOST_DATE_TIME_LIB) link_date_time="yes" break],
|
||||
[link_date_time="no"])
|
||||
done
|
||||
|
||||
fi
|
||||
if test "x$link_date_time" = "xno"; then
|
||||
AC_MSG_ERROR(Could not link against $ax_lib !)
|
||||
fi
|
||||
fi
|
||||
|
||||
CPPFLAGS="$CPPFLAGS_SAVED"
|
||||
LDFLAGS="$LDFLAGS_SAVED"
|
||||
fi
|
||||
])
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE authenticationClientFactory [
|
||||
|
||||
<!ELEMENT authenticationClientFactory (testAuthentication|
|
||||
webAuthentication)>
|
||||
|
||||
<!ELEMENT testAuthentication (user) >
|
||||
|
||||
<!ELEMENT user EMPTY >
|
||||
<!ATTLIST user login CDATA #REQUIRED >
|
||||
<!ATTLIST user password CDATA #REQUIRED >
|
||||
|
||||
]>
|
||||
<authenticationClientFactory>
|
||||
<testAuthentication>
|
||||
<user login="root" password="q" />
|
||||
</testAuthentication>
|
||||
</authenticationClientFactory>
|
|
@ -1,130 +0,0 @@
|
|||
dnl-----------------------------------------------------------------------------
|
||||
dnl Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
dnl
|
||||
dnl This file is part of the Campcaster project.
|
||||
dnl http://campcaster.sourcefabric.org/
|
||||
dnl
|
||||
dnl Campcaster is free software; you can redistribute it and/or modify
|
||||
dnl it under the terms of the GNU General Public License as published by
|
||||
dnl the Free Software Foundation; either version 2 of the License, or
|
||||
dnl (at your option) any later version.
|
||||
dnl
|
||||
dnl Campcaster is distributed in the hope that it will be useful,
|
||||
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
dnl GNU General Public License for more details.
|
||||
dnl
|
||||
dnl You should have received a copy of the GNU General Public License
|
||||
dnl along with Campcaster; if not, write to the Free Software
|
||||
dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
dnl
|
||||
dnl-----------------------------------------------------------------------------
|
||||
|
||||
dnl-----------------------------------------------------------------------------
|
||||
dnl NOTE: Run all configure related scripts from the tmp directory of the
|
||||
dnl project.
|
||||
dnl This is due to the fact that configure spreads a lot of trash around,
|
||||
dnl like atom4te cache directories, config.* files, etc. into the directory
|
||||
dnl it is being run from. We clearly don't want these in our base directory.
|
||||
dnl-----------------------------------------------------------------------------
|
||||
AC_INIT(StorageClient, 0.0, bugs@campware.org)
|
||||
AC_PREREQ(2.59)
|
||||
AC_COPYRIGHT([Copyright (c) 2010 Sourcefabric O.P.S. under the GNU GPL])
|
||||
AC_REVISION($Revision$)
|
||||
|
||||
AC_CONFIG_SRCDIR(../src/StorageClientFactory.cxx)
|
||||
|
||||
AC_CONFIG_HEADERS(configure.h)
|
||||
AC_PROG_CXX()
|
||||
|
||||
AC_CHECK_HEADERS(getopt.h sys/time.h time.h)
|
||||
|
||||
|
||||
dnl-----------------------------------------------------------------------------
|
||||
dnl specify whether debug info should be compiled into the executable
|
||||
dnl-----------------------------------------------------------------------------
|
||||
AC_SUBST(CXXFLAGS)
|
||||
|
||||
AC_ARG_ENABLE([debug],
|
||||
AC_HELP_STRING([--enable-debug], [compile with debug info (no)]),
|
||||
[],
|
||||
[enable_debug=no])
|
||||
|
||||
if test "x${enable_debug}" = "xyes"; then
|
||||
CXXFLAGS="-g -O0"
|
||||
AC_DEFINE( YDEBUG, 1, [Debug is on] )
|
||||
else
|
||||
CXXFLAGS="-O3"
|
||||
fi
|
||||
|
||||
|
||||
AC_MSG_RESULT([using compiler options: ${CXXFLAGS}])
|
||||
|
||||
|
||||
dnl-----------------------------------------------------------------------------
|
||||
dnl specify the pkg-config path
|
||||
dnl-----------------------------------------------------------------------------
|
||||
AC_ARG_WITH([pkg-config-path],
|
||||
AC_HELP_STRING([--with-pkg-config-path],
|
||||
[use the pkg-config path (prefix/lib/pkgconfig)]),
|
||||
[PKG_CONFIG_PATH=${withval}],
|
||||
[PKG_CONFIG_PATH=${prefix}/lib/pkgconfig:$PKG_CONFIG_PATH])
|
||||
|
||||
AC_MSG_RESULT([using pkg-config path: ${PKG_CONFIG_PATH}])
|
||||
|
||||
export PKG_CONFIG_PATH
|
||||
|
||||
export PATH=${prefix}/bin:${PATH}
|
||||
|
||||
|
||||
AX_BOOST_BASE([1.33.1])
|
||||
if test "x${BOOST_CPPFLAGS}" != "x"; then
|
||||
AX_BOOST_DATE_TIME
|
||||
if test "x${BOOST_DATE_TIME_LIB}" = "x"; then
|
||||
AC_MSG_ERROR([Boost date-time library not found])
|
||||
fi
|
||||
else
|
||||
AC_MSG_ERROR([Boost library >= 1.33.1 not found])
|
||||
fi
|
||||
|
||||
PKG_CHECK_MODULES(LIBXMLPP,[libxml++-2.6 >= 2.8.1])
|
||||
AC_SUBST(LIBXMLPP_CFLAGS)
|
||||
AC_SUBST(LIBXMLPP_LIBS)
|
||||
|
||||
AC_CHECK_CURL(7.12.3)
|
||||
AC_SUBST(CURL_CFLAGS)
|
||||
AC_SUBST(CURL_LIBS)
|
||||
|
||||
AC_CHECK_TAGLIB(1.3.1)
|
||||
AC_SUBST(TAGLIB_CFLAGS)
|
||||
AC_SUBST(TAGLIB_LIBS)
|
||||
|
||||
AC_CHECK_ICU(3.0)
|
||||
AC_SUBST(ICU_CFLAGS)
|
||||
AC_SUBST(ICU_CXXFLAGS)
|
||||
AC_SUBST(ICU_LIBS)
|
||||
|
||||
AC_PATH_PROG(GENRB, genrb)
|
||||
AC_SUBST(GENRB)
|
||||
|
||||
|
||||
dnl-----------------------------------------------------------------------------
|
||||
dnl enable compilaton for code coverage data
|
||||
dnl-----------------------------------------------------------------------------
|
||||
AC_SUBST(COVERAGE_CXXFLAGS)
|
||||
|
||||
AC_ARG_ENABLE( coverage,
|
||||
[ --enable-coverage enable code coverage data generaton (no) ],
|
||||
ENABLE_COVERAGE=${enableval}, ENABLE_COVERAGE="no" )
|
||||
|
||||
if test "x${ENABLE_COVERAGE}" == "xyes" ; then
|
||||
COVERAGE_CXXFLAGS="-fprofile-arcs -ftest-coverage"
|
||||
AC_MSG_RESULT([compiling in code coverage mode])
|
||||
else
|
||||
AC_MSG_RESULT([not compiling in code coverage mode])
|
||||
fi
|
||||
|
||||
|
||||
AC_CONFIG_FILES(../Makefile:../etc/Makefile.in)
|
||||
|
||||
AC_OUTPUT()
|
File diff suppressed because it is too large
Load Diff
|
@ -1,76 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE storageClientFactory [
|
||||
|
||||
<!ELEMENT storageClientFactory (testStorage|webStorage) >
|
||||
|
||||
<!ELEMENT testStorage (playlist*, audioClip*) >
|
||||
<!ATTLIST testStorage tempFiles CDATA #REQUIRED >
|
||||
|
||||
<!ELEMENT playlist (playlistElement*) >
|
||||
<!ATTLIST playlist id NMTOKEN #REQUIRED >
|
||||
<!ATTLIST playlist playlength NMTOKEN #REQUIRED >
|
||||
|
||||
<!ELEMENT playlistElement ((audioClip|playlist), fadeInfo?) >
|
||||
<!ATTLIST playlistElement id NMTOKEN #REQUIRED >
|
||||
<!ATTLIST playlistElement relativeOffset NMTOKEN #REQUIRED >
|
||||
|
||||
<!ELEMENT audioClip EMPTY >
|
||||
<!ATTLIST audioClip id NMTOKEN #REQUIRED >
|
||||
<!ATTLIST audioClip playlength NMTOKEN #REQUIRED >
|
||||
<!ATTLIST audioClip title CDATA #REQUIRED >
|
||||
<!ATTLIST audioClip uri CDATA #REQUIRED >
|
||||
|
||||
<!ELEMENT fadeInfo EMPTY >
|
||||
<!ATTLIST fadeInfo id NMTOKEN #REQUIRED >
|
||||
<!ATTLIST fadeInfo fadeIn NMTOKEN #REQUIRED >
|
||||
<!ATTLIST fadeInfo fadeOut NMTOKEN #REQUIRED >
|
||||
|
||||
<!ELEMENT webStorage (location) >
|
||||
<!ATTLIST webStorage tempFiles CDATA #REQUIRED >
|
||||
|
||||
<!ELEMENT location EMPTY >
|
||||
<!ATTLIST location server CDATA #REQUIRED >
|
||||
<!ATTLIST location port NMTOKEN #REQUIRED >
|
||||
<!ATTLIST location path CDATA #REQUIRED >
|
||||
|
||||
]>
|
||||
<storageClientFactory>
|
||||
<testStorage tempFiles="file:///tmp/tempPlaylist">
|
||||
<playlist id="1" playlength="00:00:34.000000" >
|
||||
<playlistElement id="101" relativeOffset="0" >
|
||||
<audioClip id="10001" playlength="00:00:11.000000"
|
||||
title="one"
|
||||
uri="file:var/test1.mp3" />
|
||||
</playlistElement>
|
||||
<playlistElement id="102" relativeOffset="00:00:11.000000" >
|
||||
<audioClip id="10002" playlength="00:00:12.000000"
|
||||
title="two"
|
||||
uri="file:var/test2.mp3" />
|
||||
<fadeInfo id="9901" fadeIn="00:00:02.000000"
|
||||
fadeOut="00:00:01.500000" />
|
||||
</playlistElement>
|
||||
<playlistElement id="103" relativeOffset="00:00:23.000000" >
|
||||
<playlist id="2" playlength="00:00:11.000000" >
|
||||
<playlistElement id="111" relativeOffset="00:00:00.000000" >
|
||||
<audioClip id="10003" playlength="00:00:11.000000"
|
||||
title="three"
|
||||
uri="file:var/test3.mp3" />
|
||||
</playlistElement>
|
||||
</playlist>
|
||||
</playlistElement>
|
||||
</playlist>
|
||||
<playlist id="2" playlength="00:00:11.000000" >
|
||||
<playlistElement id="111" relativeOffset="00:00:00.000000" >
|
||||
<audioClip id="10003" playlength="00:00:11.000000"
|
||||
title="three"
|
||||
uri="file:var/test3.mp3" />
|
||||
</playlistElement>
|
||||
</playlist>
|
||||
<audioClip id="10001" playlength="01:00:00.000000"
|
||||
title="one"
|
||||
uri="file:var/test1.mp3" />
|
||||
<audioClip id="10002" playlength="00:30:00.000000"
|
||||
title="two"
|
||||
uri="file:var/test2.mp3" />
|
||||
</testStorage>
|
||||
</storageClientFactory>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue