Commit 7550767d authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Expose number of frames from ISource

parent d87640ec
...@@ -51,6 +51,7 @@ namespace Backend ...@@ -51,6 +51,7 @@ namespace Backend
virtual bool hasAudio() const = 0; virtual bool hasAudio() const = 0;
virtual unsigned int nbAudioTracks() const = 0; virtual unsigned int nbAudioTracks() const = 0;
virtual const uint8_t* snapshot() const = 0; virtual const uint8_t* snapshot() const = 0;
virtual int64_t nbFrames() const = 0;
}; };
class IMemorySource class IMemorySource
......
...@@ -82,7 +82,12 @@ VLCSource::preparse() ...@@ -82,7 +82,12 @@ VLCSource::preparse()
mediaPlayer->getSize( &m_width, &m_height ); mediaPlayer->getSize( &m_width, &m_height );
m_fps = mediaPlayer->getFps(); m_fps = mediaPlayer->getFps();
if ( m_fps < 0.1f ) if ( m_fps < 0.1f )
{
vlmcWarning() << "Invalid FPS for source" << m_media->mrl(); vlmcWarning() << "Invalid FPS for source" << m_media->mrl();
delete renderer;
return false;
}
m_nbFrames = (int64_t)( (float)( m_length / 1000 ) * m_fps );
return computeSnapshot( renderer ); return computeSnapshot( renderer );
} }
delete renderer; delete renderer;
...@@ -178,3 +183,9 @@ VLCSource::snapshot() const ...@@ -178,3 +183,9 @@ VLCSource::snapshot() const
return m_snapshot->bits(); return m_snapshot->bits();
} }
int64_t
VLCSource::nbFrames() const
{
return m_nbFrames;
}
...@@ -53,6 +53,7 @@ public: ...@@ -53,6 +53,7 @@ public:
virtual bool hasAudio() const; virtual bool hasAudio() const;
virtual unsigned int nbAudioTracks() const; virtual unsigned int nbAudioTracks() const;
const uint8_t* snapshot() const; const uint8_t* snapshot() const;
virtual int64_t nbFrames() const;
// Below this point are backend internal methods: // Below this point are backend internal methods:
LibVLCpp::Media* media(); LibVLCpp::Media* media();
...@@ -71,6 +72,7 @@ private: ...@@ -71,6 +72,7 @@ private:
int64_t m_length; //in milliseconds. int64_t m_length; //in milliseconds.
QImage* m_snapshot; QImage* m_snapshot;
bool m_isParsed; bool m_isParsed;
int64_t m_nbFrames;
}; };
......
...@@ -39,7 +39,7 @@ Clip::Clip( Media *media, qint64 begin /*= 0*/, qint64 end /*= -1*/, const QStri ...@@ -39,7 +39,7 @@ Clip::Clip( Media *media, qint64 begin /*= 0*/, qint64 end /*= -1*/, const QStri
m_parent( media->baseClip() ) m_parent( media->baseClip() )
{ {
if ( end == -1 ) if ( end == -1 )
m_end = media->nbFrames(); m_end = media->source()->nbFrames();
if ( uuid.isEmpty() == true ) if ( uuid.isEmpty() == true )
m_uuid = QUuid::createUuid(); m_uuid = QUuid::createUuid();
else else
...@@ -279,7 +279,7 @@ Clip::mediaMetadataUpdated() ...@@ -279,7 +279,7 @@ Clip::mediaMetadataUpdated()
if ( m_end == 0 ) if ( m_end == 0 )
{ {
m_begin = 0; m_begin = 0;
m_end = m_media->nbFrames(); m_end = m_media->source()->nbFrames();
computeLength(); computeLength();
} }
} }
...@@ -57,7 +57,6 @@ QPixmap* Media::defaultSnapshot = NULL; ...@@ -57,7 +57,6 @@ QPixmap* Media::defaultSnapshot = NULL;
Media::Media(const QString &path ) Media::Media(const QString &path )
: m_source( NULL ) : m_source( NULL )
, m_fileInfo( NULL ) , m_fileInfo( NULL )
, m_nbFrames( 0 )
, m_baseClip( NULL ) , m_baseClip( NULL )
, m_inWorkspace( false ) , m_inWorkspace( false )
, m_snapshotImage( NULL ) , m_snapshotImage( NULL )
...@@ -88,18 +87,6 @@ void Media::setFileType(Media::FileType type) ...@@ -88,18 +87,6 @@ void Media::setFileType(Media::FileType type)
m_fileType = type; m_fileType = type;
} }
void
Media::setNbFrames( qint64 nbFrames )
{
m_nbFrames = nbFrames;
}
qint64
Media::nbFrames() const
{
return m_nbFrames;
}
const QString& const QString&
Media::mrl() const Media::mrl() const
{ {
......
...@@ -110,7 +110,6 @@ protected: ...@@ -110,7 +110,6 @@ protected:
Backend::ISource* m_source; Backend::ISource* m_source;
QString m_mrl; QString m_mrl;
QFileInfo* m_fileInfo; QFileInfo* m_fileInfo;
qint64 m_nbFrames;
FileType m_fileType; FileType m_fileType;
QString m_fileName; QString m_fileName;
Clip* m_baseClip; Clip* m_baseClip;
......
...@@ -100,7 +100,7 @@ ClipRenderer::startPreview() ...@@ -100,7 +100,7 @@ ClipRenderer::startPreview()
connect( m_eventWatcher, SIGNAL( timeChanged( qint64 ) ), this, SLOT( __timeChanged( qint64 ) ) ); connect( m_eventWatcher, SIGNAL( timeChanged( qint64 ) ), this, SLOT( __timeChanged( qint64 ) ) );
m_sourceRenderer->start(); m_sourceRenderer->start();
m_sourceRenderer->setPosition( (float)m_begin / (float)m_selectedClip->getMedia()->nbFrames() ); m_sourceRenderer->setPosition( (float)m_begin / (float)m_selectedClip->getMedia()->source()->nbFrames() );
m_clipLoaded = true; m_clipLoaded = true;
m_isRendering = true; m_isRendering = true;
m_paused = false; m_paused = false;
......
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