From 45310d0cf6731bad36956510e5c54faab691a877 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 24 Sep 2014 23:29:10 +0200 Subject: decoder/mp4v2: add tag table --- src/decoder/plugins/Mp4v2DecoderPlugin.cxx | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'src/decoder/plugins') diff --git a/src/decoder/plugins/Mp4v2DecoderPlugin.cxx b/src/decoder/plugins/Mp4v2DecoderPlugin.cxx index d4f7c5843..bf97763c5 100644 --- a/src/decoder/plugins/Mp4v2DecoderPlugin.cxx +++ b/src/decoder/plugins/Mp4v2DecoderPlugin.cxx @@ -265,16 +265,25 @@ mp4_scan_file(Path path_fs, const MP4Tags* tags = MP4TagsAlloc(); MP4TagsFetch(tags, handle); - mp4_safe_invoke_tag(handler, handler_ctx, TAG_NAME, tags->name); - mp4_safe_invoke_tag(handler, handler_ctx, TAG_ARTIST, tags->artist); - mp4_safe_invoke_tag(handler, handler_ctx, TAG_ALBUM_ARTIST, tags->albumArtist); - mp4_safe_invoke_tag(handler, handler_ctx, TAG_ALBUM, tags->album); - mp4_safe_invoke_tag(handler, handler_ctx, TAG_COMPOSER, tags->composer); - mp4_safe_invoke_tag(handler, handler_ctx, TAG_COMMENT, tags->comments); - mp4_safe_invoke_tag(handler, handler_ctx, TAG_GENRE, tags->genre); - mp4_safe_invoke_tag(handler, handler_ctx, TAG_DATE, tags->releaseDate); - mp4_safe_invoke_tag(handler, handler_ctx, TAG_ARTIST_SORT, tags->sortArtist); - mp4_safe_invoke_tag(handler, handler_ctx, TAG_ALBUM_ARTIST_SORT, tags->sortAlbumArtist); + static constexpr struct { + const char *MP4Tags::*p; + TagType tag_type; + } mp4v2_tags[] = { + { &MP4Tags::name, TAG_NAME }, + { &MP4Tags::artist, TAG_ARTIST }, + { &MP4Tags::albumArtist, TAG_ALBUM_ARTIST }, + { &MP4Tags::album, TAG_ALBUM }, + { &MP4Tags::composer, TAG_COMPOSER }, + { &MP4Tags::comments, TAG_COMMENT }, + { &MP4Tags::genre, TAG_GENRE }, + { &MP4Tags::releaseDate, TAG_DATE }, + { &MP4Tags::sortArtist, TAG_ARTIST_SORT }, + { &MP4Tags::sortAlbumArtist, TAG_ALBUM_ARTIST_SORT }, + }; + + for (const auto &i : mp4v2_tags) + mp4_safe_invoke_tag(handler, handler_ctx, + i.tag_type, tags->*i.p); char buff[8]; /* tmp buffer for index to string. */ if (tags->track != nullptr) { -- cgit v1.2.3