Fixed issue of LOOPING, MUTED, and VOLUME properties 42/124842/10
authortaeyoon0.lee <taeyoon0.lee@samsung.com>
Wed, 12 Apr 2017 13:22:50 +0000 (22:22 +0900)
committertaeyoon0.lee <taeyoon0.lee@samsung.com>
Thu, 20 Apr 2017 12:11:09 +0000 (21:11 +0900)
 - OnInitialize() initializes VideoPlayer using NativeImage as default

Change-Id: I7f75886de2d9f522d44cd0d8504959ac85bd091c

automated-tests/src/dali-toolkit/utc-Dali-VideoView.cpp
dali-toolkit/internal/controls/video-view/video-view-impl.cpp
dali-toolkit/internal/controls/video-view/video-view-impl.h

index d6128c5..983ac77 100644 (file)
@@ -29,6 +29,7 @@ namespace
 const char* const TEST_FILE( "test.mp4" );
 const char* const VOLUME_LEFT( "volumeLeft" );
 const char* const VOLUME_RIGHT( "volumeRight" );
 const char* const TEST_FILE( "test.mp4" );
 const char* const VOLUME_LEFT( "volumeLeft" );
 const char* const VOLUME_RIGHT( "volumeRight" );
+const char* const RENDERING_TYPE( "renderingTarget" );
 
 }
 
 
 }
 
@@ -201,20 +202,21 @@ int UtcDaliVideoViewProperty4(void)
   left = right = 0.f;
 
   Property::Map map;
   left = right = 0.f;
 
   Property::Map map;
-  map.Insert( VOLUME_LEFT, 1.0f );
+  map.Insert( VOLUME_LEFT, 0.5f );
   map.Insert( VOLUME_RIGHT, 0.5f );
 
   map.Insert( VOLUME_RIGHT, 0.5f );
 
-  Property::Map map2;
   view.SetProperty( VideoView::Property::VOLUME, map );
   view.SetProperty( VideoView::Property::VOLUME, map );
-  Property::Value val4 = view.GetProperty( VideoView::Property::VOLUME );
-  DALI_TEST_CHECK( val4.Get( map2 ) );
+  Property::Value val = view.GetProperty( VideoView::Property::VOLUME );
+
+  Property::Map map2;
+  DALI_TEST_CHECK( val.Get( map2 ) );
 
 
-  Property::Value* volumeLeft = map.Find( VOLUME_LEFT );
-  Property::Value* volumeRight = map.Find( VOLUME_RIGHT );
+  Property::Value* volumeLeft = map2.Find( VOLUME_LEFT );
+  Property::Value* volumeRight = map2.Find( VOLUME_RIGHT );
 
   DALI_TEST_CHECK( volumeLeft && volumeLeft->Get( left ) );
   DALI_TEST_CHECK( volumeRight && volumeRight->Get( right ) );
 
   DALI_TEST_CHECK( volumeLeft && volumeLeft->Get( left ) );
   DALI_TEST_CHECK( volumeRight && volumeRight->Get( right ) );
-  DALI_TEST_CHECK( left == 1.0f );
+  DALI_TEST_CHECK( left == 0.5f );
   DALI_TEST_CHECK( right == 0.5f );
 
   END_TEST;
   DALI_TEST_CHECK( right == 0.5f );
 
   END_TEST;
@@ -275,3 +277,38 @@ int UtcDaliVideoViewMethodsForCoverage(void)
 
   END_TEST;
 }
 
   END_TEST;
 }
