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>
This commit is contained in:
Chris White 2021-04-10 10:46:28 -04:00
parent f52937d1ff
commit c711c8ed39
2 changed files with 28 additions and 0 deletions

View file

@ -142,6 +142,31 @@ G_DEFINE_BOXED_TYPE (GstAllocationParams, gst_allocation_params,
(GBoxedCopyFunc) gst_allocation_params_copy,
(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

View file

@ -167,6 +167,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);