AJA NTV2 SDK  18.0.0.2122
NTV2 SDK 18.0.0.2122
ancillarydata_cea608_vanc.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MIT */
9 #include <ios>
10 #include <iomanip>
11 
12 using namespace std;
13 
14 
17 {
18  Init();
19 }
20 
21 
24 {
25  Init();
26  *this = clone;
27 }
28 
29 
32 {
33  Init();
34  if (pClone != NULL_PTR)
35  *this = *pClone;
36 }
37 
38 
40  : AJAAncillaryData_Cea608 (pData)
41 {
42  Init();
43 }
44 
45 
47 {
48 }
49 
50 
52 {
57 
58  m_isF2 = false; // default to field 1
59  m_lineNum = 12; // line 21 (0 = line 9 in 525i)
60 }
61 
62 
64 {
65  if (this != &rhs) // ignore self-assignment
66  {
67  AJAAncillaryData_Cea608::operator= (rhs); // copy the base class stuff
68 
69  // copy the local stuff
70  m_isF2 = rhs.m_isF2;
71  m_lineNum = rhs.m_lineNum;
72  }
73  return *this;
74 }
75 
76 
78 {
80  Init();
81 }
82 
83 
84 AJAStatus AJAAncillaryData_Cea608_Vanc::SetLine (const bool inIsF2, const uint8_t lineNum)
85 {
86  m_isF2 = inIsF2;
87  m_lineNum = lineNum & 0x1F; // valid range is 0 (= line 9) to 31 (= line 40)
88  return AJA_STATUS_SUCCESS;
89 }
90 
91 
92 AJAStatus AJAAncillaryData_Cea608_Vanc::GetLine (uint8_t & fieldNum, uint8_t & lineNum) const
93 {
94  fieldNum = IsField2() ? 0x01/*NTV2_FIELD1*/ : 0x00/*NTV2_FIELD0*/;
95  lineNum = uint8_t(GetLineNumber());
96  return AJA_STATUS_SUCCESS;
97 }
98 
99 
101 {
103  {
104  Init(); // load default values
105  m_rcvDataValid = false;
106  return AJA_STATUS_FAIL;
107  }
108 
109  // Parse the payload data...
110  m_isF2 = ((m_payload[0] >> 7) & 0x01) ? false : true; // Field number (flag) is bit 7 of the 1st payload word
111  // SDKs prior to 16.0 had the sense of this bit wrong.
112  m_lineNum = (m_payload[0] & 0x1F); // Line number is bits [4:0] of the 1st payload word
113  m_char1 = m_payload[1]; // the 1st character
114  m_char2 = m_payload[2]; // the 2nd character
115  m_rcvDataValid = true;
116  return AJA_STATUS_SUCCESS;
117 }
118 
119 
121 {
124 
126  if (AJA_SUCCESS (status))
127  {
128  /*
129  From S334-1 and S334-2 standards documents:
130  The LINE value at the start of the UDW represents the field number and line where the data are intended to be carried.
131  Bit b7 of the LINE value is the field number (0 for field 2; 1 for field 1).
132  Bits b6 and b5 are 0.
133  Bits b4-b0 form a 5-bit unsigned integer which represents the offset (in lines) of the data insertion line,
134  relative to the base line for the original image format:
135  line 9 of 525-line F1
136  line 272 of 525-line F2
137  line 5 of 625-line F1
138  line 318 of 625-line F2
139  NOTE: SDKs prior to 16.0 used the opposite sense of this bit.
140  */
141  m_payload[0] = uint8_t((m_isF2 ? 0x00 : 0x01) << 7) | (m_lineNum & 0x1F); // F2 flag goes in b7, line num in bits [4:0]
142  m_payload[1] = m_char1;
143  m_payload[2] = m_char2;
144  }
145 
147  return status;
148 }
149 
150 ostream & AJAAncillaryData_Cea608_Vanc::Print (ostream & debugStream, const bool bShowDetail) const
151 {
152  debugStream << IDAsString() << "(" << ::AJAAncDataCodingToString (m_coding) << ")" << endl;
153  AJAAncillaryData_Cea608::Print (debugStream, bShowDetail);
154  debugStream << endl
155  << "Field: " << (m_isF2 ? "F2" : "F1") << endl
156  << "Line: " << dec << uint16_t(m_lineNum);
157  return debugStream;
158 }
159 
160 
162 {
163  if (pInAncData->GetDataCoding() == AJAAncDataCoding_Digital)
164  if (pInAncData->GetDID() == AJAAncillaryData_Cea608_Vanc_DID)
165  if (pInAncData->GetSID() == AJAAncillaryData_Cea608_Vanc_SID)
166  if (pInAncData->GetDC() == AJAAncillaryData_Cea608_Vanc_PayloadSize)
168  return AJAAncDataType_Unknown;
169 }
virtual void Clear(void)
Frees my allocated memory, if any, and resets my members to their default values. ...
virtual uint8_t GetDID(void) const
#define AJA_SUCCESS(_status_)
Definition: types.h:372
virtual AJAAncillaryData_Cea608_Vanc & operator=(const AJAAncillaryData_Cea608_Vanc &inRHS)
Assignment operator – replaces my contents with the right-hand-side value.
virtual uint8_t GetSID(void) const
virtual AJAStatus SetLine(const bool inIsF2, const uint8_t inLineNum)
Sets my SMPTE 334 (CEA608) field/line numbers.
AJAStatus
Definition: types.h:380
AJAAncDataType m_ancType
One of a known set of ancillary data types (or "Custom" if not identified)
AJAAncDataType
Identifies the ancillary data types that are known to this module.
Definition: ancillarydata.h:44
virtual AJAStatus GeneratePayloadData(void)
Generate the payload data from my "local" ancillary data.
Declares the AJAAncillaryData_Cea608_Vanc class.
Definition: json.hpp:5362
#define false
uint8_t m_checksum
My 8-bit checksum: DID + SID + DC + payload (w/o parity) [note: NOT the same as the 9-bit checksum in...
ByteVector m_payload
My payload data (DC = size)
AJAAncDataCoding m_coding
Analog or digital data.
Includes data that is valid, but we don&#39;t recognize.
Definition: ancillarydata.h:46
virtual std::ostream & Print(std::ostream &inOutStream, const bool inDetailed=false) const
Streams a human-readable representation of me to the given output stream.
virtual uint8_t Calculate8BitChecksum(void) const
Generates an 8-bit checksum from the DID + SID + DC + payload data.
This is the base class for handling CEA-608 caption data packets.
AJAAncillaryData_Cea608 & operator=(const AJAAncillaryData_Cea608 &inRHS)
Assignment operator – replaces my contents with the right-hand-side value.
const uint32_t AJAAncillaryData_Cea608_Vanc_PayloadSize
This class handles VANC-based CEA-608 caption data packets (not "analog" Line 21).
#define NULL_PTR
Definition: types.h:327
virtual void Clear(void)
Frees my allocated memory, if any, and resets my members to their default values. ...
uint8_t m_SID
Official SMPTE secondary ID (or DBN - w/o parity)
virtual AJAStatus GetLine(uint8_t &outFieldNum, uint8_t &outLineNum) const
virtual uint16_t GetLineNumber(void) const
virtual AJAAncDataCoding GetDataCoding(void) const
virtual ~AJAAncillaryData_Cea608_Vanc()
My destructor.
uint8_t m_DID
Official SMPTE ancillary packet ID (w/o parity)
CEA608 SD Closed Captioning (SMPTE 334 VANC packet)
Definition: ancillarydata.h:51
const std::string & AJAAncDataCodingToString(const AJAAncDataCoding inValue, const bool inCompact=true)
virtual uint32_t GetDC(void) const
AJAAncillaryData_Cea608_Vanc()
My default constructor.
virtual std::string IDAsString(void) const
const uint8_t AJAAncillaryData_Cea608_Vanc_SID
I am the principal class that stores a single SMPTE-291 SDI ancillary data packet OR the digitized co...
virtual std::ostream & Print(std::ostream &inOutStream, const bool inDetailed=false) const
Streams a human-readable representation of me to the given output stream.
bool m_rcvDataValid
This is set true (or not) by ParsePayloadData()
static AJAAncDataType RecognizeThisAncillaryData(const AJAAncillaryData *pInAncData)
AJAStatus AllocDataMemory(const uint32_t inNumBytes)
const uint8_t AJAAncillaryData_Cea608_Vanc_DID
virtual AJAStatus ParsePayloadData(void)
Parses out (interprets) the "local" ancillary data from my payload data.
The ancillary data is in the form of a SMPTE-291 Ancillary Packet.