Check playing pipeline

This commit is contained in:
Barzan Hayati 2025-07-01 23:01:34 +00:00
parent be3aed33ba
commit 716474f473
2 changed files with 28 additions and 0 deletions

View File

@ -63,6 +63,19 @@ void PipelineManager::playing_pipeline(int num_sources, char** url_camera) {
gst_element_set_state(pipeline, GST_STATE_PLAYING);
}
void PipelineManager::check_playing_pipeline() {
// Verify pipeline state (add this immediately after starting)
GstState state;
GstStateChangeReturn ret =
gst_element_get_state(pipeline, &state, NULL, GST_CLOCK_TIME_NONE);
if (ret == GST_STATE_CHANGE_FAILURE) {
g_printerr("Failed to start pipeline!\n");
} else {
g_print("Pipeline state: %d (1=NULL, 2=READY, 3=PAUSED, 4=PLAYING)\n",
state);
}
}
GstPadProbeReturn PipelineManager::buffer_probe(GstPad* pad,
GstPadProbeInfo* info,
gpointer user_data) {
@ -156,6 +169,14 @@ bool PipelineManager::setup_pipeline() {
return true;
}
gboolean PipelineManager::check_pipeline_state(gpointer user_data) {
GstElement* pipeline = (GstElement*)user_data;
GstState state;
gst_element_get_state(pipeline, &state, NULL, GST_CLOCK_TIME_NONE);
g_print("Pipeline state (periodic check): %d\n", state);
return G_SOURCE_CONTINUE; // Keep timer active
}
gboolean PipelineManager::event_thread_func(gpointer arg) {
DataPointer* data = static_cast<DataPointer*>(arg);
// show which source camera. called every 4o ms.
@ -226,6 +247,9 @@ bool PipelineManager::create_pipeline_elements(int num_sources,
gst_object_unref(sink_pad);
playing_pipeline(num_sources, url_camera);
check_playing_pipeline();
rtsp_streaming_manager->start_rtsp_streaming();
/* Wait till pipeline encounters an error or EOS */
@ -234,6 +258,8 @@ bool PipelineManager::create_pipeline_elements(int num_sources,
DataPointer* pointer_data = new DataPointer{tiler_manager};
g_timeout_add(40, event_thread_func, pointer_data); // NULL
g_timeout_add_seconds(1, check_pipeline_state,
pipeline); // Check every 5 seconds
message_handling->pipeline_is_run = true;

View File

@ -52,5 +52,7 @@ class PipelineManager {
static GstPadProbeReturn buffer_probe(GstPad *, GstPadProbeInfo *,
gpointer);
static gboolean event_thread_func(gpointer);
static gboolean check_pipeline_state(gpointer);
void check_playing_pipeline();
~PipelineManager();
};