[gst-devel] Problem linking rtspsrc to any other element

Bobby shuyufu at gmail.com
Sun Nov 21 02:42:40 CET 2010


Hi,

Applications must listen "pad-added" signal fired from rtspsrc and link 
element in callback function.

Here is an example for reference

static void on_pad_added (GstElement *element, GstPad *pad, void *data)
{
GstElement *rtpjpeg = GST_ELEMENT (data);
GstPad *sinkpad;

sinkpad = gst_element_get_pad (rtpjpeg, "sink");
gst_pad_link (pad, sinkpad);
gst_object_unref (sinkpad);
}

int main (int argc, char *argv[])
{
GstElement *rtspsrc = gst_element_factory_make("rtspsrc", NULL);
GstElement *rtpjpeg = gst_element_factory_make("rtpjpegdepay", NULL);
// creats some other elements
// adds elements to pipeline
// links elements except rtspsrc
g_signal_connect (rtspsrc , "pad-added", G_CALLBACK (on_pad_added), 
rtpjpeg);
}

於 2010/11/21 上午 12:55, Hanno Jaspers 提到:
> Hi everyone,
>
> I try to receive the rtsp stream (a MJPEG stream), sent from an Elphel
> camera. I get no problems when using vlc or the gst-launch tool. The
> correct pipeline for gst-launch is: gst-launch rtspsrc
> location="rtsp://192.168.1.9:554" ! rtpjpegdepay ! jpegdec ! xvimagesink
>
> I tried to embed this pipeline in my own application, but somehow, I
> can't link the rtspsrc to another element. I tried to link it to an
> rtpjpegdepay element, a queue element, even a fakesink, but nothing
> works. My code looks sth like this:
>
>    gst_init (&argc,&argv);
>    GMainLoop *loop = g_main_loop_new(NULL, FALSE);
>
>    GstElement *pipeline = gst_pipeline_new ("Windows Overlay Test");
>
>    GstElement *rtspsrc = gst_element_factory_make("rtspsrc", NULL);
>    GstElement *rtpjpeg = gst_element_factory_make("rtpjpegdepay", NULL);
>    GstElement *jpegdec = gst_element_factory_make("jpegdec", NULL);
>    GstElement *fakesink = gst_element_factory_make("fakesink", NULL);
>
>    if (!(rtspsrc&&  rtpjpeg&&  jpegdec&&  fakesink&&  queue1&&  queue2&&
> queue3)) {
>        qCritical()<<  "Elements could not be created!!!";
>        exit(-1);
>    }
>
>    g_object_set(G_OBJECT(rtspsrc), "location", "rtsp://192.168.1.9:554",
> NULL);
>    g_object_set(G_OBJECT(fakesink), "dump", true, NULL);
>
>    gst_bin_add_many (GST_BIN (pipeline), rtspsrc, rtpjpeg,  jpegdec,
> fakesink, NULL);
>    if (!gst_element_link(rtspsrc, fakesink)) {
>        qCritical()<<  "RTSPSRC could not be linked!!!";
>        exit(-1);
>    }
>
> The "gst_element_link(rtspsrc, fakesink)" always returns false. Here's
> the interesting part of the debug output (GST_DEBUG=4):
> 0:00:00.457158021  6075      0x1195730 DEBUG          GST_PARENTAGE
> gstbin.c:1152:gst_bin_add_func:<Windows Overlay Test>  added element
> "fakesink0"
> 0:00:00.457173107  6075      0x1195730 INFO        GST_ELEMENT_PADS
> gstutils.c:1614:gst_element_link_pads_full: trying to link element
> rtspsrc0:(any) to element fakesink0:(any)
> 0:00:00.457184491  6075      0x1195730 DEBUG       GST_ELEMENT_PADS
> gstutils.c:1755:gst_element_link_pads_full: trying dest pad
> fakesink0:sink
> 0:00:00.457193920  6075      0x1195730 DEBUG       GST_ELEMENT_PADS
> gstutils.c:1115:gst_element_get_compatible_pad: finding pad in rtspsrc0
> compatible with fakesink0:sink
> 0:00:00.457204536  6075      0x1195730 DEBUG       GST_ELEMENT_PADS
> gstutils.c:1200:gst_element_get_compatible_pad:<rtspsrc0>  Could not find
> a compatible unlinked always pad to link to fakesink0:sink, now checking
> request pads
> 0:00:00.457485856  6075      0x1195730 DEBUG               GST_CAPS
> gstpad.c:2274:gst_pad_get_caps_reffed:<fakesink0:sink>  get pad caps
> 0:00:00.457495564  6075      0x1195730 DEBUG               GST_CAPS
> gstpad.c:2184:gst_pad_get_caps_unlocked:<fakesink0:sink>  get pad caps
> 0:00:00.457504084  6075      0x1195730 DEBUG               GST_CAPS
> gstpad.c:2188:gst_pad_get_caps_unlocked:<fakesink0:sink>  dispatching to
> pad getcaps function
> 0:00:00.457518681  6075      0x1195730 DEBUG               GST_CAPS
> gstpad.c:2201:gst_pad_get_caps_unlocked:<fakesink0:sink>  pad getcaps
> returned ANY
> 0:00:00.457546268  6075      0x1195730 DEBUG       GST_ELEMENT_PADS
> gstutils.c:889:gst_element_get_compatible_pad_template: Looking for a
> suitable pad template in rtspsrc0 out of 1 templates...
> 0:00:00.457557513  6075      0x1195730 DEBUG               GST_CAPS
> gstutils.c:905:gst_element_get_compatible_pad_template: compatible
> direction: found src pad template "stream%d"
> 0:00:00.457566313  6075      0x1195730 DEBUG               GST_CAPS
> gstutils.c:908:gst_element_get_compatible_pad_template: intersecting ANY
> 0:00:00.457575462  6075      0x1195730 DEBUG               GST_CAPS
> gstutils.c:910:gst_element_get_compatible_pad_template: ..and
> application/x-rtp; application/x-rdt
> 0:00:00.457585659  6075      0x1195730 DEBUG               GST_CAPS
> gstutils.c:916:gst_element_get_compatible_pad_template: caps are
> compatible
> 0:00:00.457593830  6075      0x1195730 DEBUG       GST_ELEMENT_PADS
> gstutils.c:928:gst_element_get_compatible_pad_template: Returning new
> pad template 0x1556bb0
> 0:00:00.457602770  6075      0x1195730 INFO        GST_ELEMENT_PADS
> gstelement.c:960:gst_element_get_static_pad: no such pad 'stream%d' in
> element "rtspsrc0"
> 0:00:00.457617018  6075      0x1195730 INFO        GST_ELEMENT_PADS
> gstutils.c:1221:gst_element_get_compatible_pad:<rtspsrc0>  Could not find
> a compatible pad to link to fakesink0:sink
> 0:00:00.457626795  6075      0x1195730 DEBUG       GST_ELEMENT_PADS
> gstutils.c:1797:gst_element_link_pads_full: we might have request pads
> on both sides, checking...
> 0:00:00.457635944  6075      0x1195730 DEBUG       GST_ELEMENT_PADS
> gstutils.c:1838:gst_element_link_pads_full: no link possible from
> rtspsrc0 to fakesink0
> RTSPSRC could not be linked!!!
>
> Where's the problem? Thanks for your help!
> Hanno
>
>
>
> ------------------------------------------------------------------------------
> Beautiful is writing same markup. Internet Explorer 9 supports
> standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2&  L3.
> Spend less time writing and  rewriting code and more time creating great
> experiences on the web. Be a part of the beta today
> http://p.sf.net/sfu/msIE9-sfdev2dev
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel





More information about the gstreamer-devel mailing list