From 7762b252a32b677673b8026c39ec2e7edd4066f7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim-Philipp=20M=C3=BCller?= Date: Sun, 12 Mar 2006 13:47:22 +0000 Subject: [PATCH] Add new API to libgsttag: gst_tag_from_id3_user_tag(). Original commit message from CVS: * docs/libs/gst-plugins-base-libs-sections.txt: * gst-libs/gst/tag/gstid3tag.c: (gst_tag_from_id3_user_tag): * gst-libs/gst/tag/tag.h: Add new API to libgsttag: gst_tag_from_id3_user_tag(). --- ChangeLog | 7 +++ docs/libs/gst-plugins-base-libs-sections.txt | 1 + gst-libs/gst/tag/gstid3tag.c | 92 +++++++++++++++++++++------- gst-libs/gst/tag/tag.h | 2 + 4 files changed, 80 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index f51c226..2a42cc3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-03-12 Tim-Philipp Müller + + * docs/libs/gst-plugins-base-libs-sections.txt: + * gst-libs/gst/tag/gstid3tag.c: (gst_tag_from_id3_user_tag): + * gst-libs/gst/tag/tag.h: + Add new API to libgsttag: gst_tag_from_id3_user_tag(). + 2006-03-11 Tim-Philipp Müller * gst/typefind/gsttypefindfunctions.c: (plugin_init): diff --git a/docs/libs/gst-plugins-base-libs-sections.txt b/docs/libs/gst-plugins-base-libs-sections.txt index e3f7c5e..672162a 100644 --- a/docs/libs/gst-plugins-base-libs-sections.txt +++ b/docs/libs/gst-plugins-base-libs-sections.txt @@ -151,6 +151,7 @@ gst_tag_id3_genre_count gst_tag_id3_genre_get gst_tag_list_new_from_id3v1 gst_tag_from_id3_tag +gst_tag_from_id3_user_tag gst_tag_to_id3_tag diff --git a/gst-libs/gst/tag/gstid3tag.c b/gst-libs/gst/tag/gstid3tag.c index 0ca25b4..966ede2 100644 --- a/gst-libs/gst/tag/gstid3tag.c +++ b/gst-libs/gst/tag/gstid3tag.c @@ -208,13 +208,13 @@ static GstTagEntryMatch tag_matches[] = { }; /** -* gst_tag_from_id3_tag: -* @id3_tag: ID3v2 tag to convert to GStreamer tag -* -* Looks up the GStreamer tag for a ID3v2 tag. -* -* Returns: The corresponding GStreamer tag or NULL if none exists. -*/ + * gst_tag_from_id3_tag: + * @id3_tag: ID3v2 tag to convert to GStreamer tag + * + * Looks up the GStreamer tag for a ID3v2 tag. + * + * Returns: The corresponding GStreamer tag or NULL if none exists. + */ G_CONST_RETURN gchar * gst_tag_from_id3_tag (const gchar * id3_tag) { @@ -235,14 +235,62 @@ gst_tag_from_id3_tag (const gchar * id3_tag) return NULL; } +static GstTagEntryMatch user_tag_matches[] = { + /* musicbrainz identifiers being used in the real world (foobar2000) */ + {GST_TAG_MUSICBRAINZ_ARTISTID, "TXXX|musicbrainz_artistid"}, + {GST_TAG_MUSICBRAINZ_ALBUMID, "TXXX|musicbrainz_albumid"}, + {GST_TAG_MUSICBRAINZ_ALBUMARTISTID, "TXXX|musicbrainz_albumartistid"}, + {GST_TAG_MUSICBRAINZ_TRMID, "TXXX|musicbrainz_trmid"}, + /* musicbrainz identifiers according to spec no one pays + * attention to (http://musicbrainz.org/docs/specs/metadata_tags.html) */ + {GST_TAG_MUSICBRAINZ_ARTISTID, "TXXX|MusicBrainz Artist Id"}, + {GST_TAG_MUSICBRAINZ_ALBUMID, "TXXX|MusicBrainz Album Id"}, + {GST_TAG_MUSICBRAINZ_ALBUMARTISTID, "TXXX|MusicBrainz Album Artist Id"}, + {GST_TAG_MUSICBRAINZ_TRMID, "TXXX|MusicBrainz TRM Id"}, + {NULL, NULL} +}; + +/** + * gst_tag_from_id3_user_tag: + * @type: the type of ID3v2 user tag (e.g. "TXXX" or "UDIF") + * @id3_user_tag: ID3v2 user tag to convert to GStreamer tag + * + * Looks up the GStreamer tag for an ID3v2 user tag (e.g. description in + * TXXX frame or owner in UFID frame). + * + * Returns: The corresponding GStreamer tag or NULL if none exists. + */ +G_CONST_RETURN gchar * +gst_tag_from_id3_user_tag (const gchar * type, const gchar * id3_user_tag) +{ + int i = 0; + + g_return_val_if_fail (type != NULL && strlen (type) == 4, NULL); + g_return_val_if_fail (id3_user_tag != NULL, NULL); + + for (i = 0; i < G_N_ELEMENTS (user_tag_matches); ++i) { + if (strncmp (type, user_tag_matches[i].original_tag, 4) == 0 && + strcmp (id3_user_tag, user_tag_matches[i].original_tag + 5) == 0) { + GST_LOG ("Mapped ID3v2 user tag '%s' to GStreamer tag '%s'", + user_tag_matches[i].original_tag, user_tag_matches[i].gstreamer_tag); + return user_tag_matches[i].gstreamer_tag; + } + } + + GST_INFO ("Cannot map ID3v2 user tag '%s' of type '%s' to GStreamer tag", + id3_user_tag, type); + + return NULL; +} + /** -* gst_tag_to_id3_tag: -* @gst_tag: GStreamer tag to convert to vorbiscomment tag -* -* Looks up the ID3v2 tag for a GStreamer tag. -* -* Returns: The corresponding ID3v2 tag or NULL if none exists. -*/ + * gst_tag_to_id3_tag: + * @gst_tag: GStreamer tag to convert to vorbiscomment tag + * + * Looks up the ID3v2 tag for a GStreamer tag. + * + * Returns: The corresponding ID3v2 tag or NULL if none exists. + */ G_CONST_RETURN gchar * gst_tag_to_id3_tag (const gchar * gst_tag) { @@ -330,14 +378,14 @@ beach: } /** -* gst_tag_list_new_from_id3v1: -* @data: 128 bytes of data containing the ID3v1 tag -* -* Parses the data containing an ID3v1 tag and returns a #GstTagList from the -* parsed data. -* -* Returns: A new tag list or NULL if the data was not an ID3v1 tag. -*/ + * gst_tag_list_new_from_id3v1: + * @data: 128 bytes of data containing the ID3v1 tag + * + * Parses the data containing an ID3v1 tag and returns a #GstTagList from the + * parsed data. + * + * Returns: A new tag list or NULL if the data was not an ID3v1 tag. + */ GstTagList * gst_tag_list_new_from_id3v1 (const guint8 * data) { diff --git a/gst-libs/gst/tag/tag.h b/gst-libs/gst/tag/tag.h index 91328c8..a0cb63e 100644 --- a/gst-libs/gst/tag/tag.h +++ b/gst-libs/gst/tag/tag.h @@ -112,6 +112,8 @@ G_CONST_RETURN gchar * gst_tag_id3_genre_get (const guint GstTagList * gst_tag_list_new_from_id3v1 (const guint8 * data); G_CONST_RETURN gchar * gst_tag_from_id3_tag (const gchar * id3_tag); +G_CONST_RETURN gchar * gst_tag_from_id3_user_tag (const gchar * type, + const gchar * id3_user_tag); G_CONST_RETURN gchar * gst_tag_to_id3_tag (const gchar * gst_tag); void gst_tag_register_musicbrainz_tags (void); -- 2.7.4