From 351f8237045fbbf78bde8764b616ef4a3df2ef23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Cr=C3=AAte?= Date: Thu, 1 Feb 2024 18:03:58 -0500 Subject: [PATCH] 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: --- girs/GstAnalytics-1.0.gir | 10 ++++++++-- .../gst-libs/gst/analytics/gstanalyticsmeta.c | 15 ++++++++++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/girs/GstAnalytics-1.0.gir b/girs/GstAnalytics-1.0.gir index 9c9ebf6b03..7a04ce0c3d 100644 --- a/girs/GstAnalytics-1.0.gir +++ b/girs/GstAnalytics-1.0.gir @@ -177,13 +177,16 @@ Get instance size - + + Gets the string version of the name of this type of analytics data + the name + The type of analytics data @@ -963,13 +966,16 @@ Since 1.24 - + + Gets the string version of the name of this type of analytics data + the name + The type of analytics data diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/analytics/gstanalyticsmeta.c b/subprojects/gst-plugins-bad/gst-libs/gst/analytics/gstanalyticsmeta.c index 329d838811..92b714ea91 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/analytics/gstanalyticsmeta.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/analytics/gstanalyticsmeta.c @@ -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,7 +186,10 @@ gst_analytics_mtd_type_get_name (GstAnalyticsMtdType type) g_return_val_if_fail (impl != NULL, NULL); - return impl->name; + if (type == GST_ANALYTICS_MTD_TYPE_ANY) + return "ANY"; + else + return impl->name; } /**