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
This commit is contained in:
parent
f3b3144133
commit
754380524d
4 changed files with 15 additions and 25 deletions
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue