How to Implement Picture frame feature of Id3v2 in TagLIb ?

mahendra Deore mahendradeore at gmail.com
Tue Sep 27 13:49:21 UTC 2011


Hi,

As I gone through the taglib's folder "bindings/c/". In which tag_c.cpp and
tag_c.h having complete implementation to get generic features of all
supported formats.
As Taglib does not implement every feature of ID3v2. But if I want picture
frame feature should be the part of taglib ,instead of extend Taglib to
support this feature in application.


To support  this I have written api inside "bindings/c/tag_c.cpp" file which
gives me picture frame buffer and buffersize. To implement this using ref of
documentation
at Taglib site. But this api is not generic only specific to id3v2 . This
api is independent of other API and works fine for me.

Belwo is the code snippet for api:-
===============================================================
char *taglib_tag_id3v2_albumart(char  *pFile,int *size)
{
        TagLib::ID3v2::FrameList listOfMp3Frames;
        ID3v2::AttachedPictureFrame * pictureFrame;
        TagLib::ID3v2::Tag *mp3tag;
        char *pImgBuffer = NULL;

        if(pFile != NULL)
        {
                TagLib::MPEG::File mp3File(pFile);
                mp3tag = mp3File.ID3v2Tag();

                if(mp3tag)
                {
                        listOfMp3Frames =
mp3tag->frameListMap()["APIC"];//look for picture frames only

                        if(!listOfMp3Frames.isEmpty())
                        {
                                TagLib::ID3v2::FrameList::ConstIterator it=
listOfMp3Frames.begin();
                                pictureFrame =
static_cast<ID3v2::AttachedPictureFrame *> (*it);//cast Frame * to
AttachedPictureFrame*
                                *size = pictureFrame->picture().size();
                                pImgBuffer = (char
*)calloc(pictureFrame->picture().size(),sizeof(char));

memcpy(pImgBuffer,pictureFrame->picture().data(),pictureFrame->picture().size());
                                return pImgBuffer;
                        }
                }
        }
        return NULL;
}
========================================================================================================

Is this is the correct way to do ? Or Need to write generic implementation
for picture-frame feature ?

Note: My application is in C and I could not extend Tag-lib to support this
feature in my app.

Please help me to solved this issue.

Thanks,
Mahendra
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/taglib-devel/attachments/20110927/129a0742/attachment.html>


More information about the taglib-devel mailing list