Added devel-API for video player 51/132451/9
authortaeyoon0.lee <taeyoon0.lee@samsung.com>
Mon, 5 Jun 2017 08:37:15 +0000 (17:37 +0900)
committertaeyoon0.lee <taeyoon0.lee@samsung.com>
Fri, 30 Jun 2017 06:16:43 +0000 (15:16 +0900)
 - SetDisplayArea, Forward, Backward

Change-Id: I5cb5999a37f14c44dbe249f40eaefd2c13c0b975

adaptors/common/video-player-impl.cpp
adaptors/common/video-player-impl.h
adaptors/devel-api/adaptor-framework/video-player-plugin.h
adaptors/devel-api/adaptor-framework/video-player.cpp
adaptors/devel-api/adaptor-framework/video-player.h
plugins/video-player/tizen-video-player.cpp
plugins/video-player/tizen-video-player.h

index b87f091ec1e39e15ce758527d50ceb6d6c5e1307..2585b17b7a9a37b53d7482d14e07f52ef0d39339 100644 (file)
@@ -232,6 +232,14 @@ int VideoPlayer::GetPlayPosition()
   return 0;
 }
 
+void VideoPlayer::SetDisplayArea( DisplayArea area )
+{
+  if( mPlugin != NULL )
+  {
+    mPlugin->SetDisplayArea( area );
+  }
+}
+
 void VideoPlayer::SetDisplayRotation( Dali::VideoPlayerPlugin::DisplayRotation rotation )
 {
   if( mPlugin != NULL )
@@ -260,6 +268,22 @@ Dali::VideoPlayerPlugin::VideoPlayerSignalType& VideoPlayer::FinishedSignal()
   return mFinishedSignal;
 }
 
+void VideoPlayer::Forward( int millisecond )
+{
+  if( mPlugin != NULL )
+  {
+    mPlugin->Forward( millisecond );
+  }
+}
+
+void VideoPlayer::Backward( int millisecond )
+{
+  if( mPlugin != NULL )
+  {
+    mPlugin->Backward( millisecond );
+  }
+}
+
 } // namespace Adaptor;
 } // namespace Internal;
 } // namespace Dali;
index 4424217b0b2e87a7855761946e3fde5084f706ed..e37b5f60c405046a561ec3b6d4d24c15960369e9 100644 (file)
@@ -124,6 +124,11 @@ public:
    */
   int GetPlayPosition();
 
+  /**
+   * @copydoc Dali::VideoPlayer::SetDisplayArea()
+   */
+  void SetDisplayArea( DisplayArea area );
+
   /**
    * @copydoc Dali::VideoPlayer::SetSetDisplayRotation()
    */
@@ -144,6 +149,16 @@ public:
    */
   void Initialize();
 
+  /**
+   * @brief Dali::VideoPlayer::Forward()
+   */
+  void Forward( int millisecond );
+
+  /**
+   * @brief Dali::VideoPlayer::Backward()
+   */
+  void Backward( int millisecond );
+
 private:
 
   /**
index 0791db16e5c222a423e93006e50c1b666e5f4cc9..4bbcc0424b583149dcba60510d9aa0253be8ae86 100644 (file)
 
 // EXTERNAL INCLUDES
 #include <dali/public-api/signals/dali-signal.h>
+#include <dali/public-api/math/rect.h>
 
 namespace Dali
 {
 
 class Any;
+typedef Dali::Rect< int > DisplayArea;
 
 /**
  * @brief VideoPlayerPlugin is an abstract interface, used by dali-adaptor to access video player plugin.
@@ -164,6 +166,13 @@ public:
    */
   virtual int GetPlayPosition() = 0;
 
+  /**
+   * @brief Sets the area of video display.
+   * @SINCE_1_2.46
+   * param[in] area The left-top position and size of the video display area
+   */
+  virtual void SetDisplayArea( DisplayArea area ) = 0;
+
   /**
    * @brief Sets video display rotation
    * @SINCE_1_1.38
@@ -186,6 +195,22 @@ public:
    */
   virtual VideoPlayerSignalType& FinishedSignal() = 0;
 
+  /**
+   * @brief Seeks forward by the specified number of milliseconds.
+   *
+   * @SINCE_1_2.46
+   * @param[in] millisecond The position for forward playback
+   */
+  virtual void Forward( int millisecond ) = 0;
+
+  /**
+   * @brief Seeks backward by the specified number of milliseconds.
+   *
+   * @SINCE_1_2.46
+   * @param[in] millisecond The position for backward playback
+   */
+  virtual void Backward( int millisecond ) = 0;
+
 };
 
 } // namespace Dali;
index 8cb539572a81b424895d8caf9e18accba342a22c..fb4b2a2dac0346e2df2fde1ae7a1cc170f35364c 100644 (file)
@@ -141,6 +141,11 @@ int VideoPlayer::GetPlayPosition()
   return GetImplementation( *this ).GetPlayPosition();
 }
 
