11#include <promeki/config.h>
12#if PROMEKI_ENABLE_PROAV
24PROMEKI_NAMESPACE_BEGIN
40 bool underline =
false;
41 SubtitleEdgeStyle edgeStyle = SubtitleEdgeStyle::None;
42 SubtitleFontFace fontFace = SubtitleFontFace::Default;
43 Color foregroundColor;
44 Color backgroundColor;
46 SubtitleOpacity foregroundOpacity = SubtitleOpacity::Solid;
47 SubtitleOpacity backgroundOpacity = SubtitleOpacity::Solid;
48 SubtitleOpacity edgeOpacity = SubtitleOpacity::Solid;
53 bool hasAnyStyle()
const {
54 return italic || underline
55 || edgeStyle.value() != SubtitleEdgeStyle::None.value()
56 || fontFace.value() != SubtitleFontFace::Default.value()
57 || foregroundColor.isValid() || backgroundColor.isValid()
58 || edgeColor.isValid()
59 || foregroundOpacity.value() != SubtitleOpacity::Solid.value()
60 || backgroundOpacity.value() != SubtitleOpacity::Solid.value()
61 || edgeOpacity.value() != SubtitleOpacity::Solid.value();
64 bool operator==(
const Cea708PenAttr &o)
const {
65 return italic == o.italic && underline == o.underline
66 && edgeStyle.value() == o.edgeStyle.value()
67 && fontFace.value() == o.fontFace.value()
68 && foregroundColor == o.foregroundColor
69 && backgroundColor == o.backgroundColor
70 && edgeColor == o.edgeColor
71 && foregroundOpacity.value() == o.foregroundOpacity.value()
72 && backgroundOpacity.value() == o.backgroundOpacity.value()
73 && edgeOpacity.value() == o.edgeOpacity.value();
75 bool operator!=(
const Cea708PenAttr &o)
const {
return !(*
this == o); }
104struct Cea708WindowAttr {
108 SubtitleOpacity fillOpacity = SubtitleOpacity::Solid;
116 uint8_t borderType = 0;
121 uint8_t printDirection = 0;
123 uint8_t scrollDirection = 3;
125 bool wordWrap =
false;
127 uint8_t displayEffect = 0;
129 uint8_t effectDirection = 0;
131 uint8_t effectSpeed = 0;
137 bool hasAnyAttribute()
const {
138 return fillColor.isValid()
139 || fillOpacity.value() != SubtitleOpacity::Solid.value()
140 || borderColor.isValid()
143 || printDirection != 0
144 || scrollDirection != 3
146 || displayEffect != 0
147 || effectDirection != 0
151 bool operator==(
const Cea708WindowAttr &o)
const {
152 return fillColor == o.fillColor
153 && fillOpacity.value() == o.fillOpacity.value()
154 && borderColor == o.borderColor && borderType == o.borderType
155 && justify == o.justify && printDirection == o.printDirection
156 && scrollDirection == o.scrollDirection && wordWrap == o.wordWrap
157 && displayEffect == o.displayEffect && effectDirection == o.effectDirection
158 && effectSpeed == o.effectSpeed;
160 bool operator!=(
const Cea708WindowAttr &o)
const {
return !(*
this == o); }
173 uint32_t codepoint = 0;
176 bool operator==(
const Cea708Cell &o)
const {
177 return codepoint == o.codepoint && pen == o.pen;
179 bool operator!=(
const Cea708Cell &o)
const {
return !(*
this == o); }
216 static constexpr int MaxRows = 15;
219 static constexpr int MaxCols = 42;
221 bool visible =
false;
222 bool defined =
false;
227 bool relativePos =
true;
240 Cea708WindowAttr attrs;
247 List<List<Cea708Cell>> grid;
251 void resize(
int rows,
int cols);
263 void putChar(uint32_t cp,
const Cea708PenAttr &pen);
271 void putChar(uint32_t cp) { putChar(cp, Cea708PenAttr{}); }
275 void carriageReturn();
291 SubtitleSpan::List visibleSpans()
const;
294 bool isEmpty()
const;
296 bool operator==(
const Cea708Window &o)
const;
297 bool operator!=(
const Cea708Window &o)
const {
return !(*
this == o); }
358class Cea708WindowState {
361 static constexpr int WindowCount = 8;
373 int currentWindowId()
const {
return _currentWindow; }
376 void setCurrentWindowId(
int id) {
377 _currentWindow = (
id < 0) ? 0 : (id > 7) ? 7 : id;
381 const Cea708Window &window(
int id)
const {
return _windows[clampId(
id)]; }
384 Cea708Window &window(
int id) {
return _windows[clampId(
id)]; }
388 const Cea708Window ¤tWindow()
const {
return _windows[_currentWindow]; }
389 Cea708Window ¤tWindow() {
return _windows[_currentWindow]; }
394 const Cea708PenAttr ¤tPen()
const {
return _pen; }
395 Cea708PenAttr ¤tPen() {
return _pen; }
399 bool anyVisible()
const;
406 String visibleText()
const;
415 SubtitleSpan::List visibleSpans()
const;
421 void processServiceBytes(
const Cea708Service &svc);
430 void processBytes(
const void *data,
size_t size);
434 using WindowArray = Array<Cea708Window, WindowCount>;
436 WindowArray _windows;
437 int _currentWindow = 0;
450 uint32_t _pendingHighSurrogate = 0;
452 static int clampId(
int id) {
453 if (
id < 0)
return 0;
454 if (
id > 7)
return 7;