analyticsmeta: Make the GstAnalyticsRelatableMtdData struct private

Only ask the subclass about how much space they need, this way we can keep
the allocation details more private.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5863>
This commit is contained in:
Olivier Crête 2023-12-22 19:45:35 -05:00
parent ed02a3991e
commit 91815710dd
6 changed files with 150 additions and 221 deletions

View file

@ -284,42 +284,6 @@ Quark of the class of object associated with this location.</doc>
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/analytics/gstanalyticsmeta.h">Only use for criteria.</doc> <doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/analytics/gstanalyticsmeta.h">Only use for criteria.</doc>
</member> </member>
</bitfield> </bitfield>
<record name="RelatableMtdData" c:type="GstAnalyticsRelatableMtdData" version="1.24">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/analytics/gstanalyticsmeta.h">Base structure for analysis-metadata that can be placed in relation. Only
other analysis-metadata based on GstAnalyticsRelatableMtdData should
directly use this structure.</doc>
<source-position filename="../subprojects/gst-plugins-bad/gst-libs/gst/analytics/gstanalyticsmeta.h"/>
<field name="analysis_type" writable="1">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/analytics/gstanalyticsmeta.h">Identify the type of analysis-metadata</doc>
<type name="MtdType" c:type="GstAnalyticsMtdType"/>
</field>
<field name="id" writable="1">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/analytics/gstanalyticsmeta.h">Instance identifier.</doc>
<type name="guint" c:type="guint"/>
</field>
<field name="size" writable="1">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/analytics/gstanalyticsmeta.h">Size in bytes of the instance</doc>
<type name="gsize" c:type="gsize"/>
</field>
<field name="free">
<callback name="free">
<source-position filename="../subprojects/gst-plugins-bad/gst-libs/gst/analytics/gstanalyticsmeta.h"/>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
<parameters>
<parameter name="mtd_data" transfer-ownership="none">
<type name="RelatableMtdData" c:type="GstAnalyticsRelatableMtdData*"/>
</parameter>
</parameters>
</callback>
</field>
<field name="_gst_reserved" writable="1">
<array zero-terminated="0" fixed-size="4">
<type name="gpointer" c:type="gpointer"/>
</array>
</field>
</record>
<record name="RelationMeta" c:type="GstAnalyticsRelationMeta" disguised="1"> <record name="RelationMeta" c:type="GstAnalyticsRelationMeta" disguised="1">
<source-position filename="../subprojects/gst-plugins-bad/gst-libs/gst/analytics/gstanalyticsmeta.h"/> <source-position filename="../subprojects/gst-plugins-bad/gst-libs/gst/analytics/gstanalyticsmeta.h"/>
<method name="add_cls_mtd" c:identifier="gst_analytics_relation_meta_add_cls_mtd" version="1.24"> <method name="add_cls_mtd" c:identifier="gst_analytics_relation_meta_add_cls_mtd" version="1.24">
@ -362,11 +326,11 @@ directly use this structure.</doc>
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/analytics/gstanalyticsmeta.c">Add a relatable metadata to @meta. This method is meant to be used by <doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/analytics/gstanalyticsmeta.c">Add a relatable metadata to @meta. This method is meant to be used by
new struct sub-classing GstAnalyticsRelatableMtd.</doc> new struct sub-classing GstAnalyticsRelatableMtd.</doc>
<source-position filename="../subprojects/gst-plugins-bad/gst-libs/gst/analytics/gstanalyticsmeta.h"/> <source-position filename="../subprojects/gst-plugins-bad/gst-libs/gst/analytics/gstanalyticsmeta.h"/>
<return-value> <return-value transfer-ownership="none" nullable="1">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/analytics/gstanalyticsmeta.c">New GstAnalyticsRelatableMtdData instance. <doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/analytics/gstanalyticsmeta.c">A pointer to a memory area of size @size where to put the data
Since 1.24</doc> Since 1.24</doc>
<type name="RelatableMtdData" c:type="GstAnalyticsRelatableMtdData*"/> <type name="gpointer" c:type="gpointer"/>
</return-value> </return-value>
<parameters> <parameters>
<instance-parameter name="meta" transfer-ownership="none"> <instance-parameter name="meta" transfer-ownership="none">
@ -631,11 +595,11 @@ Since 1.24</doc>
</method> </method>
<method name="get_mtd_data" c:identifier="gst_analytics_relation_meta_get_mtd_data" introspectable="0"> <method name="get_mtd_data" c:identifier="gst_analytics_relation_meta_get_mtd_data" introspectable="0">
<source-position filename="../subprojects/gst-plugins-bad/gst-libs/gst/analytics/gstanalyticsmeta.h"/> <source-position filename="../subprojects/gst-plugins-bad/gst-libs/gst/analytics/gstanalyticsmeta.h"/>
<return-value nullable="1"> <return-value transfer-ownership="none" nullable="1">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/analytics/gstanalyticsmeta.c">Instance of GstAnalyticsRelatableMtdData <doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/analytics/gstanalyticsmeta.c">Analytics data pointer
Since 1.24</doc> Since 1.24</doc>
<type name="RelatableMtdData" c:type="GstAnalyticsRelatableMtdData*"/> <type name="gpointer" c:type="gpointer"/>
</return-value> </return-value>
<parameters> <parameters>
<instance-parameter name="meta" transfer-ownership="none"> <instance-parameter name="meta" transfer-ownership="none">

