diff --git a/gst-libs/gst/mpegts/gst-dvb-descriptor.c b/gst-libs/gst/mpegts/gst-dvb-descriptor.c index 466589bdc6..8a22c891a8 100644 --- a/gst-libs/gst/mpegts/gst-dvb-descriptor.c +++ b/gst-libs/gst/mpegts/gst-dvb-descriptor.c @@ -75,6 +75,40 @@ gst_mpegts_descriptor_parse_dvb_network_name (const GstMpegTsDescriptor * return TRUE; } +/** + * gst_mpegts_descriptor_from_dvb_network_name: + * @name: the network name to set + * + * Fills a #GstMpegTsDescriptor to be a %GST_MTS_DESC_DVB_NETWORK_NAME, + * with the network name @name. The data field of the #GstMpegTsDescriptor + * will be allocated, and transferred to the caller. + * + * Returns: (transfer full): the #GstMpegTsDescriptor or %NULL on fail + */ +GstMpegTsDescriptor * +gst_mpegts_descriptor_from_dvb_network_name (const gchar * name) +{ + GstMpegTsDescriptor *descriptor; + guint8 *converted_name; + gsize size; + + g_return_val_if_fail (name != NULL, NULL); + g_return_val_if_fail (strlen (name) <= 256, NULL); + + converted_name = dvb_text_from_utf8 (name, &size); + + if (!converted_name) { + GST_WARNING ("Could not find proper encoding for string `%s`", name); + return NULL; + } + + descriptor = _new_descriptor (GST_MTS_DESC_DVB_NETWORK_NAME, size); + memcpy (descriptor->data + 2, converted_name, size); + g_free (converted_name); + + return descriptor; +} + /* GST_MTS_DESC_DVB_SATELLITE_DELIVERY_SYSTEM (0x43) */ /** * gst_mpegts_descriptor_parse_satellite_delivery_system: diff --git a/gst-libs/gst/mpegts/gst-dvb-descriptor.h b/gst-libs/gst/mpegts/gst-dvb-descriptor.h index f04b162416..957dd10aea 100644 --- a/gst-libs/gst/mpegts/gst-dvb-descriptor.h +++ b/gst-libs/gst/mpegts/gst-dvb-descriptor.h @@ -123,6 +123,8 @@ typedef enum { gboolean gst_mpegts_descriptor_parse_dvb_network_name (const GstMpegTsDescriptor *descriptor, gchar **name); +GstMpegTsDescriptor *gst_mpegts_descriptor_from_dvb_network_name (const gchar * name); + /* GST_MTS_DESC_DVB_SATELLITE_DELIVERY_SYSTEM (0x43) */ typedef struct _GstMpegTsSatelliteDeliverySystemDescriptor GstMpegTsSatelliteDeliverySystemDescriptor;