+++ /dev/null
-#ifndef __DALI_TOOLKIT_VIDEO_PLAYER_H__
-#define __DALI_TOOLKIT_VIDEO_PLAYER_H__
-
-/*
- * Copyright (c) 2016 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/object/base-handle.h>
-#include <dali/public-api/object/base-object.h>
-
-#include <dali/devel-api/adaptor-framework/video-player-plugin.h>
-
-namespace Dali
-{
-
-class Any;
-
-namespace Internal
-{
-namespace Adaptor
-{
-
-class VideoPlayer;
-
-}
-}
-
-/**
- * @brief VideoPlayer class is used for video playback.
- * @SINCE_1_1.38
- */
-class VideoPlayer: public BaseHandle
-{
-public:
-
- VideoPlayer();
-
- ~VideoPlayer();
-
- static VideoPlayer New();
-
- VideoPlayer( const VideoPlayer& player );
-
- VideoPlayer& operator=( const VideoPlayer& player );
-
- static VideoPlayer DownCast( BaseHandle handle );
-
- void SetUrl( const std::string& url );
-
- std::string GetUrl();
-
- void SetLooping(bool looping);
-
- bool IsLooping();
-
- void Play();
-
- void Pause();
-
- void Stop();
-
- void SetMute( bool mute );
-
- bool IsMuted();
-
- void SetVolume( float left, float right );
-
- void GetVolume( float& left, float& right );
-
- void SetRenderingTarget( Any target );
-
- void SetPlayPosition( int millisecond );
-
- int GetPlayPosition();
-
- void SetDisplayArea( DisplayArea area );
-
- void SetDisplayRotation( Dali::VideoPlayerPlugin::DisplayRotation rotation );
-
- Dali::VideoPlayerPlugin::DisplayRotation GetDisplayRotation();
-
- Dali::VideoPlayerPlugin::VideoPlayerSignalType& FinishedSignal();
-
- void Forward( int millisecond );
-
- void Backward( int millisecond );
-
-private:
-
- VideoPlayer( Internal::Adaptor::VideoPlayer* internal );
-
-};
-
-} // namespace Dali;
-
-#endif
END_TEST;
}
+
+int UtcDaliVideoViewPropertyUnderlay(void)
+{
+ ToolkitTestApplication application;
+ ToolkitApplication::DECODED_IMAGES_SUPPORTED = true;
+
+ VideoView view = VideoView::New();
+ DALI_TEST_CHECK( view );
+
+ Stage::GetCurrent().Add( view );
+
+ application.SendNotification();
+ application.Render();
+
+ bool isUnderlay = view.GetProperty( Toolkit::VideoView::Property::UNDERLAY ).Get< bool >();
+ DALI_TEST_CHECK( isUnderlay );
+
+ view.SetProperty( Toolkit::VideoView::Property::UNDERLAY, false );
+ isUnderlay = view.GetProperty( Toolkit::VideoView::Property::UNDERLAY ).Get< bool >();
+ DALI_TEST_CHECK( !isUnderlay );
+
+ view.SetProperty( Toolkit::VideoView::Property::UNDERLAY, true );
+ isUnderlay = view.GetProperty( Toolkit::VideoView::Property::UNDERLAY ).Get< bool >();
+ DALI_TEST_CHECK( isUnderlay );
+
+ // If platform api doesn't provide any API or feature for decoded images of video,
+ // UNDERLAY should be true
+ ToolkitApplication::DECODED_IMAGES_SUPPORTED = false;
+
+ view.SetProperty( Toolkit::VideoView::Property::UNDERLAY, false );
+ isUnderlay = view.GetProperty( Toolkit::VideoView::Property::UNDERLAY ).Get< bool >();
+ DALI_TEST_CHECK( isUnderlay );
+
+ END_TEST;
+}
DALI_PROPERTY_REGISTRATION( Toolkit, VideoView, "looping", BOOLEAN, LOOPING )
DALI_PROPERTY_REGISTRATION( Toolkit, VideoView, "muted", BOOLEAN, MUTED )
DALI_PROPERTY_REGISTRATION( Toolkit, VideoView, "volume", MAP, VOLUME )
+DALI_PROPERTY_REGISTRATION( Toolkit, VideoView, "underlay", BOOLEAN, UNDERLAY )
DALI_SIGNAL_REGISTRATION( Toolkit, VideoView, "finished", FINISHED_SIGNAL )
const char* const VOLUME_LEFT( "volumeLeft" );
const char* const VOLUME_RIGHT( "volumeRight" );
+
+// 3.0 TC uses RENDERING_TARGET. It should be removed in next release
const char* const RENDERING_TARGET( "renderingTarget" );
const char* const WINDOW_SURFACE_TARGET( "windowSurfaceTarget" );
const char* const NATIVE_IMAGE_TARGET( "nativeImageTarget" );
mUpdateTriggerPropertyIndex( Property::INVALID_INDEX),
mNotification( NULL ),
mCurrentVideoPlayPosition( 0 ),
- mIsNativeImageTarget( true ),
mIsPlay( false ),
- mIsPause( false )
+ mIsPause( false ),
+ mIsUnderlay( true )
{
mVideoPlayer = Dali::VideoPlayer::New();
void VideoView::OnInitialize()
{
- Any source;
- Dali::NativeImageSourcePtr nativeImageSourcePtr = Dali::NativeImageSource::New( source );
- mNativeImage = Dali::NativeImage::New( *nativeImageSourcePtr );
-
- mVideoPlayer.SetRenderingTarget( nativeImageSourcePtr );
- mVideoPlayer.FinishedSignal().Connect( this, &VideoView::EmitSignalFinish );
-
mUpdateTriggerPropertyIndex = Self().RegisterProperty( "updateTrigger", true );
+ mVideoPlayer.FinishedSignal().Connect( this, &VideoView::EmitSignalFinish );
+ SetWindowSurfaceTarget();
}
void VideoView::SetUrl( const std::string& url )
mPropertyMap.Clear();
}
- if( mIsNativeImageTarget )
+ if( !mIsUnderlay )
{
Actor self( Self() );
Internal::InitializeVisual( self, mVisual, mNativeImage );
if( target && target->Get( targetType ) && targetType == WINDOW_SURFACE_TARGET )
{
- this->SetWindowSurfaceTarget();
+ mIsUnderlay = true;
+ SetWindowSurfaceTarget();
}
else if( target && target->Get( targetType ) && targetType == NATIVE_IMAGE_TARGET )
{
- this->SetNativeImageTarget();
+ mIsUnderlay = false;
+ SetNativeImageTarget();
}
RelayoutRequest();
}
break;
}
+ case Toolkit::VideoView::Property::UNDERLAY:
+ {
+ bool underlay;
+ if( value.Get( underlay ) )
+ {
+ impl.SetUnderlay( underlay );
+ }
+ break;
+ }
}
}
}
value = map;
break;
}
+ case Toolkit::VideoView::Property::UNDERLAY:
+ {
+ value = impl.IsUnderlay();
+ break;
+ }
}
}
mVideoPlayer.SetRenderingTarget( Dali::Adaptor::Get().GetNativeWindowHandle() );
mVideoPlayer.SetUrl( mUrl );
- mIsNativeImageTarget = false;
+ if( !mRenderer )
+ {
+ // For underlay rendering mode, video display area have to be transparent.
+ Geometry geometry = VisualFactoryCache::CreateQuadGeometry();
+ Shader shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
+ mRenderer = Renderer::New( geometry, shader );
+
+ mRenderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON );
+ mRenderer.SetProperty( Renderer::Property::BLEND_FACTOR_SRC_RGB, BlendFactor::ONE );
+ mRenderer.SetProperty( Renderer::Property::BLEND_FACTOR_DEST_RGB, BlendFactor::ZERO );
+ mRenderer.SetProperty( Renderer::Property::BLEND_FACTOR_SRC_ALPHA, BlendFactor::ONE );
+ mRenderer.SetProperty( Renderer::Property::BLEND_FACTOR_DEST_ALPHA, BlendFactor::ZERO );
+ }
+ self.AddRenderer( mRenderer );
+
+ UpdateDisplayArea();
if( mIsPlay )
{
{
mVideoPlayer.SetPlayPosition( curPos );
}
-
- // For underlay rendering mode, video display area have to be transparent.
- Geometry geometry = VisualFactoryCache::CreateQuadGeometry();
- Shader shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
- Renderer renderer = Renderer::New( geometry, shader );
-
- renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON );
- renderer.SetProperty( Renderer::Property::BLEND_FACTOR_SRC_RGB, BlendFactor::ONE );
- renderer.SetProperty( Renderer::Property::BLEND_FACTOR_DEST_RGB, BlendFactor::ZERO );
- renderer.SetProperty( Renderer::Property::BLEND_FACTOR_SRC_ALPHA, BlendFactor::ONE );
- renderer.SetProperty( Renderer::Property::BLEND_FACTOR_DEST_ALPHA, BlendFactor::ZERO );
- self.AddRenderer( renderer );
}
void VideoView::SetNativeImageTarget()
{
+ if( mVideoPlayer.IsVideoTextureSupported() == false )
+ {
+ DALI_LOG_ERROR( "Platform doesn't support decoded video frame images\n" );
+ mIsUnderlay = true;
+ return;
+ }
+
Actor self( Self() );
int curPos = mVideoPlayer.GetPlayPosition();
mVideoPlayer.SetUrl( mUrl );
Internal::InitializeVisual( self, mVisual, mNativeImage );
- mIsNativeImageTarget = true;
+ Self().RemoveRenderer( mRenderer );
if( mIsPlay )
{
void VideoView::UpdateDisplayArea()
{
+ if( !mIsUnderlay )
+ {
+ return;
+ }
+
Actor self( Self() );
bool positionUsesAnchorPoint = self.GetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT ).Get< bool >();
mVideoPlayer.SetDisplayArea( mDisplayArea );
}
+void VideoView::SetUnderlay( bool set )
+{
+ if( set != mIsUnderlay )
+ {
+ mIsUnderlay = set;
+
+ if( mIsUnderlay )
+ {
+ SetWindowSurfaceTarget();
+ }
+ else
+ {
+ SetNativeImageTarget();
+ }
+ }
+}
+
+bool VideoView::IsUnderlay()
+{
+ return mIsUnderlay;
+}
+
} // namespace Internal
} // namespace toolkit