+
+int UtcDaliVideoViewMethodsForRenderType(void)
+{
+  ToolkitTestApplication application;
+  VideoView videoView = VideoView::New();
+  DALI_TEST_CHECK( videoView );
+
+  Property::Map windowSurfaceTarget;
+  Property::Map nativeImageTarget;
+
+  windowSurfaceTarget.Insert( RENDERING_TYPE, "windowSurfaceTarget" );
+  nativeImageTarget.Insert( RENDERING_TYPE, "nativeImageTarget" );
+
+  Property::Map map;
+  Property::Value value;
+  videoView.SetProperty( VideoView::Property::VIDEO, windowSurfaceTarget );
+
+  value = videoView.GetProperty( VideoView::Property::VIDEO );
+  DALI_TEST_CHECK( value.Get( map ) );
+
+  Property::Value* type = map.Find( RENDERING_TYPE );
+  DALI_TEST_CHECK( type );
+  DALI_TEST_EQUALS( "windowSurfaceTarget", type->Get<std::string>(), TEST_LOCATION );
+
+  videoView.SetProperty( VideoView::Property::VIDEO, nativeImageTarget );
+
+  value = videoView.GetProperty( VideoView::Property::VIDEO );
+  DALI_TEST_CHECK( value.Get( map ) );
+  type = map.Find( RENDERING_TYPE );
+
+  DALI_TEST_CHECK( type );
+  DALI_TEST_EQUALS( "nativeImageTarget", type->Get<std::string>(), TEST_LOCATION );
+
+  END_TEST;
+}
index 2ec07ef..1fd4be5 100644 (file)
@@ -67,7 +67,7 @@ DALI_TYPE_REGISTRATION_END()
 
 const char* const VOLUME_LEFT( "volumeLeft" );
 const char* const VOLUME_RIGHT( "volumeRight" );
 
 const char* const VOLUME_LEFT( "volumeLeft" );
 const char* const VOLUME_RIGHT( "volumeRight" );
-const char* const RENDERING_TARGET( "RENDERING_TARGET" );
+const char* const RENDERING_TARGET( "renderingTarget" );
 const char* const WINDOW_SURFACE_TARGET( "windowSurfaceTarget" );
 const char* const NATIVE_IMAGE_TARGET( "nativeImageTarget" );
 
 const char* const WINDOW_SURFACE_TARGET( "windowSurfaceTarget" );
 const char* const NATIVE_IMAGE_TARGET( "nativeImageTarget" );
 
@@ -76,7 +76,7 @@ const char* const NATIVE_IMAGE_TARGET( "nativeImageTarget" );
 VideoView::VideoView()
 : Control( ControlBehaviour( ACTOR_BEHAVIOUR_DEFAULT | DISABLE_STYLE_CHANGE_SIGNALS ) ),
   mCurrentVideoPlayPosition( 0 ),
 VideoView::VideoView()
 : Control( ControlBehaviour( ACTOR_BEHAVIOUR_DEFAULT | DISABLE_STYLE_CHANGE_SIGNALS ) ),
   mCurrentVideoPlayPosition( 0 ),
-  mSetRenderingTarget( false ),
+  mIsNativeImageTarget( true ),
   mIsPlay( false ),
   mIsPause( false )
 {
   mIsPlay( false ),
   mIsPause( false )
 {
@@ -97,23 +97,31 @@ Toolkit::VideoView VideoView::New()
   return handle;
 }
 
   return handle;
 }
 
+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 );
+}
+
 void VideoView::SetUrl( const std::string& url )
 {
   if( mUrl != url || !mPropertyMap.Empty() )
   {
 void VideoView::SetUrl( const std::string& url )
 {
   if( mUrl != url || !mPropertyMap.Empty() )
   {
-    mPropertyMap.Clear();
-
     mUrl = url;
     mUrl = url;
+    mPropertyMap.Clear();
   }
 
   }
 
-  if( mSetRenderingTarget )
-  {
-    mVideoPlayer.SetUrl( mUrl );
-  }
-  else
+  if( mIsNativeImageTarget )
   {
   {
-    SetNativeImageTarget();
+    Actor self( Self() );
+    Internal::InitializeVisual( self, mVisual, mNativeImage );
   }
   }
+
+  mVideoPlayer.SetUrl( mUrl );
 }
 
 void VideoView::SetPropertyMap( Property::Map map )
 }
 
 void VideoView::SetPropertyMap( Property::Map map )