+void VideoPlayer::SetDisplayArea( DisplayArea area )
+{
+  GetImplementation( *this ).SetDisplayArea( area );
+}
+
 void VideoPlayer::SetDisplayRotation( Dali::VideoPlayerPlugin::DisplayRotation rotation )
 {
   GetImplementation( *this ).SetDisplayRotation( rotation );
@@ -156,5 +161,15 @@ Dali::VideoPlayerPlugin::VideoPlayerSignalType& VideoPlayer::FinishedSignal()
   return GetImplementation( *this ).FinishedSignal();
 }
 
+void VideoPlayer::Forward( int millisecond )
+{
+  GetImplementation( *this ).Forward( millisecond );
+}
+
+void VideoPlayer::Backward( int millisecond )
+{
+  GetImplementation( *this ).Backward( millisecond );
+}
+
 } // namespace Dali;
 
index 9d37043f21f0b41b5a78ca3d7e650cac5cf358cd..8c69719f93e4db69ab63b0f9543a11e0db527a42 100644 (file)
@@ -196,6 +196,13 @@ public:
    */
   int GetPlayPosition();
 
+  /**
+   * @brief Sets the area of video display.
+   * @SINCE_1_2.46
+   * param[in] area The left-top position and size of the video display area
+   */
+  void SetDisplayArea( DisplayArea area );
+
   /**
    * @brief Sets video display rotation
    * @SINCE_1_1.38
@@ -218,6 +225,22 @@ public:
    */
   Dali::VideoPlayerPlugin::VideoPlayerSignalType& FinishedSignal();
 
+  /**
+   * @brief Seeks forward by the specified number of milliseconds.
+   *
+   * @SINCE_1_2.46
+   * @param[in] millisecond The position for forward playback
+   */
+  void Forward( int millisecond );
+
+  /**
+   * @brief Seeks backward by the specified number of milliseconds.
+   *
+   * @SINCE_1_2.46
+   * @param[in] millisecond The position for backward playback
+   */
+  void Backward( int millisecond );
+
 private: // Not intended for application developers
 
   /**
index d33e2347d5f3cbe916e7eb62aa1a165b4aef1dea..c54a55829e4c369e6c85b87a6a1167c84c9ea17c 100644 (file)
@@ -208,8 +208,8 @@ TizenVideoPlayer::TizenVideoPlayer()
   mPlayerState( PLAYER_STATE_NONE ),
   mTbmSurface( NULL ),
   mPacket( NULL ),
-  mBackgroundColor( Dali::Stage::DEFAULT_BACKGROUND_COLOR ),
-  mTargetType( NativeImage )
+  mTargetType( NativeImage ),
+  mAlphaBitChanged( false )
 {
 }
 
@@ -279,13 +279,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 );
@@ -295,8 +292,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 );
@@ -512,6 +507,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 );
@@ -555,6 +556,7 @@ void TizenVideoPlayer::InitializeUnderlayMode( Ecore_Wl_Window* ecoreWlWindow )
   }
 
   GetPlayerState( &mPlayerState );
+  mEcoreWlWindow = ecoreWlWindow;
 
   if( mPlayerState == PLAYER_STATE_IDLE )
   {
@@ -564,12 +566,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 );
@@ -646,5 +656,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, true, NULL, 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, true, NULL, NULL );
+    LogPlayerError( error );
+  }
+}
+
 } // namespace Plugin
 } // namespace Dali;
index ac82edde2458fc69e4fae23b6dce5dfc4a12b560..9f870cce68d381d1dc44e45898fd9bb324f30ae2 100644 (file)
@@ -139,6 +139,11 @@ public:
    */
   virtual int GetPlayPosition();
 
+  /**
+   * @copydoc Dali::VideoPlayerPlugin::SetDisplayArea()
+   */
+  virtual void SetDisplayArea( DisplayArea area );
+
   /**
    * @copydoc Dali::VideoPlayerPlugin::SetDisplayRotation()
    */
@@ -159,6 +164,16 @@ public:
    */
   void PushPacket( media_packet_h packet );
 
+  /**
+   * @brief Dali::VideoPlayer::Forward()
+   */
+  void Forward( int millisecond );
+
+  /**
+   * @brief Dali::VideoPlayer::Backward()
+   */
+  void Backward( int millisecond );
+
 private:
 
   /**
@@ -201,6 +216,10 @@ private:
   Dali::Mutex mPacketMutex;
   Dali::Vector< media_packet_h > mPacketVector; ///< Container for media packet handle from Tizen player callback
 
+  Ecore_Wl_Window* mEcoreWlWindow;
+
+  bool mAlphaBitChanged; ///< True if underlay rendering initialization changes window alpha
+
 public:
 
   Dali::VideoPlayerPlugin::VideoPlayerSignalType mFinishedSignal;