[Libreoffice-commits] core.git: 5 commits - avmedia/source

Minh Ngo nlminhtl at gmail.com
Mon Oct 7 00:29:54 PDT 2013


 avmedia/source/vlc/vlcframegrabber.cxx      |   13 +++++++++++--
 avmedia/source/vlc/vlcmanager.cxx           |   10 +++++++++-
 avmedia/source/vlc/vlcplayer.cxx            |    6 +++++-
 avmedia/source/vlc/wrapper/Common.cxx       |    5 ++++-
 avmedia/source/vlc/wrapper/Instance.cxx     |    4 ++++
 avmedia/source/vlc/wrapper/Media.cxx        |   13 +++++++++++--
 avmedia/source/vlc/wrapper/Player.cxx       |    5 ++++-
 avmedia/source/vlc/wrapper/SymbolLoader.hxx |   15 +++++++++------
 8 files changed, 57 insertions(+), 14 deletions(-)

New commits:
commit bc43c1ca942c4c111aa7f45b268e13ab03c7f613
Author: Minh Ngo <nlminhtl at gmail.com>
Date:   Mon Oct 7 10:23:04 2013 +0300

    Avmedia/VLC: Fixing some errors when creating libvlc_instance_t.
    
    condition wait is temporary only for non-windows system. Looks like there is some
    hang. Must be investigate later...
    
    Change-Id: Ia20227503f70244d33411164d4af95ba69e86509

diff --git a/avmedia/source/vlc/vlcframegrabber.cxx b/avmedia/source/vlc/vlcframegrabber.cxx
index f5b7091..7a742e9 100644
--- a/avmedia/source/vlc/vlcframegrabber.cxx
+++ b/avmedia/source/vlc/vlcframegrabber.cxx
@@ -28,10 +28,15 @@ namespace
 
     const char * const VLC_ARGS[] = {
         "-Vdummy",
+        // "--ignore-config"
+        "--demux",
+        "ffmpeg",
         "--snapshot-format=png",
-        "--ffmpeg-threads",
+        "--ffmpeg-threads", /* Is deprecated in 2.1.0 */
         "--verbose=2",
-        "--no-audio"
+        "--no-audio"//,
+        //"--file-logging",
+        //"--logfile=C:/home/dev/log/vlc_log"
     };
 }
 
@@ -64,7 +69,11 @@ VLCFrameGrabber::VLCFrameGrabber( wrapper::EventHandler& eh, const rtl::OUString
         mPlayer.pause();
 
         const TimeValue timeout = {2, 0};
+
+        //TODO: Fix this hang on Windows
+#ifndef WNT
         condition.wait(&timeout);
+#endif
 
         if ( !mPlayer.hasVout() )
         {
diff --git a/avmedia/source/vlc/vlcmanager.cxx b/avmedia/source/vlc/vlcmanager.cxx
index 8453bb4..370505d 100644
--- a/avmedia/source/vlc/vlcmanager.cxx
+++ b/avmedia/source/vlc/vlcmanager.cxx
@@ -30,7 +30,13 @@ namespace
 
     const char * const VLC_ARGS[] = {
         "-Vdummy",
-        "--verbose=2"
+#ifdef WNT
+        "--demux",
+        "ffmpeg",
+#endif
+        "--verbose=2"//,
+        //"--file-logging",
+        //"--logfile=C:/home/dev/log/vlc_log"
     };
 }
 
@@ -69,7 +75,9 @@ Manager::Manager( const uno::Reference< lang::XMultiServiceFactory >& rxMgr )
         SAL_WARN("avmedia", "Cannot load symbols");
 
     if (m_is_vlc_found)
+    {
         mEventHandler.create();
+    }
 }
 
 Manager::~Manager()
diff --git a/avmedia/source/vlc/vlcplayer.cxx b/avmedia/source/vlc/vlcplayer.cxx
index a1fef95..8d54672 100644
--- a/avmedia/source/vlc/vlcplayer.cxx
+++ b/avmedia/source/vlc/vlcplayer.cxx
@@ -50,7 +50,10 @@ unsigned VLCPlayer::getHeight() const
 void SAL_CALL VLCPlayer::start() throw ( ::com::sun::star::uno::RuntimeException )
 {
     ::osl::MutexGuard aGuard(m_aMutex);
-    mPlayer.play();
+    if (!mPlayer.play())
+    {
+        // TODO: Error
+    }
 }
 
 void SAL_CALL VLCPlayer::stop() throw ( ::com::sun::star::uno::RuntimeException )
