[vlmc-devel] VLCMedia: Rely on libvlc to store the mrl

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


vlmc | branch: ibackend | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Mon Feb 24 15:30:26 2014 +0200| [305d6662d204c648f9edfdf427994a6b3c97a7c7] | committer: Hugo Beauzée-Luyssen

VLCMedia: Rely on libvlc to store the mrl

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

 src/Backend/VLC/LibVLCpp/VLCMedia.cpp |   14 +++++++++-----
 src/Backend/VLC/LibVLCpp/VLCMedia.h   |    4 ++--
 src/Backend/VLC/VLCSource.cpp         |    2 +-
 3 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/src/Backend/VLC/LibVLCpp/VLCMedia.cpp b/src/Backend/VLC/LibVLCpp/VLCMedia.cpp
index da575a0..d2aade6 100644
--- a/src/Backend/VLC/LibVLCpp/VLCMedia.cpp
+++ b/src/Backend/VLC/LibVLCpp/VLCMedia.cpp
@@ -31,9 +31,9 @@
 using namespace LibVLCpp;
 
 Media::Media( LibVLCpp::Instance* instance, const QString& filename )
-    : m_fileName( filename )
-    , m_tracks( NULL )
+    : m_tracks( NULL )
     , m_nbTracks( 0 )
+    , m_mrl( NULL )
 
 {
     m_internalPtr = libvlc_media_new_location( *instance, filename.toLocal8Bit() );
@@ -42,6 +42,7 @@ Media::Media( LibVLCpp::Instance* instance, const QString& filename )
 Media::Media( LibVLCpp::Media &media )
     : m_tracks( NULL )
     , m_nbTracks( 0 )
+    , m_mrl( NULL )
 {
     m_internalPtr = libvlc_media_duplicate( media );
 }
@@ -51,6 +52,7 @@ Media::~Media()
     if ( m_tracks != NULL )
         libvlc_media_tracks_release( m_tracks, m_nbTracks );
     libvlc_media_release( m_internalPtr );
+    free( m_mrl );
 }
 
 void
@@ -115,10 +117,12 @@ Media::setAudioDataCtx( void* dataCtx )
     addOption( param );
 }
 
-const QString&
-Media::getFileName() const
+const char*
+Media::mrl()
 {
-    return m_fileName;
+    if ( m_mrl == NULL )
+        m_mrl = libvlc_media_get_mrl( m_internalPtr );
+    return m_mrl;
 }
 
 void
diff --git a/src/Backend/VLC/LibVLCpp/VLCMedia.h b/src/Backend/VLC/LibVLCpp/VLCMedia.h
index 18faca3..6c80d41 100644
--- a/src/Backend/VLC/LibVLCpp/VLCMedia.h
+++ b/src/Backend/VLC/LibVLCpp/VLCMedia.h
@@ -48,18 +48,18 @@ namespace LibVLCpp
         void                setAudioUnlockCallback( void* );
         void                setVideoDataCtx( void* dataCtx );
         void                setAudioDataCtx( void* dataCtx );
-        const QString&      getFileName() const;
+        const char*         mrl();
         void                parse();
         void                fetchTrackInfo();
         unsigned int videoCodec() const;
         unsigned int audioCodec() const;
 
     private:
-        QString                     m_fileName;
         libvlc_media_track_t        **m_tracks;
         // this has not to be equal to nb video tracks + nb audio tracks.
         // it is only meant to use when iterating over m_tracksInfo
         int                         m_nbTracks;
+        char*                       m_mrl;
     };
 }
 
diff --git a/src/Backend/VLC/VLCSource.cpp b/src/Backend/VLC/VLCSource.cpp
index f3d9a48..4437fd2 100644
--- a/src/Backend/VLC/VLCSource.cpp
+++ b/src/Backend/VLC/VLCSource.cpp
@@ -82,7 +82,7 @@ VLCSource::preparse()
         mediaPlayer->getSize( &m_width, &m_height );
         m_fps = mediaPlayer->getFps();
         if ( m_fps < 0.1f )
-            vlmcWarning() << "Invalid FPS for source" << m_media->getFileName();
+            vlmcWarning() << "Invalid FPS for source" << m_media->mrl();
         return computeSnapshot( renderer );
     }
     delete renderer;



More information about the Vlmc-devel mailing list