MGh
May 31, 2021, 3:21am
1
Hi,
I was wondering where I can find the implementation of Pause, Resume in the deep stream pipeline? Since when I run the pipeline I see in the output that press P for pause press R for resume. I would like to find the code in which this is implemented and rather than keystroke change it to a signal that I define myself.
Thanks
Mahshid
Hi @MGh
In the Deepstream C++ sample app, there is event_thread_func named function to do this. In the main function, this thread function added before g_main_loop_run:
g_timeout_add (40, event_thread_func, NULL);
g_main_loop_run (main_loop);
In event_thread_func, this implementation is at the end of the function in the switch-case statement
static guint rrow, rcol;
static gboolean rrowsel = FALSE, selecting = FALSE;
/**
* Loop function to check keyboard inputs and status of each pipeline.
*/
static gboolean
event_thread_func (gpointer arg)
{
guint i;
gboolean ret = TRUE;
// Check if all instances have quit
for (i = 0; i < num_instances; i++) {
if (!appCtx[i]->quit)
break;
}
if (i == num_instances) {
quit = TRUE;
g_main_loop_quit (main_loop);
return FALSE;
}
// Check for keyboard input
if (!kbhit ()) {
//continue;
return TRUE;
}
int c = fgetc (stdin);
g_print ("\n");
gint source_id;
GstElement *tiler = appCtx[0]->pipeline.tiled_display_bin.tiler;
g_object_get (G_OBJECT (tiler), "show-source", &source_id, NULL);
if (selecting) {
if (rrowsel == FALSE) {
if (c >= '0' && c <= '9') {
rrow = c - '0';
if (rrow < appCtx[0]->config.tiled_display_config.rows){
g_print ("--selecting source row %d--\n", rrow);
rrowsel = TRUE;
}else{
g_print ("--selected source row %d out of bound, reenter\n", rrow);
}
}
} else {
if (c >= '0' && c <= '9') {
unsigned int tile_num_columns = appCtx[0]->config.tiled_display_config.columns;
rcol = c - '0';
if (rcol < tile_num_columns){
selecting = FALSE;
rrowsel = FALSE;
source_id = tile_num_columns * rrow + rcol;
g_print ("--selecting source col %d sou=%d--\n", rcol, source_id);
if (source_id >= (gint) appCtx[0]->config.num_source_sub_bins) {
source_id = -1;
} else {
source_ids[0] = source_id;
appCtx[0]->show_bbox_text = TRUE;
g_object_set (G_OBJECT (tiler), "show-source", source_id, NULL);
}
}else{
g_print ("--selected source col %d out of bound, reenter\n", rcol);
}
}
}
}
switch (c) {
case 'h':
print_runtime_commands ();
break;
case 'p':
for (i = 0; i < num_instances; i++)
pause_pipeline (appCtx[i]);
break;
case 'r':
for (i = 0; i < num_instances; i++)
resume_pipeline (appCtx[i]);
break;
case 'q':
quit = TRUE;
g_main_loop_quit (main_loop);
ret = FALSE;
break;
case 'z':
if (source_id == -1 && selecting == FALSE) {
g_print ("--selecting source --\n");
selecting = TRUE;
} else {
if (!show_bbox_text)
appCtx[0]->show_bbox_text = FALSE;
g_object_set (G_OBJECT (tiler), "show-source", -1, NULL);
source_ids[0] = -1;
selecting = FALSE;
g_print ("--tiled mode --\n");
}
break;
default:
break;
}
return ret;
}
Regards
MGh
May 31, 2021, 2:41pm
4
Hi @mehmetdeniz ,
Thanks a lot. This is what I was looking for.
Regards
Mahshid