@@ -226,6 +229,7 @@ uno::Reference< css::media::XFrameGrabber > SAL_CALL VLCPlayer::createFrameGrabb
      throw ( ::com::sun::star::uno::RuntimeException )
 {
     ::osl::MutexGuard aGuard(m_aMutex);
+
     if ( !mrFrameGrabber.is() )
     {
         VLCFrameGrabber *frameGrabber = new VLCFrameGrabber( mEventHandler, mUrl );
commit 8de1f54e19b68194b79a642750b9d3a4c8707d7b
Author: Minh Ngo <nlminhtl at gmail.com>
Date:   Mon Oct 7 10:21:24 2013 +0300

    Avmedia/VLC: Adding some todo
    
    Change-Id: I5c01ae2f0e2109460aa332b31b524f855b87948a

diff --git a/avmedia/source/vlc/wrapper/Instance.cxx b/avmedia/source/vlc/wrapper/Instance.cxx
index 4d117d6..a6a71d1 100644
--- a/avmedia/source/vlc/wrapper/Instance.cxx
+++ b/avmedia/source/vlc/wrapper/Instance.cxx
@@ -38,6 +38,10 @@ namespace wrapper
     Instance::Instance( int argc, const char * const argv[] )
         : mInstance( libvlc_new( argc, argv ) )
     {
+        if ( mInstance == NULL)
+        {
+            //TODO: error
+        }
     }
 
     Instance::Instance( const Instance& other )
diff --git a/avmedia/source/vlc/wrapper/Player.cxx b/avmedia/source/vlc/wrapper/Player.cxx
index 92348e2..d8608d8 100644
--- a/avmedia/source/vlc/wrapper/Player.cxx
+++ b/avmedia/source/vlc/wrapper/Player.cxx
@@ -12,6 +12,7 @@
 #include "Player.hxx"
 #include "Media.hxx"
 #include "SymbolLoader.hxx"
+ #include "Common.hxx"
 
 struct libvlc_media_t;
 
@@ -50,6 +51,7 @@ namespace
     void ( *libvlc_video_set_scale ) ( libvlc_media_player_t *p_mi, float f_factor );
     int ( *libvlc_video_get_size ) ( libvlc_media_player_t *p_mi, unsigned num,
                                      unsigned *px, unsigned *py );
+    int ( *libvlc_video_get_track_count ) ( libvlc_media_player_t *p_mi );
 }
 
 namespace avmedia
@@ -87,7 +89,8 @@ namespace wrapper
             SYM_MAP( libvlc_video_set_mouse_input ),
             SYM_MAP( libvlc_media_player_retain ),
             SYM_MAP( libvlc_video_set_scale ),
-            SYM_MAP( libvlc_video_get_size )
+            SYM_MAP( libvlc_video_get_size ),
+            SYM_MAP( libvlc_video_get_track_count )
         };
 
         return InitApiMap( VLC_PLAYER_API );
commit 926fcc560b7a5dc45968ddeffbf8cf185eb6f1c6
Author: Minh Ngo <nlminhtl at gmail.com>
Date:   Mon Oct 7 10:18:29 2013 +0300

    Avmedia/VLC: Using *_new_location instead of *_new_path function.
    
    There are some bug in *_new_location in the latest VLC versions. It
    doesn't parse URI correctly from the string "file:///blah-blah-blah".
    
    Change-Id: Iae54ad79fce0775a2f0a325766f713ff43e5d9ed

diff --git a/avmedia/source/vlc/wrapper/Media.cxx b/avmedia/source/vlc/wrapper/Media.cxx
index c2627de..d48ad49 100644
--- a/avmedia/source/vlc/wrapper/Media.cxx
+++ b/avmedia/source/vlc/wrapper/Media.cxx
@@ -25,18 +25,21 @@ namespace wrapper
 namespace
 {
     libvlc_media_t* ( *libvlc_media_new_path ) ( libvlc_instance_t *p_instance, const char *path );
+    libvlc_media_t* ( *libvlc_media_new_location ) (libvlc_instance_t *p_instance, const char *psz_mrl);
     void ( *libvlc_media_release ) ( libvlc_media_t *p_md );
     void ( *libvlc_media_retain ) ( libvlc_media_t *p_md );
     libvlc_time_t ( *libvlc_media_get_duration ) ( libvlc_media_t *p_md );
     void ( *libvlc_media_parse ) ( libvlc_media_t *p_md );
     int ( *libvlc_media_is_parsed ) ( libvlc_media_t *p_md );
+    char* ( *libvlc_media_get_mrl )(libvlc_media_t *p_md);
+
 
     libvlc_media_t* InitMedia( const rtl::OUString& url, Instance& instance )
     {
         rtl::OString dest;
         url.convertToString(&dest, RTL_TEXTENCODING_UTF8, 0);
 
-        return libvlc_media_new_path(instance, dest.getStr());
+        return libvlc_media_new_location(instance, dest.getStr());
     }
 }
 
