summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinh Ngo <nlminhtl@gmail.com>2013-07-11 08:29:29 +0300
committerMinh Ngo <nlminhtl@gmail.com>2013-07-11 08:29:29 +0300
commit8f83e797f65b1b4a38f3866c43d59bfecdd7746b (patch)
treee830fa469c2f6fb154897e1117894ac89dfe5973
parent8b02c98a757570900264fb65df01c3954c74d745 (diff)
Binding a video frame into a LibreOffice's widget
Change-Id: Iebf5b9f8cc83e7d2a96f105b07b6fe0eaf8b2678
-rw-r--r--avmedia/source/vlc/vlcplayer.cxx46
-rw-r--r--avmedia/source/vlc/vlcwindow.hxx1
2 files changed, 44 insertions, 3 deletions
diff --git a/avmedia/source/vlc/vlcplayer.cxx b/avmedia/source/vlc/vlcplayer.cxx
index 3c8453ba3086..0a15a72ccfdd 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 3449e2c0210a..268be6fb5901 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();