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
This commit is contained in:
parent
802cf04d06
commit
85cafac6af
@ -1758,6 +1758,57 @@ packet_duration_kate (GstOggStream * pad, ogg_packet * packet)
|
|||||||
return duration;
|
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-OFF* */
|
||||||
/* indent hates our freedoms */
|
/* indent hates our freedoms */
|
||||||
@ -1903,7 +1954,7 @@ const GstOggMap mappers[] = {
|
|||||||
is_header_count,
|
is_header_count,
|
||||||
packet_duration_kate,
|
packet_duration_kate,
|
||||||
NULL,
|
NULL,
|
||||||
NULL
|
extract_tags_kate
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"BBCD\0", 5, 13,
|
"BBCD\0", 5, 13,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user