X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fvideo-view%2Fvideo-view-impl.cpp;h=463a2149a9339dfe6b04938edcb36379f495d428;hp=7fcab034f1d926605e2a011515c95484ba2d0782;hb=b1e8521ad77e7b4e62b59613b2edef64429130e9;hpb=8db599ebe35a704d4adfd70040c33ce8e31e8d64 diff --git a/dali-toolkit/internal/controls/video-view/video-view-impl.cpp b/dali-toolkit/internal/controls/video-view/video-view-impl.cpp old mode 100755 new mode 100644 index 7fcab03..463a214 --- a/dali-toolkit/internal/controls/video-view/video-view-impl.cpp +++ b/dali-toolkit/internal/controls/video-view/video-view-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,8 +22,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -131,26 +131,27 @@ const char* FRAGMENT_SHADER_TEXTURE = DALI_COMPOSE_SHADER( } // anonymous namepsace -VideoView::VideoView() +VideoView::VideoView( Dali::VideoSyncMode syncMode ) : Control( ControlBehaviour( ACTOR_BEHAVIOUR_DEFAULT | DISABLE_STYLE_CHANGE_SIGNALS ) ), mCurrentVideoPlayPosition( 0 ), + mFrameID( 0 ), mIsPlay( false ), - mIsUnderlay( true ) + mIsUnderlay( true ), + mSyncMode( syncMode ) { - mVideoPlayer = Dali::VideoPlayer::New(); } VideoView::~VideoView() { } -Toolkit::VideoView VideoView::New() +Toolkit::VideoView VideoView::New( VideoSyncMode syncMode ) { - VideoView* impl = new VideoView(); + VideoView* impl = new VideoView( syncMode ); Toolkit::VideoView handle = Toolkit::VideoView( *impl ); + impl->mVideoPlayer = Dali::VideoPlayer::New( impl->Self(), syncMode ); impl->Initialize(); - return handle; } @@ -551,9 +552,9 @@ void VideoView::SetDepthIndex( int depthIndex ) } } -void VideoView::OnStageConnection( int depth ) +void VideoView::OnSceneConnection( int depth ) { - Control::OnStageConnection( depth ); + Control::OnSceneConnection( depth ); if( mIsUnderlay ) { @@ -561,9 +562,19 @@ void VideoView::OnStageConnection( int depth ) } } -void VideoView::OnStageDisconnection() +void VideoView::OnSceneDisconnection() { - Control::OnStageDisconnection(); + Control::OnSceneDisconnection(); +} + +void VideoView::OnSizeSet( const Vector3& targetSize ) +{ + if( mIsUnderlay && mSyncMode == Dali::VideoSyncMode::ENABLED ) + { + SetFrameRenderCallback(); + mVideoPlayer.StartSynchronization(); + } + Control::OnSizeSet( targetSize ); } Vector3 VideoView::GetNaturalSize() @@ -611,7 +622,7 @@ void VideoView::SetWindowSurfaceTarget() { Actor self = Self(); - if( !self.OnStage() ) + if( !self.GetProperty< bool >( Actor::Property::CONNECTED_TO_SCENE ) ) { // When the control is off the stage, it does not have Window. return; @@ -729,18 +740,20 @@ void VideoView::SetNativeImageTarget() void VideoView::UpdateDisplayArea( Dali::PropertyNotification& source ) { - if( !mIsUnderlay ) + // If mSyncMode is enabled, Video player's size and poistion is updated in Video player's constraint. + // Because video view and player should be work syncronization. + if( !mIsUnderlay || mSyncMode == Dali::VideoSyncMode::ENABLED ) { return; } Actor self( Self() ); - bool positionUsesAnchorPoint = self.GetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT ).Get< bool >(); - Vector3 actorSize = self.GetCurrentSize() * self.GetCurrentScale(); - Vector3 anchorPointOffSet = actorSize * ( positionUsesAnchorPoint ? self.GetCurrentAnchorPoint() : AnchorPoint::TOP_LEFT ); + bool positionUsesAnchorPoint = self.GetProperty( Actor::Property::POSITION_USES_ANCHOR_POINT ).Get< bool >(); + Vector3 actorSize = self.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ) * self.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ); + Vector3 anchorPointOffSet = actorSize * ( positionUsesAnchorPoint ? self.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ) : AnchorPoint::TOP_LEFT ); - Vector2 screenPosition = self.GetProperty( DevelActor::Property::SCREEN_POSITION ).Get< Vector2 >(); + Vector2 screenPosition = self.GetProperty( Actor::Property::SCREEN_POSITION ).Get< Vector2 >(); mDisplayArea.x = screenPosition.x - anchorPointOffSet.x; mDisplayArea.y = screenPosition.y - anchorPointOffSet.y; @@ -808,6 +821,27 @@ int VideoView::GetDisplayMode() const return static_cast< int >( mVideoPlayer.GetDisplayMode() ); } +Any VideoView::GetMediaPlayer() +{ + return mVideoPlayer.GetMediaPlayer(); +} + +void VideoView::OnAnimationFinished( Animation& animation ) +{ + // send desync + SetFrameRenderCallback(); +} + +void VideoView::PlayAnimation( Dali::Animation animation ) +{ + if( mIsUnderlay && mSyncMode == Dali::VideoSyncMode::ENABLED ) + { + mVideoPlayer.StartSynchronization(); + animation.FinishedSignal().Connect( this, &VideoView::OnAnimationFinished ); + } + animation.Play(); +} + Dali::Shader VideoView::CreateShader() { std::string fragmentShader = "#extension GL_OES_EGL_image_external:require\n"; @@ -877,6 +911,23 @@ void VideoView::ApplyBackupProperties() } } +void VideoView::FrameRenderCallback( int frameID ) +{ + // send desync + if( frameID == mFrameID ) + { + mVideoPlayer.FinishSynchronization(); + mFrameID = 0; + } +} + +void VideoView::SetFrameRenderCallback() +{ + mFrameID++; + DevelWindow::AddFrameRenderedCallback( DevelWindow::Get( Self() ), + std::unique_ptr< CallbackBase >( MakeCallback( this, &VideoView::FrameRenderCallback ) ), mFrameID ); +} + } // namespace Internal } // namespace toolkit