Tag Parser  8.2.0
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
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 
6 namespace TagParser {
7 
8 class EbmlElement;
9 class MatroskaContainer;
10 class MatroskaTrack;
11 class MatroskaTag;
12 
14  friend class MatroskaTrack;
15 
16 public:
17  void make(std::ostream &stream) const;
18  const MatroskaTrack &track() const;
19  uint64 requiredSize() const;
20 
21 private:
23 
24  const MatroskaTrack &m_track;
25  uint64 m_dataSize;
26  uint64 m_requiredSize;
27  byte m_sizeDenotationLength;
28 };
29 
34 {
35  return m_track;
36 }
37 
42 {
43  return m_requiredSize;
44 }
45 
47  friend class MatroskaContainer;
49 
50 public:
51  MatroskaTrack(EbmlElement &trackElement);
52  ~MatroskaTrack() override;
53 
54  TrackType type() const override;
55 
56  static MediaFormat codecIdToMediaFormat(const std::string &codecId);
57  void readStatisticsFromTags(const std::vector<std::unique_ptr<MatroskaTag>> &tags, Diagnostics &diag);
58  MatroskaTrackHeaderMaker prepareMakingHeader(Diagnostics &diag) const;
59  void makeHeader(std::ostream &stream, Diagnostics &diag) const;
60 
61 protected:
62  void internalParseHeader(Diagnostics &diag) override;
63 
64 private:
65  template <typename PropertyType, typename ConversionFunction>
66  void assignPropertyFromTagValue(const std::unique_ptr<MatroskaTag> &tag, const char *fieldId, PropertyType &integer,
67  const ConversionFunction &conversionFunction, Diagnostics &diag);
68 
69  EbmlElement *m_trackElement;
70 };
71 
85 {
86  return MatroskaTrackHeaderMaker(*this, diag);
87 }
88 
96 inline void MatroskaTrack::makeHeader(std::ostream &stream, Diagnostics &diag) const
97 {
98  prepareMakingHeader(diag).make(stream);
99 }
100 
101 } // namespace TagParser
102 
103 #endif // TAG_PARSER_MATROSKATRACK_H
MatroskaTrackHeaderMaker prepareMakingHeader(Diagnostics &diag) const
Prepares making header.
Definition: matroskatrack.h:84
The MatroskaTrackHeaderMaker class helps writing Matroska "TrackEntry"-elements storing track header ...
Definition: matroskatrack.h:13
Implementation of GenericContainer<MediaFileInfo, MatroskaTag, MatroskaTrack, EbmlElement>.
The MediaFormat class specifies the format of media data.
Definition: mediaformat.h:244
The EbmlElement class helps to parse EBML files such as Matroska files.
Definition: ebmlelement.h:31
Implementation of TagParser::AbstractTrack for the Matroska container.
Definition: matroskatrack.h:46
The AbstractTrack class parses and stores technical information about video, audio and other kinds of...
Definition: abstracttrack.h:40
uint64 requiredSize() const
Returns the number of bytes which will be written when calling make().
Definition: matroskatrack.h:41
void makeHeader(std::ostream &stream, Diagnostics &diag) const
Writes header information to the specified stream (makes a "TrackEntry"-element).
Definition: matroskatrack.h:96
friend class MatroskaTrackHeaderMaker
Definition: matroskatrack.h:48
const MatroskaTrack & track() const
Returns the number of bytes which will be written when making the track.
Definition: matroskatrack.h:33
Contains all classes and functions of the TagInfo library.
Definition: aaccodebook.h:9
#define TAG_PARSER_EXPORT
Marks the symbol to be exported by the tagparser library.
TrackType
Specifies the track type.
Definition: abstracttrack.h:28
The Diagnostics class is a container for DiagMessage.
Definition: diagnostics.h:156
void make(std::ostream &stream) const
Saves the header for the track (specified when constructing the object) to the specified stream (make...