summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Lespiau <damien.lespiau@intel.com>2010-03-31 18:13:34 +0100
committerDamien Lespiau <damien.lespiau@intel.com>2010-03-31 18:13:34 +0100
commitca1aa6b21afb8041d5c14061227d7105b6e44b58 (patch)
tree67b01ac66de9a70adf7e4c4ca287bc4451281627
parentbb44a5e7ff8bf60d321dbb0f9f275af29a773608 (diff)
downloadclutter-gst-ca1aa6b21afb8041d5c14061227d7105b6e44b58.tar.gz
tests: Add a test that seeks every 250 ms
-rw-r--r--tests/.gitignore1
-rw-r--r--tests/Makefile.am8
-rw-r--r--tests/test-seek.c164
3 files changed, 173 insertions, 0 deletions
diff --git a/tests/.gitignore b/tests/.gitignore
index feee60f..56c780c 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -1,4 +1,5 @@
test-alpha
test-rgb-upload
+test-seek
test-start-stop
test-yuv-upload
diff --git a/tests/Makefile.am b/tests/Makefile.am
index f62de48..b35d3c6 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -3,6 +3,7 @@ NULL = #
noinst_PROGRAMS = \
test-alpha \
test-rgb-upload \
+ test-seek \
test-start-stop \
test-yuv-upload \
$(NULL)
@@ -25,6 +26,13 @@ test_rgb_upload_LDFLAGS = \
$(GST_LIBS) \
$(top_builddir)/clutter-gst/libclutter-gst-@CLUTTER_GST_MAJORMINOR@.la
+test_seek_SOURCES = test-seek.c
+test_seek_CFLAGS = $(CLUTTER_GST_CFLAGS) $(GST_CFLAGS)
+test_seek_LDFLAGS = \
+ $(CLUTTER_GST_LIBS) \
+ $(GST_LIBS) \
+ $(top_builddir)/clutter-gst/libclutter-gst-@CLUTTER_GST_MAJORMINOR@.la
+
test_start_stop_SOURCES = test-start-stop.c
test_start_stop_CFLAGS = $(CLUTTER_GST_CFLAGS) $(GST_CFLAGS)
test_start_stop_LDFLAGS = \
diff --git a/tests/test-seek.c b/tests/test-seek.c
new file mode 100644
index 0000000..c07ac36
--- /dev/null
+++ b/tests/test-seek.c
@@ -0,0 +1,164 @@
+/*
+ * Clutter-GStreamer.
+ *
+ * GStreamer integration library for Clutter.
+ *
+ * video-player.c - A simple fullscreen video player with an OSD.
+ *
+ * Copyright (C) 2007,2008 OpenedHand
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <stdlib.h>
+
+#include <clutter/clutter.h>
+#include <clutter-gst/clutter-gst.h>
+
+static gboolean
+random_seek (ClutterGstVideoTexture *video_texture)
+{
+ double progress;
+
+ progress = g_random_double ();
+
+ printf ("progress %lf\n", progress);
+ clutter_media_set_progress (CLUTTER_MEDIA (video_texture), progress);
+
+ return TRUE;
+}
+
+static void
+on_playing (ClutterGstVideoTexture *video_texture,
+ GParamSpec *pspec,
+ gpointer data)
+{
+ g_timeout_add (250, (GSourceFunc) random_seek, video_texture);
+}
+
+static gboolean
+input_cb (ClutterStage *stage,
+ ClutterEvent *event,
+ gpointer user_data)
+{
+ switch (event->type)
+ {
+ case CLUTTER_KEY_PRESS:
+ switch (clutter_event_get_key_symbol (event))
+ {
+ case CLUTTER_q:
+ case CLUTTER_Escape:
+ clutter_main_quit ();
+ break;
+ }
+ default:
+ break;
+ }
+
+ return FALSE;
+}
+
+static void
+size_change (ClutterTexture *texture,
+ gint width,
+ gint height,
+ ClutterActor *stage)
+{
+ gfloat new_x, new_y, new_width, new_height;
+ gfloat stage_width, stage_height;
+
+ clutter_actor_get_size (stage, &stage_width, &stage_height);
+
+ new_height = (height * stage_width) / width;
+ if (new_height <= stage_height)
+ {
+ new_width = stage_width;
+
+ new_x = 0;
+ new_y = (stage_height - new_height) / 2;
+ }
+ else
+ {
+ new_width = (width * stage_height) / height;
+ new_height = stage_height;
+
+ new_x = (stage_width - new_width) / 2;
+ new_y = 0;
+ }
+
+ clutter_actor_set_position (CLUTTER_ACTOR (texture), new_x, new_y);
+ clutter_actor_set_size (CLUTTER_ACTOR (texture), new_width, new_height);
+}
+
+int
+main (int argc, char *argv[])
+{
+ ClutterActor *stage, *video_texture;
+ ClutterColor stage_color = { 0x00, 0x00, 0x00, 0x00 };
+ GError *error = NULL;
+
+ if (!g_thread_supported ())
+ g_thread_init (NULL);
+
+ clutter_gst_init_with_args (&argc,
+ &argv,
+ " - Test seeking with ClutterGstVideoTexture",
+ NULL,
+ NULL,
+ &error);
+
+ if (argc < 2)
+ {
+ g_print ("Usage: %s [OPTIONS] <video file>\n", argv[0]);
+ return EXIT_FAILURE;
+ }
+
+ stage = clutter_stage_get_default ();
+ clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
+
+ video_texture = clutter_gst_video_texture_new ();
+ g_assert (video_texture);
+
+ g_object_set (G_OBJECT(video_texture), "sync-size", FALSE, NULL);
+
+ /* Handle it ourselves so can scale up for fullscreen better */
+ g_signal_connect (CLUTTER_TEXTURE (video_texture),
+ "size-change",
+ G_CALLBACK (size_change), stage);
+
+ /* Load up out video texture */
+ clutter_media_set_filename (CLUTTER_MEDIA (video_texture), argv[1]);
+ clutter_media_set_audio_volume (CLUTTER_MEDIA (video_texture), 0.5);
+ g_signal_connect (video_texture,
+ "notify::duration",
+ G_CALLBACK (on_playing), NULL);
+
+ /* Add control UI to stage */
+ clutter_container_add_actor (CLUTTER_CONTAINER (stage), video_texture);
+
+ clutter_stage_hide_cursor (CLUTTER_STAGE (stage));
+
+ /* Hook up other events */
+ g_signal_connect (stage, "event", G_CALLBACK (input_cb), stage);
+
+ clutter_media_set_playing (CLUTTER_MEDIA (video_texture), TRUE);
+
+ clutter_actor_show (stage);
+
+ clutter_main ();
+
+ return 0;
+}