Tag Parser: matroska/matroskatrack.h Source File

Tag Parser 12.5.2 C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags

Loading...
Searching...
No Matches
matroskatrack.h
Go to the documentation of this file.
1#ifndef TAG_PARSER_MATROSKATRACK_H
2#define TAG_PARSER_MATROSKATRACK_H
3
4#include "../abstracttrack.h"
5
6namespace TagParser {
7
8class EbmlElement;
9class MatroskaContainer;
10class MatroskaTrack;
11class MatroskaTag;
12
13 class TAG_PARSER_EXPORT MatroskaTrackHeaderMaker {
14 friend class MatroskaTrack;
15
16public:
17 void make(std::ostream &stream) const;
18 const MatroskaTrack &track() const;
19 std::uint64_t requiredSize() const;
20
21private:
22 MatroskaTrackHeaderMaker(const MatroskaTrack &track, Diagnostics &diag);
23
24 const MatroskaTrack &m_track;
25 const std::string &m_language;
26 const std::string &m_languageIETF;
27 std::uint64_t m_dataSize;
28 std::uint64_t m_requiredSize;
29 std::uint8_t m_sizeDenotationLength;
30};
31
35 inline const MatroskaTrack &MatroskaTrackHeaderMaker::track() const
36{
37 return m_track;
38}
39
43 inline std::uint64_t MatroskaTrackHeaderMaker::requiredSize() const
44{
45 return m_requiredSize;
46}
47
48 class TAG_PARSER_EXPORT MatroskaTrack : public AbstractTrack {
49 friend class MatroskaContainer;
50 friend class MatroskaTrackHeaderMaker;
51
52public:
53 MatroskaTrack(EbmlElement &trackElement);
54 ~MatroskaTrack() override;
55
56 TrackType type() const override;
57
58 static MediaFormat codecIdToMediaFormat(const std::string &codecId);
59 void readStatisticsFromTags(const std::vector<std::unique_ptr<MatroskaTag>> &tags, Diagnostics &diag);
60 MatroskaTrackHeaderMaker prepareMakingHeader(Diagnostics &diag) const;
61 void makeHeader(std::ostream &stream, Diagnostics &diag) const;
62
63protected:
64 void internalParseHeader(Diagnostics &diag, AbortableProgressFeedback &progress) override;
65
66private:
67 template <typename PropertyType, typename ConversionFunction>
68 void assignPropertyFromTagValue(const std::unique_ptr<MatroskaTag> &tag, std::string_view fieldId, PropertyType &integer,
69 const ConversionFunction &conversionFunction, Diagnostics &diag);
70
71 EbmlElement *m_trackElement;
72};
73
86 inline MatroskaTrackHeaderMaker MatroskaTrack::prepareMakingHeader(Diagnostics &diag) const
87{
88 return MatroskaTrackHeaderMaker(*this, diag);
89}
90
98 inline void MatroskaTrack::makeHeader(std::ostream &stream, Diagnostics &diag) const
99{
100 prepareMakingHeader(diag).make(stream);
101}
102
103} // namespace TagParser
104
105#endif // TAG_PARSER_MATROSKATRACK_H
abstracttrack.h
TagParser::AbortableProgressFeedback
The AbortableProgressFeedback class provides feedback about an ongoing operation via callbacks.
Definition progressfeedback.h:186
TagParser::AbstractTrack::AbstractTrack
AbstractTrack(std::istream &inputStream, std::ostream &outputStream, std::uint64_t startOffset)
Constructs a new track.
Definition abstracttrack.cpp:33
TagParser::Diagnostics
The Diagnostics class is a container for DiagMessage.
Definition diagnostics.h:156
TagParser::EbmlElement
The EbmlElement class helps to parse EBML files such as Matroska files.
Definition ebmlelement.h:32
TagParser::MatroskaContainer
Implementation of GenericContainer<MediaFileInfo, MatroskaTag, MatroskaTrack, EbmlElement>.
Definition matroskacontainer.h:24
TagParser::MatroskaTag
Implementation of TagParser::Tag for the Matroska container.
Definition matroskatag.h:72
TagParser::MatroskaTrackHeaderMaker::MatroskaTrack
friend class MatroskaTrack
Definition matroskatrack.h:14
TagParser::MatroskaTrackHeaderMaker::requiredSize
std::uint64_t requiredSize() const
Returns the number of bytes which will be written when calling make().
Definition matroskatrack.h:43
TagParser::MatroskaTrackHeaderMaker::track
const MatroskaTrack & track() const
Returns the number of bytes which will be written when making the track.
Definition matroskatrack.h:35
TagParser::MatroskaTrackHeaderMaker::make
void make(std::ostream &stream) const
Saves the header for the track (specified when constructing the object) to the specified stream (make...
Definition matroskatrack.cpp:617
TagParser::MatroskaTrack
Implementation of TagParser::AbstractTrack for the Matroska container.
Definition matroskatrack.h:48
TagParser::MatroskaTrack::codecIdToMediaFormat
static MediaFormat codecIdToMediaFormat(const std::string &codecId)
Returns the MediaFormat for the specified Matroska codec ID.
Definition matroskatrack.cpp:59
TagParser::MatroskaTrack::type
TrackType type() const override
Returns the type of the track if known; otherwise returns TrackType::Unspecified.
Definition matroskatrack.cpp:50
TagParser::MatroskaTrack::prepareMakingHeader
MatroskaTrackHeaderMaker prepareMakingHeader(Diagnostics &diag) const
Prepares making header.
Definition matroskatrack.h:86
TagParser::MatroskaTrack::makeHeader
void makeHeader(std::ostream &stream, Diagnostics &diag) const
Writes header information to the specified stream (makes a "TrackEntry"-element).
Definition matroskatrack.h:98
TagParser::MatroskaTrack::readStatisticsFromTags
void readStatisticsFromTags(const std::vector< std::unique_ptr< MatroskaTag > > &tags, Diagnostics &diag)
Reads track-specific statistics from the specified tags.
Definition matroskatrack.cpp:266
TagParser::MatroskaTrack::MatroskaTrack
MatroskaTrack(EbmlElement &trackElement)
Constructs a new track for the specified trackElement.
Definition matroskatrack.cpp:37
TagParser::MatroskaTrack::internalParseHeader
void internalParseHeader(Diagnostics &diag, AbortableProgressFeedback &progress) override
This method is internally called to parse header information.
Definition matroskatrack.cpp:286
TagParser::MatroskaTrack::MatroskaTrackHeaderMaker
friend class MatroskaTrackHeaderMaker
Definition matroskatrack.h:50
TagParser::MatroskaTrack::MatroskaContainer
friend class MatroskaContainer
Definition matroskatrack.h:49
TagParser::MediaFormat
The MediaFormat class specifies the format of media data.
Definition mediaformat.h:247
TAG_PARSER_EXPORT
#define TAG_PARSER_EXPORT
Marks the symbol to be exported by the tagparser library.
Definition global.h:14
TagParser
Contains all classes and functions of the TagInfo library.
Definition aaccodebook.h:10
TagParser::TrackType
TrackType
The TrackType enum specifies the underlying file type of a track and the concrete class of the track ...
Definition abstracttrack.h:32