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=8c34ab5dc464e5f67144918245843d41b038a676;hp=93ce5a31ed66eb8ba6f0d622a84803869628b5d3;hb=dc3bbd29a417e1fbc7f81104c60c5ba90212f216;hpb=736d0519550d784c776d594936af1c60f2670a14 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 93ce5a3..8c34ab5 100755 --- 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) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 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. @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -33,6 +32,7 @@ // INTERNAL INCLUDES #include #include +#include namespace Dali { @@ -157,7 +157,6 @@ Toolkit::VideoView VideoView::New() void VideoView::OnInitialize() { mVideoPlayer.FinishedSignal().Connect( this, &VideoView::EmitSignalFinish ); - SetWindowSurfaceTarget(); } void VideoView::SetUrl( const std::string& url ) @@ -228,7 +227,7 @@ bool VideoView::IsLooping() void VideoView::Play() { - if( mIsUnderlay ) + if( mOverlayRenderer ) { Self().AddRenderer( mOverlayRenderer ); } @@ -295,7 +294,7 @@ Dali::Toolkit::VideoView::VideoViewSignalType& VideoView::FinishedSignal() void VideoView::EmitSignalFinish() { - if( mIsUnderlay ) + if( mOverlayRenderer ) { Self().RemoveRenderer( mOverlayRenderer ); } @@ -378,91 +377,103 @@ bool VideoView::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* return connected; } -void VideoView::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value ) +void VideoView::SetPropertyInternal( Property::Index index, const Property::Value& value ) { - Toolkit::VideoView videoView = Toolkit::VideoView::DownCast( Dali::BaseHandle( object ) ); - - if( videoView ) + switch( index ) { - VideoView& impl = GetImpl( videoView ); - - switch( index ) + case Toolkit::VideoView::Property::VIDEO: { - case Toolkit::VideoView::Property::VIDEO: - { - std::string videoUrl; - Property::Map map; + std::string videoUrl; + Property::Map map; - if( value.Get( videoUrl ) ) - { - impl.SetUrl( videoUrl ); - } - else if( value.Get( map ) ) - { - impl.SetPropertyMap( map ); - } - break; + if( value.Get( videoUrl ) ) + { + SetUrl( videoUrl ); } - case Toolkit::VideoView::Property::LOOPING: + else if( value.Get( map ) ) { - bool looping; - if( value.Get( looping ) ) - { - impl.SetLooping( looping ); - } - break; + SetPropertyMap( map ); } - case Toolkit::VideoView::Property::MUTED: + break; + } + case Toolkit::VideoView::Property::LOOPING: + { + bool looping; + if( value.Get( looping ) ) { - bool mute; - if( value.Get( mute ) ) - { - impl.SetMute( mute ); - } - break; + SetLooping( looping ); } - case Toolkit::VideoView::Property::VOLUME: + break; + } + case Toolkit::VideoView::Property::MUTED: + { + bool mute; + if( value.Get( mute ) ) { - Property::Map map; - float left, right; - if( value.Get( map ) ) - { - Property::Value* volumeLeft = map.Find( VOLUME_LEFT ); - Property::Value* volumeRight = map.Find( VOLUME_RIGHT ); - if( volumeLeft && volumeLeft->Get( left ) && volumeRight && volumeRight->Get( right ) ) - { - impl.SetVolume( left, right ); - } - } - break; + SetMute( mute ); } - case Toolkit::VideoView::Property::UNDERLAY: + break; + } + case Toolkit::VideoView::Property::VOLUME: + { + Property::Map map; + float left, right; + if( value.Get( map ) ) { - bool underlay; - if( value.Get( underlay ) ) + Property::Value* volumeLeft = map.Find( VOLUME_LEFT ); + Property::Value* volumeRight = map.Find( VOLUME_RIGHT ); + if( volumeLeft && volumeLeft->Get( left ) && volumeRight && volumeRight->Get( right ) ) { - impl.SetUnderlay( underlay ); + SetVolume( left, right ); } - break; } - case Toolkit::VideoView::Property::PLAY_POSITION: + break; + } + case Toolkit::VideoView::Property::UNDERLAY: + { + bool underlay; + if( value.Get( underlay ) ) { - int pos; - if( value.Get( pos ) ) - { - impl.SetPlayPosition( pos ); - } - break; + SetUnderlay( underlay ); } - case Toolkit::VideoView::Property::DISPLAY_MODE: + break; + } + case Toolkit::VideoView::Property::PLAY_POSITION: + { + int pos; + if( value.Get( pos ) ) { - int mode; - if( value.Get( mode ) ) - { - impl.SetDisplayMode( mode ); - } - break; + SetPlayPosition( pos ); + } + break; + } + case Toolkit::VideoView::Property::DISPLAY_MODE: + { + int mode; + if( value.Get( mode ) ) + { + SetDisplayMode( mode ); } + break; + } + } +} + +void VideoView::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value ) +{ + Toolkit::VideoView videoView = Toolkit::VideoView::DownCast( Dali::BaseHandle( object ) ); + + if( videoView ) + { + VideoView& impl = GetImpl( videoView ); + + impl.SetPropertyInternal( index, value ); + + if( index != Toolkit::VideoView::Property::UNDERLAY ) + { + // Backup values. + // These values will be used when underlay mode is changed. + impl.mPropertyBackup[index] = value; } } } @@ -543,6 +554,11 @@ void VideoView::SetDepthIndex( int depthIndex ) void VideoView::OnStageConnection( int depth ) { Control::OnStageConnection( depth ); + + if( mIsUnderlay ) + { + SetWindowSurfaceTarget(); + } } void VideoView::OnStageDisconnection() @@ -594,6 +610,13 @@ float VideoView::GetWidthForHeight( float height ) void VideoView::SetWindowSurfaceTarget() { Actor self = Self(); + + if( !self.OnStage() ) + { + // When the control is off the stage, it does not have Window. + return; + } + int curPos = mVideoPlayer.GetPlayPosition(); if( mIsPlay ) @@ -613,8 +636,10 @@ void VideoView::SetWindowSurfaceTarget() self.RemoveRenderer( mTextureRenderer ); } - mVideoPlayer.SetRenderingTarget( Dali::Adaptor::Get().GetNativeWindowHandle() ); - mVideoPlayer.SetUrl( mUrl ); + // Note VideoPlayer::SetRenderingTarget resets all the options. (e.g. url, mute, looping) + mVideoPlayer.SetRenderingTarget( Dali::Adaptor::Get().GetNativeWindowHandle( self ) ); + + ApplyBackupProperties(); if( !mOverlayRenderer ) { @@ -655,6 +680,8 @@ void VideoView::SetNativeImageTarget() if( mOverlayRenderer ) { self.RemoveRenderer( mOverlayRenderer ); + + mOverlayRenderer.Reset(); } self.RemovePropertyNotification( mPositionUpdateNotification ); @@ -684,8 +711,10 @@ void VideoView::SetNativeImageTarget() } Self().AddRenderer( mTextureRenderer ); + // Note VideoPlayer::SetRenderingTarget resets all the options. (e.g. url, mute, looping) mVideoPlayer.SetRenderingTarget( nativeImageSourcePtr ); - mVideoPlayer.SetUrl( mUrl ); + + ApplyBackupProperties(); if( mIsPlay ) { @@ -779,6 +808,11 @@ int VideoView::GetDisplayMode() const return static_cast< int >( mVideoPlayer.GetDisplayMode() ); } +Any VideoView::GetMediaPlayer() +{ + return mVideoPlayer.GetMediaPlayer(); +} + Dali::Shader VideoView::CreateShader() { std::string fragmentShader = "#extension GL_OES_EGL_image_external:require\n"; @@ -835,6 +869,19 @@ bool VideoView::GetStringFromProperty( const Dali::Property::Value& value, std:: return extracted; } +void VideoView::ApplyBackupProperties() +{ + Property::Map::SizeType pos = 0; + Property::Map::SizeType count = mPropertyBackup.Count(); + + for( ; pos < count; pos++ ) + { + KeyValuePair property = mPropertyBackup.GetKeyValue( pos ); + + SetPropertyInternal( property.first.indexKey, property.second ); + } +} + } // namespace Internal } // namespace toolkit