Author: hdu
Date: Mon May 12 16:07:09 2014
New Revision: 1594017

URL: http://svn.apache.org/r1594017
Log:
#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.

Modified:
    openoffice/trunk/main/avmedia/source/macavf/macavf_framegrabber.cxx
    openoffice/trunk/main/avmedia/source/macavf/macavf_framegrabber.hxx
    openoffice/trunk/main/avmedia/source/macavf/macavf_player.cxx
    openoffice/trunk/main/avmedia/source/macavf/macavf_player.hxx

Modified: openoffice/trunk/main/avmedia/source/macavf/macavf_framegrabber.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/avmedia/source/macavf/macavf_framegrabber.cxx?rev=1594017&r1=1594016&r2=1594017&view=diff
==============================================================================
--- openoffice/trunk/main/avmedia/source/macavf/macavf_framegrabber.cxx 
(original)
+++ openoffice/trunk/main/avmedia/source/macavf/macavf_framegrabber.cxx Mon May 
12 16:07:09 2014
@@ -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::
         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;
     }
 

Modified: openoffice/trunk/main/avmedia/source/macavf/macavf_framegrabber.hxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/avmedia/source/macavf/macavf_framegrabber.hxx?rev=1594017&r1=1594016&r2=1594017&view=diff
==============================================================================
--- openoffice/trunk/main/avmedia/source/macavf/macavf_framegrabber.hxx 
(original)
+++ openoffice/trunk/main/avmedia/source/macavf/macavf_framegrabber.hxx Mon May 
12 16:07:09 2014
@@ -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);

Modified: openoffice/trunk/main/avmedia/source/macavf/macavf_player.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/avmedia/source/macavf/macavf_player.cxx?rev=1594017&r1=1594016&r2=1594017&view=diff
==============================================================================
--- openoffice/trunk/main/avmedia/source/macavf/macavf_player.cxx (original)
+++ openoffice/trunk/main/avmedia/source/macavf/macavf_player.cxx Mon May 12 
16:07:09 2014
@@ -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
 
 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 > S
     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;
 }

Modified: openoffice/trunk/main/avmedia/source/macavf/macavf_player.hxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/avmedia/source/macavf/macavf_player.hxx?rev=1594017&r1=1594016&r2=1594017&view=diff
==============================================================================
--- openoffice/trunk/main/avmedia/source/macavf/macavf_player.hxx (original)
+++ openoffice/trunk/main/avmedia/source/macavf/macavf_player.hxx Mon May 12 
16:07:09 2014
@@ -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;


Reply via email to