AJA NTV2 SDK  18.0.0.2122
NTV2 SDK 18.0.0.2122
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_
Declares the AJALock class.
_CaptionDecode608Stats
The currently supported caption decoder stats.
NTV2Line21CharacterSet
The available CEA-608 character sets.
AJARefPtr< CNTV2CaptionDecodeChannel608 > CNTV2CaptionDecodeChannel608Ptr
#define NULL
#define AJA_EXPORT
Definition: export.h:34
I am a reference-counted pointer template class. I am intended to be a proxy for an underlying object...
Definition: ajarefptr.h:89
bool Check608Parity(UByte char608_1, UByte char608_2, std::string &outDebugStr)
Definition: lock.h:28
Defines the AJARefPtr template class.
Total Misc commands parsed (RollUp, FlashOn, RCL, BS, EDM, EOC, etc.)
Total Parse608Data failures.
virtual UWord GetCurrentScreen(void) const
Total Mid-Row commands parsed (color, underline, italic, flash, etc.)
virtual UWord GetColumn(void) const
Answers with the column at which the next caption character will be inserted.
virtual NTV2Line21Mode GetCaptionMode(void) const
enum _CaptionDecode608Stats CaptionDecode608Stats
The currently supported caption decoder stats.
CEA-608 Character Attributes.
virtual NTV2Line21CharacterSet GetCurrentCharacterSet(void) const
Answers with my current character set.
const UWord NTV2_CC608_MaxCol(32)
The maximum column index number (located at the right edge of the screen).
#define IsLine21TextChannel(_chan_)
Total attribute commands parsed.
enum NTV2Line21CharacterSet NTV2Line21CharSet
Declares the NTV2CaptionLogMask, and the CNTV2CaptionLogConfig class.
ULWord NTV2_CC608_CodePoint
Describes a unique CEA-608 caption character code point in 32 bits: 0xSS00XXYY, where... SS == NTV2Line21CharacterSet XX == CEA608 byte 1 (parity stripped) YY == CEA608 byte 2 (parity stripped)
uint8_t UByte
Definition: ajatypes.h:218
Total tab offset commands parsed.
void() NTV2Caption608Changed(void *pInstance, const NTV2Caption608ChangeInfo &inChangeInfo)
This callback is used to respond to dynamic events that occur during CEA-608 caption decoding...
#define AJAExport
Definition: export.h:33
virtual UWord GetRow(void) const
Answers with the row at which the next caption character will be inserted.
uint16_t UWord
Definition: ajatypes.h:221
UByte Add608OddParity(UByte ch)
virtual UWord GetTextModeDisplayRowCount(void) const
Returns the number of rows used for displaying Text Mode captions (Tx1/Tx2/Tx3/Tx4).
Total PAC (preamble address code) commands parsed.
NTV2Line21Mode
The CEA-608 modes: pop-on, roll-up (2, 3 and 4-line), and paint-on.
Total Parse608Data successes.
virtual bool IsTextChannel(void) const
Answers true if the caption channel I&#39;m currently handling is Tx1, Tx2, Tx3 or Tx4.
const UWord NTV2_CC608_MaxRow(15)
The maximum permissible row index number (located at the bottom of the screen).
Line21RowSet Line21ColumnSet
A set of caption column numbers.
Total plain ol&#39; characters parsed.
NTV2Line21Channel
The CEA-608 caption channels: CC1 thru CC4, TX1 thru TX4, plus XDS.
Declares several data types used with 608/SD captioning.
Total character set commands parsed.
virtual void SetTextModeDisplayAttributes(const NTV2Line21Attrs &inAttributes)
Sets the display attributes that Text Mode captions will use henceforth.
NTV2Line21Field
The two CEA-608 interlace fields.
std::set< int > Line21RowSet
A set of caption row numbers.
virtual const NTV2Line21Attrs & GetTextModeDisplayAttributes(void) const
Returns the display attributes that Text Mode captions are currently using (assuming my caption chann...
Total special characters parsed.