A factory for creating MP4 items during parsing. More...
#include <mp4itemfactory.h>
Public Member Functions | |
ItemFactory (const ItemFactory &)=delete | |
ItemFactory & | operator= (const ItemFactory &)=delete |
virtual std::pair< String, Item > | parseItem (const Atom *atom, const ByteVector &data) const |
virtual ByteVector | renderItem (const String &itemName, const Item &item) const |
virtual std::pair< ByteVector, Item > | itemFromProperty (const String &key, const StringList &values) const |
virtual std::pair< String, StringList > | itemToProperty (const ByteVector &itemName, const Item &item) const |
virtual String | propertyKeyForName (const ByteVector &name) const |
virtual ByteVector | nameForPropertyKey (const String &key) const |
Static Public Member Functions | |
static ItemFactory * | instance () |
Protected Types | |
enum class | ItemHandlerType { Unknown , FreeForm , IntPair , IntPairNoTrailing , Bool , Int , TextOrInt , UInt , LongLong , Byte , Gnre , Covr , TextImplicit , Text } |
using | NameHandlerMap = Map< ByteVector, ItemHandlerType > |
Protected Member Functions | |
ItemFactory () | |
~ItemFactory () | |
virtual NameHandlerMap | nameHandlerMap () const |
virtual ItemHandlerType | handlerTypeForName (const ByteVector &name) const |
virtual Map< ByteVector, String > | namePropertyMap () const |
Static Protected Member Functions | |
static MP4::AtomDataList | parseData2 (const MP4::Atom *atom, const ByteVector &data, int expectedFlags=-1, bool freeForm=false) |
static ByteVectorList | parseData (const MP4::Atom *atom, const ByteVector &bytes, int expectedFlags=-1, bool freeForm=false) |
static std::pair< String, Item > | parseText (const MP4::Atom *atom, const ByteVector &bytes, int expectedFlags=1) |
static std::pair< String, Item > | parseFreeForm (const MP4::Atom *atom, const ByteVector &bytes) |
static std::pair< String, Item > | parseInt (const MP4::Atom *atom, const ByteVector &bytes) |
static std::pair< String, Item > | parseByte (const MP4::Atom *atom, const ByteVector &bytes) |
static std::pair< String, Item > | parseTextOrInt (const MP4::Atom *atom, const ByteVector &bytes) |
static std::pair< String, Item > | parseUInt (const MP4::Atom *atom, const ByteVector &bytes) |
static std::pair< String, Item > | parseLongLong (const MP4::Atom *atom, const ByteVector &bytes) |
static std::pair< String, Item > | parseGnre (const MP4::Atom *atom, const ByteVector &bytes) |
static std::pair< String, Item > | parseIntPair (const MP4::Atom *atom, const ByteVector &bytes) |
static std::pair< String, Item > | parseBool (const MP4::Atom *atom, const ByteVector &bytes) |
static std::pair< String, Item > | parseCovr (const MP4::Atom *atom, const ByteVector &data) |
static ByteVector | renderAtom (const ByteVector &name, const ByteVector &data) |
static ByteVector | renderData (const ByteVector &name, int flags, const ByteVectorList &data) |
static ByteVector | renderText (const ByteVector &name, const MP4::Item &item, int flags=TypeUTF8) |
static ByteVector | renderFreeForm (const String &name, const MP4::Item &item) |
static ByteVector | renderBool (const ByteVector &name, const MP4::Item &item) |
static ByteVector | renderInt (const ByteVector &name, const MP4::Item &item) |
static ByteVector | renderTextOrInt (const ByteVector &name, const MP4::Item &item) |
static ByteVector | renderByte (const ByteVector &name, const MP4::Item &item) |
static ByteVector | renderUInt (const ByteVector &name, const MP4::Item &item) |
static ByteVector | renderLongLong (const ByteVector &name, const MP4::Item &item) |
static ByteVector | renderIntPair (const ByteVector &name, const MP4::Item &item) |
static ByteVector | renderIntPairNoTrailing (const ByteVector &name, const MP4::Item &item) |
static ByteVector | renderCovr (const ByteVector &name, const MP4::Item &item) |
A factory for creating MP4 items during parsing.
This factory abstracts away the parsing and rendering between atom data and MP4 items.
Reimplementing this factory is the key to adding support for atom types not directly supported by TagLib to your application. To do so you would subclass this factory and reimplement nameHandlerMap() to add support for new atoms. If the new atoms do not have the same behavior as other supported atoms, it may be necessary to reimplement parseItem() and renderItem(). Then by setting your factory in the MP4::Tag constructor you can implement behavior that will allow for new atom types to be used.
A custom item factory adding support for a "tsti" integer atom and a "tstt" text atom can be implemented like this:
If the custom item shall also be accessible via a property, namePropertyMap() can be overridden in the same way.
|
protected |
Mapping of atom name to handler type.
|
strongprotected |
|
delete |
|
protected |
Constructs an item factory. Because this is a singleton this method is protected, but may be used for subclasses.
|
protected |
Destroys the frame factory.
|
protectedvirtual |
Returns handler type for atom name. The default method looks up the map created by nameHandlerMap() and should be enough for most uses.
|
static |
|
virtual |
Create an MP4 item from a property with key and values. If the property is not supported, an invalid item is returned. The default implementation uses the map returned by namePropertyMap().
|
virtual |
Get an MP4 item as a property. If no property exists for itemName, an empty string is returned as the property key. The default implementation uses the map returned by namePropertyMap().
|
virtual |
Returns atom name for property key, empty if no property is supported for this key. The default method uses the reverse mapping of propertyKeyForName() and should be enough for most uses.
|
protectedvirtual |
Returns mapping between atom names and handler types. This method is called once by handlerTypeForName() to initialize its internal cache. To add support for a new atom, it is sufficient in most cases to just reimplement this method and add new entries.
|
protectedvirtual |
Returns mapping between atom names and property keys. This method is called once by propertyKeyForName() to initialize its internal cache. To add support for a new atom with a property, it is sufficient in most cases to just reimplement this method and add new entries.
|
delete |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
virtual |
Create an MP4 item from the data bytes of an atom. Returns the name (in most cases atom->name) and an item, an invalid item on failure. The default implementation uses the map returned by nameHandlerMap().
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
virtual |
Returns property key for atom name, empty if no property exists for this atom. The default method looks up the map created by namePropertyMap() and should be enough for most uses.
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
virtual |
Render an MP4 item to the data bytes of an atom itemName. An empty byte vector is returned if the item is invalid or unknown. The default implementation uses the map returned by nameHandlerMap().
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
staticprotected |