This is an automated email from the ASF dual-hosted git repository. arielch pushed a commit to branch AOO418 in repository https://gitbox.apache.org/repos/asf/openoffice.git
commit 6a7d45efb49169f8345719aa163722d8b8f2c22f Author: Herbert Dürr <h...@apache.org> AuthorDate: Mon May 12 16:07:09 2014 +0000 #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. git-svn-id: https://svn.apache.org/repos/asf/openoffice/trunk@1594017 13f79535-47bb-0310-9956-ffa450edef68 (cherry picked from commit 32322404843edfd777f7b843f7e0e2e38f46fabf) --- main/avmedia/source/macavf/macavf_framegrabber.cxx | 12 ++++++++--- main/avmedia/source/macavf/macavf_framegrabber.hxx | 1 + main/avmedia/source/macavf/macavf_player.cxx | 23 ++++------------------ main/avmedia/source/macavf/macavf_player.hxx | 4 +--- 4 files changed, 15 insertions(+), 25 deletions(-) diff --git a/main/avmedia/source/macavf/macavf_framegrabber.cxx b/main/avmedia/source/macavf/macavf_framegrabber.cxx index f9fb5a6..df5d9f9 100644 --- a/main/avmedia/source/macavf/macavf_framegrabber.cxx +++ b/main/avmedia/source/macavf/macavf_framegrabber.cxx @@ -51,8 +51,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]; @@ -61,9 +59,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/main/avmedia/source/macavf/macavf_framegrabber.hxx b/main/avmedia/source/macavf/macavf_framegrabber.hxx index c483eda..24c42c6 100644 --- a/main/avmedia/source/macavf/macavf_framegrabber.hxx +++ b/main/avmedia/source/macavf/macavf_framegrabber.hxx @@ -42,6 +42,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/main/avmedia/source/macavf/macavf_player.cxx b/main/avmedia/source/macavf/macavf_player.cxx index 27fd644..34c76d4 100644 --- a/main/avmedia/source/macavf/macavf_player.cxx +++ b/main/avmedia/source/macavf/macavf_player.cxx @@ -112,17 +112,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]); @@ -139,8 +128,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]]; @@ -433,12 +420,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; } diff --git a/main/avmedia/source/macavf/macavf_player.hxx b/main/avmedia/source/macavf/macavf_player.hxx index 45f6f86..05c5220 100644 --- a/main/avmedia/source/macavf/macavf_player.hxx +++ b/main/avmedia/source/macavf/macavf_player.hxx @@ -46,6 +46,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); @@ -72,15 +73,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;