[gst-devel] problem of sending out vediio through rtp protocol

Jyoti jyoti.d at allaboutif.com
Wed Jun 3 11:22:53 CEST 2009


The string in the below line should be "video".

         else if(g_strrstr (gst_structure_get_name (str), "vedio"))
      {
             t_pad = gst_element_get_static_pad (multiudpsink2, "sink");
             g_print("rtp catch vedio\n");
        }

Its always better to check the return values, and print the appropriate
error messages.
Say for in your example you can check if the "t_pad" is created or its NULL.
So that you can trace easily.


2009/6/3 xuxin04072129 <xuxin04072129 at 126.com>

>
> hi all
>    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  I
> re-write the code , but i get error as flows
>        Error: internal data flow error.
> 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
>
> /******************************************************
>  #include <gst/gsth>
> #include <glib.h>
> #include <unistd.h>
> #include <stdlib.h>
>
>
> GstElement *multiudpsink1, *multiudpsink2;
>
> 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;
> }
>
> // I have rewrite this function
> static void on_pad_added(GstElement *element, GstPad *pad, gpointer data)
> {
>     GstCaps *caps;
>     GstStructure *str;
>     GstPad *t_pad;
>
>     caps=gst_pad_get_caps(pad);
>     str=gst_caps_get_structure(caps,0);
>
>     //
>          if (g_strrstr (gst_structure_get_name (str), "audio"))
>          {
>              t_pad = gst_element_get_static_pad (multiudpsink1, "sink");
>              g_print("rtp catch audio\n");
>          }
>          else if(g_strrstr (gst_structure_get_name (str), "vedio"))
>       {
>              t_pad = gst_element_get_static_pad (multiudpsink2, "sink");
>              g_print("rtp catch vedio\n");
>         }
>         else
>         {
>             gst_caps_unref (caps);
>             return;
>         }
>
>         if (GST_PAD_IS_LINKED (t_pad))
>       {
>           gst_caps_unref (caps);
>             g_object_unref (t_pad);
>             return;
>       }
>       //
>       else
>       {
>           //
>           gst_pad_link (pad, t_pad);
>           g_print("Dynamic pad created, linking rtpbin/udp\n");
>
>           gst_caps_unref (caps);
>             g_object_unref (t_pad);
>             return;
>       }
> }
>
> int main(int argc, char **argv)
> {
>     GMainLoop *loop;
>     GstBus *bus;
>     GstPad *pad;
>     GstCaps *videocap, *audiocap;
>     GstElement *pipeline, *gstrtpbin, *udpsrc1, *udpsrc2;
>
>
>     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");
>     multiudpsink1 = gst_element_factory_make("multiudpsink",
> "multiudpsink1");
>     multiudpsink2 = gst_element_factory_make("multiudpsink",
> "multiudpsink2");
>
>
>     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_INT, 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_INT, 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(multiudpsink1), "clients","172.21.29.169:5000,
> 172.21.29.168:5000", NULL);
>     g_object_set(G_OBJECT(multiudpsink2), "clients","172.21.29.169:5002,
> 172.21.29.168:5002", NULL);
>     g_object_set(G_OBJECT(multiudpsink1), "sync",FALSE, NULL);
>     g_object_set(G_OBJECT(multiudpsink2), "sync",FALSE, NULL);
>
>     gst_caps_unref(videocap);
>     gst_caps_unref(audiocap);
>
>     gst_bin_add_many(GST_BIN(pipeline), udpsrc1, udpsrc2, gstrtpbin,
> multiudpsink1, multiudpsink2, 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),NULL);
>
>     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;
> }
>
>
> ------------------------------
> 网易全新推出企业邮箱 <http://qiye.163.com/?ft=2>
>
> ------------------------------------------------------------------------------
> OpenSolaris 2009.06 is a cutting edge operating system for enterprises
> looking to deploy the next generation of Solaris that includes the latest
> innovations from Sun and the OpenSource community. Download a copy and
> enjoy capabilities such as Networking, Storage and Virtualization.
> Go to: http://p.sf.net/sfu/opensolaris-get
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20090603/0611ab83/attachment.htm>


More information about the gstreamer-devel mailing list