TagLib API Documentation
matroskacues.h
Go to the documentation of this file.
1/***************************************************************************
2 * This library is free software; you can redistribute it and/or modify *
3 * it under the terms of the GNU Lesser General Public License version *
4 * 2.1 as published by the Free Software Foundation. *
5 * *
6 * This library is distributed in the hope that it will be useful, but *
7 * WITHOUT ANY WARRANTY; without even the implied warranty of *
8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
9 * Lesser General Public License for more details. *
10 * *
11 * You should have received a copy of the GNU Lesser General Public *
12 * License along with this library; if not, write to the Free Software *
13 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
14 * 02110-1301 USA *
15 * *
16 * Alternatively, this file is available under the Mozilla Public *
17 * License Version 1.1. You may obtain a copy of the License at *
18 * http://www.mozilla.org/MPL/ *
19 ***************************************************************************/
20
21#ifndef TAGLIB_MATROSKACUES_H
22#define TAGLIB_MATROSKACUES_H
23#ifndef DO_NOT_DOCUMENT
24
25#include <optional>
26
27#include "tlist.h"
28#include "matroskaelement.h"
29
30namespace TagLib {
31 class File;
32
33 namespace EBML {
34 class MkCues;
35 }
36
37 namespace Matroska {
38 class CuePoint;
39 class CueTrack;
40
41 class Cues : public Element
42 {
43 public:
44 using CuePointList = std::list<std::unique_ptr<CuePoint>>;
45 explicit Cues(offset_t segmentDataOffset);
46 ~Cues() override;
47 bool isValid(TagLib::File &file) const;
48 void addCuePoint(std::unique_ptr<CuePoint> &&cuePoint);
49 const CuePointList &cuePointList();
50 bool sizeChanged(Element &caller, offset_t delta) override;
51 void write(TagLib::File &file) override;
52
53 private:
54 friend class EBML::MkCues;
55 ByteVector renderInternal() override;
56
57 CuePointList cuePoints;
58 const offset_t segmentDataOffset;
59 };
60
61 class CuePoint
62 {
63 public:
64 using CueTrackList = std::list<std::unique_ptr<CueTrack>>;
65 using Time = unsigned long long;
66 CuePoint();
67 ~CuePoint();
68 bool isValid(TagLib::File &file, offset_t segmentDataOffset) const;
69 void addCueTrack(std::unique_ptr<CueTrack> &&cueTrack);
70 const CueTrackList &cueTrackList() const;
71 void setTime(Time timestamp);
72 Time getTime() const;
73 bool adjustOffset(offset_t offset, offset_t delta);
74
75 private:
76 CueTrackList cueTracks;
77 Time time = 0;
78 };
79
80 class CueTrack
81 {
82 public:
83 using ReferenceTimeList = List<unsigned long long>;
84 CueTrack();
85 ~CueTrack();
86 bool isValid(TagLib::File &file, offset_t segmentDataOffset) const;
87 void setTrackNumber(unsigned long long trackNr);
88 unsigned long long getTrackNumber() const;
89 void setClusterPosition(offset_t clusterPos);
90 offset_t getClusterPosition() const;
91 void setRelativePosition(std::optional<offset_t> relativePos);
92 std::optional<offset_t> getRelativePosition() const;
93 void setCodecState(std::optional<offset_t> codecStatePos);
94 std::optional<offset_t> getCodecState() const;
95 void setBlockNumber(std::optional<unsigned long long> blockNr);
96 std::optional<unsigned long long> getBlockNumber() const;
97 void setDuration(std::optional<unsigned long long> segmentTicks);
98 std::optional<unsigned long long> getDuration() const;
99 void addReferenceTime(unsigned long long refTime);
100 const ReferenceTimeList &referenceTimes() const;
101 bool adjustOffset(offset_t offset, offset_t delta);
102
103 private:
104 unsigned long long trackNumber = 0;
105 offset_t clusterPosition = 0;
106 std::optional<offset_t> relativePosition;
107 std::optional<unsigned long long> blockNumber;
108 std::optional<unsigned long long> duration;
109 std::optional<offset_t> codecState;
110 ReferenceTimeList refTimes;
111 };
112 }
113}
114
115#endif
116#endif
A file class with some useful methods for tag manipulation.
Definition tfile.h:51
A namespace for all TagLib related classes and functions.
Definition apefile.h:41
off_t offset_t
Definition taglib.h:64