diff options
author | Herbert Dürr <hdu@apache.org> | 2014-05-12 16:07:09 +0000 |
---|---|---|
committer | Tor Lillqvist <tml@collabora.com> | 2014-05-15 18:49:14 +0300 |
commit | 754380524d6b9f3b5f49629ac8b3ad392cc5173c (patch) | |
tree | a0b4ea19d4b3773662c8c3f9edfca929549e98a7 /avmedia | |
parent | f3b314413336eb60e66886f48b56149bb586d830 (diff) |
AOO: #i124875# avoid wasteful loading of an AVAsset in MacAVF::Framegrabber
FrameGrabber used to load its own copy of a movie. Since multimedia content
is often very data-intensive this should and can be avoided by using the
movie asset already available in the Player.
Change-Id: I5ace1d1751b38839ef051ce0dc0328308325b269
Diffstat (limited to 'avmedia')
-rw-r--r-- | avmedia/source/macavf/framegrabber.hxx | 1 | ||||
-rw-r--r-- | avmedia/source/macavf/framegrabber.mm | 12 | ||||
-rw-r--r-- | avmedia/source/macavf/player.hxx | 4 | ||||
-rw-r--r-- | avmedia/source/macavf/player.mm | 23 |
4 files changed, 15 insertions, 25 deletions
diff --git a/avmedia/source/macavf/framegrabber.hxx b/avmedia/source/macavf/framegrabber.hxx index 14020cd82e4c..0ac32cc37dd4 100644 --- a/avmedia/source/macavf/framegrabber.hxx +++ b/avmedia/source/macavf/framegrabber.hxx @@ -39,6 +39,7 @@ public: virtual ~FrameGrabber(); bool create( const ::rtl::OUString& rURL ); + bool create( AVAsset* pMovie ); // XFrameGrabber virtual ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > SAL_CALL grabFrame( double fMediaTime ) throw (::com::sun::star::uno::RuntimeException); diff --git a/avmedia/source/macavf/framegrabber.mm b/avmedia/source/macavf/framegrabber.mm index 9f06ebdd8c19..6c2609dd2962 100644 --- a/avmedia/source/macavf/framegrabber.mm +++ b/avmedia/source/macavf/framegrabber.mm @@ -49,8 +49,6 @@ FrameGrabber::~FrameGrabber() bool FrameGrabber::create( const ::rtl::OUString& rURL ) { - // TODO: use AVPlayer's movie directly instead of loading it here? - NSString* pNSStr = [NSString stringWithCharacters:rURL.getStr() length:rURL.getLength()]; NSURL* pNSURL = [NSURL URLWithString: [pNSStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; AVAsset* pMovie = [AVURLAsset URLAssetWithURL:pNSURL options:nil]; @@ -59,9 +57,17 @@ bool FrameGrabber::create( const ::rtl::OUString& rURL ) OSL_TRACE( "AVGrabber::create() cannot load url=\"%s\"", [pNSStr UTF8String] ); return false; } + + return create( pMovie ); +} + +// ------------------------------------------------------------------------------ + +bool FrameGrabber::create( AVAsset* pMovie ) +{ if( [[pMovie tracksWithMediaType:AVMediaTypeVideo] count] == 0) { - OSL_TRACE( "AVGrabber::create() found no video in url=\"%s\"", [pNSStr UTF8String] ); + OSL_TRACE( "AVGrabber::create() found no video content!" ); return false; } diff --git a/avmedia/source/macavf/player.hxx b/avmedia/source/macavf/player.hxx index 2cdf8a1fd2b0..6bb4d3a22160 100644 --- a/avmedia/source/macavf/player.hxx +++ b/avmedia/source/macavf/player.hxx @@ -43,6 +43,7 @@ public: virtual ~Player(); bool create( const ::rtl::OUString& rURL ); + bool create( AVAsset* ); // XPlayer virtual void SAL_CALL start() throw (::com::sun::star::uno::RuntimeException); @@ -69,15 +70,12 @@ public: virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException); - AVAsset* getMovie(); AVPlayer* getAVPlayer() const { return mpPlayer; } virtual bool handleObservation( NSString* pKeyPath ); private: ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMgr; - ::rtl::OUString maURL; - AVPlayer* mpPlayer; float mfUnmutedVolume; diff --git a/avmedia/source/macavf/player.mm b/avmedia/source/macavf/player.mm index 38478da14be2..404083bde48a 100644 --- a/avmedia/source/macavf/player.mm +++ b/avmedia/source/macavf/player.mm @@ -110,17 +110,6 @@ Player::~Player() // ------------------------------------------------------------------------------ -AVAsset* Player::getMovie() -{ - if( !mpPlayer ) - return nil; - AVAsset* pMovie = [[mpPlayer currentItem] asset]; - OSL_ASSERT( pMovie ); - return pMovie; -} - -// ------------------------------------------------------------------------------ - bool Player::handleObservation( NSString* pKeyPath ) { OSL_TRACE( "AVPlayer::handleObservation key=\"%s\"", [pKeyPath UTF8String]); @@ -137,8 +126,6 @@ bool Player::handleObservation( NSString* pKeyPath ) bool Player::create( const ::rtl::OUString& rURL ) { - maURL = rURL; - // get the media asset NSString* aNSStr = [NSString stringWithCharacters:rURL.getStr() length:rURL.getLength()]; NSURL* aNSURL = [NSURL URLWithString: [aNSStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; @@ -431,12 +418,10 @@ uno::Reference< media::XFrameGrabber > SAL_CALL Player::createFrameGrabber() uno::Reference< media::XFrameGrabber > xRet; OSL_TRACE ("Player::createFrameGrabber"); - if( !maURL.isEmpty() ) - { - FrameGrabber* pGrabber = new FrameGrabber( mxMgr ); - if( pGrabber->create( maURL ) ) - xRet = pGrabber; - } + FrameGrabber* pGrabber = new FrameGrabber( mxMgr ); + AVAsset* pMovie = [[mpPlayer currentItem] asset]; + if( pGrabber->create( pMovie ) ) + xRet = pGrabber; return xRet; } |