2015-04-22 19:22:01 +02:00
|
|
|
#ifndef MEDIA_MATROSKATAG_H
|
|
|
|
#define MEDIA_MATROSKATAG_H
|
|
|
|
|
2015-09-06 19:57:33 +02:00
|
|
|
#include "./matroskatagfield.h"
|
2016-05-26 01:59:22 +02:00
|
|
|
#include "./matroskatagid.h"
|
2015-09-06 15:42:18 +02:00
|
|
|
|
2015-09-06 19:57:33 +02:00
|
|
|
#include "../fieldbasedtag.h"
|
2015-04-22 19:22:01 +02:00
|
|
|
|
|
|
|
namespace Media {
|
|
|
|
|
|
|
|
class EbmlElement;
|
|
|
|
class MatroskaTag;
|
|
|
|
|
2016-08-29 15:43:05 +02:00
|
|
|
class TAG_PARSER_EXPORT MatroskaTagMaker
|
2015-04-22 19:22:01 +02:00
|
|
|
{
|
|
|
|
friend class MatroskaTag;
|
|
|
|
|
|
|
|
public:
|
|
|
|
void make(std::ostream &stream) const;
|
|
|
|
const MatroskaTag &tag() const;
|
|
|
|
uint64 requiredSize() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
MatroskaTagMaker(MatroskaTag &tag);
|
|
|
|
|
|
|
|
MatroskaTag &m_tag;
|
|
|
|
uint64 m_targetsSize;
|
|
|
|
uint64 m_simpleTagsSize;
|
2015-12-22 23:54:35 +01:00
|
|
|
std::vector<MatroskaTagFieldMaker> m_maker;
|
2015-04-22 19:22:01 +02:00
|
|
|
uint64 m_tagSize;
|
|
|
|
uint64 m_totalSize;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Returns the associated tag.
|
|
|
|
*/
|
|
|
|
inline const MatroskaTag &MatroskaTagMaker::tag() const
|
|
|
|
{
|
|
|
|
return m_tag;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Returns the number of bytes which will be written when making the tag.
|
|
|
|
*/
|
|
|
|
inline uint64 MatroskaTagMaker::requiredSize() const
|
|
|
|
{
|
|
|
|
return m_totalSize;
|
|
|
|
}
|
|
|
|
|
2017-03-07 00:02:59 +01:00
|
|
|
/*!
|
|
|
|
* \brief Defines traits for the TagField implementation of the MatroskaTag class.
|
|
|
|
*/
|
|
|
|
template <>
|
|
|
|
class TAG_PARSER_EXPORT FieldMapBasedTagTraits<MatroskaTag>
|
|
|
|
{
|
|
|
|
public:
|
2017-03-07 17:16:17 +01:00
|
|
|
typedef MatroskaTagField FieldType;
|
|
|
|
typedef std::less<typename FieldType::IdentifierType> Compare;
|
2017-03-07 00:02:59 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class TAG_PARSER_EXPORT MatroskaTag : public FieldMapBasedTag<MatroskaTag>
|
2015-04-22 19:22:01 +02:00
|
|
|
{
|
2017-03-07 01:52:26 +01:00
|
|
|
friend class FieldMapBasedTag<MatroskaTag>;
|
|
|
|
|
2015-04-22 19:22:01 +02:00
|
|
|
public:
|
|
|
|
MatroskaTag();
|
|
|
|
|
2017-01-23 00:25:53 +01:00
|
|
|
static constexpr TagType tagType = TagType::MatroskaTag;
|
2017-03-07 00:02:59 +01:00
|
|
|
static constexpr const char *tagName = "Matroska tag";
|
|
|
|
static constexpr TagTextEncoding defaultTextEncoding = TagTextEncoding::Utf8;
|
2015-04-22 19:22:01 +02:00
|
|
|
bool canEncodingBeUsed(TagTextEncoding encoding) const;
|
|
|
|
bool supportsTarget() const;
|
2016-05-26 01:59:22 +02:00
|
|
|
TagTargetLevel targetLevel() const;
|
2015-04-22 19:22:01 +02:00
|
|
|
|
|
|
|
void parse(EbmlElement &tagElement);
|
|
|
|
MatroskaTagMaker prepareMaking();
|
|
|
|
void make(std::ostream &stream);
|
|
|
|
|
2017-03-07 01:52:26 +01:00
|
|
|
protected:
|
2017-03-07 17:16:17 +01:00
|
|
|
IdentifierType internallyGetFieldId(KnownField field) const;
|
|
|
|
KnownField internallyGetKnownField(const IdentifierType &id) const;
|
2017-03-07 01:52:26 +01:00
|
|
|
|
2015-04-22 19:22:01 +02:00
|
|
|
private:
|
|
|
|
void parseTargets(EbmlElement &targetsElement);
|
|
|
|
};
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Constructs a new tag.
|
|
|
|
*/
|
|
|
|
inline MatroskaTag::MatroskaTag()
|
|
|
|
{}
|
|
|
|
|
2016-05-26 01:59:22 +02:00
|
|
|
inline bool MatroskaTag::supportsTarget() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline TagTargetLevel MatroskaTag::targetLevel() const
|
|
|
|
{
|
|
|
|
return matroskaTagTargetLevel(m_target.level());
|
|
|
|
}
|
|
|
|
|
2015-04-22 19:22:01 +02:00
|
|
|
inline bool MatroskaTag::canEncodingBeUsed(TagTextEncoding encoding) const
|
|
|
|
{
|
|
|
|
return encoding == TagTextEncoding::Utf8;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // MEDIA_MATROSKATAG_H
|