Skip to content

Commit

Permalink
[CodeClean] util function to get stream-id
Browse files Browse the repository at this point in the history
Remove random number, use util function to get new stream-id.

Signed-off-by: Jaeyun Jung <[email protected]>
  • Loading branch information
jaeyun-jung committed Sep 15, 2023
1 parent 239dbcd commit b139fbd
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
9 changes: 4 additions & 5 deletions gst/nnstreamer/elements/gsttensor_crop.c
Original file line number Diff line number Diff line change
Expand Up @@ -444,13 +444,12 @@ gst_tensor_crop_negotiate (GstTensorCrop * self)
GSList *walk;

if (self->send_stream_start) {
gchar *sid;
g_autofree gchar *element_name = gst_element_get_name (self);
g_autofree gchar *pad_name = gst_pad_get_name (self->srcpad);
g_autofree gchar *sid = gst_pad_create_stream_id_printf (self->srcpad,
GST_ELEMENT_CAST (self), "%s-nnscrop-%s", element_name, pad_name);

sid = g_strdup_printf ("%s-%08x",
GST_ELEMENT_NAME (self), g_random_int ());
gst_pad_push_event (self->srcpad, gst_event_new_stream_start (sid));
g_free (sid);

self->send_stream_start = FALSE;
}

Expand Down
12 changes: 8 additions & 4 deletions gst/nnstreamer/elements/gsttensor_merge.c
Original file line number Diff line number Diff line change
Expand Up @@ -675,10 +675,14 @@ gst_tensor_merge_collected (GstCollectPads * pads,
GST_DEBUG_OBJECT (tensor_merge, " all pads are collected ");

if (tensor_merge->need_stream_start) {
gchar s_id[32];
g_snprintf (s_id, sizeof (s_id), " tensormerge - %08x ", g_random_int ());
gst_pad_push_event (tensor_merge->srcpad,
gst_event_new_stream_start (s_id));
g_autofree gchar *element_name = gst_element_get_name (tensor_merge);
g_autofree gchar *pad_name = gst_pad_get_name (tensor_merge->srcpad);
g_autofree gchar *sid =
gst_pad_create_stream_id_printf (tensor_merge->srcpad,
GST_ELEMENT_CAST (tensor_merge), "%s-nnsmerge-%s", element_name,
pad_name);

gst_pad_push_event (tensor_merge->srcpad, gst_event_new_stream_start (sid));
tensor_merge->need_stream_start = FALSE;
}

Expand Down
9 changes: 6 additions & 3 deletions gst/nnstreamer/elements/gsttensor_mux.c
Original file line number Diff line number Diff line change
Expand Up @@ -492,9 +492,12 @@ gst_tensor_mux_collected (GstCollectPads * pads, GstTensorMux * tensor_mux)
GST_DEBUG_OBJECT (tensor_mux, " all pads are collected ");

if (tensor_mux->need_stream_start) {
gchar s_id[32];
g_snprintf (s_id, sizeof (s_id), " tensormux - %08x ", g_random_int ());
gst_pad_push_event (tensor_mux->srcpad, gst_event_new_stream_start (s_id));
g_autofree gchar *element_name = gst_element_get_name (tensor_mux);
g_autofree gchar *pad_name = gst_pad_get_name (tensor_mux->srcpad);
g_autofree gchar *sid = gst_pad_create_stream_id_printf (tensor_mux->srcpad,
GST_ELEMENT_CAST (tensor_mux), "%s-nnsmux-%s", element_name, pad_name);

gst_pad_push_event (tensor_mux->srcpad, gst_event_new_stream_start (sid));
tensor_mux->need_stream_start = FALSE;
}

Expand Down

0 comments on commit b139fbd

Please sign in to comment.