tagparser/matroska/matroskaseekinfo.h

76 lines
2.9 KiB
C
Raw Normal View History

#ifndef TAG_PARSER_MATROSKASEEKINFO_H
#define TAG_PARSER_MATROSKASEEKINFO_H
2015-04-22 19:22:01 +02:00
2015-09-06 19:57:33 +02:00
#include "./ebmlelement.h"
2015-04-22 19:22:01 +02:00
#include <utility>
namespace TagParser {
2015-04-22 19:22:01 +02:00
2018-03-07 01:17:50 +01:00
class TAG_PARSER_EXPORT MatroskaSeekInfo {
2015-04-22 19:22:01 +02:00
public:
MatroskaSeekInfo();
const std::vector<EbmlElement *> &seekHeadElements() const;
2019-03-13 19:06:42 +01:00
const std::vector<std::pair<EbmlElement::IdentifierType, std::uint64_t>> &info() const;
std::vector<std::pair<EbmlElement::IdentifierType, std::uint64_t>> &info();
void shift(std::uint64_t start, std::int64_t amount);
void parse(EbmlElement *seekHeadElements, Diagnostics &diag, std::size_t maxNesting = 1);
void make(std::ostream &stream, Diagnostics &diag);
2019-03-13 19:06:42 +01:00
std::uint64_t minSize() const;
std::uint64_t maxSize() const;
std::uint64_t actualSize() const;
bool push(unsigned int index, EbmlElement::IdentifierType id, std::uint64_t offset);
2015-04-22 19:22:01 +02:00
void clear();
// these methods seem to be not needed anymore
2019-03-13 19:06:42 +01:00
static std::pair<EbmlElement::IdentifierType, std::uint64_t> *findSeekInfo(std::vector<MatroskaSeekInfo> &seekInfos, std::uint64_t offset);
static bool updateSeekInfo(const std::vector<MatroskaSeekInfo> &oldSeekInfos, std::vector<MatroskaSeekInfo> &newSeekInfos,
std::uint64_t oldOffset, std::uint64_t newOffset);
static bool updateSeekInfo(std::vector<MatroskaSeekInfo> &newSeekInfos, std::uint64_t oldOffset, std::uint64_t newOffset);
2015-04-22 19:22:01 +02:00
private:
std::vector<EbmlElement *> m_seekHeadElements;
std::vector<std::unique_ptr<EbmlElement>> m_additionalSeekHeadElements;
2019-03-13 19:06:42 +01:00
std::vector<std::pair<EbmlElement::IdentifierType, std::uint64_t>> m_info;
2015-04-22 19:22:01 +02:00
};
/*!
* \brief Constructs a new MatroskaSeekInfo.
*/
2018-03-07 01:17:50 +01:00
inline MatroskaSeekInfo::MatroskaSeekInfo()
{
}
2015-04-22 19:22:01 +02:00
/*!
* \brief Returns a pointer to the seek head elements the seek information is composed of.
* \remarks This list is initially empty. When calling parse() it is at least populated with the specified seek head element (ownership remains
* by the caller). In case that seek table references another seek table those elements are also returned (the MatroskaSeekInfo has ownership).
2015-04-22 19:22:01 +02:00
*/
inline const std::vector<EbmlElement *> &MatroskaSeekInfo::seekHeadElements() const
2015-04-22 19:22:01 +02:00
{
return m_seekHeadElements;
2015-04-22 19:22:01 +02:00
}
/*!
* \brief Returns the seek information gathered when the parse() method was called.
* \returns Returns the seek information as pairs of element IDs and the associated offsets (relative to the beginning of the file).
*/
2019-03-13 19:06:42 +01:00
inline const std::vector<std::pair<EbmlElement::IdentifierType, std::uint64_t>> &MatroskaSeekInfo::info() const
2015-04-22 19:22:01 +02:00
{
return m_info;
}
/*!
* \brief Returns a mutable version of the seek information gathered when the parse() method was called.
* \returns Returns the seek information as pairs of element IDs and the associated offsets (relative to the beginning of the file).
*/
2019-03-13 19:06:42 +01:00
inline std::vector<std::pair<EbmlElement::IdentifierType, std::uint64_t>> &MatroskaSeekInfo::info()
2015-04-22 19:22:01 +02:00
{
return m_info;
}
2018-03-07 01:17:50 +01:00
} // namespace TagParser
2015-04-22 19:22:01 +02:00
#endif // TAG_PARSER_MATROSKASEEKINFO_H