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

Minh Ngo nlminhtl at gmail.com
Sun Jul 28 22:12:23 PDT 2013


 avmedia/source/vlc/vlcframegrabber.cxx |   92 +--------------------------------
 avmedia/source/vlc/vlcplayer.cxx       |    8 +-
 avmedia/source/vlc/vlcplayer.hxx       |    1 
 3 files changed, 8 insertions(+), 93 deletions(-)

New commits:
commit 0cb786310fa20a7eaf25dde9f73da81440eacf2a
Author: Minh Ngo <nlminhtl at gmail.com>
Date:   Mon Jul 29 08:11:31 2013 +0300

    Removing bad code. Fixing VLC starting arguments.
    
    Change-Id: I095638260d08d5d2fd67c93a42dbdbfe19581b75

diff --git a/avmedia/source/vlc/vlcframegrabber.cxx b/avmedia/source/vlc/vlcframegrabber.cxx
index ec5b959..a189190 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 92e0614..34ebb00 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 0c29f3f..00a55eb 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:


More information about the Libreoffice-commits mailing list