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