[gst-devel] CPU load while in GST_PAUSED_STATE
Thomas Comiotto
comiotto at rcfmedia.ch
Sat Jan 24 05:38:01 CET 2004
Hello,
I am running a most miminalistic pipeline videotestsrc ! xvideosink within a
GTK idle_func() for testing purposes using GST 6.4.
Now, as soon as I swich the pipeline to GST_PAUSED_STATE, or alternatively,
stop iterating the pipeline for a while, the CPU load goes up to all of the
available CPU time (97%) while the running/iterated pipeline generates a load
of 1.7%.
I thought an uniterated/paused pipeline would mean just freezing the stream in
its current state while doing _nothing_ so what am i missing?
I am using GST 6.4 because I can't figure out how to get the XID needed for
stealing sockets in GTK in GST7.3. What is the preferred method of including
GST videosinks in GTK widgets, since in 7.3 gst_util_get_int_arg () doesn't
seem to be available anymore.
Any hints would be very much appreciated!
Regards,
Thomas Comiotto
#include <gst/gst.h>
#include <gtk/gtk.h>
#include <unistd.h>
#include <stdlib.h>
#include <gnome.h>
#define SRC_WIDTH 640
#define SRC_HEIGHT 480
GstElement *pipeline;
GstElement *videotestsrc, *videosink;
gboolean have_size;
gboolean paused;
/* GTK Widgets */
GtkWidget *vw_window;
GtkWidget *vw_socket;
void
videosink_have_size (GstElement * videosink, gint width, gint height)
{
have_size = TRUE;
}
static
gboolean key_press_event (GtkWidget *widget, GdkEventKey *event)
{
switch (event->keyval) {
case GDK_Escape:
gtk_main_quit();
break;
case GDK_space:
{
if (paused) paused = FALSE;
else paused = TRUE;
break;
}
}
return TRUE;
}
void
init_all ()
{
/* GST Elements */
pipeline = gst_pipeline_new ("pipeline");
videotestsrc = gst_element_factory_make ("videotestsrc", "videotestsrc");
g_object_set (G_OBJECT (videotestsrc), "width", SRC_WIDTH, NULL);
g_object_set (G_OBJECT (videotestsrc), "height", SRC_HEIGHT, NULL);
videosink = gst_element_factory_make ("xvideosink", "videosink");
g_object_set (G_OBJECT (videosink), "toplevel", FALSE, NULL);
/* Assertions: */
g_assert (pipeline != NULL);
g_assert (videosink != NULL);
g_assert (videotestsrc != NULL);
/* GUI */
vw_window = gnome_app_new ("Video-Wall Client", "Video-Wall Client");
gtk_window_set_decorated (GTK_WINDOW (vw_window), FALSE);
vw_socket = gtk_socket_new ();
gtk_widget_show (vw_socket);
gnome_app_set_contents (GNOME_APP (vw_window), GTK_WIDGET (vw_socket));
g_signal_connect (G_OBJECT (vw_window), "key-press-event",
G_CALLBACK (key_press_event), NULL);
g_signal_connect (G_OBJECT (videosink), "have_size", G_CALLBACK
(videosink_have_size), pipeline);
/* GST Links */
gst_element_link_pads (videotestsrc, "src", videosink, "sink");
/* Add all element to their appropriate bins */
gst_bin_add (GST_BIN (pipeline), videotestsrc);
gst_bin_add (GST_BIN (pipeline), videosink);
have_size = FALSE;
}
gboolean
idle_func (gpointer data)
{
gboolean static first_time = TRUE;
if (first_time && have_size) {
gtk_widget_realize (vw_socket);
gtk_socket_steal (GTK_SOCKET (vw_socket), gst_util_get_int_arg (G_OBJECT
(videosink), "xid"));
gtk_widget_set_uposition (vw_window, 0, 0);
gtk_widget_set_usize (vw_window, gdk_screen_width (), gdk_screen_height ());
gtk_widget_show_all (vw_window);
first_time = FALSE;
}
/*
Replace the following swippet by
if (!paused) gst_bin_iterate (GST_BIN (pipeline));
doesn't make any difference regarding to CPU usage
*/
gst_bin_iterate (GST_BIN (pipeline));
if (paused) gst_element_set_state(pipeline, GST_STATE_PAUSED);
else gst_element_set_state(pipeline, GST_STATE_PLAYING);
return TRUE;
}
gint
main (gint argc, char *argv[])
{
gnome_init ("Video Client", "0.0.1", argc, argv);
gst_init (&argc, &argv);
init_all ();
gtk_idle_add (idle_func, NULL);
/* Main Loops */
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
gtk_main ();
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
gst_object_destroy (GST_OBJECT (pipeline));
g_print ("Normal Program Termination\n");
return 0;
}
More information about the gstreamer-devel
mailing list