Gstreamer RTSP src element name

rajvik kamdar.rajvi at gmail.com
Tue Jan 24 14:45:43 UTC 2017


It gets into the ifelse condition. Still facing error:
name of caps string: application/x-rtp, media=(string)video,
payload=(int)96, clock-rate=(int)90000, encoding-name=(string)H264,
packetization-mode=(string)1, profile-level-id=(string)42801e,
sprop-parameter-sets=(str
ing)"Z0KAHpZWDY/yf/gACAAKhAAAD6QAA6mDgAAC3GAAFuNvxjg7QsXc\,aMqNSA\=\=",
a-tool=(string)"vlc\ 2.1.6", a-recvonly=(string)"",
a-type=(string)broadcast, a-charset=(string)UTF-8, ssrc=(uint)3197239660,
clock-base=(uint)22
81054233, seqnum-base=(uint)15975, npt-start=(guint64)7813930284000,
play-speed=(double)1, play-scale=(double)1
name of caps struct string: application/x-rtp
name of caps string: application/x-rtp, media=(string)audio,
payload=(int)96, clock-rate=(int)44100,
encoding-name=(string)MPEG4-GENERIC, encoding-params=(string)2,
streamtype=(string)5, profile-level-id=(string)15, m
ode=(string)AAC-hbr, config=(string)1210, sizelength=(string)13,
indexlength=(string)3, indexdeltalength=(string)3, profile=(string)1,
a-tool=(string)"vlc\ 2.1.6", a-recvonly=(string)"",
a-type=(string)broadcast, a-ch
arset=(string)UTF-8, ssrc=(uint)358833443, clock-base=(uint)1031817228,
seqnum-base=(uint)16576, npt-start=(guint64)7813930284000,
play-speed=(double)1, play-scale=(double)1
0:00:00.795704054  2728   0x188430 WARN                 basesrc
gstbasesrc.c:2933:gst_base_src_loop:<udpsrc1> error: Internal data flow
error.
0:00:00.812515845  2728   0x188430 WARN                 basesrc
gstbasesrc.c:2933:gst_base_src_loop:<udpsrc1> error: streaming task paused,
reason not-linked (-1)



Any idea as to how to move forward with this?
Code snippet:

GstElement *audioQueue, *videoQueue;
GstElement *source, *audio, *video, *convert, *pipeline, *audioDepay,
           *audioParse, *audioDecode, *audioConvert, *audioResample,
*audioSink, *videoDepay, *videoParser, *videoDecode, *videoConvert,
*videoScale, *videoSink;

static void onPadAdded(GstElement *element, GstPad *pad, gpointer data)
{
        GstCaps *caps;
        const char *name;
        char *capsName;
        caps = gst_pad_get_current_caps(pad);
        GstStructure *str = gst_caps_get_structure(caps, 0);
        name = gst_structure_get_name(str);
        g_print("name of caps struct string: %s \n", name);
        capsName = gst_caps_to_string(caps);
        g_print("name of caps string: %s \n", capsName);
        if (g_strrstr(capsName,"audio"))
        {
                GstPad *dynamic_pad =
gst_element_get_static_pad(audioQueue, "sink");
                gst_pad_link(pad, dynamic_pad);
        }

        else if (g_strrstr(capsName, "video"))
        {
                GstPad *video_dynamic_pad =
gst_element_get_static_pad(videoQueue, "sink");
                gst_pad_link(pad, video_dynamic_pad);
        }
        g_free(capsName);

}



