Added support for playlist start time configuration, scheduler can pass any position from where to start the playlist by passing value (in seconds) to the GstreamerPlayer::start method. Whenever the playlist is stopped, GstreamerPlayer::Close returns time (in seconds) at what position it stopped, which can be useful if a playlist gets crashed in between. Scheduler should store this returned value for future reference to restart the playlist from the old position. Files Changed: GLiveSupport.cxx, PlaylistEvent.cxx, AudioPlayerInterface.h, GstreamerPlayer.cxx, GstreamerPlayContext.h, GstreamerPlayer.h

This commit is contained in:
kapil 2009-10-01 22:08:14 +00:00
parent f2098954b8
commit e1a2db28e8
6 changed files with 50 additions and 22 deletions

View file

@ -170,7 +170,7 @@ class AudioPlayerInterface
* *
* @see #open * @see #open
*/ */
virtual void virtual int
close(void) throw (std::logic_error) = 0; close(void) throw (std::logic_error) = 0;
/** /**
@ -204,7 +204,7 @@ class AudioPlayerInterface
* @see #stop * @see #stop
*/ */
virtual void virtual void
start(void) throw (std::logic_error) start(int) throw (std::logic_error)
= 0; = 0;
/** /**

View file

@ -21,7 +21,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author$ Author : $Author: Kapil Agrawal$
Version : $Revision$ Version : $Revision$
Location : $URL$ Location : $URL$
@ -233,6 +233,23 @@ public:
} }
return ns; return ns;
} }
/*------------------------------------------------------------------------------
* Seeks to the passed argument seek
*---------------------------------------------------------------------------*/
void
start_time (gint start_time){
GstState state;
GstState pending;
gst_element_set_state (m_pipeline, GST_STATE_PAUSED);
gst_element_get_state (m_pipeline, &state, &pending, 50000000);
if (!gst_element_seek (m_pipeline, 1.0, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH, GST_SEEK_TYPE_SET,
start_time*GST_SECOND, GST_SEEK_TYPE_END, 0)) {
g_print ("\nstart_time seek failed\n");
}
else
g_print ("\n start_time seek succces\n");
}
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Returns current stream's position. * Returns current stream's position.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/

View file

