Add event function

This commit is contained in:
Barzan Hayati 2025-07-01 14:21:52 +00:00
parent 93ed240a0a
commit cd754380a3
2 changed files with 30 additions and 0 deletions

View File

@ -120,6 +120,23 @@ bool PipelineManager::setup_pipeline() {
return true;
}
gboolean PipelineManager::event_thread_func(gpointer arg) {
DataPointer* data = static_cast<DataPointer*>(arg);
// show which source camera. called every 4o ms.
// if (value==true){
// gst_element_set_state (pipeline, GST_STATE_PAUSED);
// gst_element_set_state (pipeline, GST_STATE_PLAYING);
// IMPORTANT:
guint show_source = -1; // which source to show: should be an integer
// between the range (0, num_sources-1)
// to show the selected source number only.
// choose show_source=-1 to show the results for all the videos at once
g_object_set(G_OBJECT(data->tiler_manager->tiler), "show-source",
show_source, NULL);
return true;
}
bool PipelineManager::create_pipeline_elements(int num_sources,
char** url_camera) {
streammux_manager->create_streammux(num_sources);
@ -168,5 +185,12 @@ bool PipelineManager::create_pipeline_elements(int num_sources,
playing_pipeline(num_sources, url_camera);
rtsp_streaming_manager->start_rtsp_streaming();
/* Wait till pipeline encounters an error or EOS */
g_print("Running... \n");
// event executed every 40 ms for selecting show_source
DataPointer* pointer_data = new DataPointer{tiler_manager};
g_timeout_add(40, event_thread_func, pointer_data); // NULL
return true;
}

View File

@ -31,9 +31,14 @@ class PipelineManager {
MessageHandling *message_handling = new MessageHandling();
RtspStreamingManager *rtsp_streaming_manager = new RtspStreamingManager();
typedef struct {
TilerManager *tiler_manager;
} DataPointer;
public:
int current_device = -1;
struct cudaDeviceProp prop;
QueueManager queue_array[5];
PipelineManager();
PipelineManager(int, char **);
@ -42,5 +47,6 @@ class PipelineManager {
bool setup_pipeline();
void playing_pipeline(int, char **);
void set_cuda_device();
static gboolean event_thread_func(gpointer);
~PipelineManager();
};