Getting source stream ID from nvosd plugin

I have successfully run deepstream3_example with N number of uri. Now I am trying to get information like source stream ID from nvosd plugin through buffer probe. I have added probe like this:

g_object_set (G_OBJECT (streammux), "width", MUXER_OUTPUT_WIDTH, "height",
          MUXER_OUTPUT_HEIGHT, "batch-size", num_sources,
          "batched-push-timeout", MUXER_BATCH_TIMEOUT_USEC, NULL);
gst_element_link_many (streammux, pgie, tiler, nvvidconv, nvosd, transform, sink,NULL)
tiler_src_pad = gst_element_get_static_pad (nvosd, "src");

gst_pad_add_probe (tiler_src_pad, GST_PAD_PROBE_TYPE_BUFFER,
            tiler_src_pad_buffer_probe, NULL, NULL);

From buffer probe, which metadata contains this stream_id info? I am confused with the metadata received…

static GstPadProbeReturn tiler_src_pad_buffer_probe (GstPad * pad, GstPadProbeInfo * info, gpointer u_data)
    GstBuffer *buf = (GstBuffer *) info->data;

    long int src_id = (gulong) info->id;

    printf(" Source ID = %d", src_id);

    return GST_PAD_PROBE_OK;

This always prints “1” . But I needed the specific source_id that has been muxed with streammux.

The source_id in gstnvinfer.cpp → gst_nvinfer_sink_event()
is the sequence order of source adding

For example,
In application:

gchar pad_name_sink[16] = "sink_<b>2</b>";
sinkpad = gst_element_get_request_pad (streammux, pad_name_sink);

In streammux,

sscanf (name, "sink_%u", &stream_index);
pad_data->pad_id = stream_index;
frame_meta->source_id = pad_data->pad_id;

So this source id is 2
source_id is in NvDsFrameMeta

When I try to access source_id using :

frame_meta = (NvDsFrameMeta *) (l_frame->data);
      NvOSD_RectParams rect_params;
      guint source_id_info = frame_meta->source_id;

I get null , just to be on the same page , I want to access either uri or some some source id which helps me to find this frame belongs to specific camera.

this is my config example of source :

#Type - 1=CameraV4L2 2=URI 3=MultiURI 4=RTSP
# (0): memtype_device   - Memory type Device
# (1): memtype_pinned   - Memory type Host Pinned
# (2): memtype_unified  - Memory type Unified


I am also trying the same but instead of getting null I’m getting ‘0’, I’m using the sample-app\deepstream-app … any ideas what it could be ? Happy to paste code if needed.


Can you create a new topic?

I want to get the target location information of multiple sources in deepstream-app. Can you tell me how your code has changed? Thank you

Hi Chris,
Where should I put this piece of code? Thanks.