title: Gstreamer RTSP `gst-launch-1.0` Equivalent C Code
body: <p>I am currently working on a project using NVIDIA Deepstream that involves GStreamer. When I tried to change the source element from "filesrc" element to "rtspsrc" element and adding on "rtph264depay" and "queue", it resulted in</p>
  
  <pre><code>0:00:09.533730268 19680 0x7fc02c0025e0 WARN                 basesrc gstbasesrc.c:2948:gst_base_src_loop:&lt;udpsrc0&gt; error: Internal data flow error.
  0:00:09.533772178 19680 0x7fc02c0025e0 WARN                 basesrc gstbasesrc.c:2948:gst_base_src_loop:&lt;udpsrc0&gt; error: streaming task paused, reason not-linked (-1)
  ERROR from element udpsrc0: Internal data flow error.
  Error: Internal data flow 
  </code></pre>
  
  <p>I thought this might have been caused due to the codes preceding (TCP server connection) or following (NVIDIA hardware utilizing elements) the "source" element. To test that I was on the right direction, I tried running</p>
  
  <pre><code>gst-launch-1.0 rtspsrc location=rtsp://192.168.0.71:8554/h264ESVideoTest ! rtph264depay ! queue ! h264parse ! avdec_h264 ! videoconvert ! videoscale ! autovideosink 
  </code></pre>
  
  <p>which managed to show the stream and at the same time its equivalent code in C as attached below </p>
  
  <pre><code>#include &lt;gst/gst.h&gt;
  #include &lt;glib.h&gt;
  
  static gboolean
  bus_call (GstBus * bus, GstMessage * msg, gpointer data)
  {
    GMainLoop *loop = (GMainLoop *) data;
    switch (GST_MESSAGE_TYPE (msg)) {
      case GST_MESSAGE_EOS:
        g_print ("End of stream\n");
        g_main_loop_quit (loop);
        break;
      case GST_MESSAGE_ERROR:{
        gchar *debug;
        GError *error;
        gst_message_parse_error (msg, &amp;error, &amp;debug);
        g_printerr ("ERROR from element %s: %s\n",
            GST_OBJECT_NAME (msg-&gt;src), error-&gt;message);
        g_free (debug);
        g_printerr ("Error: %s\n", error-&gt;message);
        g_error_free (error);
        g_main_loop_quit (loop);
        break;
      }
      default:
        break;
    }
    return TRUE;
  }
  
  int
  main (int argc, char *argv[])
  {
    GMainLoop *loop = NULL;
    GstElement *pipeline = NULL, 
               *source = NULL, 
               *rtpdepay = NULL,
               *vidqueue = NULL,
               *h264parser = NULL,
               *decoder = NULL, 
               *vidconvert = NULL, 
               *vidscale = NULL, 
               *sink = NULL;
  
    GstBus *bus = NULL;
    guint bus_watch_id;
    GstCaps *caps1 = NULL, *caps2 = NULL;
    gulong osd_probe_id = 0;
    GstPad *osd_sink_pad = NULL;
  
    /* GStreamer initialization */
    gst_init (&amp;argc, &amp;argv);
    loop = g_main_loop_new (NULL, FALSE);
  
    /* Create gstreamer elements */
    pipeline = gst_pipeline_new ("pipeline");
    source = gst_element_factory_make ("rtspsrc", "file-source");
    rtpdepay = gst_element_factory_make ("rtph264depay", "rtpdepay");
    vidqueue = gst_element_factory_make ("queue", "vidqueue");
    h264parser = gst_element_factory_make ("h264parse", "h264parser");
    decoder = gst_element_factory_make ("avdec_h264", "avh264decoder");
    vidconvert = gst_element_factory_make ("videoconvert", "vidconvert");
    vidscale = gst_element_factory_make ("videoscale", "vidscale");
    sink = gst_element_factory_make ("autovideosink", "sink");
  
    /* Check elements creation */
    if (!pipeline   || 
        !source     || 
        !rtpdepay   || 
        !vidqueue   ||
        !h264parser || 
        !decoder    || 
        !vidconvert || 
        !vidscale   || 
        !sink) {
      g_printerr ("One or more element could not be created. Exiting.\n");
      return -1;
    }
  
    /* Set input location to the source element */
    g_object_set (G_OBJECT (source), "location", argv[1], NULL);
  
    /* Add a message handler */
    bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
    bus_watch_id = gst_bus_add_watch (bus, bus_call, loop);
    gst_object_unref (bus);
  
    /* Set up the pipeline */
    /* Add all elements into the pipeline */
    gst_bin_add_many (GST_BIN (pipeline),
                      source, 
                      rtpdepay, 
                      vidqueue,  
                      h264parser, 
                      decoder, 
                      vidconvert, 
                      vidscale, 
                      sink, 
                      NULL);
  
    /* Link the elements together */
    gst_element_link_many (source, 
                           rtpdepay, 
                           vidqueue,  
                           h264parser, 
                           decoder, 
                           vidconvert, 
                           vidscale, 
                           sink, 
                           NULL);
  
    /* Set the pipeline to "playing" state */
    g_print ("Now playing: %s\n", argv[1]);
    gst_element_set_state (pipeline, GST_STATE_PLAYING);
  
    /* Wait till pipeline encounters an error or EOS */
    g_print ("Running...\n");
    g_main_loop_run (loop);
  
    /* Out of the main loop */
    g_print ("Returned, stopping playback\n");
    gst_element_set_state (pipeline, GST_STATE_NULL);
    g_print ("Deleting pipeline\n");
    gst_object_unref (GST_OBJECT (pipeline));
    g_source_remove (bus_watch_id);
    g_main_loop_unref (loop);
    return 0;
  }
  </code></pre>
  
  <p>which resulted in the same error as before.</p>
  
  <p>I was under the impression that any properties that doesn't require setting inside the <code>gst-launch-1.0</code> command would not require its equivalent in C code as well. Are there any properties of "rtspsrc" that requires setting in C but <code>gst-launch-1.0</code> does automatically? Or am I making another kind of mistake altogether?</p>
  
  <p>EDIT1:
  attached is the explicit error log for the C code</p>
  
  <pre><code>0:00:00.095045906 19967 0x7f60c401d8f0 FIXME                default gstutils.c:3766:gst_pad_create_stream_id_internal:&lt;fakesrc0:src&gt; Creating random stream-id, consider implementing a deterministic way of creating a stream-id
  0:00:00.135622983 19967 0x7f60b80031e0 WARN                 basesrc gstbasesrc.c:2948:gst_base_src_loop:&lt;udpsrc1&gt; error: Internal data flow error.
  0:00:00.135662497 19967 0x7f60b80031e0 WARN                 basesrc gstbasesrc.c:2948:gst_base_src_loop:&lt;udpsrc1&gt; error: streaming task paused, reason not-linked (-1)
  ERROR from element udpsrc1: Internal data flow error.
  Error: Internal data flow error.
  Returned, stopping playback
  0:00:00.136197250 19967      0x1c9ba30 WARN                 rtspsrc gstrtspsrc.c:5483:gst_rtspsrc_try_send:&lt;file-source&gt; send interrupted
  0:00:00.136228722 19967      0x1c9ba30 WARN                 rtspsrc gstrtspsrc.c:7552:gst_rtspsrc_pause:&lt;file-source&gt; PAUSE interrupted
  </code></pre>