tests/examples/seek/seek.c: Add scrub checkbox.

Original commit message from CVS:
* tests/examples/seek/seek.c: (end_scrub), (do_seek), (seek_cb),
(stop_seek), (scrub_toggle_cb), (main):
Add scrub checkbox.
This commit is contained in:
Wim Taymans 2006-03-22 12:28:36 +00:00
parent 81d110160b
commit 97a3b710df
2 changed files with 35 additions and 18 deletions

View file

@ -1,3 +1,9 @@
2006-03-22 Wim Taymans <wim@fluendo.com>
* tests/examples/seek/seek.c: (end_scrub), (do_seek), (seek_cb),
(stop_seek), (scrub_toggle_cb), (main):
Add scrub checkbox.
2006-03-21 Tim-Philipp Müller <tim at centricular dot net>
* ext/ogg/gstoggparse.c: (gst_ogg_parse_find_stream),

View file

@ -15,6 +15,7 @@ static gboolean accurate_seek = FALSE;
static gboolean keyframe_seek = FALSE;
static gboolean loop_seek = FALSE;
static gboolean flush_seek = TRUE;
static gboolean scrub = FALSE;
static GstElement *pipeline;
static gint64 position;
@ -41,11 +42,14 @@ static gulong changed_id;
//#define VSINK "cacasink"
//#define UPDATE_INTERVAL 500
#define UPDATE_INTERVAL 100
//#define UPDATE_INTERVAL 100
#define UPDATE_INTERVAL 10
/* number of milliseconds to play for after a seek */
//#define SCRUB_TIME 250
//#define SCRUB
#define SCRUB_TIME 100
/* seek timeout */
#define SEEK_TIMEOUT 40 * GST_MSECOND
#define THREAD
#define PAD_SEEK
@ -997,7 +1001,6 @@ update_scale (gpointer data)
static void do_seek (GtkWidget * widget);
#ifdef SCRUB
static gboolean
end_scrub (GtkWidget * widget)
{
@ -1006,7 +1009,6 @@ end_scrub (GtkWidget * widget)
return FALSE;
}
#endif
static gboolean
send_event (GstEvent * event)
@ -1074,8 +1076,7 @@ do_seek (GtkWidget * widget)
if (res) {
if (flush_seek) {
gst_pipeline_set_new_stream_time (GST_PIPELINE (pipeline), 0);
gst_element_get_state (GST_ELEMENT (pipeline), NULL, NULL,
50 * GST_MSECOND);
gst_element_get_state (GST_ELEMENT (pipeline), NULL, NULL, SEEK_TIMEOUT);
}
} else
g_print ("seek failed\n");
@ -1084,23 +1085,21 @@ do_seek (GtkWidget * widget)
static void
seek_cb (GtkWidget * widget)
{
#ifdef SCRUB
/* If the timer hasn't expired yet, then the pipeline is running */
if (seek_timeout_id != 0) {
if (scrub && seek_timeout_id != 0) {
gst_element_set_state (pipeline, GST_STATE_PAUSED);
}
#endif
do_seek (widget);
#ifdef SCRUB
gst_element_set_state (pipeline, GST_STATE_PLAYING);
if (scrub) {
gst_element_set_state (pipeline, GST_STATE_PLAYING);
if (seek_timeout_id == 0) {
seek_timeout_id =
g_timeout_add (SCRUB_TIME, (GSourceFunc) end_scrub, widget);
if (seek_timeout_id == 0) {
seek_timeout_id =
g_timeout_add (SCRUB_TIME, (GSourceFunc) end_scrub, widget);
}
}
#endif
}
static void
@ -1152,10 +1151,10 @@ stop_seek (GtkWidget * widget, gpointer user_data)
seek_timeout_id = 0;
/* Still scrubbing, so the pipeline is already playing */
} else {
if (state == GST_STATE_PLAYING)
if (state == GST_STATE_PLAYING) {
gst_element_set_state (pipeline, GST_STATE_PLAYING);
}
}
set_update_scale (TRUE);
return FALSE;
@ -1253,6 +1252,12 @@ flush_toggle_cb (GtkToggleButton * button, GstPipeline * pipeline)
flush_seek = gtk_toggle_button_get_active (button);
}
static void
scrub_toggle_cb (GtkToggleButton * button, GstPipeline * pipeline)
{
scrub = gtk_toggle_button_get_active (button);
}
static void
segment_done (GstBus * bus, GstMessage * message, GstPipeline * pipeline)
{
@ -1343,6 +1348,7 @@ main (int argc, char **argv)
{
GtkWidget *window, *hbox, *vbox, *play_button, *pause_button, *stop_button;
GtkWidget *accurate_checkbox, *key_checkbox, *loop_checkbox, *flush_checkbox;
GtkWidget *scrub_checkbox;
GOptionEntry options[] = {
{"stats", 's', 0, G_OPTION_ARG_NONE, &stats,
"Show pad stats", NULL},
@ -1396,6 +1402,8 @@ main (int argc, char **argv)
key_checkbox = gtk_check_button_new_with_label ("Key_unit Seek");
loop_checkbox = gtk_check_button_new_with_label ("Loop");
flush_checkbox = gtk_check_button_new_with_label ("Flush");
scrub_checkbox = gtk_check_button_new_with_label ("Scrub");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (flush_checkbox), TRUE);
adjustment =
@ -1422,6 +1430,7 @@ main (int argc, char **argv)
gtk_box_pack_start (GTK_BOX (hbox), key_checkbox, FALSE, FALSE, 2);
gtk_box_pack_start (GTK_BOX (hbox), loop_checkbox, FALSE, FALSE, 2);
gtk_box_pack_start (GTK_BOX (hbox), flush_checkbox, FALSE, FALSE, 2);
gtk_box_pack_start (GTK_BOX (hbox), scrub_checkbox, FALSE, FALSE, 2);
gtk_box_pack_start (GTK_BOX (vbox), hscale, TRUE, TRUE, 2);
/* connect things ... */
@ -1439,6 +1448,8 @@ main (int argc, char **argv)
G_CALLBACK (loop_toggle_cb), pipeline);
g_signal_connect (G_OBJECT (flush_checkbox), "toggled",
G_CALLBACK (flush_toggle_cb), pipeline);
g_signal_connect (G_OBJECT (scrub_checkbox), "toggled",
G_CALLBACK (scrub_toggle_cb), pipeline);
g_signal_connect (G_OBJECT (window), "destroy", gtk_main_quit, NULL);