[gst-devel] autoseek patch for gst-player
Joshua N Pritikin
vishnu at pobox.com
Thu Nov 7 06:03:05 CET 2002
This patch adds a menu item toggle "Auto Seek". When active and the
media is play, it will seek to a new position every five seconds.
i find this valuable for testing the robustness of seeking.
We can most this to a debug menu once gst-player is more stable.
--
Victory to the Divine Mother!! after all,
http://sahajayoga.org http://why-compete.org
-------------- next part --------------
Index: main.c
===================================================================
RCS file: /cvsroot/gstreamer/gst-player/src/main.c,v
retrieving revision 1.21
diff -u -u -r1.21 main.c
--- main.c 30 Oct 2002 21:16:26 -0000 1.21
+++ main.c 7 Nov 2002 13:58:14 -0000
@@ -147,6 +147,42 @@
}
static void
+_do_random_seek (GstMediaPlay *mplay)
+{
+ if (gst_play_get_state (mplay->play) != GST_STATE_PLAYING)
+ return;
+
+ gint64 offset = (((gint64) g_random_int () << 31) +
+ g_random_int ()) % mplay->length_nanos;
+
+ static gint seek_count = 0;
+ g_print ("[%d] seek to 0x%llx of 0x%llx\n",
+ ++seek_count, offset, mplay->length_nanos);
+
+ gst_play_seek_to_time (mplay->play, offset);
+}
+
+static gboolean
+_random_seek_timer (GstMediaPlay *mplay)
+{ _do_random_seek (mplay); return TRUE; }
+
+static guint autoseek_id = 0;
+static void
+toggle_autoseek (GtkWidget *widget, GstMediaPlay *mplay)
+{
+ if (autoseek_id)
+ {
+ g_source_remove (autoseek_id);
+ autoseek_id = 0;
+ }
+ else
+ {
+ autoseek_id =
+ g_timeout_add (5 * 1000, (GSourceFunc) _random_seek_timer, mplay);
+ }
+}
+
+static void
current_location (GstMediaPlay *mplay, gchar *location, gchar *location_short, GtkWidget *window)
{
gtk_window_set_title (GTK_WINDOW (window),location_short);
@@ -299,6 +335,14 @@
toggle_fullscreen, NULL, NULL,
GNOME_APP_PIXMAP_NONE, NULL,
GDK_4, (GdkModifierType) GDK_CONTROL_MASK, NULL
+ },
+ GNOMEUIINFO_SEPARATOR,
+ {
+ GNOME_APP_UI_ITEM, N_("_Auto Seek"),
+ NULL,
+ toggle_autoseek, NULL, NULL,
+ GNOME_APP_PIXMAP_NONE, NULL,
+ 0, 0, NULL
},
GNOMEUIINFO_END
};
More information about the gstreamer-devel
mailing list