[Libreoffice-commits] core.git: Branch 'feature/vlc' - avmedia/source

Minh Ngo nlminhtl at gmail.com
Wed Jul 10 22:30:44 PDT 2013


 avmedia/source/vlc/vlcplayer.cxx |   46 ++++++++++++++++++++++++++++++++++++---
 avmedia/source/vlc/vlcwindow.hxx |    1 
 2 files changed, 44 insertions(+), 3 deletions(-)

New commits:
commit 8f83e797f65b1b4a38f3866c43d59bfecdd7746b
Author: Minh Ngo <nlminhtl at gmail.com>
Date:   Thu Jul 11 08:29:29 2013 +0300

    Binding a video frame into a LibreOffice's widget
    
    Change-Id: Iebf5b9f8cc83e7d2a96f105b07b6fe0eaf8b2678

diff --git a/avmedia/source/vlc/vlcplayer.cxx b/avmedia/source/vlc/vlcplayer.cxx
index 3c8453b..0a15a72 100644
--- a/avmedia/source/vlc/vlcplayer.cxx
+++ b/avmedia/source/vlc/vlcplayer.cxx
@@ -1,3 +1,6 @@
+#include <vcl/syschild.hxx>
+#include <vcl/sysdata.hxx>
+
 #include "vlcplayer.hxx"
 #include "vlcwindow.hxx"
 #include "vlcframegrabber.hxx"
@@ -22,7 +25,7 @@ const int MS_IN_SEC = 1000; // Millisec in sec
 
 namespace
 {
-    libvlc_media_t* initMedia( const rtl::OUString& url, boost::shared_ptr<libvlc_instance_t>& instance )
+    libvlc_media_t* InitMedia( const rtl::OUString& url, boost::shared_ptr<libvlc_instance_t>& instance )
     {
         rtl::OString dest;
         url.convertToString(&dest, RTL_TEXTENCODING_UTF8, 0);
@@ -34,7 +37,7 @@ VLCPlayer::VLCPlayer( const rtl::OUString& url )
     : VLC_Base(m_aMutex)
     , mInstance( libvlc_new( sizeof( VLC_ARGS ) / sizeof( VLC_ARGS[0] ), VLC_ARGS ), libvlc_release )
     , mPlayer( libvlc_media_player_new(mInstance.get()), libvlc_media_player_release )
-    , mMedia( initMedia( url, mInstance), libvlc_media_release )
+    , mMedia( InitMedia( url, mInstance), libvlc_media_release )
 {
     libvlc_media_player_set_media( mPlayer.get(), mMedia.get() );
 }
@@ -119,10 +122,47 @@ css::awt::Size SAL_CALL VLCPlayer::getPreferredPlayerWindowSize()
     return css::awt::Size( 1, 1 );
 }
 
+namespace
+{
+    // TODO: Move this function to the common space for avoiding duplication with
+    // gstreamer/gstwindow::createPlayerWindow functionality
+    int GetWindowID( const uno::Sequence< uno::Any >& arguments )
+    {
+        if (arguments.getLength() <= 2)
+            return -1;
+
+        sal_IntPtr pIntPtr = 0;
+
+        arguments[ 2 ] >>= pIntPtr;
+
+        SystemChildWindow *pParentWindow = reinterpret_cast< SystemChildWindow* >( pIntPtr );
+
+        const SystemEnvData* pEnvData = pParentWindow ? pParentWindow->GetSystemData() : NULL;
+
+        if (pEnvData == NULL)
+            return -1;
+
+        // Explicit converts from long to int
+        const int id = static_cast<int>( pEnvData->aWindow );
+
+        return id;
+    }
+}
+
 uno::Reference< css::media::XPlayerWindow > SAL_CALL VLCPlayer::createPlayerWindow( const uno::Sequence< uno::Any >& aArguments )
 {
     ::osl::MutexGuard aGuard(m_aMutex);
-    return uno::Reference< css::media::XPlayerWindow >(new VLCWindow( *this ));
+
+    VLCWindow * const window = new VLCWindow( *this );
+
+    const int winID = GetWindowID( aArguments );
+
+    if (winID != -1)
+    {
+        libvlc_media_player_set_xwindow( mPlayer.get(), winID );
+    }
+
+    return uno::Reference< css::media::XPlayerWindow >( window );
 }
 
 uno::Reference< css::media::XFrameGrabber > SAL_CALL VLCPlayer::createFrameGrabber()
diff --git a/avmedia/source/vlc/vlcwindow.hxx b/avmedia/source/vlc/vlcwindow.hxx
index 3449e2c..268be6f 100644
--- a/avmedia/source/vlc/vlcwindow.hxx
+++ b/avmedia/source/vlc/vlcwindow.hxx
@@ -31,6 +31,7 @@ class VLCWindow : public ::cppu::WeakImplHelper2 < ::com::sun::star::media::XPla
     VLCPlayer& mPlayer;
 public:
     SAL_CALL VLCWindow(VLCPlayer& player);
+
     void SAL_CALL update();
     ::sal_Bool SAL_CALL setZoomLevel( css::media::ZoomLevel ZoomLevel );
     css::media::ZoomLevel SAL_CALL getZoomLevel();


More information about the Libreoffice-commits mailing list