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;
//#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
static void do_seek (GtkWidget * widget);
-#ifdef SCRUB
static gboolean
end_scrub (GtkWidget * widget)
{
return FALSE;
}
-#endif
static gboolean
send_event (GstEvent * event)
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");
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
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;
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)
{
{
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},
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 =
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 ... */
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);