[vlc-devel] [PATCH 2/3] Save album art to id3 tag.
Angelo Haller
vlc-devel at szanni.org
Sun Jul 29 18:31:21 CEST 2012
On 07/28/2012 11:11 PM, Rémi Denis-Courmont wrote:
> Le samedi 28 juillet 2012 17:39:35 vlc-devel at szanni.org, vous avez écrit :
>> ---
>> modules/meta_engine/taglib.cpp | 63
>> ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63
>> insertions(+)
> diff --git a/modules/meta_engine/taglib.cpp b/modules/meta_engine/taglib.cpp
> index 148401b..3c20540 100644
> --- a/modules/meta_engine/taglib.cpp
> +++ b/modules/meta_engine/taglib.cpp
> @@ -32,6 +32,8 @@
> #include <vlc_demux.h> /* demux_meta_t */
> #include <vlc_strings.h> /* vlc_b64_decode_binary */
> #include <vlc_input.h> /* for attachment_new */
> +#include <vlc_url.h> /* make_path */
> +#include <vlc_httpd.h> /* mime content-type */
>
> #ifdef WIN32
> # include <vlc_charset.h>
> @@ -40,6 +42,7 @@
> # include <unistd.h>
> #endif
>
> +#include <stdio.h>
>
> // Taglib headers
> #include <taglib.h>
> @@ -709,6 +712,66 @@ static void WriteMetaToId3v2( ID3v2::Tag* tag,
> input_item_t* p_item )
> WRITE( Publisher, "TPUB" );
>
> #undef WRITE
> +
> + //Write album art
> + char *psz_url = input_item_GetArtworkURL( p_item );
> + if( psz_url )
> + {
> + ID3v2::FrameList frames = tag->frameList( "APIC" );
> + ID3v2::AttachedPictureFrame *frame = NULL;
> + if( frames.isEmpty() )
> + {
> + frame = new TagLib::ID3v2::AttachedPictureFrame;
> + tag->addFrame( frame );
> + }
> + else
> + {
> + frame = static_cast<ID3v2::AttachedPictureFrame *>( frames.back()
> );
> + }
> +
> + FILE *p_file = fopen( make_path( psz_url ), "rb" );
>
> You cannot apply make_path() like that. It will return garbage if the URL is
> not that of a "file".
>
> Also, there is a memory leak.
I'll add error checking and fix the leak.
> If you really need to know the size of a file, use fstat() please.
Any rationale for that? Just curious.
More information about the vlc-devel
mailing list