Commit 85cafac6 authored by Vincent Penquerc'h's avatar Vincent Penquerc'h Committed by Tim-Philipp Müller

oggstream: implement tag extraction for Kate streams

This will mainly allow Totem to know the language of those streams,
so the subtitle selection menu gets properly filled out.

https://bugzilla.gnome.org/show_bug.cgi?id=638005
parent 802cf04d
......@@ -1758,6 +1758,57 @@ packet_duration_kate (GstOggStream * pad, ogg_packet * packet)
return duration;
}
static void
extract_tags_kate (GstOggStream * pad, ogg_packet * packet)
{
GstTagList *list = NULL;
if (packet->bytes <= 0)
return;
switch (packet->packet[0]) {
case 0x80:{
const gchar *canonical;
char language[16];
if (packet->bytes < 64) {
GST_WARNING ("Kate ID header packet is less than 64 bytes, ignored");
break;
}
/* the language tag is 16 bytes at offset 32, ensure NUL terminator */
memcpy (language, packet->packet + 32, 16);
language[15] = 0;
/* language is an ISO 639-1 code or RFC 3066 language code, we
* truncate to ISO 639-1 */
g_strdelimit (language, NULL, '\0');
canonical = gst_tag_get_language_code_iso_639_1 (language);
if (canonical) {
list = gst_tag_list_new_full (GST_TAG_LANGUAGE_CODE, canonical, NULL);
} else {
GST_WARNING ("Unknown or invalid language code %s, ignored", language);
}
break;
}
case 0x81:
tag_list_from_vorbiscomment_packet (packet,
(const guint8 *) "\201kate\0\0\0\0", 9, &list);
break;
default:
break;
}
if (list) {
if (pad->taglist) {
/* ensure the comment packet cannot override the category/language
from the identification header */
gst_tag_list_insert (pad->taglist, list, GST_TAG_MERGE_KEEP_ALL);
} else
pad->taglist = list;
}
}
/* *INDENT-OFF* */
/* indent hates our freedoms */
......@@ -1903,7 +1954,7 @@ const GstOggMap mappers[] = {
is_header_count,
packet_duration_kate,
NULL,
NULL
extract_tags_kate
},
{
"BBCD\0", 5, 13,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment