video-info: implement GstVideoInfo as boxed type
authorMarcin Kolny <marcin.kolny@flytronic.pl>
Mon, 6 Jul 2015 09:36:58 +0000 (11:36 +0200)
committerSebastian Dröge <sebastian@centricular.com>
Mon, 6 Jul 2015 09:52:51 +0000 (12:52 +0300)
GstVideoInfo usually is created on the stack, but boxed type can be useful
for bindings.

https://bugzilla.gnome.org/show_bug.cgi?id=752011

gst-libs/gst/video/video-info.c
gst-libs/gst/video/video-info.h

index 0aa9ebb..8dd8109 100644 (file)
 #include "video-info.h"
 #include "video-tile.h"
 
+/**
+ * gst_video_info_copy:
+ * @info: a #GstVideoInfo
+ *
+ * Copy a GstVideoInfo structure.
+ *
+ * Returns: a new #GstVideoInfo. free with gst_video_info_free.
+ *
+ * Since: 1.6
+ */
+GstVideoInfo *
+gst_video_info_copy (const GstVideoInfo * info)
+{
+  return g_slice_dup (GstVideoInfo, info);
+}
+
+/**
+ * gst_video_info_free:
+ * @info: a #GstVideoInfo
+ *
+ * Free a GstVideoInfo structure previously allocated with gst_video_info_new()
+ * or gst_video_info_copy().
+ *
+ * Since: 1.6
+ */
+void
+gst_video_info_free (GstVideoInfo * info)
+{
+  g_slice_free (GstVideoInfo, info);
+}
+
+G_DEFINE_BOXED_TYPE (GstVideoInfo, gst_video_info,
+    (GBoxedCopyFunc) gst_video_info_copy, (GBoxedFreeFunc) gst_video_info_free);
+
+/**
+ * gst_video_info_new:
+ *
+ * Allocate a new #GstVideoInfo that is also initialized with
+ * gst_video_info_init().
+ *
+ * Returns: a new #GstVideoInfo. free with gst_video_info_free().
+ *
+ * Since: 1.6
+ */
+GstVideoInfo *
+gst_video_info_new (void)
+{
+  GstVideoInfo *info;
+
+  info = g_slice_new (GstVideoInfo);
+  gst_video_info_init (info);
+
+  return info;
+}
+
 static int fill_planes (GstVideoInfo * info);
 
 /**
index d1d2611..18a1d45 100644 (file)
@@ -287,6 +287,8 @@ struct _GstVideoInfo {
   } ABI;
 };
 
+GType gst_video_info_get_type            (void);
+
 /* general info */
 #define GST_VIDEO_INFO_FORMAT(i)         (GST_VIDEO_FORMAT_INFO_FORMAT((i)->finfo))
 #define GST_VIDEO_INFO_NAME(i)           (GST_VIDEO_FORMAT_INFO_NAME((i)->finfo))
@@ -335,26 +337,29 @@ struct _GstVideoInfo {
 #define GST_VIDEO_INFO_COMP_PSTRIDE(i,c) GST_VIDEO_FORMAT_INFO_PSTRIDE((i)->finfo,(c))
 #define GST_VIDEO_INFO_COMP_POFFSET(i,c) GST_VIDEO_FORMAT_INFO_POFFSET((i)->finfo,(c))
 
-void         gst_video_info_init        (GstVideoInfo *info);
+GstVideoInfo * gst_video_info_new         (void);
+void           gst_video_info_init        (GstVideoInfo *info);
+GstVideoInfo * gst_video_info_copy        (const GstVideoInfo *info);
+void           gst_video_info_free        (GstVideoInfo *info);
 
-void         gst_video_info_set_format  (GstVideoInfo *info, GstVideoFormat format,
-                                         guint width, guint height);
+void           gst_video_info_set_format  (GstVideoInfo *info, GstVideoFormat format,
+                                           guint width, guint height);
 
-gboolean     gst_video_info_from_caps   (GstVideoInfo *info, const GstCaps  * caps);
+gboolean       gst_video_info_from_caps   (GstVideoInfo *info, const GstCaps  * caps);
 
-GstCaps *    gst_video_info_to_caps     (GstVideoInfo *info);
+GstCaps *      gst_video_info_to_caps     (GstVideoInfo *info);
 
-gboolean     gst_video_info_convert     (GstVideoInfo *info,
-                                         GstFormat     src_format,
-                                         gint64        src_value,
-                                         GstFormat     dest_format,
-                                         gint64       *dest_value);
-gboolean     gst_video_info_is_equal    (const GstVideoInfo *info,
-                     const GstVideoInfo *other);
+gboolean       gst_video_info_convert     (GstVideoInfo *info,
+                                           GstFormat     src_format,
+                                           gint64        src_value,
+                                           GstFormat     dest_format,
+                                           gint64       *dest_value);
+gboolean       gst_video_info_is_equal    (const GstVideoInfo *info,
+                                           const GstVideoInfo *other);
 
 #include <gst/video/video.h>
 
-void         gst_video_info_align       (GstVideoInfo * info, GstVideoAlignment * align);
+void           gst_video_info_align       (GstVideoInfo * info, GstVideoAlignment * align);
 
 
 G_END_DECLS