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/source/vlc/vlcframegrabber.cxx | |
parent | 5b7bed15fc9860f40c2b0666227946120f082111 (diff) |
Removing bad code. Fixing VLC starting arguments.
Change-Id: I095638260d08d5d2fd67c93a42dbdbfe19581b75
Diffstat (limited to 'avmedia/source/vlc/vlcframegrabber.cxx')
-rw-r--r-- | avmedia/source/vlc/vlcframegrabber.cxx | 92 |
1 files changed, 4 insertions, 88 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() |