mpegts: Add network name descriptor construction
authorJesper Larsen <jesper.larsen@ixonos.com>
Mon, 28 Oct 2013 13:49:08 +0000 (14:49 +0100)
committerJesper Larsen <jesper.larsen@ixonos.com>
Thu, 6 Feb 2014 14:30:48 +0000 (15:30 +0100)
Add function to create a Network Name DVB descriptor.

gst-libs/gst/mpegts/gst-dvb-descriptor.c
gst-libs/gst/mpegts/gst-dvb-descriptor.h

index 466589bdc6fe601a7bf2ab5f0625a6d0eaf45af2..8a22c891a872c3f03e4bdfba3024da5b464fa9a4 100644 (file)
@@ -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:
index f04b162416feca11a49af7f8e74504995538d769..957dd10aeac991f97871ad56e86e98dcc6209241 100644 (file)
@@ -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;