offset plumbing almost completed
This commit is contained in:
parent
405dffb98b
commit
1f05438448
|
@ -170,7 +170,7 @@ class AudioPlayerInterface
|
||||||
*
|
*
|
||||||
* @see #open
|
* @see #open
|
||||||
*/
|
*/
|
||||||
virtual int
|
virtual void
|
||||||
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(int,int) throw (std::logic_error)
|
start(gint64) throw (std::logic_error)
|
||||||
= 0;
|
= 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -83,6 +83,7 @@ class GstreamerPlayContext
|
||||||
gpointer m_data;
|
gpointer m_data;
|
||||||
AudioDescription *m_audioDescription;
|
AudioDescription *m_audioDescription;
|
||||||
std::string m_audioDevice;
|
std::string m_audioDevice;
|
||||||
|
gint64 m_clipOffset;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -97,6 +98,7 @@ public:
|
||||||
m_data = NULL;
|
m_data = NULL;
|
||||||
m_audioDescription = NULL;
|
m_audioDescription = NULL;
|
||||||
m_audioDevice = "default";
|
m_audioDevice = "default";
|
||||||
|
m_clipOffset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
~GstreamerPlayContext(){
|
~GstreamerPlayContext(){
|
||||||
|
@ -131,6 +133,7 @@ public:
|
||||||
delete m_audioDescription;
|
delete m_audioDescription;
|
||||||
m_audioDescription = NULL;
|
m_audioDescription = NULL;
|
||||||
}
|
}
|
||||||
|
m_clipOffset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void playContext(){
|
void playContext(){
|
||||||
|
@ -145,7 +148,8 @@ public:
|
||||||
gst_element_get_state (m_pipeline, &state, &pending, 2000000000);//just in case, do not wait for more than 2 sec
|
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,
|
gst_element_seek(m_pipeline, 1.0, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH, GST_SEEK_TYPE_SET,
|
||||||
m_audioDescription->m_clipBegin*GST_NSECOND, GST_SEEK_TYPE_SET, m_audioDescription->m_clipEnd*GST_NSECOND);
|
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);
|
g_object_set(G_OBJECT(m_volume), "volume", 1.0, NULL);
|
||||||
}
|
}
|
||||||
|
@ -246,20 +250,10 @@ public:
|
||||||
return ns;
|
return ns;
|
||||||
}
|
}
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
* Seeks to the passed argument seek
|
* Offsets playback within the clip
|
||||||
*---------------------------------------------------------------------------*/
|
*---------------------------------------------------------------------------*/
|
||||||
void
|
void setClipOffset(gint64 startTime){
|
||||||
start_time (gint start_time){
|
m_clipOffset = startTime;
|
||||||
GstState state;
|
|
||||||
GstState pending;
|
|
||||||
gst_element_set_state (m_pipeline, GST_STATE_PAUSED);
|
|
||||||
gst_element_get_state (m_pipeline, &state, &pending, GST_CLOCK_TIME_NONE);
|
|
||||||
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");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
|
|
|
@ -303,7 +303,6 @@ GstreamerPlayer :: playNextSmil(void) throw (
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
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,14 +326,6 @@ 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_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;
|
||||||
}
|
}
|
||||||
|
@ -387,34 +378,33 @@ GstreamerPlayer :: getPosition(void) throw (std::logic_error)
|
||||||
}
|
}
|
||||||
|
|
||||||
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)));
|
length.reset(new time_duration(microseconds((m_smilOffset + ns) / 1000LL)));
|
||||||
|
|
||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gint64
|
||||||
|
GstreamerPlayer :: offsetSmil(gint64 startTime)
|
||||||
|
{
|
||||||
|
//have to take start_time, offset the smilHandler based on it (remove all clips that fall before start_time)
|
||||||
|
//and calculate clip offset as a reminder, then set that offset to the player somehow
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
* Start playing
|
* Start playing
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
GstreamerPlayer :: start(int start_time, int stop_time) throw (std::logic_error)
|
GstreamerPlayer :: start(gint64 startTime) throw (std::logic_error)
|
||||||
{
|
{
|
||||||
DEBUG_BLOCK
|
DEBUG_BLOCK
|
||||||
m_stop_time = stop_time;
|
|
||||||
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);
|
gint64 clipOffset = offsetSmil(startTime);
|
||||||
|
m_playContext->setClipOffset(clipOffset);
|
||||||
m_playContext->playContext();
|
m_playContext->playContext();
|
||||||
}else{
|
}else{
|
||||||
error() << "Already playing!" << endl;
|
error() << "Already playing!" << endl;
|
||||||
|
@ -467,22 +457,17 @@ GstreamerPlayer :: stop(void) throw (std::logic_error)
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
* Close the currently opened audio file.
|
* Close the currently opened audio file.
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
int
|
void
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -124,12 +124,11 @@ class GstreamerPlayer : virtual public Configurable,
|
||||||
std::string m_audioDevice;
|
std::string m_audioDevice;
|
||||||
|
|
||||||
gint64 m_smilOffset;
|
gint64 m_smilOffset;
|
||||||
gint m_stop_time;
|
|
||||||
gint64 m_currentPlayLength;
|
gint64 m_currentPlayLength;
|
||||||
gint64 m_Id;
|
gint64 m_Id;
|
||||||
|
|
||||||
|
gint64 offsetSmil(gint64);//private helper to handle playback offset
|
||||||
public:
|
public:
|
||||||
gint m_start_time;
|
|
||||||
/**
|
/**
|
||||||
* Contains runtime error messages from GStreamer.
|
* Contains runtime error messages from GStreamer.
|
||||||
*/
|
*/
|
||||||
|
@ -167,7 +166,6 @@ public:
|
||||||
static gboolean
|
static gboolean
|
||||||
fireOnStartEvent(gpointer self) throw ();
|
fireOnStartEvent(gpointer self) throw ();
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
|
@ -315,7 +313,7 @@ public:
|
||||||
*
|
*
|
||||||
* @see #open
|
* @see #open
|
||||||
*/
|
*/
|
||||||
virtual int
|
virtual void
|
||||||
close(void) throw (std::logic_error);
|
close(void) throw (std::logic_error);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -330,7 +328,7 @@ public:
|
||||||
* @see #stop
|
* @see #stop
|
||||||
*/
|
*/
|
||||||
virtual void
|
virtual void
|
||||||
start(int,int) throw (std::logic_error);
|
start(gint64) throw (std::logic_error);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pause the player.
|
* Pause the player.
|
||||||
|
|
|
@ -76,7 +76,6 @@ using namespace LiveSupport::SchedulerClient;
|
||||||
using namespace LiveSupport::Widgets;
|
using namespace LiveSupport::Widgets;
|
||||||
using namespace LiveSupport::GLiveSupport;
|
using namespace LiveSupport::GLiveSupport;
|
||||||
|
|
||||||
#define STOP_TIME 300
|
|
||||||
/* =================================================== local data structures */
|
/* =================================================== local data structures */
|
||||||
|
|
||||||
|
|
||||||
|
@ -1306,7 +1305,7 @@ GLiveSupport :: playOutputAudio(Ptr<Playable>::Ref playable)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
outputPlayer->start(0, STOP_TIME);
|
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;
|
||||||
|
@ -1315,7 +1314,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(0, STOP_TIME);
|
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;
|
||||||
|
@ -1365,7 +1364,7 @@ GLiveSupport :: pauseOutputAudio(void)
|
||||||
outputPlayerIsPaused = true;
|
outputPlayerIsPaused = true;
|
||||||
|
|
||||||
} else if (outputPlayerIsPaused) {
|
} else if (outputPlayerIsPaused) {
|
||||||
outputPlayer->start(0, STOP_TIME);
|
outputPlayer->start(0);
|
||||||
outputPlayerIsPaused = false;
|
outputPlayerIsPaused = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1448,7 +1447,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(0, STOP_TIME);
|
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;
|
||||||
|
@ -1457,7 +1456,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(0, STOP_TIME);
|
cuePlayer->start(0);
|
||||||
std::cerr << "gLiveSupport: Cue playing playlist '"
|
std::cerr << "gLiveSupport: Cue playing playlist '"
|
||||||
<< *playable->getTitle()
|
<< *playable->getTitle()
|
||||||
<< "'" << std::endl;
|
<< "'" << std::endl;
|
||||||
|
@ -1506,7 +1505,7 @@ GLiveSupport :: pauseCueAudio(void)
|
||||||
cuePlayerIsPaused = true;
|
cuePlayerIsPaused = true;
|
||||||
|
|
||||||
} else if (cuePlayerIsPaused) {
|
} else if (cuePlayerIsPaused) {
|
||||||
cuePlayer->start(0, STOP_TIME);
|
cuePlayer->start(0);
|
||||||
cuePlayerIsPaused = false;
|
cuePlayerIsPaused = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1774,7 +1773,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(0, STOP_TIME);
|
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();
|
||||||
|
|
|
@ -54,8 +54,6 @@ using namespace boost;
|
||||||
using namespace LiveSupport::Core;
|
using namespace LiveSupport::Core;
|
||||||
using namespace LiveSupport::Scheduler;
|
using namespace LiveSupport::Scheduler;
|
||||||
|
|
||||||
#define START_TIME 0
|
|
||||||
#define STOP_TIME 30
|
|
||||||
/* =================================================== local data structures */
|
/* =================================================== local data structures */
|
||||||
|
|
||||||
|
|
||||||
|
@ -161,7 +159,7 @@ PlaylistEvent :: start(Ptr<time_duration>::Ref offset) thr
|
||||||
|
|
||||||
try {
|
try {
|
||||||
audioPlayer->open(*playlist->getUri(), (gint64)playlist->getId()->getId());
|
audioPlayer->open(*playlist->getUri(), (gint64)playlist->getId()->getId());
|
||||||
audioPlayer->start(START_TIME, STOP_TIME);
|
audioPlayer->start(offset->total_microseconds());
|
||||||
|
|
||||||
playLog->addPlayLogEntry(playlist->getId(), TimeConversion::now());
|
playLog->addPlayLogEntry(playlist->getId(), TimeConversion::now());
|
||||||
} catch (std::invalid_argument &e) {
|
} catch (std::invalid_argument &e) {
|
||||||
|
|
Loading…
Reference in New Issue