field names of Vorbis Comments are now case insensitive
This commit is contained in:
parent
09fcb37442
commit
87e3dd3184
|
@ -23,6 +23,27 @@ namespace Media {
|
|||
* \brief Implementation of Media::Tag for the Vorbis comment.
|
||||
*/
|
||||
|
||||
const TagValue &VorbisComment::value(KnownField field) const
|
||||
{
|
||||
switch(field) {
|
||||
case KnownField::Vendor:
|
||||
return vendor();
|
||||
default:
|
||||
return FieldMapBasedTag<VorbisCommentField, CaseInsensitiveStringComparer>::value(field);
|
||||
}
|
||||
}
|
||||
|
||||
bool VorbisComment::setValue(KnownField field, const TagValue &value)
|
||||
{
|
||||
switch(field) {
|
||||
case KnownField::Vendor:
|
||||
setVendor(value);
|
||||
return true;
|
||||
default:
|
||||
return FieldMapBasedTag<VorbisCommentField, CaseInsensitiveStringComparer>::setValue(field, value);
|
||||
}
|
||||
}
|
||||
|
||||
string VorbisComment::fieldId(KnownField field) const
|
||||
{
|
||||
using namespace VorbisCommentIds;
|
||||
|
@ -147,13 +168,19 @@ void VorbisComment::make(std::ostream &stream)
|
|||
// prepare making
|
||||
invalidateStatus();
|
||||
static const string context("making Vorbis comment");
|
||||
string vendor;
|
||||
try {
|
||||
m_vendor.toString(vendor);
|
||||
} catch(ConversionException &) {
|
||||
addNotification(NotificationType::Warning, "Can not convert the assigned vendor to string.", context);
|
||||
}
|
||||
BinaryWriter writer(&stream);
|
||||
// write signature
|
||||
static const char sig[7] = {0x03, 0x76, 0x6F, 0x72, 0x62, 0x69, 0x73};
|
||||
stream.write(sig, sizeof(sig));
|
||||
// write vendor
|
||||
writer.writeUInt32LE(m_vendor.size());
|
||||
writer.writeString(m_vendor);
|
||||
writer.writeUInt32LE(vendor.size());
|
||||
writer.writeString(vendor);
|
||||
// write field count
|
||||
writer.writeUInt32LE(fieldCount());
|
||||
// write fields
|
||||
|
|
|
@ -3,13 +3,14 @@
|
|||
|
||||
#include "vorbiscommentfield.h"
|
||||
|
||||
#include "../caseinsensitivecomparer.h"
|
||||
#include "../fieldbasedtag.h"
|
||||
|
||||
namespace Media {
|
||||
|
||||
class OggIterator;
|
||||
|
||||
class LIB_EXPORT VorbisComment : public FieldMapBasedTag<VorbisCommentField>
|
||||
class LIB_EXPORT VorbisComment : public FieldMapBasedTag<VorbisCommentField, CaseInsensitiveStringComparer>
|
||||
{
|
||||
public:
|
||||
VorbisComment();
|
||||
|
@ -20,18 +21,19 @@ public:
|
|||
TagTextEncoding proposedTextEncoding() const;
|
||||
bool canEncodingBeUsed(TagTextEncoding encoding) const;
|
||||
|
||||
const TagValue &value(KnownField field) const;
|
||||
bool setValue(KnownField field, const TagValue &value);
|
||||
std::string fieldId(KnownField field) const;
|
||||
KnownField knownField(const std::string &id) const;
|
||||
|
||||
void parse(OggIterator &iterator);
|
||||
void make(std::ostream &stream);
|
||||
|
||||
const std::string &vendor() const;
|
||||
void setVendor(const std::string &vendor);
|
||||
const TagValue &vendor() const;
|
||||
void setVendor(const TagValue &vendor);
|
||||
|
||||
private:
|
||||
std::string m_vendor;
|
||||
|
||||
TagValue m_vendor;
|
||||
};
|
||||
|
||||
/*!
|
||||
|
@ -66,12 +68,12 @@ inline bool VorbisComment::canEncodingBeUsed(TagTextEncoding encoding) const
|
|||
return encoding == TagTextEncoding::Utf8;
|
||||
}
|
||||
|
||||
inline const std::string &VorbisComment::vendor() const
|
||||
inline const TagValue &VorbisComment::vendor() const
|
||||
{
|
||||
return m_vendor;
|
||||
}
|
||||
|
||||
inline void VorbisComment::setVendor(const std::string &vendor)
|
||||
inline void VorbisComment::setVendor(const TagValue &vendor)
|
||||
{
|
||||
m_vendor = vendor;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue