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
*/
virtual void
virtual int
close(void) throw (std::logic_error) = 0;
/**
@ -204,7 +204,7 @@ class AudioPlayerInterface
* @see #stop
*/
virtual void
start(void) throw (std::logic_error)
start(int) throw (std::logic_error)
= 0;
/**

View File

@ -21,7 +21,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author$
Author : $Author: Kapil Agrawal$
Version : $Revision$
Location : $URL$
@ -233,6 +233,23 @@ public:
}
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.
*----------------------------------------------------------------------------*/

View File

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

View File

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

View File

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

View File

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