The string in the below line should be &quot;video&quot;.<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; else if(g_strrstr (gst_structure_get_name (str), &quot;vedio&quot;))<br>&nbsp; &nbsp;&nbsp;&nbsp; {&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;t_pad = gst_element_get_static_pad (multiudpsink2, &quot;sink&quot;);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;g_print(&quot;rtp catch vedio\n&quot;);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br><br>Its always better to check the return values, and print the appropriate error messages.<br>
Say for in your example you can check if the &quot;t_pad&quot; is created or its NULL.<br>
So that you can trace easily.<br>
<br><br><div class="gmail_quote">2009/6/3 xuxin04072129 <span dir="ltr">&lt;<a href="mailto:xuxin04072129@126.com">xuxin04072129@126.com</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><br>hi all<br>&nbsp;&nbsp; I come across a problem when sending out vedio through rtp protocol.Last time i ask the same question here and Wim Taymans told me that i had connected to the pad-added signal twice.I should thank him first .Later&nbsp; I re-write the code , but i get error as flows <br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Error: internal data flow error.<br>I am new to gstreamer , can anyone help me to check my code and give me some suggestions . Thank you very much. the following is my code<br><br>/******************************************************<br>
&nbsp;#include &lt;gst/gsth&gt;<br>#include &lt;glib.h&gt;<br>#include &lt;unistd.h&gt;<br>#include &lt;stdlib.h&gt;<br><br><br>GstElement *multiudpsink1, *multiudpsink2;<br><br>static gboolean<br>bus_call (GstBus&nbsp;&nbsp;&nbsp;&nbsp; *bus,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GstMessage *msg,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gpointer&nbsp;&nbsp;&nbsp; data)<br>{<br>&nbsp; GMainLoop *loop = (GMainLoop *) data;<br>&nbsp; switch (GST_MESSAGE_TYPE (msg)) {<br>&nbsp;&nbsp;&nbsp; case GST_MESSAGE_EOS:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; g_print (&quot;End of stream\n&quot;);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; g_main_loop_quit (loop);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;<br>&nbsp;&nbsp;&nbsp; case GST_MESSAGE_ERROR: {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gchar *debug;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GError *error;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gst_message_parse_error (msg, &amp;error, &amp;debug);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; g_free (debug);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; g_printerr (&quot;Error: %s\n&quot;, error-&gt;message);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; g_error_free (error);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; g_main_loop_quit (loop);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; default:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;<br>&nbsp; }<br>&nbsp; return TRUE;<br>}<br><br>// I have rewrite this function<br>static void on_pad_added(GstElement *element, GstPad *pad, gpointer data)<br>
{<br>&nbsp;&nbsp;&nbsp; GstCaps *caps;<br>&nbsp;&nbsp;&nbsp; GstStructure *str;<br>&nbsp;&nbsp;&nbsp; GstPad *t_pad;<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; caps=gst_pad_get_caps(pad);<br>&nbsp;&nbsp;&nbsp; str=gst_caps_get_structure(caps,0);<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; //<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (g_strrstr (gst_structure_get_name (str), &quot;audio&quot;)) <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;t_pad = gst_element_get_static_pad (multiudpsink1, &quot;sink&quot;);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;g_print(&quot;rtp catch audio\n&quot;);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;else if(g_strrstr (gst_structure_get_name (str), &quot;vedio&quot;))<br>
&nbsp; &nbsp;&nbsp;&nbsp; {&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;t_pad = gst_element_get_static_pad (multiudpsink2, &quot;sink&quot;);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;g_print(&quot;rtp catch vedio\n&quot;);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; gst_caps_unref (caps);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (GST_PAD_IS_LINKED (t_pad)) <br>&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; gst_caps_unref (caps);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; g_object_unref (t_pad);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return;<br>&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp; &nbsp;&nbsp;&nbsp; //<br>
&nbsp; &nbsp;&nbsp;&nbsp; else<br>&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //<br>&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; gst_pad_link (pad, t_pad);<br>&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; g_print(&quot;Dynamic pad created, linking rtpbin/udp\n&quot;);<br>&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; gst_caps_unref (caps);&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; g_object_unref (t_pad);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return;<br>&nbsp; &nbsp;&nbsp;&nbsp; } &nbsp;&nbsp;&nbsp; <br>}<br><br>int main(int argc, char **argv)<br>{<br>&nbsp;&nbsp;&nbsp; GMainLoop *loop;<br>&nbsp;&nbsp;&nbsp; GstBus *bus;<br>&nbsp;&nbsp;&nbsp; GstPad *pad;<br>&nbsp;&nbsp;&nbsp; GstCaps *videocap, *audiocap;<br>
&nbsp;&nbsp;&nbsp; GstElement *pipeline, *gstrtpbin, *udpsrc1, *udpsrc2;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; gst_init(&amp;argc, &amp;argv);<br>&nbsp;&nbsp;&nbsp; loop = g_main_loop_new(NULL, FALSE);<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; pipeline = gst_pipeline_new(&quot;server&quot;);<br>
&nbsp;&nbsp;&nbsp; gstrtpbin = gst_element_factory_make(&quot;gstrtpbin&quot;, &quot;gst_rtpbin&quot;);<br>&nbsp;&nbsp;&nbsp; udpsrc1 = gst_element_factory_make(&quot;udpsrc&quot;, &quot;udpsrc1&quot;);<br>&nbsp;&nbsp;&nbsp; udpsrc2 = gst_element_factory_make(&quot;udpsrc&quot;, &quot;udpsrc2&quot;);<br>
&nbsp;&nbsp;&nbsp; multiudpsink1 = gst_element_factory_make(&quot;multiudpsink&quot;, &quot;multiudpsink1&quot;);<br>&nbsp;&nbsp;&nbsp; multiudpsink2 = gst_element_factory_make(&quot;multiudpsink&quot;, &quot;multiudpsink2&quot;);&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));<br>&nbsp;&nbsp;&nbsp; gst_bus_add_watch(bus, bus_call, loop);<br>&nbsp;&nbsp;&nbsp; gst_object_unref(bus);<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; videocap = gst_caps_new_simple(&quot;application/x-rtp&quot;, <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &quot;media&quot;, G_TYPE_STRING, &quot;video&quot;,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &quot;clock-rate&quot;, G_TYPE_INT, 90000,<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &quot;encoding-name&quot;, G_TYPE_STRING, &quot;H264&quot;, NULL);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; audiocap = gst_caps_new_simple(&quot;application/x-rtp&quot;,<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &quot;media&quot;, G_TYPE_STRING, &quot;audio&quot;,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &quot;clock-rate&quot;, G_TYPE_INT, 8000,<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &quot;encoding-name&quot;, G_TYPE_STRING, &quot;PCMA&quot;, NULL);<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; g_object_set(G_OBJECT(udpsrc1), &quot;caps&quot;, videocap, NULL);<br>&nbsp;&nbsp;&nbsp; g_object_set(G_OBJECT(udpsrc2), &quot;caps&quot;, audiocap, NULL);<br>
&nbsp;&nbsp;&nbsp; g_object_set(G_OBJECT(udpsrc1), &quot;port&quot;, 5000, NULL);<br>&nbsp;&nbsp;&nbsp; g_object_set(G_OBJECT(udpsrc2), &quot;port&quot;, 5002, NULL);<br>&nbsp;&nbsp;&nbsp; g_object_set(G_OBJECT(multiudpsink1), &quot;clients&quot;,&quot;<a href="http://172.21.29.169:5000" target="_blank">172.21.29.169:5000</a>,<a href="http://172.21.29.168:5000" target="_blank">172.21.29.168:5000</a>&quot;, NULL);<br>
&nbsp;&nbsp;&nbsp; g_object_set(G_OBJECT(multiudpsink2), &quot;clients&quot;,&quot;<a href="http://172.21.29.169:5002" target="_blank">172.21.29.169:5002</a>,<a href="http://172.21.29.168:5002" target="_blank">172.21.29.168:5002</a>&quot;, NULL);<br>
&nbsp;&nbsp;&nbsp; g_object_set(G_OBJECT(multiudpsink1), &quot;sync&quot;,FALSE, NULL);<br>&nbsp;&nbsp;&nbsp; g_object_set(G_OBJECT(multiudpsink2), &quot;sync&quot;,FALSE, NULL);<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; gst_caps_unref(videocap);<br>&nbsp;&nbsp;&nbsp; gst_caps_unref(audiocap);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; gst_bin_add_many(GST_BIN(pipeline), udpsrc1, udpsrc2, gstrtpbin, multiudpsink1, multiudpsink2, NULL);<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; pad = gst_element_get_request_pad(gstrtpbin, &quot;recv_rtp_sink_0&quot;);<br>&nbsp;&nbsp;&nbsp; gst_pad_link(gst_element_get_pad(udpsrc1, &quot;src&quot;), pad);<br>
&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; pad = gst_element_get_request_pad(gstrtpbin, &quot;recv_rtp_sink_1&quot;);<br>&nbsp;&nbsp;&nbsp; gst_pad_link(gst_element_get_pad(udpsrc2, &quot;src&quot;), pad);<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; g_signal_connect(gstrtpbin, &quot;pad-added&quot;, G_CALLBACK(on_pad_added),NULL);&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; gst_element_set_state(pipeline, GST_STATE_PLAYING);<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; g_print(&quot;Running...\n&quot;);<br>&nbsp;&nbsp;&nbsp; g_main_loop_run(loop);<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; /* Out of the main loop, clean up nicely */<br>&nbsp;&nbsp;&nbsp; g_print(&quot;Returned, stopping playback\n&quot;);<br>
&nbsp;&nbsp;&nbsp; gst_element_set_state(pipeline, GST_STATE_NULL);<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; g_print(&quot;Deleting pipeline\n&quot;);<br>&nbsp;&nbsp;&nbsp; gst_object_unref(GST_OBJECT(pipeline));<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; return 0;<br>}<br></div><br><br><span title="neteasefooter"><hr>

<a href="http://qiye.163.com/?ft=2" target="_blank">网易全新推出企业邮箱</a>
</span><br>------------------------------------------------------------------------------<br>
OpenSolaris 2009.06 is a cutting edge operating system for enterprises<br>
looking to deploy the next generation of Solaris that includes the latest<br>
innovations from Sun and the OpenSource community. Download a copy and<br>
enjoy capabilities such as Networking, Storage and Virtualization.<br>
Go to: <a href="http://p.sf.net/sfu/opensolaris-get" target="_blank">http://p.sf.net/sfu/opensolaris-get</a><br>_______________________________________________<br>
gstreamer-devel mailing list<br>
<a href="mailto:gstreamer-devel@lists.sourceforge.net">gstreamer-devel@lists.sourceforge.net</a><br>
<a href="https://lists.sourceforge.net/lists/listinfo/gstreamer-devel" target="_blank">https://lists.sourceforge.net/lists/listinfo/gstreamer-devel</a><br>
<br></blockquote></div><br>