AJA NTV2 SDK  17.0.1.1246
NTV2 SDK 17.0.1.1246
ntv2caption608message.h
Go to the documentation of this file.
1 
7 #ifndef __NTV2_CAPTION608MESSAGE__
8 #define __NTV2_CAPTION608MESSAGE__
9 
10 #include "ntv2captionlogging.h"
11 #include "ntv2caption608types.h"
13 #include <string>
14 #include <iostream>
15 
16 
18 {
19  NTV2_CC608_CaptionMsgType_Data = 0, // message contains data to be transmitted
20  NTV2_CC608_CaptionMsgType_Delay = 1 // message contains frame count
21 
23 
24 
35 
37 {
38  friend class CNTV2CaptionEncoder608;
40 
41  // Class Data
42  protected:
43  static const UWord NTV2_CC608_CaptionMsgMaxBytes = 256;
44 
45 
46  // Class Methods
47  protected:
48  static bool Create (CNTV2Caption608MessagePtr & outNewInstance,
49  const NTV2Line21Channel inChannel,
51 
52 
53  // Instance Methods
54  protected:
55  // Construction & Destruction
56  explicit CNTV2Caption608Message (const NTV2Line21Channel inChannel,
58  public: virtual inline ~CNTV2Caption608Message () {}
59 
60  public:
66  virtual std::ostream & Print (std::ostream & inOutStream) const;
67 
68  protected:
69  // Inquiry
70  virtual inline NTV2_CC608_CaptionMessageType GetType (void) const {return mType;}
71  virtual inline NTV2Line21Channel GetChannel (void) const {return mChannel;}
72  virtual inline bool HasData (void) const {return GetLength () > 0;}
73  virtual inline bool IsData (void) const {return GetType () == NTV2_CC608_CaptionMsgType_Data;}
74  virtual inline bool IsDelay (void) const {return GetType () == NTV2_CC608_CaptionMsgType_Delay;}
75  virtual inline bool IsLowPriority (void) const {return !IsLine21CaptionChannel (GetChannel ());}
76  virtual inline bool IsHighPriority (void) const {return IsLine21CaptionChannel (GetChannel ());}
77  virtual inline UWord GetLength (void) const {return mLength;}
78  virtual inline UWord GetBytesRemaining (void) const {return IsPastEnd () ? 0 : GetLength () - GetReadPosition ();}
79  virtual inline UWord GetRemainingByteCapacity (void) const {return NTV2_CC608_CaptionMsgMaxBytes - GetLength ();}
80 
81 
82  // Readers
83 
88  virtual UByte ReadNext (void);
89 
90 
94  virtual inline void SkipNext (void) {if (mReadPosition < mLength) mReadPosition++;}
95 
96 
100  virtual inline UWord GetReadPosition (void) const {return mReadPosition;}
101 
102 
106  virtual inline bool IsPastEnd (void) const {return GetReadPosition () >= GetLength ();}
107 
108 
109  // Writers
110 
116  virtual bool Add608Command (const UWord inCommand);
117 
124  virtual bool Add608String (const std::string & inMessageStr);
125 
132  virtual bool AddBytePair (const UByte inByte1, const UByte inByte2);
133 
134 
135  private:
136  virtual CNTV2Caption608Message & operator = (const CNTV2Caption608Message & inRHS);
137 
138 
139  // Instance Data
140  private:
142  UWord mLength;
143  UWord mReadPosition;
144  UByte mData [NTV2_CC608_CaptionMsgMaxBytes];
145  const NTV2Line21Channel mChannel;
146 
147 }; // CNTV2Caption608Message
148 
149 
150 // Output stream operators:
151 inline std::ostream & operator << (std::ostream & inOutStream, const CNTV2Caption608Message & inMsg) {return inMsg.Print (inOutStream);}
152 std::ostream & operator << (std::ostream & inOutStream, CNTV2Caption608MessagePtr inMsgPtr);
153 
154 
155 // Backward compatibility
158 
159 
160 #endif // __NTV2_CAPTION608MESSAGE__
CNTV2Caption608Message::IsData
virtual bool IsData(void) const
Definition: ntv2caption608message.h:73
ntv2caption608types.h
Declares several data types used with 608/SD captioning.
CNTV2Caption608Message::Print
virtual std::ostream & Print(std::ostream &inOutStream) const
Prints a human-readable representation of me to the given output stream.
AJARefPtr
I am a reference-counted pointer template class. I am intended to be a proxy for an underlying object...
Definition: ajarefptr.h:89
CNTV2Caption608Message::HasData
virtual bool HasData(void) const
Definition: ntv2caption608message.h:72
CNTV2Caption608Message::GetLength
virtual UWord GetLength(void) const
Definition: ntv2caption608message.h:77
CNTV2Caption608MessagePtr
AJARefPtr< CNTV2Caption608Message > CNTV2Caption608MessagePtr
Definition: ntv2caption608message.h:32
CNTV2Caption608MessageQueue::Print
virtual std::ostream & Print(std::ostream &inOutStream, const bool inDumpMessages=true) const
Prints a human-readable representation of me to the given output stream in oldest-to-newest order.
CNTV2Caption608Message::IsDelay
virtual bool IsDelay(void) const
Definition: ntv2caption608message.h:74
CNTV2Caption608MessageQueue
I am a thread-safe queue of caption messages. Internally, I maintain two queues: one for high-priorit...
Definition: ntv2caption608messagequeue.h:20
NTV2_CC608_CaptionMsgType_Data
@ NTV2_CC608_CaptionMsgType_Data
Definition: ntv2caption608message.h:19
CNTV2Caption608Message::GetReadPosition
virtual UWord GetReadPosition(void) const
Returns my internal read position.
Definition: ntv2caption608message.h:100
CNTV2Caption608Message
Definition: ntv2caption608message.h:36
CNTV2Caption608Message::GetChannel
virtual NTV2Line21Channel GetChannel(void) const
Definition: ntv2caption608message.h:71
NTV2CaptionMessagePtr
CNTV2Caption608MessagePtr NTV2CaptionMessagePtr
Definition: ntv2caption608message.h:157
IsLine21CaptionChannel
#define IsLine21CaptionChannel(_chan_)
Definition: ntv2caption608types.h:103
UWord
uint16_t UWord
Definition: ajatypes.h:244
NTV2_CC608_CaptionMsgType_Delay
@ NTV2_CC608_CaptionMsgType_Delay
Definition: ntv2caption608message.h:20
CNTV2608MsgPtr
CNTV2Caption608MessagePtr CNTV2608MsgPtr
Definition: ntv2caption608message.h:34
CNTV2Caption608Message::GetType
virtual NTV2_CC608_CaptionMessageType GetType(void) const
Definition: ntv2caption608message.h:70
CNTV2Caption608Message::IsPastEnd
virtual bool IsPastEnd(void) const
Returns "true" if my internal read position is past the end; otherwise returns "false".
Definition: ntv2caption608message.h:106
CNTV2Caption608Message::IsHighPriority
virtual bool IsHighPriority(void) const
Definition: ntv2caption608message.h:76
NTV2_CC608_CaptionMessageType
NTV2_CC608_CaptionMessageType
Definition: ntv2caption608message.h:17
CNTV2Caption608Message::GetRemainingByteCapacity
virtual UWord GetRemainingByteCapacity(void) const
Definition: ntv2caption608message.h:79
UByte
uint8_t UByte
Definition: ajatypes.h:241
NTV2Line21Channel
NTV2Line21Channel
The CEA-608 caption channels: CC1 thru CC4, TX1 thru TX4, plus XDS.
Definition: ntv2caption608types.h:82
operator<<
std::ostream & operator<<(std::ostream &inOutStream, const CNTV2Caption608Message &inMsg)
Definition: ntv2caption608message.h:151
AJAExport
#define AJAExport
Definition: export.h:33
CNTV2Caption608Message::GetBytesRemaining
virtual UWord GetBytesRemaining(void) const
Definition: ntv2caption608message.h:78
CNTV2CaptionLogConfig
Definition: ntv2captionlogging.h:77
CNTV2Caption608Message::IsLowPriority
virtual bool IsLowPriority(void) const
Definition: ntv2caption608message.h:75
CNTV2CaptionEncoder608
Definition: ntv2captionencoder608.h:53
NTV2CaptionMessage
CNTV2Caption608Message NTV2CaptionMessage
Definition: ntv2caption608message.h:156
ajarefptr.h
Defines the AJARefPtr template class.
ntv2captionlogging.h
Declares the NTV2CaptionLogMask, and the CNTV2CaptionLogConfig class.
CNTV2Caption608Message::SkipNext
virtual void SkipNext(void)
Increments my internal read position (if not already past end).
Definition: ntv2caption608message.h:94
CNTV2Caption608Message::~CNTV2Caption608Message
virtual ~CNTV2Caption608Message()
Definition: ntv2caption608message.h:58