tagparser/matroska/matroskatrack.h

102 lines
2.6 KiB
C
Raw Normal View History

2015-04-22 19:22:01 +02:00
#ifndef MEDIA_MATROSKATRACK_H
#define MEDIA_MATROSKATRACK_H
2015-09-06 19:57:33 +02:00
#include "../abstracttrack.h"
2015-04-22 19:22:01 +02:00
namespace Media {
class EbmlElement;
class MatroskaContainer;
class MatroskaTrack;
class TAG_PARSER_EXPORT MatroskaTrackHeaderMaker
{
friend class MatroskaTrack;
public:
void make(std::ostream &stream) const;
const MatroskaTrack &track() const;
uint64 requiredSize() const;
private:
MatroskaTrackHeaderMaker(const MatroskaTrack &track);
const MatroskaTrack &m_track;
uint64 m_dataSize;
uint64 m_requiredSize;
byte m_sizeDenotationLength;
};
/*!
* \brief Returns the number of bytes which will be written when making the track.
*/
inline const MatroskaTrack &MatroskaTrackHeaderMaker::track() const
{
return m_track;
}
2015-04-22 19:22:01 +02:00
/*!
* \brief Returns the number of bytes which will be written when calling make().
*/
inline uint64 MatroskaTrackHeaderMaker::requiredSize() const
{
return m_requiredSize;
}
2016-08-29 15:43:05 +02:00
class TAG_PARSER_EXPORT MatroskaTrack : public AbstractTrack
2015-04-22 19:22:01 +02:00
{
friend class MatroskaContainer;
friend class MatroskaTrackHeaderMaker;
2015-04-22 19:22:01 +02:00
public:
MatroskaTrack(EbmlElement &trackElement);
~MatroskaTrack();
TrackType type() const;
static MediaFormat codecIdToMediaFormat(const std::string &codecId);
MatroskaTrackHeaderMaker prepareMakingHeader() const;
void makeHeader(std::ostream &stream) const;
2015-04-22 19:22:01 +02:00
protected:
void internalParseHeader();
private:
EbmlElement *m_trackElement;
};
/*!
* \brief Prepares making header.
* \returns Returns a MatroskaTrackHeaderMaker object which can be used to actually make the track
* header.
* \remarks The track must NOT be mutated after making is prepared when it is intended to actually
* make the tag using the make() method of the returned object.
* \throws Throws Media::Failure or a derived exception when a making error occurs.
*
* This method might be useful when it is necessary to know the size of the track header before making
* it.
* \sa make()
* \todo Make inline in next major release.
*/
inline MatroskaTrackHeaderMaker MatroskaTrack::prepareMakingHeader() const
{
return MatroskaTrackHeaderMaker(*this);
}
/*!
* \brief Writes header information to the specified \a stream (makes a "TrackEntry"-element).
* \throws Throws std::ios_base::failure when an IO error occurs.
* \throws Throws Media::Failure or a derived exception when a making
* error occurs.
* \sa prepareMaking()
* \todo Make inline in next major release.
*/
inline void MatroskaTrack::makeHeader(std::ostream &stream) const
{
prepareMakingHeader().make(stream);
}
2015-04-22 19:22:01 +02:00
}
#endif // MEDIA_MATROSKATRACK_H