How control state of a video streaming pipeline & g_main_loop_run()

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

How control state of a video streaming pipeline & g_main_loop_run()

djlorenzoc
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
Reply | Threaded
Open this post in threaded view
|

Re: How control state of a video streaming pipeline & g_main_loop_run()

djlorenzoc
 
Reply | Threaded
Open this post in threaded view
|

Re: How control state of a video streaming pipeline & g_main_loop_run()

Sandeep Prakash
In reply to this post by djlorenzoc
Hi,

djlorenzoc wrote
 /* 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);
What is the role of the "filter" element here?

djlorenzoc wrote
I want to control its state from an external program,but I saw that g_main_loop_run() blocks the execution of the pipe.
By external program you mean from a different process launched from the same application, or a completely different program, or a different thread?? Plz Explain.

djlorenzoc wrote
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?
You can add a bus watch as follows:
gboolean bus_call(GstBus *bus, GstMessage *msg, gpointer data)
{
}
.
.
.
bus = gst_pipeline_get_bus (GST_PIPELINE(pipeline));
gst_bus_add_watch (bus, bus_call, NULL);
gst_object_unref (bus);


djlorenzoc wrote
2) Launch a g_main_loop_quit.
What do you think about? Is it possible to do that?
Not sure what is "Launching a g_main_loop_quit" is? Plz Explain.


Regards,
Sandeep
Reply | Threaded
Open this post in threaded view
|

Re: How control state of a video streaming pipeline & g_main_loop_run()

Sudarshan Bisht
 
 g_main_loop_quit can be used inside the bus callback handler , once you get the NULL state of pipeline . 

 
On Mon, Jul 19, 2010 at 10:38 AM, Sandeep Prakash <[hidden email]> wrote:

Hi,


djlorenzoc wrote:
>
>  /* 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);
>
What is the role of the "filter" element here?


djlorenzoc wrote:
>
> I want to control its state from an external program,but I saw that
> g_main_loop_run() blocks the execution of the pipe.
>
By external program you mean from a different process launched from the same
application, or a completely different program, or a different thread?? Plz
Explain.


djlorenzoc wrote:
>
> 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?
>
You can add a bus watch as follows:
gboolean bus_call(GstBus *bus, GstMessage *msg, gpointer data)
{
}
.
.
.
bus = gst_pipeline_get_bus (GST_PIPELINE(pipeline));
gst_bus_add_watch (bus, bus_call, NULL);
gst_object_unref (bus);



djlorenzoc wrote:
>
> 2) Launch a g_main_loop_quit.
> What do you think about? Is it possible to do that?
>
Not sure what is "Launching a g_main_loop_quit" is? Plz Explain.


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

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel



--
Regards,

Sudarshan Bisht

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel