video-player: Let player_set_play_position set exact position 60/267760/4
authorEunki, Hong <eunkiki.hong@samsung.com>
Thu, 9 Dec 2021 12:17:52 +0000 (21:17 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Fri, 10 Dec 2021 01:48:47 +0000 (10:48 +0900)
Previous version just set play position to nearest keyframe.
But when keyframe distance is so big and when we call Forward,
the nearest keyframe can be 'PASTER' than current position.

This patch turn on accurate flag so we can go to excat frames.

Change-Id: I24e6d9933c5a973c34bc944480b497c870495fc4
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
dali-extension/video-player/ecore-wl/tizen-video-player-ecore-wl.cpp
dali-extension/video-player/ecore-wl2/tizen-video-player-ecore-wl2.cpp

index 6e3bf1a..bdd65d8 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
@@ -214,6 +214,14 @@ void LogPlayerError( int error )
   }
 }
 
+/**
+ * @brief Whether set play positoin accurately or not.
+ *  If true, we set play position to the nearest frame position. but this might be considerably slow, accurately.
+ *  If false, we set play position to the nearest key frame position. this might be faster but less accurate.
+ * see player_set_play_position()
+ */
+constexpr bool ACCURATE_PLAY_POSITION_SET = true;
+
 } // unnamed namespace
 
 TizenVideoPlayer::TizenVideoPlayer( Dali::Actor actor, Dali::VideoSyncMode syncMode )
@@ -477,7 +485,7 @@ void TizenVideoPlayer::SetPlayPosition( int millisecond )
       mPlayerState == PLAYER_STATE_PAUSED
   )
   {
-    error = player_set_play_position( mPlayer, millisecond, false, PlayerSeekCompletedCb, NULL );
+    error = player_set_play_position( mPlayer, millisecond, ACCURATE_PLAY_POSITION_SET, PlayerSeekCompletedCb, NULL );
     LogPlayerError( error );
   }
 }
@@ -742,7 +750,7 @@ void TizenVideoPlayer::Forward( int millisecond )
 
     nextPosition = currentPosition + millisecond;
 
-    error = player_set_play_position( mPlayer, nextPosition, false, PlayerSeekCompletedCb, NULL );
+    error = player_set_play_position( mPlayer, nextPosition, ACCURATE_PLAY_POSITION_SET, PlayerSeekCompletedCb, NULL );
     LogPlayerError( error );
   }
 }
@@ -767,7 +775,7 @@ void TizenVideoPlayer::Backward( int millisecond )
     nextPosition = currentPosition - millisecond;
     nextPosition = ( nextPosition < 0 )? 0 : nextPosition;
 
-    error = player_set_play_position( mPlayer, nextPosition, false, PlayerSeekCompletedCb, NULL );
+    error = player_set_play_position( mPlayer, nextPosition, ACCURATE_PLAY_POSITION_SET, PlayerSeekCompletedCb, NULL );
     LogPlayerError( error );
   }
 }
index fd30f63..85c3f0b 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
@@ -39,6 +39,7 @@ extern "C" DALI_EXPORT_API void DestroyVideoPlayerPlugin(Dali::VideoPlayerPlugin
     delete plugin;
   }
 }
+
 namespace Dali
 {
 namespace Plugin
@@ -252,6 +253,14 @@ private:
   float                 mHalfScreenHeight;
 };
 
+/**
+ * @brief Whether set play positoin accurately or not.
+ *  If true, we set play position to the nearest frame position. but this might be considerably slow, accurately.
+ *  If false, we set play position to the nearest key frame position. this might be faster but less accurate.
+ * see player_set_play_position()
+ */
+constexpr bool ACCURATE_PLAY_POSITION_SET = true;
+
 } // unnamed namespace
 
 TizenVideoPlayer::TizenVideoPlayer(Dali::Actor actor, Dali::VideoSyncMode syncMode)
@@ -617,7 +626,7 @@ void TizenVideoPlayer::SetPlayPosition(int millisecond)
      mPlayerState == PLAYER_STATE_PLAYING ||
      mPlayerState == PLAYER_STATE_PAUSED)
   {
-    error = player_set_play_position(mPlayer, millisecond, false, PlayerSeekCompletedCb, NULL);
+    error = player_set_play_position(mPlayer, millisecond, ACCURATE_PLAY_POSITION_SET, PlayerSeekCompletedCb, NULL);
     ret   = LogPlayerError(error);
     if(ret)
     {
@@ -1091,7 +1100,7 @@ void TizenVideoPlayer::Forward(int millisecond)
 
     nextPosition = currentPosition + millisecond;
 
-    error = player_set_play_position(mPlayer, nextPosition, false, PlayerSeekCompletedCb, NULL);
+    error = player_set_play_position(mPlayer, nextPosition, ACCURATE_PLAY_POSITION_SET, PlayerSeekCompletedCb, NULL);
     ret   = LogPlayerError(error);
     if(ret)
     {
@@ -1124,7 +1133,7 @@ void TizenVideoPlayer::Backward(int millisecond)
     nextPosition = currentPosition - millisecond;
     nextPosition = (nextPosition < 0) ? 0 : nextPosition;
 
-    error = player_set_play_position(mPlayer, nextPosition, false, PlayerSeekCompletedCb, NULL);
+    error = player_set_play_position(mPlayer, nextPosition, ACCURATE_PLAY_POSITION_SET, PlayerSeekCompletedCb, NULL);
     ret   = LogPlayerError(error);
     if(ret)
     {