[Libreoffice-commits] core.git: Branch 'aoo/trunk' - avmedia/source

Herbert Dürr hdu at apache.org
Mon May 12 11:07:41 PDT 2014


 avmedia/source/macavf/macavf_framegrabber.cxx |   12 +++++++++---
 avmedia/source/macavf/macavf_framegrabber.hxx |    1 +
 avmedia/source/macavf/macavf_player.cxx       |   23 ++++-------------------
 avmedia/source/macavf/macavf_player.hxx       |    4 +---
 4 files changed, 15 insertions(+), 25 deletions(-)

New commits:
commit 976e787f6b33389ea9dcd35ff7680dedeace47ac
Author: Herbert Dürr <hdu at apache.org>
Date:   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.

diff --git a/avmedia/source/macavf/macavf_framegrabber.cxx b/avmedia/source/macavf/macavf_framegrabber.cxx
index 1748199..55611af 100644
--- a/avmedia/source/macavf/macavf_framegrabber.cxx
+++ b/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/avmedia/source/macavf/macavf_framegrabber.hxx b/avmedia/source/macavf/macavf_framegrabber.hxx
index 21d1dad..940e54d 100644
--- a/avmedia/source/macavf/macavf_framegrabber.hxx
+++ b/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/avmedia/source/macavf/macavf_player.cxx b/avmedia/source/macavf/macavf_player.cxx
index 2e15907..26bc07a 100644
--- a/avmedia/source/macavf/macavf_player.cxx
+++ b/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/avmedia/source/macavf/macavf_player.hxx b/avmedia/source/macavf/macavf_player.hxx
index 98c5454..fc99551 100644
--- a/avmedia/source/macavf/macavf_player.hxx
+++ b/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;


More information about the Libreoffice-commits mailing list