diff options
author | Minh Ngo <nlminhtl@gmail.com> | 2013-07-11 08:29:29 +0300 |
---|---|---|
committer | Michael Meeks <michael.meeks@suse.com> | 2013-07-26 10:50:22 +0100 |
commit | fa978db06c10a2fc83ada50118b861b29c5be4f9 (patch) | |
tree | a8a1351a7958e67b4595eae5ec35280920f91255 /avmedia | |
parent | Fixing get/set time methods (correctly converts ms into sec). (diff) | |
download | core-fa978db06c10a2fc83ada50118b861b29c5be4f9.tar.gz core-fa978db06c10a2fc83ada50118b861b29c5be4f9.zip |
Binding a video frame into a LibreOffice's widget
Change-Id: Iebf5b9f8cc83e7d2a96f105b07b6fe0eaf8b2678
Diffstat (limited to 'avmedia')
-rw-r--r-- | avmedia/source/vlc/vlcplayer.cxx | 46 | ||||
-rw-r--r-- | avmedia/source/vlc/vlcwindow.hxx | 1 |
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(); |