[M108 Migration][MM] Handle PlaybackRate. 13/288613/2
authorVenugopal S M <sm.venugopal@samsung.com>
Tue, 19 Jul 2022 01:10:35 +0000 (18:10 -0700)
committerBot Blink <blinkbot@samsung.com>
Wed, 22 Feb 2023 02:10:52 +0000 (02:10 +0000)
- Enable call to setPlaybackRate
- Delay setting playback rate if player is not prepared(HBBTV)

Reference:
https://review.tizen.org/gerrit/278307
https://review.tizen.org/gerrit/278434
https://review.tizen.org/gerrit/281298
https://review.tizen.org/gerrit/288027

Change-Id: Ib82d363fb0c5f8e585a10967a3d913cd2eb181d3
Signed-off-by: Venugopal S M <sm.venugopal@samsung.com>
tizen_src/chromium_impl/content/browser/media/tizen_renderer_impl.cc
tizen_src/chromium_impl/media/base/tizen/media_player_bridge_capi.cc
tizen_src/chromium_impl/media/base/tizen/media_player_bridge_capi.h
tizen_src/chromium_impl/media/filters/media_player_esplusplayer.cc
tizen_src/chromium_impl/media/filters/media_player_esplusplayer.h

index 19667a5..f45686c 100644 (file)
@@ -432,13 +432,12 @@ void TizenRendererImpl::SetPlaybackRate(double playback_rate) {
 
   playback_rate_ = playback_rate;
 
-  // TODO: Random error is observed on TM1.
-  // EsppPlayer::GetEsppPlayer()->SetRate(playback_rate_);
-
-  if (playback_rate > 0)
+  if (playback_rate > 0) {
+    GetPlayer()->SetRate(playback_rate_);
     GetPlayer()->Play();
-  else
+  } else {
     GetPlayer()->Pause();
+  }
 }
 
 void TizenRendererImpl::SetVolume(float volume) {
index 6da6d56..9eefb6a 100644 (file)
@@ -128,6 +128,7 @@ MediaPlayerBridgeCapi::MediaPlayerBridgeCapi(int player_id,
       is_seeking_(false),
       is_play_pending_(false),
       is_initialized_(false),
+      is_set_playback_rate_delayed_(false),
       duration_(0),
       playback_time_(0),
       seek_duration_(0),
@@ -302,11 +303,21 @@ void MediaPlayerBridgeCapi::Play() {
     return;
   }
 
+  if (GetPlayerState() < PLAYER_STATE_READY) {
+    delayed_player_state_ = PLAYER_STATE_DELAYED_PLAY;
+    return;
+  }
+
   if (playback_rate_ == 0.0) {
     is_paused_ = false;
     return;
   }
 
+  if (is_set_playback_rate_delayed_) {
+    is_set_playback_rate_delayed_ = false;
+    SetRate(playback_rate_);
+  }
+
   if (player_start(player_) != PLAYER_ERROR_NONE) {
     LOG(ERROR) << "|player_start| failed";
     return;
@@ -358,6 +369,12 @@ void MediaPlayerBridgeCapi::SetRate(double rate) {
     return;
   }
 
+  if (GetPlayerState() < PLAYER_STATE_READY) {
+    playback_rate_ = rate;
+    is_set_playback_rate_delayed_ = true;
+    return;
+  }
+
   if (!is_file_url_ &&
       player_set_streaming_playback_rate(player_, static_cast<float>(rate)) !=
           PLAYER_ERROR_NONE) {
index 396abe9..59d4133 100644 (file)
@@ -105,6 +105,7 @@ class MEDIA_EXPORT MediaPlayerBridgeCapi : public MediaPlayerEfl {
   bool is_play_pending_;
   bool is_player_released_;
   bool is_initialized_;
+  bool is_set_playback_rate_delayed_;
 
   double duration_;
   double playback_time_;
index 30c306c..a1b03fd 100644 (file)
@@ -459,7 +459,7 @@ void MediaPlayerESPlusPlayer::SetRate(double rate) {
   int error =
       esplusplayer_set_playback_rate(esplayer_, playback_rate_, should_mute);
   if (error != ESPLUSPLAYER_ERROR_TYPE_NONE) {
-    LOG(ERROR) << "player pause failed! error #"
+    LOG(ERROR) << "player set playback rate failed! error #"
                << esplusplayer_get_error_string(
                       static_cast<esplusplayer_error_type>(error));
     return;
index 72e0f6d..1f80bd7 100644 (file)
@@ -161,7 +161,7 @@ class MEDIA_EXPORT MediaPlayerESPlusPlayer : public MediaPlayerTizen {
       last_frames_;
 
   double volume_ = 1.0;
-  bool playback_rate_ = 0.0;
+  double playback_rate_ = 0.0;
   bool is_prepared_ = false;
   bool is_preparing_ = false;
   bool is_paused_ = true;