int trackrenderer_get_playing_time(TrackRendererHandle handle,
uint64_t* time_millisecond);
+/**
+ * @brief Get dropped frame counts in videosink
+ * @description In this function trackrenderer get currently dropped frames in
+ * sink.
+ * @param [in] handle : trackrenderer handle ptr.
+ * @param [out] counts : dropped counts
+ * @return Return 0 if trackrenderer successfully get frame counts.
+ * Otherwise -1.
+ * @code
+ * //prepare trackrenderer hanle
+ * //your logic
+ * uint64_t count = 0;
+ * trackrenderer_get_dropped_frames(handle,static_cast<void*>(&count)));
+ * //your logic
+ * trackrenderer_stop(handle);
+ * @endcode
+ * @pre The trackrenderer must be at least created and set up.
+ * @post None
+ * @exception None.
+ * @version 2.0
+ * @remark None
+ * @see trackrenderer_create() \n
+ * trackrenderer_prepare()
+ */
+int trackrenderer_get_dropped_frames(TrackRendererHandle handle, void* counts);
+
+/**
+ * @brief Get dropped frame counts for catchup in video/audio sink
+ * @description In this function trackrenderer get dropped frames for catchup
+ * in sink.
+ * @param [in] handle : trackrenderer handle ptr.
+ * @param [in] type : the type of the track
+ * @param [out] counts : dropped counts
+ * @return Return 0 if trackrenderer successfully get frame counts.
+ * Otherwise -1.
+ * @code
+ * //prepare trackrenderer hanle
+ * //your logic
+ * uint64_t dropped_video_frames = 0;
+ * trackrenderer_get_dropped_frames_for_catchup(handle,
+ * TrackRendererTrackType::kTrackRendererTrackTypeVideo,
+ * static_cast<void*>(&dropped_video_frames)));
+ * //your logic
+ * trackrenderer_stop(handle);
+ * @endcode
+ * @pre The trackrenderer must be at least created and set up.
+ * @post None
+ * @exception None.
+ * @version 3.0
+ * @remark None
+ * @see trackrenderer_create() \n
+ * trackrenderer_prepare()
+ */
+int trackrenderer_get_dropped_frames_for_catchup(TrackRendererHandle handle,
+ TrackRendererTrackType type,
+ void* counts);
+
/**
* @brief Flush buffers for a trackrenderer.
* @description In this function trackrenderer will flush data in
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* frame_counts);
+ bool GetDroppedFramesForCatchup(TrackType type, void* frame_counts);
bool Deactivate(TrackType type);
bool Activate(TrackType type, const Track& track);
bool SubmitPacket(const DecoderInputBufferPtr& data,
return true;
}
+bool TrackRenderer::GetDroppedFrames(void* frame_counts) {
+ std::lock_guard<std::mutex> lk(resource_m_);
+ if (state_ == State::kStopped) return false;
+ if (!pipeline_) return false;
+ uint64_t drop_count = 0;
+ Elements element = Elements::kSinkVideo;
+ GstStructure *stats = nullptr;
+
+ pipeline_->GetProperty(element, "stats", &stats);
+ if(!stats) {
+ TRACKRENDERER_WARN("stats is null");
+ return false;
+ }
+
+ gst_structure_get_uint64(stats, "dropped", &drop_count);
+ gst_structure_free(stats);
+
+ TRACKRENDERER_INFO("dropped %" PRIu64, drop_count);
+
+ *(int64_t*)frame_counts = drop_count;
+
+ return true;
+}
+
+bool TrackRenderer::GetDroppedFramesForCatchup(TrackType type,
+ void* frame_counts) {
+ std::lock_guard<std::mutex> lk(resource_m_);
+ if (state_ == State::kStopped) return false;
+ if (!pipeline_) return false;
+ uint64_t drop_count = 0;
+ Elements video_element = Elements::kSinkVideo;
+ Elements audio_element = Elements::kSinkAudio;
+ GstStructure *stats = nullptr;
+
+ if (type == kTrackTypeAudio)
+ pipeline_->GetProperty(audio_element, "stats", &stats);
+ else if (type == kTrackTypeVideo)
+ pipeline_->GetProperty(video_element, "stats", &stats);
+
+ if(!stats) {
+ TRACKRENDERER_WARN("stats is null");
+ return false;
+ }
+
+ gst_structure_get_uint64(stats, "dropped", &drop_count);
+ gst_structure_free(stats);
+
+ TRACKRENDERER_INFO("dropped %" PRIu64, drop_count);
+
+ *(int64_t*)frame_counts = drop_count;
+
+ return true;
+}
+
bool TrackRenderer::SetDisplayMode(const DisplayMode& mode) {
std::lock_guard<std::mutex> lk(resource_m_);
if (state_ == State::kStopped) return false;
return kSuccess;
}
+int trackrenderer_get_dropped_frames(TrackRendererHandle handle, void* counts) {
+ auto priv = static_cast<TrackRendererPrivPtr>(handle);
+ if (!priv) return kFailed;
+ if (priv->renderer->GetDroppedFrames(counts) == false) {
+ return kFailed;
+ }
+ return kSuccess;
+}
+
+int trackrenderer_get_dropped_frames_for_catchup(TrackRendererHandle handle,
+ TrackRendererTrackType type,
+ void* counts) {
+ auto priv = static_cast<TrackRendererPrivPtr>(handle);
+ if (!priv) return kFailed;
+ if (priv->renderer->GetDroppedFramesForCatchup(
+ plusplayer::trackrenderer::capi_utils::ConvertToTrackType(type),
+ counts) == false) {
+ return kFailed;
+ }
+ return kSuccess;
+}
+
using TrackType = plusplayer::trackrenderer::TrackType;
int trackrenderer_deactivate(TrackRendererHandle handle,