mpegts: Add ISO 639 parsing functions

https://bugzilla.gnome.org/show_bug.cgi?id=709180
This commit is contained in:
Jesper Larsen 2013-10-05 14:45:31 +02:00 committed by Edward Hervey
parent f489ae5d55
commit 7cb434e42f
2 changed files with 59 additions and 3 deletions

View file

@ -634,6 +634,61 @@ gst_mpegts_descriptor_parse_iso_639_language (const GstMpegTsDescriptor *
}
/**
* gst_mpegts_descriptor_parse_iso_639_language_idx:
* @descriptor: a %GST_MTS_DESC_ISO_639_LANGUAGE #GstMpegTsDescriptor
* @idx: Table id of the language to parse
* @lang (out) (transfer none): 4-byte gchar array to hold the language code
* @audio_type: (out) (transfer none): the #GstMpegTsIso639AudioType to set
*
* Extracts the iso 639-2 language information from specific table id in @descriptor.
*
* Note: Use #gst_tag_get_language_code if you want to get the the
* ISO 639-1 language code from the returned ISO 639-2 one.
*
* Returns: %TRUE if parsing succeeded, else %FALSE.
*/
gboolean
gst_mpegts_descriptor_parse_iso_639_language_idx (const GstMpegTsDescriptor *
descriptor, guint idx, gchar (*lang)[4],
GstMpegTsIso639AudioType * audio_type)
{
guint8 *data;
g_return_val_if_fail (descriptor != NULL && descriptor->data != NULL, FALSE);
g_return_val_if_fail (lang != NULL, FALSE);
g_return_val_if_fail (descriptor->tag == GST_MTS_DESC_ISO_639_LANGUAGE,
FALSE);
g_return_val_if_fail (audio_type != NULL, FALSE);
g_return_val_if_fail (descriptor->length / 4 > idx, FALSE);
data = (guint8 *) descriptor->data + 2 + idx * 4;
memcpy (lang, data, 3);
*lang[3] = 0;
data += 3;
*audio_type = *data;
return TRUE;
}
/**
* gst_mpegts_descriptor_parse_iso_639_language_nb:
* @descriptor: a %GST_MTS_DESC_ISO_639_LANGUAGE #GstMpegTsDescriptor
*
* Returns: The number of languages in @descriptor
*/
guint
gst_mpegts_descriptor_parse_iso_639_language_nb (const GstMpegTsDescriptor *
descriptor)
{
g_return_val_if_fail (descriptor != NULL && descriptor->data != NULL, 0);
return descriptor->length / 4;
}
/**
* gst_mpegts_descriptor_parse_logical_channel:
* @descriptor: a %GST_MTS_DESC_DTG_LOGICAL_CHANNEL #GstMpegTsDescriptor

View file

@ -275,9 +275,6 @@ typedef enum {
GST_MPEGTS_AUDIO_TYPE_VISUAL_IMPAIRED_COMMENTARY
} GstMpegTsIso639AudioType;
/* FIXME: Make two methods. One for getting the number of languages,
* and the other for getting the (allocated, null-terminated) language
* and audio type */
typedef struct _GstMpegTsISO639LanguageDescriptor GstMpegTsISO639LanguageDescriptor;
struct _GstMpegTsISO639LanguageDescriptor
{
@ -288,6 +285,10 @@ struct _GstMpegTsISO639LanguageDescriptor
gboolean gst_mpegts_descriptor_parse_iso_639_language (const GstMpegTsDescriptor *descriptor,
GstMpegTsISO639LanguageDescriptor *res);
gboolean gst_mpegts_descriptor_parse_iso_639_language_idx (const GstMpegTsDescriptor *descriptor,
guint idx, gchar (*lang)[4],
GstMpegTsIso639AudioType *audio_type);
guint gst_mpegts_descriptor_parse_iso_639_language_nb (const GstMpegTsDescriptor *descriptor);