|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
ID3v2 PRIV frameHello
I am new on this mailing list. I made a PRIV frame class for ID3v2 tag and maybe you can integrate it in the official taglib. (see my attachement) An other comment on taglib. It's said in the online documentation that : "Reimplementing this factory is the key to adding support for frame types not directly supported by TagLib to your application" (FrameFactory) but the createFrame() method isn't virtual so subclass FrameFactory can't can't be effective. Furthermore a FrameFactory's subclass can't access ID3v2 frame header, so it's very difficult to add an unsupported frame. Maxime /* * File: privateframe.cpp * Author: max * * Created on 5 septembre 2009, 21:49 */ /*************************************************************************** * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License version * * 2.1 as published by the Free Software Foundation. * * * * This library is distributed in the hope that it will be useful, but * * WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * * USA * * * * Alternatively, this file is available under the Mozilla Public * * License Version 1.1. You may obtain a copy of the License at * * http://www.mozilla.org/MPL/ * ***************************************************************************/ #include <tdebug> #include "privateframe.h" using namespace TagLib; using namespace ID3v2; class PrivateFrame::PrivateFramePrivate { public: PrivateFramePrivate() { } String ownerIdentifier; ByteVector privateData; }; //////////////////////////////////////////////////////////////////////////////// // public members //////////////////////////////////////////////////////////////////////////////// PrivateFrame::PrivateFrame() : Frame("PRIV") { d = new PrivateFramePrivate; } PrivateFrame::PrivateFrame(const ByteVector &data) : Frame(data) { d = new PrivateFramePrivate; setPrivateData(data); } PrivateFrame::~PrivateFrame() { delete d; } String PrivateFrame::toString() const { return d->ownerIdentifier; } String PrivateFrame::ownerIdentifier() const { return d->ownerIdentifier; } void PrivateFrame::setOwnerIdentifier(const String& own) { d->ownerIdentifier = own; } ByteVector PrivateFrame::privateData() const { return d->privateData; } void PrivateFrame::setPrivateData(const ByteVector &data) { d->privateData = data; } //////////////////////////////////////////////////////////////////////////////// // protected members //////////////////////////////////////////////////////////////////////////////// void PrivateFrame::parseFields(const ByteVector &data) { if (data.size() < 4) { debug("An private data frame must contain at least 4 bytes."); return; } int pos = 0; d->ownerIdentifier = readStringField(data, String::Latin1, &pos); d->privateData = data.mid(pos); } ByteVector PrivateFrame::renderFields() const { ByteVector data; data.append(d->ownerIdentifier.data(String::Latin1)); data.append(textDelimiter(String::Latin1)); data.append(d->privateData); return data; } //////////////////////////////////////////////////////////////////////////////// // private members //////////////////////////////////////////////////////////////////////////////// PrivateFrame::PrivateFrame(const ByteVector &data, Header *h) : Frame(h) { d = new PrivateFramePrivate; parseFields(fieldData(data)); } /* * File: privateframe.h * Author: max * * Created on 5 septembre 2009, 21:49 */ /*************************************************************************** * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License version * * 2.1 as published by the Free Software Foundation. * * * * This library is distributed in the hope that it will be useful, but * * WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * * USA * * * * Alternatively, this file is available under the Mozilla Public * * License Version 1.1. You may obtain a copy of the License at * * http://www.mozilla.org/MPL/ * ***************************************************************************/ #ifndef _PRIVATEFRAME_H #define _PRIVATEFRAME_H #include <taglib/id3v2frame.h> #include <taglib/id3v2header.h> #include <taglib/taglib_export.h> namespace TagLib { namespace ID3v2 { //! An ID3v2 private frame implementation /*! * This is an implementation of ID3v2 Private frame. * Arbitrary binary data may be included in tags, stored in PRIV frames. * There may be multiple PRIV frames in a single tag. Each PRIV it * labelled with a owner identifier. The owner identifier * uniquely identifies the PRIV frame in the tag. */ class TAGLIB_EXPORT PrivateFrame : public Frame { friend class FrameFactory; public: /*! * Constructs an empty private frame. The owner identifier and text * encoding should be set manually. */ PrivateFrame(); /*! * Constructs a PrivateFrame frame based on \a data. */ explicit PrivateFrame(const ByteVector &data); //explicit PrivateFrame(const Frame* frame); /*! * Destroys the PrivateFrame instance. */ virtual ~PrivateFrame(); /*! * Returns a string containing the owner identifier. */ virtual String toString() const; /*! * Returns the owner identifier of the object. * * \see setOwnerIdentifier() */ String ownerIdentifier() const; /*! * Sets the owner identifier of the object to \a desc. * * \see ownerIdentifier() */ void setOwnerIdentifier(const String &own); /*! * Returns the private data as a ByteVector. * * \note ByteVector has a data() method that returns a const char * which * should make it easy to export this data to external programs. * * \see setPrivateData() */ ByteVector privateData() const; /*! * Sets the private data to \a data. * * \see PrivateData() */ void setPrivateData(const ByteVector &object); protected: virtual void parseFields(const ByteVector &data); virtual ByteVector renderFields() const; private: PrivateFrame(const ByteVector &data, Header *h); PrivateFrame(const PrivateFrame &); PrivateFrame & operator=(const PrivateFrame &); class PrivateFramePrivate; PrivateFramePrivate *d; }; } } #endif /* _PRIVATEFRAME_H */ _______________________________________________ taglib-devel mailing list taglib-devel@... https://mail.kde.org/mailman/listinfo/taglib-devel |
|
|
Re: ID3v2 PRIV frameHi Maxime,
On Mon, Sep 7, 2009 at 10:32 PM, Maxime de Roucy<maxime.deroucy@...> wrote: > I made a PRIV frame class for ID3v2 tag and maybe you can integrate it > in the official taglib. > (see my attachement) PRIV frames are already supported in SVN trunk and soon-to-be-released TagLib 1.6 (http://marc.info/?l=taglib-devel&m=125200930026215&w=2). > An other comment on taglib. It's said in the online documentation that : > "Reimplementing this factory is the key to adding support for frame > types not directly supported by TagLib to your > application" (FrameFactory) > but the createFrame() method isn't virtual so subclass FrameFactory > can't can't be effective. > Furthermore a FrameFactory's subclass can't access ID3v2 frame header, > so it's very difficult to add an unsupported frame. I think it is a known problem, but can't be fixed due to binary incompatibility. The 1.6 release is last in 1.x series, the next release will be 2.0 which can break compatibility. It can be fixed there. -- Lukas Lalinsky lalinsky@... _______________________________________________ taglib-devel mailing list taglib-devel@... https://mail.kde.org/mailman/listinfo/taglib-devel |
| Free embeddable forum powered by Nabble | Forum Help |