[clutter-gst] video-player: Play the goom visualisation if there's no video



commit a1986444896ead135647729eaa9c4cc83c141ab5
Author: Nirbheek Chauhan <nirbheek chauhan collabora co uk>
Date:   Sun Dec 23 09:19:27 2012 +0530

    video-player: Play the goom visualisation if there's no video
    
    Bugzilla: https://bugzilla.gnome.org/show_bug.cgi?id=690659

 examples/video-player.c |   40 ++++++++++++++++++++++++++++++++++++++++
 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 ();
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]