diff options
author | Minh Ngo <nlminhtl@gmail.com> | 2013-09-14 19:25:43 +0300 |
---|---|---|
committer | Minh Ngo <nlminhtl@gmail.com> | 2013-09-14 19:26:31 +0300 |
commit | 793eaa8b2610f7972c1c6717ba2ae430013080cf (patch) | |
tree | b1fd28ddb89313be736927519f498495fd188219 /avmedia | |
parent | 5480482b74b91b5fb68bb364debd10c6e83b4e23 (diff) |
Mute sound when grabbing a frame.
Change-Id: I8190d6c9a93183d48076c95a7cd0b978a2954afb
Diffstat (limited to 'avmedia')
-rw-r--r-- | avmedia/source/vlc/vlcframegrabber.cxx | 27 | ||||
-rw-r--r-- | avmedia/source/vlc/vlcframegrabber.hxx | 9 | ||||
-rw-r--r-- | avmedia/source/vlc/vlcmanager.cxx | 2 | ||||
-rw-r--r-- | avmedia/source/vlc/vlcplayer.cxx | 9 | ||||
-rw-r--r-- | avmedia/source/vlc/vlcplayer.hxx | 1 |
5 files changed, 27 insertions, 21 deletions
diff --git a/avmedia/source/vlc/vlcframegrabber.cxx b/avmedia/source/vlc/vlcframegrabber.cxx index b7ef4a99cb0a..ea05f76e2fe5 100644 --- a/avmedia/source/vlc/vlcframegrabber.cxx +++ b/avmedia/source/vlc/vlcframegrabber.cxx @@ -25,15 +25,23 @@ namespace const ::rtl::OUString AVMEDIA_VLC_GRABBER_IMPLEMENTATIONNAME = "com.sun.star.comp.avmedia.VLCFrameGrabber_VLC"; const ::rtl::OUString AVMEDIA_VLC_GRABBER_SERVICENAME = "com.sun.star.media.VLCFrameGrabber_VLC"; const int MSEC_IN_SEC = 1000; + + const char * const VLC_ARGS[] = { + "-Vdummy", + "--snapshot-format=png", + "--ffmpeg-threads", + "--verbose=-1", + "--no-audio" + }; } -VLCFrameGrabber::VLCFrameGrabber( VLC::Player& player, VLC::EventHandler& eh, const rtl::OUString& url ) +VLCFrameGrabber::VLCFrameGrabber( VLC::EventHandler& eh, const rtl::OUString& url ) : FrameGrabber_BASE() - , mPlayer( player ) - , mUrl( url ) + , mInstance( sizeof( VLC_ARGS ) / sizeof( VLC_ARGS[0] ), VLC_ARGS ) + , mMedia( url, mInstance ) + , mPlayer( mMedia ) , mEventHandler( eh ) { - std::cout << "URL: " << url << std::endl; } ::uno::Reference< css::graphic::XGraphic > SAL_CALL VLCFrameGrabber::grabFrame( double fMediaTime ) @@ -46,8 +54,6 @@ VLCFrameGrabber::VLCFrameGrabber( VLC::Player& player, VLC::EventHandler& eh, co VLC::EventManager manager( mPlayer, mEventHandler ); manager.onPaused(boost::bind(&osl::Condition::set, &condition)); - mPlayer.setMute( true ); - if ( !mPlayer.play() ) { std::cerr << "Couldn't play when trying to grab frame" << std::endl; @@ -60,19 +66,14 @@ VLCFrameGrabber::VLCFrameGrabber( VLC::Player& player, VLC::EventHandler& eh, co const TimeValue timeout = {2, 0}; condition.wait(&timeout); - if ( mUrl.isEmpty() || !mPlayer.hasVout() ) + if ( !mPlayer.hasVout() ) { std::cerr << "Couldn't grab frame" << std::endl; - mPlayer.setMute( false ); - manager.onPaused(); return ::uno::Reference< css::graphic::XGraphic >(); } - std::cout << "Take snapshot " << fileName << std::endl; - std::cout << mPlayer.takeSnapshot( fileName ) << std::endl; - - mPlayer.setMute( false ); + mPlayer.takeSnapshot( fileName ); mPlayer.stop(); manager.onPaused(); diff --git a/avmedia/source/vlc/vlcframegrabber.hxx b/avmedia/source/vlc/vlcframegrabber.hxx index 616ab2f5952e..c6a1a11d193e 100644 --- a/avmedia/source/vlc/vlcframegrabber.hxx +++ b/avmedia/source/vlc/vlcframegrabber.hxx @@ -24,10 +24,10 @@ #include <com/sun/star/media/XFrameGrabber.hpp> #include <cppuhelper/implbase2.hxx> #include "vlccommon.hxx" +#include "wrapper/Wrapper.hxx" namespace VLC { - class Player; class EventHandler; } @@ -39,11 +39,12 @@ typedef ::cppu::WeakImplHelper2< ::com::sun::star::media::XFrameGrabber, class VLCFrameGrabber : public FrameGrabber_BASE { - VLC::Player& mPlayer; - const rtl::OUString& mUrl; + VLC::Instance mInstance; + VLC::Media mMedia; + VLC::Player mPlayer; VLC::EventHandler& mEventHandler; public: - VLCFrameGrabber( VLC::Player& player, VLC::EventHandler& eh, const rtl::OUString& url ); + VLCFrameGrabber( VLC::EventHandler& eh, const rtl::OUString& url ); ::com::sun::star::uno::Reference< css::graphic::XGraphic > SAL_CALL grabFrame( double fMediaTime ) throw ( ::com::sun::star::uno::RuntimeException ); diff --git a/avmedia/source/vlc/vlcmanager.cxx b/avmedia/source/vlc/vlcmanager.cxx index 1c7c64552d77..c09609359f32 100644 --- a/avmedia/source/vlc/vlcmanager.cxx +++ b/avmedia/source/vlc/vlcmanager.cxx @@ -29,8 +29,6 @@ namespace const char * const VLC_ARGS[] = { "-Vdummy", - "--snapshot-format=png", - "--ffmpeg-threads", "--verbose=-1" }; } diff --git a/avmedia/source/vlc/vlcplayer.cxx b/avmedia/source/vlc/vlcplayer.cxx index 37be3485d078..0974d1245059 100644 --- a/avmedia/source/vlc/vlcplayer.cxx +++ b/avmedia/source/vlc/vlcplayer.cxx @@ -189,8 +189,13 @@ uno::Reference< css::media::XFrameGrabber > SAL_CALL VLCPlayer::createFrameGrabb throw ( ::com::sun::star::uno::RuntimeException ) { ::osl::MutexGuard aGuard(m_aMutex); - VLCFrameGrabber *frameGrabber = new VLCFrameGrabber( mPlayer, mEventHandler, mUrl ); - return uno::Reference< css::media::XFrameGrabber >( frameGrabber ); + if ( !mrFrameGrabber.is() ) + { + VLCFrameGrabber *frameGrabber = new VLCFrameGrabber( mEventHandler, mUrl ); + mrFrameGrabber = uno::Reference< css::media::XFrameGrabber >( frameGrabber ); + } + + return mrFrameGrabber; } ::rtl::OUString SAL_CALL VLCPlayer::getImplementationName() diff --git a/avmedia/source/vlc/vlcplayer.hxx b/avmedia/source/vlc/vlcplayer.hxx index e2aa17bda89d..3da58c6e8b98 100644 --- a/avmedia/source/vlc/vlcplayer.hxx +++ b/avmedia/source/vlc/vlcplayer.hxx @@ -50,6 +50,7 @@ class VLCPlayer : public ::cppu::BaseMutex, VLC::EventManager mEventManager; const rtl::OUString mUrl; bool mPlaybackLoop; + ::com::sun::star::uno::Reference< css::media::XFrameGrabber > mrFrameGrabber; public: VLCPlayer( const rtl::OUString& url, VLC::Instance& instance, |