From e92b1b7edc1079307a5c55f34a1ae8c0f9e1b71c Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 8 May 2002 20:18:13 +0000 Subject: [PATCH] Added simple seeking testsuite Original commit message from CVS: Added simple seeking testsuite Added effectv --- configure.ac | 4 +- testsuite/seeking/Makefile.am | 9 +++ testsuite/seeking/seek1.c | 117 ++++++++++++++++++++++++++++++++++ 3 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 testsuite/seeking/Makefile.am create mode 100644 testsuite/seeking/seek1.c diff --git a/configure.ac b/configure.ac index a674cb5b32..83230534bb 100644 --- a/configure.ac +++ b/configure.ac @@ -170,7 +170,7 @@ AC_SUBST(GST_PLUGIN_LDFLAGS) dnl these are all the gst plugins, compilable without additional libs GST_PLUGINS_ALL="\ ac3parse adder audioscale auparse avi cdxaparse chart\ - cutter deinterlace festival flx goom intfloat law level\ + cutter deinterlace effectv festival flx goom intfloat law level\ median mpeg1enc mpeg1sys mpeg1videoparse mpeg2enc mpeg2sub\ mpegaudio mpegaudioparse mpegstream mpegtypes modplug\ monoscope passthrough playondemand qtdemux rtjpeg silence sine\ @@ -760,6 +760,7 @@ gst/cdxaparse/Makefile gst/chart/Makefile gst/cutter/Makefile gst/deinterlace/Makefile +gst/effectv/Makefile gst/festival/Makefile gst/flx/Makefile gst/goom/Makefile @@ -855,6 +856,7 @@ gst-libs/gst/floatcast/Makefile examples/capsfilter/Makefile examples/Makefile tools/Makefile +testsuite/seeking/Makefile ) AC_OUTPUT diff --git a/testsuite/seeking/Makefile.am b/testsuite/seeking/Makefile.am new file mode 100644 index 0000000000..f8bfe7d43b --- /dev/null +++ b/testsuite/seeking/Makefile.am @@ -0,0 +1,9 @@ +testprogs = seek1 ## autoplug3 ## autoplug4 # autoplug2 + +TESTS = $(testprogs) + +check_PROGRAMS = $(testprogs) + +# we have nothing but apps here, we can do this safely +LIBS = $(GST_LIBS) $(GTK_LIBS) +CFLAGS = $(GST_CFLAGS) $(GTK_CFLAGS) diff --git a/testsuite/seeking/seek1.c b/testsuite/seeking/seek1.c new file mode 100644 index 0000000000..63550880a4 --- /dev/null +++ b/testsuite/seeking/seek1.c @@ -0,0 +1,117 @@ +#include +#include +#include + +static GstElement *src, *mad, *osssink, *pipeline; + +static void +set_seek (GtkAdjustment *adj, gpointer data) +{ + g_print ("%f\n", adj->value); + + gst_pad_send_event (gst_element_get_pad (mad, "src"), + gst_event_new_seek (GST_SEEK_BYTEOFFSET_SET, adj->value*1000, TRUE)); + +} + +static void +play_cb (GtkButton * button, gpointer data) +{ + GstElement *pipeline = GST_ELEMENT (data); + + gst_element_set_state (pipeline, GST_STATE_PLAYING); + gtk_idle_add ((GtkFunction) gst_bin_iterate, pipeline); +} + +static void +pause_cb (GtkButton * button, gpointer data) +{ + GstElement *pipeline = GST_ELEMENT (data); + + gst_element_set_state (pipeline, GST_STATE_PAUSED); +} + +static void +stop_cb (GtkButton * button, gpointer data) +{ + GstElement *pipeline = GST_ELEMENT (data); + + gst_element_set_state (pipeline, GST_STATE_READY); +} + +int +main (int argc, char **argv) +{ + guint channels; + GtkWidget *window, *hbox, *play_button, *pause_button, *stop_button, *quit_button, *hscale; + + gst_init (&argc, &argv); + gtk_init (&argc, &argv); + + if (argc != 2) { + g_print ("usage: %s \n", argv[0]); + exit (-1); + } + + src = gst_element_factory_make ("filesrc", "filesrc"); + mad = gst_element_factory_make ("mad", "mad"); + osssink = gst_element_factory_make ("osssink", "osssink"); + + g_object_set (G_OBJECT (src), "location", argv[1], NULL); + g_object_set (G_OBJECT (osssink), "fragment", 0x00180008, NULL); + g_object_get (G_OBJECT (osssink), "channels", &channels, NULL); + + pipeline = gst_pipeline_new ("app"); + + gst_bin_add (GST_BIN (pipeline), src); + gst_bin_add (GST_BIN (pipeline), mad); + gst_bin_add (GST_BIN (pipeline), osssink); + + gst_element_connect (src, mad); + gst_element_connect (mad, osssink); + + + /* initialize gui elements ... */ + window = gtk_window_new (GTK_WINDOW_TOPLEVEL); + hbox = gtk_hbox_new (FALSE, 0); + play_button = gtk_button_new_with_label ("play"); + pause_button = gtk_button_new_with_label ("pause"); + stop_button = gtk_button_new_with_label ("stop"); + quit_button = gtk_button_new_with_label ("quit"); + + hscale = gtk_hscale_new (GTK_ADJUSTMENT (gtk_adjustment_new (1.0, 0.01, 100.0, 0.1, 0.0, 0.0))); + gtk_scale_set_digits (GTK_SCALE (hscale), 2); + gtk_range_set_update_policy (GTK_RANGE (hscale), GTK_UPDATE_CONTINUOUS); + + gtk_signal_connect(GTK_OBJECT(gtk_range_get_adjustment(GTK_RANGE(hscale))), + "value_changed", G_CALLBACK (set_seek), osssink); + + /* do the packing stuff ... */ + gtk_window_set_default_size (GTK_WINDOW (window), 96, 96); + gtk_container_add (GTK_CONTAINER (window), hbox); + gtk_box_pack_start (GTK_BOX (hbox), play_button, FALSE, FALSE, 2); + gtk_box_pack_start (GTK_BOX (hbox), pause_button, FALSE, FALSE, 2); + gtk_box_pack_start (GTK_BOX (hbox), stop_button, FALSE, FALSE, 2); + gtk_box_pack_start (GTK_BOX (hbox), quit_button, FALSE, FALSE, 2); + gtk_box_pack_start (GTK_BOX (hbox), hscale, TRUE, TRUE, 2); + + /* connect things ... */ + g_signal_connect (G_OBJECT (play_button), "clicked", G_CALLBACK (play_cb), pipeline); + g_signal_connect (G_OBJECT (pause_button), "clicked", G_CALLBACK (pause_cb), pipeline); + g_signal_connect (G_OBJECT (stop_button), "clicked", G_CALLBACK (stop_cb), pipeline); + g_signal_connect (G_OBJECT (quit_button), "clicked", gtk_main_quit, NULL); + + /* show the gui. */ + gtk_widget_show (play_button); + gtk_widget_show (pause_button); + gtk_widget_show (stop_button); + gtk_widget_show (quit_button); + gtk_widget_show (hscale); + gtk_widget_show (hbox); + gtk_widget_show (window); + + + gtk_main (); + + return 0; +}