Commit ad6ea0b9 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Started refactoring for Clip workflow

The aim is to launch a clip workflow, and let it start the playback, but
pause as the first frame.
parent 951e98ad
......@@ -97,7 +97,7 @@ void ClipWorkflow::setRenderComplete()
}
void ClipWorkflow::initialize()
void ClipWorkflow::setVmem()
{
char buffer[32];
......@@ -118,36 +118,44 @@ void ClipWorkflow::initialize()
m_clip->getParent()->getVLCMedia()->addOption( buffer );
}
void ClipWorkflow::startRender( LibVLCpp::MediaPlayer* mediaPlayer )
void ClipWorkflow::initialize( LibVLCpp::MediaPlayer* mediaPlayer )
{
initialize();
setVmem();
m_mediaPlayer = mediaPlayer;
m_mediaPlayer->setMedia( m_clip->getParent()->getVLCMedia() );
if ( m_clip->getBegin() == 0.0f )
{
QWriteLocker lock( m_initMutex );
m_isReady = true;
connect( m_mediaPlayer, SIGNAL( playing() ), this, SLOT( pauseAfterPlaybackStarted() ), Qt::DirectConnection );
}
else
{
//The last parameter is NOT here for decoration ;)
connect( m_mediaPlayer, SIGNAL( playing() ), this, SLOT( playbackStarted() ), Qt::DirectConnection );
connect( m_mediaPlayer, SIGNAL( playing() ), this, SLOT( setPosition() ), Qt::DirectConnection );
}
m_mediaPlayer->play();
}
void ClipWorkflow::playbackStarted()
void ClipWorkflow::setPosition()
{
disconnect( m_mediaPlayer, SIGNAL( playing() ), this, SLOT( playbackStarted() ) );
connect( m_mediaPlayer, SIGNAL( positionChanged() ), this, SLOT( positionChanged() ), Qt::DirectConnection );
disconnect( m_mediaPlayer, SIGNAL( playing() ), this, SLOT( setPosition() ) );
connect( m_mediaPlayer, SIGNAL( positionChanged() ), this, SLOT( pauseAfterPlaybackStarted() ), Qt::DirectConnection );
m_mediaPlayer->setPosition( m_clip->getBegin() );
}
void ClipWorkflow::positionChanged()
void ClipWorkflow::pauseAfterPlaybackStarted()
{
disconnect( m_mediaPlayer, SIGNAL( positionChanged() ), this, SLOT( positionChanged() ) );
disconnect( m_mediaPlayer, SIGNAL( positionChanged() ), this, SLOT( pauseAfterPlaybackStarted() ) );
disconnect( m_mediaPlayer, SIGNAL( playing() ), this, SLOT( pauseAfterPlaybackStarted() ) );
connect( m_mediaPlayer, SIGNAL( paused() ), this, SLOT( pausedMediaPlayer() ), Qt::DirectConnection );
m_mediaPlayer->pause();
}
void ClipWorkflow::pausedMediaPlayer()
{
disconnect( m_mediaPlayer, SIGNAL( paused() ), this, SLOT( pausedMediaPlayer() ) );
QWriteLocker lock( m_initMutex);
m_isReady = true;
}
......
......@@ -47,14 +47,14 @@ class ClipWorkflow : public QObject
bool renderComplete() const;
unsigned char* getOutput();
void startRender( LibVLCpp::MediaPlayer* mediaPlayer );
void initialize( LibVLCpp::MediaPlayer* mediaPlayer );
bool isReady() const;
bool isEndReached() const;
private:
static void lock( ClipWorkflow* clipWorkflow, void** pp_ret );
static void unlock( ClipWorkflow* clipWorkflow );
void initialize();
void setVmem();
void setRenderComplete();
private:
......@@ -71,8 +71,9 @@ class ClipWorkflow : public QObject
QReadWriteLock* m_endReachedLock;
public slots:
void playbackStarted();
void positionChanged();
void pauseAfterPlaybackStarted();
void pausedMediaPlayer();
void setPosition();
};
#endif // CLIPWORKFLOW_H
......@@ -38,7 +38,7 @@ void TrackWorkflow::addClip( Clip* clip )
void TrackWorkflow::startRender()
{
m_currentClipWorkflow->startRender( m_mediaPlayer );
m_currentClipWorkflow->initialize( m_mediaPlayer );
while ( m_currentClipWorkflow->isReady() == false )
usleep( 150 );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment