Just for knowledge....<br>
I was able to avoid the 100% CPU usage doing these changes to the fakesrc example on the gst manual (note that I've used the directdrawsink and not the xvimagesink):<br><br>static void<br>cb_handoff (GstElement *fakesrc,
<br> GstBuffer *buffer,<br> GstPad *pad,<br> gpointer user_data)<br>{<br> static gboolean white = FALSE;<br><br> GTimeVal gtime;<br> g_get_current_time(&gtime);<br><br> GstClockTime gstClock=GST_TIMEVAL_TO_TIME(gtime);
<br><br>//basetime is a static GstClockTime var<br> buffer->timestamp= gstClock-baseTime;<br><br> memset (GST_BUFFER_DATA (buffer), white ? 0xff : 0x0,<br> GST_BUFFER_SIZE (buffer));<br> white = !white;<br>
<br>}<br><br><br><br>gint<br>main (gint argc,<br> gchar *argv[])<br>{<br> GstElement *pipeline, *fakesrc, *flt, *conv, *videosink,*parDDSink;<br> GMainLoop *loop;<br> GstBus* bus;<br><br> /* init GStreamer */<br>
gst_init (&argc, &argv);<br> loop = g_main_loop_new (NULL, FALSE);<br><br> /* setup pipeline */<br> pipeline = gst_pipeline_new ("pipeline");<br> fakesrc = gst_element_factory_make ("fakesrc", "source");
<br><br> gst_base_src_set_format((GstBaseSrc*)fakesrc,GST_FORMAT_TIME);<br><br> flt = gst_element_factory_make ("capsfilter", "flt");<br> conv = gst_element_factory_make ("ffmpegcolorspace", "conv");
<br> videosink = gst_element_factory_make ("directdrawsink", "directdraw");<br> parDDSink = gst_element_factory_make ("capsfilter", "ddSinkPar");<br> /* setup */<br> g_object_set (G_OBJECT (flt), "caps",
<br> gst_caps_new_simple ("video/x-raw-rgb",<br> "width", G_TYPE_INT, 384,<br> "height", G_TYPE_INT, 288,<br> "framerate", GST_TYPE_FRACTION, 1, 1,
<br> "bpp", G_TYPE_INT, 16,<br> "depth", G_TYPE_INT, 16,<br> "endianness", G_TYPE_INT, G_BYTE_ORDER,<br> NULL), NULL);
<br><br><br> g_object_set (G_OBJECT(parDDSink), "caps",<br> gst_caps_new_simple ("video/x-raw-rgb",<br> "width", G_TYPE_INT, 384,<br> "height", G_TYPE_INT, 288,
<br> "framerate",GST_TYPE_FRACTION, 1, 1),<br> NULL);<br><br> gst_bin_add_many (GST_BIN (pipeline), fakesrc, flt,conv,parDDSink, videosink, NULL);<br><br> gst_element_link_many (fakesrc, flt, conv, parDDSink,videosink, NULL);
<br><br><br> bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));<br> gst_bus_add_watch (bus, bus_call, loop);<br> gst_object_unref (bus);<br><br> /* setup fake source */<br> g_object_set (G_OBJECT (fakesrc),<br> "signal-handoffs", TRUE,
<br> "sizemax", 384 * 288 * 2,<br> "sizetype", 2, NULL);<br> g_signal_connect (fakesrc, "handoff", G_CALLBACK (cb_handoff), NULL);<br><br> /* play */<br> gst_element_set_state (pipeline, GST_STATE_PLAYING);
<br><br> GstClock *clock;<br> clock=gst_pipeline_get_clock ((GstPipeline*)pipeline);<br> baseTime=gst_clock_get_time(clock);<br><br> g_main_loop_run (loop);<br><br> /* clean up */<br> gst_element_set_state (pipeline, GST_STATE_NULL);
<br> gst_object_unref (GST_OBJECT (pipeline));<br><br> return 0;<br>}<br><br><br>Simply I've done some add on the time management, unfortunately I can't reach the flow control of 1fps and the video is flickering as fast as it can with a strange behaviour: if I run the example with GST_DEBUG >= 3 the fps is exactly 1, this is a very mistery for me....
<br><br>Hope that's helpfull for some of you.<br><br>Regards.<br><br><br><br clear="all"><br>-- <br>Riccardo Corona