Move Vorbis to the Ogg namespace

This commit is contained in:
Lukáš Lalinský 2012-11-12 16:32:15 +01:00
parent f6741b65e4
commit 2a86da4df5
5 changed files with 34 additions and 72 deletions

View File

@ -34,7 +34,7 @@
using namespace TagLib;
class Vorbis::File::FilePrivate
class Ogg::Vorbis::File::FilePrivate
{
public:
FilePrivate() :
@ -63,7 +63,7 @@ namespace TagLib {
// public members
////////////////////////////////////////////////////////////////////////////////
Vorbis::File::File(FileName file, bool readProperties,
Ogg::Vorbis::File::File(FileName file, bool readProperties,
Properties::ReadStyle propertiesStyle) : Ogg::File(file)
{
d = new FilePrivate;
@ -71,7 +71,7 @@ Vorbis::File::File(FileName file, bool readProperties,
read(readProperties, propertiesStyle);
}
Vorbis::File::File(IOStream *stream, bool readProperties,
Ogg::Vorbis::File::File(IOStream *stream, bool readProperties,
Properties::ReadStyle propertiesStyle) : Ogg::File(stream)
{
d = new FilePrivate;
@ -79,32 +79,32 @@ Vorbis::File::File(IOStream *stream, bool readProperties,
read(readProperties, propertiesStyle);
}
Vorbis::File::~File()
Ogg::Vorbis::File::~File()
{
delete d;
}
Ogg::XiphComment *Vorbis::File::tag() const
Ogg::XiphComment *Ogg::Vorbis::File::tag() const
{
return d->comment;
}
PropertyMap Vorbis::File::properties() const
PropertyMap Ogg::Vorbis::File::properties() const
{
return d->comment->properties();
}
PropertyMap Vorbis::File::setProperties(const PropertyMap &properties)
PropertyMap Ogg::Vorbis::File::setProperties(const PropertyMap &properties)
{
return d->comment->setProperties(properties);
}
Vorbis::Properties *Vorbis::File::audioProperties() const
Ogg::Vorbis::Properties *Ogg::Vorbis::File::audioProperties() const
{
return d->properties;
}
bool Vorbis::File::save()
bool Ogg::Vorbis::File::save()
{
ByteVector v(vorbisCommentHeaderID);
@ -121,12 +121,12 @@ bool Vorbis::File::save()
// private members
////////////////////////////////////////////////////////////////////////////////
void Vorbis::File::read(bool readProperties, Properties::ReadStyle propertiesStyle)
void Ogg::Vorbis::File::read(bool readProperties, Properties::ReadStyle propertiesStyle)
{
ByteVector commentHeaderData = packet(1);
if(commentHeaderData.mid(0, 7) != vorbisCommentHeaderID) {
debug("Vorbis::File::read() - Could not find the Vorbis comment header.");
debug("Ogg::Vorbis::File::read() - Could not find the Ogg::Vorbis comment header.");
setValid(false);
return;
}

View File

@ -34,16 +34,7 @@
namespace TagLib {
/*
* This is just to make this appear to be in the Ogg namespace in the
* documentation. The typedef below will make this work with the current code.
* In the next BIC version of TagLib this will be really moved into the Ogg
* namespace.
*/
#ifdef DOXYGEN
namespace Ogg {
#endif
//! A namespace containing classes for Vorbis metadata
@ -125,17 +116,7 @@ namespace TagLib {
};
}
/*
* To keep compatibility with the current version put Vorbis in the Ogg namespace
* only in the docs and provide a typedef to make it work. In the next BIC
* version this will be removed and it will only exist in the Ogg namespace.
*/
#ifdef DOXYGEN
}
#else
namespace Ogg { namespace Vorbis { typedef TagLib::Vorbis::File File; } }
#endif
}

View File

@ -33,7 +33,7 @@
using namespace TagLib;
class Vorbis::Properties::PropertiesPrivate
class Ogg::Vorbis::Properties::PropertiesPrivate
{
public:
PropertiesPrivate(File *f, ReadStyle s) :
@ -72,58 +72,58 @@ namespace TagLib {
// public members
////////////////////////////////////////////////////////////////////////////////
Vorbis::Properties::Properties(File *file, ReadStyle style) : AudioProperties(style)
Ogg::Vorbis::Properties::Properties(File *file, ReadStyle style) : AudioProperties(style)
{
d = new PropertiesPrivate(file, style);
read();
}
Vorbis::Properties::~Properties()
Ogg::Vorbis::Properties::~Properties()
{
delete d;
}
int Vorbis::Properties::length() const
int Ogg::Vorbis::Properties::length() const
{
return d->length;
}
int Vorbis::Properties::bitrate() const
int Ogg::Vorbis::Properties::bitrate() const
{
return int(float(d->bitrate) / float(1000) + 0.5);
}
int Vorbis::Properties::sampleRate() const
int Ogg::Vorbis::Properties::sampleRate() const
{
return d->sampleRate;
}
int Vorbis::Properties::channels() const
int Ogg::Vorbis::Properties::channels() const
{
return d->channels;
}
int Vorbis::Properties::vorbisVersion() const
int Ogg::Vorbis::Properties::vorbisVersion() const
{
return d->vorbisVersion;
}
int Vorbis::Properties::bitrateMaximum() const
int Ogg::Vorbis::Properties::bitrateMaximum() const
{
return d->bitrateMaximum;
}
int Vorbis::Properties::bitrateNominal() const
int Ogg::Vorbis::Properties::bitrateNominal() const
{
return d->bitrateNominal;
}
int Vorbis::Properties::bitrateMinimum() const
int Ogg::Vorbis::Properties::bitrateMinimum() const
{
return d->bitrateMinimum;
}
String Vorbis::Properties::toString() const
String Ogg::Vorbis::Properties::toString() const
{
StringList desc;
desc.append("Ogg Vorbis audio (version " + String::number(vorbisVersion()) + ")");
@ -136,7 +136,7 @@ String Vorbis::Properties::toString() const
// private members
////////////////////////////////////////////////////////////////////////////////
void Vorbis::Properties::read()
void Ogg::Vorbis::Properties::read()
{
// Get the identification header from the Ogg implementation.
@ -145,7 +145,7 @@ void Vorbis::Properties::read()
int pos = 0;
if(data.mid(pos, 7) != vorbisSetupHeaderID) {
debug("Vorbis::Properties::read() -- invalid Vorbis identification header");
debug("Ogg::Vorbis::Properties::read() -- invalid Ogg::Vorbis identification header");
return;
}
@ -171,7 +171,7 @@ void Vorbis::Properties::read()
// TODO: Later this should be only the "fast" mode.
d->bitrate = d->bitrateNominal;
// Find the length of the file. See http://wiki.xiph.org/VorbisStreamLength/
// Find the length of the file. See http://wiki.xiph.org/Ogg::VorbisStreamLength/
// for my notes on the topic.
const Ogg::PageHeader *first = d->file->firstPageHeader();
@ -184,9 +184,9 @@ void Vorbis::Properties::read()
if(start >= 0 && end >= 0 && d->sampleRate > 0)
d->length = (int)((end - start) / (long long) d->sampleRate);
else
debug("Vorbis::Properties::read() -- Either the PCM values for the start or "
debug("Ogg::Vorbis::Properties::read() -- Either the PCM values for the start or "
"end of this file was incorrect or the sample rate is zero.");
}
else
debug("Vorbis::Properties::read() -- Could not find valid first and last Ogg pages.");
debug("Ogg::Vorbis::Properties::read() -- Could not find valid first and last Ogg pages.");
}

View File

@ -31,16 +31,7 @@
namespace TagLib {
/*
* This is just to make this appear to be in the Ogg namespace in the
* documentation. The typedef below will make this work with the current code.
* In the next BIC version of TagLib this will be really moved into the Ogg
* namespace.
*/
#ifdef DOXYGEN
namespace Ogg {
#endif
namespace Vorbis {
@ -109,17 +100,7 @@ namespace TagLib {
};
}
/*
* To keep compatibility with the current version put Vorbis in the Ogg namespace
* only in the docs and provide a typedef to make it work. In the next BIC
* version this will be removed and it will only exist in the Ogg namespace.
*/
#ifdef DOXYGEN
}
#else
namespace Ogg { namespace Vorbis { typedef TagLib::AudioProperties AudioProperties; } }
#endif
}

View File

@ -29,12 +29,12 @@ public:
ScopedFileCopy copy("empty", ".ogg");
string newname = copy.fileName();
Vorbis::File *f = new Vorbis::File(newname.c_str());
Ogg::Vorbis::File *f = new Ogg::Vorbis::File(newname.c_str());
f->tag()->setArtist("The Artist");
f->save();
delete f;
f = new Vorbis::File(newname.c_str());
f = new Ogg::Vorbis::File(newname.c_str());
CPPUNIT_ASSERT_EQUAL(String("The Artist"), f->tag()->artist());
delete f;
}
@ -44,12 +44,12 @@ public:
ScopedFileCopy copy("empty", ".ogg");
string newname = copy.fileName();
Vorbis::File *f = new Vorbis::File(newname.c_str());
Ogg::Vorbis::File *f = new Ogg::Vorbis::File(newname.c_str());
f->tag()->addField("test", ByteVector(128 * 1024, 'x') + ByteVector(1, '\0'));
f->save();
delete f;
f = new Vorbis::File(newname.c_str());
f = new Ogg::Vorbis::File(newname.c_str());
CPPUNIT_ASSERT_EQUAL(19, f->lastPageHeader()->pageSequenceNumber());
delete f;
}
@ -59,7 +59,7 @@ public:
ScopedFileCopy copy("empty", ".ogg");
string newname = copy.fileName();
Vorbis::File *f = new Vorbis::File(newname.c_str());
Ogg::Vorbis::File *f = new Ogg::Vorbis::File(newname.c_str());
CPPUNIT_ASSERT_EQUAL(TagLib::uint(0), f->tag()->properties().size());
@ -82,7 +82,7 @@ public:
ScopedFileCopy copy("test", ".ogg");
string newname = copy.fileName();
Vorbis::File *f = new Vorbis::File(newname.c_str());
Ogg::Vorbis::File *f = new Ogg::Vorbis::File(newname.c_str());
PropertyMap tags = f->tag()->properties();
CPPUNIT_ASSERT_EQUAL(TagLib::uint(2), tags["UNUSUALTAG"].size());