mpegts: Support parsing of DVB Teletext descriptor

Descriptor tag is 0x56
This commit is contained in:
Jesper Larsen 2013-11-19 10:50:30 +01:00
parent ffb51c2123
commit cfb4da7215
2 changed files with 89 additions and 0 deletions

View file

@ -319,6 +319,71 @@ gst_mpegts_descriptor_parse_dvb_short_event (const GstMpegTsDescriptor *
return TRUE;
}
/* GST_MTS_DESC_DVB_TELETEXT (0x56) */
/**
* gst_mpegts_descriptor_parse_dvb_teletext_idx:
* @descriptor: a %GST_MTS_DESC_DVB_TELETEXT #GstMpegTsDescriptor
* @idx: The id of the teletext to get
* @language_code: (out) (allow-none): a 4-byte gchar array to hold language
* @teletext_type: (out) (allow-none): #GstMpegTsDVBTeletextType
* @magazine_number: (out) (allow-none):
* @page_number: (out) (allow-none):
*
* Parses teletext number @idx in the @descriptor. The language is in ISO639 format.
*
* Returns: FALSE on out-of-bounds and errors
*/
gboolean
gst_mpegts_descriptor_parse_dvb_teletext_idx (const GstMpegTsDescriptor *
descriptor, guint idx, gchar (*language_code)[4],
GstMpegTsDVBTeletextType * teletext_type, guint8 * magazine_number,
guint8 * page_number)
{
guint8 *data;
g_return_val_if_fail (descriptor != NULL && descriptor->data != NULL, FALSE);
g_return_val_if_fail (descriptor->tag == GST_MTS_DESC_DVB_TELETEXT, FALSE);
if (descriptor->length / 5 <= idx)
return FALSE;
data = (guint8 *) descriptor->data + 2 + idx * 5;
if (language_code) {
memcpy (language_code, data, 3);
(*language_code)[3] = 0;
}
if (teletext_type)
*teletext_type = data[3] >> 3;
if (magazine_number)
*magazine_number = data[3] & 0x07;
if (page_number)
*page_number = data[4];
return TRUE;
}
/**
* gst_mpegts_descriptor_parse_dvb_teletext_nb:
* @descriptor: a %GST_MTS_DESC_DVB_TELETEXT #GstMpegTsDescriptor
*
* Find the number of teletext entries in @descriptor
*
* Returns: Number of teletext entries
*/
guint
gst_mpegts_descriptor_parse_dvb_teletext_nb (const GstMpegTsDescriptor *
descriptor)
{
if (descriptor == NULL && descriptor->data == NULL)
return 0;
return descriptor->length / 5;
}
/* GST_MTS_DESC_DVB_SUBTITLING (0x59) */
/**

View file

@ -339,6 +339,30 @@ gboolean gst_mpegts_descriptor_parse_dvb_component (const GstMpegTsDescriptor *d
gboolean gst_mpegts_descriptor_parse_dvb_stream_identifier (const GstMpegTsDescriptor *descriptor,
guint8 *component_tag);
/* GST_MTS_DESC_DVB_TELETEXT (0x56) */
/**
* GstMpegTsDVBTeletextType:
*
* The type of teletext page.
*
* As specified in Table 100 of ETSI EN 300 468 v1.13.1
*/
typedef enum {
INITIAL_PAGE = 0x01,
SUBTITLE_PAGE,
ADDITIONAL_INFO_PAGE,
PROGRAMME_SCHEDULE_PAGE,
HEARING_IMPAIRED_PAGE
} GstMpegTsDVBTeletextType;
gboolean gst_mpegts_descriptor_parse_dvb_teletext_idx (const GstMpegTsDescriptor *
descriptor, guint idx, gchar (*language_code)[4],
GstMpegTsDVBTeletextType * teletext_type, guint8 * magazine_number,
guint8 * page_number);
guint gst_mpegts_descriptor_parse_dvb_teletext_nb (const GstMpegTsDescriptor *
descriptor);
/* GST_MTS_DESC_DVB_SUBTITLING (0x59) */
gboolean gst_mpegts_descriptor_parse_dvb_subtitling_idx (const GstMpegTsDescriptor *descriptor,
guint idx, gchar (*lang)[4],