hi wim and Jyoti&nbsp; :<br>&nbsp;&nbsp;&nbsp; thank you for your replies .I followed your suggestions and rewrite the code.But it still can't&nbsp; work fine.&nbsp; I get the following error:<br>&nbsp;&nbsp;&nbsp; Running...<br>&nbsp;&nbsp;&nbsp; catch video in decodebin<br>&nbsp;&nbsp;&nbsp; Dynamic pad created, linking decoderbin/queue<br>&nbsp;&nbsp;&nbsp; catch audio in decodebin<br>&nbsp;&nbsp;&nbsp; Dynamic pad created, linking decoderbin/queue<br>&nbsp;&nbsp;&nbsp; Error: internal data flow error<br>&nbsp;&nbsp;&nbsp; Returned, stopping playback<br>&nbsp;&nbsp;&nbsp; Deleting pipeline<br>please give me some more suggestion,i will thank you very much. <br><br>&nbsp;&nbsp;&nbsp; By the way,i find a source code on net, he didn't use callback.Instead ,he write the code as follow <br><br>&nbsp;&nbsp;&nbsp; send_rtp_sink0 = gst_element_get_request_pad(rtpbin, "send_rtp_sink_0");<br>&nbsp;&nbsp;&nbsp; send_rtp_src0 = gst_element_get_static_pad(rtpbin, "send_rtp_src_0");<br><br>and the reason is :in the Reference it's described that the "send_rtp_src_%d" pad is<br>automatically created if a pad_request to "send_rtp_sink_%d" is called.<br><br>&nbsp;&nbsp;&nbsp; I have tried this method ,but failed.<br><br>#include &lt;gst/gst.h&gt;<br>#include &lt;glibh&gt;<br>#include &lt;unistd.h&gt;<br>#include &lt;stdlib.h&gt;<br><br>// global declaration<br>GstElement *pipeline,*udpsink0,*udpsink1;<br>GstElement *audio_bin,*video_bin;<br><br>//<br>gboolean res;//element link <br>GstPadLinkReturn lres;//pad link<br><br>//bus<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 ("End of stream\n");<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 ("Error: %s\n", 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>static void on_pad_added_rtpbin(GstElement *element, GstPad *pad, gpointer data)<br>{<br>&nbsp;&nbsp;&nbsp; GstCaps *caps=NULL;<br>&nbsp;&nbsp;&nbsp; GstStructure *str=NULL;<br>&nbsp;&nbsp;&nbsp; GstPad *t_pad=NULL;<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; g_assert(pad!=NULL);<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; //media type audio or video<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (g_strrstr (gst_structure_get_name (str), "audio")) <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;&nbsp; g_print("rtp catch audio\n");<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; t_pad = gst_element_get_static_pad (udpsink0, "sink");<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; g_assert(t_pad!=NULL);&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<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), "video"))<br>&nbsp; &nbsp;&nbsp;&nbsp; {&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; g_print("rtp catch video\n");<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; t_pad = gst_element_get_static_pad (udpsink1, "sink");<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; g_assert(t_pad!=NULL);&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<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; else<br>&nbsp; &nbsp;&nbsp;&nbsp; {&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; lres=gst_pad_link (pad, t_pad);<br>&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; g_assert (lres == GST_PAD_LINK_OK);<br>&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; g_print("Dynamic pad created, linking rtpbin/udp\n");<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>&nbsp;&nbsp;&nbsp; <br>}<br><br>static void on_pad_added_decodebin(GstElement *decodebin,GstPad *pad,gboolean last,gpointer data)<br>{<br>&nbsp;&nbsp;&nbsp; GstCaps *caps;<br>&nbsp; &nbsp;&nbsp;&nbsp; GstStructure *str;<br>&nbsp; &nbsp;&nbsp;&nbsp; GstPad *t_pad;<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; //media type<br>&nbsp;&nbsp;&nbsp; caps = gst_pad_get_caps (pad);<br>&nbsp; &nbsp;&nbsp;&nbsp; str = gst_caps_get_structure (caps, 0);<br>&nbsp; &nbsp;&nbsp;&nbsp; //check media type audio or video<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (g_strrstr (gst_structure_get_name (str), "audio")) <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;&nbsp; g_print("catch audio in decodebin\n");<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; t_pad = gst_element_get_static_pad (audio_bin, "sink");<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; g_assert(t_pad!=NULL);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if(t_pad==NULL)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; g_print("cannot get the sink pad of audiobin ");<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<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), "video"))<br>&nbsp; &nbsp;&nbsp;&nbsp; {&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; g_print("catch video in decodebin\n");<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; t_pad = gst_element_get_static_pad (video_bin, "sink");<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; g_assert(t_pad!=NULL);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if(t_pad==NULL)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; g_print("cannot get the sink pad of videobin ");<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<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;&nbsp; <br>&nbsp; &nbsp;&nbsp;&nbsp; <br>&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; {&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("Dynamic pad created, linking decoderbin/queue\n");<br>&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>&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; <br>&nbsp;&nbsp;&nbsp; //pad of rtpbin<br>&nbsp;&nbsp;&nbsp; GstPad *sink_pad;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; GstPad *bin_pad;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; GstPad *videopad_src,*videopad_sink;<br>&nbsp;&nbsp;&nbsp; GstPad *audiopad_src,*audiopad_sink;<br>&nbsp;&nbsp;&nbsp; //declare elements <br>&nbsp;&nbsp;&nbsp; GstElement&nbsp; *filesrc,*decodebin,*gstrtpbin;<br>&nbsp;&nbsp;&nbsp; //element for video<br>&nbsp;&nbsp;&nbsp; GstElement *queue1,*x264enc,*rtph264pay;<br>&nbsp;&nbsp;&nbsp; //element for audio<br>&nbsp;&nbsp;&nbsp; GstElement *queue2,*audioresample,*audioconvert,*alawenc,*rtppcmapay;<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; //generate elements<br>&nbsp;&nbsp;&nbsp; pipeline = gst_pipeline_new("server");<br>&nbsp;&nbsp;&nbsp; filesrc=gst_element_factory_make("filesrc", "filesrc");<br>&nbsp;&nbsp;&nbsp; decodebin=gst_element_factory_make("decodebin", "decodebin");<br>&nbsp;&nbsp;&nbsp; gstrtpbin = gst_element_factory_make("gstrtpbin", "gstrtpbin");<br>&nbsp;&nbsp;&nbsp; //for video<br>&nbsp;&nbsp;&nbsp; queue1=gst_element_factory_make("queue", "queue1");<br>&nbsp;&nbsp;&nbsp; x264enc=gst_element_factory_make("x264enc", "x264enc");<br>&nbsp;&nbsp;&nbsp; rtph264pay=gst_element_factory_make("rtph264pay", "rtph264pay");<br>&nbsp;&nbsp;&nbsp; udpsink0=gst_element_factory_make("udpsink", "udpsink0");<br>&nbsp;&nbsp;&nbsp; //for audio<br>&nbsp;&nbsp;&nbsp; queue2 = gst_element_factory_make("queue", "queue2");<br>&nbsp;&nbsp;&nbsp; audioresample = gst_element_factory_make("audioresample", "audioresample");<br>&nbsp;&nbsp;&nbsp; audioconvert = gst_element_factory_make("audioconvert", "audioconvert");<br>&nbsp;&nbsp;&nbsp; alawenc = gst_element_factory_make("alawenc", "alawenc");&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; rtppcmapay = gst_element_factory_make("rtppcmapay", "rtppcmapay");<br>&nbsp;&nbsp;&nbsp; udpsink1=gst_element_factory_make("udpsink", "udpsink1");<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; //set properties of elements<br>&nbsp;&nbsp;&nbsp; g_object_set(G_OBJECT(filesrc), "location","/home/xuxin/desktop/g_p/a.avi", NULL);&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; g_object_set(G_OBJECT(udpsink0), "port",5000, NULL);<br>&nbsp;&nbsp;&nbsp; g_object_set(G_OBJECT(udpsink1), "port",5002, NULL);<br>&nbsp;&nbsp;&nbsp; g_object_set(G_OBJECT(udpsink0), "host","172.21.29.169", NULL);<br>&nbsp;&nbsp;&nbsp; g_object_set(G_OBJECT(udpsink1), "host","172.21.29.169", NULL);<br>&nbsp;&nbsp;&nbsp; g_object_set(G_OBJECT(udpsink0), "sync",FALSE, NULL);<br>&nbsp;&nbsp;&nbsp; g_object_set(G_OBJECT(udpsink1), "sync",FALSE, NULL);<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; //create video_bin<br>&nbsp;&nbsp;&nbsp; video_bin = gst_bin_new ("videobin");<br>&nbsp;&nbsp;&nbsp; gst_bin_add_many (GST_BIN (video_bin),queue1,x264enc,rtph264pay,NULL);<br>&nbsp;&nbsp;&nbsp; res=gst_element_link_many(queue1,x264enc,rtph264pay,NULL);<br>&nbsp;&nbsp;&nbsp; g_assert (res == TRUE);<br>&nbsp;&nbsp;&nbsp; //add pad to video_bin<br>&nbsp;&nbsp;&nbsp; videopad_sink = gst_element_get_static_pad (queue1, "sink");<br>&nbsp;&nbsp;&nbsp; videopad_src= gst_element_get_static_pad (rtph264pay, "src");&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; gst_element_add_pad (video_bin,gst_ghost_pad_new ("sink", videopad_sink));<br>&nbsp;&nbsp;&nbsp; gst_element_add_pad (video_bin,gst_ghost_pad_new ("src",videopad_src));<br>&nbsp; &nbsp;&nbsp;&nbsp; gst_object_unref (videopad_sink);<br>&nbsp; &nbsp;&nbsp;&nbsp; gst_object_unref (videopad_src);<br>&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp; &nbsp;&nbsp;&nbsp; //create audio_bin<br>&nbsp; &nbsp;&nbsp;&nbsp; audio_bin = gst_bin_new ("audiobin");<br>&nbsp;&nbsp;&nbsp; gst_bin_add_many (GST_BIN (audio_bin),queue2,audioresample,audioconvert,alawenc,rtppcmapay,NULL);<br>&nbsp;&nbsp;&nbsp; res=gst_element_link_many(queue2,audioresample,audioconvert,alawenc,rtppcmapay,NULL);<br>&nbsp;&nbsp;&nbsp; g_assert (res == TRUE);<br>&nbsp;&nbsp;&nbsp; //add pad to audio_bin<br>&nbsp;&nbsp;&nbsp; audiopad_sink = gst_element_get_static_pad (queue2, "sink");<br>&nbsp;&nbsp;&nbsp; audiopad_src= gst_element_get_static_pad (rtppcmapay, "src");&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; res=gst_element_add_pad (audio_bin,gst_ghost_pad_new ("sink", audiopad_sink));<br>&nbsp;&nbsp;&nbsp; g_assert (res == TRUE);<br>&nbsp;&nbsp;&nbsp; res=gst_element_add_pad (audio_bin,gst_ghost_pad_new ("src", audiopad_src));<br>&nbsp;&nbsp;&nbsp; g_assert (res == TRUE);<br>&nbsp; &nbsp;&nbsp;&nbsp; gst_object_unref (audiopad_sink);<br>&nbsp; &nbsp;&nbsp;&nbsp; gst_object_unref (audiopad_src);<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; //add elements into pipeline<br>&nbsp;&nbsp;&nbsp; gst_bin_add_many(GST_BIN(pipeline),<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; filesrc,decodebin,audio_bin,video_bin,gstrtpbin,udpsink0,udpsink1,NULL);<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; //static link filesrc and decoderbin <br>&nbsp;&nbsp;&nbsp; res=gst_element_link(filesrc,decodebin);&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; g_assert (res == TRUE);&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; //get request pad from gstrtpbin and connect with video_bin<br>&nbsp;&nbsp;&nbsp; bin_pad=gst_element_get_pad(video_bin, "src");<br>&nbsp;&nbsp;&nbsp; g_assert(bin_pad!=NULL);&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; sink_pad = gst_element_get_request_pad(gstrtpbin, "recv_rtp_sink_0");<br>&nbsp;&nbsp;&nbsp; g_assert(sink_pad!=NULL);&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; lres=gst_pad_link(bin_pad, sink_pad);<br>&nbsp;&nbsp;&nbsp; g_assert (lres == GST_PAD_LINK_OK);<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; //get request pad from gstrtpbin and connect with audio_bin<br>&nbsp;&nbsp;&nbsp; bin_pad=gst_element_get_pad(audio_bin, "src");<br>&nbsp;&nbsp;&nbsp; g_assert(bin_pad!=NULL);<br>&nbsp;&nbsp;&nbsp; sink_pad = gst_element_get_request_pad(gstrtpbin, "recv_rtp_sink_1");<br>&nbsp;&nbsp;&nbsp; g_assert(sink_pad!=NULL);<br>&nbsp;&nbsp;&nbsp; lres=gst_pad_link(bin_pad, sink_pad);<br>&nbsp;&nbsp;&nbsp; g_assert (lres == GST_PAD_LINK_OK);<br><br>&nbsp;&nbsp;&nbsp; //signal link<br>&nbsp;&nbsp;&nbsp; g_signal_connect(decodebin, "new-decoded-pad", G_CALLBACK(on_pad_added_decodebin),NULL);&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; g_signal_connect(gstrtpbin, "pad-added", G_CALLBACK(on_pad_added_rtpbin),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("Running...\n");<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("Returned, stopping playback\n");<br>&nbsp;&nbsp;&nbsp; gst_element_set_state(pipeline, GST_STATE_NULL);<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; g_print("Deleting pipeline\n");<br>&nbsp;&nbsp;&nbsp; gst_object_unref(GST_OBJECT(pipeline));<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; return 0;<br>}<br><br><!-- footer --><br><span title="neteasefooter"/><hr/>
<a href="http://qiye.163.com/?ft=1">业务订单流失怎么办?</a>
</span>