Tag Parser  9.1.2
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  std::uint64_t requiredSize() const;
20 
21 private:
23 
24  const MatroskaTrack &m_track;
25  std::uint64_t m_dataSize;
26  std::uint64_t m_requiredSize;
27  std::uint8_t m_sizeDenotationLength;
28 };
29 
34 {
35  return m_track;
36 }
37 
41 inline std::uint64_t MatroskaTrackHeaderMaker::requiredSize() const
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
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:96
TagParser::MatroskaTrackHeaderMaker::track
const MatroskaTrack & track() const
Returns the number of bytes which will be written when making the track.
Definition: matroskatrack.h:33
TagParser::TrackType::MatroskaTrack
@ MatroskaTrack
TagParser::Diagnostics
The Diagnostics class is a container for DiagMessage.
Definition: diagnostics.h:156
TagParser
Contains all classes and functions of the TagInfo library.
Definition: aaccodebook.h:10
TagParser::MatroskaTrackHeaderMaker
The MatroskaTrackHeaderMaker class helps writing Matroska "TrackEntry"-elements storing track header ...
Definition: matroskatrack.h:13
TagParser::TagType::MatroskaTag
@ MatroskaTag
TagParser::TrackType
TrackType
Specifies the track type.
Definition: abstracttrack.h:27
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:598
TagParser::EbmlElement
The EbmlElement class helps to parse EBML files such as Matroska files.
Definition: ebmlelement.h:31
TagParser::MatroskaTrack
Implementation of TagParser::AbstractTrack for the Matroska container.
Definition: matroskatrack.h:46
TagParser::AbstractTrack
The AbstractTrack class parses and stores technical information about video, audio and other kinds of...
Definition: abstracttrack.h:39
TagParser::MatroskaTrack::MatroskaTrackHeaderMaker
friend class MatroskaTrackHeaderMaker
Definition: matroskatrack.h:48
TagParser::MatroskaTrack::prepareMakingHeader
MatroskaTrackHeaderMaker prepareMakingHeader(Diagnostics &diag) const
Prepares making header.
Definition: matroskatrack.h:84
TAG_PARSER_EXPORT
#define TAG_PARSER_EXPORT
Marks the symbol to be exported by the tagparser library.
TagParser::MatroskaTrackHeaderMaker::requiredSize
std::uint64_t requiredSize() const
Returns the number of bytes which will be written when calling make().
Definition: matroskatrack.h:41
TagParser::MatroskaContainer
Implementation of GenericContainer<MediaFileInfo, MatroskaTag, MatroskaTrack, EbmlElement>.
Definition: matroskacontainer.h:24
TagParser::MediaFormat
The MediaFormat class specifies the format of media data.
Definition: mediaformat.h:245