Revert "[4.0] Fix SVACE issues"
[platform/core/uifw/dali-adaptor.git] / plugins / video-player / tizen-video-player.cpp
index bbcabaf..f7baa50 100644 (file)
@@ -63,7 +63,6 @@ static void MediaPacketVideoDecodedCb( media_packet_h packet, void* user_data )
   player->PushPacket( packet );
 }
 
-
 static void EmitPlaybackFinishedSignal( void* user_data )
 {
   TizenVideoPlayer* player = static_cast< TizenVideoPlayer* >( user_data );
@@ -86,6 +85,12 @@ static void EmitPlaybackFinishedSignal( void* user_data )
   player->Stop();
 }
 
+// ToDo: VD player_set_play_position() doesn't work when callback pointer is NULL.
+// We should check whether this callback is needed in platform.
+static void PlayerSeekCompletedCb( void* data )
+{
+}
+
 void LogPlayerError( int error )
 {
   if( error != PLAYER_ERROR_NONE )
@@ -206,9 +211,10 @@ void LogPlayerError( int error )
 TizenVideoPlayer::TizenVideoPlayer()
 : mPlayer( NULL ),
   mPlayerState( PLAYER_STATE_NONE ),
+  mTbmSurface( NULL ),
   mPacket( NULL ),
-  mBackgroundColor( Dali::Stage::DEFAULT_BACKGROUND_COLOR ),
-  mTargetType( NativeImage )
+  mTargetType( NativeImage ),
+  mAlphaBitChanged( false )
 {
 }
 
@@ -278,13 +284,10 @@ void TizenVideoPlayer::SetRenderingTarget( Any target )
   }
 
   mNativeImageSourcePtr = NULL;
+  mEcoreWlWindow = NULL;
 
   if( target.GetType() == typeid( Dali::NativeImageSourcePtr ) )
   {
-    if( mTargetType == TizenVideoPlayer::WindowSurface )
-    {
-      Stage::GetCurrent().SetBackgroundColor( mBackgroundColor );
-    }
     mTargetType = TizenVideoPlayer::NativeImage;
 
     Dali::NativeImageSourcePtr nativeImageSourcePtr = AnyCast< Dali::NativeImageSourcePtr >( target );
@@ -294,8 +297,6 @@ void TizenVideoPlayer::SetRenderingTarget( Any target )
   else if( target.GetType() == typeid( Ecore_Wl_Window* ) )
   {
     mTargetType = TizenVideoPlayer::WindowSurface;
-    mBackgroundColor = Stage::GetCurrent().GetBackgroundColor();
-    Stage::GetCurrent().SetBackgroundColor( Color::TRANSPARENT );
 
     Ecore_Wl_Window* nativeWindow = Dali::AnyCast< Ecore_Wl_Window* >( target );
     InitializeUnderlayMode( nativeWindow );
@@ -441,7 +442,7 @@ void TizenVideoPlayer::SetPlayPosition( int millisecond )
       mPlayerState == PLAYER_STATE_PAUSED
   )
   {
-    error = player_set_play_position( mPlayer, millisecond, true, NULL, NULL );
+    error = player_set_play_position( mPlayer, millisecond, false, PlayerSeekCompletedCb, NULL );
     LogPlayerError( error );
   }
 }
