2015-04-22 19:22:01 +02:00
|
|
|
#ifndef MEDIA_VORBISCOMMENT_H
|
|
|
|
#define MEDIA_VORBISCOMMENT_H
|
|
|
|
|
2015-09-06 19:57:33 +02:00
|
|
|
#include "./vorbiscommentfield.h"
|
2015-04-22 19:22:01 +02:00
|
|
|
|
2015-09-06 19:57:33 +02:00
|
|
|
#include "../caseinsensitivecomparer.h"
|
|
|
|
#include "../fieldbasedtag.h"
|
2016-03-22 22:52:36 +01:00
|
|
|
#include "../mediaformat.h"
|
2015-04-22 19:22:01 +02:00
|
|
|
|
|
|
|
namespace Media {
|
|
|
|
|
|
|
|
class OggIterator;
|
2016-03-22 22:52:36 +01:00
|
|
|
class VorbisComment;
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief The OggParameter struct holds the OGG parameter for a VorbisComment.
|
|
|
|
*/
|
|
|
|
struct LIB_EXPORT OggParameter
|
|
|
|
{
|
|
|
|
OggParameter();
|
|
|
|
void set(std::size_t pageIndex, std::size_t segmentIndex, GeneralMediaFormat streamFormat = GeneralMediaFormat::Vorbis);
|
|
|
|
|
|
|
|
std::size_t firstPageIndex;
|
|
|
|
std::size_t firstSegmentIndex;
|
|
|
|
std::size_t lastPageIndex;
|
|
|
|
std::size_t lastSegmentIndex;
|
|
|
|
GeneralMediaFormat streamFormat;
|
|
|
|
bool removed;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Creates new parameters.
|
|
|
|
* \remarks The OggContainer class is responsible for assigning sane values.
|
|
|
|
*/
|
|
|
|
inline OggParameter::OggParameter() :
|
|
|
|
firstPageIndex(0),
|
|
|
|
firstSegmentIndex(0),
|
|
|
|
lastPageIndex(0),
|
|
|
|
lastSegmentIndex(0),
|
|
|
|
streamFormat(GeneralMediaFormat::Vorbis), // default to Vorbis here
|
|
|
|
removed(false)
|
|
|
|
{}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Sets firstPageIndex/lastPageIndex, firstSegmentIndex/lastSegmentIndex and streamFormat.
|
|
|
|
*/
|
|
|
|
inline void OggParameter::set(std::size_t pageIndex, std::size_t segmentIndex, GeneralMediaFormat streamFormat)
|
|
|
|
{
|
|
|
|
firstPageIndex = lastPageIndex = pageIndex;
|
|
|
|
firstSegmentIndex = lastSegmentIndex = segmentIndex;
|
|
|
|
this->streamFormat = streamFormat;
|
|
|
|
}
|
2015-04-22 19:22:01 +02:00
|
|
|
|
2015-07-27 23:13:03 +02:00
|
|
|
class LIB_EXPORT VorbisComment : public FieldMapBasedTag<VorbisCommentField, CaseInsensitiveStringComparer>
|
2015-04-22 19:22:01 +02:00
|
|
|
{
|
2016-03-22 22:52:36 +01:00
|
|
|
friend class OggContainer;
|
|
|
|
|
2015-04-22 19:22:01 +02:00
|
|
|
public:
|
|
|
|
VorbisComment();
|
|
|
|
|
|
|
|
TagType type() const;
|
|
|
|
const char *typeName() const;
|
|
|
|
TagTextEncoding proposedTextEncoding() const;
|
|
|
|
bool canEncodingBeUsed(TagTextEncoding encoding) const;
|
|
|
|
|
2015-07-27 23:13:03 +02:00
|
|
|
const TagValue &value(KnownField field) const;
|
|
|
|
bool setValue(KnownField field, const TagValue &value);
|
2015-04-22 19:22:01 +02:00
|
|
|
std::string fieldId(KnownField field) const;
|
|
|
|
KnownField knownField(const std::string &id) const;
|
|
|
|
|
2016-01-17 19:32:58 +01:00
|
|
|
void parse(OggIterator &iterator, bool skipSignature = false);
|
|
|
|
void make(std::ostream &stream, bool noSignature = false);
|
2015-04-22 19:22:01 +02:00
|
|
|
|
2015-07-27 23:13:03 +02:00
|
|
|
const TagValue &vendor() const;
|
|
|
|
void setVendor(const TagValue &vendor);
|
2016-03-22 22:52:36 +01:00
|
|
|
OggParameter &oggParams();
|
|
|
|
const OggParameter &oggParams() const;
|
2015-04-22 19:22:01 +02:00
|
|
|
|
|
|
|
private:
|
2015-07-27 23:13:03 +02:00
|
|
|
TagValue m_vendor;
|
2016-03-22 22:52:36 +01:00
|
|
|
OggParameter m_oggParams;
|
2015-04-22 19:22:01 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Constructs a new Vorbis comment.
|
|
|
|
*/
|
|
|
|
inline VorbisComment::VorbisComment()
|
|
|
|
{}
|
|
|
|
|
|
|
|
inline TagType VorbisComment::type() const
|
|
|
|
{
|
|
|
|
return TagType::VorbisComment;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline const char *VorbisComment::typeName() const
|
|
|
|
{
|
2016-03-22 22:52:36 +01:00
|
|
|
switch(m_oggParams.streamFormat) {
|
|
|
|
case GeneralMediaFormat::Opus:
|
|
|
|
return "Opus comment";
|
|
|
|
case GeneralMediaFormat::Theora:
|
|
|
|
return "Theora comment";
|
|
|
|
default:
|
|
|
|
// just assume Vorbis otherwise
|
|
|
|
return "Vorbis comment";
|
|
|
|
}
|
2015-04-22 19:22:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
inline TagTextEncoding VorbisComment::proposedTextEncoding() const
|
|
|
|
{
|
|
|
|
return TagTextEncoding::Utf8;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool VorbisComment::canEncodingBeUsed(TagTextEncoding encoding) const
|
|
|
|
{
|
|
|
|
return encoding == TagTextEncoding::Utf8;
|
|
|
|
}
|
|
|
|
|
2016-03-22 22:52:36 +01:00
|
|
|
/*!
|
|
|
|
* \brief Returns the vendor.
|
|
|
|
* \remarks Also accessable via value(KnownField::Vendor).
|
|
|
|
*/
|
2015-07-27 23:13:03 +02:00
|
|
|
inline const TagValue &VorbisComment::vendor() const
|
2015-04-22 19:22:01 +02:00
|
|
|
{
|
|
|
|
return m_vendor;
|
|
|
|
}
|
|
|
|
|
2016-03-22 22:52:36 +01:00
|
|
|
/*!
|
|
|
|
* \brief Returns the vendor.
|
|
|
|
* \remarks Also accessable via setValue(KnownField::Vendor, vendor).
|
|
|
|
*/
|
2015-07-27 23:13:03 +02:00
|
|
|
inline void VorbisComment::setVendor(const TagValue &vendor)
|
2015-04-22 19:22:01 +02:00
|
|
|
{
|
|
|
|
m_vendor = vendor;
|
|
|
|
}
|
|
|
|
|
2016-03-22 22:52:36 +01:00
|
|
|
/*!
|
|
|
|
* \brief Returns the OGG parameter for the comment.
|
|
|
|
*
|
|
|
|
* Consists of first page index, first segment index, last page index, last segment index and tag index (in this order).
|
|
|
|
* These values are used and managed by the OggContainer class and do not affect the behavior of the VorbisComment instance.
|
|
|
|
*/
|
|
|
|
inline OggParameter &VorbisComment::oggParams()
|
|
|
|
{
|
|
|
|
return m_oggParams;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Returns the OGG parameter for the comment.
|
|
|
|
*
|
|
|
|
* Consists of first page index, first segment index, last page index, last segment index and tag index (in this order).
|
|
|
|
* These values are used and managed by the OggContainer class and do not affect the behavior of the VorbisComment instance.
|
|
|
|
*/
|
|
|
|
inline const OggParameter &VorbisComment::oggParams() const
|
|
|
|
{
|
|
|
|
return m_oggParams;
|
|
|
|
}
|
|
|
|
|
2015-04-22 19:22:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif // MEDIA_VORBISCOMMENT_H
|