hi all Hi, I was trying to transfer video and audio using network sender------->server---------------->receiver_1 when i use the gst-launch tool to test my commends,it succeede. But when i wrote the "server" in c language and run the project again , i got this Error: internal data flow error. on "server".the flowing is my commends and source code of server. Please help me,thank you very much sender: gst-launch -v gstrtpbin name=rtpbin \ filesrc location=filesrc location=/home/xuxin/desktop/g_p/a.avi ! decodebin name=dec \ dec. ! queue ! x264enc byte-stream=false ! rtph264pay ! rtpbin.send_rtp_sink_0 \ rtpbin.send_rtp_src_0 ! udpsink port=5000 host=172.21.29.177 name=vrtpsink \ dec. ! queue ! audioresample ! audioconvert ! alawenc ! rtppcmapay ! rtpbin.send_rtp_sink_1 \ rtpbin.send_rtp_src_1 ! udpsink port=5002 host=172.21.29.177 ts-offset=0 name=artpsink Server( ip:172.21.29.177) gst-launch -v gstrtpbin name=rtpbin latency=200 \ udpsrc caps="application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)H264" port=5000 ! rtpbin.recv_rtp_sink_0 \ rtpbin ! udpsink port=5000 host=224.0.0.1 sync=false ts-offset=0 \ udpsrc caps="application/x-rtp,media=(string)audio,clock-rate=(int)8000,encoding-name=(string)PCMA" port=5002 ! rtpbin.recv_rtp_sink_1 \ rtpbin. ! udpsink port=5002 host=224.0.0.1 sync=false ts-offset=0 receiver (in multigroup) gst-launch -v gstrtpbin name=rtpbin latency=200 \ udpsrc multigroup="224.0.0.1" caps="application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)H264" port=5000 ! rtpbin.recv_rtp_sink_0 \ rtpbin. ! rtph264depay ! decodebin ! xvimagesink \ udpsrc multigroup="224.0.0.1" caps="application/x-rtp,media=(string)audio,clock-rate=(int)8000,encoding-name=(string)PCMA" port=5002 ! rtpbin.recv_rtp_sink_1 \ rtpbin. ! rtppcmadepay ! decodebin ! audioconvert ! audioresample ! alsasink then I write "Server" in C language ,the code is showed below #include <gst/gst.h> #include <glib.h> #include <unistd.h> #include <stdlib.h> static gboolean bus_call (GstBus *bus, GstMessage *msg, gpointer data) { GMainLoop *loop = (GMainLoop *) data; switch (GST_MESSAGE_TYPE (msg)) { case GST_MESSAGE_EOS: g_print ("End of stream\n"); g_main_loop_quit (loop); break; case GST_MESSAGE_ERROR: { gchar *debug; GError *error; gst_message_parse_error (msg, &error, &debug); g_free (debug); g_printerr ("Error: %s\n", error->message); g_error_free (error); g_main_loop_quit (loop); break; } default: break; } return TRUE; } static void on_pad_added(GstElement *element, GstPad *pad, gpointer data) { GstPad *sinkpad; GstElement *udpsink = (GstElement *)data; g_print("Dynamic pad created, linking demuxer/decoder\n"); sinkpad = gst_element_get_static_pad(udpsink, "sink"); gst_pad_link(pad, sinkpad); gst_object_unref(sinkpad); } int main(int argc, char **argv) { GMainLoop *loop; GstBus *bus; GstPad *pad; GstCaps *videocap, *audiocap; GstElement *pipeline, *gstrtpbin, *udpsrc1, *udpsrc2, *udpsink1, *udpsink2; gst_init(&argc, &argv); loop = g_main_loop_new(NULL, FALSE); pipeline = gst_pipeline_new("server"); gstrtpbin = gst_element_factory_make("gstrtpbin", "gst_rtpbin"); udpsrc1 = gst_element_factory_make("udpsrc", "udpsrc1"); udpsrc2 = gst_element_factory_make("udpsrc", "udpsrc2"); udpsink1 = gst_element_factory_make("udpsink", "udpsink1"); udpsink2 = gst_element_factory_make("udpsink", "udpsink2"); bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline)); gst_bus_add_watch(bus, bus_call, loop); gst_object_unref(bus); videocap = gst_caps_new_simple("application/x-rtp", "media", G_TYPE_STRING, "video", "clock-rate", G_TYPE_LONG, 90000, "encoding-name", G_TYPE_STRING, "H264", NULL); audiocap = gst_caps_new_simple("application/x-rtp", "media", G_TYPE_STRING, "audio", "clock-rate", G_TYPE_LONG, 8000, "encoding-name", G_TYPE_STRING, "PCMA", NULL); g_object_set(G_OBJECT(udpsrc1), "caps", videocap, NULL); g_object_set(G_OBJECT(udpsrc2), "caps", audiocap, NULL); g_object_set(G_OBJECT(udpsrc1), "port", 5000, NULL); g_object_set(G_OBJECT(udpsrc2), "port", 5002, NULL); g_object_set(G_OBJECT(udpsink1), "port", 5000, NULL); g_object_set(G_OBJECT(udpsink2), "port", 5002, NULL); g_object_set(G_OBJECT(udpsink1), "host", "172.21.29.177", NULL); g_object_set(G_OBJECT(udpsink2), "host", "172.21.29.177", NULL); gst_caps_unref(videocap); gst_caps_unref(audiocap); gst_bin_add_many(GST_BIN(pipeline), udpsrc1, udpsrc2, gstrtpbin, udpsink1, udpsink2, NULL); pad = gst_element_get_request_pad(gstrtpbin, "recv_rtp_sink_0"); gst_pad_link(gst_element_get_pad(udpsrc1, "src"), pad); pad = gst_element_get_request_pad(gstrtpbin, "recv_rtp_sink_1"); gst_pad_link(gst_element_get_pad(udpsrc2, "src"), pad); g_signal_connect(gstrtpbin, "pad-added", G_CALLBACK(on_pad_added), udpsink1); g_signal_connect(gstrtpbin, "pad_added", G_CALLBACK(on_pad_added), udpsink2); gst_element_set_state(pipeline, GST_STATE_PLAYING); g_print("Running...\n"); g_main_loop_run(loop); /* Out of the main loop, clean up nicely */ g_print("Returned, stopping playback\n"); gst_element_set_state(pipeline, GST_STATE_NULL); g_print("Deleting pipeline\n"); gst_object_unref(GST_OBJECT(pipeline)); return 0; } 网易全新推出企业邮箱 ------------------------------------------------------------------------------ Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT is a gathering of tech-side developers & brand creativity professionals. Meet the minds behind Google Creative Lab, Visual Complexity, Processing, & iPhoneDevCamp as they present alongside digital heavyweights like Barbarian Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/gstreamer-devel |
On Sun, 2009-05-31 at 16:20 +0800, xuxin04072129 wrote:
Hi, You connect to the pad-added signal twice. Just connect only once and in the callback, see which udpsink you need to link. Wim > > hi all > Hi, I was trying to transfer video and audio using network > > sender------->server---------------->receiver_1 > > when i use the gst-launch tool to test my commends,it succeede. But > when i wrote the "server" in c language and run the project again , i > got this > > Error: internal data flow error. > > on "server".the flowing is my commends and source code of server. > Please help me,thank you very much > > sender: > gst-launch -v gstrtpbin name=rtpbin \ > filesrc location=filesrc location=/home/xuxin/desktop/g_p/a.avi ! > decodebin name=dec \ > dec. ! queue ! x264enc byte-stream=false ! rtph264pay ! > rtpbin.send_rtp_sink_0 \ > rtpbin.send_rtp_src_0 ! udpsink port=5000 host=172.21.29.177 > name=vrtpsink \ > dec. ! queue ! audioresample ! audioconvert ! alawenc ! rtppcmapay ! > rtpbin.send_rtp_sink_1 \ > rtpbin.send_rtp_src_1 ! udpsink port=5002 host=172.21.29.177 > ts-offset=0 name=artpsink > > Server( ip:172.21.29.177) > gst-launch -v gstrtpbin name=rtpbin latency=200 \ > udpsrc > caps="application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)H264" port=5000 ! rtpbin.recv_rtp_sink_0 \ > rtpbin ! udpsink port=5000 host=224.0.0.1 sync=false ts-offset=0 \ > udpsrc > caps="application/x-rtp,media=(string)audio,clock-rate=(int)8000,encoding-name=(string)PCMA" port=5002 ! rtpbin.recv_rtp_sink_1 \ > rtpbin. ! udpsink port=5002 host=224.0.0.1 sync=false ts-offset=0 > > receiver (in multigroup) > > gst-launch -v gstrtpbin name=rtpbin latency=200 \ > udpsrc multigroup="224.0.0.1" > caps="application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)H264" port=5000 ! rtpbin.recv_rtp_sink_0 \ > rtpbin. ! rtph264depay ! decodebin ! xvimagesink \ > udpsrc multigroup="224.0.0.1" > caps="application/x-rtp,media=(string)audio,clock-rate=(int)8000,encoding-name=(string)PCMA" port=5002 ! rtpbin.recv_rtp_sink_1 \ > rtpbin. ! rtppcmadepay ! decodebin ! audioconvert ! audioresample ! > alsasink > > then I write "Server" in C language ,the code is showed below > > #include <gst/gst.h> > #include <glib.h> > #include <unistd.h> > #include <stdlib.h> > > static gboolean > bus_call (GstBus *bus, > GstMessage *msg, > gpointer data) > { > GMainLoop *loop = (GMainLoop *) data; > switch (GST_MESSAGE_TYPE (msg)) { > case GST_MESSAGE_EOS: > g_print ("End of stream\n"); > g_main_loop_quit (loop); > break; > case GST_MESSAGE_ERROR: { > gchar *debug; > GError *error; > gst_message_parse_error (msg, &error, &debug); > g_free (debug); > g_printerr ("Error: %s\n", error->message); > g_error_free (error); > g_main_loop_quit (loop); > break; > } > default: > break; > } > return TRUE; > } > > static void on_pad_added(GstElement *element, GstPad *pad, gpointer > data) > { > GstPad *sinkpad; > GstElement *udpsink = (GstElement *)data; > > g_print("Dynamic pad created, linking demuxer/decoder\n"); > sinkpad = gst_element_get_static_pad(udpsink, "sink"); > gst_pad_link(pad, sinkpad); > gst_object_unref(sinkpad); > } > > int main(int argc, char **argv) > { > GMainLoop *loop; > GstBus *bus; > GstPad *pad; > GstCaps *videocap, *audiocap; > GstElement *pipeline, *gstrtpbin, *udpsrc1, *udpsrc2, > *udpsink1, *udpsink2; > > gst_init(&argc, &argv); > loop = g_main_loop_new(NULL, FALSE); > > pipeline = gst_pipeline_new("server"); > gstrtpbin = gst_element_factory_make("gstrtpbin", "gst_rtpbin"); > udpsrc1 = gst_element_factory_make("udpsrc", "udpsrc1"); > udpsrc2 = gst_element_factory_make("udpsrc", "udpsrc2"); > udpsink1 = gst_element_factory_make("udpsink", "udpsink1"); > udpsink2 = gst_element_factory_make("udpsink", "udpsink2"); > > bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline)); > gst_bus_add_watch(bus, bus_call, loop); > gst_object_unref(bus); > > videocap = gst_caps_new_simple("application/x-rtp", > "media", G_TYPE_STRING, "video", > "clock-rate", G_TYPE_LONG, 90000, > "encoding-name", G_TYPE_STRING, "H264", NULL); > > audiocap = gst_caps_new_simple("application/x-rtp", > "media", G_TYPE_STRING, "audio", > "clock-rate", G_TYPE_LONG, 8000, > "encoding-name", G_TYPE_STRING, "PCMA", NULL); > > g_object_set(G_OBJECT(udpsrc1), "caps", videocap, NULL); > g_object_set(G_OBJECT(udpsrc2), "caps", audiocap, NULL); > g_object_set(G_OBJECT(udpsrc1), "port", 5000, NULL); > g_object_set(G_OBJECT(udpsrc2), "port", 5002, NULL); > g_object_set(G_OBJECT(udpsink1), "port", 5000, NULL); > g_object_set(G_OBJECT(udpsink2), "port", 5002, NULL); > g_object_set(G_OBJECT(udpsink1), "host", "172.21.29.177", NULL); > g_object_set(G_OBJECT(udpsink2), "host", "172.21.29.177", NULL); > > gst_caps_unref(videocap); > gst_caps_unref(audiocap); > > gst_bin_add_many(GST_BIN(pipeline), udpsrc1, udpsrc2, gstrtpbin, > udpsink1, udpsink2, NULL); > > pad = gst_element_get_request_pad(gstrtpbin, "recv_rtp_sink_0"); > gst_pad_link(gst_element_get_pad(udpsrc1, "src"), pad); > > pad = gst_element_get_request_pad(gstrtpbin, "recv_rtp_sink_1"); > gst_pad_link(gst_element_get_pad(udpsrc2, "src"), pad); > > g_signal_connect(gstrtpbin, "pad-added", G_CALLBACK(on_pad_added), > udpsink1); > g_signal_connect(gstrtpbin, "pad_added", G_CALLBACK(on_pad_added), > udpsink2); > > gst_element_set_state(pipeline, GST_STATE_PLAYING); > > g_print("Running...\n"); > g_main_loop_run(loop); > > /* Out of the main loop, clean up nicely */ > g_print("Returned, stopping playback\n"); > gst_element_set_state(pipeline, GST_STATE_NULL); > > g_print("Deleting pipeline\n"); > gst_object_unref(GST_OBJECT(pipeline)); > > return 0; > } > > > > > > ______________________________________________________________________ > 网易全新推出企业邮箱 > ------------------------------------------------------------------------------ > Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT > is a gathering of tech-side developers & brand creativity professionals. Meet > the minds behind Google Creative Lab, Visual Complexity, Processing, & > iPhoneDevCamp as they present alongside digital heavyweights like Barbarian > Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com > _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/gstreamer-devel ------------------------------------------------------------------------------ Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT is a gathering of tech-side developers & brand creativity professionals. Meet the minds behind Google Creative Lab, Visual Complexity, Processing, & iPhoneDevCamp as they present alongside digital heavyweights like Barbarian Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/gstreamer-devel |
Free forum by Nabble | Edit this page |