[clutter-gst/wip/overlays] untested/uncompiled overlay support starting point
- From: Lionel Landwerlin <llandwerlin src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter-gst/wip/overlays] untested/uncompiled overlay support starting point
- Date: Thu, 29 May 2014 18:47:25 +0000 (UTC)
commit 345ef1563573b8ded2f66dc80b1db075c493c589
Author: Lionel Landwerlin <llandwerlin gmail com>
Date: Thu May 29 19:47:10 2014 +0100
untested/uncompiled overlay support starting point
clutter-gst/clutter-gst-content.c | 44 ++++++++++++++++++++++++++++++++++
clutter-gst/clutter-gst-types.c | 44 ++++++++++++++++++++++++++++++++++
clutter-gst/clutter-gst-types.h | 19 ++++++++++++--
clutter-gst/clutter-gst-video-sink.c | 42 ++++++++++++++++++++++++++++++++
4 files changed, 146 insertions(+), 3 deletions(-)
---
diff --git a/clutter-gst/clutter-gst-content.c b/clutter-gst/clutter-gst-content.c
index e23a31c..883e53f 100644
--- a/clutter-gst/clutter-gst-content.c
+++ b/clutter-gst/clutter-gst-content.c
@@ -58,6 +58,9 @@ struct _ClutterGstContentPrivate
ClutterGstVideoSink *sink;
ClutterGstPlayer *player;
ClutterGstFrame *current_frame;
+
+ gboolean paint_frame;
+ gboolean paint_overlays;
};
enum
@@ -66,6 +69,8 @@ enum
PROP_VIDEO_SINK,
PROP_PLAYER,
+ PROP_PAINT_FRAME,
+ PROP_PAINT_OVERLAYS,
PROP_LAST
};
@@ -288,6 +293,11 @@ clutter_gst_content_set_property (GObject *object,
CLUTTER_GST_PLAYER (g_value_get_object (value)));
break;
+ case PROP_PAINT_FRAME:
+ content_set_player (self,
+ CLUTTER_GST_PLAYER (g_value_get_object (value)));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -365,6 +375,21 @@ clutter_gst_content_class_init (ClutterGstContentClass *klass)
"Cogl Video Sink",
CLUTTER_GST_TYPE_VIDEO_SINK,
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
+
+ props[PROP_PAINT_FRAME] =
+ g_param_spec_boolean ("paint-frame",
+ "Paint Video Overlays",
+ "Paint Video Overlays",
+ TRUE,
+ G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
+ g_object_class_install_properties (gobject_class, PROP_LAST, props);
+
+ props[PROP_PAINT_OVERLAYS] =
+ g_param_spec_boolean ("paint-overlays",
+ "Paint Video Overlays",
+ "Paint Video Overlays",
+ TRUE,
+ G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
g_object_class_install_properties (gobject_class, PROP_LAST, props);
@@ -398,6 +423,9 @@ clutter_gst_content_init (ClutterGstContent *self)
content_set_sink (self,
CLUTTER_GST_VIDEO_SINK (clutter_gst_create_video_sink ()),
FALSE);
+
+ priv->paint_frame = TRUE;
+ priv->paint_overlays = TRUE;
}
@@ -445,6 +473,22 @@ clutter_gst_content_get_frame (ClutterGstContent *self)
}
/**
+ * clutter_gst_content_get_overlays:
+ * @self: A #ClutterGstContent
+ *
+ * Returns: (transfer none) (element ClutterGst.Overlay): The #ClutterGstFrame currently attached to @self.
+ *
+ * Since: 3.0
+ */
+GPtrArray *
+clutter_gst_content_get_overlay (ClutterGstContent *self)
+{
+ g_return_val_if_fail (CLUTTER_GST_IS_CONTENT (self), NULL);
+
+ return self->priv->overlays;
+}
+
+/**
* clutter_gst_content_get_sink:
* @self: A #ClutterGstContent
*
diff --git a/clutter-gst/clutter-gst-types.c b/clutter-gst/clutter-gst-types.c
index 6818ad5..1b82911 100644
--- a/clutter-gst/clutter-gst-types.c
+++ b/clutter-gst/clutter-gst-types.c
@@ -70,6 +70,50 @@ G_DEFINE_BOXED_TYPE (ClutterGstFrame,
clutter_gst_frame_copy,
clutter_gst_frame_free);
+
+ClutterGstOverlay *
+clutter_gst_overlay_new (void)
+{
+ return g_slice_new0 (ClutterGstOverlay);
+}
+
+static gpointer
+clutter_gst_overlay_copy (gpointer data)
+{
+ if (G_LIKELY (data))
+ {
+ ClutterGstOverlay *overlay = g_slice_dup (ClutterGstOverlay, data);
+
+ if (overlay->pipeline != COGL_INVALID_HANDLE)
+ overlay->pipeline = cogl_object_ref (overlay->pipeline);
+
+ return overlay;
+ }
+
+ return NULL;
+}
+
+static void
+clutter_gst_overlay_free (gpointer data)
+{
+ if (G_LIKELY (data))
+ {
+ ClutterGstOverlay *overlay = (ClutterGstOverlay *) data;
+
+ if (overlay->pipeline != COGL_INVALID_HANDLE)
+ {
+ cogl_object_unref (overlay->pipeline);
+ overlay->pipeline = COGL_INVALID_HANDLE;
+ }
+ g_slice_free (ClutterGstOverlay, overlay);
+ }
+}
+
+G_DEFINE_BOXED_TYPE (ClutterGstOverlay,
+ clutter_gst_overlay,
+ clutter_gst_overlay_copy,
+ clutter_gst_overlay_free);
+
static ClutterGstBox *
clutter_gst_box_copy (const ClutterGstBox *box)
{
diff --git a/clutter-gst/clutter-gst-types.h b/clutter-gst/clutter-gst-types.h
index 7124d90..cde1d60 100644
--- a/clutter-gst/clutter-gst-types.h
+++ b/clutter-gst/clutter-gst-types.h
@@ -39,6 +39,7 @@
typedef struct _ClutterGstBox ClutterGstBox;
typedef struct _ClutterGstFrame ClutterGstFrame;
+typedef struct _ClutterGstOverlay ClutterGstOverlay;
typedef struct _ClutterGstVideoResolution ClutterGstVideoResolution;
/**
@@ -90,7 +91,7 @@ struct _ClutterGstVideoResolution
/**
* ClutterGstFrame:
* @resolution: a #ClutterGstVideoResolution
- * @pipeline: a #CoglHandle to the pipeline to paint a frame
+ * @pipeline: a #CoglPipeline to paint a frame
*
* Represents a frame outputted by the #ClutterGstVideoSink.
*/
@@ -100,6 +101,17 @@ struct _ClutterGstFrame
CoglPipeline *pipeline;
};
+/**
+ * ClutterGstOverlay:
+ * @position:
+ * @pipeline: a #CoglPipeline to paint an overlay
+ *
+ */
+struct _ClutterGstOverlay
+{
+ ClutterGstBox position;
+ CoglPipeline *pipeline;
+};
/**
* ClutterGstBox:
@@ -121,8 +133,9 @@ struct _ClutterGstBox
};
-GType clutter_gst_frame_get_type (void) G_GNUC_CONST;
-GType clutter_gst_box_get_type (void) G_GNUC_CONST;
+GType clutter_gst_frame_get_type (void) G_GNUC_CONST;
+GType clutter_gst_box_get_type (void) G_GNUC_CONST;
+GType clutter_gst_overlay_get_type (void) G_GNUC_CONST;
gfloat clutter_gst_box_get_width (const ClutterGstBox *box);
gfloat clutter_gst_box_get_height (const ClutterGstBox *box);
diff --git a/clutter-gst/clutter-gst-video-sink.c b/clutter-gst/clutter-gst-video-sink.c
index 1959c4e..39a6257 100644
--- a/clutter-gst/clutter-gst-video-sink.c
+++ b/clutter-gst/clutter-gst-video-sink.c
@@ -231,8 +231,48 @@ struct _ClutterGstVideoSinkPrivate
guint8 *tabley;
guint8 *tableu;
guint8 *tablev;
+
+ /**/
+ GstVideoOverlayComposition *last_composition;
};
+/* Overlays */
+
+static void
+clutter_gst_video_sink_upload_overlay (ClutterGstVideoSink *sink, GstBuffer *buffer)
+{
+ ClutterGstVideoSinkPrivate *priv = sink->priv;
+
+ GstVideoOverlayComposition *composition = NULL;
+ GstVideoOverlayCompositionMeta *composition_meta;
+
+ composition_meta = gst_buffer_get_video_overlay_composition_meta (buffer);
+ if (composition_meta)
+ composition = composition_meta->overlay;
+
+ if (composition == NULL)
+ {
+ if (priv->last_composition != NULL)
+ {
+ gst_video_overlay_composition_unref (priv->last_composition);
+ priv->last_composition = NULL;
+
+ /* Clear overlays and emit a new overlay frame */
+ }
+ return;
+ }
+
+ if (composition)
+ gst_video_overlay_composition_unref (priv->last_composition);
+ priv->last_composition = gst_video_overlay_composition_ref (composition);
+
+ nb_rectangle = gst_video_overlay_composition_n_rectangles (composition);
+ for (i = 0; i < nb_rectangle; i++)
+ {
+
+ }
+}
+
/* Snippet cache */
static SnippetCacheEntry *
@@ -2092,6 +2132,8 @@ clutter_gst_video_sink_propose_allocation (GstBaseSink *base_sink, GstQuery *que
GST_VIDEO_META_API_TYPE, NULL);
gst_query_add_allocation_meta (query,
GST_VIDEO_GL_TEXTURE_UPLOAD_META_API_TYPE, NULL);
+ gst_query_add_allocation_meta (query,
+ GST_VIDEO_OVERLAY_COMPOSITION_META_API_TYPE, NULL);
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]