<span style="font-family: courier new,monospace;">Hi experts,<br><br>I am trying to write a pipeline for receiving and decoding H.264 RTP packets. Please see the C codes below. It is basically equivalent to following pipeline.<br>
</span><pre class="programlisting">gst<span class="symbol">-</span>launch <span class="symbol">-</span>v gstrtpbin name<span class="symbol">=</span>rtpbin \<br> udpsrc caps<span class="symbol">=</span><span class="string">"application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)H264"</span> \<br>
port<span class="symbol">=</span><span class="number">5000</span> <span class="symbol">!</span> rtpbin<span class="symbol">.</span>recv_rtp_sink_0 \<br> rtpbin<span class="symbol">. !</span> rtph264depay <span class="symbol">!</span> ffdec_h264 <span class="symbol">!</span> xvimagesink \<br>
</pre><br><span style="font-family: courier new,monospace;">But I couldn't link gstrtpbin and rtph264depay. The error message is as follows:<br><font size="1">0:00:00.135605335 5934 0x95aa008 INFO GST_ELEMENT_PADS gstutils.c:1587:gst_element_link_pads: trying to link element gst-rtp-bin:(any) to element rtp-decoder:(any)<br>
0:00:00.135657988 5934 0x95aa008 INFO GST_ELEMENT_PADS gstelement.c:970:gst_element_get_static_pad: no such pad 'recv_rtp_src_%d_%d_%d' in element "gst-rtp-bin"<br>0:00:00.135679108 5934 0x95aa008 INFO GST_ELEMENT_PADS gstutils.c:1208:gst_element_get_compatible_pad:<gst-rtp-bin> Could not find a compatible pad to link to rtp-decoder:sink</font><br>
<br>Could someone give me some hints? Why I have no "recv_rtp_src_%d_%d_%d"? Or could someone lead me to similar examples? Thanks in advance!<br><br>Regards,<br><br>Qin<br><br><br>static</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">GstElement* construct_receiver_pipeline(void){</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> GstElement *pipeline, *gstrtpbin, *vdec, *rtpdec, *vsink;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> GstElement *jitterbuf, *vconv;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> GstElement *udpsrc_rtp;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> GstCaps *caps;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> GstPad *pad;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> gboolean err;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> GstPadLinkReturn res;</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> //Create gstrtpbin</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> gstrtpbin = gst_element_factory_make("gstrtpbin", "gst-rtp-bin");</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> if ( !gstrtpbin ) {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> g_printerr("Failed to create gstrtpbin\n");</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> return 0;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> g_object_set(G_OBJECT (jitterbuf), "latency", jitter_latency, NULL);</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> //RTP ource initialization</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> udpsrc_rtp = gst_element_factory_make("udpsrc", "udp-udpsrc_rtp");</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> if ( !udpsrc_rtp ) {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> g_printerr("Failed to create udpsrc\n");</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> return 0;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> g_object_set(G_OBJECT (udpsrc_rtp), "port", rtp_port, NULL);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> //gst_caps_new_simple and gst_element_linked_filter don't work</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> g_object_set(G_OBJECT (udpsrc_rtp), "caps",</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> gst_caps_from_string("application/x-rtp, "</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> "clock-rate=(int)90000, "</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> "payload=(int)96, "</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> "media=(string)video, "</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> "encoding-name=(string)H264"), NULL);</span><span style="font-family: courier new,monospace;"></span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> //Create video decoder</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> vdec = gst_element_factory_make(vdecoder, "video-decoder");</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> if ( !vdec ) {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> g_printerr("Failed to create %s\n", vdecoder);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> return 0;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> //Choose RTP decoder according to video codec</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> rtpdecoder = g_strdup(select_rtp_decoder(vdecoder));</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> g_free(vdecoder);</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> //Create rtp decoder</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> rtpdec = gst_element_factory_make(rtpdecoder, "rtp-decoder");</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> if ( !rtpdec ) {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> g_printerr("Failed to create %s\n", rtpdecoder);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> return 0;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> //Create video converter</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> vconv = gst_element_factory_make("ffmpegcolorspace", "video-converter");</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> if ( !vconv ) {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> g_printerr("Failed to create ffmpegcolorspace\n");</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> return 0;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> //Create video sink</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> vsink = gst_element_factory_make("xvimagesink", "video-sink");</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> if ( !vsink ) {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> g_printerr("Failed to create xvimagesink\n");</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> return 0;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> /* Set up the pipeline */</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> gst_bin_add_many(GST_BIN (pipeline), udpsrc_rtp, gstrtpbin/*, jitterbuf*/,</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> rtpdec, vdec, vconv, vsink, NULL);</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> //link udpsrc_rtp to gstrtpbin</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> pad = gst_element_get_request_pad(gstrtpbin, "recv_rtp_sink_%d");</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> if ( !pad ) {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> g_printerr("Failed to create pad\n");</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> return 0;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> res = gst_pad_link(gst_element_get_pad(udpsrc_rtp, "src"), pad);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> gst_object_unref(GST_OBJECT (pad));</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> if ( GST_PAD_LINK_FAILED(res) ) {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> g_printerr("Failed to link pads\n");</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> return 0;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> err = gst_element_link_many(gstrtpbin, rtpdec, vdec, vconv, vsink, NULL);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> if ( err==FALSE ) {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> g_printerr("Failed to link elements\n");</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> return 0;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> return pipeline;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">}</span><br>