Add fps buffer probe
This commit is contained in:
parent
f0d8a7b18b
commit
e719e9ace8
@ -63,6 +63,30 @@ void PipelineManager::playing_pipeline(int num_sources, char** url_camera) {
|
||||
gst_element_set_state(pipeline, GST_STATE_PLAYING);
|
||||
}
|
||||
|
||||
GstPadProbeReturn PipelineManager::buffer_probe(GstPad* pad,
|
||||
GstPadProbeInfo* info,
|
||||
gpointer user_data) {
|
||||
(void)pad; // This explicitly marks it as unused
|
||||
(void)info; // This explicitly marks it as unused
|
||||
(void)user_data; // This explicitly marks it as unused
|
||||
static guint frame_count = 0;
|
||||
static auto last_time = std::chrono::steady_clock::now();
|
||||
|
||||
frame_count++;
|
||||
auto current_time = std::chrono::steady_clock::now();
|
||||
auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
current_time - last_time)
|
||||
.count();
|
||||
|
||||
if (elapsed >= 1000) { // Update every second
|
||||
g_print("FPS: %ld\n", frame_count * 1000 / elapsed);
|
||||
frame_count = 0;
|
||||
last_time = current_time;
|
||||
}
|
||||
|
||||
return GST_PAD_PROBE_OK;
|
||||
}
|
||||
|
||||
bool PipelineManager::setup_pipeline() {
|
||||
/* Set up the pipeline */
|
||||
/* add all elements into the pipeline */
|
||||
@ -182,6 +206,13 @@ bool PipelineManager::create_pipeline_elements(int num_sources,
|
||||
message_handling->create_message_handler(pipeline, g_run_forever, loop);
|
||||
setup_pipeline();
|
||||
|
||||
// --- BUFFER PROBE FOR FPS ---
|
||||
GstPad* sink_pad = gst_element_get_static_pad(
|
||||
nv_video_convert_manager->nvvidconv, "src"); // Or any element's pad
|
||||
gst_pad_add_probe(sink_pad, GST_PAD_PROBE_TYPE_BUFFER, buffer_probe, NULL,
|
||||
NULL);
|
||||
gst_object_unref(sink_pad);
|
||||
|
||||
playing_pipeline(num_sources, url_camera);
|
||||
rtsp_streaming_manager->start_rtsp_streaming();
|
||||
|
||||
|
||||
@ -47,6 +47,8 @@ class PipelineManager {
|
||||
bool setup_pipeline();
|
||||
void playing_pipeline(int, char **);
|
||||
void set_cuda_device();
|
||||
static GstPadProbeReturn buffer_probe(GstPad *, GstPadProbeInfo *,
|
||||
gpointer);
|
||||
static gboolean event_thread_func(gpointer);
|
||||
~PipelineManager();
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user