@@ -511,6 +512,12 @@ void TizenVideoPlayer::InitializeTextureStreamMode( Dali::NativeImageSourcePtr n
 
   mNativeImageSourcePtr = nativeImageSourcePtr;
 
+  if( mAlphaBitChanged )
+  {
+    ecore_wl_window_alpha_set( mEcoreWlWindow, false );
+    mAlphaBitChanged = false;
+  }
+
   if( mPlayerState == PLAYER_STATE_NONE )
   {
     error = player_create( &mPlayer );
@@ -554,6 +561,7 @@ void TizenVideoPlayer::InitializeUnderlayMode( Ecore_Wl_Window* ecoreWlWindow )
   }
 
   GetPlayerState( &mPlayerState );
+  mEcoreWlWindow = ecoreWlWindow;
 
   if( mPlayerState == PLAYER_STATE_IDLE )
   {
@@ -563,12 +571,20 @@ void TizenVideoPlayer::InitializeUnderlayMode( Ecore_Wl_Window* ecoreWlWindow )
     error = player_set_sound_type( mPlayer, SOUND_TYPE_MEDIA );
     LogPlayerError( error );
 
-    error = player_set_display_mode( mPlayer, PLAYER_DISPLAY_MODE_FULL_SCREEN );
+    error = player_set_display_mode( mPlayer, PLAYER_DISPLAY_MODE_DST_ROI );
     LogPlayerError( error );
 
+    error = player_set_display_roi_area( mPlayer, 0, 0, 1, 1 );
+
     int width, height;
+    mAlphaBitChanged = ( ecore_wl_window_alpha_get( mEcoreWlWindow ) )? false: true;
     ecore_wl_screen_size_get( &width, &height );
-    error = player_set_ecore_wl_display( mPlayer, PLAYER_DISPLAY_TYPE_OVERLAY, ecoreWlWindow, 0, 0, width, height );
+
+    if( mAlphaBitChanged )
+    {
+      ecore_wl_window_alpha_set( mEcoreWlWindow, true );
+    }
+    error = player_set_ecore_wl_display( mPlayer, PLAYER_DISPLAY_TYPE_OVERLAY, mEcoreWlWindow, 0, 0, width, height );
     LogPlayerError( error );
 
     error = player_set_display_visible( mPlayer, true );
@@ -645,5 +661,76 @@ void TizenVideoPlayer::PushPacket( media_packet_h packet )
   mPacketVector.PushBack( packet );
 }
 
+void TizenVideoPlayer::SetDisplayArea( DisplayArea area )
+{
+  GetPlayerState( &mPlayerState );
+
+  if( mNativeImageSourcePtr != NULL )
+  {
+    DALI_LOG_ERROR( "SetDisplayArea is only for window surface target.\n" );
+    return;
+  }
+
+  if( mPlayerState == PLAYER_STATE_IDLE ||
+      mPlayerState == PLAYER_STATE_READY ||
+      mPlayerState == PLAYER_STATE_PLAYING ||
+      mPlayerState == PLAYER_STATE_PAUSED
+
+  )
+  {
+    int error = player_set_display_roi_area( mPlayer, area.x, area.y, area.width, area.height );
+    LogPlayerError( error );
+  }
+}
+
+void TizenVideoPlayer::Forward( int millisecond )
+{
+  int error;
+
+  GetPlayerState( &mPlayerState );
+
+  if( mPlayerState == PLAYER_STATE_READY ||
+      mPlayerState == PLAYER_STATE_PLAYING ||
+      mPlayerState == PLAYER_STATE_PAUSED
+  )
+  {
+    int currentPosition = 0;
+    int nextPosition = 0;
+
+    error = player_get_play_position( mPlayer, &currentPosition );
+    LogPlayerError( error );
+
+    nextPosition = currentPosition + millisecond;
+
+    error = player_set_play_position( mPlayer, nextPosition, false, PlayerSeekCompletedCb, NULL );
+    LogPlayerError( error );
+  }
+}
+
+void TizenVideoPlayer::Backward( int millisecond )
+{
+  int error;
+
+  GetPlayerState( &mPlayerState );
+
+  if( mPlayerState == PLAYER_STATE_READY ||
+      mPlayerState == PLAYER_STATE_PLAYING ||
+      mPlayerState == PLAYER_STATE_PAUSED
+  )
+  {
+    int currentPosition = 0;
+    int nextPosition = 0;
+
+    error = player_get_play_position( mPlayer, &currentPosition );
+    LogPlayerError( error );
+
+    nextPosition = currentPosition - millisecond;
+    nextPosition = ( nextPosition < 0 )? 0 : nextPosition;
+
+    error = player_set_play_position( mPlayer, nextPosition, false, PlayerSeekCompletedCb, NULL );
+    LogPlayerError( error );
+  }
+}
+
 } // namespace Plugin
 } // namespace Dali;