View file

@ -39,7 +39,6 @@ struct _GstAnalyticsClsConfLvlAndClass
/* /*
* GstAnalyticsClsMtd: * GstAnalyticsClsMtd:
* @parent: parent
* @length: classes and confidence levels count * @length: classes and confidence levels count
* @class_quarks: (array length=length): Array of quark representing a class * @class_quarks: (array length=length): Array of quark representing a class
* @confidence_levels: (array length=length): Array of confidence levels for * @confidence_levels: (array length=length): Array of confidence levels for
@ -49,25 +48,10 @@ struct _GstAnalyticsClsConfLvlAndClass
*/ */
struct _GstAnalyticsClsMtdData struct _GstAnalyticsClsMtdData
{ {
GstAnalyticsRelatableMtdData parent;
gsize length; gsize length;
GstAnalyticsClsConfLvlAndClass confidence_levels_and_classes[]; // Must be last GstAnalyticsClsConfLvlAndClass confidence_levels_and_classes[]; // Must be last
}; };
static GstAnalyticsClsMtdData *
gst_analytics_cls_mtd_get_data (GstAnalyticsClsMtd * instance)
{
GstAnalyticsRelatableMtdData *rlt_data =
gst_analytics_relation_meta_get_mtd_data (instance->meta,
instance->id);
g_return_val_if_fail (rlt_data, NULL);
g_return_val_if_fail (rlt_data->analysis_type ==
gst_analytics_cls_mtd_get_type_quark (), NULL);
return (GstAnalyticsClsMtdData *) rlt_data;
}
/** /**
* gst_analytics_cls_mtd_get_type_quark: * gst_analytics_cls_mtd_get_type_quark:
* Get a quark identifying #GstAnalyticsMtd type. * Get a quark identifying #GstAnalyticsMtd type.
@ -113,7 +97,8 @@ gst_analytics_cls_mtd_get_level (GstAnalyticsClsMtd * handle, gint index)
g_return_val_if_fail (index >= 0, -1.0); g_return_val_if_fail (index >= 0, -1.0);
g_return_val_if_fail (handle->meta != NULL, -1.0); g_return_val_if_fail (handle->meta != NULL, -1.0);
GstAnalyticsClsMtdData *cls_mtd_data; GstAnalyticsClsMtdData *cls_mtd_data;
cls_mtd_data = gst_analytics_cls_mtd_get_data (handle); cls_mtd_data = gst_analytics_relation_meta_get_mtd_data (handle->meta,
handle->id);
g_return_val_if_fail (cls_mtd_data != NULL, -1.0); g_return_val_if_fail (cls_mtd_data != NULL, -1.0);
g_return_val_if_fail (cls_mtd_data->length > index, -1.0); g_return_val_if_fail (cls_mtd_data->length > index, -1.0);
return cls_mtd_data->confidence_levels_and_classes[index].confidence_levels; return cls_mtd_data->confidence_levels_and_classes[index].confidence_levels;
@ -136,7 +121,8 @@ gst_analytics_cls_mtd_get_index_by_quark (GstAnalyticsClsMtd * handle,
g_return_val_if_fail (handle, -1); g_return_val_if_fail (handle, -1);
GstAnalyticsClsMtdData *cls_mtd_data; GstAnalyticsClsMtdData *cls_mtd_data;
cls_mtd_data = gst_analytics_cls_mtd_get_data (handle); cls_mtd_data = gst_analytics_relation_meta_get_mtd_data (handle->meta,
handle->id);
g_return_val_if_fail (cls_mtd_data != NULL, -1); g_return_val_if_fail (cls_mtd_data != NULL, -1);
for (gint i = 0; i < cls_mtd_data->length; i++) { for (gint i = 0; i < cls_mtd_data->length; i++) {
@ -159,7 +145,8 @@ gsize
gst_analytics_cls_mtd_get_length (GstAnalyticsClsMtd * handle) gst_analytics_cls_mtd_get_length (GstAnalyticsClsMtd * handle)
{ {
GstAnalyticsClsMtdData *cls_mtd_data; GstAnalyticsClsMtdData *cls_mtd_data;
cls_mtd_data = gst_analytics_cls_mtd_get_data (handle); cls_mtd_data = gst_analytics_relation_meta_get_mtd_data (handle->meta,
handle->id);
g_return_val_if_fail (cls_mtd_data != NULL, 0); g_return_val_if_fail (cls_mtd_data != NULL, 0);
return cls_mtd_data->length; return cls_mtd_data->length;
} }
@ -178,7 +165,8 @@ gst_analytics_cls_mtd_get_quark (GstAnalyticsClsMtd * handle, gint index)
{ {
GstAnalyticsClsMtdData *cls_mtd_data; GstAnalyticsClsMtdData *cls_mtd_data;
g_return_val_if_fail (handle, 0); g_return_val_if_fail (handle, 0);
cls_mtd_data = gst_analytics_cls_mtd_get_data (handle); cls_mtd_data = gst_analytics_relation_meta_get_mtd_data (handle->meta,
handle->id);
g_return_val_if_fail (cls_mtd_data != NULL, 0); g_return_val_if_fail (cls_mtd_data != NULL, 0);
return cls_mtd_data->confidence_levels_and_classes[index].class; return cls_mtd_data->confidence_levels_and_classes[index].class;
} }

View file

@ -27,68 +27,24 @@
GST_DEBUG_CATEGORY_STATIC (an_relation_meta_debug); GST_DEBUG_CATEGORY_STATIC (an_relation_meta_debug);
#define GST_CAT_AN_RELATION an_relation_meta_debug #define GST_CAT_AN_RELATION an_relation_meta_debug
static char invalid_type_name[] = "_invalid"; /*
* GstAnalyticsRelatableMtdData:
static guint * @analysis_type: Identify the type of analysis-metadata
gst_analytics_relation_meta_get_next_id (GstAnalyticsRelationMeta * meta); * @id: Instance identifier.
* @size: Size in bytes of the instance
/**
* gst_analytics_mtd_get_type_quark:
* @instance: Instance of #GstAnalyticsMtd
* Get analysis result type.
* *
* Returns: quark associated with type. * Base structure for analysis-metadata that can be placed in relation. Only
* * other analysis-metadata based on GstAnalyticsRelatableMtdDatax should
* Since: 1.24 * directly use this structure.
*/ */
GstAnalyticsMtdType typedef struct
gst_analytics_mtd_get_type_quark (GstAnalyticsMtd * handle)
{ {
GstAnalyticsRelatableMtdData *rlt; GstAnalyticsMtdType analysis_type;
rlt = gst_analytics_relation_meta_get_mtd_data (handle->meta, handle->id); guint id;
gsize size;
gpointer data[];
} GstAnalyticsRelatableMtdData;
g_return_val_if_fail (rlt != NULL,
g_quark_from_static_string (invalid_type_name));
return rlt->analysis_type;
}
/**
* gst_analytics_mtd_get_id:
* @instance: Instance of #GstAnalyticsMtd
* Get instance id
*
* Returns: Id of @instance
*
* Since: 1.24
*/
guint
gst_analytics_mtd_get_id (GstAnalyticsMtd * handle)
{
return handle->id;
}
/**
* gst_analytics_mtd_get_size:
* @instance Instance of #GstAnalyticsRelatableMtd
* Get instance size
*
* Returns: Size (in bytes) of this instance or 0 on failure.
*
* Since: 1.24
*/
gsize
gst_analytics_mtd_get_size (GstAnalyticsMtd * handle)
{
GstAnalyticsRelatableMtdData *rlt;
rlt = gst_analytics_relation_meta_get_mtd_data (handle->meta, handle->id);
if (rlt == NULL) {
GST_CAT_ERROR (GST_CAT_AN_RELATION, "Invalid parameter");
return 0;
}
return rlt->size;
}
/* /*
* GstAnalyticsRelationMeta: * GstAnalyticsRelationMeta:
@ -132,6 +88,89 @@ typedef struct _GstAnalyticsRelationMeta
} GstAnalyticsRelationMeta; } GstAnalyticsRelationMeta;
static char invalid_type_name[] = "_invalid";
static guint
gst_analytics_relation_meta_get_next_id (GstAnalyticsRelationMeta * meta);
static GstAnalyticsRelatableMtdData *
gst_analytics_relation_meta_get_mtd_data_internal (GstAnalyticsRelationMeta *
meta, guint an_meta_id)
{
GstAnalyticsRelatableMtdData *rv;
g_return_val_if_fail (meta, NULL);
if (an_meta_id >= meta->rel_order) {
GST_CAT_ERROR (GST_CAT_AN_RELATION, "Invalid parameter");
return NULL;
}
rv = (GstAnalyticsRelatableMtdData *)
(meta->mtd_data_lookup[an_meta_id] + meta->analysis_results);
return rv;
}
/**
* gst_analytics_mtd_get_type_quark:
* @instance: Instance of #GstAnalyticsMtd
* Get analysis result type.
*
* Returns: quark associated with type.
*
* Since: 1.24
*/
GstAnalyticsMtdType
gst_analytics_mtd_get_type_quark (GstAnalyticsMtd * handle)
{
GstAnalyticsRelatableMtdData *rlt;
rlt = gst_analytics_relation_meta_get_mtd_data_internal (handle->meta,
handle->id);
g_return_val_if_fail (rlt != NULL,
g_quark_from_static_string (invalid_type_name));
return rlt->analysis_type;
}
/**
* gst_analytics_mtd_get_id:
* @instance: Instance of #GstAnalyticsMtd
* Get instance id
*
* Returns: Id of @instance
*
* Since: 1.24
*/
guint
gst_analytics_mtd_get_id (GstAnalyticsMtd * handle)
{
return handle->id;
}
/**
* gst_analytics_mtd_get_size:
* @instance Instance of #GstAnalyticsRelatableMtd
* Get instance size
*
* Returns: Size (in bytes) of this instance or 0 on failure.
*
* Since: 1.24
*/
gsize
gst_analytics_mtd_get_size (GstAnalyticsMtd * handle)
{
GstAnalyticsRelatableMtdData *rlt;
rlt = gst_analytics_relation_meta_get_mtd_data_internal (handle->meta,
handle->id);
if (rlt == NULL) {
GST_CAT_ERROR (GST_CAT_AN_RELATION, "Invalid parameter");
return 0;
}
return rlt->size;
}
/** /**
* gst_analytics_relation_get_length: * gst_analytics_relation_get_length:
* @instance Instance of #GstAnalyticsRelationMeta * @instance Instance of #GstAnalyticsRelationMeta
@ -256,21 +295,11 @@ static void
gst_analytics_relation_meta_free (GstMeta * meta, GstBuffer * buffer) gst_analytics_relation_meta_free (GstMeta * meta, GstBuffer * buffer)
{ {
GstAnalyticsRelationMeta *rmeta = (GstAnalyticsRelationMeta *) meta; GstAnalyticsRelationMeta *rmeta = (GstAnalyticsRelationMeta *) meta;
gpointer state = NULL;
GstAnalyticsMtd mtd;
GstAnalyticsRelatableMtdData *data;
GST_CAT_TRACE (GST_CAT_AN_RELATION, GST_CAT_TRACE (GST_CAT_AN_RELATION,
"Content analysis meta-data(%p) freed for buffer(%p)", "Content analysis meta-data(%p) freed for buffer(%p)",
(gpointer) rmeta, (gpointer) buffer); (gpointer) rmeta, (gpointer) buffer);
/* call custom free function if set */
while (gst_analytics_relation_meta_iterate (rmeta, &state, 0, &mtd)) {
data = gst_analytics_relation_meta_get_mtd_data (mtd.meta, mtd.id);
if (data->free != NULL) {
data->free (data);
}
}
g_free (rmeta->analysis_results); g_free (rmeta->analysis_results);
g_free (rmeta->adj_mat); g_free (rmeta->adj_mat);
g_free (rmeta->mtd_data_lookup); g_free (rmeta->mtd_data_lookup);
@ -779,15 +808,16 @@ gst_buffer_get_analytics_relation_meta (GstBuffer * buffer)
* Add a relatable metadata to @meta. This method is meant to be used by * Add a relatable metadata to @meta. This method is meant to be used by
* new struct sub-classing GstAnalyticsRelatableMtd. * new struct sub-classing GstAnalyticsRelatableMtd.
* *
* Returns: New GstAnalyticsRelatableMtdData instance. * Returns: A pointer to a memory area of size @size where to put the data
* *
* Since 1.24 * Since 1.24
*/ */
GstAnalyticsRelatableMtdData * gpointer
gst_analytics_relation_meta_add_mtd (GstAnalyticsRelationMeta * meta, gst_analytics_relation_meta_add_mtd (GstAnalyticsRelationMeta * meta,
GstAnalyticsMtdType type, gsize size, GstAnalyticsMtd * rlt_mtd) GstAnalyticsMtdType type, gsize size, GstAnalyticsMtd * rlt_mtd)
{ {
gsize new_size = size + meta->offset; gsize object_size;
gsize new_size;
GstAnalyticsRelatableMtdData *dest = NULL; GstAnalyticsRelatableMtdData *dest = NULL;
gpointer mem; gpointer mem;
guint8 **new_adj_mat; guint8 **new_adj_mat;
@ -795,6 +825,12 @@ gst_analytics_relation_meta_add_mtd (GstAnalyticsRelationMeta * meta,
GST_CAT_TRACE (GST_CAT_AN_RELATION, "Adding relatable metadata to rmeta %p", GST_CAT_TRACE (GST_CAT_AN_RELATION, "Adding relatable metadata to rmeta %p",
meta); meta);
object_size = sizeof (GstAnalyticsRelatableMtdData);
object_size += sizeof (gpointer) * (size / sizeof (gpointer));
if (size % sizeof (gpointer))
object_size += sizeof (gpointer);
new_size = meta->offset + object_size;
if (new_size > meta->max_size) { if (new_size > meta->max_size) {
if (new_size > meta->max_size_increment + meta->offset) { if (new_size > meta->max_size_increment + meta->offset) {
@ -827,9 +863,8 @@ gst_analytics_relation_meta_add_mtd (GstAnalyticsRelationMeta * meta,
dest->analysis_type = type; dest->analysis_type = type;
dest->id = gst_analytics_relation_meta_get_next_id (meta); dest->id = gst_analytics_relation_meta_get_next_id (meta);
dest->size = size; dest->size = size;
dest->free = NULL;
meta->mtd_data_lookup[dest->id] = meta->offset; meta->mtd_data_lookup[dest->id] = meta->offset;
meta->offset += dest->size; meta->offset += object_size;
meta->length++; meta->length++;
rlt_mtd->id = dest->id; rlt_mtd->id = dest->id;
rlt_mtd->meta = meta; rlt_mtd->meta = meta;
@ -841,7 +876,7 @@ gst_analytics_relation_meta_add_mtd (GstAnalyticsRelationMeta * meta,
"Failed to add relatable, out-of-space (%" G_GSIZE_FORMAT " / %" "Failed to add relatable, out-of-space (%" G_GSIZE_FORMAT " / %"
G_GSIZE_FORMAT ").", new_size, meta->max_size); G_GSIZE_FORMAT ").", new_size, meta->max_size);
} }
return dest; return &dest->data[0];
} }
/** /**
@ -876,7 +911,7 @@ gst_analytics_relation_meta_get_mtd (GstAnalyticsRelationMeta * meta,
return FALSE; return FALSE;
} }
d = gst_analytics_relation_meta_get_mtd_data (meta, an_meta_id); d = gst_analytics_relation_meta_get_mtd_data_internal (meta, an_meta_id);
if (d == NULL) if (d == NULL)
return FALSE; return FALSE;
@ -899,23 +934,17 @@ gst_analytics_relation_meta_get_mtd (GstAnalyticsRelationMeta * meta,
* @meta: Instance of GstAnalyticsRelationMeta * @meta: Instance of GstAnalyticsRelationMeta
* @an_meta_id: Id of GstAnalyticsMtd instance to retrieve * @an_meta_id: Id of GstAnalyticsMtd instance to retrieve
* *
* Returns:(nullable): Instance of GstAnalyticsRelatableMtdData * Returns:(nullable): Analytics data pointer
* *
* Since 1.24 * Since 1.24
*/ */
GstAnalyticsRelatableMtdData * gpointer
gst_analytics_relation_meta_get_mtd_data (GstAnalyticsRelationMeta * gst_analytics_relation_meta_get_mtd_data (GstAnalyticsRelationMeta *
meta, guint an_meta_id) meta, guint an_meta_id)
{ {
GstAnalyticsRelatableMtdData *rv; GstAnalyticsRelatableMtdData *rv =
g_return_val_if_fail (meta, NULL); gst_analytics_relation_meta_get_mtd_data_internal (meta, an_meta_id);
if (an_meta_id >= meta->rel_order) { return &rv->data[0];
GST_CAT_ERROR (GST_CAT_AN_RELATION, "Invalid parameter");
return NULL;
}
rv = (GstAnalyticsRelatableMtdData *)
(meta->mtd_data_lookup[an_meta_id] + meta->analysis_results);
return rv;
} }

View file

@ -56,7 +56,6 @@ typedef guint32 GstAnalyticsMtdType;
#define GST_ANALYTICS_MTD_CAST(mtd) \ #define GST_ANALYTICS_MTD_CAST(mtd) \
((GstAnalyticsMtd *)(mtd)) ((GstAnalyticsMtd *)(mtd))
typedef struct _GstAnalyticsRelatableMtdData GstAnalyticsRelatableMtdData;
typedef struct _GstAnalyticsRelationMeta GstAnalyticsRelationMeta; typedef struct _GstAnalyticsRelationMeta GstAnalyticsRelationMeta;
/** /**
@ -76,29 +75,6 @@ struct _GstAnalyticsMtd
GstAnalyticsRelationMeta *meta; GstAnalyticsRelationMeta *meta;
}; };
/**
* GstAnalyticsRelatableMtdData:
* @analysis_type: Identify the type of analysis-metadata
* @id: Instance identifier.
* @size: Size in bytes of the instance
*
* Base structure for analysis-metadata that can be placed in relation. Only
* other analysis-metadata based on GstAnalyticsRelatableMtdData should
* directly use this structure.
*
* Since: 1.24
*/
struct _GstAnalyticsRelatableMtdData
{
GstAnalyticsMtdType analysis_type;
guint id;
gsize size;
void (*free) (GstAnalyticsRelatableMtdData * mtd_data);
gpointer _gst_reserved[GST_PADDING];
};
GST_ANALYTICS_META_API GST_ANALYTICS_META_API
GstAnalyticsMtdType gst_analytics_mtd_get_type_quark (GstAnalyticsMtd * instance); GstAnalyticsMtdType gst_analytics_mtd_get_type_quark (GstAnalyticsMtd * instance);
@ -196,7 +172,7 @@ GstAnalyticsRelationMeta *
gst_buffer_get_analytics_relation_meta (GstBuffer * buffer); gst_buffer_get_analytics_relation_meta (GstBuffer * buffer);
GST_ANALYTICS_META_API GST_ANALYTICS_META_API
GstAnalyticsRelatableMtdData * gpointer
gst_analytics_relation_meta_add_mtd (GstAnalyticsRelationMeta * meta, gst_analytics_relation_meta_add_mtd (GstAnalyticsRelationMeta * meta,
GstAnalyticsMtdType type, gsize size, GstAnalyticsMtd * rlt_mtd); GstAnalyticsMtdType type, gsize size, GstAnalyticsMtd * rlt_mtd);
@ -206,7 +182,7 @@ gst_analytics_relation_meta_get_mtd (GstAnalyticsRelationMeta *
meta, guint an_meta_id, GstAnalyticsMtdType type, GstAnalyticsMtd * rlt); meta, guint an_meta_id, GstAnalyticsMtdType type, GstAnalyticsMtd * rlt);
GST_ANALYTICS_META_API GST_ANALYTICS_META_API
GstAnalyticsRelatableMtdData * gpointer
gst_analytics_relation_meta_get_mtd_data (GstAnalyticsRelationMeta * meta, gst_analytics_relation_meta_get_mtd_data (GstAnalyticsRelationMeta * meta,
guint an_meta_id); guint an_meta_id);

View file

@ -32,7 +32,6 @@ typedef struct _GstAnalyticsODMtdData GstAnalyticsODMtdData;
/** /**
* GstAnalyticsODMtdData: * GstAnalyticsODMtdData:
* @parent: parent #GstAnalyticsMtd
* @object_type: Type of object * @object_type: Type of object
* @x: x component of upper-left corner * @x: x component of upper-left corner
* @y: y component of upper-left corner * @y: y component of upper-left corner
@ -46,7 +45,6 @@ typedef struct _GstAnalyticsODMtdData GstAnalyticsODMtdData;
*/ */
struct _GstAnalyticsODMtdData struct _GstAnalyticsODMtdData
{ {
GstAnalyticsRelatableMtdData parent;
GQuark object_type; GQuark object_type;
gint x; gint x;
gint y; gint y;
@ -84,19 +82,6 @@ gst_analytics_od_mtd_get_type_name (void)
return GST_RELATABLE_MTD_OD_TYPE_NAME; return GST_RELATABLE_MTD_OD_TYPE_NAME;
} }
static GstAnalyticsODMtdData *
gst_analytics_od_mtd_get_data (GstAnalyticsODMtd * instance)
{
GstAnalyticsRelatableMtdData *rlt_data =
gst_analytics_relation_meta_get_mtd_data (instance->meta,
instance->id);
g_return_val_if_fail (rlt_data, NULL);
g_return_val_if_fail (rlt_data->analysis_type ==
gst_analytics_od_mtd_get_type_quark (), NULL);
return (GstAnalyticsODMtdData *) rlt_data;
}
/** /**
* gst_analytics_od_mtd_get_location: * gst_analytics_od_mtd_get_location:
* @instance: instance * @instance: instance
@ -117,21 +102,20 @@ gboolean
gst_analytics_od_mtd_get_location (GstAnalyticsODMtd * instance, gst_analytics_od_mtd_get_location (GstAnalyticsODMtd * instance,
gint * x, gint * y, gint * w, gint * h, gfloat * loc_conf_lvl) gint * x, gint * y, gint * w, gint * h, gfloat * loc_conf_lvl)
{ {
g_return_val_if_fail (instance && x && y && w && h, FALSE);
GstAnalyticsODMtdData *data; GstAnalyticsODMtdData *data;
data = gst_analytics_od_mtd_get_data (instance);
g_return_val_if_fail (instance && x && y && w && h, FALSE);
data = gst_analytics_relation_meta_get_mtd_data (instance->meta,
instance->id);
g_return_val_if_fail (data != NULL, FALSE); g_return_val_if_fail (data != NULL, FALSE);
if (data) {
*x = data->x; *x = data->x;
*y = data->y; *y = data->y;
*w = data->w; *w = data->w;
*h = data->h; *h = data->h;
if (loc_conf_lvl) { if (loc_conf_lvl)
*loc_conf_lvl = data->location_confidence_lvl; *loc_conf_lvl = data->location_confidence_lvl;
}
}
return TRUE; return TRUE;
} }
@ -149,7 +133,8 @@ gst_analytics_od_mtd_get_type (GstAnalyticsODMtd * handle)
{ {
GstAnalyticsODMtdData *data; GstAnalyticsODMtdData *data;
g_return_val_if_fail (handle != NULL, 0); g_return_val_if_fail (handle != NULL, 0);
data = gst_analytics_od_mtd_get_data (handle); data = gst_analytics_relation_meta_get_mtd_data (handle->meta,
handle->id);
g_return_val_if_fail (data != NULL, 0); g_return_val_if_fail (data != NULL, 0);
return data->object_type; return data->object_type;
} }

View file

@ -30,7 +30,6 @@ typedef struct _GstAnalyticsTrackingMtdData GstAnalyticsTrackingMtdData;
/** /**
* GstAnalyticsTrackingMtd: * GstAnalyticsTrackingMtd:
* @parent: parent #GstAnalyticsMtd
* @tracking_id: Tracking identifier * @tracking_id: Tracking identifier
* @tracking_first_seen: Tracking creation time * @tracking_first_seen: Tracking creation time
* @tracking_last_seen: Tracking last observation * @tracking_last_seen: Tracking last observation
@ -42,7 +41,6 @@ typedef struct _GstAnalyticsTrackingMtdData GstAnalyticsTrackingMtdData;
*/ */
struct _GstAnalyticsTrackingMtdData struct _GstAnalyticsTrackingMtdData
{ {
GstAnalyticsRelatableMtdData parent;
guint64 tracking_id; guint64 tracking_id;
GstClockTime tracking_first_seen; GstClockTime tracking_first_seen;
GstClockTime tracking_last_seen; GstClockTime tracking_last_seen;
@ -52,20 +50,6 @@ struct _GstAnalyticsTrackingMtdData
static char type[] = GST_RELATABLE_MTD_TRACKING_TYPE_NAME; static char type[] = GST_RELATABLE_MTD_TRACKING_TYPE_NAME;
static GstAnalyticsTrackingMtdData *
gst_analytics_tracking_mtd_get_data (GstAnalyticsTrackingMtd * instance)
{
GstAnalyticsRelatableMtdData *rlt_data =
gst_analytics_relation_meta_get_mtd_data (instance->meta,
instance->id);
g_return_val_if_fail (rlt_data, NULL);
g_return_val_if_fail (rlt_data->analysis_type ==
gst_analytics_tracking_mtd_get_type_quark (), NULL);
return (GstAnalyticsTrackingMtdData *) rlt_data;
}
/** /**
* gst_analytics_tracking_mtd_get_type_quark: * gst_analytics_tracking_mtd_get_type_quark:
* Returns: Quark representing the type of GstAnalyticsRelatableMtd * Returns: Quark representing the type of GstAnalyticsRelatableMtd
@ -107,7 +91,8 @@ gst_analytics_tracking_mtd_update_last_seen (GstAnalyticsTrackingMtd * instance,
{ {
GstAnalyticsTrackingMtdData *trk_mtd_data; GstAnalyticsTrackingMtdData *trk_mtd_data;
g_return_val_if_fail (instance, FALSE); g_return_val_if_fail (instance, FALSE);
trk_mtd_data = gst_analytics_tracking_mtd_get_data (instance); trk_mtd_data = gst_analytics_relation_meta_get_mtd_data (instance->meta,
instance->id);
g_return_val_if_fail (trk_mtd_data != NULL, FALSE); g_return_val_if_fail (trk_mtd_data != NULL, FALSE);
trk_mtd_data->tracking_last_seen = last_seen; trk_mtd_data->tracking_last_seen = last_seen;
@ -128,7 +113,8 @@ gst_analytics_tracking_mtd_set_lost (GstAnalyticsTrackingMtd * instance)
{ {
GstAnalyticsTrackingMtdData *trk_mtd_data; GstAnalyticsTrackingMtdData *trk_mtd_data;
g_return_val_if_fail (instance, FALSE); g_return_val_if_fail (instance, FALSE);
trk_mtd_data = gst_analytics_tracking_mtd_get_data (instance); trk_mtd_data = gst_analytics_relation_meta_get_mtd_data (instance->meta,
instance->id);
g_return_val_if_fail (trk_mtd_data != NULL, FALSE); g_return_val_if_fail (trk_mtd_data != NULL, FALSE);
trk_mtd_data->tracking_lost = TRUE; trk_mtd_data->tracking_lost = TRUE;
return TRUE; return TRUE;
@ -154,7 +140,8 @@ gst_analytics_tracking_mtd_get_info (GstAnalyticsTrackingMtd * instance,
{ {
GstAnalyticsTrackingMtdData *trk_mtd_data; GstAnalyticsTrackingMtdData *trk_mtd_data;
g_return_val_if_fail (instance, FALSE); g_return_val_if_fail (instance, FALSE);
trk_mtd_data = gst_analytics_tracking_mtd_get_data (instance); trk_mtd_data = gst_analytics_relation_meta_get_mtd_data (instance->meta,
instance->id);
g_return_val_if_fail (trk_mtd_data != NULL, FALSE); g_return_val_if_fail (trk_mtd_data != NULL, FALSE);