@@ -49,7 +52,9 @@ bool Media::LoadSymbols()
         SYM_MAP( libvlc_media_retain ),
         SYM_MAP( libvlc_media_get_duration ),
         SYM_MAP( libvlc_media_parse ),
-        SYM_MAP( libvlc_media_is_parsed )
+        SYM_MAP( libvlc_media_is_parsed ),
+        SYM_MAP( libvlc_media_get_mrl ),
+        SYM_MAP( libvlc_media_new_location )
     };
 
     return InitApiMap( VLC_MEDIA_API );
@@ -58,6 +63,10 @@ bool Media::LoadSymbols()
 Media::Media( const rtl::OUString& url, Instance& instance )
     : mMedia( InitMedia( url, instance ) )
 {
+    if (mMedia == NULL)
+    {
+        // TODO: Error
+    }
 }
 
 Media::Media( const Media& other )
commit 3196e5b7a52580bfa9242a35175e241db328a49f
Author: Minh Ngo <nlminhtl at gmail.com>
Date:   Mon Oct 7 10:16:43 2013 +0300

    Avmedia/VLC: Returns "No error" if there aren't any error.
    
    Change-Id: Ic080cbcef56a82129347bbb4f008d1c36b0a927a

diff --git a/avmedia/source/vlc/wrapper/Common.cxx b/avmedia/source/vlc/wrapper/Common.cxx
index 1ed5256..4c28b6d 100644
--- a/avmedia/source/vlc/wrapper/Common.cxx
+++ b/avmedia/source/vlc/wrapper/Common.cxx
@@ -11,6 +11,8 @@
 
 namespace
 {
+    const char AVMEDIA_NO_ERROR[] = "No error";
+
     const char* ( *libvlc_get_version ) (void);
     char *  ( * libvlc_errmsg ) (void);
 }
@@ -39,7 +41,8 @@ const char* Common::Version()
 
 const char* Common::LastErrorMessage()
 {
-    return libvlc_errmsg();
+    const char *errorMsg = libvlc_errmsg();
+    return errorMsg == NULL ? AVMEDIA_NO_ERROR : errorMsg;
 }
 }
 }
commit c2f9e24ecfdc36decb9c3042d88976399e4606aa
Author: Minh Ngo <nlminhtl at gmail.com>
Date:   Mon Oct 7 10:14:10 2013 +0300

    Avmedia/VLC: Correct reading from the WINx86_64 registry for LO 32-bit.
    
    Change-Id: Ic98a179e5cfa34183e71a72bb417147612500a61
    TODO: Unfortunately. Another cases must be checked later....

diff --git a/avmedia/source/vlc/wrapper/SymbolLoader.hxx b/avmedia/source/vlc/wrapper/SymbolLoader.hxx
index ec38d1b..7061faf 100644
--- a/avmedia/source/vlc/wrapper/SymbolLoader.hxx
+++ b/avmedia/source/vlc/wrapper/SymbolLoader.hxx
@@ -47,21 +47,23 @@ namespace
         wchar_t arCurrent[MAX_PATH];
         DWORD dwType, dwCurrentSize = sizeof( arCurrent );
 
-        if ( ::RegOpenKeyExW( HKEY_LOCAL_MACHINE, L"SOFTWARE\\VideoLAN\\VLC",
-                             0, KEY_READ, &hKey ) == ERROR_SUCCESS )
+        //TODO: This one will work only with LibreOffice 32-bit + VLC 32-bit on Win x86_64.
+        const LONG errorCore = ::RegOpenKeyExW( HKEY_LOCAL_MACHINE, L"SOFTWARE\\Wow6432Node\\VideoLAN\\VLC", 0, KEY_READ | KEY_WOW64_64KEY, &hKey );
+        if ( errorCore == ERROR_SUCCESS )
         {
             if ( ::RegQueryValueExW( hKey, L"InstallDir", NULL, &dwType, (LPBYTE) arCurrent, &dwCurrentSize ) == ERROR_SUCCESS &&
                  dwType == REG_SZ )
             {
                 ::RegCloseKey( hKey );
-                // The value might be 0-terminated or not
-                if (arCurrent[dwCurrentSize/2] == 0)
-                    dwCurrentSize -= 2;
-                return OUString( arCurrent, dwCurrentSize ) + "/";
+                dwCurrentSize -= 2;
+                dwCurrentSize /= 2;
+
+                return OUString( arCurrent, dwCurrentSize ) + OUString::createFromAscii("\\");
             }
 
             ::RegCloseKey( hKey );
         }
+
         return OUString();
     }
 #endif
@@ -100,6 +102,7 @@ namespace
         oslModule aModule = osl_loadModule( fullPath.pData,
                                             SAL_LOADMODULE_DEFAULT );
 
+
         if( aModule == NULL)
         {
             SAL_WARN("avmedia", "Cannot load libvlc");


More information about the Libreoffice-commits mailing list