mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-22 16:26:39 +00:00
meta: Add API to register metas in two steps
And also remove the specific registration APIs for serializable meta. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5830>
This commit is contained in:
parent
2a9c4e3270
commit
f5d5f2cf1a
7 changed files with 218 additions and 176 deletions
153
girs/Gst-1.0.gir
153
girs/Gst-1.0.gir
|
@ -26040,48 +26040,6 @@ transform function.</doc>
|
||||||
</parameter>
|
</parameter>
|
||||||
</parameters>
|
</parameters>
|
||||||
</function>
|
</function>
|
||||||
<function name="register_serializable" c:identifier="gst_meta_register_serializable" version="1.24" introspectable="0">
|
|
||||||
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstmeta.c">Same as gst_meta_register() but also set serialize/deserialize functions.</doc>
|
|
||||||
<source-position filename="../subprojects/gstreamer/gst/gstmeta.h"/>
|
|
||||||
<return-value transfer-ownership="none">
|
|
||||||
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstmeta.c">a #GstMetaInfo that can be used to access metadata.</doc>
|
|
||||||
<type name="MetaInfo" c:type="const GstMetaInfo*"/>
|
|
||||||
</return-value>
|
|
||||||
<parameters>
|
|
||||||
<parameter name="api" transfer-ownership="none">
|
|
||||||
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstmeta.c">the type of the #GstMeta API</doc>
|
|
||||||
<type name="GType" c:type="GType"/>
|
|
||||||
</parameter>
|
|
||||||
<parameter name="impl" transfer-ownership="none">
|
|
||||||
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstmeta.c">the name of the #GstMeta implementation</doc>
|
|
||||||
<type name="utf8" c:type="const gchar*"/>
|
|
||||||
</parameter>
|
|
||||||
<parameter name="size" transfer-ownership="none">
|
|
||||||
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstmeta.c">the size of the #GstMeta structure</doc>
|
|
||||||
<type name="gsize" c:type="gsize"/>
|
|
||||||
</parameter>
|
|
||||||
<parameter name="init_func" transfer-ownership="none">
|
|
||||||
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstmeta.c">a #GstMetaInitFunction</doc>
|
|
||||||
<type name="MetaInitFunction" c:type="GstMetaInitFunction"/>
|
|
||||||
</parameter>
|
|
||||||
<parameter name="free_func" transfer-ownership="none">
|
|
||||||
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstmeta.c">a #GstMetaFreeFunction</doc>
|
|
||||||
<type name="MetaFreeFunction" c:type="GstMetaFreeFunction"/>
|
|
||||||
</parameter>
|
|
||||||
<parameter name="transform_func" transfer-ownership="none">
|
|
||||||
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstmeta.c">a #GstMetaTransformFunction</doc>
|
|
||||||
<type name="MetaTransformFunction" c:type="GstMetaTransformFunction"/>
|
|
||||||
</parameter>
|
|
||||||
<parameter name="serialize_func" transfer-ownership="none">
|
|
||||||
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstmeta.c">a #GstMetaSerializeFunction</doc>
|
|
||||||
<type name="MetaSerializeFunction" c:type="GstMetaSerializeFunction"/>
|
|
||||||
</parameter>
|
|
||||||
<parameter name="deserialize_func" transfer-ownership="none">
|
|
||||||
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstmeta.c">a #GstMetaDeserializeFunction</doc>
|
|
||||||
<type name="MetaDeserializeFunction" c:type="GstMetaDeserializeFunction"/>
|
|
||||||
</parameter>
|
|
||||||
</parameters>
|
|
||||||
</function>
|
|
||||||
</record>
|
</record>
|
||||||
<callback name="MetaClearFunction" c:type="GstMetaClearFunction" version="1.24">
|
<callback name="MetaClearFunction" c:type="GstMetaClearFunction" version="1.24">
|
||||||
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstmeta.h">Clears the content of the meta. This will be called by the GstBufferPool
|
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstmeta.h">Clears the content of the meta. This will be called by the GstBufferPool
|
||||||
|
@ -26223,6 +26181,75 @@ pooled metas.</doc>
|
||||||
</instance-parameter>
|
</instance-parameter>
|
||||||
</parameters>
|
</parameters>
|
||||||
</method>
|
</method>
|
||||||
|
<method name="register" c:identifier="gst_meta_info_register" version="1.24">
|
||||||
|
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstmeta.c">Registers a new meta.
|
||||||
|
|
||||||
|
Use the structure returned by gst_meta_info_new(), it consumes it and the
|
||||||
|
structure shouldnt be used after. The one returned by the function can be
|
||||||
|
kept.</doc>
|
||||||
|
<source-position filename="../subprojects/gstreamer/gst/gstmeta.h"/>
|
||||||
|
<return-value transfer-ownership="none">
|
||||||
|
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstmeta.c">the registered meta</doc>
|
||||||
|
<type name="MetaInfo" c:type="const GstMetaInfo*"/>
|
||||||
|
</return-value>
|
||||||
|
<parameters>
|
||||||
|
<instance-parameter name="info" transfer-ownership="full">
|
||||||
|
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstmeta.c">a new #GstMetaInfo created by gst_meta_info_new()</doc>
|
||||||
|
<type name="MetaInfo" c:type="GstMetaInfo*"/>
|
||||||
|
</instance-parameter>
|
||||||
|
</parameters>
|
||||||
|
</method>
|
||||||
|
<function name="new" c:identifier="gst_meta_info_new" version="1.24" introspectable="0">
|
||||||
|
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstmeta.c">Creates a new structure that needs to be filled before being
|
||||||
|
registered. This structure should filled and then registered with
|
||||||
|
gst_meta_info_register().
|
||||||
|
|
||||||
|
Example:
|
||||||
|
```c
|
||||||
|
const GstMetaInfo *
|
||||||
|
gst_my_meta_get_info (void)
|
||||||
|
{
|
||||||
|
static const GstMetaInfo *meta_info = NULL;
|
||||||
|
|
||||||
|
if (g_once_init_enter ((GstMetaInfo **) & meta_info)) {
|
||||||
|
GstMetaInfo *info = gst_meta_info_new (
|
||||||
|
gst_my_meta_api_get_type (),
|
||||||
|
"GstMyMeta",
|
||||||
|
sizeof (GstMyMeta));
|
||||||
|
const GstMetaInfo *meta = NULL;
|
||||||
|
|
||||||
|
info->init_func = my_meta_init;
|
||||||
|
info->free_func = my_meta_free;
|
||||||
|
info->transform_func = my_meta_transform;
|
||||||
|
info->serialize_func = my_meta_serialize;
|
||||||
|
info->deserialize_func = my_meta_deserialize;
|
||||||
|
meta = gst_meta_info_register (info);
|
||||||
|
g_once_init_leave ((GstMetaInfo **) & meta_info, (GstMetaInfo *) meta);
|
||||||
|
}
|
||||||
|
|
||||||
|
return meta_info;
|
||||||
|
}
|
||||||
|
```</doc>
|
||||||
|
<source-position filename="../subprojects/gstreamer/gst/gstmeta.h"/>
|
||||||
|
<return-value>
|
||||||
|
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstmeta.c">a new #GstMetaInfo that needs to be filled</doc>
|
||||||
|
<type name="MetaInfo" c:type="GstMetaInfo*"/>
|
||||||
|
</return-value>
|
||||||
|
<parameters>
|
||||||
|
<parameter name="api" transfer-ownership="none">
|
||||||
|
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstmeta.c">the type of the #GstMeta API</doc>
|
||||||
|
<type name="GType" c:type="GType"/>
|
||||||
|
</parameter>
|
||||||
|
<parameter name="impl" transfer-ownership="none">
|
||||||
|
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstmeta.c">the name of the #GstMeta implementation</doc>
|
||||||
|
<type name="utf8" c:type="const gchar*"/>
|
||||||
|
</parameter>
|
||||||
|
<parameter name="size" transfer-ownership="none">
|
||||||
|
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstmeta.c">the size of the #GstMeta structure</doc>
|
||||||
|
<type name="gsize" c:type="gsize"/>
|
||||||
|
</parameter>
|
||||||
|
</parameters>
|
||||||
|
</function>
|
||||||
</record>
|
</record>
|
||||||
<callback name="MetaInitFunction" c:type="GstMetaInitFunction">
|
<callback name="MetaInitFunction" c:type="GstMetaInitFunction">
|
||||||
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstmeta.h">Function called when @meta is initialized in @buffer.</doc>
|
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstmeta.h">Function called when @meta is initialized in @buffer.</doc>
|
||||||
|
@ -52327,48 +52354,6 @@ transform function.</doc>
|
||||||
</parameter>
|
</parameter>
|
||||||
</parameters>
|
</parameters>
|
||||||
</function>
|
</function>
|
||||||
<function name="meta_register_serializable" c:identifier="gst_meta_register_serializable" moved-to="Meta.register_serializable" version="1.24" introspectable="0">
|
|
||||||
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstmeta.c">Same as gst_meta_register() but also set serialize/deserialize functions.</doc>
|
|
||||||
<source-position filename="../subprojects/gstreamer/gst/gstmeta.h"/>
|
|
||||||
<return-value transfer-ownership="none">
|
|
||||||
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstmeta.c">a #GstMetaInfo that can be used to access metadata.</doc>
|
|
||||||
<type name="MetaInfo" c:type="const GstMetaInfo*"/>
|
|
||||||
</return-value>
|
|
||||||
<parameters>
|
|
||||||
<parameter name="api" transfer-ownership="none">
|
|
||||||
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstmeta.c">the type of the #GstMeta API</doc>
|
|
||||||
<type name="GType" c:type="GType"/>
|
|
||||||
</parameter>
|
|
||||||
<parameter name="impl" transfer-ownership="none">
|
|
||||||
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstmeta.c">the name of the #GstMeta implementation</doc>
|
|
||||||
<type name="utf8" c:type="const gchar*"/>
|
|
||||||
</parameter>
|
|
||||||
<parameter name="size" transfer-ownership="none">
|
|
||||||
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstmeta.c">the size of the #GstMeta structure</doc>
|
|
||||||
<type name="gsize" c:type="gsize"/>
|
|
||||||
</parameter>
|
|
||||||
<parameter name="init_func" transfer-ownership="none">
|
|
||||||
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstmeta.c">a #GstMetaInitFunction</doc>
|
|
||||||
<type name="MetaInitFunction" c:type="GstMetaInitFunction"/>
|
|
||||||
</parameter>
|
|
||||||
<parameter name="free_func" transfer-ownership="none">
|
|
||||||
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstmeta.c">a #GstMetaFreeFunction</doc>
|
|
||||||
<type name="MetaFreeFunction" c:type="GstMetaFreeFunction"/>
|
|
||||||
</parameter>
|
|
||||||
<parameter name="transform_func" transfer-ownership="none">
|
|
||||||
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstmeta.c">a #GstMetaTransformFunction</doc>
|
|
||||||
<type name="MetaTransformFunction" c:type="GstMetaTransformFunction"/>
|
|
||||||
</parameter>
|
|
||||||
<parameter name="serialize_func" transfer-ownership="none">
|
|
||||||
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstmeta.c">a #GstMetaSerializeFunction</doc>
|
|
||||||
<type name="MetaSerializeFunction" c:type="GstMetaSerializeFunction"/>
|
|
||||||
</parameter>
|
|
||||||
<parameter name="deserialize_func" transfer-ownership="none">
|
|
||||||
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstmeta.c">a #GstMetaDeserializeFunction</doc>
|
|
||||||
<type name="MetaDeserializeFunction" c:type="GstMetaDeserializeFunction"/>
|
|
||||||
</parameter>
|
|
||||||
</parameters>
|
|
||||||
</function>
|
|
||||||
<function name="mini_object_replace" c:identifier="gst_mini_object_replace" moved-to="MiniObject.replace">
|
<function name="mini_object_replace" c:identifier="gst_mini_object_replace" moved-to="MiniObject.replace">
|
||||||
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstminiobject.c">Atomically modifies a pointer to point to a new mini-object.
|
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstminiobject.c">Atomically modifies a pointer to point to a new mini-object.
|
||||||
The reference count of @olddata is decreased and the reference count of
|
The reference count of @olddata is decreased and the reference count of
|
||||||
|
|
|
@ -371,14 +371,14 @@ gst_analytics_relation_meta_get_info (void)
|
||||||
{
|
{
|
||||||
static const GstMetaInfo *info = NULL;
|
static const GstMetaInfo *info = NULL;
|
||||||
if (g_once_init_enter ((GstMetaInfo **) & info)) {
|
if (g_once_init_enter ((GstMetaInfo **) & info)) {
|
||||||
GstMetaInfo *meta = (GstMetaInfo *)
|
GstMetaInfo *meta = gst_meta_info_new (GST_ANALYTICS_RELATION_META_API_TYPE,
|
||||||
gst_meta_register (GST_ANALYTICS_RELATION_META_API_TYPE,
|
|
||||||
"GstAnalyticsRelationMeta",
|
"GstAnalyticsRelationMeta",
|
||||||
sizeof (GstAnalyticsRelationMeta),
|
sizeof (GstAnalyticsRelationMeta));
|
||||||
gst_analytics_relation_meta_init,
|
meta->init_func = gst_analytics_relation_meta_init;
|
||||||
gst_analytics_relation_meta_free,
|
meta->free_func = gst_analytics_relation_meta_free;
|
||||||
gst_analytics_relation_meta_transform);
|
meta->transform_func = gst_analytics_relation_meta_transform;
|
||||||
meta->clear_func = gst_analytics_relation_meta_clear;
|
meta->clear_func = gst_analytics_relation_meta_clear;
|
||||||
|
meta = (GstMetaInfo *) gst_meta_info_register (meta);
|
||||||
g_once_init_leave ((GstMetaInfo **) & info, (GstMetaInfo *) meta);
|
g_once_init_leave ((GstMetaInfo **) & info, (GstMetaInfo *) meta);
|
||||||
}
|
}
|
||||||
return info;
|
return info;
|
||||||
|
|
|
@ -588,14 +588,16 @@ gst_audio_meta_get_info (void)
|
||||||
static const GstMetaInfo *audio_meta_info = NULL;
|
static const GstMetaInfo *audio_meta_info = NULL;
|
||||||
|
|
||||||
if (g_once_init_enter ((GstMetaInfo **) & audio_meta_info)) {
|
if (g_once_init_enter ((GstMetaInfo **) & audio_meta_info)) {
|
||||||
const GstMetaInfo *meta =
|
GstMetaInfo *info = gst_meta_info_new (GST_AUDIO_META_API_TYPE,
|
||||||
gst_meta_register_serializable (GST_AUDIO_META_API_TYPE,
|
"GstAudioMeta", sizeof (GstAudioMeta));
|
||||||
"GstAudioMeta", sizeof (GstAudioMeta),
|
|
||||||
gst_audio_meta_init,
|
info->init_func = gst_audio_meta_init;
|
||||||
gst_audio_meta_free,
|
info->free_func = gst_audio_meta_free;
|
||||||
gst_audio_meta_transform,
|
info->transform_func = gst_audio_meta_transform;
|
||||||
gst_audio_meta_serialize,
|
info->serialize_func = gst_audio_meta_serialize;
|
||||||
gst_audio_meta_deserialize);
|
info->deserialize_func = gst_audio_meta_deserialize;
|
||||||
|
const GstMetaInfo *meta = gst_meta_info_register (info);
|
||||||
|
|
||||||
g_once_init_leave ((GstMetaInfo **) & audio_meta_info,
|
g_once_init_leave ((GstMetaInfo **) & audio_meta_info,
|
||||||
(GstMetaInfo *) meta);
|
(GstMetaInfo *) meta);
|
||||||
}
|
}
|
||||||
|
|
|
@ -252,11 +252,14 @@ gst_video_meta_get_info (void)
|
||||||
static const GstMetaInfo *video_meta_info = NULL;
|
static const GstMetaInfo *video_meta_info = NULL;
|
||||||
|
|
||||||
if (g_once_init_enter ((GstMetaInfo **) & video_meta_info)) {
|
if (g_once_init_enter ((GstMetaInfo **) & video_meta_info)) {
|
||||||
const GstMetaInfo *meta =
|
GstMetaInfo *info = gst_meta_info_new (GST_VIDEO_META_API_TYPE,
|
||||||
gst_meta_register_serializable (GST_VIDEO_META_API_TYPE, "GstVideoMeta",
|
"GstVideoMeta",
|
||||||
sizeof (GstVideoMeta), (GstMetaInitFunction) gst_video_meta_init,
|
sizeof (GstVideoMeta));
|
||||||
(GstMetaFreeFunction) NULL, gst_video_meta_transform,
|
info->init_func = gst_video_meta_init;
|
||||||
video_meta_serialize, video_meta_deserialize);
|
info->transform_func = gst_video_meta_transform;
|
||||||
|
info->serialize_func = video_meta_serialize;
|
||||||
|
info->deserialize_func = video_meta_deserialize;
|
||||||
|
const GstMetaInfo *meta = gst_meta_info_register (info);
|
||||||
g_once_init_leave ((GstMetaInfo **) & video_meta_info,
|
g_once_init_leave ((GstMetaInfo **) & video_meta_info,
|
||||||
(GstMetaInfo *) meta);
|
(GstMetaInfo *) meta);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2918,16 +2918,17 @@ gst_reference_timestamp_meta_get_info (void)
|
||||||
static const GstMetaInfo *meta_info = NULL;
|
static const GstMetaInfo *meta_info = NULL;
|
||||||
|
|
||||||
if (g_once_init_enter ((GstMetaInfo **) & meta_info)) {
|
if (g_once_init_enter ((GstMetaInfo **) & meta_info)) {
|
||||||
const GstMetaInfo *meta =
|
const GstMetaInfo *meta = NULL;
|
||||||
gst_meta_register_serializable
|
GstMetaInfo *info =
|
||||||
(gst_reference_timestamp_meta_api_get_type (),
|
gst_meta_info_new (gst_reference_timestamp_meta_api_get_type (),
|
||||||
"GstReferenceTimestampMeta",
|
"GstReferenceTimestampMeta",
|
||||||
sizeof (GstReferenceTimestampMeta),
|
sizeof (GstReferenceTimestampMeta));
|
||||||
(GstMetaInitFunction) _gst_reference_timestamp_meta_init,
|
info->init_func = (GstMetaInitFunction) _gst_reference_timestamp_meta_init;
|
||||||
(GstMetaFreeFunction) _gst_reference_timestamp_meta_free,
|
info->free_func = (GstMetaFreeFunction) _gst_reference_timestamp_meta_free;
|
||||||
_gst_reference_timestamp_meta_transform,
|
info->transform_func = _gst_reference_timestamp_meta_transform;
|
||||||
timestamp_meta_serialize,
|
info->serialize_func = timestamp_meta_serialize;
|
||||||
timestamp_meta_deserialize);
|
info->deserialize_func = timestamp_meta_deserialize;
|
||||||
|
meta = gst_meta_info_register (info);
|
||||||
g_once_init_leave ((GstMetaInfo **) & meta_info, (GstMetaInfo *) meta);
|
g_once_init_leave ((GstMetaInfo **) & meta_info, (GstMetaInfo *) meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -301,8 +301,9 @@ gst_meta_register_custom (const gchar * name, const gchar ** tags,
|
||||||
{
|
{
|
||||||
gchar *api_name = g_strdup_printf ("%s-api", name);
|
gchar *api_name = g_strdup_printf ("%s-api", name);
|
||||||
GType api;
|
GType api;
|
||||||
GstMetaInfoImpl *info;
|
GstMetaInfo *info;
|
||||||
GstMetaInfo *ret = NULL;
|
GstMetaInfoImpl *impl;
|
||||||
|
const GstMetaInfo *ret = NULL;
|
||||||
|
|
||||||
g_return_val_if_fail (tags != NULL, NULL);
|
g_return_val_if_fail (tags != NULL, NULL);
|
||||||
g_return_val_if_fail (name != NULL, NULL);
|
g_return_val_if_fail (name != NULL, NULL);
|
||||||
|
@ -312,20 +313,24 @@ gst_meta_register_custom (const gchar * name, const gchar ** tags,
|
||||||
if (api == G_TYPE_INVALID)
|
if (api == G_TYPE_INVALID)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
info = (GstMetaInfoImpl *) gst_meta_register_serializable (api, name,
|
info = gst_meta_info_new (api, name, sizeof (GstCustomMeta));
|
||||||
sizeof (GstCustomMeta),
|
if (info == NULL)
|
||||||
custom_init_func, custom_free_func, custom_transform_func,
|
|
||||||
custom_serialize_func, custom_deserialize_func);
|
|
||||||
|
|
||||||
if (!info)
|
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
info->is_custom = TRUE;
|
impl = (GstMetaInfoImpl *) info;
|
||||||
info->custom_transform_func = transform_func;
|
|
||||||
info->custom_transform_user_data = user_data;
|
|
||||||
info->custom_transform_destroy_notify = destroy_data;
|
|
||||||
|
|
||||||
ret = (GstMetaInfo *) info;
|
info->init_func = custom_init_func;
|
||||||
|
info->free_func = custom_free_func;
|
||||||
|
info->transform_func = custom_transform_func;
|
||||||
|
info->serialize_func = custom_serialize_func;
|
||||||
|
info->deserialize_func = custom_deserialize_func;
|
||||||
|
|
||||||
|
impl->is_custom = TRUE;
|
||||||
|
impl->custom_transform_func = transform_func;
|
||||||
|
impl->custom_transform_user_data = user_data;
|
||||||
|
impl->custom_transform_destroy_notify = destroy_data;
|
||||||
|
|
||||||
|
ret = gst_meta_info_register (info);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -411,27 +416,14 @@ gst_meta_register_internal (GType api, const gchar * impl, gsize size,
|
||||||
GstMetaDeserializeFunction deserialize_func)
|
GstMetaDeserializeFunction deserialize_func)
|
||||||
{
|
{
|
||||||
GstMetaInfo *info;
|
GstMetaInfo *info;
|
||||||
GType type;
|
|
||||||
|
|
||||||
g_return_val_if_fail (api != 0, NULL);
|
|
||||||
g_return_val_if_fail (impl != NULL, NULL);
|
|
||||||
g_return_val_if_fail (size != 0, NULL);
|
|
||||||
|
|
||||||
if (init_func == NULL)
|
if (init_func == NULL)
|
||||||
g_critical ("Registering meta implementation '%s' without init function",
|
g_critical ("Registering meta implementation '%s' without init function",
|
||||||
impl);
|
impl);
|
||||||
|
|
||||||
/* first try to register the implementation name. It's possible
|
info = gst_meta_info_new (api, impl, size);
|
||||||
* that this fails because it was already registered. Don't warn,
|
if (info == NULL)
|
||||||
* glib did this for us already. */
|
|
||||||
type = g_pointer_type_register_static (impl);
|
|
||||||
if (type == G_TYPE_INVALID)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
info = (GstMetaInfo *) g_new0 (GstMetaInfoImpl, 1);
|
|
||||||
info->api = api;
|
|
||||||
info->type = type;
|
|
||||||
info->size = size;
|
|
||||||
info->init_func = init_func;
|
info->init_func = init_func;
|
||||||
info->free_func = free_func;
|
info->free_func = free_func;
|
||||||
info->transform_func = transform_func;
|
info->transform_func = transform_func;
|
||||||
|
@ -439,16 +431,7 @@ gst_meta_register_internal (GType api, const gchar * impl, gsize size,
|
||||||
info->deserialize_func = deserialize_func;
|
info->deserialize_func = deserialize_func;
|
||||||
((GstMetaInfoImpl *) info)->is_custom = FALSE;
|
((GstMetaInfoImpl *) info)->is_custom = FALSE;
|
||||||
|
|
||||||
GST_CAT_DEBUG (GST_CAT_META,
|
return gst_meta_info_register (info);
|
||||||
"register \"%s\" implementing \"%s\" of size %" G_GSIZE_FORMAT, impl,
|
|
||||||
g_type_name (api), size);
|
|
||||||
|
|
||||||
g_rw_lock_writer_lock (&lock);
|
|
||||||
g_hash_table_insert (metainfo, (gpointer) g_intern_string (impl),
|
|
||||||
(gpointer) info);
|
|
||||||
g_rw_lock_writer_unlock (&lock);
|
|
||||||
|
|
||||||
return info;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -478,33 +461,103 @@ gst_meta_register (GType api, const gchar * impl, gsize size,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_meta_register_serializable: (skip):
|
* gst_meta_info_new:
|
||||||
* @api: the type of the #GstMeta API
|
* @api: the type of the #GstMeta API
|
||||||
* @impl: the name of the #GstMeta implementation
|
* @impl: the name of the #GstMeta implementation
|
||||||
* @size: the size of the #GstMeta structure
|
* @size: the size of the #GstMeta structure
|
||||||
* @init_func: a #GstMetaInitFunction
|
|
||||||
* @free_func: a #GstMetaFreeFunction
|
|
||||||
* @transform_func: a #GstMetaTransformFunction
|
|
||||||
* @serialize_func: a #GstMetaSerializeFunction
|
|
||||||
* @deserialize_func: a #GstMetaDeserializeFunction
|
|
||||||
*
|
*
|
||||||
* Same as gst_meta_register() but also set serialize/deserialize functions.
|
* Creates a new structure that needs to be filled before being
|
||||||
|
* registered. This structure should filled and then registered with
|
||||||
|
* gst_meta_info_register().
|
||||||
*
|
*
|
||||||
* Returns: (transfer none): a #GstMetaInfo that can be used to access metadata.
|
* Example:
|
||||||
|
* ```c
|
||||||
|
* const GstMetaInfo *
|
||||||
|
* gst_my_meta_get_info (void)
|
||||||
|
* {
|
||||||
|
* static const GstMetaInfo *meta_info = NULL;
|
||||||
|
*
|
||||||
|
* if (g_once_init_enter ((GstMetaInfo **) & meta_info)) {
|
||||||
|
* GstMetaInfo *info = gst_meta_info_new (
|
||||||
|
* gst_my_meta_api_get_type (),
|
||||||
|
* "GstMyMeta",
|
||||||
|
* sizeof (GstMyMeta));
|
||||||
|
* const GstMetaInfo *meta = NULL;
|
||||||
|
*
|
||||||
|
* info->init_func = my_meta_init;
|
||||||
|
* info->free_func = my_meta_free;
|
||||||
|
* info->transform_func = my_meta_transform;
|
||||||
|
* info->serialize_func = my_meta_serialize;
|
||||||
|
* info->deserialize_func = my_meta_deserialize;
|
||||||
|
* meta = gst_meta_info_register (info);
|
||||||
|
* g_once_init_leave ((GstMetaInfo **) & meta_info, (GstMetaInfo *) meta);
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* return meta_info;
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Returns: a new #GstMetaInfo that needs to be filled
|
||||||
*
|
*
|
||||||
* Since: 1.24
|
* Since: 1.24
|
||||||
*/
|
*/
|
||||||
const GstMetaInfo *
|
|
||||||
gst_meta_register_serializable (GType api, const gchar * impl, gsize size,
|
GstMetaInfo *
|
||||||
GstMetaInitFunction init_func, GstMetaFreeFunction free_func,
|
gst_meta_info_new (GType api, const gchar * impl, gsize size)
|
||||||
GstMetaTransformFunction transform_func,
|
|
||||||
GstMetaSerializeFunction serialize_func,
|
|
||||||
GstMetaDeserializeFunction deserialize_func)
|
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (serialize_func != NULL, NULL);
|
GType type;
|
||||||
g_return_val_if_fail (deserialize_func != NULL, NULL);
|
GstMetaInfo *info;
|
||||||
return gst_meta_register_internal (api, impl, size, init_func, free_func,
|
|
||||||
transform_func, serialize_func, deserialize_func);
|
g_return_val_if_fail (api != 0, NULL);
|
||||||
|
g_return_val_if_fail (impl != NULL, NULL);
|
||||||
|
g_return_val_if_fail (size != 0, NULL);
|
||||||
|
|
||||||
|
/* first try to register the implementation name. It's possible
|
||||||
|
* that this fails because it was already registered. Don't warn,
|
||||||
|
* glib did this for us already. */
|
||||||
|
type = g_pointer_type_register_static (impl);
|
||||||
|
|
||||||
|
info = (GstMetaInfo *) g_new0 (GstMetaInfoImpl, 1);
|
||||||
|
info->api = api;
|
||||||
|
info->type = type;
|
||||||
|
info->size = size;
|
||||||
|
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_meta_info_register:
|
||||||
|
* @info: (transfer full): a new #GstMetaInfo created by gst_meta_info_new()
|
||||||
|
*
|
||||||
|
* Registers a new meta.
|
||||||
|
*
|
||||||
|
* Use the structure returned by gst_meta_info_new(), it consumes it and the
|
||||||
|
* structure shouldnt be used after. The one returned by the function can be
|
||||||
|
* kept.
|
||||||
|
*
|
||||||
|
* Returns: (transfer none): the registered meta
|
||||||
|
*
|
||||||
|
* Since: 1.24
|
||||||
|
*/
|
||||||
|
|
||||||
|
const GstMetaInfo *
|
||||||
|
gst_meta_info_register (GstMetaInfo * info)
|
||||||
|
{
|
||||||
|
if (info->type == G_TYPE_INVALID) {
|
||||||
|
g_free (info);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_CAT_DEBUG (GST_CAT_META,
|
||||||
|
"register \"%s\" implementing \"%s\" of size %" G_GSIZE_FORMAT,
|
||||||
|
g_type_name (info->type), g_type_name (info->api), info->size);
|
||||||
|
|
||||||
|
g_rw_lock_writer_lock (&lock);
|
||||||
|
g_hash_table_insert (metainfo,
|
||||||
|
(gpointer) g_intern_string (g_type_name (info->type)), (gpointer) info);
|
||||||
|
g_rw_lock_writer_unlock (&lock);
|
||||||
|
|
||||||
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -367,13 +367,11 @@ const GstMetaInfo * gst_meta_register (GType api, const gchar *impl,
|
||||||
GstMetaTransformFunction transform_func);
|
GstMetaTransformFunction transform_func);
|
||||||
|
|
||||||
GST_API
|
GST_API
|
||||||
const GstMetaInfo * gst_meta_register_serializable (GType api, const gchar *impl,
|
GstMetaInfo * gst_meta_info_new (GType api,
|
||||||
gsize size,
|
const gchar *impl,
|
||||||
GstMetaInitFunction init_func,
|
gsize size);
|
||||||
GstMetaFreeFunction free_func,
|
GST_API
|
||||||
GstMetaTransformFunction transform_func,
|
const GstMetaInfo * gst_meta_info_register (GstMetaInfo *info);
|
||||||
GstMetaSerializeFunction serialize_func,
|
|
||||||
GstMetaDeserializeFunction deserialize_func);
|
|
||||||
|
|
||||||
GST_API
|
GST_API
|
||||||
const GstMetaInfo * gst_meta_register_custom (const gchar *name, const gchar **tags,
|
const GstMetaInfo * gst_meta_register_custom (const gchar *name, const gchar **tags,
|
||||||
|
|
Loading…
Reference in a new issue