From 60518f7074bf1b887e8b4bead8c00fa2166e688f Mon Sep 17 00:00:00 2001 From: kapil Date: Fri, 2 Oct 2009 12:49:43 +0000 Subject: [PATCH] Added support for passing a stop_time value of the playlist, when the scheduler wants the playlist to stop. It has to be passed as second parameter to start method of audioplayer. For now the STOP_TIME macro is used to pass value. Files Changed: GLiveSupport.cxx, PlaylistEvent.cxx, AudioPlayerInterface.h, GstreamerPlayer.cxx, streamerPlayer.h --- .../PlaylistExecutor/AudioPlayerInterface.h | 2 +- .../playlistExecutor/src/GstreamerPlayer.cxx | 13 ++++++++++--- .../playlistExecutor/src/GstreamerPlayer.h | 3 ++- .../products/gLiveSupport/src/GLiveSupport.cxx | 16 ++++++++-------- .../src/products/scheduler/src/PlaylistEvent.cxx | 4 +++- 5 files changed, 24 insertions(+), 14 deletions(-) diff --git a/campcaster/src/modules/playlistExecutor/include/LiveSupport/PlaylistExecutor/AudioPlayerInterface.h b/campcaster/src/modules/playlistExecutor/include/LiveSupport/PlaylistExecutor/AudioPlayerInterface.h index e7245da61..b61bfcb06 100644 --- a/campcaster/src/modules/playlistExecutor/include/LiveSupport/PlaylistExecutor/AudioPlayerInterface.h +++ b/campcaster/src/modules/playlistExecutor/include/LiveSupport/PlaylistExecutor/AudioPlayerInterface.h @@ -204,7 +204,7 @@ class AudioPlayerInterface * @see #stop */ virtual void - start(int) throw (std::logic_error) + start(int,int) throw (std::logic_error) = 0; /** diff --git a/campcaster/src/modules/playlistExecutor/src/GstreamerPlayer.cxx b/campcaster/src/modules/playlistExecutor/src/GstreamerPlayer.cxx index 03077710c..239fa7dff 100644 --- a/campcaster/src/modules/playlistExecutor/src/GstreamerPlayer.cxx +++ b/campcaster/src/modules/playlistExecutor/src/GstreamerPlayer.cxx @@ -386,8 +386,14 @@ GstreamerPlayer :: getPosition(void) throw (std::logic_error) throw std::logic_error("player not open"); } - gint64 ns = m_playContext->getPosition(); - + gint64 ns = m_playContext->getPosition(); +#if 0 + if (((ns/GST_SECOND) + (m_smilOffset/GST_SECOND)) >= m_stop_time){ + m_playContext->stopContext(); + m_playContext->closeContext(); + g_idle_add(GstreamerPlayer::fireOnStopEvent, this); + } +#endif length.reset(new time_duration(microseconds((m_smilOffset + ns) / 1000LL))); return length; @@ -398,9 +404,10 @@ GstreamerPlayer :: getPosition(void) throw (std::logic_error) * Start playing *----------------------------------------------------------------------------*/ void -GstreamerPlayer :: start(int start_time) throw (std::logic_error) +GstreamerPlayer :: start(int start_time, int stop_time) throw (std::logic_error) { DEBUG_BLOCK + m_stop_time = stop_time; m_start_time = start_time; if (!isOpen()) { throw std::logic_error("GstreamerPlayer not opened yet"); diff --git a/campcaster/src/modules/playlistExecutor/src/GstreamerPlayer.h b/campcaster/src/modules/playlistExecutor/src/GstreamerPlayer.h index d1ab1555d..7addcf6da 100644 --- a/campcaster/src/modules/playlistExecutor/src/GstreamerPlayer.h +++ b/campcaster/src/modules/playlistExecutor/src/GstreamerPlayer.h @@ -124,6 +124,7 @@ class GstreamerPlayer : virtual public Configurable, std::string m_audioDevice; gint64 m_smilOffset; + gint m_stop_time; gint64 m_currentPlayLength; gint64 m_Id; @@ -329,7 +330,7 @@ public: * @see #stop */ virtual void - start(int) throw (std::logic_error); + start(int,int) throw (std::logic_error); /** * Pause the player. diff --git a/campcaster/src/products/gLiveSupport/src/GLiveSupport.cxx b/campcaster/src/products/gLiveSupport/src/GLiveSupport.cxx index f82eaba10..40e8ae5aa 100644 --- a/campcaster/src/products/gLiveSupport/src/GLiveSupport.cxx +++ b/campcaster/src/products/gLiveSupport/src/GLiveSupport.cxx @@ -76,7 +76,7 @@ using namespace LiveSupport::SchedulerClient; using namespace LiveSupport::Widgets; using namespace LiveSupport::GLiveSupport; - +#define STOP_TIME 300 /* =================================================== local data structures */ @@ -1302,7 +1302,7 @@ GLiveSupport :: playOutputAudio(Ptr::Ref playable) { return false; } - outputPlayer->start(0); + outputPlayer->start(0, STOP_TIME); std::cerr << "gLiveSupport: Live Mode playing audio clip '" << *playable->getTitle() << "'" << std::endl; @@ -1311,7 +1311,7 @@ GLiveSupport :: playOutputAudio(Ptr::Ref playable) case Playable::PlaylistType: outputItemPlayingNow = acquirePlaylist(playable->getId()); outputPlayer->open(*outputItemPlayingNow->getUri(), (gint64)outputItemPlayingNow->getId()->getId()); - outputPlayer->start(0); + outputPlayer->start(0, STOP_TIME); std::cerr << "gLiveSupport: Live Mode playing playlist '" << *playable->getTitle() << "'" << std::endl; @@ -1361,7 +1361,7 @@ GLiveSupport :: pauseOutputAudio(void) outputPlayerIsPaused = true; } else if (outputPlayerIsPaused) { - outputPlayer->start(0); + outputPlayer->start(0, STOP_TIME); outputPlayerIsPaused = false; } } @@ -1444,7 +1444,7 @@ GLiveSupport :: playCueAudio(Ptr::Ref playable) case Playable::AudioClipType: cueItemPlayingNow = acquireAudioClip(playable->getId()); cuePlayer->open(*cueItemPlayingNow->getUri(), (gint64)cueItemPlayingNow->getId()->getId()); - cuePlayer->start(0); + cuePlayer->start(0, STOP_TIME); std::cerr << "gLiveSupport: Cue playing audio clip '" << *playable->getTitle() << "'" << std::endl; @@ -1453,7 +1453,7 @@ GLiveSupport :: playCueAudio(Ptr::Ref playable) case Playable::PlaylistType: cueItemPlayingNow = acquirePlaylist(playable->getId()); cuePlayer->open(*cueItemPlayingNow->getUri(), (gint64)cueItemPlayingNow->getId()->getId()); - cuePlayer->start(0); + cuePlayer->start(0, STOP_TIME); std::cerr << "gLiveSupport: Cue playing playlist '" << *playable->getTitle() << "'" << std::endl; @@ -1502,7 +1502,7 @@ GLiveSupport :: pauseCueAudio(void) cuePlayerIsPaused = true; } else if (cuePlayerIsPaused) { - cuePlayer->start(0); + cuePlayer->start(0, STOP_TIME); cuePlayerIsPaused = false; } } @@ -1770,7 +1770,7 @@ GLiveSupport :: playTestSoundOnCue(Ptr::Ref oldDevice, } cuePlayer->setAudioDevice(*newDevice); cuePlayer->open(*testAudioUrl, (gint64)0); - cuePlayer->start(0); + cuePlayer->start(0, STOP_TIME); Ptr::Ref sleepT(new time_duration(microseconds(10))); while (cuePlayer->isPlaying()) { runMainLoop(); diff --git a/campcaster/src/products/scheduler/src/PlaylistEvent.cxx b/campcaster/src/products/scheduler/src/PlaylistEvent.cxx index 380d61fb5..aa68009dd 100644 --- a/campcaster/src/products/scheduler/src/PlaylistEvent.cxx +++ b/campcaster/src/products/scheduler/src/PlaylistEvent.cxx @@ -54,6 +54,8 @@ using namespace boost; using namespace LiveSupport::Core; using namespace LiveSupport::Scheduler; +#define START_TIME 0 +#define STOP_TIME 30 /* =================================================== local data structures */ @@ -159,7 +161,7 @@ PlaylistEvent :: start(void) throw () try { audioPlayer->open(*playlist->getUri(), (gint64)playlist->getId()->getId()); - audioPlayer->start(0); + audioPlayer->start(START_TIME, STOP_TIME); playLog->addPlayLogEntry(playlist->getId(), TimeConversion::now()); } catch (std::invalid_argument &e) {