mpegts: Add support for extended event desriptor

https://bugzilla.gnome.org/show_bug.cgi?id=724034
This commit is contained in:
Stefan Ringel 2014-02-16 10:43:52 +01:00 committed by Sebastian Dröge
parent e6cb996cea
commit 347ac5fbd7
2 changed files with 70 additions and 2 deletions

View file

@ -46,7 +46,6 @@
* * GST_MTS_DESC_DVB_DATA_BROADCAST
* * GST_MTS_DESC_DVB_CAROUSEL_IDENTIFIER
* * GST_MTS_DESC_DVB_STREAM_IDENTIFIER
* * GST_MTS_DESC_DVB_EXTENDED_EVENT
* * GST_MTS_DESC_DVB_COMPONENT
* * GST_MTS_DESC_DVB_FREQUENCY_LIST
*/
@ -483,6 +482,72 @@ gst_mpegts_descriptor_from_dvb_subtitling (const gchar * lang,
return descriptor;
}
/* GST_MTS_DESC_DVB_EXTENDED_EVENT (0x4E) */
/**
* gst_mpegts_descriptor_parse_dvb_extended_event:
* @descriptor: a %GST_MTS_DESC_DVB_EXTENDED_EVENT #GstMpegTsDescriptor
* @res: (out) (transfer none): the #GstMpegTsExtendedEventDescriptor to fill
*
* Extracts the DVB extended event information from @descriptor.
*
* Returns: %TRUE if parsing succeeded, else %FALSE.
*/
gboolean
gst_mpegts_descriptor_parse_dvb_extended_event (const GstMpegTsDescriptor
* descriptor, GstMpegTsExtendedEventDescriptor * res)
{
guint8 *data, *desc_data;
guint8 tmp, len_item;
GstMpegTsExtendedEventItem *item;
g_return_val_if_fail (descriptor != NULL && descriptor->data != NULL, FALSE);
g_return_val_if_fail (res != NULL, FALSE);
g_return_val_if_fail (descriptor->tag == GST_MTS_DESC_DVB_EXTENDED_EVENT,
FALSE);
data = (guint8 *) descriptor->data + 2;
tmp = *data;
res->descriptor_number = tmp >> 4;
res->last_descriptor_number = tmp & 0x0f;
data += 1;
memcpy (data, res->language_code, 3);
data += 3;
len_item = *data;
data += 1;
res->nb_items = 0;
res->items = g_ptr_array_new ();
for (guint i = 0; i < len_item;) {
desc_data = data;
item = malloc (sizeof (GstMpegTsExtendedEventItem));
item->item_description =
get_encoding_and_convert ((const gchar *) desc_data + 1, *desc_data);
desc_data += *desc_data + 1;
i += *desc_data + 1;
item->item =
get_encoding_and_convert ((const gchar *) desc_data + 1, *desc_data);
desc_data += *desc_data + 1;
i += *desc_data + 1;
g_ptr_array_add (res->items, item);
res->nb_items += 1;
}
data += len_item;
res->text = get_encoding_and_convert ((const gchar *) data + 1, *data);
return TRUE;
}
/* GST_MTS_DESC_DVB_TERRESTRIAL_DELIVERY_SYSTEM (0x5A) */
/**
* gst_mpegts_descriptor_parse_dvb_terrestrial_delivary_system:

View file

@ -307,13 +307,16 @@ struct _GstMpegTsExtendedEventItem
gchar *item;
};
/**
* @items: (element-type GstMpegTsExtendedEventItem):
*/
struct _GstMpegTsExtendedEventDescriptor
{
guint8 descriptor_number;
guint8 last_descriptor_number;
gchar language_code[3];
guint8 nb_items;
GstMpegTsExtendedEventItem items[128];
GPtrArray *items;
gchar *text;
};