int main(int argc, char *argv[]) {
        GstCaps *capsFilter;
        GstBus *bus;
        GstMessage *msg;
        GstPad *pad;
        gboolean link_ok;
        GstStateChangeReturn ret;

        /* Initialize GStreamer */
        gst_init (&argc, &argv);


        /* Create Elements */
        pipeline = gst_pipeline_new("rtsp-pipeline");
        source = gst_element_factory_make ("rtspsrc", "rtsp-source");
        g_object_set(source, "location", "rtsp://192.168.3.30:8554/rajvi",
NULL);
        g_object_set(source, "latency", 0, NULL);

        audioQueue = gst_element_factory_make ("queue", "audio-queue");
        audioDepay = gst_element_factory_make ("rtpmp4gdepay",
"audio-depayer");
        audioParse = gst_element_factory_make ("aacparse", "audio-parser");
        audioDecode = gst_element_factory_make ("avdec_aac",
"audio-decoder");
        audioConvert = gst_element_factory_make ("audioconvert", "aconv");
        audioResample = gst_element_factory_make ("audioresample",
"audio-resample");
        audioSink = gst_element_factory_make ("autoaudiosink", "audiosink");

        if (!audioQueue || !audioDepay || !audioParse || !audioConvert ||
!audioResample || !audioSink)
        {
                g_printerr("Cannot create audio elements \n");
                return 0;
        }
        videoQueue = gst_element_factory_make ("queue", "video-queue");
        videoDepay= gst_element_factory_make ("rtph264depay",
"video-depay");
        videoParser = gst_element_factory_make ("h264parse",
"video-parser");
        videoDecode = gst_element_factory_make ("omxh264dec",
"video-decoder");
        videoConvert = gst_element_factory_make("videoconvert", "convert");
        videoScale = gst_element_factory_make("videoscale", "video-scale");
        videoSink = gst_element_factory_make("ximagesink", "video-sink");
        capsFilter = gst_caps_new_simple("video/x-raw",
                        "width", G_TYPE_INT, 176,
                        "height", G_TYPE_INT, 144,
                        NULL);

        if (!videoQueue || !videoDepay || !videoParser || !videoDecode ||
!videoConvert || !videoScale || !videoSink || !capsFilter)
        {
                g_printerr("Cannot create video elements \n");
                return 0;
        }
        gst_bin_add(GST_BIN(pipeline), source);
        gst_bin_add_many(GST_BIN(pipeline),
                        audioQueue, audioDepay, audioParse, audioDecode,
audioConvert, audioResample, audioSink,
                        videoQueue, videoDepay, videoParser, videoDecode,
videoConvert, videoScale, videoSink, NULL);

        if (!gst_element_link_many(audioQueue, audioDepay,  NULL ))
        {
                g_printerr("Cannot link audioqueue  and audioDepay \n");
                return 0;
        }
        if (!gst_element_link_many(audioParse, audioDecode, NULL ))
        {
                g_printerr("Cannot link audioParse and audiodecode \n");
                return 0;
        }
        if (!gst_element_link_many( audioConvert, audioResample, audioSink,
NULL ))
        {
                g_printerr("Cannot link audioConvert, audioParse, audioSink
\n");
                return 0;
        }


        /*Linking filter element to videoScale and videoSink */
        link_ok = gst_element_link_filtered(videoScale,videoSink,
capsFilter);
        gst_caps_unref (capsFilter);
        if (!link_ok) {
                g_warning ("Failed to link element1 and element2!");
                return 0;
        }
        /* Linking video elements internally */
        if (!gst_element_link_many(videoQueue, videoDepay,  NULL))
        {
                g_printerr("Cannot link videoQueue and videoDepay \n");
                return 0;
        }
        if (!gst_element_link_many(videoParser, videoDecode, videoConvert,
NULL))
        {
                g_printerr("Cannot link videoParser, videoDecode,
videoConvert \n");
                return 0;
        }
        g_signal_connect(source, "pad-added", G_CALLBACK(onPadAdded), NULL);

          /* Start playing */
        gst_element_set_state ( pipeline, GST_STATE_PLAYING);

        /* Wait until error or EOS */
        bus = gst_element_get_bus (pipeline);
        msg = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE,
GST_MESSAGE_ERROR | GST_MESSAGE_EOS);

        /* Free resources */
        if (msg != NULL)
                gst_message_unref (msg);
        gst_object_unref (bus);
        gst_element_set_state (pipeline, GST_STATE_NULL);
        gst_object_unref (pipeline);
        return 0;
}


On Tue, Jan 24, 2017 at 6:29 PM, Tarun Tej K [via GStreamer-devel] <
ml-node+s966125n4681617h35 at n4.nabble.com> wrote:

> Try g_strstr instead of g_str_has_prefix
>
>
> On 24-Jan-2017 6:16 PM, "rajvik" <[hidden email]
> <http:///user/SendEmail.jtp?type=node&node=4681617&i=0>> wrote:
>
> The problem is it is not getting into the if else statement.
>
>      if (g_str_has_prefix(capsName,"audio"))
>         {
>         g_print("Here 6th .....\n");
>                 GstPad *dynamic_pad = gst_element_get_static_pad(audioQueue,
> "sink");
>                 gst_pad_link(pad, dynamic_pad);
>         }
>
>         else if (g_str_has_prefix(capsName, "video"))
>         {
>         g_print("Here 7th .....\n");
>                 GstPad *video_dynamic_pad = gst_element_get_static_pad(videoQueue,
> "sink");
>                 gst_pad_link(pad, video_dynamic_pad);
>         }
>         g_free(capsName);
>
> Reason being the prefix of capsName is :
> name of caps string: application/x-rtp, media=(string)audio,
> payload=(int)96, clock-rate=(int)44100, encoding-name=(string)MPEG4-GENERIC,
> encoding-params=(string)2, streamtype=(string)5,
> profile-level-id=(string)15, m
> ode=(string)AAC-hbr, config=(string)1210, sizelength=(string)13,
> indexlength=(string)3, indexdeltalength=(string)3, profile=(string)1,
> a-tool=(string)"vlc\ 2.1.6", a-recvonly=(string)"",
> a-type=(string)broadcast, a-ch
> arset=(string)UTF-8, ssrc=(uint)398000458, clock-base=(uint)687408962,
> seqnum-base=(uint)15402, npt-start=(guint64)4219024000,
> play-speed=(double)1, play-scale=(double)1
>
> Any API which would do a string compare for 1 word from the whole string?
>
> On Tue, Jan 24, 2017 at 5:14 PM, Tarun Tej K [via GStreamer-devel] <[hidden
> email] <http:///user/SendEmail.jtp?type=node&node=4681616&i=0>> wrote:
>
>> I am not sure, but can you try without having the queues? Can you please
>> see how it works when link the pads with audioDepay and videoDepay directly?
>>
>> Tarun
>>
>> On 24-Jan-2017 4:31 PM, "rajvik" <[hidden email]
>> <http:///user/SendEmail.jtp?type=node&node=4681615&i=0>> wrote:
>>
>> Thank you so much for the insights. I did incorporate what you asked me
>> to,
>> but still I am getting error:
>> *0:00:00.602211533  2055   0x188380 WARN                 basesrc
>> gstbasesrc.c:2933:gst_base_src_loop:<udpsrc3> error: Internal data flow
>> error.
>> 0:00:00.618291500  2055   0x188380 WARN                 basesrc
>> gstbasesrc.c:2933:gst_base_src_loop:<udpsrc3> error: streaming task
>> paused,
>> reason not-linked (-1)
>> 0:00:00.638866649  2055   0x188430 WARN                 basesrc
>> gstbasesrc.c:2933:gst_base_src_loop:<udpsrc0> error: Internal data flow
>> error.
>> 0:00:00.655050073  2055   0x188430 WARN                 basesrc
>> gstbasesrc.c:2933:gst_base_src_loop:<udpsrc0> error: streaming task
>> paused,
>> reason not-linked (-1)*
>>
>> Please find the below code snippet:
>>
>> *Taken audioQueue and VideoQueue as global variables and find the below cb
>> function: *
>>
>> static void onPadAdded(GstElement *element, GstPad *pad, gpointer data)
>> {
>>
>>         GstCaps *caps;
>>         const char *name;
>>         char *capsName;
>>         caps = gst_pad_get_current_caps(pad);
>>         GstStructure *str = gst_caps_get_structure(caps, 0);
>>         name = gst_structure_get_name(str);
>>         g_debug("name of caps struct string: %s", name);
>>         capsName = gst_caps_to_string(caps);
>>         g_debug("name of caps string: %s", capsName);
>>
>>         if (g_str_has_prefix(capsName,"audio"))
>>         {
>>                 GstPad *dynamic_pad = gst_element_get_static_pad(aud
>> ioQueue,
>> "sink");
>>                 gst_pad_link(pad, dynamic_pad);
>>         }
>>
>>         else if (g_str_has_prefix(capsName, "video"))
>>         {
>>                 GstPad *video_dynamic_pad =
>> gst_element_get_static_pad(videoQueue, "sink");
>>                 gst_pad_link(pad, video_dynamic_pad);
>>         }
>>         g_free(capsName);
>>
>> }
>>
>> *Following is the g_signal_connect operation:*
>>
>>
>>         gst_bin_add(GST_BIN(pipeline), source);
>>         gst_bin_add_many(GST_BIN(pipeline),
>>                         audioQueue, audioDepay, audioParse, audioDecode,
>> audioConvert, audioResample, audioSink,
>>                         videoQueue, videoDepay, videoParser, videoDecode,
>> videoConvert, videoScale, videoSink, NULL);
>>
>>         if (!gst_element_link_many(audioQueue, audioDepay, NULL ))
>>         {
>>                 g_printerr("Cannot link audioqueue  and audioDepay \n");
>>                 return 0;
>>         }
>>         if (!gst_element_link_many(audioParse, audioDecode,NULL ))
>>         {
>>                 g_printerr("Cannot link audioParse and audiodecode \n");
>>                 return 0;
>>         }
>>         if (!gst_element_link_many(audioConvert, audioResample,
>> audioSink,
>> NULL ))
>>         {
>>                 g_printerr("Cannot link audioConvert, audioParse,
>> audioSink
>> \n");
>>                 return 0;
>>         }
>>
>>
>>         /*Linking filter element to videoScale and videoSink */
>>         link_ok = gst_element_link_filtered(videoScale,videoSink,
>> capsFilter);
>>         gst_caps_unref (capsFilter);
>>         if (!link_ok) {
>>                 g_warning ("Failed to link element1 and element2!");
>>         }
>>         /* Linking video elements internally */
>>         if (!gst_element_link_many(videoQueue, videoDepay, NULL))
>>         {
>>                 g_printerr("Cannot link videoQueue and videoDepay \n");
>>                 return 0;
>>         }
>>         if (!gst_element_link_many( videoParser, videoDecode,
>> videoConvert,
>> NULL))
>>         {
>>                 g_printerr("Cannot link videoParser, videoDecode,
>> videoConvert \n");
>>                 return 0;
>>         }
>>         g_signal_connect(source, "pad-added", G_CALLBACK(onPadAdded),
>> NULL);
>>
>>
>>
>>
>> --
>> View this message in context: http://gstreamer-devel.966125.
>> n4.nabble.com/Gstreamer-RTSP-src-element-name-tp4681595p4681613.html
>>
>> Sent from the GStreamer-devel mailing list archive at Nabble.com.
>> _______________________________________________
>> gstreamer-devel mailing list
>> [hidden email] <http:///user/SendEmail.jtp?type=node&node=4681615&i=1>
>> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>>
>>
>>
>> _______________________________________________
>> gstreamer-devel mailing list
>> [hidden email] <http:///user/SendEmail.jtp?type=node&node=4681615&i=2>
>> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>>
>>
>> ------------------------------
>> If you reply to this email, your message will be added to the discussion
>> below:
>> http://gstreamer-devel.966125.n4.nabble.com/Gstreamer-RTSP-s
>> rc-element-name-tp4681595p4681615.html
>> To unsubscribe from Gstreamer RTSP src element name, click here.
>> NAML
>> <http://gstreamer-devel.966125.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>>
>
>
> ------------------------------
> View this message in context: Re: Gstreamer RTSP src element name
> <http://gstreamer-devel.966125.n4.nabble.com/Gstreamer-RTSP-src-element-name-tp4681595p4681616.html>
>
> Sent from the GStreamer-devel mailing list archive
> <http://gstreamer-devel.966125.n4.nabble.com/> at Nabble.com.
>
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email] <http:///user/SendEmail.jtp?type=node&node=4681617&i=1>
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>
>
>
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email] <http:///user/SendEmail.jtp?type=node&node=4681617&i=2>
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
> http://gstreamer-devel.966125.n4.nabble.com/Gstreamer-RTSP-
> src-element-name-tp4681595p4681617.html
> To unsubscribe from Gstreamer RTSP src element name, click here
> <http://gstreamer-devel.966125.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4681595&code=a2FtZGFyLnJhanZpQGdtYWlsLmNvbXw0NjgxNTk1fDExNjQ0OTk2Mjk=>
> .
> NAML
> <http://gstreamer-devel.966125.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Gstreamer-RTSP-src-element-name-tp4681595p4681618.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20170124/7b2cec06/attachment-0001.html>


More information about the gstreamer-devel mailing list