AJA NTV2 SDK  17.5.0.1242
NTV2 SDK 17.5.0.1242
ntv2captiondecodechannel608.h
Go to the documentation of this file.
1 
7 #ifndef __NTV2_CEA608_DECODECHANNEL_
8 #define __NTV2_CEA608_DECODECHANNEL_
9 
10 #include "ntv2captionlogging.h"
11 #include "ntv2caption608types.h"
13 #include "ajabase/system/lock.h"
14 #include <vector>
15 
16 #ifdef MSWindows
17  #include "windows.h"
18  #include "stdio.h"
19 #endif
20 
21 
26 {
39 
40 
41 
63 
65 {
66  // CLASS METHODS
67  public:
73  static bool Create (CNTV2CaptionDecodeChannel608Ptr & outInstance);
74 
75 
76  // INSTANCE METHODS
77  public:
81 
86  virtual void Reset (void);
87 
93  virtual bool SetChannel (const NTV2Line21Channel inNewChannel);
94 
99  virtual inline bool IsTextChannel (void) const {return IsLine21TextChannel (mChannel);}
100 
105  virtual inline NTV2Line21CharacterSet GetCurrentCharacterSet (void) const {return mCharacterSet;}
106 
107  virtual NTV2Line21Channel GetCurrentChannel (UByte char608_1, UByte char608_2, NTV2Line21Field field);
109 
113 
124  virtual bool Parse608Data (const UByte inByte1, const UByte inByte2, std::string & outDebugStr);
125 
130  virtual inline UWord GetRow (void) const {return mRow;}
131 
136  virtual inline UWord GetColumn (void) const {return mCol;}
138 
142 
150  virtual UByte GetOnAirCharacter (const UWord inRow, const UWord inCol, NTV2Line21Attrs & outAttr) const;
151 
160  virtual std::string GetOnAirCharacter (const UWord inRow, const UWord inCol) const;
161 
171  virtual std::string GetOnAirCharacterWithAttributes (const UWord inRow, const UWord inCol, NTV2Line21Attrs & outAttr) const;
172 
180  virtual UWord GetOnAirUTF16CharacterWithAttributes (const UWord inRow, const UWord inCol, NTV2Line21Attrs & outAttr) const;
181 
188  virtual NTV2Line21CharacterSet GetOnAirCharacterSet (const UWord inRow, const UWord inCol) const;
189 
190  virtual bool GetCharacterAttributes (const UWord screen, const UWord inRow, const UWord inCol, NTV2Line21Attrs & outAttr) const;
192 
196 
201  virtual inline UWord GetTextModeDisplayRowCount (void) const {return mTextRows;}
202 
209  virtual bool SetTextModeDisplayRowCount (const UWord inNumRows);
210 
216  virtual inline const NTV2Line21Attrs & GetTextModeDisplayAttributes (void) const {return mTextModeStyle;}
217 
223  virtual inline void SetTextModeDisplayAttributes (const NTV2Line21Attrs & inAttributes) {mTextModeStyle = inAttributes;}
225 
229  virtual std::string GetDebugPrintRow (const UWord inRow, const bool inShowChars = true) const;
231  virtual std::string GetDebugPrintScreen (const bool inShowChars = true) const;
232  virtual void SetDebugRowsOfInterest (const UWord inFromRow, const UWord inToRow, const bool inAdd = false);
233  virtual void SetDebugColumnsOfInterest (const UWord inFromCol, const UWord inToCol, const bool inAdd = false);
235 
236  virtual ~CNTV2CaptionDecodeChannel608 ();
237 
238  virtual std::vector<uint32_t> GetStats(void) const;
239  static std::string GetStatTitle(const CaptionDecode608Stats inStat);
240  virtual bool SubscribeChangeNotification (NTV2Caption608Changed * pInCallback, void * pInUserData = NULL);
241  virtual bool UnsubscribeChangeNotification (NTV2Caption608Changed * pInCallback, void * pInUserData = NULL);
242 
243 
244  // PROTECTED INSTANCE METHODS
245  protected:
246  virtual bool Parse608CharacterData (UByte char608_1, UByte char608_2, std::string & outDebugStr);
247  virtual bool Parse608TabOffsetCommand (UByte char608_1, UByte char608_2, std::string & outDebugStr);
248  virtual bool Parse608CharacterSetCommand (UByte char608_1, UByte char608_2, std::string & outDebugStr);
249  virtual bool Parse608AttributeCommand (UByte char608_1, UByte char608_2, std::string & outDebugStr);
250  virtual bool Parse608PACCommand (UByte char608_1, UByte char608_2, std::string & outDebugStr);
251  virtual bool Parse608MidRowCommand (UByte char608_1, UByte char608_2, std::string & outDebugStr);
252  virtual bool Parse608SpecialCharacter (UByte char608_1, UByte char608_2, std::string & outDebugStr);
253  virtual bool Parse608MiscCommand (UByte char608_1, UByte char608_2, std::string & outDebugStr);
254 
255  virtual bool DoResumeCaptionLoading (void);
256  virtual bool DoBackspace (void);
257  virtual bool DoDeleteToEndOfRow (void);
258  virtual bool DoRollUpCaption (const UWord inRows);
259  virtual bool DoFlashOn (void);
260  virtual bool DoResumeDirectCaptioning (void);
261  virtual bool DoTextRestart (void);
262  virtual bool DoResumeTextDisplay (void);
263  virtual bool DoEraseDisplayedMemory (void);
264  virtual bool DoCarriageReturn (void);
265  virtual bool DoEraseNonDisplayedMemory (void);
266  virtual bool DoEndOfCaption (void);
267 
268  private:
269  // Low-level back buffer accessors
270  virtual bool SetScreenCharacter (const UWord inScreenNum, const UWord inRow, const UWord inCol, const NTV2_CC608_CodePoint inNewCodePoint);
271  virtual NTV2_CC608_CodePoint GetScreenCharacter (const UWord inScreenNum, const UWord inRow, const UWord inCol) const;
272  virtual bool SetScreenAttributes (const UWord inScreenNum, const UWord inRow, const UWord inCol, const NTV2Line21Attrs inAttr);
273  virtual NTV2Line21Attrs GetScreenAttributes (const UWord inScreenNum, const UWord inRow, const UWord inCol) const;
274 
275  protected:
276  // Higher-level accessors
277  virtual void SetAttributes (const UWord inRow, const UWord inCol, const NTV2Line21Attrs inAttr);
278  virtual bool EraseScreen (const UWord screen);
279 
280  virtual bool SetRow (const UWord inNewRow);
281  virtual bool IncrementRow (const int inDelta = 1);
282 
283  virtual bool SetColumn (const UWord inNewCol);
284  virtual bool IncrementColumn (const int inDelta = 1);
285 
286  virtual bool SetCaptionMode (const NTV2Line21Mode inNewCaptionMode);
287  virtual inline NTV2Line21Mode GetCaptionMode (void) const {return mCaptionMode;}
288 
289  virtual inline UWord GetCurrentScreen (void) const {return mCurrScreen;}
290  virtual bool SetCurrentScreen (const UWord inNewScreen);
291 
292  virtual void MoveRollUpWindow (const UWord inNewBaseRow);
293 
294  virtual void InsertCharacter (const UByte char608_1, const UByte char608_2, const NTV2Line21Attrs inAttr);
295  virtual void InsertCharacter (const UByte char608_1, const UByte char608_2);
296  virtual void InsertTextCharacter (const UByte inASCIIChar);
297 
298  // Someday we may want to signal interested third parties when my state changes:
299  virtual void Notify_ChannelChanged (const NTV2Line21Channel inOldChannel, const NTV2Line21Channel inNewChannel) const;
300  virtual void Notify_CurrentRowChanged (const UWord inOldRow, const UWord inNewRow) const;
301  virtual void Notify_CurrentColumnChanged (const UWord inOldCol, const UWord inNewCol) const;
302  virtual void Notify_CurrentScreenChanged (const UWord inOldScreen, const UWord inNewScreen) const;
303  virtual void Notify_CaptionModeChanged (const NTV2Line21Mode inOldMode, const NTV2Line21Mode inNewMode) const;
304  virtual void Notify_ScreenCharChanged (const UWord inScreenNum, const UWord inRow, const UWord inCol,
305  const NTV2_CC608_CodePoint inOldCodePoint, const NTV2_CC608_CodePoint inNewCodePoint) const;
306  virtual void Notify_ScreenAttrChanged (const UWord inScreenNum, const UWord inRow, const UWord inCol,
307  const NTV2Line21Attrs & inOldAttr, const NTV2Line21Attrs & inNewAttr) const;
308 
309 
310  // PRIVATE INSTANCE METHODS
311  protected:
313  explicit CNTV2CaptionDecodeChannel608 (); // Hidden constructor
314  private:
316  virtual CNTV2CaptionDecodeChannel608 & operator = (const CNTV2CaptionDecodeChannel608 & inObj);
317 
318 
319  // INSTANCE DATA
320  private:
323  mutable void * mpScreenLock;
326  UWord mCurrScreen;
327  UWord mRow;
328  UWord mCol;
329  UWord mRollBaseRow;
330  UWord mTextRows;
331  NTV2Line21Attrs mTextModeStyle;
332  NTV2Line21Mode mCaptionMode;
333  NTV2Line21Channel mChannel;
334  NTV2Line21CharSet mCharacterSet;
335 
336  // Debugging/logging:
337  Line21RowSet mDebugRows;
338  Line21ColumnSet mDebugCols;
339 
340  NTV2Caption608Changed * mpCallback;
341  void * mpUserData;
342 
343  // Stats
344  std::vector<uint32_t> mStats;
345  mutable AJALock mStatsLock;
346 
347  public: // BACK-BUFFER TEST MODE
348  static bool sStaticBackBufferTestMode; // Defaults to false.
349  // To test me with static back-buffers, set sStaticBackBufferTestMode
350  // true, then call Reset, then operate me normally.
351  // In this mode, GetScreenCharacter and GetScreenAttributes will always
352  // return the fixed test pattern that's set in my constructor.
353 
354 #if defined(AJA_DEBUG) // DEBUG BUILDS ONLY: ClassTest and InstanceTest
355  static bool ClassTest (void); // ClassTest: Implementation in libajacc/test/main.cpp
356  bool InstanceTest (void); // InstanceTest: Implementation in libajacc/test/main.cpp
357 #endif // AJA_DEBUG
358 
359 }; // CNTV2CaptionDecodeChannel608
360 
361 
362 AJA_EXPORT bool Check608Parity (UByte char608_1, UByte char608_2, std::string & outDebugStr);
364 
365 #endif // __NTV2_CEA608_DECODECHANNEL_
ntv2caption608types.h
Declares several data types used with 608/SD captioning.
CNTV2CaptionDecodeChannel608::SetTextModeDisplayAttributes
virtual void SetTextModeDisplayAttributes(const NTV2Line21Attrs &inAttributes)
Sets the display attributes that Text Mode captions will use henceforth.
Definition: ntv2captiondecodechannel608.h:223
NULL
#define NULL
Definition: ntv2caption608types.h:19
AJARefPtr
I am a reference-counted pointer template class. I am intended to be a proxy for an underlying object...
Definition: ajarefptr.h:89
AJA_EXPORT
#define AJA_EXPORT
Definition: export.h:34
kTotalMidRowCmds
@ kTotalMidRowCmds
Total Mid-Row commands parsed (color, underline, italic, flash, etc.)
Definition: ntv2captiondecodechannel608.h:34
kMaxTallies
@ kMaxTallies
Definition: ntv2captiondecodechannel608.h:37
CNTV2CaptionDecodeChannel608::GetCaptionMode
virtual NTV2Line21Mode GetCaptionMode(void) const
Definition: ntv2captiondecodechannel608.h:287
kTotalMiscCmds
@ kTotalMiscCmds
Total Misc commands parsed (RollUp, FlashOn, RCL, BS, EDM, EOC, etc.)
Definition: ntv2captiondecodechannel608.h:32
Line21ColumnSet
Line21RowSet Line21ColumnSet
A set of caption column numbers.
Definition: ntv2captionlogging.h:56
CNTV2CaptionDecodeChannel608::sStaticBackBufferTestMode
static bool sStaticBackBufferTestMode
Definition: ntv2captiondecodechannel608.h:348
CNTV2CaptionDecodeChannel608::GetCurrentScreen
virtual UWord GetCurrentScreen(void) const
Definition: ntv2captiondecodechannel608.h:289
CaptionDecode608Stats
enum _CaptionDecode608Stats CaptionDecode608Stats
The currently supported caption decoder stats.
CNTV2CaptionDecodeChannel608::GetColumn
virtual UWord GetColumn(void) const
Answers with the column at which the next caption character will be inserted.
Definition: ntv2captiondecodechannel608.h:136
CNTV2CaptionDecodeChannel608
Definition: ntv2captiondecodechannel608.h:64
Line21RowSet
std::set< int > Line21RowSet
A set of caption row numbers.
Definition: ntv2captionlogging.h:55
lock.h
Declares the AJALock class.
Check608Parity
bool Check608Parity(UByte char608_1, UByte char608_2, std::string &outDebugStr)
CNTV2CaptionDecodeChannel608::GetCurrentCharacterSet
virtual NTV2Line21CharacterSet GetCurrentCharacterSet(void) const
Answers with my current character set.
Definition: ntv2captiondecodechannel608.h:105
_CaptionDecode608Stats
_CaptionDecode608Stats
The currently supported caption decoder stats.
Definition: ntv2captiondecodechannel608.h:25
NTV2Line21CharSet
enum NTV2Line21CharacterSet NTV2Line21CharSet
CNTV2CaptionDecodeChannel608::NTV2CC608CodePoint
NTV2_CC608_CodePoint NTV2CC608CodePoint
Definition: ntv2captiondecodechannel608.h:312
kParsedOKTally
@ kParsedOKTally
Total Parse608Data successes.
Definition: ntv2captiondecodechannel608.h:27
kTotalCharData
@ kTotalCharData
Total plain ol' characters parsed.
Definition: ntv2captiondecodechannel608.h:36
UWord
uint16_t UWord
Definition: ajatypes.h:253
Add608OddParity
UByte Add608OddParity(UByte ch)
kTotalAttribCmds
@ kTotalAttribCmds
Total attribute commands parsed.
Definition: ntv2captiondecodechannel608.h:31
CNTV2CaptionDecodeChannel608Ptr
AJARefPtr< CNTV2CaptionDecodeChannel608 > CNTV2CaptionDecodeChannel608Ptr
Definition: ntv2captiondecodechannel608.h:61
kTotalTabOffsetCmds
@ kTotalTabOffsetCmds
Total tab offset commands parsed.
Definition: ntv2captiondecodechannel608.h:29
IsLine21TextChannel
#define IsLine21TextChannel(_chan_)
Definition: ntv2caption608types.h:104
AJALock
Definition: lock.h:30
NTV2_CC608_MaxCol
const UWord NTV2_CC608_MaxCol(32)
The maximum column index number (located at the right edge of the screen).
kParseFailTally
@ kParseFailTally
Total Parse608Data failures.
Definition: ntv2captiondecodechannel608.h:28
NTV2_CC608_CodePoint
ULWord NTV2_CC608_CodePoint
Describes a unique CEA-608 caption character code point in 32 bits: 0xSS00XXYY, where....
Definition: ntv2caption608types.h:276
NTV2Caption608Changed
void() NTV2Caption608Changed(void *pInstance, const NTV2Caption608ChangeInfo &inChangeInfo)
This callback is used to respond to dynamic events that occur during CEA-608 caption decoding.
Definition: ntv2caption608types.h:872
NTV2Line21Mode
NTV2Line21Mode
The CEA-608 modes: pop-on, roll-up (2, 3 and 4-line), and paint-on.
Definition: ntv2caption608types.h:123
UByte
uint8_t UByte
Definition: ajatypes.h:250
CNTV2CaptionDecodeChannel608::GetRow
virtual UWord GetRow(void) const
Answers with the row at which the next caption character will be inserted.
Definition: ntv2captiondecodechannel608.h:130
kTotalSpecialChars
@ kTotalSpecialChars
Total special characters parsed.
Definition: ntv2captiondecodechannel608.h:35
CNTV2CaptionDecodeChannel608::GetTextModeDisplayRowCount
virtual UWord GetTextModeDisplayRowCount(void) const
Returns the number of rows used for displaying Text Mode captions (Tx1/Tx2/Tx3/Tx4).
Definition: ntv2captiondecodechannel608.h:201
NTV2Line21Channel
NTV2Line21Channel
The CEA-608 caption channels: CC1 thru CC4, TX1 thru TX4, plus XDS.
Definition: ntv2caption608types.h:82
AJAExport
#define AJAExport
Definition: export.h:33
CNTV2CaptionDecodeChannel608::IsTextChannel
virtual bool IsTextChannel(void) const
Answers true if the caption channel I'm currently handling is Tx1, Tx2, Tx3 or Tx4.
Definition: ntv2captiondecodechannel608.h:99
CNTV2CaptionDecodeChannel608::GetTextModeDisplayAttributes
virtual const NTV2Line21Attrs & GetTextModeDisplayAttributes(void) const
Returns the display attributes that Text Mode captions are currently using (assuming my caption chann...
Definition: ntv2captiondecodechannel608.h:216
kTotalPACCmds
@ kTotalPACCmds
Total PAC (preamble address code) commands parsed.
Definition: ntv2captiondecodechannel608.h:33
CNTV2CaptionLogConfig
Definition: ntv2captionlogging.h:77
NTV2Line21Field
NTV2Line21Field
The two CEA-608 interlace fields.
Definition: ntv2caption608types.h:56
NTV2Line21Attributes
CEA-608 Character Attributes.
Definition: ntv2caption608types.h:357
kTotalCharSetCmds
@ kTotalCharSetCmds
Total character set commands parsed.
Definition: ntv2captiondecodechannel608.h:30
NTV2Line21CharacterSet
NTV2Line21CharacterSet
The available CEA-608 character sets.
Definition: ntv2caption608types.h:243
ajarefptr.h
Defines the AJARefPtr template class.
ntv2captionlogging.h
Declares the NTV2CaptionLogMask, and the CNTV2CaptionLogConfig class.
NTV2_CC608_MaxRow
const UWord NTV2_CC608_MaxRow(15)
The maximum permissible row index number (located at the bottom of the screen).