analytics: Always return a string from mtd_type_get_name()

It makes it easier to use in printf() style strings without worrying
about getting a NULL.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6035>
This commit is contained in:
Olivier Crête 2024-02-01 18:03:58 -05:00 committed by GStreamer Marge Bot
parent 0850922104
commit 351f823704
2 changed files with 22 additions and 3 deletions

View file

@ -177,13 +177,16 @@ Get instance size</doc>
</instance-parameter>
</parameters>
</method>
<function name="type_get_name" c:identifier="gst_analytics_mtd_type_get_name">
<function name="type_get_name" c:identifier="gst_analytics_mtd_type_get_name" version="1.24">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/analytics/gstanalyticsmeta.c">Gets the string version of the name of this type of analytics data</doc>
<source-position filename="../subprojects/gst-plugins-bad/gst-libs/gst/analytics/gstanalyticsmeta.h"/>
<return-value transfer-ownership="none">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/analytics/gstanalyticsmeta.c">the name</doc>
<type name="utf8" c:type="const gchar*"/>
</return-value>
<parameters>
<parameter name="type" transfer-ownership="none">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/analytics/gstanalyticsmeta.c">The type of analytics data</doc>
<type name="MtdType" c:type="GstAnalyticsMtdType"/>
</parameter>
</parameters>
@ -963,13 +966,16 @@ Since 1.24</doc>
<type name="MtdType" c:type="GstAnalyticsMtdType"/>
</return-value>
</function>
<function name="mtd_type_get_name" c:identifier="gst_analytics_mtd_type_get_name" moved-to="Mtd.type_get_name">
<function name="mtd_type_get_name" c:identifier="gst_analytics_mtd_type_get_name" moved-to="Mtd.type_get_name" version="1.24">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/analytics/gstanalyticsmeta.c">Gets the string version of the name of this type of analytics data</doc>
<source-position filename="../subprojects/gst-plugins-bad/gst-libs/gst/analytics/gstanalyticsmeta.h"/>
<return-value transfer-ownership="none">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/analytics/gstanalyticsmeta.c">the name</doc>
<type name="utf8" c:type="const gchar*"/>
</return-value>
<parameters>
<parameter name="type" transfer-ownership="none">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/analytics/gstanalyticsmeta.c">The type of analytics data</doc>
<type name="MtdType" c:type="GstAnalyticsMtdType"/>
</parameter>
</parameters>

View file

@ -169,6 +169,16 @@ gst_analytics_mtd_get_size (GstAnalyticsMtd * handle)
return rlt->size;
}
/**
* gst_analytics_mtd_type_get_name:
* @type: The type of analytics data
*
* Gets the string version of the name of this type of analytics data
*
* Returns: the name
*
* Since: 1.24
*/
const gchar *
gst_analytics_mtd_type_get_name (GstAnalyticsMtdType type)
{
@ -176,6 +186,9 @@ gst_analytics_mtd_type_get_name (GstAnalyticsMtdType type)
g_return_val_if_fail (impl != NULL, NULL);
if (type == GST_ANALYTICS_MTD_TYPE_ANY)
return "ANY";
else
return impl->name;
}