Add interface about drop 73/296573/1
authorEunhye Choi <eunhae1.choi@samsung.com>
Tue, 1 Aug 2023 08:28:46 +0000 (17:28 +0900)
committerEunhye Choi <eunhae1.choi@samsung.com>
Tue, 1 Aug 2023 08:28:49 +0000 (17:28 +0900)
- add interface about frame drop information

Change-Id: Iedfa19da817bb972602123142a1eb44e4914d0ce

include/esplusplayer_capi/esplusplayer_capi.h
include/plusplayer/esplusplayer.h
src/esplusplayer/include_internal/esplayer/esplayer.h
src/esplusplayer/src/esplayer.cpp
src/esplusplayer/src/esplusplayer_capi.cpp
src/plusplayer-core/include_internal/core/trackrendereradapter.h
src/plusplayer-core/src/trackrendereradapter.cpp

index 0440098..aa20820 100644 (file)
@@ -73,6 +73,16 @@ typedef void (*esplusplayer_event_cb)(const esplusplayer_event_type,
 typedef void* esplusplayer_handle;
 
 /**
+ * @brief  Enumerations for the Adaptive info type
+ */
+typedef enum {
+  ESPLUSPLAYER_ADAPT_INFO_TYPE_NONE,
+  ESPLUSPLAYER_ADAPT_INFO_TYPE_DROPPED_FRAMES,
+  ESPLUSPLAYER_ADAPT_INFO_TYPE_DROPPED_VIDEO_FRAMES_FOR_CATCHUP,
+  ESPLUSPLAYER_ADAPT_INFO_TYPE_DROPPED_AUDIO_FRAMES_FOR_CATCHUP,
+} esplusplayer_adaptive_info_type;
+
+/**
  * @brief   Enumerations for low latency mode
  * @remark  Public supports #ESPLUSPLAYER_LOW_LATENCY_MODE_DISABLE_PREROLL only.
  */
@@ -1165,6 +1175,35 @@ int esplusplayer_set_video_stream_info(esplusplayer_handle handle,
 int esplusplayer_get_playing_time(esplusplayer_handle handle, uint64_t* ms);
 
 /**
+ * @brief     Get dropped frame counts in videosink.
+ * @param     [in] handle : esplusplayer handle.
+ * @param     [out] padaptive_info : dropped frame counts.
+ * @param     [in] adaptive_type : type of adaptive info which APP want to get.
+ * @return    @c ESPLUSPLAYER_ERROR_TYPE_NONE on success,otherwise @c one of esplusplayer_error_type
+ *            values will be returned.
+ * @retval    #ESPLUSPLAYER_ERROR_TYPE_NONE Successful
+ * @retval    #ESPLUSPLAYER_ERROR_TYPE_INVALID_PARAMETER Invalid parameter
+ * @retval    #ESPLUSPLAYER_ERROR_TYPE_INVALID_OPERATION Internal operation failed
+ * @code
+ *            prepare esplayer done
+ *            // ... your codes ...
+ *            uint64_t count = 0;
+ *            esplusplayer_get_adaptive_info(esplayer,
+ *                static_cast<void*>(&count),ESPLUSPLAYER_ADAPT_INFO_TYPE_DROPPED_FRAMES);
+ *            // ... your codes ...
+ *            esplusplayer_stop(esplayer);
+ * @endcode
+ * @pre       The player must be one of #ESPLUSPLAYER_STATE_READY,
+ *                   #ESPLUSPLAYER_STATE_PAUSE or #ESPLUSPLAYER_STATE_PLAYING.
+ * @post      None
+ * @exception None
+ * @see       esplusplayer_prepare_async()
+ */
+int esplusplayer_get_adaptive_info(
+    esplusplayer_handle handle, void* padaptive_info,
+    esplusplayer_adaptive_info_type adaptive_type);
+
+/**
  * @brief     Set volume to player
  * @param     [in] handle : esplusplayer handle.
  * @param     [in] volume : volume level(0 ~ 100).
index 02438b1..df5cdfb 100644 (file)
@@ -64,7 +64,16 @@ enum class PacketSubmitStatus {
   kFull,           // buffer already full
   kSuccess         // submit succeeded
 };
-
+/**
+ * @brief  Enumerations for adaptive info type.
+ */
+enum class PlayerAdaptiveInfo {
+  kMinType,
+  kVideoDroppedFrames,
+  kDroppedVideoFramesForCatchup,
+  kDroppedAudioFramesForCatchup,
+  kMaxType,
+};
 /**
  * @brief   Enumerations for low latency mode
  */
@@ -580,6 +589,19 @@ class EsPlusPlayer : private boost::noncopyable {
    */
   virtual bool GetPlayingTime(uint64_t* time_in_milliseconds) { return false; }
   /**
+   * @brief     Get the adaptive info from the plugins
+   * @param     [in] adaptive_type : App wanted get info type
+   * @param     [out] padaptive_info : return value of requested(such as dropped
+   *                   frames)
+   * @pre       The player must be one of #EsState::kPlaying or
+   * #EsState::kPaused or #EsState::kReady
+   * @return    @c True on success, otherwise @c False
+   */
+  virtual bool GetAdaptiveInfo(void* padaptive_info,
+                               const PlayerAdaptiveInfo& adaptive_type) {
+    return false;
+  }
+  /**
    * @brief     Set on mute of the audio sound
    * @param     [in] is_mute : On mute of the sound
    *            (@c true = mute, @c false = non-mute)
index fd22fd2..1990ade 100644 (file)
@@ -85,6 +85,8 @@ class EsPlayer : public EsPlusPlayer {
   bool SetVideoFrameBufferType(DecodedVideoFrameBufferType type) override;
   void RegisterListener(EsEventListener* listener,
                         EsEventListener::UserData userdata) override;
+  bool GetAdaptiveInfo(void* padaptive_info,
+                       const PlayerAdaptiveInfo& adaptive_type) override;
   bool SetVolume(const int& volume) override;
   bool GetVolume(int* volume) override;
   bool Flush(const StreamType& type) override;
index d4ae619..509688b 100644 (file)
@@ -1210,6 +1210,38 @@ void EsPlayer::RegisterListener(EsEventListener* listener,
   eventlistener_userdata_ = userdata;
 }
 
+bool EsPlayer::GetAdaptiveInfo(void* padaptive_info,
+                               const PlayerAdaptiveInfo& adaptive_type) {
+  if (!padaptive_info || adaptive_type <= PlayerAdaptiveInfo::kMinType ||
+      adaptive_type >= PlayerAdaptiveInfo::kMaxType)
+    return false;
+  switch (adaptive_type) {
+    case PlayerAdaptiveInfo::kVideoDroppedFrames:
+      if (state_manager_.GetState() < EsState::kReady) {
+        LOG_ERROR_P(this, "Wrong state, we aren't started yet");
+        return false;
+      }
+      return trackrenderer_->GetDroppedFrames(padaptive_info);
+    case PlayerAdaptiveInfo::kDroppedVideoFramesForCatchup:
+      if (state_manager_.GetState() < EsState::kReady) {
+        LOG_ERROR_P(this, "Wrong state, we aren't started yet");
+        return false;
+      }
+      return trackrenderer_->GetDroppedFramesForCatchup(kTrackTypeVideo,
+                                                        padaptive_info);
+    case PlayerAdaptiveInfo::kDroppedAudioFramesForCatchup:
+      if (state_manager_.GetState() < EsState::kReady) {
+        LOG_ERROR_P(this, "Wrong state, we aren't started yet");
+        return false;
+      }
+      return trackrenderer_->GetDroppedFramesForCatchup(kTrackTypeAudio,
+                                                        padaptive_info);
+    default:
+      break;
+  }
+  return false;
+}
+
 bool EsPlayer::SetVolume(const int& volume) {
   if (volume < internal::kVolumeMin || volume > internal::kVolumeMax) {
     LOG_ERROR_P(this, "Invalid volume level %d", volume);
index cb057de..1b95cb9 100644 (file)
@@ -40,6 +40,7 @@ using plusplayer::EsPacket;
 using plusplayer::EsPacketPtr;
 using plusplayer::EsState;
 using plusplayer::MatroskaColor;
+using plusplayer::PlayerAdaptiveInfo;
 using plusplayer::PlayerLowLatencyMode;
 using plusplayer::StreamType;
 using plusplayer::SubmitDataType;
@@ -1046,6 +1047,18 @@ int esplusplayer_set_video_frame_buffer_type(
   return convert_return_type_(ret);
 }
 
+int esplusplayer_get_adaptive_info(
+    esplusplayer_handle handle, void* padaptive_info,
+    esplusplayer_adaptive_info_type adaptive_type) {
+  // LOG_ENTER_P(cast_(handle))
+  if (is_null_(handle) || is_null_(padaptive_info))
+    return ESPLUSPLAYER_ERROR_TYPE_INVALID_PARAMETER;
+
+  auto ret = cast_(handle)->GetAdaptiveInfo(
+      padaptive_info, static_cast<PlayerAdaptiveInfo>(adaptive_type));
+  return convert_return_type_(ret);
+}
+
 int esplusplayer_set_volume(esplusplayer_handle handle, const int volume) {
   LOG_ENTER_P(cast_(handle))
   if (is_null_(handle)) return ESPLUSPLAYER_ERROR_TYPE_INVALID_PARAMETER;
index c8e8be1..7f7aa54 100644 (file)
@@ -103,6 +103,8 @@ class TrackRendererAdapter {
   bool Seek(uint64_t time_millisecond, double playback_rate, bool audio_mute);
   bool SetPlaybackRate(double playback_rate, bool audio_mute);
   bool GetPlayingTime(uint64_t* curtime_in_msec);
+  bool GetDroppedFrames(void* counts);
+  bool GetDroppedFramesForCatchup(TrackType type, void* counts);
   bool Deactivate(TrackType type);
   bool Activate(TrackType type, const Track& track);
   bool SubmitPacket(const DecoderInputBufferPtr& data);
index dbd5430..72dcf3f 100644 (file)
@@ -140,6 +140,23 @@ bool TrackRendererAdapter::GetPlayingTime(uint64_t* time_millisecond) {
   return true;
 }
 
+bool TrackRendererAdapter::GetDroppedFrames(void* counts) {
+  if (trackrenderer_get_dropped_frames(handle_, counts) == kFailed) {
+    return false;
+  }
+  return true;
+}
+
+bool TrackRendererAdapter::GetDroppedFramesForCatchup(TrackType type,
+                                                      void* counts) {
+  if (trackrenderer_get_dropped_frames_for_catchup(
+          handle_, adapter_utils::ConvertToTrackRendererTrackType(type),
+          counts) == kFailed) {
+    return false;
+  }
+  return true;
+}
+
 bool TrackRendererAdapter::Deactivate(TrackType type) {
   if (trackrenderer_deactivate(
           handle_, adapter_utils::ConvertToTrackRendererTrackType(type)) ==