From e4b04ce37b02cb9c257612b52aaf5abb2b1e14fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Cartegnie?= Date: Tue, 24 Sep 2024 15:27:56 +0700 Subject: [PATCH] meta: taglib: simplify processing Ogg pictures --- modules/meta_engine/Makefile.am | 3 +- modules/meta_engine/meson.build | 2 +- modules/meta_engine/taglib.cpp | 59 ++------------------------------- 3 files changed, 5 insertions(+), 59 deletions(-) diff --git a/modules/meta_engine/Makefile.am b/modules/meta_engine/Makefile.am index e188bfae7454..7cf12fdbfe55 100644 --- a/modules/meta_engine/Makefile.am +++ b/modules/meta_engine/Makefile.am @@ -4,8 +4,7 @@ libfolder_plugin_la_SOURCES = meta_engine/folder.c meta_LTLIBRARIES = libfolder_plugin.la libtaglib_plugin_la_SOURCES = meta_engine/taglib.cpp \ - meta_engine/ID3Pictures.h \ - demux/xiph_metadata.h demux/xiph_metadata.c + meta_engine/ID3Pictures.h libtaglib_plugin_la_CXXFLAGS = $(AM_CXXFLAGS) $(TAGLIB_CFLAGS) libtaglib_plugin_la_LDFLAGS = $(AM_LDFLAGS) -rpath '$(metadir)' libtaglib_plugin_la_LIBADD = $(TAGLIB_LIBS) -lz diff --git a/modules/meta_engine/meson.build b/modules/meta_engine/meson.build index a37c02d8e3d5..14b3a4ee4ee7 100644 --- a/modules/meta_engine/meson.build +++ b/modules/meta_engine/meson.build @@ -9,7 +9,7 @@ taglib_dep = dependency('taglib', version: '>= 1.11', required: get_option('tagl if taglib_dep.found() vlc_modules += { 'name' : 'taglib', - 'sources' : files('taglib.cpp', '../demux/xiph_metadata.c'), + 'sources' : files('taglib.cpp'), 'dependencies' : [taglib_dep, z_dep] } endif diff --git a/modules/meta_engine/taglib.cpp b/modules/meta_engine/taglib.cpp index 1769ce771042..ca83d1974b91 100644 --- a/modules/meta_engine/taglib.cpp +++ b/modules/meta_engine/taglib.cpp @@ -36,6 +36,7 @@ #include /* vlc_uri2path */ #include /* mime type */ #include +#include #include #include @@ -77,7 +78,6 @@ #include #include #include -#include "../demux/xiph_metadata.h" #include "ID3Pictures.h" #include @@ -849,61 +849,8 @@ static void ReadMetaFromXiph( Ogg::XiphComment* tag, demux_meta_t* p_demux_meta, } } - // Try now to get embedded art - StringList mime_list { tag->fieldListMap()[ "COVERARTMIME" ] }; - StringList art_list { tag->fieldListMap()[ "COVERART" ] }; - - input_attachment_t *p_attachment; - - if( mime_list.size() != 0 && art_list.size() != 0 ) - { - // We get only the first cover art - if( mime_list.size() > 1 || art_list.size() > 1 ) - msg_Warn( p_demux_meta, "Found %i embedded arts, so using only the first one", - art_list.size() ); - - const char* psz_name = "cover"; - const char* psz_mime = mime_list[0].toCString(true); - const char* psz_description = "cover"; - - uint8_t *p_data; - int i_data = vlc_b64_decode_binary( &p_data, art_list[0].toCString(false) ); - - msg_Dbg( p_demux_meta, "Found embedded art: %s (%s) is %i bytes", - psz_name, psz_mime, i_data ); - - p_attachment = vlc_input_attachment_New( psz_name, psz_mime, - psz_description, p_data, i_data ); - free( p_data ); - } - else - { - StringList block_picture_list { tag->fieldListMap()[ "METADATA_BLOCK_PICTURE" ] }; - if( block_picture_list.size() == 0 ) - return; - - uint8_t *p_data; - int i_cover_score; - int i_cover_idx; - int i_data = vlc_b64_decode_binary( &p_data, block_picture_list[0].toCString(false) ); - i_cover_score = i_cover_idx = 0; - /* TODO: Use i_cover_score / i_cover_idx to select the picture. */ - p_attachment = ParseFlacPicture( p_data, i_data, 0, - &i_cover_score, &i_cover_idx ); - free( p_data ); - } - - if (p_attachment) { - TAB_APPEND_CAST( (input_attachment_t**), - p_demux_meta->i_attachments, p_demux_meta->attachments, - p_attachment ); - - char *psz_url; - if( asprintf( &psz_url, "attachment://%s", p_attachment->psz_name ) != -1 ) { - vlc_meta_SetArtURL( p_meta, psz_url ); - free( psz_url ); - } - } + // Taglib extracts if(key == "METADATA_BLOCK_PICTURE" || key == "COVERART") + ProcessAPICListFromFLAC( tag->pictureList(), p_demux_meta, p_meta ); } /**