[gst-devel] How control state of a video streaming pipeline & g_main_loop_run()

djlorenzoc l.centurelli at gmail.com
Sat Jul 17 21:24:20 CEST 2010


Hi everybody,
I'm using a TI board and I need to implement a #C streaming video pipeline.
The  pipe is :

gst-launch -v v4l2src ! TIVidenc1 codecName=mpeg4enc engineName=encode
contiguousInputFrame=TRUE ! rtpmp4vpay !
 udpsink host=<HOST IP ADDRESS> port=5000

I'm new with the #C implementation of the pipes. I tried to implement it in
this way:
##################################################################
  GstElement *pipeline, *source,*sink,*encoder,*payloader;//dichiarazione
dei plugin utilizzati
  GMainLoop *loop=g_main_loop_new(NULL,FALSE);
  gst_init (&argc, &argv);
  pipeline = gst_pipeline_new ("pipe_prova");
  source   = gst_element_factory_make ("v4l2src",       "video_source");
  encoder = gst_element_factory_make ("TIVidenc1",      "encoder_mpeg4");
  payloader= gst_element_factory_make ("rtpmp4vpay",     
"payloader_mpeg4");
  sink     = gst_element_factory_make ("udpsink", "output");
  videorate = gst_element_factory_make ("videorate", "videorate");  
                .
                .
                .
                .
 /* we add all elements into the pipeline */
  gst_bin_add_many (GST_BIN (pipeline),
                    source, videorate, filter, encoder, payloader, sink,
NULL);
  gst_element_link_many (source, videorate, filter, encoder, payloader,
sink, NULL); 
  /* Set the pipeline to "playing" state*/
  gst_element_set_state (pipeline, GST_STATE_PLAYING);
  g_main_loop_run(loop);
##########################################################

This is my simple program,without caps settings.
I want to control its state from an external program,but I saw that
g_main_loop_run() blocks the execution of the pipe.
I thought 2 solutions:
-1) Control the state of the pipe: when I want to stop stream I set the pipe
to the READY state; when I want to stream I set it to PLAY. I think that in
this way I reduce the launch time of the pipe. Is it exactly?
Have I to add a bus? Can anyone suggest me a possible solution?

2) Launch a g_main_loop_quit. 
What do you think about? Is it possible to do that? 

Thank you for your attention

Regards

Lorenzo
-- 
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/How-control-state-of-a-video-streaming-pipeline-g-main-loop-run-tp2292629p2292629.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.




More information about the gstreamer-devel mailing list