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=a0a696a32bd1b160d030d21dff1c87f0b683e3d9;hb=dea624eb348a4926d8761c8a1364f03f9f71acf5;hpb=078278a2ea58db1f07114513bf21783eb689f63a diff --git a/dali-toolkit/internal/controls/video-view/video-view-impl.cpp b/dali-toolkit/internal/controls/video-view/video-view-impl.cpp index a0a696a..463a214 100644 --- a/dali-toolkit/internal/controls/video-view/video-view-impl.cpp +++ b/dali-toolkit/internal/controls/video-view/video-view-impl.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -130,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; } @@ -550,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 ) { @@ -560,9 +562,19 @@ void VideoView::OnStageConnection( int depth ) } } -void VideoView::OnStageDisconnection() +void VideoView::OnSceneDisconnection() +{ + Control::OnSceneDisconnection(); +} + +void VideoView::OnSizeSet( const Vector3& targetSize ) { - Control::OnStageDisconnection(); + if( mIsUnderlay && mSyncMode == Dali::VideoSyncMode::ENABLED ) + { + SetFrameRenderCallback(); + mVideoPlayer.StartSynchronization(); + } + Control::OnSizeSet( targetSize ); } Vector3 VideoView::GetNaturalSize() @@ -728,7 +740,9 @@ 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; } @@ -812,6 +826,22 @@ 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"; @@ -881,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