AJA NTV2 SDK  18.0.0.2122
NTV2 SDK 18.0.0.2122
ancillarydata_timecode_atc.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MIT */
9 #include "ntv2publicinterface.h"
10 #include <ios>
11 #include <iomanip>
12 
13 using namespace std;
14 
15 
16 
18 {
19  Init();
20 }
21 
22 
24 {
25  Init();
26 
27  *this = clone;
28 }
29 
30 
32 {
33  Init();
34 
35  if (pClone != NULL_PTR)
36  *this = *pClone;
37 }
38 
39 
41 {
42  Init();
43 }
44 
45 
47 {
48 }
49 
50 
52 {
57 
58  m_dbb1 = 0;
59  m_dbb2 = 0;
60 }
61 
62 
64 {
65  if (this != &rhs) // ignore self-assignment
66  {
67  AJAAncillaryData_Timecode::operator= (rhs); // copy the base class stuff
68 
69  m_dbb1 = rhs.m_dbb1;
70  m_dbb2 = rhs.m_dbb2;
71  }
72 
73  return *this;
74 }
75 
76 
78 {
80 
81  Init();
82 }
83 
84 
86 {
87  m_dbb1 = dbb1;
88 
89  return AJA_STATUS_SUCCESS;
90 }
91 
92 
94 {
95  dbb1 = m_dbb1;
96  return AJA_STATUS_SUCCESS;
97 }
98 
99 
101 {
102  m_dbb2 = dbb2;
103  return AJA_STATUS_SUCCESS;
104 }
105 
106 
108 {
109  dbb2 = m_dbb2;
110  return AJA_STATUS_SUCCESS;
111 }
112 
113 
115 {
116  SetDBB1(dbb1);
117  SetDBB2(dbb2);
118  return AJA_STATUS_SUCCESS;
119 }
120 
121 
122 AJAStatus AJAAncillaryData_Timecode_ATC::GetDBB (uint8_t & dbb1, uint8_t & dbb2) const
123 {
124  GetDBB1(dbb1);
125  GetDBB2(dbb2);
126  return AJA_STATUS_SUCCESS;
127 }
128 
129 
131 {
132  AJAStatus status = AJA_STATUS_SUCCESS;
133 
134  // reality check...
136  {
137  Init(); // load default values
138  status = AJA_STATUS_FAIL;
139  m_rcvDataValid = false;
140  }
141  else
142  {
143  // we have some kind of payload data - try to parse it
144  // extract the time digits from the even payload words, bits[7:4]
145  // (note: SetTimeHexValue() does the needed masking)
146  SetTimeHexValue(kTcFrameUnits, (m_payload[ 0] >> 4)); // frame units);
147  SetTimeHexValue(kTcFrameTens, (m_payload[ 2] >> 4)); // frame tens
148  SetTimeHexValue(kTcSecondUnits, (m_payload[ 4] >> 4)); // second units
149  SetTimeHexValue(kTcSecondTens, (m_payload[ 6] >> 4)); // second tens
150  SetTimeHexValue(kTcMinuteUnits, (m_payload[ 8] >> 4)); // minute units
151  SetTimeHexValue(kTcMinuteTens, (m_payload[10] >> 4)); // minute tens
152  SetTimeHexValue(kTcHourUnits, (m_payload[12] >> 4)); // hour units
153  SetTimeHexValue(kTcHourTens, (m_payload[14] >> 4)); // hour tens
154 
155  // extract the binary group values from the odd payload words, bits[7:4]
156  // (note: SetBinaryGroupHexValue() does the needed masking)
157  SetBinaryGroupHexValue(kBg1, (m_payload[ 1] >> 4)); // BG 1
158  SetBinaryGroupHexValue(kBg2, (m_payload[ 3] >> 4)); // BG 2
159  SetBinaryGroupHexValue(kBg3, (m_payload[ 5] >> 4)); // BG 3
160  SetBinaryGroupHexValue(kBg4, (m_payload[ 7] >> 4)); // BG 4
161  SetBinaryGroupHexValue(kBg5, (m_payload[ 9] >> 4)); // BG 5
162  SetBinaryGroupHexValue(kBg6, (m_payload[11] >> 4)); // BG 6
163  SetBinaryGroupHexValue(kBg7, (m_payload[13] >> 4)); // BG 7
164  SetBinaryGroupHexValue(kBg8, (m_payload[15] >> 4)); // BG 8
165 
166  // extract the distributed bits from bit[3] of all UDW
167  uint8_t i;
168  uint8_t dbb = 0; // DBB1 comes from UDW1 - UDW8 bit 3, ls bit first
169  for (i = 0; i < 8; i++)
170  {
171  dbb = dbb >> 1;
172  dbb |= (m_payload[i] << 4) & 0x80;
173  }
174  m_dbb1 = dbb;
175 
176  dbb = 0; // DBB2 comes from UDW9 - UDW16 bit 3, ls bit first
177  for (i = 8; i < 16; i++)
178  {
179  dbb = dbb >> 1;
180  dbb |= (m_payload[i] << 4) & 0x80;
181  }
182  m_dbb2 = dbb;
183  m_rcvDataValid = true;
184  }
185 
186  return status;
187 }
188 
189 
191 {
195 
197  if (AJA_FAILURE(status))
198  return status;
199 
200  // time digits in the even payload words
201  m_payload[ 0] = (m_timeDigits[kTcFrameUnits] & 0x0F) << 4;
202  m_payload[ 2] = (m_timeDigits[kTcFrameTens] & 0x0F) << 4;
203  m_payload[ 4] = (m_timeDigits[kTcSecondUnits] & 0x0F) << 4;
204  m_payload[ 6] = (m_timeDigits[kTcSecondTens] & 0x0F) << 4;
205  m_payload[ 8] = (m_timeDigits[kTcMinuteUnits] & 0x0F) << 4;
206  m_payload[10] = (m_timeDigits[kTcMinuteTens] & 0x0F) << 4;
207  m_payload[12] = (m_timeDigits[kTcHourUnits] & 0x0F) << 4;
208  m_payload[14] = (m_timeDigits[kTcHourTens] & 0x0F) << 4;
209 
210  // binary group data in the odd payload words
211  m_payload[ 1] = (m_binaryGroup[kBg1] & 0x0F) << 4;
212  m_payload[ 3] = (m_binaryGroup[kBg2] & 0x0F) << 4;
213  m_payload[ 5] = (m_binaryGroup[kBg3] & 0x0F) << 4;
214  m_payload[ 7] = (m_binaryGroup[kBg4] & 0x0F) << 4;
215  m_payload[ 9] = (m_binaryGroup[kBg5] & 0x0F) << 4;
216  m_payload[11] = (m_binaryGroup[kBg6] & 0x0F) << 4;
217  m_payload[13] = (m_binaryGroup[kBg7] & 0x0F) << 4;
218  m_payload[15] = (m_binaryGroup[kBg8] & 0x0F) << 4;
219 
220  // add the distributed bits
221  uint8_t i;
222  uint8_t dbb = m_dbb1; // DBB1 goes into UDW1 - 8, ls bit first
223  for (i = 0; i < 8; i++)
224  {
225  m_payload[i] |= (dbb & 0x01) << 3;
226  dbb = dbb >> 1;
227  }
228 
229  dbb = m_dbb2; // DBB2 goes into UDW9 - 16, ls bit first
230  for (i = 8; i < 16; i++)
231  {
232  m_payload[i] |= (dbb & 0x01) << 3;
233  dbb = dbb >> 1;
234  }
235 
237  return AJA_STATUS_SUCCESS;
238 }
239 
240 
241 
243 {
245  SetLocationLineNumber(9); // All but Field2 should go on line 9
246  return SetDBB1(uint8_t(inType));
247 }
248 
249 
251 {
252  uint8_t dbb1;
253  GetDBB1 (dbb1);
255 
256  switch (dbb1)
257  {
267  break;
268 
269  default:
270  break;
271  }
272  return AJA_STATUS_SUCCESS;
273 }
274 
275 
276 
278 {
279  if (pInAncData->GetDataCoding() == AJAAncDataCoding_Digital)
280  if (pInAncData->GetDID() == AJAAncillaryData_SMPTE12M_DID)
281  if (pInAncData->GetSID() == AJAAncillaryData_SMPTE12M_SID)
282  if (pInAncData->GetDC() == AJAAncillaryData_SMPTE12M_PayloadSize)
284  return AJAAncDataType_Unknown;
285 }
286 
287 
288 ostream & AJAAncillaryData_Timecode_ATC::Print (ostream & debugStream, const bool bShowDetail) const
289 {
290  AJAAncillaryData_Timecode::Print (debugStream, bShowDetail); // print the generic stuff
291  debugStream << endl
292  << "DBB1: " << xHEX0N(uint16_t(m_dbb1),2) << endl
293  << "DBB2: " << xHEX0N(uint16_t(m_dbb2),2);
294  return debugStream;
295 }
virtual AJAStatus GetDBB2(uint8_t &dbb2) const
virtual uint8_t GetDID(void) const
virtual AJAStatus SetDBB(uint8_t dbb1, uint8_t dbb2)
virtual AJAStatus GetDBB1(uint8_t &dbb1) const
const uint8_t AJAAncillaryData_SMPTE12M_SID
virtual AJAStatus SetDBB1PayloadType(const AJAAncillaryData_Timecode_ATC_DBB1PayloadType inType)
Sets my payload type.
virtual uint8_t GetSID(void) const
SMPTE 12-M Ancillary Timecode (formerly known as "RP-188")
Definition: ancillarydata.h:48
virtual AJAStatus SetSID(const uint8_t inSID)
Sets my Secondary Data ID (SID) - (aka the Data Block Number (DBN) for "Type 1" SMPTE-291 packets)...
virtual AJAStatus GeneratePayloadData(void)
Generate the payload data from the "local" ancillary data.
virtual AJAStatus SetDID(const uint8_t inDataID)
Sets my Data ID (DID).
AJAStatus
Definition: types.h:380
virtual AJAStatus SetDBB2(uint8_t dbb2)
virtual AJAStatus SetLocationHorizOffset(const uint16_t inOffset)
Sets my ancillary data "location" horizontal offset.
AJAAncDataType m_ancType
One of a known set of ancillary data types (or "Custom" if not identified)
virtual AJAStatus GetDBB(uint8_t &dbb1, uint8_t &dbb2) const
#define AJA_FAILURE(_status_)
Definition: types.h:373
AJAAncDataType
Identifies the ancillary data types that are known to this module.
Definition: ancillarydata.h:44
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 AJAAncillaryData_Timecode_ATC & operator=(const AJAAncillaryData_Timecode_ATC &inRHS)
Assignment operator – replaces my contents with the right-hand-side value.
Definition: json.hpp:5362
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...
AJAAncillaryData_Timecode & operator=(const AJAAncillaryData_Timecode &inRHS)
Assignment operator – replaces my contents with the right-hand-side value.
ByteVector m_payload
My payload data (DC = size)
AJAAncDataCoding m_coding
Analog or digital data.
virtual AJAStatus SetLocationLineNumber(const uint16_t inLineNum)
Sets my ancillary data "location" frame line number.
Includes data that is valid, but we don&#39;t recognize.
Definition: ancillarydata.h:46
AJAAncillaryData_Timecode_ATC()
My default constructor.
virtual uint8_t Calculate8BitChecksum(void) const
Generates an 8-bit checksum from the DID + SID + DC + payload data.
This is the base class for the AJAAncillaryData_Timecode_ATC and AJAAncillaryData_Timecode_VITC class...
#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. ...
static AJAAncDataType RecognizeThisAncillaryData(const AJAAncillaryData *pInAncData)
uint8_t m_SID
Official SMPTE secondary ID (or DBN - w/o parity)
Declares the AJAAncillaryData_Timecode_ATC class.
#define AJAAncDataHorizOffset_AnyHanc
HANC – Packet placed/found in any legal area of raster line after EAV.
virtual void Clear(void)
Frees my allocated memory, if any, and resets my members to their default values. ...
virtual AJAAncDataCoding GetDataCoding(void) const
#define xHEX0N(__x__, __n__)
virtual AJAStatus GetDBB1PayloadType(AJAAncillaryData_Timecode_ATC_DBB1PayloadType &outType) const
Answers with my current payload type.
I am the ATC-specific (analog) subclass of the AJAAncillaryData_Timecode class.
uint8_t m_DID
Official SMPTE ancillary packet ID (w/o parity)
virtual uint32_t GetDC(void) const
const uint32_t AJAAncillaryData_SMPTE12M_PayloadSize
I am the principal class that stores a single SMPTE-291 SDI ancillary data packet OR the digitized co...
bool m_rcvDataValid
This is set true (or not) by ParsePayloadData()
uint8_t m_binaryGroup[kNumBinaryGroups]
virtual AJAStatus ParsePayloadData(void)
Parses out (interprets) the "local" ancillary data from my payload data.
Declares enums and structs used by all platform drivers and the SDK.
AJAAncillaryData_Timecode_ATC_DBB1PayloadType
virtual AJAStatus SetDBB1(uint8_t dbb1)
virtual ~AJAAncillaryData_Timecode_ATC()
My destructor.
virtual AJAStatus SetTimeHexValue(const uint8_t inDigitNum, const uint8_t inHexValue, const uint8_t inMask=0x0f)
Sets my raw "time" hex values.
uint8_t m_timeDigits[kNumTimeDigits]
AJAStatus AllocDataMemory(const uint32_t inNumBytes)
const uint8_t AJAAncillaryData_SMPTE12M_DID
The ancillary data is in the form of a SMPTE-291 Ancillary Packet.
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 AJAStatus SetBinaryGroupHexValue(uint8_t digitNum, uint8_t hexValue, uint8_t mask=0x0f)
Sets my raw "Binary Group" hex values.