riff: extract track number and album artist tags from INFO chunks

https://bugzilla.gnome.org/show_bug.cgi?id=670286
This commit is contained in:
Tim-Philipp Müller 2012-03-09 20:54:00 +00:00
parent 5cb1cd2d54
commit b2d066f49c
2 changed files with 34 additions and 2 deletions

View file

@ -104,6 +104,9 @@ G_BEGIN_DECLS
#define GST_RIFF_INFO_ISRF GST_MAKE_FOURCC ('I','S','R','F') /* source form */
#define GST_RIFF_INFO_ITCH GST_MAKE_FOURCC ('I','T','C','H') /* technician(s) */
#define GST_RIFF_INFO_IAAR GST_MAKE_FOURCC ('I','A','A','R') /* album artist */
#define GST_RIFF_INFO_ITRK GST_MAKE_FOURCC ('I','T','R','K') /* track number */
/*********Chunk Names***************/
#define GST_RIFF_FF00 GST_MAKE_FOURCC (0xFF,0xFF,0x00,0x00)
#define GST_RIFF_00 GST_MAKE_FOURCC ('0', '0',0x00,0x00)

View file

@ -620,6 +620,9 @@ gst_riff_parse_info (GstElement * element,
while (size > 8) {
tag = GST_READ_UINT32_LE (data);
tsize = GST_READ_UINT32_LE (data + 4);
GST_MEMDUMP_OBJECT (element, "tag chunk", data, MIN (tsize + 8, size));
size -= 8;
data += 8;
@ -640,6 +643,9 @@ gst_riff_parse_info (GstElement * element,
case GST_RIFF_INFO_IARL:
type = GST_TAG_LOCATION;
break;
case GST_RIFF_INFO_IAAR:
type = GST_TAG_ALBUM_ARTIST;
break;
case GST_RIFF_INFO_IART:
type = GST_TAG_ARTIST;
break;
@ -706,6 +712,9 @@ gst_riff_parse_info (GstElement * element,
case GST_RIFF_INFO_ITCH:
type = NULL; /*"Technician"; */
break;
case GST_RIFF_INFO_ITRK:
type = GST_TAG_TRACK_NUMBER;
break;
default:
type = NULL;
GST_WARNING_OBJECT (element,
@ -718,12 +727,31 @@ gst_riff_parse_info (GstElement * element,
static const gchar *env_vars[] = { "GST_AVI_TAG_ENCODING",
"GST_RIFF_TAG_ENCODING", "GST_TAG_ENCODING", NULL
};
GType tag_type;
gchar *val;
GST_DEBUG_OBJECT (element, "mapped tag %" GST_FOURCC_FORMAT " to tag %s",
GST_FOURCC_ARGS (tag), type);
tag_type = gst_tag_get_type (type);
val = gst_tag_freeform_string_to_utf8 ((gchar *) data, tsize, env_vars);
if (val) {
gst_tag_list_add (taglist, GST_TAG_MERGE_APPEND, type, val, NULL);
if (val != NULL) {
if (tag_type == G_TYPE_STRING) {
gst_tag_list_add (taglist, GST_TAG_MERGE_APPEND, type, val, NULL);
} else {
GValue tag_val = { 0, };
g_value_init (&tag_val, tag_type);
if (gst_value_deserialize (&tag_val, val)) {
gst_tag_list_add_value (taglist, GST_TAG_MERGE_APPEND, type,
&tag_val);
} else {
GST_WARNING_OBJECT (element, "could not deserialize '%s' into a "
"tag %s of type %s", val, type, g_type_name (tag_type));
}
g_value_unset (&tag_val);
}
g_free (val);
} else {
GST_WARNING_OBJECT (element, "could not extract %s tag", type);
@ -741,6 +769,7 @@ gst_riff_parse_info (GstElement * element,
}
if (!gst_tag_list_is_empty (taglist)) {
GST_INFO_OBJECT (element, "extracted tags: %" GST_PTR_FORMAT, taglist);
*_taglist = taglist;
} else {
*_taglist = NULL;