summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek.chauhan@collabora.co.uk>2012-12-23 09:19:27 +0530
committerDamien Lespiau <damien.lespiau@intel.com>2013-01-03 17:21:57 +0000
commita1986444896ead135647729eaa9c4cc83c141ab5 (patch)
tree377ce46ae91e7a9efeb2b5871277f3f9e1d2262a /examples
parent886c5df923ec972f4dd8bc6d5bfe6eda5b41b6dd (diff)
downloadclutter-gst-a1986444896ead135647729eaa9c4cc83c141ab5.tar.gz
video-player: Play the goom visualisation if there's no video
Bugzilla: https://bugzilla.gnome.org/show_bug.cgi?id=690659
Diffstat (limited to 'examples')
-rw-r--r--examples/video-player.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/examples/video-player.c b/examples/video-player.c
index a0dcd36..cd973e5 100644
--- a/examples/video-player.c
+++ b/examples/video-player.c
@@ -6,6 +6,7 @@
* video-player.c - A simple video player with an OSD.
*
* Copyright (C) 2007,2008 OpenedHand
+ * Copyright (C) 2013 Collabora
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -31,6 +32,8 @@
#define SEEK_H 14
#define SEEK_W 440
+#define GST_PLAY_FLAG_VIS 1 << 3
+
typedef struct _VideoApp
{
ClutterActor *stage;
@@ -358,11 +361,18 @@ int
main (int argc, char *argv[])
{
VideoApp *app = NULL;
+ GstElement *pipe;
+ GstElement *playsink;
+ GstElement *goomsource;
+ GstIterator *iter;
ClutterActor *stage;
ClutterColor stage_color = { 0x00, 0x00, 0x00, 0x00 };
ClutterColor control_color1 = { 73, 74, 77, 0xee };
ClutterColor control_color2 = { 0xcc, 0xcc, 0xcc, 0xff };
GError *error = NULL;
+ GValue value = { 0, };
+ char *sink_name;
+ int playsink_flags;
clutter_gst_init_with_args (&argc,
&argv,
@@ -430,6 +440,36 @@ main (int argc, char *argv[])
/* Load up out video texture */
clutter_media_set_filename (CLUTTER_MEDIA (app->vtexture), argv[1]);
+ /* Set up things so that a visualisation is played if there's no video */
+ pipe = clutter_gst_video_texture_get_pipeline (CLUTTER_GST_VIDEO_TEXTURE (app->vtexture));
+ if (!pipe)
+ g_error ("Unable to get gstreamer pipeline!\n");
+
+ iter = gst_bin_iterate_sinks (GST_BIN (pipe));
+ if (!iter)
+ g_error ("Unable to iterate over sinks!\n");
+ while (gst_iterator_next (iter, &value) == GST_ITERATOR_OK) {
+ playsink = g_value_get_object (&value);
+ sink_name = gst_element_get_name (playsink);
+ if (g_strcmp0 (sink_name, "playsink") != 0) {
+ g_free (sink_name);
+ break;
+ }
+ g_free (sink_name);
+ }
+ gst_iterator_free (iter);
+
+ goomsource = gst_element_factory_make ("goom", "source");
+ if (!goomsource)
+ g_error ("Unable to create goom visualiser!\n");
+
+ g_object_get (playsink, "flags", &playsink_flags, NULL);
+ playsink_flags |= GST_PLAY_FLAG_VIS;
+ g_object_set (playsink,
+ "vis-plugin", goomsource,
+ "flags", playsink_flags,
+ NULL);
+
/* Create the control UI */
app->control = clutter_group_new ();