@svta/cml-608 0.19.0 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -0
- package/dist/index.d.ts +406 -20
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1173 -15
- package/dist/index.js.map +1 -1
- package/package.json +4 -28
- package/NOTICE +0 -59
- package/dist/CaptionModes.d.ts +0 -7
- package/dist/CaptionModes.d.ts.map +0 -1
- package/dist/CaptionModes.js +0 -2
- package/dist/CaptionModes.js.map +0 -1
- package/dist/CaptionScreen.d.ts +0 -80
- package/dist/CaptionScreen.d.ts.map +0 -1
- package/dist/CaptionScreen.js +0 -220
- package/dist/CaptionScreen.js.map +0 -1
- package/dist/CaptionsLogger.d.ts +0 -49
- package/dist/CaptionsLogger.d.ts.map +0 -1
- package/dist/CaptionsLogger.js +0 -56
- package/dist/CaptionsLogger.js.map +0 -1
- package/dist/Channels.d.ts +0 -7
- package/dist/Channels.d.ts.map +0 -1
- package/dist/Channels.js +0 -2
- package/dist/Channels.js.map +0 -1
- package/dist/CmdHistory.d.ts +0 -10
- package/dist/CmdHistory.d.ts.map +0 -1
- package/dist/CmdHistory.js +0 -2
- package/dist/CmdHistory.js.map +0 -1
- package/dist/Cta608Channel.d.ts +0 -88
- package/dist/Cta608Channel.d.ts.map +0 -1
- package/dist/Cta608Channel.js +0 -262
- package/dist/Cta608Channel.js.map +0 -1
- package/dist/Cta608Parser.d.ts +0 -115
- package/dist/Cta608Parser.d.ts.map +0 -1
- package/dist/Cta608Parser.js +0 -428
- package/dist/Cta608Parser.js.map +0 -1
- package/dist/CueHandler.d.ts +0 -12
- package/dist/CueHandler.d.ts.map +0 -1
- package/dist/CueHandler.js +0 -2
- package/dist/CueHandler.js.map +0 -1
- package/dist/PACData.d.ts +0 -13
- package/dist/PACData.d.ts.map +0 -1
- package/dist/PACData.js +0 -2
- package/dist/PACData.js.map +0 -1
- package/dist/PenState.d.ts +0 -56
- package/dist/PenState.d.ts.map +0 -1
- package/dist/PenState.js +0 -95
- package/dist/PenState.js.map +0 -1
- package/dist/PenStyles.d.ts +0 -13
- package/dist/PenStyles.d.ts.map +0 -1
- package/dist/PenStyles.js +0 -2
- package/dist/PenStyles.js.map +0 -1
- package/dist/Row.d.ts +0 -75
- package/dist/Row.d.ts.map +0 -1
- package/dist/Row.js +0 -174
- package/dist/Row.js.map +0 -1
- package/dist/SccParser.d.ts +0 -49
- package/dist/SccParser.d.ts.map +0 -1
- package/dist/SccParser.js +0 -99
- package/dist/SccParser.js.map +0 -1
- package/dist/StyledUnicodeChar.d.ts +0 -54
- package/dist/StyledUnicodeChar.d.ts.map +0 -1
- package/dist/StyledUnicodeChar.js +0 -71
- package/dist/StyledUnicodeChar.js.map +0 -1
- package/dist/SupportedField.d.ts +0 -7
- package/dist/SupportedField.d.ts.map +0 -1
- package/dist/SupportedField.js +0 -2
- package/dist/SupportedField.js.map +0 -1
- package/dist/VerboseLevel.d.ts +0 -22
- package/dist/VerboseLevel.d.ts.map +0 -1
- package/dist/VerboseLevel.js +0 -17
- package/dist/VerboseLevel.js.map +0 -1
- package/dist/extractCta608Data.d.ts +0 -11
- package/dist/extractCta608Data.d.ts.map +0 -1
- package/dist/extractCta608Data.js +0 -38
- package/dist/extractCta608Data.js.map +0 -1
- package/dist/extractCta608DataFromSample.d.ts +0 -12
- package/dist/extractCta608DataFromSample.d.ts.map +0 -1
- package/dist/extractCta608DataFromSample.js +0 -35
- package/dist/extractCta608DataFromSample.js.map +0 -1
- package/dist/findCta608Nalus.d.ts +0 -12
- package/dist/findCta608Nalus.d.ts.map +0 -1
- package/dist/findCta608Nalus.js +0 -60
- package/dist/findCta608Nalus.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/utils/NR_COLS.d.ts +0 -2
- package/dist/utils/NR_COLS.d.ts.map +0 -1
- package/dist/utils/NR_COLS.js +0 -2
- package/dist/utils/NR_COLS.js.map +0 -1
- package/dist/utils/NR_ROWS.d.ts +0 -2
- package/dist/utils/NR_ROWS.d.ts.map +0 -1
- package/dist/utils/NR_ROWS.js +0 -2
- package/dist/utils/NR_ROWS.js.map +0 -1
- package/dist/utils/backgroundColors.d.ts +0 -2
- package/dist/utils/backgroundColors.d.ts.map +0 -1
- package/dist/utils/backgroundColors.js +0 -12
- package/dist/utils/backgroundColors.js.map +0 -1
- package/dist/utils/createCmdHistory.d.ts +0 -3
- package/dist/utils/createCmdHistory.d.ts.map +0 -1
- package/dist/utils/createCmdHistory.js +0 -7
- package/dist/utils/createCmdHistory.js.map +0 -1
- package/dist/utils/getCharForByte.d.ts +0 -2
- package/dist/utils/getCharForByte.d.ts.map +0 -1
- package/dist/utils/getCharForByte.js +0 -6
- package/dist/utils/getCharForByte.js.map +0 -1
- package/dist/utils/hasCmdRepeated.d.ts +0 -3
- package/dist/utils/hasCmdRepeated.d.ts.map +0 -1
- package/dist/utils/hasCmdRepeated.js +0 -4
- package/dist/utils/hasCmdRepeated.js.map +0 -1
- package/dist/utils/index.d.ts +0 -20
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -20
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/numArrayToHexArray.d.ts +0 -2
- package/dist/utils/numArrayToHexArray.d.ts.map +0 -1
- package/dist/utils/numArrayToHexArray.js +0 -9
- package/dist/utils/numArrayToHexArray.js.map +0 -1
- package/dist/utils/rowsHighCh1.d.ts +0 -4
- package/dist/utils/rowsHighCh1.d.ts.map +0 -1
- package/dist/utils/rowsHighCh1.js +0 -10
- package/dist/utils/rowsHighCh1.js.map +0 -1
- package/dist/utils/rowsHighCh2.d.ts +0 -4
- package/dist/utils/rowsHighCh2.d.ts.map +0 -1
- package/dist/utils/rowsHighCh2.js +0 -10
- package/dist/utils/rowsHighCh2.js.map +0 -1
- package/dist/utils/rowsLowCh1.d.ts +0 -4
- package/dist/utils/rowsLowCh1.d.ts.map +0 -1
- package/dist/utils/rowsLowCh1.js +0 -12
- package/dist/utils/rowsLowCh1.js.map +0 -1
- package/dist/utils/rowsLowCh2.d.ts +0 -4
- package/dist/utils/rowsLowCh2.d.ts.map +0 -1
- package/dist/utils/rowsLowCh2.js +0 -11
- package/dist/utils/rowsLowCh2.js.map +0 -1
- package/dist/utils/seiHelpers.d.ts +0 -7
- package/dist/utils/seiHelpers.d.ts.map +0 -1
- package/dist/utils/seiHelpers.js +0 -78
- package/dist/utils/seiHelpers.js.map +0 -1
- package/dist/utils/setLastCmd.d.ts +0 -3
- package/dist/utils/setLastCmd.d.ts.map +0 -1
- package/dist/utils/setLastCmd.js +0 -5
- package/dist/utils/setLastCmd.js.map +0 -1
- package/dist/utils/specialCea608CharsCodes.d.ts +0 -7
- package/dist/utils/specialCea608CharsCodes.d.ts.map +0 -1
- package/dist/utils/specialCea608CharsCodes.js +0 -103
- package/dist/utils/specialCea608CharsCodes.js.map +0 -1
package/dist/Cta608Channel.js
DELETED
|
@@ -1,262 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* This code was ported from the dash.js project at:
|
|
4
|
-
* https://github.com/Dash-Industry-Forum/dash.js/blob/development/externals/cea608-parser.js
|
|
5
|
-
* https://github.com/Dash-Industry-Forum/dash.js/commit/8269b26a761e0853bb21d78780ed945144ecdd4d#diff-71bc295a2d6b6b7093a1d3290d53a4b2
|
|
6
|
-
*
|
|
7
|
-
* The original copyright appears below:
|
|
8
|
-
*
|
|
9
|
-
* The copyright in this software is being made available under the BSD License,
|
|
10
|
-
* included below. This software may be subject to other third party and contributor
|
|
11
|
-
* rights, including patent rights, and no such rights are granted under this license.
|
|
12
|
-
*
|
|
13
|
-
* Copyright (c) 2015-2016, DASH Industry Forum.
|
|
14
|
-
* All rights reserved.
|
|
15
|
-
*
|
|
16
|
-
* Redistribution and use in source and binary forms, with or without modification,
|
|
17
|
-
* are permitted provided that the following conditions are met:
|
|
18
|
-
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
19
|
-
* list of conditions and the following disclaimer.
|
|
20
|
-
* * Redistributions in binary form must reproduce the above copyright notice,
|
|
21
|
-
* this list of conditions and the following disclaimer in the documentation and/or
|
|
22
|
-
* other materials provided with the distribution.
|
|
23
|
-
* 2. Neither the name of Dash Industry Forum nor the names of its
|
|
24
|
-
* contributors may be used to endorse or promote products derived from this software
|
|
25
|
-
* without specific prior written permission.
|
|
26
|
-
*
|
|
27
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY
|
|
28
|
-
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
29
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
30
|
-
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
|
31
|
-
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
32
|
-
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
33
|
-
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
34
|
-
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
35
|
-
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
36
|
-
* POSSIBILITY OF SUCH DAMAGE.
|
|
37
|
-
*/
|
|
38
|
-
import { CaptionScreen } from './CaptionScreen.js';
|
|
39
|
-
import { CaptionsLogger } from './CaptionsLogger.js';
|
|
40
|
-
import { VerboseLevel } from './VerboseLevel.js';
|
|
41
|
-
import { NR_ROWS } from './utils/NR_ROWS.js';
|
|
42
|
-
/**
|
|
43
|
-
* CTA-608 Channel
|
|
44
|
-
*
|
|
45
|
-
* @beta
|
|
46
|
-
*/
|
|
47
|
-
export class Cta608Channel {
|
|
48
|
-
constructor(channelNumber, outputFilter, logger = new CaptionsLogger()) {
|
|
49
|
-
this.chNr = channelNumber;
|
|
50
|
-
this.outputFilter = outputFilter;
|
|
51
|
-
this.mode = null;
|
|
52
|
-
this.displayedMemory = new CaptionScreen(logger);
|
|
53
|
-
this.nonDisplayedMemory = new CaptionScreen(logger);
|
|
54
|
-
this.lastOutputScreen = new CaptionScreen(logger);
|
|
55
|
-
this.currRollUpRow = this.displayedMemory.rows[NR_ROWS - 1];
|
|
56
|
-
this.writeScreen = this.displayedMemory;
|
|
57
|
-
this.mode = null;
|
|
58
|
-
this.cueStartTime = null; // Keeps track of where a cue started.
|
|
59
|
-
this.logger = logger;
|
|
60
|
-
this.logger.log(VerboseLevel.INFO, 'new Cea608Channel(' + this.chNr + ')');
|
|
61
|
-
}
|
|
62
|
-
reset() {
|
|
63
|
-
var _a, _b;
|
|
64
|
-
this.mode = null;
|
|
65
|
-
this.displayedMemory.reset();
|
|
66
|
-
this.nonDisplayedMemory.reset();
|
|
67
|
-
this.lastOutputScreen.reset();
|
|
68
|
-
(_b = (_a = this.outputFilter) === null || _a === void 0 ? void 0 : _a.reset) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
69
|
-
this.currRollUpRow = this.displayedMemory.rows[NR_ROWS - 1];
|
|
70
|
-
this.writeScreen = this.displayedMemory;
|
|
71
|
-
this.mode = null;
|
|
72
|
-
this.cueStartTime = null;
|
|
73
|
-
}
|
|
74
|
-
getHandler() {
|
|
75
|
-
return this.outputFilter;
|
|
76
|
-
}
|
|
77
|
-
setHandler(outputFilter) {
|
|
78
|
-
this.outputFilter = outputFilter;
|
|
79
|
-
}
|
|
80
|
-
setPAC(pacData) {
|
|
81
|
-
this.writeScreen.setPAC(pacData);
|
|
82
|
-
}
|
|
83
|
-
setBkgData(bkgData) {
|
|
84
|
-
this.writeScreen.setBkgData(bkgData);
|
|
85
|
-
}
|
|
86
|
-
setMode(newMode) {
|
|
87
|
-
if (newMode === this.mode) {
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
this.mode = newMode;
|
|
91
|
-
this.logger.log(VerboseLevel.INFO, () => 'MODE=' + newMode);
|
|
92
|
-
if (this.mode === 'MODE_POP-ON') {
|
|
93
|
-
this.writeScreen = this.nonDisplayedMemory;
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
this.writeScreen = this.displayedMemory;
|
|
97
|
-
this.writeScreen.reset();
|
|
98
|
-
}
|
|
99
|
-
if (this.mode !== 'MODE_ROLL-UP') {
|
|
100
|
-
this.displayedMemory.setRollUpRows(null);
|
|
101
|
-
this.nonDisplayedMemory.setRollUpRows(null);
|
|
102
|
-
}
|
|
103
|
-
this.mode = newMode;
|
|
104
|
-
}
|
|
105
|
-
insertChars(chars) {
|
|
106
|
-
for (let i = 0; i < chars.length; i++) {
|
|
107
|
-
this.writeScreen.insertChar(chars[i]);
|
|
108
|
-
}
|
|
109
|
-
const screen = this.writeScreen === this.displayedMemory ? 'DISP' : 'NON_DISP';
|
|
110
|
-
this.logger.log(VerboseLevel.INFO, () => screen + ': ' + this.writeScreen.getDisplayText(true));
|
|
111
|
-
if (this.mode === 'MODE_PAINT-ON' || this.mode === 'MODE_ROLL-UP') {
|
|
112
|
-
this.logger.log(VerboseLevel.TEXT, () => 'DISPLAYED: ' + this.displayedMemory.getDisplayText(true));
|
|
113
|
-
this.outputDataUpdate();
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
ccRCL() {
|
|
117
|
-
// Resume Caption Loading (switch mode to Pop On)
|
|
118
|
-
this.logger.log(VerboseLevel.INFO, 'RCL - Resume Caption Loading');
|
|
119
|
-
this.setMode('MODE_POP-ON');
|
|
120
|
-
}
|
|
121
|
-
ccBS() {
|
|
122
|
-
// BackSpace
|
|
123
|
-
this.logger.log(VerboseLevel.INFO, 'BS - BackSpace');
|
|
124
|
-
if (this.mode === 'MODE_TEXT') {
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
this.writeScreen.backSpace();
|
|
128
|
-
if (this.writeScreen === this.displayedMemory) {
|
|
129
|
-
this.outputDataUpdate();
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
ccAOF() {
|
|
133
|
-
// Reserved (formerly Alarm Off)
|
|
134
|
-
}
|
|
135
|
-
ccAON() {
|
|
136
|
-
// Reserved (formerly Alarm On)
|
|
137
|
-
}
|
|
138
|
-
ccDER() {
|
|
139
|
-
// Delete to End of Row
|
|
140
|
-
this.logger.log(VerboseLevel.INFO, 'DER- Delete to End of Row');
|
|
141
|
-
this.writeScreen.clearToEndOfRow();
|
|
142
|
-
this.outputDataUpdate();
|
|
143
|
-
}
|
|
144
|
-
ccRU(nrRows) {
|
|
145
|
-
// Roll-Up Captions-2,3,or 4 Rows
|
|
146
|
-
this.logger.log(VerboseLevel.INFO, 'RU(' + nrRows + ') - Roll Up');
|
|
147
|
-
this.writeScreen = this.displayedMemory;
|
|
148
|
-
this.setMode('MODE_ROLL-UP');
|
|
149
|
-
this.writeScreen.setRollUpRows(nrRows);
|
|
150
|
-
}
|
|
151
|
-
ccFON() {
|
|
152
|
-
// Flash On
|
|
153
|
-
this.logger.log(VerboseLevel.INFO, 'FON - Flash On');
|
|
154
|
-
this.writeScreen.setPen({ flash: true });
|
|
155
|
-
}
|
|
156
|
-
ccRDC() {
|
|
157
|
-
// Resume Direct Captioning (switch mode to PaintOn)
|
|
158
|
-
this.logger.log(VerboseLevel.INFO, 'RDC - Resume Direct Captioning');
|
|
159
|
-
this.setMode('MODE_PAINT-ON');
|
|
160
|
-
}
|
|
161
|
-
ccTR() {
|
|
162
|
-
// Text Restart in text mode (not supported, however)
|
|
163
|
-
this.logger.log(VerboseLevel.INFO, 'TR');
|
|
164
|
-
this.setMode('MODE_TEXT');
|
|
165
|
-
}
|
|
166
|
-
ccRTD() {
|
|
167
|
-
// Resume Text Display in Text mode (not supported, however)
|
|
168
|
-
this.logger.log(VerboseLevel.INFO, 'RTD');
|
|
169
|
-
this.setMode('MODE_TEXT');
|
|
170
|
-
}
|
|
171
|
-
ccEDM() {
|
|
172
|
-
// Erase Displayed Memory
|
|
173
|
-
this.logger.log(VerboseLevel.INFO, 'EDM - Erase Displayed Memory');
|
|
174
|
-
this.displayedMemory.reset();
|
|
175
|
-
this.outputDataUpdate(true);
|
|
176
|
-
}
|
|
177
|
-
ccCR() {
|
|
178
|
-
// Carriage Return
|
|
179
|
-
this.logger.log(VerboseLevel.INFO, 'CR - Carriage Return');
|
|
180
|
-
this.writeScreen.rollUp();
|
|
181
|
-
this.outputDataUpdate(true);
|
|
182
|
-
}
|
|
183
|
-
ccENM() {
|
|
184
|
-
// Erase Non-Displayed Memory
|
|
185
|
-
this.logger.log(VerboseLevel.INFO, 'ENM - Erase Non-displayed Memory');
|
|
186
|
-
this.nonDisplayedMemory.reset();
|
|
187
|
-
}
|
|
188
|
-
ccEOC() {
|
|
189
|
-
// End of Caption (Flip Memories)
|
|
190
|
-
this.logger.log(VerboseLevel.INFO, 'EOC - End Of Caption');
|
|
191
|
-
if (this.mode === 'MODE_POP-ON') {
|
|
192
|
-
const tmp = this.displayedMemory;
|
|
193
|
-
this.displayedMemory = this.nonDisplayedMemory;
|
|
194
|
-
this.nonDisplayedMemory = tmp;
|
|
195
|
-
this.writeScreen = this.nonDisplayedMemory;
|
|
196
|
-
this.logger.log(VerboseLevel.TEXT, () => 'DISP: ' + this.displayedMemory.getDisplayText());
|
|
197
|
-
}
|
|
198
|
-
this.outputDataUpdate(true);
|
|
199
|
-
}
|
|
200
|
-
ccTO(nrCols) {
|
|
201
|
-
// Tab Offset 1,2, or 3 columns
|
|
202
|
-
this.logger.log(VerboseLevel.INFO, 'TO(' + nrCols + ') - Tab Offset');
|
|
203
|
-
this.writeScreen.moveCursor(nrCols);
|
|
204
|
-
}
|
|
205
|
-
ccMIDROW(secondByte) {
|
|
206
|
-
// Parse MIDROW command
|
|
207
|
-
const styles = { flash: false };
|
|
208
|
-
styles.underline = secondByte % 2 === 1;
|
|
209
|
-
styles.italics = secondByte >= 0x2e;
|
|
210
|
-
if (!styles.italics) {
|
|
211
|
-
const colorIndex = Math.floor(secondByte / 2) - 0x10;
|
|
212
|
-
const colors = [
|
|
213
|
-
'white',
|
|
214
|
-
'green',
|
|
215
|
-
'blue',
|
|
216
|
-
'cyan',
|
|
217
|
-
'red',
|
|
218
|
-
'yellow',
|
|
219
|
-
'magenta',
|
|
220
|
-
];
|
|
221
|
-
styles.foreground = colors[colorIndex];
|
|
222
|
-
}
|
|
223
|
-
else {
|
|
224
|
-
styles.foreground = 'white';
|
|
225
|
-
}
|
|
226
|
-
this.logger.log(VerboseLevel.INFO, 'MIDROW: ' + JSON.stringify(styles));
|
|
227
|
-
this.writeScreen.setPen(styles);
|
|
228
|
-
}
|
|
229
|
-
outputDataUpdate(dispatch = false) {
|
|
230
|
-
const time = this.logger.time;
|
|
231
|
-
if (time === null) {
|
|
232
|
-
return;
|
|
233
|
-
}
|
|
234
|
-
if (this.outputFilter) {
|
|
235
|
-
if (this.cueStartTime === null && !this.displayedMemory.isEmpty()) {
|
|
236
|
-
// Start of a new cue
|
|
237
|
-
this.cueStartTime = time;
|
|
238
|
-
}
|
|
239
|
-
else {
|
|
240
|
-
if (!this.displayedMemory.equals(this.lastOutputScreen)) {
|
|
241
|
-
this.outputFilter.newCue(this.cueStartTime, time, this.lastOutputScreen);
|
|
242
|
-
if (dispatch && this.outputFilter.dispatchCue) {
|
|
243
|
-
this.outputFilter.dispatchCue();
|
|
244
|
-
}
|
|
245
|
-
this.cueStartTime = this.displayedMemory.isEmpty() ? null : time;
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
this.lastOutputScreen.copy(this.displayedMemory);
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
cueSplitAtTime(t) {
|
|
252
|
-
if (this.outputFilter) {
|
|
253
|
-
if (!this.displayedMemory.isEmpty()) {
|
|
254
|
-
if (this.outputFilter.newCue) {
|
|
255
|
-
this.outputFilter.newCue(this.cueStartTime, t, this.displayedMemory);
|
|
256
|
-
}
|
|
257
|
-
this.cueStartTime = t;
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
//# sourceMappingURL=Cta608Channel.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Cta608Channel.js","sourceRoot":"","sources":["../src/Cta608Channel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAKrD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C;;;;GAIG;AACH,MAAM,OAAO,aAAa;IAazB,YACC,aAAqB,EACrB,YAAwB,EACxB,SAAyB,IAAI,cAAc,EAAE;QAE7C,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,eAAe,GAAG,IAAI,aAAa,CAAC,MAAM,CAAC,CAAC;QACjD,IAAI,CAAC,kBAAkB,GAAG,IAAI,aAAa,CAAC,MAAM,CAAC,CAAC;QACpD,IAAI,CAAC,gBAAgB,GAAG,IAAI,aAAa,CAAC,MAAM,CAAC,CAAC;QAClD,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC;QAC5D,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,eAAe,CAAC;QACxC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,YAAY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,CAAC;wBAC/C,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,CAAC;oBACjC,CAAC;oBAED,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;gBAClE,CAAC;YACF,CAAC;YACD,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QAClD,CAAC;IACF,CAAC;IAED,cAAc,CAAC,CAAS;QACvB,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACvB,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,EAAE,CAAC;gBACrC,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC;oBAC9B,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,YAAa,EAAE,CAAC,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;gBACvE,CAAC;gBAED,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC;YACvB,CAAC;QACF,CAAC;IACF,CAAC;CACD","sourcesContent":["/**\n *\n * This code was ported from the dash.js project at:\n * https://github.com/Dash-Industry-Forum/dash.js/blob/development/externals/cea608-parser.js\n * https://github.com/Dash-Industry-Forum/dash.js/commit/8269b26a761e0853bb21d78780ed945144ecdd4d#diff-71bc295a2d6b6b7093a1d3290d53a4b2\n *\n * The original copyright appears below:\n *\n * The copyright in this software is being made available under the BSD License,\n * included below. This software may be subject to other third party and contributor\n * rights, including patent rights, and no such rights are granted under this license.\n *\n * Copyright (c) 2015-2016, DASH Industry Forum.\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without modification,\n * are permitted provided that the following conditions are met:\n * 1. Redistributions of source code must retain the above copyright notice, this\n * list of conditions and the following disclaimer.\n * * Redistributions in binary form must reproduce the above copyright notice,\n * this list of conditions and the following disclaimer in the documentation and/or\n * other materials provided with the distribution.\n * 2. Neither the name of Dash Industry Forum nor the names of its\n * contributors may be used to endorse or promote products derived from this software\n * without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY\n * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\n * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,\n * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n * POSSIBILITY OF SUCH DAMAGE.\n */\n\nimport type { CaptionModes } from './CaptionModes.js';\nimport { CaptionScreen } from './CaptionScreen.js';\nimport { CaptionsLogger } from './CaptionsLogger.js';\nimport type { CueHandler } from './CueHandler.js';\nimport type { PACData } from './PACData.js';\nimport type { PenStyles } from './PenStyles.js';\nimport type { Row } from './Row.js';\nimport { VerboseLevel } from './VerboseLevel.js';\nimport { NR_ROWS } from './utils/NR_ROWS.js';\n\n/**\n * CTA-608 Channel\n *\n * @beta\n */\nexport class Cta608Channel {\n\tchNr: number;\n\toutputFilter: CueHandler;\n\tmode: CaptionModes;\n\tdisplayedMemory: CaptionScreen;\n\tnonDisplayedMemory: CaptionScreen;\n\tlastOutputScreen: CaptionScreen;\n\tcurrRollUpRow: Row;\n\twriteScreen: CaptionScreen;\n\tcueStartTime: number | null;\n\n\tprivate logger: CaptionsLogger;\n\n\tconstructor(\n\t\tchannelNumber: number,\n\t\toutputFilter: CueHandler,\n\t\tlogger: CaptionsLogger = new CaptionsLogger(),\n\t) {\n\t\tthis.chNr = channelNumber;\n\t\tthis.outputFilter = outputFilter;\n\t\tthis.mode = null;\n\t\tthis.displayedMemory = new CaptionScreen(logger);\n\t\tthis.nonDisplayedMemory = new CaptionScreen(logger);\n\t\tthis.lastOutputScreen = new CaptionScreen(logger);\n\t\tthis.currRollUpRow = this.displayedMemory.rows[NR_ROWS - 1];\n\t\tthis.writeScreen = this.displayedMemory;\n\t\tthis.mode = null;\n\t\tthis.cueStartTime = null; // Keeps track of where a cue started.\n\t\tthis.logger = logger;\n\n\t\tthis.logger.log(VerboseLevel.INFO, 'new Cea608Channel(' + this.chNr + ')');\n\t}\n\n\treset(): void {\n\t\tthis.mode = null;\n\t\tthis.displayedMemory.reset();\n\t\tthis.nonDisplayedMemory.reset();\n\t\tthis.lastOutputScreen.reset();\n\t\tthis.outputFilter?.reset?.();\n\t\tthis.currRollUpRow = this.displayedMemory.rows[NR_ROWS - 1];\n\t\tthis.writeScreen = this.displayedMemory;\n\t\tthis.mode = null;\n\t\tthis.cueStartTime = null;\n\t}\n\n\tgetHandler(): CueHandler {\n\t\treturn this.outputFilter;\n\t}\n\n\tsetHandler(outputFilter: CueHandler): void {\n\t\tthis.outputFilter = outputFilter;\n\t}\n\n\tsetPAC(pacData: PACData): void {\n\t\tthis.writeScreen.setPAC(pacData);\n\t}\n\n\tsetBkgData(bkgData: Partial<PenStyles>): void {\n\t\tthis.writeScreen.setBkgData(bkgData);\n\t}\n\n\tsetMode(newMode: CaptionModes): void {\n\t\tif (newMode === this.mode) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.mode = newMode;\n\t\tthis.logger.log(VerboseLevel.INFO, () => 'MODE=' + newMode);\n\t\tif (this.mode === 'MODE_POP-ON') {\n\t\t\tthis.writeScreen = this.nonDisplayedMemory;\n\t\t}\n\t\telse {\n\t\t\tthis.writeScreen = this.displayedMemory;\n\t\t\tthis.writeScreen.reset();\n\t\t}\n\t\tif (this.mode !== 'MODE_ROLL-UP') {\n\t\t\tthis.displayedMemory.setRollUpRows(null);\n\t\t\tthis.nonDisplayedMemory.setRollUpRows(null);\n\t\t}\n\t\tthis.mode = newMode;\n\t}\n\n\tinsertChars(chars: number[]): void {\n\t\tfor (let i = 0; i < chars.length; i++) {\n\t\t\tthis.writeScreen.insertChar(chars[i]);\n\t\t}\n\n\t\tconst screen =\n\t\t\tthis.writeScreen === this.displayedMemory ? 'DISP' : 'NON_DISP';\n\t\tthis.logger.log(\n\t\t\tVerboseLevel.INFO,\n\t\t\t() => screen + ': ' + this.writeScreen.getDisplayText(true),\n\t\t);\n\t\tif (this.mode === 'MODE_PAINT-ON' || this.mode === 'MODE_ROLL-UP') {\n\t\t\tthis.logger.log(\n\t\t\t\tVerboseLevel.TEXT,\n\t\t\t\t() => 'DISPLAYED: ' + this.displayedMemory.getDisplayText(true),\n\t\t\t);\n\t\t\tthis.outputDataUpdate();\n\t\t}\n\t}\n\n\tccRCL(): void {\n\t\t// Resume Caption Loading (switch mode to Pop On)\n\t\tthis.logger.log(VerboseLevel.INFO, 'RCL - Resume Caption Loading');\n\t\tthis.setMode('MODE_POP-ON');\n\t}\n\n\tccBS(): void {\n\t\t// BackSpace\n\t\tthis.logger.log(VerboseLevel.INFO, 'BS - BackSpace');\n\t\tif (this.mode === 'MODE_TEXT') {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.writeScreen.backSpace();\n\t\tif (this.writeScreen === this.displayedMemory) {\n\t\t\tthis.outputDataUpdate();\n\t\t}\n\t}\n\n\tccAOF(): void {\n\t\t// Reserved (formerly Alarm Off)\n\t}\n\n\tccAON(): void {\n\t\t// Reserved (formerly Alarm On)\n\t}\n\n\tccDER(): void {\n\t\t// Delete to End of Row\n\t\tthis.logger.log(VerboseLevel.INFO, 'DER- Delete to End of Row');\n\t\tthis.writeScreen.clearToEndOfRow();\n\t\tthis.outputDataUpdate();\n\t}\n\n\tccRU(nrRows: number | null): void {\n\t\t// Roll-Up Captions-2,3,or 4 Rows\n\t\tthis.logger.log(VerboseLevel.INFO, 'RU(' + nrRows + ') - Roll Up');\n\t\tthis.writeScreen = this.displayedMemory;\n\t\tthis.setMode('MODE_ROLL-UP');\n\t\tthis.writeScreen.setRollUpRows(nrRows);\n\t}\n\n\tccFON(): void {\n\t\t// Flash On\n\t\tthis.logger.log(VerboseLevel.INFO, 'FON - Flash On');\n\t\tthis.writeScreen.setPen({ flash: true });\n\t}\n\n\tccRDC(): void {\n\t\t// Resume Direct Captioning (switch mode to PaintOn)\n\t\tthis.logger.log(VerboseLevel.INFO, 'RDC - Resume Direct Captioning');\n\t\tthis.setMode('MODE_PAINT-ON');\n\t}\n\n\tccTR(): void {\n\t\t// Text Restart in text mode (not supported, however)\n\t\tthis.logger.log(VerboseLevel.INFO, 'TR');\n\t\tthis.setMode('MODE_TEXT');\n\t}\n\n\tccRTD(): void {\n\t\t// Resume Text Display in Text mode (not supported, however)\n\t\tthis.logger.log(VerboseLevel.INFO, 'RTD');\n\t\tthis.setMode('MODE_TEXT');\n\t}\n\n\tccEDM(): void {\n\t\t// Erase Displayed Memory\n\t\tthis.logger.log(VerboseLevel.INFO, 'EDM - Erase Displayed Memory');\n\t\tthis.displayedMemory.reset();\n\t\tthis.outputDataUpdate(true);\n\t}\n\n\tccCR(): void {\n\t\t// Carriage Return\n\t\tthis.logger.log(VerboseLevel.INFO, 'CR - Carriage Return');\n\t\tthis.writeScreen.rollUp();\n\t\tthis.outputDataUpdate(true);\n\t}\n\n\tccENM(): void {\n\t\t// Erase Non-Displayed Memory\n\t\tthis.logger.log(VerboseLevel.INFO, 'ENM - Erase Non-displayed Memory');\n\t\tthis.nonDisplayedMemory.reset();\n\t}\n\n\tccEOC(): void {\n\t\t// End of Caption (Flip Memories)\n\t\tthis.logger.log(VerboseLevel.INFO, 'EOC - End Of Caption');\n\t\tif (this.mode === 'MODE_POP-ON') {\n\t\t\tconst tmp = this.displayedMemory;\n\t\t\tthis.displayedMemory = this.nonDisplayedMemory;\n\t\t\tthis.nonDisplayedMemory = tmp;\n\t\t\tthis.writeScreen = this.nonDisplayedMemory;\n\t\t\tthis.logger.log(\n\t\t\t\tVerboseLevel.TEXT,\n\t\t\t\t() => 'DISP: ' + this.displayedMemory.getDisplayText(),\n\t\t\t);\n\t\t}\n\t\tthis.outputDataUpdate(true);\n\t}\n\n\tccTO(nrCols: number): void {\n\t\t// Tab Offset 1,2, or 3 columns\n\t\tthis.logger.log(VerboseLevel.INFO, 'TO(' + nrCols + ') - Tab Offset');\n\t\tthis.writeScreen.moveCursor(nrCols);\n\t}\n\n\tccMIDROW(secondByte: number): void {\n\t\t// Parse MIDROW command\n\t\tconst styles: Partial<PenStyles> = { flash: false };\n\t\tstyles.underline = secondByte % 2 === 1;\n\t\tstyles.italics = secondByte >= 0x2e;\n\t\tif (!styles.italics) {\n\t\t\tconst colorIndex = Math.floor(secondByte / 2) - 0x10;\n\t\t\tconst colors = [\n\t\t\t\t'white',\n\t\t\t\t'green',\n\t\t\t\t'blue',\n\t\t\t\t'cyan',\n\t\t\t\t'red',\n\t\t\t\t'yellow',\n\t\t\t\t'magenta',\n\t\t\t];\n\t\t\tstyles.foreground = colors[colorIndex];\n\t\t}\n\t\telse {\n\t\t\tstyles.foreground = 'white';\n\t\t}\n\t\tthis.logger.log(VerboseLevel.INFO, 'MIDROW: ' + JSON.stringify(styles));\n\t\tthis.writeScreen.setPen(styles);\n\t}\n\n\toutputDataUpdate(dispatch: boolean = false): void {\n\t\tconst time = this.logger.time;\n\t\tif (time === null) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.outputFilter) {\n\t\t\tif (this.cueStartTime === null && !this.displayedMemory.isEmpty()) {\n\t\t\t\t// Start of a new cue\n\t\t\t\tthis.cueStartTime = time;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (!this.displayedMemory.equals(this.lastOutputScreen)) {\n\t\t\t\t\tthis.outputFilter.newCue(\n\t\t\t\t\t\tthis.cueStartTime!,\n\t\t\t\t\t\ttime,\n\t\t\t\t\t\tthis.lastOutputScreen,\n\t\t\t\t\t);\n\t\t\t\t\tif (dispatch && this.outputFilter.dispatchCue) {\n\t\t\t\t\t\tthis.outputFilter.dispatchCue();\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.cueStartTime = this.displayedMemory.isEmpty() ? null : time;\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.lastOutputScreen.copy(this.displayedMemory);\n\t\t}\n\t}\n\n\tcueSplitAtTime(t: number): void {\n\t\tif (this.outputFilter) {\n\t\t\tif (!this.displayedMemory.isEmpty()) {\n\t\t\t\tif (this.outputFilter.newCue) {\n\t\t\t\t\tthis.outputFilter.newCue(this.cueStartTime!, t, this.displayedMemory);\n\t\t\t\t}\n\n\t\t\t\tthis.cueStartTime = t;\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
|
package/dist/Cta608Parser.d.ts
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* This code was ported from the dash.js project at:
|
|
4
|
-
* https://github.com/Dash-Industry-Forum/dash.js/blob/development/externals/cea608-parser.js
|
|
5
|
-
* https://github.com/Dash-Industry-Forum/dash.js/commit/8269b26a761e0853bb21d78780ed945144ecdd4d#diff-71bc295a2d6b6b7093a1d3290d53a4b2
|
|
6
|
-
*
|
|
7
|
-
* The original copyright appears below:
|
|
8
|
-
*
|
|
9
|
-
* The copyright in this software is being made available under the BSD License,
|
|
10
|
-
* included below. This software may be subject to other third party and contributor
|
|
11
|
-
* rights, including patent rights, and no such rights are granted under this license.
|
|
12
|
-
*
|
|
13
|
-
* Copyright (c) 2015-2016, DASH Industry Forum.
|
|
14
|
-
* All rights reserved.
|
|
15
|
-
*
|
|
16
|
-
* Redistribution and use in source and binary forms, with or without modification,
|
|
17
|
-
* are permitted provided that the following conditions are met:
|
|
18
|
-
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
19
|
-
* list of conditions and the following disclaimer.
|
|
20
|
-
* * Redistributions in binary form must reproduce the above copyright notice,
|
|
21
|
-
* this list of conditions and the following disclaimer in the documentation and/or
|
|
22
|
-
* other materials provided with the distribution.
|
|
23
|
-
* 2. Neither the name of Dash Industry Forum nor the names of its
|
|
24
|
-
* contributors may be used to endorse or promote products derived from this software
|
|
25
|
-
* without specific prior written permission.
|
|
26
|
-
*
|
|
27
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY
|
|
28
|
-
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
29
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
30
|
-
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
|
31
|
-
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
32
|
-
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
33
|
-
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
34
|
-
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
35
|
-
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
36
|
-
* POSSIBILITY OF SUCH DAMAGE.
|
|
37
|
-
*/
|
|
38
|
-
import type { SupportedField } from './SupportedField.js';
|
|
39
|
-
/**
|
|
40
|
-
* CEA-608 caption parser.
|
|
41
|
-
*
|
|
42
|
-
* @beta
|
|
43
|
-
*/
|
|
44
|
-
export declare class Cta608Parser {
|
|
45
|
-
private channels;
|
|
46
|
-
private currentChannel;
|
|
47
|
-
private cmdHistory;
|
|
48
|
-
private logger;
|
|
49
|
-
private lastTime;
|
|
50
|
-
constructor(field: SupportedField, out1: any, out2: any);
|
|
51
|
-
/**
|
|
52
|
-
* Add data for time t in forms of list of bytes (unsigned ints). The bytes are treated as pairs.
|
|
53
|
-
*
|
|
54
|
-
* @param time - The time in milliseconds
|
|
55
|
-
* @param byteList - The list of bytes
|
|
56
|
-
*/
|
|
57
|
-
addData(time: number | null, byteList: number[]): void;
|
|
58
|
-
/**
|
|
59
|
-
* Parse Command.
|
|
60
|
-
*
|
|
61
|
-
* @param a - The first byte
|
|
62
|
-
* @param b - The second byte
|
|
63
|
-
* @returns True if a command was found
|
|
64
|
-
*/
|
|
65
|
-
private parseCmd;
|
|
66
|
-
/**
|
|
67
|
-
* Parse midrow styling command
|
|
68
|
-
*
|
|
69
|
-
* @param a - The first byte
|
|
70
|
-
* @param b - The second byte
|
|
71
|
-
* @returns `true` if midrow styling command was found
|
|
72
|
-
*/
|
|
73
|
-
private parseMidrow;
|
|
74
|
-
/**
|
|
75
|
-
* Parse Preable Access Codes (Table 53).
|
|
76
|
-
*
|
|
77
|
-
* @param a - The first byte
|
|
78
|
-
* @param b - The second byte
|
|
79
|
-
* @returns A Boolean that tells if PAC found
|
|
80
|
-
*/
|
|
81
|
-
private parsePAC;
|
|
82
|
-
/**
|
|
83
|
-
* Interpret the second byte of the pac, and return the information.
|
|
84
|
-
*
|
|
85
|
-
* @param row - The row number
|
|
86
|
-
* @param byte - The second byte
|
|
87
|
-
* @returns pacData with style parameters
|
|
88
|
-
*/
|
|
89
|
-
private interpretPAC;
|
|
90
|
-
/**
|
|
91
|
-
* Parse characters.
|
|
92
|
-
*
|
|
93
|
-
* @param a - The first byte
|
|
94
|
-
* @param b - The second byte
|
|
95
|
-
* @returns An array with 1 to 2 codes corresponding to chars, if found. null otherwise.
|
|
96
|
-
*/
|
|
97
|
-
private parseChars;
|
|
98
|
-
/**
|
|
99
|
-
* Parse extended background attributes as well as new foreground color black.
|
|
100
|
-
*
|
|
101
|
-
* @param a - The first byte
|
|
102
|
-
* @param b - The second byte
|
|
103
|
-
* @returns True if background attributes are found
|
|
104
|
-
*/
|
|
105
|
-
private parseBackgroundAttributes;
|
|
106
|
-
/**
|
|
107
|
-
* Reset state of parser and its channels.
|
|
108
|
-
*/
|
|
109
|
-
reset(): void;
|
|
110
|
-
/**
|
|
111
|
-
* Trigger the generation of a cue, and the start of a new one if displayScreens are not empty.
|
|
112
|
-
*/
|
|
113
|
-
cueSplitAtTime(t: number): void;
|
|
114
|
-
}
|
|
115
|
-
//# sourceMappingURL=Cta608Parser.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Cta608Parser.d.ts","sourceRoot":"","sources":["../src/Cta608Parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAQH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAa1D;;;;GAIG;AACH,qBAAa,YAAY;IACxB,OAAO,CAAC,QAAQ,CAA8B;IAC9C,OAAO,CAAC,cAAc,CAAe;IACrC,OAAO,CAAC,UAAU,CAAkC;IACpD,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,QAAQ,CAAuB;gBAE3B,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG;IASvD;;;;;OAKG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI;IA8FtD;;;;;;OAMG;IACH,OAAO,CAAC,QAAQ;IAyEhB;;;;;;OAMG;IACH,OAAO,CAAC,WAAW;IAgCnB;;;;;;OAMG;IACH,OAAO,CAAC,QAAQ;IA8BhB;;;;;;OAMG;IACH,OAAO,CAAC,YAAY;IAwCpB;;;;;;OAMG;IACH,OAAO,CAAC,UAAU;IAgDlB;;;;;;OAMG;IACH,OAAO,CAAC,yBAAyB;IA8BjC;;OAEG;IACH,KAAK,IAAI,IAAI;IAUb;;OAEG;IACH,cAAc,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;CAQ/B"}
|