From dd449c38e6d0b88dd6c40e59a40c3a25ab8546e6 Mon Sep 17 00:00:00 2001 From: Jesper Larsen Date: Mon, 28 Oct 2013 14:49:08 +0100 Subject: [PATCH] mpegts: Add network name descriptor construction Add function to create a Network Name DVB descriptor. --- gst-libs/gst/mpegts/gst-dvb-descriptor.c | 34 ++++++++++++++++++++++++ gst-libs/gst/mpegts/gst-dvb-descriptor.h | 2 ++ 2 files changed, 36 insertions(+) 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;