Pipeline implementation question

Florian Lier fl0 at icram.de
Fri Jun 3 04:23:49 PDT 2011


Hello all,

I have a problem which is similar to Bernhards (I guess, due to my
limited GS knowledge) ...
The best approach to describe my problem maybe is to create a very
simple example pipeline
like this one:

"gst-launch-0.10 v4l2src ! queue ! xvimagesink pulsesrc ! queue ! pulsesink"

 
AFAIK one would implement this like the following (*pseudo-code*)

bin = gst_pipeline_new("Pipeline");
v4l2src = gst_element_factory_make ("v4l2src", "videosrc");
queue = gst_element_factory_make ("queue", "queue");
xvimagesink = gst_element_factory_make ("xvimagesink", "xvimagesink");
pulsesrc = gst_element_factory_make ("pulsesrc", "audiosrc");
queue2 = gst_element_factory_make ("queue", "queue2");
pulsesink = gst_element_factory_make ("pulsesink", "audiosink");

Now:

gst_bin_add_many(GST_BIN(bin), v4l2src, queue, xvimagesink, pulsesrc, 
queue2, pulsesink, NULL);

In the next step one would link the elements and that's when I get
confused - You don't actually "link" the
imagesink to the pulsesrc - How do you implement this pipeline?

gst_element_link_many(v4l2src, queue, xvimagesink, pulsesrc,  queue2,
pulsesink, NULL);

Doesn't work and produces a SegFault...
  

Thanks in advance, cheers - Florian


On 06/03/2011 12:20 PM, Bernhard Graaf wrote:
>
> Hi,
>
>  
>
> I need help to generate my own ,C'-Program from a running pipe:
>
>  
>
> gst-launch-0.10 tcpclientsrc host='192.168.1.3' port=8080 !
> mpegtsdemux name=demux ! queue ! mpeg2dec ! xvimagesink
> force-aspect-ratio=TRUE demux. ! queue ! mad ! alsasink
>
> With this pipe, I have no problem. It's running very well.
>
>  
>
> But if I try to compile this pipe in my own program, I'll get no results.
>
>  
>
> -----------------------------
>
> #include <stdio.h>
>
> #include <unistd.h>
>
> #include <gst/gst.h>
>
> #include <glib.h>
>
>  
>
>  
>
> GstElement *tv_pipe, *tv_source, *tv_mux, *tv_queue, *tv_v_dec,
> *tv_v_sink, *tv_a_dec, *tv_a_sink;
>
> GstBus *tv_bus;
>
> GMainLoop *loop;
>
>  
>
> static gboolean
>
> tv_bus_call (GstBus     *tmp_bus,
>
>           GstMessage *msg,
>
>           gpointer    data)
>
> {
>
>   GMainLoop *loop = (GMainLoop *) data;
>
>  
>
>   switch (GST_MESSAGE_TYPE (msg)) {
>
>  
>
>     case GST_MESSAGE_EOS:
>
>       g_print ("End of stream\n");
>
>       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);
>
>  
>
>       break;
>
>     }
>
>     default:
>
>       break;
>
>   }
>
>  
>
>   return TRUE;
>
> }
>
>  
>
>  
>
> int init_gst()
>
> {
>
>   gst_init (0, NULL);
>
>  
>
>   loop = g_main_loop_new (NULL, FALSE);
>
>  
>
>   tv_pipe = gst_pipeline_new ("TV-Stream");
>
>     if(!tv_pipe) g_printerr("TV-Stream-Pipeline not created\n");
>
>  
>
>   tv_source   = gst_element_factory_make ("tcpclientsrc", "tv-source");
>
>     if(!tv_source) g_printerr("TV-Source not created\n");
>
>  
>
>   tv_mux     = gst_element_factory_make ("mpegtsdemux", "tv-mux");
>
>     if(!tv_mux) g_printerr("TV-Mux not created\n");
>
>  
>
>   tv_queue     = gst_element_factory_make ("queue", "tv-queue");
>
>     if(!tv_queue) g_printerr("TV-Queue not created\n");
>
>  
>
>   tv_v_dec     = gst_element_factory_make ("mpeg2dec", "tv-v-dec");
>
>     if(!tv_v_dec) g_printerr("TV-Video-Dec not created\n");
>
>  
>
>   tv_v_sink     = gst_element_factory_make ("xvimagesink", "tv-v-sink");
>
>     if(!tv_v_sink) g_printerr("TV-Video-Sink not created\n");
>
>  
>
>   tv_a_dec     = gst_element_factory_make ("mad", "tv-a-dec");
>
>     if(!tv_a_dec) g_printerr("TV-Audio-Dec not created\n");
>
>  
>
>   tv_a_sink     = gst_element_factory_make ("alsasink", "tv-a-sink");
>
>     if(!tv_a_sink) g_printerr("TV-Audio-Sink not created\n");
>
>  
>
>  
>
>   tv_bus = gst_pipeline_get_bus (GST_PIPELINE (tv_pipe));
>
>   gst_bus_add_watch (tv_bus, tv_bus_call, loop);
>
>   gst_object_unref (tv_bus);
>
>  
>
>   gst_bin_add_many (GST_BIN (tv_pipe), tv_source, tv_mux, tv_queue,
> tv_v_dec, tv_v_sink, tv_a_dec, tv_a_sink, NULL);
>
>  
>
>   gst_element_link (tv_source, tv_mux);
>
>   gst_element_link (tv_mux, tv_queue);
>
>   gst_element_link (tv_queue, tv_v_dec);
>
>   gst_element_link (tv_v_dec, tv_v_sink);
>
>   gst_element_link (tv_queue, tv_a_dec);
>
>   gst_element_link (tv_a_dec, tv_a_sink);
>
>  
>
>   return 1;
>
> }
>
>  
>
> int send_tv()
>
> {
>
>   gst_element_set_state (tv_pipe, GST_STATE_NULL);
>
>  
>
>   g_object_set (G_OBJECT (tv_source), "host", "192.168.1.3", NULL);
>
>   g_object_set (G_OBJECT (tv_source), "port", 8080, NULL);
>
>  
>
>   g_print ("Now playing: TV\n");
>
>   gst_element_set_state (tv_pipe, GST_STATE_PLAYING);
>
>  
>
>   g_print ("Running...\n");
>
>   return 0;
>
> }
>
>  
>
> int main()
>
> {
>
>  
>
>   if(!tv_pipe) init_gst();
>
>   send_tv();
>
>   g_main_loop_run (loop);
>
>   return(1);
>
> }
>
>  
>
> -------------------------
>
> I there anybody how can tell me what's wrong with this program?
>
>  
>
>  
>
> Thank's a lot for helping!!!!
>
> Bernhard
>
>
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>   

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20110603/ab683d8d/attachment-0001.html>


More information about the gstreamer-devel mailing list