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

Added next/previous frame button.

Works for clip preview, doesn't work that much for render preview ATM...
parent b1a2df14
......@@ -86,7 +86,6 @@ void MediaPlayer::callbacks( const libvlc_event_t* ev
self->emit endReached();
break;
case libvlc_MediaPlayerTimeChanged:
//self->timeChangedFilter();
self->emit timeChanged();
break;
case libvlc_MediaPlayerPositionChanged:
......@@ -228,3 +227,10 @@ int MediaPlayer::getHeight()
CheckVlcppException( m_ex );
return height;
}
float MediaPlayer::getFps()
{
float fps = libvlc_media_player_get_fps( m_internalPtr, m_ex );
CheckVlcppException( m_ex );
return fps;
}
......@@ -56,6 +56,7 @@ namespace LibVLCpp
void setMedia(Media* media);
int getWidth();
int getHeight();
float getFps();
private:
static void callbacks( const libvlc_event_t* event, void* self );
......
......@@ -108,15 +108,27 @@ unsigned char* MainWorkflow::getOutput()
if ( ret == NULL )
ret = MainWorkflow::blackOutput;
++m_currentFrame;
emit frameChanged( m_currentFrame );
emit positionChanged( (float)m_currentFrame / (float)m_length );
nextFrame();
return ret;
}
else
return MainWorkflow::blackOutput;
}
void MainWorkflow::nextFrame()
{
++m_currentFrame;
emit frameChanged( m_currentFrame );
emit positionChanged( (float)m_currentFrame / (float)m_length );
}
void MainWorkflow::previousFrame()
{
--m_currentFrame;
emit frameChanged( m_currentFrame );
emit positionChanged( (float)m_currentFrame / (float)m_length );
}
void MainWorkflow::setPosition( float pos )
{
//Since any track can be reactivated, we reactivate all of them, and let them
......
......@@ -65,6 +65,8 @@ class MainWorkflow : public QObject
void stop();
static unsigned char* blackOutput;
void nextFrame();
void previousFrame();
private:
Toggleable<TrackWorkflow*>* m_tracks;
......
......@@ -82,6 +82,24 @@ void ClipPreviewWidget::togglePlayPause( bool forcePause )
m_mediaPlayer->play();
}
void ClipPreviewWidget::nextFrame()
{
if ( m_videoStopped == false )
{
qint64 interval = (1.0f / m_mediaPlayer->getFps()) * 1000.0f;
m_mediaPlayer->setTime( m_mediaPlayer->getTime() + interval );
}
}
void ClipPreviewWidget::previousFrame()
{
if ( m_videoStopped == false )
{
qint64 interval = (1.0f / m_mediaPlayer->getFps()) * 1000.0f;
m_mediaPlayer->setTime( m_mediaPlayer->getTime() - interval );
}
}
/////////////////////////////////////////////////////////////////////
/////SLOTS :
/////////////////////////////////////////////////////////////////////
......
......@@ -44,6 +44,8 @@ public:
virtual void setPosition( float newPos );
virtual void togglePlayPause( bool forcePause );
virtual void stop();
virtual void nextFrame();
virtual void previousFrame();
private:
bool m_clipLoaded;
......
......@@ -48,6 +48,8 @@ public:
virtual void startPreview( Media* media ) = 0;
virtual void setPosition( float newPos ) = 0;
virtual void togglePlayPause( bool forcePause = false ) = 0;
virtual void nextFrame() = 0;
virtual void previousFrame() = 0;
virtual void stop() = 0;
protected:
......
......@@ -38,7 +38,7 @@ PreviewWidget::PreviewWidget( MainWorkflow* mainWorkflow, QWidget *parent ) :
m_sliderPosBackup( 0 )
{
m_ui->setupUi( this );
m_ui->groupBoxButton->hide();
m_ui->seekSlider->setMinimum( 0 );
m_ui->seekSlider->setMaximum( 1000 );
m_ui->seekSlider->setSingleStep( 2 );
......@@ -233,3 +233,15 @@ void PreviewWidget::changedTab( int tabId )
m_ui->seekSlider->setValue( m_sliderPosBackup );
m_sliderPosBackup = tmp;
}
void PreviewWidget::on_pushButtonNextFrame_clicked()
{
if ( m_previewStopped == false )
m_currentPreviewRenderer->nextFrame();
}
void PreviewWidget::on_pushButtonPreviousFrame_clicked()
{
if ( m_previewStopped == false )
m_currentPreviewRenderer->previousFrame();
}
......@@ -67,6 +67,8 @@ protected:
private slots:
void on_pushButtonPlay_clicked();
void on_pushButtonStop_clicked();
void on_pushButtonNextFrame_clicked();
void on_pushButtonPreviousFrame_clicked();
void positionChanged( float );
void seekSliderPressed();
void seekSliderMoved( int value );
......
......@@ -28,8 +28,10 @@
RenderPreviewWidget::RenderPreviewWidget( MainWorkflow* mainWorkflow, QWidget* renderWidget ) :
GenericPreviewWidget( renderWidget ),
m_mainWorkflow( mainWorkflow ),
m_isRendering( false )
m_isRendering( false ),
m_framePlayed( false )
{
m_framePlayedLock = new QReadWriteLock;
m_media = new LibVLCpp::Media( "fake://" );
// --invmem-width <integer> Width
// --invmem-height <integer> Height
......@@ -66,13 +68,18 @@ RenderPreviewWidget::~RenderPreviewWidget()
void* RenderPreviewWidget::lock( void* datas )
{
RenderPreviewWidget* self = reinterpret_cast<RenderPreviewWidget*>( datas);
RenderPreviewWidget* self = reinterpret_cast<RenderPreviewWidget*>( datas );
void* ret = self->m_mainWorkflow->getOutput();
return ret;
}
void RenderPreviewWidget::unlock( void* )
void RenderPreviewWidget::unlock( void* datas )
{
RenderPreviewWidget* self = reinterpret_cast<RenderPreviewWidget*>( datas );
qDebug() << "RenderPreviewWidget::unlock() : Frame rendered";
QWriteLocker lock( self->m_framePlayedLock );
self->m_framePlayed = true;
}
void RenderPreviewWidget::stopPreview()
......@@ -94,6 +101,29 @@ void RenderPreviewWidget::setPosition( float newPos )
m_mainWorkflow->setPosition( newPos );
}
void RenderPreviewWidget::nextFrame()
{
{
QWriteLocker lock( m_framePlayedLock );
m_framePlayed = false;
}
m_mainWorkflow->nextFrame();
m_mediaPlayer->play();
bool framePlayed = false;
while ( framePlayed == false )
{
usleep( 50 );
QReadLocker lock( m_framePlayedLock );
framePlayed = m_framePlayed;
}
m_mediaPlayer->pause();
}
void RenderPreviewWidget::previousFrame()
{
}
void RenderPreviewWidget::togglePlayPause( bool forcePause )
{
//If force pause is true, we just ensure that this render is paused... no need to start it.
......
......@@ -51,6 +51,8 @@ class RenderPreviewWidget : public GenericPreviewWidget
virtual void setPosition( float newPos );
virtual void togglePlayPause( bool forcePause );
virtual void stop();
virtual void nextFrame();
virtual void previousFrame();
static void* lock( void* datas );
static void unlock( void* datas );
......@@ -59,6 +61,8 @@ class RenderPreviewWidget : public GenericPreviewWidget
MainWorkflow* m_mainWorkflow;
LibVLCpp::Media* m_media;
bool m_isRendering;
QReadWriteLock* m_framePlayedLock;
bool m_framePlayed;
public slots:
void __positionChanged();
......
......@@ -92,6 +92,29 @@
</item>
<item row="2" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="pushButtonPreviousFrame">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../ressources.qrc">
<normaloff>:/images/images/previous_frame.png</normaloff>:/images/images/previous_frame.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonPlay">
<property name="sizePolicy">
......@@ -109,14 +132,14 @@
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonStop">
<widget class="QPushButton" name="pushButtonNextFrame">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
......@@ -128,12 +151,12 @@
</property>
<property name="icon">
<iconset resource="../../../ressources.qrc">
<normaloff>:/images/images/stop.png</normaloff>:/images/images/stop.png</iconset>
<normaloff>:/images/images/next_frame.png</normaloff>:/images/images/next_frame.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
......@@ -152,155 +175,26 @@
</spacer>
</item>
<item>
<widget class="QGroupBox" name="groupBoxButton">
<widget class="QPushButton" name="pushButtonStop">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../ressources.qrc">
<normaloff>:/images/images/stop.png</normaloff>:/images/images/stop.png</iconset>
</property>
<property name="iconSize">
<size>
<width>136</width>
<height>60</height>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="title">
<string/>
</property>
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>56</x>
<y>10</y>
<width>25</width>
<height>25</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QPushButton" name="pushButton_2">
<property name="geometry">
<rect>
<x>12</x>
<y>10</y>
<width>25</width>
<height>25</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QPushButton" name="pushButton_3">
<property name="geometry">
<rect>
<x>34</x>
<y>10</y>
<width>25</width>
<height>25</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QPushButton" name="pushButton_4">
<property name="geometry">
<rect>
<x>100</x>
<y>10</y>
<width>25</width>
<height>25</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QPushButton" name="pushButton_5">
<property name="geometry">
<rect>
<x>78</x>
<y>10</y>
<width>25</width>
<height>25</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QPushButton" name="pushButton_11">
<property name="geometry">
<rect>
<x>12</x>
<y>35</y>
<width>25</width>
<height>25</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QPushButton" name="pushButton_12">
<property name="geometry">
<rect>
<x>100</x>
<y>35</y>
<width>25</width>
<height>25</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
</widget>
</widget>
</item>
</layout>
......
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