added initial version of the event scheduler and audio player
integrated into the scheduler daemon
This commit is contained in:
parent
654ec9651a
commit
692230835a
|
@ -20,8 +20,8 @@
|
|||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
#
|
||||
# Author : $Author: fgerlits $
|
||||
# Version : $Revision: 1.20 $
|
||||
# Author : $Author: maroy $
|
||||
# Version : $Revision: 1.21 $
|
||||
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/etc/Makefile.in,v $
|
||||
#
|
||||
# @configure_input@
|
||||
|
@ -53,6 +53,14 @@ USR_LIB_DIR = ${USR_DIR}/lib
|
|||
BOOST_INCLUDE_DIR = ${USR_INCLUDE_DIR}/boost-1_31
|
||||
LIBXMLPP_INCLUDE_DIR = ${USR_INCLUDE_DIR}/libxml++-1.0
|
||||
|
||||
HELIX_LIB_DIR = ${USR_LIB_DIR}/helix
|
||||
HELIX_LIBS = ${HELIX_LIB_DIR}/runtlib.a \
|
||||
${HELIX_LIB_DIR}/syslib.a \
|
||||
${HELIX_LIB_DIR}/contlib.a \
|
||||
${HELIX_LIB_DIR}/debuglib.a \
|
||||
${HELIX_LIB_DIR}/utillib.a
|
||||
|
||||
|
||||
VPATH = ${SRC_DIR}
|
||||
|
||||
MODULES_DIR = ${BASE_DIR}/../../modules
|
||||
|
@ -75,6 +83,18 @@ STORAGE_LIB_DIR = ${STORAGE_DIR}/lib
|
|||
STORAGE_LIB = livesupport_storage
|
||||
STORAGE_LIB_FILE = ${STORAGE_LIB_DIR}/lib${STORAGE_LIB}.a
|
||||
|
||||
PLAYLIST_EXECUTOR_DIR = ${MODULES_DIR}/playlistExecutor
|
||||
PLAYLIST_EXECUTOR_INCLUDE_DIR = ${PLAYLIST_EXECUTOR_DIR}/include
|
||||
PLAYLIST_EXECUTOR_LIB_DIR = ${PLAYLIST_EXECUTOR_DIR}/lib
|
||||
PLAYLIST_EXECUTOR_LIB = livesupport_playlist_executor
|
||||
PLAYLIST_EXECUTOR_LIB_FILE = ${PLAYLIST_EXECUTOR_LIB_DIR}/lib${PLAYLIST_EXECUTOR_LIB}.a
|
||||
|
||||
EVENT_SCHEDULER_DIR = ${MODULES_DIR}/eventScheduler
|
||||
EVENT_SCHEDULER_INCLUDE_DIR = ${EVENT_SCHEDULER_DIR}/include
|
||||
EVENT_SCHEDULER_LIB_DIR = ${EVENT_SCHEDULER_DIR}/lib
|
||||
EVENT_SCHEDULER_LIB = livesupport_event_scheduler
|
||||
EVENT_SCHEDULER_LIB_FILE = ${EVENT_SCHEDULER_LIB_DIR}/lib${EVENT_SCHEDULER_LIB}.a
|
||||
|
||||
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
|
||||
|
@ -98,11 +118,15 @@ CXXFLAGS = @CXXFLAGS@ @DEFS@ @COVERAGE_CXXFLAGS@ \
|
|||
-I${CORE_INCLUDE_DIR} \
|
||||
-I${DB_INCLUDE_DIR} \
|
||||
-I${STORAGE_INCLUDE_DIR} \
|
||||
-I${PLAYLIST_EXECUTOR_INCLUDE_DIR} \
|
||||
-I${EVENT_SCHEDULER_INCLUDE_DIR} \
|
||||
-I${TMP_DIR}
|
||||
LDFLAGS = @LDFLAGS@ -L${USR_LIB_DIR} \
|
||||
LDFLAGS = @LDFLAGS@ -L${USR_LIB_DIR} -L${HELIX_LIB_DIR} \
|
||||
-L${CORE_LIB_DIR} \
|
||||
-L${DB_LIB_DIR} \
|
||||
-L${STORAGE_LIB_DIR}
|
||||
-L${STORAGE_LIB_DIR} \
|
||||
-L${PLAYLIST_EXECUTOR_LIB_DIR} \
|
||||
-L${EVENT_SCHEDULER_LIB_DIR}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
@ -133,12 +157,16 @@ SCHEDULER_OBJS = ${TMP_DIR}/SignalDispatcher.o \
|
|||
${TMP_DIR}/PlayLogFactory.o \
|
||||
${TMP_DIR}/PostgresqlPlayLog.o \
|
||||
${TMP_DIR}/GeneratePlayReportMethod.o \
|
||||
${TMP_DIR}/UpdateFadeInFadeOutMethod.o
|
||||
${TMP_DIR}/UpdateFadeInFadeOutMethod.o \
|
||||
${TMP_DIR}/PlaylistEventContainer.o \
|
||||
${TMP_DIR}/PlaylistEvent.o
|
||||
|
||||
|
||||
SCHEDULER_EXE_OBJS = ${SCHEDULER_OBJS} \
|
||||
${TMP_DIR}/main.o
|
||||
SCHEDULER_EXE_LIBS = -l${STORAGE_LIB} -l${DB_LIB} -l${CORE_LIB} \
|
||||
SCHEDULER_EXE_LIBS = -l${EVENT_SCHEDULER_LIB} -l${PLAYLIST_EXECUTOR_LIB} \
|
||||
-l${STORAGE_LIB} -l${DB_LIB} -l${CORE_LIB} \
|
||||
${HELIX_LIBS} \
|
||||
-lodbc++ -lboost_date_time-gcc \
|
||||
-lxmlrpc++ -lssl -lxml++-1.0
|
||||
|
||||
|
@ -198,6 +226,8 @@ docclean:
|
|||
${RM} ${TEST_RESULTS}
|
||||
|
||||
depclean: clean
|
||||
${MAKE} -C ${EVENT_SCHEDULER_DIR} clean
|
||||
${MAKE} -C ${PLAYLIST_EXECUTOR_DIR} clean
|
||||
${MAKE} -C ${STORAGE_DIR} clean
|
||||
${MAKE} -C ${DB_DIR} clean
|
||||
${MAKE} -C ${CORE_DIR} clean
|
||||
|
@ -221,6 +251,9 @@ start: ${SCHEDULER_EXE}
|
|||
stop: ${SCHEDULER_EXE}
|
||||
LD_LIBRARY_PATH=${USR_LIB_DIR} ${SCHEDULER_EXE} -c ${SCHEDULER_CFG} stop
|
||||
|
||||
status: ${SCHEDULER_EXE}
|
||||
LD_LIBRARY_PATH=${USR_LIB_DIR} ${SCHEDULER_EXE} -c ${SCHEDULER_CFG} status
|
||||
|
||||
uninstall: ${SCHEDULER_EXE}
|
||||
LD_LIBRARY_PATH=${USR_LIB_DIR} ${SCHEDULER_EXE} -c ${SCHEDULER_CFG} \
|
||||
uninstall
|
||||
|
@ -230,6 +263,7 @@ uninstall: ${SCHEDULER_EXE}
|
|||
# Specific targets
|
||||
#-------------------------------------------------------------------------------
|
||||
${SCHEDULER_EXE}: ${CORE_LIB_FILE} ${DB_LIB_FILE} ${STORAGE_LIB_FILE} \
|
||||
${PLAYLIST_EXECUTOR_LIB_FILE} ${EVENT_SCHEDULER_LIB_FILE} \
|
||||
${SCHEDULER_EXE_OBJS}
|
||||
${CXX} ${LDFLAGS} -o $@ $^ ${SCHEDULER_EXE_LIBS}
|
||||
|
||||
|
@ -240,6 +274,7 @@ ${DOXYGEN_DIR}:
|
|||
${MKDIR} ${DOXYGEN_DIR}
|
||||
|
||||
${TEST_RUNNER}: ${CORE_LIB_FILE} ${DB_LIB_FILE} ${STORAGE_LIB_FILE} \
|
||||
${PLAYLIST_EXECUTOR_LIB_FILE} ${EVENT_SCHEDULER_LIB_FILE} \
|
||||
${TEST_RUNNER_OBJS}
|
||||
${CXX} ${LDFLAGS} -o $@ ${TEST_RUNNER_OBJS} ${TEST_RUNNER_LIBS}
|
||||
|
||||
|
@ -252,6 +287,12 @@ ${DB_LIB_FILE}:
|
|||
${STORAGE_LIB_FILE}:
|
||||
${MAKE} -C ${STORAGE_DIR}
|
||||
|
||||
${PLAYLIST_EXECUTOR_LIB_FILE}:
|
||||
${MAKE} -C ${PLAYLIST_EXECUTOR_DIR}
|
||||
|
||||
${EVENT_SCHEDULER_LIB_FILE}:
|
||||
${MAKE} -C ${EVENT_SCHEDULER_DIR}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Pattern rules
|
||||
|
|
|
@ -21,7 +21,7 @@ dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|||
dnl
|
||||
dnl
|
||||
dnl Author : $Author: maroy $
|
||||
dnl Version : $Revision: 1.3 $
|
||||
dnl Version : $Revision: 1.4 $
|
||||
dnl Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/etc/configure.ac,v $
|
||||
dnl-----------------------------------------------------------------------------
|
||||
|
||||
|
@ -35,7 +35,7 @@ dnl-----------------------------------------------------------------------------
|
|||
AC_INIT(Scheduler, 0.1, bugs@campware.org)
|
||||
AC_PREREQ(2.59)
|
||||
AC_COPYRIGHT([Copyright (c) 2004 Media Development Loan Fund under the GNU GPL])
|
||||
AC_REVISION($Revision: 1.3 $)
|
||||
AC_REVISION($Revision: 1.4 $)
|
||||
|
||||
AC_CONFIG_SRCDIR(../src/main.cxx)
|
||||
|
||||
|
@ -43,7 +43,7 @@ AC_CONFIG_HEADERS(configure.h)
|
|||
AC_PROG_CXX()
|
||||
|
||||
AC_CHECK_HEADERS(sys/types.h unistd.h getopt.h signal.h sys/stat.h time.h)
|
||||
AC_CHECK_HEADERS(stdio.h fcntl.h)
|
||||
AC_CHECK_HEADERS(stdio.h fcntl.h pthread.h sys/time.h)
|
||||
|
||||
dnl-----------------------------------------------------------------------------
|
||||
dnl enable compilaton for code coverage data
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<!DOCTYPE scheduler [
|
||||
|
||||
<!ELEMENT scheduler (connectionManagerFactory,storageClientFactory,
|
||||
scheduleFactory,xmlRpcDaemon) >
|
||||
scheduleFactory,audioPlayer,xmlRpcDaemon) >
|
||||
|
||||
<!ELEMENT connectionManagerFactory (simpleConnectionManager) >
|
||||
|
||||
|
@ -23,6 +23,11 @@
|
|||
|
||||
<!ELEMENT postgresqlSchedule EMPTY >
|
||||
|
||||
<!ELEMENT audioPlayer (helixPlayer) >
|
||||
|
||||
<!ELEMENT helixPlayer EMPTY >
|
||||
<!ATTLIST helixPlayer dllPath CDATA #REQUIRED >
|
||||
|
||||
<!ELEMENT xmlRpcDaemon EMPTY >
|
||||
<!ATTLIST xmlRpcDaemon xmlRpcHost CDATA #REQUIRED >
|
||||
<!ATTLIST xmlRpcDaemon xmlRpcPort NMTOKEN #REQUIRED >
|
||||
|
@ -48,6 +53,10 @@
|
|||
<postgresqlSchedule/>
|
||||
</scheduleFactory>
|
||||
|
||||
<audioPlayer>
|
||||
<helixPlayer dllPath = "../../usr/lib/helix"/>
|
||||
</audioPlayer>
|
||||
|
||||
<xmlRpcDaemon xmlRpcHost = "localhost"
|
||||
xmlRpcPort = "3344"
|
||||
pidFileName = "tmp/scheduler.pid"
|
||||
|
|
|
@ -0,0 +1,116 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport 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.
|
||||
|
||||
LiveSupport 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 LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.1 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/PlaylistEvent.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#else
|
||||
#error need unistd.h
|
||||
#endif
|
||||
|
||||
#include "LiveSupport/Core/TimeConversion.h"
|
||||
|
||||
#include "PlaylistEvent.h"
|
||||
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Scheduler;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Constructor.
|
||||
*----------------------------------------------------------------------------*/
|
||||
PlaylistEvent :: PlaylistEvent(
|
||||
Ptr<AudioPlayerInterface>::Ref audioPlayer,
|
||||
Ptr<StorageClientInterface>::Ref storage,
|
||||
Ptr<ScheduleEntry>::Ref scheduleEntry)
|
||||
throw ()
|
||||
{
|
||||
this->audioPlayer = audioPlayer;
|
||||
this->storage = storage;
|
||||
this->scheduleEntry = scheduleEntry;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Initialize the event object.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
PlaylistEvent :: initialize(void) throw (std::exception)
|
||||
{
|
||||
playlistUrl = storage->acquirePlaylist(scheduleEntry->getPlaylistId());
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Initialize the event object.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
PlaylistEvent :: deInitialize(void) throw ()
|
||||
{
|
||||
storage->releasePlaylist(scheduleEntry->getPlaylistId());
|
||||
playlistUrl.reset();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Initialize the event object.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
PlaylistEvent :: start(void) throw ()
|
||||
{
|
||||
audioPlayer->playThis(*playlistUrl);
|
||||
audioPlayer->start();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Initialize the event object.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
PlaylistEvent :: stop(void) throw ()
|
||||
{
|
||||
audioPlayer->stop();
|
||||
}
|
||||
|
|
@ -0,0 +1,215 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport 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.
|
||||
|
||||
LiveSupport 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 LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.1 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/PlaylistEvent.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef PlaylistEvent_h
|
||||
#define PlaylistEvent_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
#endif
|
||||
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include "LiveSupport/Core/StorageClientInterface.h"
|
||||
#include "LiveSupport/PlaylistExecutor/AudioPlayerInterface.h"
|
||||
#include "LiveSupport/EventScheduler/ScheduledEventInterface.h"
|
||||
|
||||
#include "ScheduleEntry.h"
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
||||
using namespace boost::posix_time;
|
||||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::PlaylistExecutor;
|
||||
using namespace LiveSupport::EventScheduler;
|
||||
using namespace LiveSupport::Scheduler;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
||||
/* =================================================================== macros */
|
||||
|
||||
|
||||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* A scheduled event for playing a playlist.
|
||||
*
|
||||
* @author $Author: maroy $
|
||||
* @version $Revision: 1.1 $
|
||||
*/
|
||||
class PlaylistEvent : public virtual ScheduledEventInterface
|
||||
{
|
||||
private:
|
||||
/**
|
||||
* The audio player to play the playlist with.
|
||||
*/
|
||||
Ptr<AudioPlayerInterface>::Ref audioPlayer;
|
||||
|
||||
/**
|
||||
* The storage containing the playlist and all related audio clips.
|
||||
*/
|
||||
Ptr<StorageClientInterface>::Ref storage;
|
||||
|
||||
/**
|
||||
* The schedule entry this event is playing.
|
||||
*/
|
||||
Ptr<ScheduleEntry>::Ref scheduleEntry;
|
||||
|
||||
/**
|
||||
* The maximum time this event should get initialized in.
|
||||
*/
|
||||
Ptr<time_duration>::Ref initTime;
|
||||
|
||||
/**
|
||||
* The URL for this playlist file.
|
||||
*/
|
||||
Ptr<std::string>::Ref playlistUrl;
|
||||
|
||||
|
||||
public:
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param audioPlayer the audio player to play the playlist with.
|
||||
* @param storage the storage containing the playlist to play,
|
||||
* and all the related audio clips.
|
||||
* @param scheduleEntry the schedule entry this event is
|
||||
* playing.
|
||||
*/
|
||||
PlaylistEvent(Ptr<AudioPlayerInterface>::Ref audioPlayer,
|
||||
Ptr<StorageClientInterface>::Ref storage,
|
||||
Ptr<ScheduleEntry>::Ref scheduleEntry)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* A virtual destructor, as this class has virtual functions.
|
||||
*/
|
||||
virtual
|
||||
~PlaylistEvent(void) throw ()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell the time this event is scheduled for.
|
||||
*
|
||||
* @return the time this event is scheduled for.
|
||||
*/
|
||||
virtual Ptr<const ptime>::Ref
|
||||
getScheduledTime(void) throw ()
|
||||
{
|
||||
return scheduleEntry->getStartTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the event object.
|
||||
* This should finishin at most maxTimeToInitialize() time.
|
||||
* Use this call to allocate any resources that will be needed
|
||||
* by the event itself.
|
||||
*
|
||||
* @exception std::exception on initialization problems.
|
||||
* a raised exception will result in the cancellation
|
||||
* of the event.
|
||||
* @see #maxTimeToInitialize
|
||||
*/
|
||||
virtual void
|
||||
initialize(void) throw (std::exception);
|
||||
|
||||
/**
|
||||
* The maximum time for the initalize() function to complete.
|
||||
* It is the responsibility of the ScheduledEventInterface object to
|
||||
* complete the initialization in that time.
|
||||
*
|
||||
* @return the maximum time for the initialize() function to complete.
|
||||
* @see #initialize
|
||||
*/
|
||||
virtual Ptr<const time_duration>::Ref
|
||||
maxTimeToInitialize(void) throw ()
|
||||
{
|
||||
return initTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* De-initialize the event object.
|
||||
*/
|
||||
virtual void
|
||||
deInitialize(void) throw ();
|
||||
|
||||
/**
|
||||
* Start the event.
|
||||
* This function call should start the execution of the event in
|
||||
* a separate thread, and return immediately.
|
||||
*/
|
||||
virtual void
|
||||
start(void) throw ();
|
||||
|
||||
/**
|
||||
* The length of the event.
|
||||
* The scheduler will call stop() when this much time has passed
|
||||
* after calling start().
|
||||
*
|
||||
* @return the length of the event, in time.
|
||||
*/
|
||||
virtual Ptr<const time_duration>::Ref
|
||||
eventLength(void) throw ()
|
||||
{
|
||||
return scheduleEntry->getPlaylength();
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop the event.
|
||||
* This function call should result in the event stopping, if
|
||||
* this has not happened yet. The processing of this event should
|
||||
* persue in a seperate thread, and the function itself should
|
||||
* return immediately.
|
||||
*/
|
||||
virtual void
|
||||
stop(void) throw ();
|
||||
};
|
||||
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
||||
|
||||
/* ====================================================== function prototypes */
|
||||
|
||||
|
||||
} // namespace Scheduler
|
||||
} // namespace LiveSupport
|
||||
|
||||
|
||||
#endif // PlaylistEvent_h
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport 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.
|
||||
|
||||
LiveSupport 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 LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.1 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/PlaylistEventContainer.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#else
|
||||
#error need unistd.h
|
||||
#endif
|
||||
|
||||
|
||||
#include "PlaylistEventContainer.h"
|
||||
#include "PlaylistEvent.h"
|
||||
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::EventScheduler;
|
||||
using namespace LiveSupport::Scheduler;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Constructor.
|
||||
*----------------------------------------------------------------------------*/
|
||||
PlaylistEventContainer :: PlaylistEventContainer(
|
||||
Ptr<StorageClientInterface>::Ref storage,
|
||||
Ptr<ScheduleInterface>::Ref schedule,
|
||||
Ptr<AudioPlayerInterface>::Ref audioPlayer)
|
||||
throw ()
|
||||
{
|
||||
this->storage = storage;
|
||||
this->schedule = schedule;
|
||||
this->audioPlayer = audioPlayer;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Return the first scheduled event after the specified timepoint
|
||||
*----------------------------------------------------------------------------*/
|
||||
Ptr<ScheduledEventInterface>::Ref
|
||||
PlaylistEventContainer :: getNextEvent(Ptr<ptime>::Ref when) throw ()
|
||||
{
|
||||
Ptr<ScheduleEntry>::Ref entry = schedule->getNextEntry(when);
|
||||
Ptr<PlaylistEvent>::Ref event;
|
||||
|
||||
if (entry.get()) {
|
||||
event.reset(new PlaylistEvent(audioPlayer, storage, entry));
|
||||
}
|
||||
|
||||
return event;
|
||||
}
|
||||
|
|
@ -0,0 +1,139 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport 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.
|
||||
|
||||
LiveSupport 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 LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.1 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/PlaylistEventContainer.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef PlaylistEventContainer_h
|
||||
#define PlaylistEventContainer_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
#endif
|
||||
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include "LiveSupport/Core/StorageClientInterface.h"
|
||||
#include "LiveSupport/PlaylistExecutor/AudioPlayerInterface.h"
|
||||
#include "LiveSupport/EventScheduler/EventContainerInterface.h"
|
||||
|
||||
#include "ScheduleInterface.h"
|
||||
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
||||
using namespace boost::posix_time;
|
||||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::PlaylistExecutor;
|
||||
using namespace LiveSupport::EventScheduler;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
||||
/* =================================================================== macros */
|
||||
|
||||
|
||||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* An event container holding the scheduled playlists.
|
||||
*
|
||||
* @author $Author: maroy $
|
||||
* @version $Revision: 1.1 $
|
||||
*/
|
||||
class PlaylistEventContainer : public virtual EventContainerInterface
|
||||
{
|
||||
private:
|
||||
/**
|
||||
* The storage containing the playlists to play.
|
||||
*/
|
||||
Ptr<StorageClientInterface>::Ref storage;
|
||||
|
||||
/**
|
||||
* The schedule interface to get the events from.
|
||||
*/
|
||||
Ptr<ScheduleInterface>::Ref schedule;
|
||||
|
||||
/**
|
||||
* The audio player to play the playlist with.
|
||||
*/
|
||||
Ptr<AudioPlayerInterface>::Ref audioPlayer;
|
||||
|
||||
|
||||
public:
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param storage the storage containing the playlist and related
|
||||
* audio clips
|
||||
* @param schedule the schedule to get the events from.
|
||||
* @param audioPlayer the audio player to play the playlists with.
|
||||
*/
|
||||
PlaylistEventContainer(Ptr<StorageClientInterface>::Ref storage,
|
||||
Ptr<ScheduleInterface>::Ref schedule,
|
||||
Ptr<AudioPlayerInterface>::Ref audioPlayer)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* A virtual destructor, as this class has virtual functions.
|
||||
*/
|
||||
virtual
|
||||
~PlaylistEventContainer(void) throw ()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the first event after the specified timepoint.
|
||||
*
|
||||
* @param when return the first event after this timepoint,
|
||||
* @return the first event to schedule after the specified
|
||||
* timepoint. may be a reference to 0, if currently
|
||||
* there are no known events after the specified time.
|
||||
*/
|
||||
virtual Ptr<ScheduledEventInterface>::Ref
|
||||
getNextEvent(Ptr<ptime>::Ref when) throw ();
|
||||
};
|
||||
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
||||
|
||||
/* ====================================================== function prototypes */
|
||||
|
||||
|
||||
} // namespace Scheduler
|
||||
} // namespace LiveSupport
|
||||
|
||||
|
||||
#endif // PlaylistEventContainer_h
|
||||
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.4 $
|
||||
Version : $Revision: 1.5 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/PostgresqlSchedule.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -124,6 +124,17 @@ const std::string PostgresqlSchedule::getScheduleEntriesStmt =
|
|||
"(? <= starts) AND (starts < ?) "
|
||||
"ORDER BY starts";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The SQL statement for querying the next scheduled entry from the
|
||||
* specified timepoint.
|
||||
* The parameters for this call are: from
|
||||
* and returns the properties: id, playlist, starts, ends for the next
|
||||
* schedule entry after the specified timepoint
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string PostgresqlSchedule::getNextEntryStmt =
|
||||
"SELECT id, playlist, starts, ends FROM schedule WHERE ? < starts "
|
||||
"ORDER BY starts";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The SQL statement for querying if a schedule entry exists.
|
||||
* Expects a single argument, the id of the schedule to check.
|
||||
|
@ -349,6 +360,51 @@ PostgresqlSchedule :: getScheduleEntries(
|
|||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Get the next schedule entry after a specified timepoint
|
||||
*----------------------------------------------------------------------------*/
|
||||
Ptr<ScheduleEntry>::Ref
|
||||
PostgresqlSchedule :: getNextEntry(Ptr<ptime>::Ref fromTime)
|
||||
throw ()
|
||||
{
|
||||
Ptr<Connection>::Ref conn;
|
||||
Ptr<ScheduleEntry>::Ref result;
|
||||
|
||||
try {
|
||||
conn = cm->getConnection();
|
||||
Ptr<Timestamp>::Ref timestamp;
|
||||
Ptr<PreparedStatement>::Ref pstmt(conn->prepareStatement(
|
||||
getNextEntryStmt));
|
||||
timestamp = Conversion::ptimeToTimestamp(fromTime);
|
||||
pstmt->setTimestamp(1, *timestamp);
|
||||
|
||||
Ptr<ResultSet>::Ref rs(pstmt->executeQuery());
|
||||
if (rs->next()) {
|
||||
Ptr<UniqueId>::Ref id(new UniqueId(rs->getInt(1)));
|
||||
Ptr<UniqueId>::Ref playlistId(new UniqueId(rs->getInt(2)));
|
||||
|
||||
*timestamp = rs->getTimestamp(3);
|
||||
Ptr<ptime>::Ref startTime = Conversion::timestampToPtime(timestamp);
|
||||
|
||||
*timestamp = rs->getTimestamp(4);
|
||||
Ptr<ptime>::Ref endTime = Conversion::timestampToPtime(timestamp);
|
||||
|
||||
result.reset(new ScheduleEntry(id, playlistId, startTime, endTime));
|
||||
}
|
||||
|
||||
cm->returnConnection(conn);
|
||||
} catch (std::exception &e) {
|
||||
if (conn) {
|
||||
cm->returnConnection(conn);
|
||||
}
|
||||
// TODO: report error
|
||||
return result;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Tell if a schedule entry exists.
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.5 $
|
||||
Version : $Revision: 1.6 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/PostgresqlSchedule.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -81,7 +81,7 @@ using namespace LiveSupport::Core;
|
|||
* </code></pre>
|
||||
*
|
||||
* @author $Author: maroy $
|
||||
* @version $Revision: 1.5 $
|
||||
* @version $Revision: 1.6 $
|
||||
*/
|
||||
class PostgresqlSchedule : public Configurable,
|
||||
public ScheduleInterface
|
||||
|
@ -127,6 +127,12 @@ class PostgresqlSchedule : public Configurable,
|
|||
*/
|
||||
static const std::string getScheduleEntriesStmt;
|
||||
|
||||
/**
|
||||
* The SQL statement for getting the next schedule entry after a
|
||||
* timepoint.
|
||||
*/
|
||||
static const std::string getNextEntryStmt;
|
||||
|
||||
/**
|
||||
* The SQL statement for telling if a schedule entry exists.
|
||||
*/
|
||||
|
@ -259,6 +265,18 @@ class PostgresqlSchedule : public Configurable,
|
|||
Ptr<ptime>::Ref toTime)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* Return the next schedule entry, after (but not including)
|
||||
* the specified timepoint.
|
||||
*
|
||||
* @param fromTime the start of the time of the interval queried,
|
||||
* inclusive
|
||||
* @return the first schedule entry, after the specified timepoint.
|
||||
*/
|
||||
virtual Ptr<ScheduleEntry>::Ref
|
||||
getNextEntry(Ptr<ptime>::Ref fromTime)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* Tell if a schedule entry exists by the give name.
|
||||
*
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.5 $
|
||||
Version : $Revision: 1.6 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/PostgresqlScheduleTest.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -299,6 +299,58 @@ PostgresqlScheduleTest :: getScheduleEntriesTest(void)
|
|||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* See if getNextEntry() returns correct entry
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
PostgresqlScheduleTest :: getNextEntryTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
// create a 1 hour long playlist
|
||||
Ptr<UniqueId>::Ref playlistId = UniqueId::generateId();
|
||||
Ptr<time_duration>::Ref playlength(new time_duration(1, 0, 0));
|
||||
Ptr<Playlist>::Ref playlist(new Playlist(playlistId, playlength));
|
||||
|
||||
Ptr<ptime>::Ref from;
|
||||
Ptr<ScheduleEntry>::Ref entry;
|
||||
|
||||
try {
|
||||
// schedule our playlist for 2004-07-23, 10 o'clock
|
||||
from.reset(new ptime(time_from_string("2004-07-23 10:00:00")));
|
||||
schedule->schedulePlaylist(playlist, from);
|
||||
|
||||
// schedule our playlist for 2004-07-23, 12 o'clock
|
||||
from.reset(new ptime(time_from_string("2004-07-23 12:00:00")));
|
||||
schedule->schedulePlaylist(playlist, from);
|
||||
|
||||
// schedule our playlist for 2004-07-23, 14 o'clock
|
||||
from.reset(new ptime(time_from_string("2004-07-23 14:00:00")));
|
||||
schedule->schedulePlaylist(playlist, from);
|
||||
|
||||
// see what gives after 2004-07-23 09:00:00
|
||||
from.reset(new ptime(time_from_string("2004-07-23 09:00:00")));
|
||||
entry = schedule->getNextEntry(from);
|
||||
CPPUNIT_ASSERT(entry.get());
|
||||
// see that it is a single entry starting from 10 to 11 o'clock
|
||||
CPPUNIT_ASSERT(*(entry->getPlaylistId()) == *(playlist->getId()));
|
||||
from.reset(new ptime(time_from_string("2004-07-23 10:00:00")));
|
||||
CPPUNIT_ASSERT(*(entry->getStartTime()) == *from);
|
||||
|
||||
// see what gives after 2004-07-23 10:00:00
|
||||
from.reset(new ptime(time_from_string("2004-07-23 10:00:00")));
|
||||
entry = schedule->getNextEntry(from);
|
||||
CPPUNIT_ASSERT(entry.get());
|
||||
// see that it is a single entry starting from 10 to 11 o'clock
|
||||
CPPUNIT_ASSERT(*(entry->getPlaylistId()) == *(playlist->getId()));
|
||||
from.reset(new ptime(time_from_string("2004-07-23 12:00:00")));
|
||||
CPPUNIT_ASSERT(*(entry->getStartTime()) == *from);
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
CPPUNIT_FAIL(e.what());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* See if scheduleEntryExists() returns correct results
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.4 $
|
||||
Version : $Revision: 1.5 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/PostgresqlScheduleTest.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -64,7 +64,7 @@ using namespace LiveSupport::Core;
|
|||
* Unit test for the PostgresqlSchedule class.
|
||||
*
|
||||
* @author $Author: maroy $
|
||||
* @version $Revision: 1.4 $
|
||||
* @version $Revision: 1.5 $
|
||||
* @see PostgresqlSchedule
|
||||
*/
|
||||
class PostgresqlScheduleTest : public CPPUNIT_NS::TestFixture
|
||||
|
@ -74,6 +74,7 @@ class PostgresqlScheduleTest : public CPPUNIT_NS::TestFixture
|
|||
CPPUNIT_TEST(simpleScheduleTest);
|
||||
CPPUNIT_TEST(scheduleAndQueryTest);
|
||||
CPPUNIT_TEST(getScheduleEntriesTest);
|
||||
CPPUNIT_TEST(getNextEntryTest);
|
||||
CPPUNIT_TEST(scheduleEntryExistsTest);
|
||||
CPPUNIT_TEST(removeFromScheduleTest);
|
||||
CPPUNIT_TEST(rescheduleTest);
|
||||
|
@ -126,6 +127,15 @@ class PostgresqlScheduleTest : public CPPUNIT_NS::TestFixture
|
|||
void
|
||||
getScheduleEntriesTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
/**
|
||||
* Schedule some playlists, then get the some playlists by
|
||||
* specifying a time.
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
getNextEntryTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
/**
|
||||
* Schedule some playlists, then check if they exist.
|
||||
*
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.4 $
|
||||
Version : $Revision: 1.5 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/ScheduleInterface.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -70,7 +70,7 @@ using namespace LiveSupport::Core;
|
|||
* The generic interface for the component scheduling events.
|
||||
*
|
||||
* @author $Author: maroy $
|
||||
* @version $Revision: 1.4 $
|
||||
* @version $Revision: 1.5 $
|
||||
*/
|
||||
class ScheduleInterface : virtual public Installable
|
||||
{
|
||||
|
@ -117,6 +117,19 @@ class ScheduleInterface : virtual public Installable
|
|||
throw ()
|
||||
= 0;
|
||||
|
||||
/**
|
||||
* Return the next schedule entry, after (but not including)
|
||||
* the specified timepoint.
|
||||
*
|
||||
* @param fromTime the start of the time of the interval queried,
|
||||
* inclusive
|
||||
* @return the first schedule entry, after the specified timepoint.
|
||||
*/
|
||||
virtual Ptr<ScheduleEntry>::Ref
|
||||
getNextEntry(Ptr<ptime>::Ref fromTime)
|
||||
throw ()
|
||||
= 0;
|
||||
|
||||
/**
|
||||
* Tell if a schedule entry exists by the give name.
|
||||
*
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.5 $
|
||||
Version : $Revision: 1.6 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/SchedulerDaemon.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -51,12 +51,19 @@
|
|||
#include <fstream>
|
||||
#include <cstdio>
|
||||
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
|
||||
#include "LiveSupport/Db/ConnectionManagerFactory.h"
|
||||
#include "LiveSupport/Storage/StorageClientFactory.h"
|
||||
#include "LiveSupport/PlaylistExecutor/AudioPlayerFactory.h"
|
||||
#include "ScheduleFactory.h"
|
||||
#include "SchedulerDaemon.h"
|
||||
#include "PlaylistEventContainer.h"
|
||||
|
||||
|
||||
using namespace boost::posix_time;
|
||||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Db;
|
||||
using namespace LiveSupport::Storage;
|
||||
using namespace LiveSupport::Scheduler;
|
||||
|
@ -88,6 +95,20 @@ static const std::string xmlRpcDaemonConfElement = "xmlRpcDaemon";
|
|||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The default constructor.
|
||||
*----------------------------------------------------------------------------*/
|
||||
SchedulerDaemon :: SchedulerDaemon (void) throw ()
|
||||
: XmlRpcDaemon()
|
||||
{
|
||||
uploadPlaylistMethod.reset(new UploadPlaylistMethod());
|
||||
displayScheduleMethod.reset(new DisplayScheduleMethod());
|
||||
displayPlaylistMethod.reset(new DisplayPlaylistMethod());
|
||||
removeFromScheduleMethod.reset(new RemoveFromScheduleMethod());
|
||||
rescheduleMethod.reset(new RescheduleMethod());
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Return the singleton instnace.
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
@ -136,6 +157,14 @@ SchedulerDaemon :: configure(const xmlpp::Element & element)
|
|||
Ptr<StorageClientFactory>::Ref scf = StorageClientFactory::getInstance();
|
||||
scf->configure( *((const xmlpp::Element*) *(nodes.begin())) );
|
||||
|
||||
// configure the AudioPlayerFactory
|
||||
nodes = element.get_children(AudioPlayerFactory::getConfigElementName());
|
||||
if (nodes.size() < 1) {
|
||||
throw std::invalid_argument("no audioPlayer element");
|
||||
}
|
||||
Ptr<AudioPlayerFactory>::Ref apf = AudioPlayerFactory::getInstance();
|
||||
apf->configure( *((const xmlpp::Element*) *(nodes.begin())) );
|
||||
|
||||
// configure the ScheduleFactory
|
||||
nodes = element.get_children(ScheduleFactory::getConfigElementName());
|
||||
if (nodes.size() < 1) {
|
||||
|
@ -151,6 +180,21 @@ SchedulerDaemon :: configure(const xmlpp::Element & element)
|
|||
}
|
||||
configureXmlRpcDaemon( *((const xmlpp::Element*) *(nodes.begin())) );
|
||||
|
||||
|
||||
// do some initialization, using the configured objects
|
||||
audioPlayer = apf->getAudioPlayer();
|
||||
|
||||
Ptr<PlaylistEventContainer>::Ref eventContainer;
|
||||
Ptr<time_duration>::Ref granularity;
|
||||
eventContainer.reset(new PlaylistEventContainer(scf->getStorageClient(),
|
||||
sf->getSchedule(),
|
||||
audioPlayer));
|
||||
// TODO: read granularity from config file
|
||||
granularity.reset(new time_duration(seconds(30)));
|
||||
|
||||
eventScheduler.reset(
|
||||
new LiveSupport::EventScheduler::EventScheduler(eventContainer,
|
||||
granularity));
|
||||
}
|
||||
|
||||
|
||||
|
@ -194,3 +238,32 @@ SchedulerDaemon :: uninstall(void) throw (std::exception)
|
|||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Start the scheduler daemon.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SchedulerDaemon :: start(void) throw (std::logic_error)
|
||||
{
|
||||
std::cerr << "SchedulerDaemon::start #1" << std::endl;
|
||||
audioPlayer->initialize();
|
||||
std::cerr << "SchedulerDaemon::start #2" << std::endl;
|
||||
eventScheduler->start();
|
||||
std::cerr << "SchedulerDaemon::start #3" << std::endl;
|
||||
XmlRpcDaemon::start();
|
||||
std::cerr << "SchedulerDaemon::start #4" << std::endl;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Stop the scheduler daemon.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SchedulerDaemon :: stop(void) throw (std::logic_error)
|
||||
{
|
||||
eventScheduler->stop();
|
||||
audioPlayer->deInitialize();
|
||||
|
||||
XmlRpcDaemon::stop();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.6 $
|
||||
Version : $Revision: 1.7 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/SchedulerDaemon.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -60,6 +60,8 @@
|
|||
#include "LiveSupport/Core/Ptr.h"
|
||||
#include "LiveSupport/Core/Installable.h"
|
||||
#include "LiveSupport/Core/Configurable.h"
|
||||
#include "LiveSupport/PlaylistExecutor/AudioPlayerInterface.h"
|
||||
#include "LiveSupport/EventScheduler/EventScheduler.h"
|
||||
#include "UploadPlaylistMethod.h"
|
||||
#include "DisplayScheduleMethod.h"
|
||||
#include "DisplayPlaylistMethod.h"
|
||||
|
@ -71,7 +73,9 @@
|
|||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::PlaylistExecutor;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
@ -120,7 +124,7 @@ using namespace LiveSupport::Core;
|
|||
* </code></pre>
|
||||
*
|
||||
* @author $Author: maroy $
|
||||
* @version $Revision: 1.6 $
|
||||
* @version $Revision: 1.7 $
|
||||
* @see ConnectionManagerFactory
|
||||
* @see StorageClientFactory
|
||||
* @see ScheduleFactory
|
||||
|
@ -137,6 +141,16 @@ class SchedulerDaemon : public Installable,
|
|||
*/
|
||||
static Ptr<SchedulerDaemon>::Ref schedulerDaemon;
|
||||
|
||||
/**
|
||||
* The event scheduler.
|
||||
*/
|
||||
Ptr<EventScheduler::EventScheduler>::Ref eventScheduler;
|
||||
|
||||
/**
|
||||
* The audio player.
|
||||
*/
|
||||
Ptr<AudioPlayerInterface>::Ref audioPlayer;
|
||||
|
||||
/**
|
||||
* The UploadPlaylistMethod the daemon is providing.
|
||||
*/
|
||||
|
@ -165,15 +179,8 @@ class SchedulerDaemon : public Installable,
|
|||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
SchedulerDaemon (void) throw ()
|
||||
: XmlRpcDaemon()
|
||||
{
|
||||
uploadPlaylistMethod.reset(new UploadPlaylistMethod());
|
||||
displayScheduleMethod.reset(new DisplayScheduleMethod());
|
||||
displayPlaylistMethod.reset(new DisplayPlaylistMethod());
|
||||
removeFromScheduleMethod.reset(new RemoveFromScheduleMethod());
|
||||
rescheduleMethod.reset(new RescheduleMethod());
|
||||
}
|
||||
SchedulerDaemon (void) throw ();
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -237,6 +244,25 @@ class SchedulerDaemon : public Installable,
|
|||
*/
|
||||
virtual void
|
||||
uninstall(void) throw (std::exception);
|
||||
|
||||
/**
|
||||
* Start the daemon.
|
||||
*
|
||||
* @exception std::logic_error if the daemon has not
|
||||
* yet been configured.
|
||||
*/
|
||||
virtual void
|
||||
start (void) throw (std::logic_error);
|
||||
|
||||
/**
|
||||
* Stop the daemon.
|
||||
*
|
||||
* @exception std::logic_error if the daemon has not
|
||||
* yet been configured.
|
||||
*/
|
||||
virtual void
|
||||
stop (void) throw (std::logic_error);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.2 $
|
||||
Version : $Revision: 1.3 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/XmlRpcDaemon.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -119,7 +119,7 @@ using namespace LiveSupport::Core;
|
|||
*
|
||||
*
|
||||
* @author $Author: maroy $
|
||||
* @version $Revision: 1.2 $
|
||||
* @version $Revision: 1.3 $
|
||||
*/
|
||||
class XmlRpcDaemon
|
||||
{
|
||||
|
@ -371,7 +371,7 @@ class XmlRpcDaemon
|
|||
* @exception std::logic_error if the daemon has not
|
||||
* yet been configured.
|
||||
*/
|
||||
void
|
||||
virtual void
|
||||
start (void) throw (std::logic_error);
|
||||
|
||||
/**
|
||||
|
@ -392,7 +392,7 @@ class XmlRpcDaemon
|
|||
* @exception std::logic_error if the daemon has not
|
||||
* yet been configured.
|
||||
*/
|
||||
void
|
||||
virtual void
|
||||
stop (void) throw (std::logic_error);
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.2 $
|
||||
Version : $Revision: 1.3 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/main.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -161,21 +161,21 @@ int main ( int argc,
|
|||
|
||||
case 'h':
|
||||
printUsage(argv[0], std::cout);
|
||||
return 0;
|
||||
exit(EXIT_SUCCESS);
|
||||
|
||||
case 'v':
|
||||
printVersion(std::cout);
|
||||
return 0;
|
||||
exit(EXIT_SUCCESS);
|
||||
|
||||
default:
|
||||
printUsage(argv[0], std::cout);
|
||||
return 1;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
if (optind != argc - 1) {
|
||||
printUsage(argv[0], std::cout);
|
||||
return 1;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
std::cerr << "using config file '" << configFileName << '\'' << std::endl;
|
||||
|
@ -190,11 +190,11 @@ int main ( int argc,
|
|||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << "semantic error in configuration file" << std::endl
|
||||
<< e.what() << std::endl;
|
||||
return 1;
|
||||
exit(EXIT_FAILURE);
|
||||
} catch (xmlpp::exception &e) {
|
||||
std::cerr << "error parsing configuration file" << std::endl
|
||||
<< e.what() << std::endl;
|
||||
return 1;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
daemon->setBackground(!debugMode);
|
||||
|
@ -213,10 +213,10 @@ int main ( int argc,
|
|||
daemon->uninstall();
|
||||
} else {
|
||||
printUsage(argv[0], std::cout);
|
||||
return 1;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
return 0;
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue