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=523fcf0868638996c333934bf3f97237086c22cf;hp=a0a696a32bd1b160d030d21dff1c87f0b683e3d9;hb=54342c70a267a34b3345b24c404f1064fed99338;hpb=946461ac1b49e996d9155c95130ec5aa1b08f77d 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..523fcf0 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 @@ -87,7 +88,7 @@ const char* const CUSTOM_SAMPLER_TYPE_NAME( "samplerExternalOES" ); const char* VERTEX_SHADER = DALI_COMPOSE_SHADER( attribute mediump vec2 aPosition;\n uniform highp mat4 uMvpMatrix;\n - uniform mediump vec3 uSize;\n + uniform highp vec3 uSize;\n \n void main()\n {\n @@ -109,7 +110,7 @@ const char* VERTEX_SHADER_TEXTURE = DALI_COMPOSE_SHADER( attribute mediump vec2 aPosition;\n varying mediump vec2 vTexCoord;\n uniform highp mat4 uMvpMatrix;\n - uniform mediump vec3 uSize;\n + uniform highp vec3 uSize;\n varying mediump vec2 sTexCoordRect;\n void main()\n {\n @@ -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