1
0
mirror of https://github.com/taglib/taglib.git synced 2025-09-08 14:24:17 -04:00

Merge branch 'master' into taglib2

Conflicts:
	taglib/toolkit/tfile.h
This commit is contained in:
Michael Helmling
2012-12-27 11:54:59 +01:00
15 changed files with 60 additions and 58 deletions

@ -131,12 +131,9 @@ void APE::File::removeUnsupportedProperties(const StringList &properties)
PropertyMap APE::File::setProperties(const PropertyMap &properties)
{
if(d->hasAPE)
return d->tag.access<APE::Tag>(ApeAPEIndex, false)->setProperties(properties);
else if(d->hasID3v1)
return d->tag.access<ID3v1::Tag>(ApeID3v1Index, false)->setProperties(properties);
else
return d->tag.access<APE::Tag>(ApeAPEIndex, true)->setProperties(properties);
if(d->hasID3v1)
d->tag.access<ID3v1::Tag>(ApeID3v1Index, false)->setProperties(properties);
return d->tag.access<APE::Tag>(ApeAPEIndex, true)->setProperties(properties);
}
APE::Properties *APE::File::audioProperties() const

@ -128,8 +128,8 @@ namespace TagLib {
/*!
* Implements the unified property interface -- import function.
* As for the export, only one tag is taken into account. If the file
* has no tag at all, APE will be created.
* Creates an APEv2 tag if necessary. A pontentially existing ID3v1
* tag will be updated as well.
*/
PropertyMap setProperties(const PropertyMap &);

@ -163,14 +163,7 @@ void FLAC::File::removeUnsupportedProperties(const StringList &unsupported)
PropertyMap FLAC::File::setProperties(const PropertyMap &properties)
{
if(d->hasXiphComment)
return d->tag.access<Ogg::XiphComment>(FlacXiphIndex, false)->setProperties(properties);
else if(d->hasID3v2)
return d->tag.access<ID3v2::Tag>(FlacID3v2Index, false)->setProperties(properties);
else if(d->hasID3v1)
return d->tag.access<ID3v1::Tag>(FlacID3v1Index, false)->setProperties(properties);
else
return d->tag.access<Ogg::XiphComment>(FlacXiphIndex, true)->setProperties(properties);
return d->tag.access<Ogg::XiphComment>(FlacXiphIndex, true)->setProperties(properties);
}
FLAC::Properties *FLAC::File::audioProperties() const

@ -122,8 +122,10 @@ namespace TagLib {
/*!
* Implements the unified property interface -- import function.
* As with the export, only one tag is taken into account. If the file
* has no tag at all, a XiphComment will be created.
* This always creates a Xiph comment, if none exists. The return value
* relates to the Xiph comment only.
* Ignores any changes to ID3v1 or ID3v2 comments since they are not allowed
* in the FLAC specification.
*/
PropertyMap setProperties(const PropertyMap &);

@ -135,15 +135,11 @@ void MPC::File::removeUnsupportedProperties(const StringList &properties)
PropertyMap MPC::File::setProperties(const PropertyMap &properties)
{
if(d->hasAPE)
return d->tag.access<APE::Tag>(MPCAPEIndex, false)->setProperties(properties);
else if(d->hasID3v1)
return d->tag.access<ID3v1::Tag>(MPCID3v1Index, false)->setProperties(properties);
else
return d->tag.access<APE::Tag>(APE, true)->setProperties(properties);
if(d->hasID3v1)
d->tag.access<APE::Tag>(MPCID3v1Index, false)->setProperties(properties);
return d->tag.access<APE::Tag>(MPCAPEIndex, true)->setProperties(properties);
}
MPC::Properties *MPC::File::audioProperties() const
{
return d->properties;

@ -124,8 +124,8 @@ namespace TagLib {
/*!
* Implements the unified property interface -- import function.
* As with the export, only one tag is taken into account. If the file
* has no tag at all, an APE tag will be created.
* Affects only the APEv2 tag which will be created if necessary.
* If an ID3v1 tag exists, it will be updated as well.
*/
PropertyMap setProperties(const PropertyMap &);

@ -156,16 +156,13 @@ void MPEG::File::removeUnsupportedProperties(const StringList &properties)
else if(d->hasID3v1)
d->tag.access<ID3v1::Tag>(ID3v1Index, false)->removeUnsupportedProperties(properties);
}
PropertyMap MPEG::File::setProperties(const PropertyMap &properties)
{
if(d->hasID3v2)
return d->tag.access<ID3v2::Tag>(ID3v2Index, false)->setProperties(properties);
else if(d->hasAPE)
return d->tag.access<APE::Tag>(APEIndex, false)->setProperties(properties);
else if(d->hasID3v1)
return d->tag.access<ID3v1::Tag>(ID3v1Index, false)->setProperties(properties);
else
return d->tag.access<ID3v2::Tag>(ID3v2Index, true)->setProperties(properties);
if(d->hasID3v1)
// update ID3v1 tag if it exists, but ignore the return value
d->tag.access<ID3v1::Tag>(ID3v1Index, false)->setProperties(properties);
return d->tag.access<ID3v2::Tag>(ID3v2Index, true)->setProperties(properties);
}
MPEG::Properties *MPEG::File::audioProperties() const

@ -133,7 +133,7 @@ namespace TagLib {
virtual Tag *tag() const;
/*!
* Implements the unified property interface -- export function.
* Implements the reading part of the unified property interface.
* If the file contains more than one tag, only the
* first one (in the order ID3v2, APE, ID3v1) will be converted to the
* PropertyMap.
@ -143,9 +143,12 @@ namespace TagLib {
void removeUnsupportedProperties(const StringList &properties);
/*!
* Implements the unified tag dictionary interface -- import function.
* As with the export, only one tag is taken into account. If the file
* has no tag at all, ID3v2 will be created.
* Implements the writing part of the unified tag dictionary interface.
* In order to avoid problems with deprecated tag formats, this method
* always creates an ID3v2 tag if necessary.
* If an ID3v1 tag exists, it will be updated as well, within the
* limitations of that format.
* The returned PropertyMap refers to the ID3v2 tag only.
*/
PropertyMap setProperties(const PropertyMap &);

@ -80,12 +80,14 @@ namespace TagLib {
/*!
* Exports the tags of the file as dictionary mapping (human readable) tag
* names (Strings) to StringLists of tag values. Calls the according specialization
* in the File subclasses.
* names (uppercase Strings) to StringLists of tag values. Calls the according
* specialization in the File subclasses.
* For each metadata object of the file that could not be parsed into the PropertyMap
* format, the returend map's unsupportedData() list will contain one entry identifying
* that object (e.g. the frame type for ID3v2 tags). Use removeUnsupportedProperties()
* to remove (a subset of) them.
* For files that contain more than one tag (e.g. an MP3 with both an ID3v2 and an ID3v2
* tag) only the most "modern" one will be exported (ID3v2 in this case).
*/
virtual PropertyMap properties() const;
@ -103,9 +105,14 @@ namespace TagLib {
* If some value(s) could not be written imported to the specific metadata format,
* the returned PropertyMap will contain those value(s). Otherwise it will be empty,
* indicating that no problems occured.
* With file types that support several tag formats (for instance, MP3 files can have
* ID3v1, ID3v2, and APEv2 tags), this function will create the most appropriate one
* (ID3v2 for MP3 files). Older formats will be updated as well, if they exist, but won't
* be taken into account for the return value of this function.
* See the documentation of the subclass implementations for detailed descriptions.
*/
virtual PropertyMap setProperties(const PropertyMap &properties);
/*!
* Returns a pointer to this file's audio properties. This should be
* reimplemented in the concrete subclasses. If no audio properties were

@ -141,12 +141,9 @@ PropertyMap TrueAudio::File::properties() const
PropertyMap TrueAudio::File::setProperties(const PropertyMap &properties)
{
if(d->hasID3v2)
return d->tag.access<ID3v2::Tag>(TrueAudioID3v2Index, false)->setProperties(properties);
else if(d->hasID3v1)
return d->tag.access<ID3v1::Tag>(TrueAudioID3v1Index, false)->setProperties(properties);
else
return d->tag.access<ID3v2::Tag>(TrueAudioID3v2Index, true)->setProperties(properties);
if(d->hasID3v1)
d->tag.access<ID3v1::Tag>(TrueAudioID3v1Index, false)->setProperties(properties);
return d->tag.access<ID3v2::Tag>(TrueAudioID3v2Index, true)->setProperties(properties);
}
TrueAudio::Properties *TrueAudio::File::audioProperties() const

@ -139,8 +139,8 @@ namespace TagLib {
/*!
* Implements the unified property interface -- import function.
* As with the export, only one tag is taken into account. If the file
* has no tag at all, ID3v2 will be created.
* Creates in ID3v2 tag if necessary. If an ID3v1 tag exists, it will
* be updated as well, within the limitations of ID3v1.
*/
PropertyMap setProperties(const PropertyMap &);

@ -119,12 +119,9 @@ PropertyMap WavPack::File::properties() const
PropertyMap WavPack::File::setProperties(const PropertyMap &properties)
{
if(d->hasAPE)
return d->tag.access<APE::Tag>(WavAPEIndex, false)->setProperties(properties);
else if(d->hasID3v1)
return d->tag.access<ID3v1::Tag>(WavID3v1Index, false)->setProperties(properties);
else
return d->tag.access<APE::Tag>(APE, true)->setProperties(properties);
if(d->hasID3v1)
d->tag.access<ID3v1::Tag>(WavID3v1Index, false)->setProperties(properties);
return d->tag.access<APE::Tag>(WavAPEIndex, true)->setProperties(properties);
}
WavPack::Properties *WavPack::File::audioProperties() const

@ -118,8 +118,8 @@ namespace TagLib {
/*!
* Implements the unified property interface -- import function.
* As for the export, only one tag is taken into account. If the file
* has no tag at all, APE will be created.
* Creates an APE tag if it does not exists and calls setProperties() on
* that. Any existing ID3v1 tag will be updated as well.
*/
PropertyMap setProperties(const PropertyMap&);

@ -24,6 +24,7 @@ class TestFLAC : public CppUnit::TestFixture
CPPUNIT_TEST(testRepeatedSave);
CPPUNIT_TEST(testSaveMultipleValues);
CPPUNIT_TEST(testDict);
CPPUNIT_TEST(testInvalid);
CPPUNIT_TEST_SUITE_END();
public:
@ -231,6 +232,17 @@ public:
CPPUNIT_ASSERT_EQUAL(String("artöst 2"), dict["ARTIST"][1]);
}
void testInvalid()
{
ScopedFileCopy copy("silence-44-s", ".flac");
PropertyMap map;
map["HÄÖ"] = String("bla");
FLAC::File f(copy.fileName().c_str());
PropertyMap invalid = f.setProperties(map);
CPPUNIT_ASSERT_EQUAL(uint(1), invalid.size());
CPPUNIT_ASSERT_EQUAL(uint(0), f.properties().size());
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestFLAC);

@ -7,6 +7,7 @@
#include <unistd.h>
#include <fcntl.h>
#include <sys/fcntl.h>
#include <sys/stat.h>
#endif
#include <stdio.h>
#include <string.h>