AJA NTV2 SDK  17.0.1.1246
NTV2 SDK 17.0.1.1246
ntv2captionencoder608.h
Go to the documentation of this file.
1 
7 #ifndef __NTV2_CEA608_ENCODER_
8 #define __NTV2_CEA608_ENCODER_
9 
10 #include "ntv2line21captioner.h"
11 #include "ntv2caption608types.h"
14 #include <string>
15 #include <deque>
16 
17 
18 #ifdef MSWindows
19  #include "windows.h"
20  #include "stdio.h"
21 #endif
22 
23 #ifdef AJALinux
24  #include <stdio.h>
25 #endif
26 
27 
52 
54 {
55  // CLASS METHODS
56  public:
64  static bool Create (CNTV2CaptionEncoder608Ptr & outEncoder);
65 
66 
67  // INSTANCE METHODS
68  public:
72 
95  virtual bool EnqueuePopOnMessage (const std::string & inMessageStr,
96  const NTV2Line21Channel inChannel = NTV2_CC608_CC1,
97  const UWord inRowNumber = 0,
98  const UWord inColumnNumber = 0,
99  const NTV2Line21Attrs & inDisplayAttribs = NTV2Line21Attrs());
100 
101 
124  virtual bool EnqueuePaintOnMessage (const std::string & inMessageStr,
125  const bool inEraseFirst = false,
126  const NTV2Line21Channel inChannel = NTV2_CC608_CC1,
127  const UWord inRowNumber = 0,
128  const UWord inColumnNumber = 0,
129  const NTV2Line21Attrs & inDisplayAttribs = NTV2Line21Attrs());
130 
156  virtual bool EnqueueRollUpMessage (const std::string & inMessageStr,
157  const NTV2Line21Mode inRollMode = NTV2_CC608_CapModeRollUp4,
158  const NTV2Line21Channel inChannel = NTV2_CC608_CC1,
159  const UWord inRowNumber = NTV2_CC608_MaxRow,
160  const UWord inColumnNumber = NTV2_CC608_MinCol,
161  const NTV2Line21Attrs & inDisplayAttribs = NTV2Line21Attrs());
162 
176  virtual bool EnqueueTextMessage (const std::string & inMessageStr,
177  const bool inEraseFirst = false,
178  const NTV2Line21Channel inChannel = NTV2_CC608_Text1);
179 
190  virtual bool EnqueueCaptionData (const CaptionData & inCaptionData);
191 
199  virtual bool EnqueueDelay (const uint32_t inFrameCount, const NTV2Line21Channel inChannel = NTV2_CC608_CC1);
201 
205 
219  virtual bool EncodeNextCaptionBytesIntoLine21 (void * pFrameBuffer,
220  const NTV2PixelFormat inPixelFormat,
221  const NTV2VideoFormat inVideoFormat,
222  const NTV2Line21Field inFieldNum);
223 
224 
230  virtual bool GetNextCaptionData (CaptionData & outCaptionData);
231 
242  virtual UByte * GetNextLine21TransmitCaptions (const NTV2Line21Field inFieldNum);
243 
244 
257  virtual bool GetNextTransmitCaptionBytes (const NTV2Line21Field inFieldNum, UByte & outChar1, UByte & outChar2);
259 
260 
264 
271  virtual size_t GetQueuedMessageCount (const NTV2Line21Field inFieldNum = NTV2_CC608_Field1) const;
272 
279  virtual size_t GetQueuedByteCount (const NTV2Line21Field inFieldNum = NTV2_CC608_Field1) const;
280 
287  virtual void Flush (const NTV2Line21Field inFieldNum = NTV2_CC608_Field1, const bool inAlsoInProgress = true);
288 
295  virtual void FlushChannel (const NTV2Line21Channel inChannel, const bool inAlsoInProgress = true);
296 
297 
305  virtual bool Erase (const NTV2Line21Channel inChannel = NTV2_CC608_CC1);
306 
307 
314  virtual void GetQueueInfoForChannel (const NTV2Line21Channel inChannel, size_t & outBytesQueued, size_t & outMessagesQueued) const;
315 
316 
317  // Stats
318 
323  virtual inline size_t GetEnqueueByteTally (void) const {return mXmitMsgQueueF1.GetEnqueueByteTally () + mXmitMsgQueueF2.GetEnqueueByteTally ();}
324 
329  virtual inline size_t GetDequeueByteTally (void) const {return mXmitMsgQueueF1.GetDequeueByteTally () + mXmitMsgQueueF2.GetDequeueByteTally ();}
330 
334  virtual inline size_t GetEnqueueMessageTally (void) const {return mXmitMsgQueueF1.GetEnqueueMessageTally () + mXmitMsgQueueF2.GetEnqueueMessageTally ();}
335 
339  virtual inline size_t GetDequeueMessageTally (void) const {return mXmitMsgQueueF1.GetDequeueMessageTally () + mXmitMsgQueueF2.GetDequeueMessageTally ();}
340 
345  virtual inline size_t GetHighestQueueDepth (void) const {return mXmitMsgQueueF1.GetHighestQueueDepth () + mXmitMsgQueueF2.GetHighestQueueDepth ();}
346 
347 
356  virtual void GetQueueStatsForChannel (const NTV2Line21Channel inChannel,
357  size_t & outEnqueueBytes, size_t & outEnqueueMsgs,
358  size_t & outDequeueBytes, size_t & outDequeueMsgs) const;
360 
364  virtual ~CNTV2CaptionEncoder608 ();
365 
366  virtual NTV2CaptionLogMask SetLogMask (const NTV2CaptionLogMask inLogMask);
367 
368 #if !defined(NTV2_DEPRECATE_17_0)
369  virtual inline bool EnqueuePopOnMessage (const std::string & str, const NTV2Line21Channel ch, const UWord row, const UWord col, const NTV2Line21AttrsPtr pAttrs) {NTV2Line21Attrs tmp; return EnqueuePopOnMessage(str, ch, row, col, pAttrs ? *pAttrs : tmp);}
370  virtual inline bool EnqueuePaintOnMessage (const std::string & str, const bool erase, const NTV2Line21Channel ch, const UWord row, const UWord col, const NTV2Line21AttrsPtr pAttrs) {NTV2Line21Attrs tmp; return EnqueuePaintOnMessage(str, erase, ch, row, col, pAttrs ? *pAttrs : tmp);}
371  virtual inline bool EnqueueRollUpMessage (const std::string & str, const NTV2Line21Mode mode, const NTV2Line21Channel ch, const UWord row, const UWord col, const NTV2Line21AttrsPtr pAttrs) {NTV2Line21Attrs tmp; return EnqueueRollUpMessage(str, mode, ch, row, col, pAttrs ? *pAttrs : tmp);}
372 #endif // defined(NTV2_DEPRECATE_17_0)
373 
374 
375  // Private Instance Methods
376  private:
377  virtual CNTV2608MsgPtr GetNextCaptionMessage (const NTV2Line21Field inFieldNum);
378  virtual bool EnqueueCaptionMessage (const NTV2Line21Field inFieldNum, CNTV2608MsgPtr pInMsg);
379 
380  virtual bool InsertPACAndPenModeCommands (const NTV2Line21Channel inChannel,
381  const UWord inRowNumber,
382  const UWord inColumnNumber,
383  const NTV2Line21Attrs & inDisplayAttribs,
384  CNTV2608MsgPtr pCapMsg);
385 
386  virtual UWord GetWhitePACCommand (const NTV2Line21Channel inChannel,
387  const UWord inRowNumber,
388  const UWord inColumnNumber,
389  const NTV2Line21Attrs & inDisplayAttribs,
390  UWord & outExtraColumn);
391 
392  virtual UWord GetColorPACCommand (const NTV2Line21Channel inChannel,
393  const UWord inRowNumber,
394  const NTV2Line21Attrs & inDisplayAttribs);
395 
396  virtual UWord GetMidRowCommand (const NTV2Line21Channel inChannel,
397  const NTV2Line21Attrs & inDisplayAttribs);
398 
399  // Hidden constructors & assignment operators
400  explicit CNTV2CaptionEncoder608 ();
401  explicit inline CNTV2CaptionEncoder608 (const CNTV2CaptionEncoder608 & inEncoderToCopy) : CNTV2CaptionLogConfig() {(void) inEncoderToCopy;}
402  virtual inline CNTV2CaptionEncoder608 & operator = (const CNTV2CaptionEncoder608 & inEncoderToCopy) {(void) inEncoderToCopy; return *this;}
403 
404 
405  // Private Class Methods
406  private:
412  static UByte CC608OddParity (const UByte inByte);
413 
414 
415  // INSTANCE DATA
416  private:
417  CNTV2Line21Captioner mLine21Encoder;
418 
419  CNTV2Caption608MessageQueue mXmitMsgQueueF1;
420  CNTV2Caption608MessageQueue mXmitMsgQueueF2;
421 
422  CNTV2608MsgPtr mpXmitCurrentF1Msg;
423  CNTV2608MsgPtr mpXmitCurrentF2Msg;
424 
425 }; // CNTV2CaptionEncoder608
426 
427 
432 {
433  public:
444  static std::string Utf8ToCEA608String (const std::string & inUtf8Str, const NTV2Line21Channel inChannel = NTV2_CC608_CC1);
445 
456  static std::string UnicodeCodePointToCEA608Sequence (const ULWord inUnicodeCodePoint, const NTV2Line21Channel inChannel = NTV2_CC608_CC1);
457 
464  static size_t Utf8LengthInChars (const std::string & inUtf8Str);
465 
474  static std::string Utf8GetCharacter (const std::string & inUtf8Str, const size_t inCharOffset);
475 
476 }; // CUtf8Helper
477 
478 #endif // __NTV2_CEA608_ENCODER_
CNTV2CaptionEncoder608::GetDequeueMessageTally
virtual size_t GetDequeueMessageTally(void) const
Returns the total number of messages that have been dequeued from me since I was instantiated.
Definition: ntv2captionencoder608.h:339
ntv2caption608types.h
Declares several data types used with 608/SD captioning.
NTV2_CC608_MinCol
const UWord NTV2_CC608_MinCol(1)
The minimum column index number (located at the left edge of the screen).
CNTV2CaptionEncoder608::GetEnqueueMessageTally
virtual size_t GetEnqueueMessageTally(void) const
Returns the total number of messages that have been enqueued onto me since I was instantiated.
Definition: ntv2captionencoder608.h:334
ntv2line21captioner.h
Declares the CNTV2Line21Captioner class.
AJARefPtr< CNTV2CaptionEncoder608 >
NTV2FrameBufferFormat
NTV2FrameBufferFormat
Identifies a particular video frame buffer format. See Device Frame Buffer Formats for details.
Definition: ntv2enums.h:207
CNTV2CaptionEncoder608::GetDequeueByteTally
virtual size_t GetDequeueByteTally(void) const
Returns the total number of bytes (including command bytes) that have been dequeued from me since I w...
Definition: ntv2captionencoder608.h:329
CNTV2CaptionEncoder608::GetHighestQueueDepth
virtual size_t GetHighestQueueDepth(void) const
Returns the highest queue depth – i.e., the maximum number of messages I held in either of my queues ...
Definition: ntv2captionencoder608.h:345
CUtf8Helpers
A small collection of UTF-8 utility functions.
Definition: ntv2captionencoder608.h:431
CNTV2Caption608MessageQueue
I am a thread-safe queue of caption messages. Internally, I maintain two queues: one for high-priorit...
Definition: ntv2caption608messagequeue.h:20
ULWord
uint32_t ULWord
Definition: ajatypes.h:246
CNTV2CaptionLogConfig::SetLogMask
virtual NTV2CaptionLogMask SetLogMask(const NTV2CaptionLogMask inLogMask)
Specifies what, if any, debug information I will write to my log stream.
Definition: ntv2captionlogging.h:187
UWord
uint16_t UWord
Definition: ajatypes.h:244
NTV2_CC608_CapModeRollUp4
@ NTV2_CC608_CapModeRollUp4
4-row roll-up from bottom
Definition: ntv2caption608types.h:130
CNTV2CaptionEncoder608::GetEnqueueByteTally
virtual size_t GetEnqueueByteTally(void) const
Returns the total number of bytes (including command bytes) that have been enqueued onto me since I w...
Definition: ntv2captionencoder608.h:323
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:241
NTV2_CC608_CC1
@ NTV2_CC608_CC1
Caption channel 1, the primary caption channel.
Definition: ntv2caption608types.h:84
NTV2_CC608_Text1
@ NTV2_CC608_Text1
Definition: ntv2caption608types.h:90
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
NTV2VideoFormat
enum _NTV2VideoFormat NTV2VideoFormat
Identifies a particular video format.
NTV2Line21Attrs
struct NTV2Line21Attributes NTV2Line21Attrs
NTV2CaptionLogMask
uint64_t NTV2CaptionLogMask
Selectors to control what information is logged.
Definition: ntv2captionlogging.h:38
NTV2_CC608_Field1
@ NTV2_CC608_Field1
Definition: ntv2caption608types.h:59
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
CaptionData
This structure encapsulates all possible CEA-608 caption data bytes that may be associated with a giv...
Definition: ntv2caption608types.h:655
CNTV2Line21Captioner
Instances of me can encode two ASCII characters into a "line 21" closed-captioning waveform....
Definition: ntv2line21captioner.h:34
CNTV2CaptionEncoder608
Definition: ntv2captionencoder608.h:53
ajarefptr.h
Defines the AJARefPtr template class.
CNTV2CaptionEncoder608Ptr
AJARefPtr< CNTV2CaptionEncoder608 > CNTV2CaptionEncoder608Ptr
Definition: ntv2captionencoder608.h:50
ntv2caption608messagequeue.h
Declares the CNTV2Caption608MessageQueue class.
NTV2_CC608_MaxRow
const UWord NTV2_CC608_MaxRow(15)
The maximum permissible row index number (located at the bottom of the screen).