[vlmc-devel] Expose number of frames from ISource

Hugo Beauzée-Luyssen git at videolan.org
Mon Feb 24 20:09:42 CET 2014


vlmc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Mon Feb 24 17:08:31 2014 +0200| [7550767d16823aed6c58e16ea27e4ade98ed9a60] | committer: Hugo Beauzée-Luyssen

Expose number of frames from ISource

> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=7550767d16823aed6c58e16ea27e4ade98ed9a60
---

 src/Backend/ISource.h         |    1 +
 src/Backend/VLC/VLCSource.cpp |   11 +++++++++++
 src/Backend/VLC/VLCSource.h   |    2 ++
 src/Media/Clip.cpp            |    4 ++--
 src/Media/Media.cpp           |   13 -------------
 src/Media/Media.h             |    1 -
 src/Renderer/ClipRenderer.cpp |    2 +-
 7 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/src/Backend/ISource.h b/src/Backend/ISource.h
index 0113b5b..3768682 100644
--- a/src/Backend/ISource.h
+++ b/src/Backend/ISource.h
@@ -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
diff --git a/src/Backend/VLC/VLCSource.cpp b/src/Backend/VLC/VLCSource.cpp
index 4437fd2..5b71a96 100644
--- a/src/Backend/VLC/VLCSource.cpp
+++ b/src/Backend/VLC/VLCSource.cpp
@@ -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;
+}
+
diff --git a/src/Backend/VLC/VLCSource.h b/src/Backend/VLC/VLCSource.h
index 5ca428a..7a5ead2 100644
--- a/src/Backend/VLC/VLCSource.h
+++ b/src/Backend/VLC/VLCSource.h
@@ -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;
 };
 
 
diff --git a/src/Media/Clip.cpp b/src/Media/Clip.cpp
index 8fd229c..d19fa1d 100644
--- a/src/Media/Clip.cpp
+++ b/src/Media/Clip.cpp
@@ -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();
     }
 }
diff --git a/src/Media/Media.cpp b/src/Media/Media.cpp
index 5ff8fae..edfab0c 100644
--- a/src/Media/Media.cpp
+++ b/src/Media/Media.cpp
@@ -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
 {
diff --git a/src/Media/Media.h b/src/Media/Media.h
index 1e1b180..ab777be 100644
--- a/src/Media/Media.h
+++ b/src/Media/Media.h
@@ -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;
diff --git a/src/Renderer/ClipRenderer.cpp b/src/Renderer/ClipRenderer.cpp
index 4e8bd72..963e787 100644
--- a/src/Renderer/ClipRenderer.cpp
+++ b/src/Renderer/ClipRenderer.cpp
@@ -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;



More information about the Vlmc-devel mailing list