diff options
author | Minh Ngo <nlminhtl@gmail.com> | 2013-07-29 08:11:31 +0300 |
---|---|---|
committer | Michael Meeks <michael.meeks@suse.com> | 2013-08-21 10:54:49 +0100 |
commit | 872b10fe417a4ff06a14cff0de0ebea9fd12ac4a (patch) | |
tree | 8c041f030d62b807fd5bb1e56d8a573637f38101 /avmedia | |
parent | 5b7bed15fc9860f40c2b0666227946120f082111 (diff) |
Removing bad code. Fixing VLC starting arguments.
Change-Id: I095638260d08d5d2fd67c93a42dbdbfe19581b75
Diffstat (limited to 'avmedia')
-rw-r--r-- | avmedia/source/vlc/vlcframegrabber.cxx | 92 | ||||
-rw-r--r-- | avmedia/source/vlc/vlcplayer.cxx | 8 | ||||
-rw-r--r-- | avmedia/source/vlc/vlcplayer.hxx | 1 |
3 files changed, 8 insertions, 93 deletions
diff --git a/avmedia/source/vlc/vlcframegrabber.cxx b/avmedia/source/vlc/vlcframegrabber.cxx index ec5b959da671..a18919095b99 100644 --- a/avmedia/source/vlc/vlcframegrabber.cxx +++ b/avmedia/source/vlc/vlcframegrabber.cxx @@ -5,6 +5,7 @@ #include "vlcframegrabber.hxx" #include "vlcplayer.hxx" #include <vlc/libvlc_media_player.h> +#include <boost/bind.hpp> using namespace ::com::sun::star; @@ -22,100 +23,15 @@ SAL_CALL VLCFrameGrabber::VLCFrameGrabber( boost::shared_ptr<libvlc_media_player { } -namespace -{ - struct FrameData - { - ::osl::Condition mCondition; - - std::vector<sal_uInt8> buffer; - - libvlc_media_player_t *mpPlayer; - - FrameData( libvlc_media_player_t *pPlayer ) - : mpPlayer( pPlayer ) - { - } - - void updateSize() - { - unsigned int w, h; - libvlc_video_get_size( mpPlayer, 0, &w, &h ); - - buffer.resize(w * h * 3); - } - - ~FrameData() - { - } - }; - - void *FrameLock( void *data, void **pPixels ) - { - FrameData *frameData = static_cast<FrameData*>( data ); - - frameData->updateSize(); - - *pPixels = frameData->buffer.data(); - - return *pPixels; - } - - void FrameUnlock( void *data, void */* id */, void *const * /* pPixels */ ) - { - FrameData *frameData = static_cast<FrameData*>( data ); - - frameData->mCondition.set(); - } - - void FrameDisplay( void */* data */, void */* id */ ) - { - } -} - ::uno::Reference< css::graphic::XGraphic > SAL_CALL VLCFrameGrabber::grabFrame( double fMediaTime ) { if ( mUrl.isEmpty() ) return ::uno::Reference< css::graphic::XGraphic >(); - libvlc_media_player_t *pPlayer = mPlayer.get(); - FrameData frameData( pPlayer ); - libvlc_video_set_callbacks( pPlayer, FrameLock, FrameUnlock, FrameDisplay, &frameData ); - - const unsigned int w = 480, h = 360; - - libvlc_video_set_format( pPlayer, "RV24", w, h, w * 3 ); - - libvlc_media_player_set_time( pPlayer, fMediaTime * MSEC_IN_SEC ); - libvlc_media_player_play( pPlayer ); - - const TimeValue t = {2, 0}; - frameData.mCondition.wait( &t ); - - if ( !frameData.mCondition.check() ) - return ::uno::Reference< css::graphic::XGraphic >(); - - Bitmap aBmp( Size( w, h ), 24 ); - - sal_uInt8 *pData = frameData.buffer.data(); - BitmapWriteAccess *pWrite = aBmp.AcquireWriteAccess(); - if ( pWrite ) - { - for ( std::size_t y = 0; y < h; ++y ) - { - for ( std::size_t x = 0; x < w; ++x ) - { - sal_uInt8 *p = pData + ( y * w + x ) * 3; - BitmapColor col( p[0], p[1], p[2] ); - pWrite->SetPixel( y, x, col ); - } - } - } - aBmp.ReleaseAccess( pWrite ); - - libvlc_media_player_stop( pPlayer ); + // libvlc_video_take_snapshot must be used, but it doesn't work for PNG files + // - return Graphic( aBmp ).GetXGraphic(); + return ::uno::Reference< css::graphic::XGraphic >(); } ::rtl::OUString SAL_CALL VLCFrameGrabber::getImplementationName() diff --git a/avmedia/source/vlc/vlcplayer.cxx b/avmedia/source/vlc/vlcplayer.cxx index 92e0614b5311..34ebb00608ca 100644 --- a/avmedia/source/vlc/vlcplayer.cxx +++ b/avmedia/source/vlc/vlcplayer.cxx @@ -15,7 +15,7 @@ const ::rtl::OUString AVMEDIA_VLC_PLAYER_SERVICENAME = "com.sun.star.media.Playe const char * const VLC_ARGS[] = { "-I", - "dummy", + "-Vdummy", "--ignore-config", "--verbose=-1", "--quiet" @@ -37,11 +37,10 @@ namespace 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 ) + , mPlayer( libvlc_media_player_new_from_media( mMedia.get() ), libvlc_media_player_release ) , mUrl( url ) { - boost::shared_ptr<libvlc_media_t> media( InitMedia( url, mInstance ), libvlc_media_release ); - mPlayer.reset( libvlc_media_player_new_from_media( media.get() ), libvlc_media_player_release ); } void SAL_CALL VLCPlayer::start() @@ -180,7 +179,6 @@ uno::Reference< css::media::XPlayerWindow > SAL_CALL VLCPlayer::createPlayerWind uno::Reference< css::media::XFrameGrabber > SAL_CALL VLCPlayer::createFrameGrabber() { ::osl::MutexGuard aGuard(m_aMutex); - VLCFrameGrabber *frameGrabber = new VLCFrameGrabber( mPlayer, mUrl ); return uno::Reference< css::media::XFrameGrabber >( frameGrabber ); } diff --git a/avmedia/source/vlc/vlcplayer.hxx b/avmedia/source/vlc/vlcplayer.hxx index 0c29f3fc9770..00a55ebfecbb 100644 --- a/avmedia/source/vlc/vlcplayer.hxx +++ b/avmedia/source/vlc/vlcplayer.hxx @@ -38,6 +38,7 @@ class VLCPlayer : public ::cppu::BaseMutex, public VLC_Base { boost::shared_ptr<libvlc_instance_t> mInstance; + boost::shared_ptr<libvlc_media_t> mMedia; boost::shared_ptr<libvlc_media_player_t> mPlayer; const rtl::OUString mUrl; public: |