summaryrefslogtreecommitdiff
path: root/gst
diff options
context:
space:
mode:
authorChris White <cxwembedded@gmail.com>2021-04-10 10:46:28 -0400
committerChris White <cxwembedded@gmail.com>2021-04-10 10:46:28 -0400
commitc711c8ed39e9d3bade36721c0a1b008be4c4a4bc (patch)
treec1e98bfc3fe671084041e7c34a845259656deb79 /gst
parentf52937d1fff96e215359c5b7910c424a2b2c495e (diff)
allocator: add gst_allocation_params_new()
This permits creating GstAllocationParams instances on the heap, which is useful for language bindings that can handle GBoxed types. https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/683 Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/788>
Diffstat (limited to 'gst')
-rw-r--r--gst/gstallocator.c25
-rw-r--r--gst/gstallocator.h3
2 files changed, 28 insertions, 0 deletions
diff --git a/gst/gstallocator.c b/gst/gstallocator.c
index ccfc6aad22..6b3047636d 100644
--- a/gst/gstallocator.c
+++ b/gst/gstallocator.c
@@ -143,6 +143,31 @@ G_DEFINE_BOXED_TYPE (GstAllocationParams, gst_allocation_params,
(GBoxedFreeFunc) gst_allocation_params_free);
/**
+ * gst_allocation_params_new:
+ *
+ * Create a new #GstAllocationParams on the heap. This function is for
+ * use in GStreamer language bindings. In your own code, you can just
+ * declare a #GstAllocationParams on the stack or in a struct, and
+ * call gst_allocation_params_init() to initialize it.
+ *
+ * You do not need to call gst_allocation_params_init() on the instance
+ * returned by this function.
+ *
+ * Returns: (transfer full) (not nullable): a new #GstAllocationParams
+ *
+ * Since: 1.20
+ */
+GstAllocationParams *
+gst_allocation_params_new (void)
+{
+ /* Call new() and then init(), rather than calling new0(), in case
+ * init() ever changes to something other than a memset(). */
+ GstAllocationParams *result = g_slice_new (GstAllocationParams);
+ gst_allocation_params_init (result);
+ return result;
+}
+
+/**
* gst_allocation_params_init:
* @params: a #GstAllocationParams
*
diff --git a/gst/gstallocator.h b/gst/gstallocator.h
index 51e6b92bca..0989dd8db1 100644
--- a/gst/gstallocator.h
+++ b/gst/gstallocator.h
@@ -168,6 +168,9 @@ void gst_allocator_set_default (GstAllocator * allocator);
/* allocation parameters */
GST_API
+GstAllocationParams * gst_allocation_params_new (void) G_GNUC_MALLOC;
+
+GST_API
void gst_allocation_params_init (GstAllocationParams *params);
GST_API