@ -21,7 +21,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author$ Author : $Author: Kapil Agrawal$
Version : $Revision$ Version : $Revision$
Location : $URL$ Location : $URL$
@ -303,7 +303,7 @@ GstreamerPlayer :: playNextSmil(void) throw (
{ {
return false; return false;
} }
// m_currentPlayLength = m_playContext->getPosition();//this gets the length of the stream that just completed m_currentPlayLength = m_playContext->getPosition();//this gets the length of the stream that just completed
m_playContext->closeContext(); m_playContext->closeContext();
if(m_smilHandler == NULL){ if(m_smilHandler == NULL){
return false; return false;
@ -327,7 +327,14 @@ GstreamerPlayer :: playNextSmil(void) throw (
m_url = (const char*) audioDescription->m_src; m_url = (const char*) audioDescription->m_src;
g_idle_add(GstreamerPlayer::fireOnStartEvent, this); g_idle_add(GstreamerPlayer::fireOnStartEvent, this);
m_smilOffset = audioDescription->m_begin; m_smilOffset = audioDescription->m_begin;
// m_smilOffset += m_currentPlayLength; // m_smilOffset += m_currentPlayLength;
m_start_time = m_start_time - (m_currentPlayLength/GST_SECOND);
if(m_start_time > 0){
m_playContext->start_time (m_start_time);
}
else {
m_start_time = 0;
}
m_playContext->playContext(); m_playContext->playContext();
return true; return true;
} }
@ -391,15 +398,16 @@ GstreamerPlayer :: getPosition(void) throw (std::logic_error)
* Start playing * Start playing
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
GstreamerPlayer :: start(void) throw (std::logic_error) GstreamerPlayer :: start(int start_time) throw (std::logic_error)
{ {
DEBUG_BLOCK DEBUG_BLOCK
m_start_time = start_time;
if (!isOpen()) { if (!isOpen()) {
throw std::logic_error("GstreamerPlayer not opened yet"); throw std::logic_error("GstreamerPlayer not opened yet");
} }
if (!isPlaying()) { if (!isPlaying()) {
m_playContext->start_time (m_start_time);
m_playContext->playContext(); m_playContext->playContext();
}else{ }else{
error() << "Already playing!" << endl; error() << "Already playing!" << endl;
@ -452,19 +460,22 @@ GstreamerPlayer :: stop(void) throw (std::logic_error)
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Close the currently opened audio file. * Close the currently opened audio file.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void int
GstreamerPlayer :: close(void) throw (std::logic_error) GstreamerPlayer :: close(void) throw (std::logic_error)
{ {
DEBUG_BLOCK DEBUG_BLOCK
gint64 ns;
int stop_time;
ns = m_playContext->getPosition();
m_playContext->stopContext(); m_playContext->stopContext();
m_playContext->closeContext(); m_playContext->closeContext();
if(m_smilHandler != NULL){ if(m_smilHandler != NULL){
delete m_smilHandler; delete m_smilHandler;
m_smilHandler = NULL; m_smilHandler = NULL;
} }
stop_time = ns/GST_SECOND;
m_open = false; m_open = false;
return (stop_time + (m_smilOffset/GST_SECOND));
} }

View file

@ -128,7 +128,7 @@ class GstreamerPlayer : virtual public Configurable,
gint64 m_Id; gint64 m_Id;
public: public:
gint m_start_time;
/** /**
* Contains runtime error messages from GStreamer. * Contains runtime error messages from GStreamer.
*/ */
@ -314,7 +314,7 @@ public:
* *
* @see #open * @see #open
*/ */
virtual void virtual int
close(void) throw (std::logic_error); close(void) throw (std::logic_error);
/** /**
@ -329,7 +329,7 @@ public:
* @see #stop * @see #stop
*/ */
virtual void virtual void
start(void) throw (std::logic_error); start(int) throw (std::logic_error);
/** /**
* Pause the player. * Pause the player.

View file

@ -1302,7 +1302,7 @@ GLiveSupport :: playOutputAudio(Ptr<Playable>::Ref playable)
{ {
return false; return false;
} }
outputPlayer->start(); outputPlayer->start(0);
std::cerr << "gLiveSupport: Live Mode playing audio clip '" std::cerr << "gLiveSupport: Live Mode playing audio clip '"
<< *playable->getTitle() << *playable->getTitle()
<< "'" << std::endl; << "'" << std::endl;
@ -1311,7 +1311,7 @@ GLiveSupport :: playOutputAudio(Ptr<Playable>::Ref playable)
case Playable::PlaylistType: case Playable::PlaylistType:
outputItemPlayingNow = acquirePlaylist(playable->getId()); outputItemPlayingNow = acquirePlaylist(playable->getId());
outputPlayer->open(*outputItemPlayingNow->getUri(), (gint64)outputItemPlayingNow->getId()->getId()); outputPlayer->open(*outputItemPlayingNow->getUri(), (gint64)outputItemPlayingNow->getId()->getId());
outputPlayer->start(); outputPlayer->start(0);
std::cerr << "gLiveSupport: Live Mode playing playlist '" std::cerr << "gLiveSupport: Live Mode playing playlist '"
<< *playable->getTitle() << *playable->getTitle()
<< "'" << std::endl; << "'" << std::endl;
@ -1361,7 +1361,7 @@ GLiveSupport :: pauseOutputAudio(void)
outputPlayerIsPaused = true; outputPlayerIsPaused = true;
} else if (outputPlayerIsPaused) { } else if (outputPlayerIsPaused) {
outputPlayer->start(); outputPlayer->start(0);
outputPlayerIsPaused = false; outputPlayerIsPaused = false;
} }
} }
@ -1444,7 +1444,7 @@ GLiveSupport :: playCueAudio(Ptr<Playable>::Ref playable)
case Playable::AudioClipType: case Playable::AudioClipType:
cueItemPlayingNow = acquireAudioClip(playable->getId()); cueItemPlayingNow = acquireAudioClip(playable->getId());
cuePlayer->open(*cueItemPlayingNow->getUri(), (gint64)cueItemPlayingNow->getId()->getId()); cuePlayer->open(*cueItemPlayingNow->getUri(), (gint64)cueItemPlayingNow->getId()->getId());
cuePlayer->start(); cuePlayer->start(0);
std::cerr << "gLiveSupport: Cue playing audio clip '" std::cerr << "gLiveSupport: Cue playing audio clip '"
<< *playable->getTitle() << *playable->getTitle()
<< "'" << std::endl; << "'" << std::endl;
@ -1453,7 +1453,7 @@ GLiveSupport :: playCueAudio(Ptr<Playable>::Ref playable)
case Playable::PlaylistType: case Playable::PlaylistType:
cueItemPlayingNow = acquirePlaylist(playable->getId()); cueItemPlayingNow = acquirePlaylist(playable->getId());
cuePlayer->open(*cueItemPlayingNow->getUri(), (gint64)cueItemPlayingNow->getId()->getId()); cuePlayer->open(*cueItemPlayingNow->getUri(), (gint64)cueItemPlayingNow->getId()->getId());
cuePlayer->start(); cuePlayer->start(0);
std::cerr << "gLiveSupport: Cue playing playlist '" std::cerr << "gLiveSupport: Cue playing playlist '"
<< *playable->getTitle() << *playable->getTitle()
<< "'" << std::endl; << "'" << std::endl;
@ -1502,7 +1502,7 @@ GLiveSupport :: pauseCueAudio(void)
cuePlayerIsPaused = true; cuePlayerIsPaused = true;
} else if (cuePlayerIsPaused) { } else if (cuePlayerIsPaused) {
cuePlayer->start(); cuePlayer->start(0);
cuePlayerIsPaused = false; cuePlayerIsPaused = false;
} }
} }
@ -1770,7 +1770,7 @@ GLiveSupport :: playTestSoundOnCue(Ptr<const Glib::ustring>::Ref oldDevice,
} }
cuePlayer->setAudioDevice(*newDevice); cuePlayer->setAudioDevice(*newDevice);
cuePlayer->open(*testAudioUrl, (gint64)0); cuePlayer->open(*testAudioUrl, (gint64)0);
cuePlayer->start(); cuePlayer->start(0);
Ptr<time_duration>::Ref sleepT(new time_duration(microseconds(10))); Ptr<time_duration>::Ref sleepT(new time_duration(microseconds(10)));
while (cuePlayer->isPlaying()) { while (cuePlayer->isPlaying()) {
runMainLoop(); runMainLoop();

View file

@ -159,7 +159,7 @@ PlaylistEvent :: start(void) throw ()
try { try {
audioPlayer->open(*playlist->getUri(), (gint64)playlist->getId()->getId()); audioPlayer->open(*playlist->getUri(), (gint64)playlist->getId()->getId());
audioPlayer->start(); audioPlayer->start(0);
playLog->addPlayLogEntry(playlist->getId(), TimeConversion::now()); playLog->addPlayLogEntry(playlist->getId(), TimeConversion::now());
} catch (std::invalid_argument &e) { } catch (std::invalid_argument &e) {