libpromeki 1.0.0-alpha
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
scc.h
Go to the documentation of this file.
1
8#pragma once
9
10
11#include <promeki/config.h>
12#if PROMEKI_ENABLE_PROAV
13#include <cstdint>
14#include <promeki/buffer.h>
15#include <promeki/error.h>
16#include <promeki/list.h>
17#include <promeki/namespace.h>
18#include <promeki/result.h>
19#include <promeki/string.h>
20#include <promeki/timecode.h>
21
22PROMEKI_NAMESPACE_BEGIN
23
24class DataStream;
25
75class Scc {
76 public:
89 struct Line {
91 Timecode start;
94 List<uint16_t> bytePairs;
95
96 bool operator==(const Line &o) const {
97 return start == o.start && bytePairs == o.bytePairs;
98 }
99 bool operator!=(const Line &o) const { return !(*this == o); }
100 };
101
102 using LineList = ::promeki::List<Line>;
103
106 static constexpr const char *HeaderString = "Scenarist_SCC V1.0";
107
109 Scc() = default;
110
112 explicit Scc(LineList lines) : _lines(std::move(lines)) {}
113
115 bool isEmpty() const { return _lines.isEmpty(); }
116
118 size_t size() const { return _lines.size(); }
119
121 const LineList &lines() const { return _lines; }
122
124 LineList &lines() { return _lines; }
125
127 void append(const Line &line) { _lines.pushToBack(line); }
128
130 void clear() { _lines = LineList(); }
131
132 bool operator==(const Scc &o) const { return _lines == o._lines; }
133 bool operator!=(const Scc &o) const { return !(*this == o); }
134
151 static Result<Scc> fromBuffer(const void *data, size_t size);
152
154 static Result<Scc> fromBuffer(const Buffer &buf);
155
157 static Result<Scc> fromString(const String &str);
158
172 Buffer toBuffer() const;
173
175 String toString() const;
176
177 private:
178 LineList _lines;
179};
180
182DataStream &operator<<(DataStream &stream, const Scc &scc);
183
185DataStream &operator>>(DataStream &stream, Scc &scc);
186
187PROMEKI_NAMESPACE_END
188
189#endif // PROMEKI_ENABLE_PROAV