[cogl/cogl-gst-1.18: 10/10] wip: video-sink: add navigation support



commit 24294d7fe107846d0d50a18f82aa71ced88cb070
Author: Lionel Landwerlin <llandwerlin gmail com>
Date:   Fri Jan 24 20:34:58 2014 +0000

    wip: video-sink: add navigation support

 cogl-gst/cogl-gst-video-sink.c |   78 +++++++++++++++++++++++++++++++++++++++-
 cogl-gst/cogl-gst-video-sink.h |   15 ++++++++
 2 files changed, 92 insertions(+), 1 deletions(-)
---
diff --git a/cogl-gst/cogl-gst-video-sink.c b/cogl-gst/cogl-gst-video-sink.c
index 3e4f4f9..555103a 100644
--- a/cogl-gst/cogl-gst-video-sink.c
+++ b/cogl-gst/cogl-gst-video-sink.c
@@ -80,11 +80,13 @@ static GstStaticPadTemplate sinktemplate_all =
                            GST_STATIC_CAPS (cogl_gst_video_sink_caps_str));
 
 static void color_balance_iface_init (GstColorBalanceInterface *iface);
+static void navigation_iface_init (GstNavigationInterface *iface);
 
 G_DEFINE_TYPE_WITH_CODE (CoglGstVideoSink,
                          cogl_gst_video_sink,
                          GST_TYPE_BASE_SINK,
-                         G_IMPLEMENT_INTERFACE (GST_TYPE_COLOR_BALANCE, color_balance_iface_init))
+                         G_IMPLEMENT_INTERFACE (GST_TYPE_COLOR_BALANCE, color_balance_iface_init)
+                         G_IMPLEMENT_INTERFACE (GST_TYPE_NAVIGATION, navigation_iface_init))
 
 enum
 {
@@ -224,6 +226,30 @@ COGL_GTYPE_DEFINE_BOXED (GstRectangle,
                          cogl_gst_rectangle_copy,
                          cogl_gst_rectangle_free);
 
+static gpointer
+cogl_gst_point_copy (gpointer src)
+{
+  if (G_LIKELY (src))
+    {
+      CoglGstPoint *new = g_slice_new (CoglGstPoint);
+      memcpy (new, src, sizeof (CoglGstPoint));
+      return new;
+    }
+  else
+    return NULL;
+}
+
+static void
+cogl_gst_point_free (gpointer ptr)
+{
+  g_slice_free (CoglGstPoint, ptr);
+}
+
+COGL_GTYPE_DEFINE_BOXED (GstPoint,
+                         gst_point,
+                         cogl_gst_point_copy,
+                         cogl_gst_point_free);
+
 /* Snippet cache */
 
 static SnippetCacheEntry *
@@ -552,6 +578,56 @@ color_balance_iface_init (GstColorBalanceInterface *iface)
   iface->get_balance_type = cogl_gst_video_sink_color_balance_get_balance_type;
 }
 
+/* Navigation */
+
+static void
+cogl_gst_video_sink_navigation_send_event (GstNavigation *navigation,
+                                           GstStructure *structure)
+{
+  CoglGstVideoSink *self = COGL_GST_VIDEO_SINK (navigation);
+  CoglGstVideoSinkPrivate *priv = self->priv;
+  GstEvent *event;
+  GstPad *pad = NULL;
+  gdouble x, y;
+  gfloat x_out, y_out;
+
+  /* Converting pointer coordinates to the non scaled geometry
+   * if the structure contains pointer coordinates */
+  /* if (gst_structure_get_double (structure, "pointer_x", &x) && */
+  /*     gst_structure_get_double (structure, "pointer_y", &y)) { */
+  /*   if (clutter_actor_transform_stage_point (CLUTTER_ACTOR (priv->texture), x, */
+  /*           y, &x_out, &y_out) == FALSE) { */
+  /*     g_warning ("Failed to convert non-scaled coordinates for video-sink"); */
+  /*     return; */
+  /*   } */
+
+  /*   x = x_out * priv->info.width / */
+  /*       clutter_actor_get_width (CLUTTER_ACTOR (priv->texture)); */
+  /*   y = y_out * priv->info.height / */
+  /*       clutter_actor_get_height (CLUTTER_ACTOR (priv->texture)); */
+
+  /*   gst_structure_set (structure, */
+  /*       "pointer_x", G_TYPE_DOUBLE, (gdouble) x, */
+  /*       "pointer_y", G_TYPE_DOUBLE, (gdouble) y, NULL); */
+  /* } */
+
+  event = gst_event_new_navigation (structure);
+
+  pad = gst_pad_get_peer (GST_VIDEO_SINK_PAD (self));
+  if (GST_IS_PAD (pad) && GST_IS_EVENT (event))
+    {
+      gst_pad_send_event (pad, event);
+
+      gst_object_unref (pad);
+    }
+}
+
+static void
+navigation_iface_init (GstNavigationInterface *iface)
+{
+  iface->send_event = cogl_gst_video_sink_navigation_send_event;
+}
+
 /**/
 
 static void
diff --git a/cogl-gst/cogl-gst-video-sink.h b/cogl-gst/cogl-gst-video-sink.h
index 12a6480..642118d 100644
--- a/cogl-gst/cogl-gst-video-sink.h
+++ b/cogl-gst/cogl-gst-video-sink.h
@@ -507,6 +507,21 @@ typedef struct _CoglGstRectangle
 COGL_GST_GTYPE_DECLARE_TYPE (rectangle);
 
 /**
+ * CoglGstPoint:
+ * @x: The X coordinate
+ * @y: The Y coordinate
+ *
+ * Describes a point that can be used for event positions.
+ */
+typedef struct _CoglGstPoint
+{
+  float x;
+  float y;
+} CoglGstPoint;
+
+COGL_GST_GTYPE_DECLARE_TYPE (point);
+
+/**
  * cogl_gst_video_sink_fit_size:
  * @sink: A #CoglGstVideoSink
  * @available: (in): The space available for video output


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