@@ -505,8 +513,6 @@ void VideoView::SetWindowSurfaceTarget()
   Actor self = Self();
   int curPos = mVideoPlayer.GetPlayPosition();
 
   Actor self = Self();
   int curPos = mVideoPlayer.GetPlayPosition();
 
-  mSetRenderingTarget = true;
-
   if( mVisual )
   {
     Toolkit::GetImplementation(mVisual).SetOffStage(self);
   if( mVisual )
   {
     Toolkit::GetImplementation(mVisual).SetOffStage(self);
@@ -515,7 +521,8 @@ void VideoView::SetWindowSurfaceTarget()
 
   mVideoPlayer.SetRenderingTarget( Dali::Adaptor::Get().GetNativeWindowHandle() );
   mVideoPlayer.SetUrl( mUrl );
 
   mVideoPlayer.SetRenderingTarget( Dali::Adaptor::Get().GetNativeWindowHandle() );
   mVideoPlayer.SetUrl( mUrl );
-  mVideoPlayer.FinishedSignal().Connect( this, &VideoView::EmitSignalFinish );
+
+  mIsNativeImageTarget = false;
 
   if( mIsPlay )
   {
 
   if( mIsPlay )
   {
@@ -534,17 +541,15 @@ void VideoView::SetNativeImageTarget()
   Actor self( Self() );
   int curPos = mVideoPlayer.GetPlayPosition();
 
   Actor self( Self() );
   int curPos = mVideoPlayer.GetPlayPosition();
 
-  mSetRenderingTarget = true;
-
   Any source;
   Dali::NativeImageSourcePtr nativeImageSourcePtr = Dali::NativeImageSource::New( source );
   mNativeImage = Dali::NativeImage::New( *nativeImageSourcePtr );
 
   mVideoPlayer.SetRenderingTarget( nativeImageSourcePtr );
   mVideoPlayer.SetUrl( mUrl );
   Any source;
   Dali::NativeImageSourcePtr nativeImageSourcePtr = Dali::NativeImageSource::New( source );
   mNativeImage = Dali::NativeImage::New( *nativeImageSourcePtr );
 
   mVideoPlayer.SetRenderingTarget( nativeImageSourcePtr );
   mVideoPlayer.SetUrl( mUrl );
-  mVideoPlayer.FinishedSignal().Connect( this, &VideoView::EmitSignalFinish );
 
   Internal::InitializeVisual( self, mVisual, mNativeImage );
 
   Internal::InitializeVisual( self, mVisual, mNativeImage );
+  mIsNativeImageTarget = true;
 
   if( mIsPlay )
   {
 
   if( mIsPlay )
   {
index 57641cd..a662802 100644 (file)
@@ -185,7 +185,6 @@ public:
    */
   void SetDepthIndex( int depthIndex );
 
    */
   void SetDepthIndex( int depthIndex );
 
-
   /**
    * @brief Performs actions as requested using the action name.
    * @SINCE_1_1.38
   /**
    * @brief Performs actions as requested using the action name.
    * @SINCE_1_1.38
@@ -201,6 +200,11 @@ public:
 private: // From Control
 
   /**
 private: // From Control
 
   /**
+   * @copydoc Toolkit::Control::OnInitialize()
+   */
+  virtual void OnInitialize();
+
+  /**
    * @copydoc Toolkit::Control::OnStageConnect()
    */
   virtual void OnStageConnection( int depth );
    * @copydoc Toolkit::Control::OnStageConnect()
    */
   virtual void OnStageConnection( int depth );
@@ -246,7 +250,7 @@ private:
   Dali::Toolkit::VideoView::VideoViewSignalType mFinishedSignal;
   std::string mUrl;
   int mCurrentVideoPlayPosition;
   Dali::Toolkit::VideoView::VideoViewSignalType mFinishedSignal;
   std::string mUrl;
   int mCurrentVideoPlayPosition;
-  bool mSetRenderingTarget;
+  bool mIsNativeImageTarget;
   bool mIsPlay;
   bool mIsPause;
 };
   bool mIsPlay;
   bool mIsPause;
 };