From ca1aa6b21afb8041d5c14061227d7105b6e44b58 Mon Sep 17 00:00:00 2001 From: Damien Lespiau Date: Wed, 31 Mar 2010 18:13:34 +0100 Subject: tests: Add a test that seeks every 250 ms --- tests/.gitignore | 1 + tests/Makefile.am | 8 +++ tests/test-seek.c | 164 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 173 insertions(+) create mode 100644 tests/test-seek.c 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 + +#include +#include + +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]