AJA NTV2 SDK  18.1.0.2439
NTV2 SDK 18.1.0.2439
ntv2publicinterface.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MIT */
7 #include "ntv2publicinterface.h"
8 #include "ntv2devicefeatures.h"
9 #include "ntv2utils.h"
10 #include "ntv2endian.h"
11 #include "ajabase/system/memory.h"
12 #include "ajabase/system/debug.h"
13 #include "ajabase/system/process.h"
14 #include "ajabase/system/thread.h"
15 #include "ajabase/common/common.h"
16 #include "ntv2registerexpert.h"
17 #include "ntv2nubtypes.h"
18 #include "ntv2version.h"
19 #include "ntv2debug.h"
20 #include <iomanip>
21 #include <locale> // For std::locale, std::numpunct, std::use_facet
22 #include <string.h> // For memset, et al.
23 #include <algorithm> // For set_difference
24 #include <iterator> // For std::inserter
25 #include "ntv2rp188.h"
26 #if !defined(MSWindows)
27  #include <unistd.h>
28 #endif
29 using namespace std;
30 
31 //#define NTV2BUFFER_NO_MEMCMP
32 
33 
35 
36 ostream & operator << (ostream & inOutStream, const NTV2StringList & inData)
37 {
38  for (NTV2StringListConstIter it(inData.begin()); it != inData.end(); )
39  {
40  inOutStream << *it;
41  if (++it != inData.end())
42  inOutStream << ", ";
43  }
44  return inOutStream;
45 }
46 
47 ostream & operator << (ostream & inOutStream, const NTV2StringSet & inData)
48 {
49  for (NTV2StringSetConstIter it(inData.begin()); it != inData.end(); )
50  {
51  inOutStream << *it;
52  if (++it != inData.end())
53  inOutStream << ", ";
54  }
55  return inOutStream;
56 }
57 
58 ostream & operator << (ostream & inOutStr, const NTV2AudioChannelPairs & inSet)
59 {
60  if (inSet.empty())
61  inOutStr << "(none)";
62  else
63  for (NTV2AudioChannelPairsConstIter iter (inSet.begin ()); iter != inSet.end (); ++iter)
64  inOutStr << (iter != inSet.begin() ? ", " : "") << ::NTV2AudioChannelPairToString (*iter, true);
65  return inOutStr;
66 }
67 
68 ostream & operator << (ostream & inOutStr, const NTV2AudioChannelQuads & inSet)
69 {
70  for (NTV2AudioChannelQuadsConstIter iter (inSet.begin ()); iter != inSet.end (); ++iter)
71  inOutStr << (iter != inSet.begin () ? ", " : "") << ::NTV2AudioChannelQuadToString (*iter, true);
72  return inOutStr;
73 }
74 
75 ostream & operator << (ostream & inOutStr, const NTV2AudioChannelOctets & inSet)
76 {
77  for (NTV2AudioChannelOctetsConstIter iter (inSet.begin ()); iter != inSet.end (); ++iter)
78  inOutStr << (iter != inSet.begin () ? ", " : "") << ::NTV2AudioChannelOctetToString (*iter, true);
79  return inOutStr;
80 }
81 
82 ostream & operator << (ostream & inOutStr, const NTV2DoubleArray & inVector)
83 {
84  for (NTV2DoubleArrayConstIter iter (inVector.begin ()); iter != inVector.end (); ++iter)
85  inOutStr << *iter << endl;
86  return inOutStr;
87 }
88 
89 ostream & operator << (ostream & inOutStr, const NTV2DIDSet & inDIDs)
90 {
91  for (NTV2DIDSetConstIter it (inDIDs.begin()); it != inDIDs.end(); )
92  {
93  inOutStr << xHEX0N(uint16_t(*it),2);
94  if (++it != inDIDs.end())
95  inOutStr << ", ";
96  }
97  return inOutStr;
98 }
99 
100 ostream & operator << (ostream & inOutStream, const UWordSequence & inData)
101 {
102  inOutStream << DEC(inData.size()) << " UWords: ";
103  for (UWordSequenceConstIter iter(inData.begin()); iter != inData.end(); )
104  {
105  inOutStream << HEX0N(*iter,4);
106  if (++iter != inData.end())
107  inOutStream << " ";
108  }
109  return inOutStream;
110 }
111 
112 ostream & operator << (ostream & inOutStream, const ULWordSequence & inData)
113 {
114  inOutStream << DEC(inData.size()) << " ULWords: ";
115  for (ULWordSequenceConstIter iter(inData.begin()); iter != inData.end(); )
116  {
117  inOutStream << HEX0N(*iter,8);
118  if (++iter != inData.end())
119  inOutStream << " ";
120  }
121  return inOutStream;
122 }
123 
124 ostream & operator << (ostream & inOutStream, const ULWord64Sequence & inData)
125 {
126  inOutStream << DEC(inData.size()) << " ULWord64s: ";
127  for (ULWord64SequenceConstIter iter(inData.begin()); iter != inData.end(); )
128  {
129  inOutStream << HEX0N(*iter,16);
130  if (++iter != inData.end())
131  inOutStream << " ";
132  }
133  return inOutStream;
134 }
135 
136 
138 {
139  Clear ();
140 }
141 
142 
144 {
145  mCRCTallyA = 0;
146  mCRCTallyB = 0;
147  mUnlockTally = 0;
148  mFrameRefClockCount = 0;
149  mGlobalClockCount = 0;
150  mFrameTRSError = false;
151  mLocked = false;
152  mVPIDValidA = false;
153  mVPIDValidB = false;
154 }
155 
156 
157 ostream & NTV2SDIInputStatus::Print (ostream & inOutStream) const
158 {
159  inOutStream << "[CRCA=" << DEC(mCRCTallyA)
160  << " CRCB=" << DEC(mCRCTallyB)
161  << " unlk=" << xHEX0N(mUnlockTally,8)
162  << " frmRefClkCnt=" << xHEX0N(mFrameRefClockCount,16)
163  << " globalClkCnt=" << xHEX0N(mGlobalClockCount,16)
164  << " frmTRS=" << YesNo(mFrameTRSError)
165  << " locked=" << YesNo(mLocked)
166  << " VPIDA=" << YesNo(mVPIDValidA)
167  << " VPIDB=" << YesNo(mVPIDValidB)
168  << "]";
169  return inOutStream;
170 }
171 
172 
174 {
175  mEnabled = false;
176  mPixel420 = false;
177  mColorSpace = NTV2_INVALID_HDMI_COLORSPACE;
178  mRGBRange = NTV2_INVALID_HDMI_RANGE;
179  mProtocol = NTV2_INVALID_HDMI_PROTOCOL;
180  mVideoStandard = NTV2_STANDARD_INVALID;
181  mVideoRate = NTV2_FRAMERATE_UNKNOWN;
182  mVideoBitDepth = NTV2_INVALID_HDMIBitDepth;
183  mAudioFormat = NTV2_AUDIO_FORMAT_INVALID;
184  mAudioRate = NTV2_AUDIO_RATE_INVALID;
185  mAudioChannels = NTV2_INVALID_HDMI_AUDIO_CHANNELS;
186 }
187 
189 {
190  Clear();
192  if (mVideoRate == NTV2_FRAMERATE_UNKNOWN)
193  return true; // Not enabled -- success
194  mEnabled = true;
195  mPixel420 = ((inData & kVRegMaskHDMOutPixel420) >> kVRegShiftHDMOutPixel420) == 1;
200  mVideoBitDepth = NTV2HDMIBitDepth((inData & kVRegMaskHDMOutBitDepth) >> kVRegShiftHDMOutBitDepth);
204  return true;
205 }
206 
207 ostream & NTV2HDMIOutputStatus::Print (ostream & inOutStream) const
208 {
209  inOutStream << "Enabled: " << YesNo(mEnabled);
210  if (mEnabled)
211  inOutStream << endl
212  << "Is 4:2:0: " << YesNo(mPixel420) << endl
213  << "Color Space: " << ::NTV2HDMIColorSpaceToString(mColorSpace,true) << endl;
214  if (mColorSpace == NTV2_HDMIColorSpaceRGB)
215  inOutStream << "RGB Range: " << ::NTV2HDMIRangeToString(mRGBRange,true) << endl;
216  inOutStream << "Protocol: " << ::NTV2HDMIProtocolToString(mProtocol,true) << endl
217  << "Video Standard: " << ::NTV2StandardToString(mVideoStandard,true) << endl
218  << "Frame Rate: " << ::NTV2FrameRateToString(mVideoRate,true) << endl
219  << "Bit Depth: " << ::NTV2HDMIBitDepthToString(mVideoBitDepth,true) << endl
220  << "Audio Format: " << ::NTV2AudioFormatToString(mAudioFormat,true) << endl
221  << "Audio Rate: " << ::NTV2AudioRateToString(mAudioRate,true) << endl
222  << "Audio Channels: " << ::NTV2HDMIAudioChannelsToString(mAudioChannels,true);
223  return inOutStream;
224 }
225 
226 
228  : mode (AUTOCIRCVIDPROCMODE_MIX),
229  foregroundVideoCrosspoint (NTV2CROSSPOINT_CHANNEL1),
230  backgroundVideoCrosspoint (NTV2CROSSPOINT_CHANNEL1),
231  foregroundKeyCrosspoint (NTV2CROSSPOINT_CHANNEL1),
232  backgroundKeyCrosspoint (NTV2CROSSPOINT_CHANNEL1),
233  transitionCoefficient (0),
234  transitionSoftness (0)
235 {
236 }
237 
238 
240  : eCommand (inCommand),
241  channelSpec (inCrosspoint),
242  lVal1 (0),
243  lVal2 (0),
244  lVal3 (0),
245  lVal4 (0),
246  lVal5 (0),
247  lVal6 (0),
248  bVal1 (false),
249  bVal2 (false),
250  bVal3 (false),
251  bVal4 (false),
252  bVal5 (false),
253  bVal6 (false),
254  bVal7 (false),
255  bVal8 (false),
256  pvVal1 (AJA_NULL),
257  pvVal2 (AJA_NULL),
258  pvVal3 (AJA_NULL),
259  pvVal4 (AJA_NULL)
260 {
261 }
262 
263 ostream & AUTOCIRCULATE_DATA::Print (ostream & oss) const
264 {
265  static const string sCmds [] = {"ACInit","ACStart","ACStop","ACPause","GetAC","ACFrmStmp",
266  "ACFlush","ACPreRoll","ACXfer","ACAbort","ACStartAt",
267  "ACXfer1","ACXfer2","ACFrmStmp2","ACTask","ACSetActFrm"};
268  if (size_t(eCommand) < sizeof(sCmds))
269  { oss << sCmds[eCommand];
270  switch (eCommand)
271  {
272  case eInitAutoCirc:
273  oss << " " << ::NTV2CrosspointToString(channelSpec);
274  oss << " frms " << DEC(lVal1) << "-" << DEC(lVal2);
275  if (lVal4 > 1) oss << " +" << DEC(lVal4) << " chls";
276  if (lVal6 & AUTOCIRCULATE_WITH_FIELDS) oss << " +FieldMode";
277  if (lVal6 & AUTOCIRCULATE_WITH_HDMIAUX) oss << " +HDMIAux";
278  if (bVal2) oss << " +RP188";
279  if (bVal3) oss << " +FBFChg";
280  if (bVal4) oss << " +FBOChg";
281  if (bVal5) oss << " +ColCorr";
282  if (bVal6) oss << " +VidProc";
283  if (bVal7) oss << " +Anc";
284  if (bVal8) oss << " +LTC";
285  oss << " " << ::NTV2AudioSystemToString(NTV2AudioSystem(lVal3 & 0xF), true);
286  if (!bVal1 && ((lVal3 & 0xF) == NTV2_MAX_NUM_AudioSystemEnums)) oss << " +AudCtrl";
287  if (lVal3 & NTV2_AUDIOSYSTEM_Plus1) oss << " +MLAud1";
288  if (lVal3 & NTV2_AUDIOSYSTEM_Plus2) oss << " +MLAud2";
289  if (lVal3 & NTV2_AUDIOSYSTEM_Plus3) oss << " +MLAud3";
290  break;
291  case eStartAutoCirc:
292  break;
294  if (lVal1 || lVal2)
295  oss << " at " << xHEX0N((uint64_t(lVal1) << 32) | uint64_t(lVal2),16);
296  break;
297  case eStopAutoCirc:
298  oss << " " << ::NTV2CrosspointToString(channelSpec);
299  break;
300  case eAbortAutoCirc:
301  oss << " " << ::NTV2CrosspointToString(channelSpec);
302  break;
303  case ePauseAutoCirc:
304  oss << " " << ::NTV2CrosspointToString(channelSpec);
305  if (!bVal1 && lVal6) oss << " at frame " << DEC(lVal6);
306  if (bVal1) oss << " +resume";
307  if (bVal1 && bVal2) oss << " +clearDropCount";
308  break;
309  case eFlushAutoCirculate:
310  oss << " " << ::NTV2CrosspointToString(channelSpec);
311  if (bVal1) oss << " +clearDropCount";
312  break;
314  oss << " " << ::NTV2CrosspointToString(channelSpec) << " " << DEC(ULWord(lVal1)) << " frame(s)";
315  break;
316  case eGetAutoCirc:
317  oss << " " << ::NTV2CrosspointToString(channelSpec);
318  break;
319  case eSetActiveFrame:
320  case eGetFrameStamp:
321  oss << " " << ::NTV2CrosspointToString(channelSpec) << " frm " << DEC(ULWord(lVal1));
322  break;
323  default:
324  break;
325  }
326  }
327  return oss;
328 }
329 
330 
331 NTV2_HEADER::NTV2_HEADER (const ULWord inStructureType, const ULWord inStructSizeInBytes)
332  : fHeaderTag (NTV2_HEADER_TAG),
333  fType (inStructureType),
334  fHeaderVersion (NTV2_CURRENT_HEADER_VERSION),
335  fVersion (AUTOCIRCULATE_STRUCT_VERSION),
336  fSizeInBytes (inStructSizeInBytes),
337  fPointerSize (sizeof(int*)),
338  fOperation (0),
339  fResultStatus (0)
340 {
341 }
342 
343 
344 ostream & operator << (ostream & inOutStream, const NTV2_HEADER & inObj)
345 {
346  return inObj.Print (inOutStream);
347 }
348 
349 
350 ostream & NTV2_HEADER::Print (ostream & inOutStream) const
351 {
352  inOutStream << "[";
353  if (NTV2_IS_VALID_HEADER_TAG (fHeaderTag))
354  inOutStream << NTV2_4CC_AS_STRING (fHeaderTag);
355  else
356  inOutStream << "BAD-" << HEX0N(fHeaderTag,8);
357  if (NTV2_IS_VALID_STRUCT_TYPE (fType))
358  inOutStream << NTV2_4CC_AS_STRING (fType);
359  else
360  inOutStream << "|BAD-" << HEX0N(fType,8);
361  inOutStream << " v" << fHeaderVersion << " vers=" << fVersion << " sz=" << fSizeInBytes;
362  return inOutStream << "]";
363 }
364 
365 string NTV2_HEADER::FourCCToString (const ULWord in4CC, char nonPrintable)
366 {
367  const char * pU32 (reinterpret_cast<const char *>(&in4CC));
368  ostringstream result, fourCC;
369  size_t badTally(0);
370  if (nonPrintable && !::isprint(nonPrintable))
371  nonPrintable = 0; // specified non-printable character to use is itself non-printable: don't use it
372  for (size_t charPos(0); charPos < 4; charPos++)
373  {
374  #if AJATargetBigEndian
375  const char ch (pU32[charPos]);
376  #else // little-endian:
377  const char ch (pU32[3 - charPos]);
378  #endif
379  if (::isprint(ch))
380  fourCC << ch;
381  else
382  {
383  if (nonPrintable)
384  fourCC << nonPrintable;
385  badTally++; // not printable
386  }
387  }
388  if (badTally == 4)
389  result << xHEX0N(in4CC,8); // nothing printable, just show hex value
390  else if (badTally)
391  result << "'" << fourCC.str() << "' (" << xHEX0N(in4CC,8) << ")"; // at least one printable, show 4CC & hex value
392  else
393  result << "'" << fourCC.str() << "'"; // all printable, show 4CC exclusively (no hex value)
394  return result.str();
395 }
396 
397 
398 ostream & operator << (ostream & inOutStream, const NTV2_TRAILER & inObj)
399 {
400  inOutStream << "[";
402  inOutStream << NTV2_4CC_AS_STRING(inObj.fTrailerTag);
403  else
404  inOutStream << "BAD-" << HEX0N(inObj.fTrailerTag,8);
405  return inOutStream << " rawVers=" << xHEX0N(inObj.fTrailerVersion,8) << " clientSDK="
409  << "." << DEC(NTV2SDKVersionDecode_Build(inObj.fTrailerVersion)) << "]";
410 }
411 
412 
413 ostream & operator << (ostream & inOutStream, const NTV2Buffer & inObj)
414 {
415  return inObj.Print (inOutStream);
416 }
417 
418 
419 ostream & NTV2Buffer::Print (ostream & inOutStream) const
420 {
421  inOutStream << (IsAllocatedBySDK() ? "0X" : "0x") << HEX0N(GetRawHostPointer(),16) << "/" << DECN(GetByteCount(),10);
422  return inOutStream;
423 }
424 
425 
426 string NTV2Buffer::AsString (UWord inDumpMaxBytes) const
427 {
428  ostringstream oss;
429  oss << xHEX0N(GetRawHostPointer(),16) << ":" << DEC(GetByteCount()) << " bytes";
430  if (inDumpMaxBytes && GetHostPointer())
431  {
432  oss << ":";
433  if (inDumpMaxBytes > 256)
434  inDumpMaxBytes = 256;
435  if (ULWord(inDumpMaxBytes) > GetByteCount())
436  inDumpMaxBytes = UWord(GetByteCount());
437  const UByte * pBytes (reinterpret_cast<const UByte *>(GetHostPointer()));
438  for (UWord ndx(0); ndx < inDumpMaxBytes; ndx++)
439  oss << HEX0N(uint16_t(pBytes[ndx]),2);
440  }
441  return oss.str();
442 }
443 
444 string NTV2Buffer::AsCode (const size_t inBytesPerWord, const std::string & inVarName, const bool inUseSTL, const bool inByteSwap) const
445 {
446  ostringstream oss;
447  if (inBytesPerWord != 1 && inBytesPerWord != 2 && inBytesPerWord != 4 && inBytesPerWord != 8) return string();
448  NTV2Buffer tmp;
449  if (inBytesPerWord > 1)
450  { // Use a copy for U16s, U32s, or U64s...
451  tmp = *this;
452  if (!tmp)
453  return string();
454  }
455  const string cType (inBytesPerWord == 1 ? "uint8_t" : (inBytesPerWord == 2 ? "uint16_t" : (inBytesPerWord == 4 ? "uint32_t" : "uint64_t")));
456  const size_t numWords (GetByteCount() / inBytesPerWord);
457  const string vecType = "std::vector<" + cType + ">";
458  const string varName (inVarName.empty() ? (inUseSTL ? "tmpVector" : "tmpArray") : inVarName);
459  oss << "const " << (inUseSTL ? vecType : cType) << " " << varName << (inUseSTL ? "" : "[]") << " = {" << endl;
460  if (inByteSwap && inBytesPerWord > 1)
461  switch (inBytesPerWord)
462  {
463  case 2: tmp.ByteSwap16(); break;
464  case 4: tmp.ByteSwap32(); break;
465  case 8: tmp.ByteSwap64(); break;
466  }
467  for (size_t ndx(0); ndx < numWords; )
468  {
469  switch (inBytesPerWord)
470  {
471  case 1: oss << xHEX0N(UWord(U8(int(ndx))),2); break;
472  case 2: oss << xHEX0N(tmp.U16(int(ndx)),4); break;
473  case 4: oss << xHEX0N(tmp.U32(int(ndx)),8); break;
474  case 8: oss << xHEX0N(tmp.U64(int(ndx)),16); break;
475  }
476  if (++ndx < numWords)
477  oss << ",";
478  if (ndx % 128 == 0)
479  oss << endl;
480  }
481  oss << "};" << endl;
482  return oss.str();
483 }
484 
485 bool NTV2Buffer::toHexString (std::string & outStr, const size_t inLineBreakInterval) const
486 {
487  outStr.clear();
488  ostringstream oss;
489  if (GetHostPointer() && GetByteCount())
490  for (int ndx(0); ndx < int(GetByteCount()); )
491  {
492  oss << HEX0N(uint16_t(U8(ndx++)),2);
493  if (inLineBreakInterval && ndx < int(GetByteCount()) && ((size_t(ndx) % inLineBreakInterval) == 0))
494  oss << endl;
495  }
496  outStr = oss.str();
497  return !outStr.empty();
498 }
499 
500 static string print_address_offset (const size_t inRadix, const ULWord64 inOffset)
501 {
502  const streamsize maxAddrWidth (sizeof(ULWord64) * 2);
503  ostringstream oss;
504  if (inRadix == 8)
505  oss << OCT0N(inOffset,maxAddrWidth) << ": ";
506  else if (inRadix == 10)
507  oss << DEC0N(inOffset,maxAddrWidth) << ": ";
508  else
509  oss << xHEX0N(inOffset,maxAddrWidth) << ": ";
510  return oss.str();
511 }
512 
513 ostream & NTV2Buffer::Dump (ostream & inOStream,
514  const size_t inStartOffset,
515  const size_t inByteCount,
516  const size_t inRadix,
517  const size_t inBytesPerGroup,
518  const size_t inGroupsPerRow,
519  const size_t inAddressRadix,
520  const bool inShowAscii,
521  const size_t inAddrOffset) const
522 {
523  if (IsNULL())
524  return inOStream;
525  if (inRadix != 8 && inRadix != 10 && inRadix != 16 && inRadix != 2)
526  return inOStream;
527  if (inAddressRadix != 0 && inAddressRadix != 8 && inAddressRadix != 10 && inAddressRadix != 16)
528  return inOStream;
529  if (inBytesPerGroup == 0) // || inGroupsPerRow == 0)
530  return inOStream;
531 
532  {
533  const void * pInStartAddress (GetHostAddress(ULWord(inStartOffset)));
534  size_t bytesRemaining (inByteCount ? inByteCount : GetByteCount());
535  size_t bytesInThisGroup (0);
536  size_t groupsInThisRow (0);
537  const unsigned maxByteWidth (inRadix == 8 ? 4 : (inRadix == 10 ? 3 : (inRadix == 2 ? 8 : 2)));
538  const UByte * pBuffer (reinterpret_cast <const UByte *> (pInStartAddress));
539  const size_t asciiBufferSize (inShowAscii && inGroupsPerRow ? (inBytesPerGroup * inGroupsPerRow + 1) * sizeof (UByte) : 0); // Size in bytes, not chars
540 
541  if (!pInStartAddress)
542  return inOStream;
543 
544  UByte * pAsciiBuffer (asciiBufferSize ? new UByte[asciiBufferSize / sizeof(UByte)] : AJA_NULL);
545  if (pAsciiBuffer)
546  ::memset (pAsciiBuffer, 0, asciiBufferSize);
547 
548  if (inGroupsPerRow && inAddressRadix)
549  inOStream << print_address_offset (inAddressRadix, ULWord64(pBuffer) - ULWord64(pInStartAddress) + ULWord64(inAddrOffset));
550  while (bytesRemaining)
551  {
552  if (inRadix == 2)
553  inOStream << BIN08(*pBuffer);
554  else if (inRadix == 8)
555  inOStream << oOCT(uint16_t(*pBuffer));
556  else if (inRadix == 10)
557  inOStream << DEC0N(uint16_t(*pBuffer),maxByteWidth);
558  else if (inRadix == 16)
559  inOStream << HEX0N(uint16_t(*pBuffer),2);
560 
561  if (pAsciiBuffer)
562  pAsciiBuffer[groupsInThisRow * inBytesPerGroup + bytesInThisGroup] = isprint(*pBuffer) ? *pBuffer : '.';
563  pBuffer++;
564  bytesRemaining--;
565 
566  bytesInThisGroup++;
567  if (bytesInThisGroup >= inBytesPerGroup)
568  {
569  groupsInThisRow++;
570  if (inGroupsPerRow && groupsInThisRow >= inGroupsPerRow)
571  {
572  if (pAsciiBuffer)
573  {
574  inOStream << " " << pAsciiBuffer;
575  ::memset (pAsciiBuffer, 0, asciiBufferSize);
576  }
577  inOStream << endl;
578  if (inAddressRadix && bytesRemaining)
579  inOStream << print_address_offset (inAddressRadix, reinterpret_cast <ULWord64> (pBuffer) - reinterpret_cast <ULWord64> (pInStartAddress) + ULWord64 (inAddrOffset));
580  groupsInThisRow = 0;
581  } // if time for new row
582  else
583  inOStream << " ";
584  bytesInThisGroup = 0;
585  } // if time for new group
586  } // loop til no bytes remaining
587 
588  if (bytesInThisGroup && bytesInThisGroup < inBytesPerGroup && pAsciiBuffer)
589  {
590  groupsInThisRow++;
591  inOStream << string ((inBytesPerGroup - bytesInThisGroup) * maxByteWidth + 1, ' ');
592  }
593 
594  if (groupsInThisRow)
595  {
596  if (groupsInThisRow < inGroupsPerRow && pAsciiBuffer)
597  inOStream << string (((inGroupsPerRow - groupsInThisRow) * inBytesPerGroup * maxByteWidth + (inGroupsPerRow - groupsInThisRow)), ' ');
598  if (pAsciiBuffer)
599  inOStream << pAsciiBuffer;
600  inOStream << endl;
601  }
602  else if (bytesInThisGroup && bytesInThisGroup < inBytesPerGroup)
603  inOStream << endl;
604 
605  if (pAsciiBuffer)
606  delete [] pAsciiBuffer;
607  } // else radix is 16, 10, 8 or 2
608 
609  return inOStream;
610 } // Dump
611 
612 string & NTV2Buffer::Dump ( string & inOutputString,
613  const size_t inStartOffset,
614  const size_t inByteCount,
615  const size_t inRadix,
616  const size_t inBytesPerGroup,
617  const size_t inGroupsPerRow,
618  const size_t inAddressRadix,
619  const bool inShowAscii,
620  const size_t inAddrOffset) const
621 {
622  ostringstream oss;
623  Dump (oss, inStartOffset, inByteCount, inRadix, inBytesPerGroup, inGroupsPerRow, inAddressRadix, inShowAscii, inAddrOffset);
624  inOutputString = oss.str();
625  return inOutputString;
626 }
627 
628 NTV2Buffer & NTV2Buffer::Segment (NTV2Buffer & outPtr, const ULWord inByteOffset, const ULWord inByteCount) const
629 {
630  outPtr.Set(AJA_NULL, 0); // Make invalid
631  if (inByteOffset >= GetByteCount())
632  return outPtr; // Offset past end
633  if (inByteOffset+inByteCount > GetByteCount())
634  return outPtr; // Segment too long
635  outPtr.Set(GetHostAddress(inByteOffset), inByteCount);
636  return outPtr;
637 }
638 
639 
640 bool NTV2Buffer::GetU64s (ULWord64Sequence & outUint64s, const size_t inU64Offset, const size_t inMaxSize, const bool inByteSwap) const
641 {
642  outUint64s.clear();
643  if (IsNULL())
644  return false;
645 
646  size_t maxSize (size_t(GetByteCount()) / sizeof(uint64_t));
647  if (maxSize < inU64Offset)
648  return false; // Past end
649  maxSize -= inU64Offset; // Remove starting offset
650 
651  const uint64_t * pU64 (reinterpret_cast <const uint64_t *> (GetHostAddress(ULWord(inU64Offset * sizeof(uint64_t)))));
652  if (!pU64)
653  return false; // Past end
654 
655  if (inMaxSize && inMaxSize < maxSize)
656  maxSize = inMaxSize;
657 
658  try
659  {
660  outUint64s.reserve(maxSize);
661  for (size_t ndx(0); ndx < maxSize; ndx++)
662  {
663  const uint64_t u64 (*pU64++);
664  outUint64s.push_back(inByteSwap ? NTV2EndianSwap64(u64) : u64);
665  }
666  }
667  catch (...)
668  {
669  outUint64s.clear();
670  outUint64s.reserve(0);
671  return false;
672  }
673  return true;
674 }
675 
676 
677 bool NTV2Buffer::GetU32s (ULWordSequence & outUint32s, const size_t inU32Offset, const size_t inMaxSize, const bool inByteSwap) const
678 {
679  outUint32s.clear();
680  if (IsNULL())
681  return false;
682 
683  size_t maxNumU32s (size_t(GetByteCount()) / sizeof(uint32_t));
684  if (maxNumU32s < inU32Offset)
685  return false; // Past end
686  maxNumU32s -= inU32Offset; // Remove starting offset
687 
688  const uint32_t * pU32 (reinterpret_cast<const uint32_t*>(GetHostAddress(ULWord(inU32Offset * sizeof(uint32_t)))));
689  if (!pU32)
690  return false; // Past end
691 
692  if (inMaxSize && inMaxSize < maxNumU32s)
693  maxNumU32s = inMaxSize;
694 
695  try
696  {
697  outUint32s.reserve(maxNumU32s);
698  for (size_t ndx(0); ndx < maxNumU32s; ndx++)
699  {
700  const uint32_t u32 (*pU32++);
701  outUint32s.push_back(inByteSwap ? NTV2EndianSwap32(u32) : u32);
702  }
703  }
704  catch (...)
705  {
706  outUint32s.clear();
707  outUint32s.reserve(0);
708  return false;
709  }
710  return true;
711 }
712 
713 
714 bool NTV2Buffer::GetU16s (UWordSequence & outUint16s, const size_t inU16Offset, const size_t inMaxSize, const bool inByteSwap) const
715 {
716  outUint16s.clear();
717  if (IsNULL())
718  return false;
719 
720  size_t maxSize (size_t(GetByteCount()) / sizeof(uint16_t));
721  if (maxSize < inU16Offset)
722  return false; // Past end
723  maxSize -= inU16Offset; // Remove starting offset
724 
725  const uint16_t * pU16 (reinterpret_cast <const uint16_t *> (GetHostAddress(ULWord(inU16Offset * sizeof(uint16_t)))));
726  if (!pU16)
727  return false; // Past end
728 
729  if (inMaxSize && inMaxSize < maxSize)
730  maxSize = inMaxSize;
731 
732  try
733  {
734  outUint16s.reserve(maxSize);
735  for (size_t ndx(0); ndx < maxSize; ndx++)
736  {
737  const uint16_t u16 (*pU16++);
738  outUint16s.push_back(inByteSwap ? NTV2EndianSwap16(u16) : u16);
739  }
740  }
741  catch (...)
742  {
743  outUint16s.clear();
744  outUint16s.reserve(0);
745  return false;
746  }
747  return true;
748 }
749 
750 
751 bool NTV2Buffer::GetU8s (UByteSequence & outUint8s, const size_t inU8Offset, const size_t inMaxSize) const
752 {
753  outUint8s.clear();
754  if (IsNULL())
755  return false;
756 
757  size_t maxSize (GetByteCount());
758  if (maxSize < inU8Offset)
759  return false; // Past end
760  maxSize -= inU8Offset; // Remove starting offset
761 
762  const uint8_t * pU8 (reinterpret_cast <const uint8_t *> (GetHostAddress(ULWord(inU8Offset))));
763  if (!pU8)
764  return false; // Past end
765 
766  if (inMaxSize && inMaxSize < maxSize)
767  maxSize = inMaxSize;
768 
769  try
770  {
771  outUint8s.reserve(maxSize);
772  for (size_t ndx(0); ndx < maxSize; ndx++)
773  outUint8s.push_back(*pU8++);
774  }
775  catch (...)
776  {
777  outUint8s.clear();
778  outUint8s.reserve(0);
779  return false;
780  }
781  return true;
782 }
783 
785 {
786  const uint8_t * pU8 (reinterpret_cast<const uint8_t*> (GetHostPointer()));
787  if (!pU8)
788  return false; // Past end
789  const size_t maxSize (GetByteCount());
790  try
791  {
792  outU8s.reserve(outU8s.size() + maxSize);
793  outU8s.insert(outU8s.end(),pU8, pU8 + maxSize);
794  }
795  catch (...)
796  {
797  return false;
798  }
799  return true;
800 }
801 
802 
803 bool NTV2Buffer::GetString (std::string & outString, const size_t inU8Offset, const size_t inMaxSize) const
804 {
805  outString.clear();
806  if (IsNULL())
807  return false;
808 
809  size_t maxSize(GetByteCount());
810  if (maxSize < inU8Offset)
811  return false; // Past end
812  maxSize -= inU8Offset; // Remove starting offset
813 
814  const uint8_t * pU8 (reinterpret_cast <const uint8_t *> (GetHostAddress(ULWord(inU8Offset))));
815  if (!pU8)
816  return false; // Past end
817 
818  if (inMaxSize && inMaxSize < maxSize)
819  maxSize = inMaxSize;
820 
821  try
822  {
823  outString.reserve(maxSize);
824  for (size_t ndx(0); ndx < maxSize; ndx++)
825  {
826  const char c = *pU8++;
827  if (c)
828  outString += c;
829  else
830  break;
831  }
832  }
833  catch (...)
834  {
835  outString.clear();
836  outString.reserve(0);
837  return false;
838  }
839  return true;
840 }
841 
842 
843 bool NTV2Buffer::PutU64s (const ULWord64Sequence & inU64s, const size_t inU64Offset, const bool inByteSwap)
844 {
845  if (IsNULL())
846  return false; // No buffer or space
847  if (inU64s.empty())
848  return true; // Nothing to copy
849 
850  size_t maxU64s (GetByteCount() / sizeof(uint64_t));
851  uint64_t * pU64 (reinterpret_cast<uint64_t*>(GetHostAddress(ULWord(inU64Offset * sizeof(uint64_t)))));
852  if (!pU64)
853  return false; // Start offset is past end
854  if (maxU64s > inU64Offset)
855  maxU64s -= inU64Offset; // Don't go past end
856  if (maxU64s > inU64s.size())
857  maxU64s = inU64s.size(); // Truncate incoming vector to not go past my end
858  if (inU64s.size() > maxU64s)
859  return false; // Will write past end
860 
861  for (unsigned ndx(0); ndx < maxU64s; ndx++)
862 #if defined(_DEBUG)
863  *pU64++ = inByteSwap ? NTV2EndianSwap64(inU64s.at(ndx)) : inU64s.at(ndx);
864 #else
865  *pU64++ = inByteSwap ? NTV2EndianSwap64(inU64s[ndx]) : inU64s[ndx];
866 #endif
867  return true;
868 }
869 
870 
871 bool NTV2Buffer::PutU32s (const ULWordSequence & inU32s, const size_t inU32Offset, const bool inByteSwap)
872 {
873  if (IsNULL())
874  return false; // No buffer or space
875  if (inU32s.empty())
876  return true; // Nothing to copy
877 
878  size_t maxU32s (GetByteCount() / sizeof(uint32_t));
879  uint32_t * pU32 (reinterpret_cast<uint32_t*>(GetHostAddress(ULWord(inU32Offset * sizeof(uint32_t)))));
880  if (!pU32)
881  return false; // Start offset is past end
882  if (maxU32s > inU32Offset)
883  maxU32s -= inU32Offset; // Don't go past end
884  if (maxU32s > inU32s.size())
885  maxU32s = inU32s.size(); // Truncate incoming vector to not go past my end
886  if (inU32s.size() > maxU32s)
887  return false; // Will write past end
888 
889  for (unsigned ndx(0); ndx < maxU32s; ndx++)
890 #if defined(_DEBUG)
891  *pU32++ = inByteSwap ? NTV2EndianSwap32(inU32s.at(ndx)) : inU32s.at(ndx);
892 #else
893  *pU32++ = inByteSwap ? NTV2EndianSwap32(inU32s[ndx]) : inU32s[ndx];
894 #endif
895  return true;
896 }
897 
898 
899 bool NTV2Buffer::PutU16s (const UWordSequence & inU16s, const size_t inU16Offset, const bool inByteSwap)
900 {
901  if (IsNULL())
902  return false; // No buffer or space
903  if (inU16s.empty())
904  return true; // Nothing to copy
905 
906  size_t maxU16s (GetByteCount() / sizeof(uint16_t));
907  uint16_t * pU16 (reinterpret_cast<uint16_t*>(GetHostAddress(ULWord(inU16Offset * sizeof(uint16_t)))));
908  if (!pU16)
909  return false; // Start offset is past end
910  if (maxU16s > inU16Offset)
911  maxU16s -= inU16Offset; // Don't go past end
912  if (maxU16s > inU16s.size())
913  maxU16s = inU16s.size(); // Truncate incoming vector to not go past my end
914  if (inU16s.size() > maxU16s)
915  return false; // Will write past end
916 
917  for (unsigned ndx(0); ndx < maxU16s; ndx++)
918 #if defined(_DEBUG)
919  *pU16++ = inByteSwap ? NTV2EndianSwap16(inU16s.at(ndx)) : inU16s.at(ndx);
920 #else
921  *pU16++ = inByteSwap ? NTV2EndianSwap16(inU16s[ndx]) : inU16s[ndx];
922 #endif
923  return true;
924 }
925 
926 
927 bool NTV2Buffer::PutU8s (const UByteSequence & inU8s, const size_t inU8Offset)
928 {
929  if (IsNULL())
930  return false; // No buffer or space
931  if (inU8s.empty())
932  return true; // Nothing to copy
933 
934  size_t maxU8s (GetByteCount());
935  uint8_t * pU8 (reinterpret_cast<uint8_t*>(GetHostAddress(ULWord(inU8Offset))));
936  if (!pU8)
937  return false; // Start offset is past end
938  if (maxU8s > inU8Offset)
939  maxU8s -= inU8Offset; // Don't go past end
940  if (maxU8s > inU8s.size())
941  maxU8s = inU8s.size(); // Truncate incoming vector to not go past end
942  if (inU8s.size() > maxU8s)
943  return false; // Will write past end
944 #if 1
945  ::memcpy(pU8, &inU8s[0], maxU8s);
946 #else
947  for (unsigned ndx(0); ndx < maxU8s; ndx++)
948  #if defined(_DEBUG)
949  *pU8++ = inU8s.at(ndx);
950  #else
951  *pU8++ = inU8s[ndx];
952  #endif
953 #endif
954  return true;
955 }
956 
957 
958 ostream & operator << (ostream & inOutStream, const NTV2_RP188 & inObj)
959 {
960  if (inObj.IsValid ())
961  return inOutStream << "{Dx" << HEX0N(inObj.fDBB,8) << "|Lx" << HEX0N(inObj.fLo,8) << "|Hx" << HEX0N(inObj.fHi,8) << "}";
962  else
963  return inOutStream << "{invalid}";
964 }
965 
966 
968 {
969  inOutList.push_back (inRP188);
970  return inOutList;
971 }
972 
973 
974 ostream & operator << (ostream & inOutStream, const NTV2TimeCodeList & inObj)
975 {
976  inOutStream << inObj.size () << ":[";
977  for (NTV2TimeCodeListConstIter iter (inObj.begin ()); iter != inObj.end (); )
978  {
979  inOutStream << *iter;
980  if (++iter != inObj.end ())
981  inOutStream << ", ";
982  }
983  return inOutStream << "]";
984 }
985 
986 
987 ostream & operator << (std::ostream & inOutStream, const NTV2TimeCodes & inObj)
988 {
989  inOutStream << inObj.size () << ":[";
990  for (NTV2TimeCodesConstIter iter (inObj.begin ()); iter != inObj.end (); )
991  {
992  inOutStream << ::NTV2TCIndexToString (iter->first,true) << "=" << iter->second;
993  if (++iter != inObj.end ())
994  inOutStream << ", ";
995  }
996  return inOutStream << "]";
997 }
998 
999 
1000 ostream & operator << (std::ostream & inOutStream, const NTV2TCIndexes & inObj)
1001 {
1002  for (NTV2TCIndexesConstIter iter (inObj.begin ()); iter != inObj.end (); )
1003  {
1004  inOutStream << ::NTV2TCIndexToString (*iter);
1005  if (++iter != inObj.end ())
1006  inOutStream << ", ";
1007  }
1008  return inOutStream;
1009 }
1010 
1011 
1013 {
1014  for (NTV2TCIndexesConstIter iter (inSet.begin ()); iter != inSet.end (); ++iter)
1015  inOutSet.insert (*iter);
1016  return inOutSet;
1017 }
1018 
1019 
1020 ostream & operator << (ostream & inOutStream, const FRAME_STAMP & inObj)
1021 {
1022  return inOutStream << inObj.acHeader
1023  << " frmTime=" << inObj.acFrameTime
1024  << " reqFrm=" << inObj.acRequestedFrame
1025  << " audClkTS=" << inObj.acAudioClockTimeStamp
1026  << " audExpAdr=" << hex << inObj.acAudioExpectedAddress << dec
1027  << " audInStrtAdr=" << hex << inObj.acAudioInStartAddress << dec
1028  << " audInStopAdr=" << hex << inObj.acAudioInStopAddress << dec
1029  << " audOutStrtAdr=" << hex << inObj.acAudioOutStartAddress << dec
1030  << " audOutStopAdr=" << hex << inObj.acAudioOutStopAddress << dec
1031  << " totBytes=" << inObj.acTotalBytesTransferred
1032  << " strtSamp=" << inObj.acStartSample
1033  << " curTime=" << inObj.acCurrentTime
1034  << " curFrm=" << inObj.acCurrentFrame
1035  << " curFrmTime=" << inObj.acCurrentFrameTime
1036  << " audClkCurTime=" << inObj.acAudioClockCurrentTime
1037  << " curAudExpAdr=" << hex << inObj.acCurrentAudioExpectedAddress << dec
1038  << " curAudStrtAdr=" << hex << inObj.acCurrentAudioStartAddress << dec
1039  << " curFldCnt=" << inObj.acCurrentFieldCount
1040  << " curLnCnt=" << inObj.acCurrentLineCount
1041  << " curReps=" << inObj.acCurrentReps
1042  << " curUsrCookie=" << hex << inObj.acCurrentUserCookie << dec
1043  << " acFrame=" << inObj.acFrame
1044  << " acRP188=" << inObj.acRP188 // deprecated
1045  << " " << inObj.acTrailer;
1046 }
1047 
1048 
1049 ostream & operator << (ostream & inOutStream, const NTV2SegmentedDMAInfo & inObj)
1050 {
1051  if (inObj.acNumSegments > 1)
1052  inOutStream << "segs=" << inObj.acNumSegments << " numActBPR=" << inObj.acNumActiveBytesPerRow
1053  << " segHostPitc=" << inObj.acSegmentHostPitch << " segDevPitc=" << inObj.acSegmentDevicePitch;
1054  else
1055  inOutStream << "n/a";
1056  return inOutStream;
1057 }
1058 
1059 
1060 ostream & operator << (ostream & inOutStream, const AUTOCIRCULATE_TRANSFER & inObj)
1061 {
1062  #if defined (_DEBUG)
1063  NTV2_ASSERT (inObj.NTV2_IS_STRUCT_VALID ());
1064  #endif
1065  string str (::NTV2FrameBufferFormatToString (inObj.acFrameBufferFormat, true));
1066  while (str.find (' ') != string::npos)
1067  str.erase (str.find (' '), 1);
1068  inOutStream << inObj.acHeader << " vid=" << inObj.acVideoBuffer
1069  << " aud=" << inObj.acAudioBuffer
1070  << " ancF1=" << inObj.acANCBuffer
1071  << " ancF2=" << inObj.acANCField2Buffer
1072  << " outTC(" << inObj.acOutputTimeCodes << ")"
1073  << " cookie=" << inObj.acInUserCookie
1074  << " vidDMAoff=" << inObj.acInVideoDMAOffset
1075  << " segDMA=" << inObj.acInSegmentedDMAInfo
1076  << " colcor=" << inObj.acColorCorrection
1077  << " fbf=" << str
1078  << " fbo=" << (inObj.acFrameBufferOrientation == NTV2_FRAMEBUFFER_ORIENTATION_BOTTOMUP ? "flip" : "norm")
1079  << " vidProc=" << inObj.acVidProcInfo
1080  << " quartsz=" << inObj.acVideoQuarterSizeExpand
1081  << " p2p=" << inObj.acPeerToPeerFlags
1082  << " repCnt=" << inObj.acFrameRepeatCount
1083  << " desFrm=" << inObj.acDesiredFrame
1084  << " rp188=" << inObj.acRP188 // deprecated
1085  << " xpt=" << inObj.acCrosspoint
1086  << " status{" << inObj.acTransferStatus << "}"
1087  << " " << inObj.acTrailer;
1088  return inOutStream;
1089 }
1090 
1091 
1092 ostream & operator << (ostream & inOutStream, const AUTOCIRCULATE_TRANSFER_STATUS & inObj)
1093 {
1094  inOutStream << inObj.acHeader << " state=" << ::NTV2AutoCirculateStateToString (inObj.acState)
1095  << " xferFrm=" << inObj.acTransferFrame
1096  << " bufLvl=" << inObj.acBufferLevel
1097  << " frms=" << inObj.acFramesProcessed
1098  << " drops=" << inObj.acFramesDropped
1099  << " " << inObj.acFrameStamp
1100  << " audXfrSz=" << inObj.acAudioTransferSize
1101  << " audStrtSamp=" << inObj.acAudioStartSample
1102  << " ancF1Siz=" << inObj.acAncTransferSize
1103  << " ancF2Siz=" << inObj.acAncField2TransferSize
1104  << " " << inObj.acTrailer;
1105  return inOutStream;
1106 }
1107 
1108 
1109 ostream & operator << (ostream & inOutStream, const NTV2RegisterValueMap & inObj)
1110 {
1111  NTV2RegValueMapConstIter iter (inObj.begin ());
1112  inOutStream << "RegValues:" << inObj.size () << "[";
1113  while (iter != inObj.end ())
1114  {
1115  const NTV2RegisterNumber registerNumber (static_cast <NTV2RegisterNumber> (iter->first));
1116  const ULWord registerValue (iter->second);
1117  inOutStream << ::NTV2RegisterNumberToString (registerNumber) << "=0x" << hex << registerValue << dec;
1118  if (++iter != inObj.end ())
1119  inOutStream << ",";
1120  }
1121  return inOutStream << "]";
1122 }
1123 
1124 
1125 ostream & operator << (ostream & inOutStream, const AutoCircVidProcInfo & inObj)
1126 {
1127  return inOutStream << "{mode=" << ::AutoCircVidProcModeToString (inObj.mode, true)
1128  << ", FGvid=" << ::NTV2CrosspointToString (inObj.foregroundVideoCrosspoint)
1129  << ", BGvid=" << ::NTV2CrosspointToString (inObj.backgroundVideoCrosspoint)
1130  << ", FGkey=" << ::NTV2CrosspointToString (inObj.foregroundKeyCrosspoint)
1131  << ", BGkey=" << ::NTV2CrosspointToString (inObj.backgroundKeyCrosspoint)
1132  << ", transCoeff=" << inObj.transitionCoefficient
1133  << ", transSoftn=" << inObj.transitionSoftness << "}";
1134 }
1135 
1136 
1137 ostream & operator << (ostream & inOutStream, const NTV2ColorCorrectionData & inObj)
1138 {
1139  return inOutStream << "{ccMode=" << ::NTV2ColorCorrectionModeToString (inObj.ccMode)
1140  << ", ccSatVal=" << inObj.ccSaturationValue
1141  << ", ccTables=" << inObj.ccLookupTables << "}";
1142 }
1143 
1144 
1146 {
1147  for (NTV2VideoFormatSetConstIter iter(inSet.begin()); iter != inSet.end(); ++iter)
1148  if (inOutSet.find(*iter) == inOutSet.end())
1149  inOutSet.insert(*iter);
1150  return inOutSet;
1151 }
1152 
1153 
1154 // Implementation of NTV2VideoFormatSet's ostream writer...
1155 ostream & operator << (ostream & inOStream, const NTV2VideoFormatSet & inFormats)
1156 {
1157  NTV2VideoFormatSet::const_iterator iter (inFormats.begin ());
1158 
1159  inOStream << inFormats.size ()
1160  << (inFormats.size () == 1 ? " video format: " : " video format(s): ");
1161 
1162  while (iter != inFormats.end ())
1163  {
1164  inOStream << std::string (::NTV2VideoFormatToString (*iter));
1165  inOStream << (++iter == inFormats.end () ? "" : ", ");
1166  }
1167 
1168  return inOStream;
1169 
1170 } // operator <<
1171 
1172 
1173 // Implementation of NTV2FrameBufferFormatSet's ostream writer...
1174 ostream & operator << (ostream & inOStream, const NTV2PixelFormats & inFormats)
1175 {
1176  NTV2PixelFormatsConstIter iter(inFormats.begin());
1177  inOStream << inFormats.size()
1178  << (inFormats.size() == 1 ? " pixel format: " : " pixel formats: ");
1179 
1180  while (iter != inFormats.end())
1181  {
1182  inOStream << ::NTV2FrameBufferFormatToString(*iter);
1183  inOStream << (++iter == inFormats.end() ? "" : ", ");
1184  }
1185  return inOStream;
1186 
1187 } // operator <<
1188 
1189 
1191 {
1192  for (NTV2PixelFormatsConstIter iter(inFBFs.begin()); iter != inFBFs.end(); ++iter)
1193  inOutSet.insert(*iter);
1194  return inOutSet;
1195 }
1196 
1197 
1198 // Implementation of NTV2StandardSet's ostream writer...
1199 ostream & operator << (ostream & inOStream, const NTV2StandardSet & inStandards)
1200 {
1201  NTV2StandardSetConstIter iter (inStandards.begin ());
1202 
1203  inOStream << inStandards.size ()
1204  << (inStandards.size () == 1 ? " standard: " : " standards: ");
1205 
1206  while (iter != inStandards.end ())
1207  {
1208  inOStream << ::NTV2StandardToString(*iter);
1209  inOStream << (++iter == inStandards.end () ? "" : ", ");
1210  }
1211 
1212  return inOStream;
1213 }
1214 
1215 
1217 {
1218  for (NTV2StandardSetConstIter iter(inSet.begin ()); iter != inSet.end(); ++iter)
1219  inOutSet.insert(*iter);
1220  return inOutSet;
1221 }
1222 
1223 
1224 // Implementation of NTV2GeometrySet's ostream writer...
1225 ostream & operator << (ostream & inOStream, const NTV2GeometrySet & inGeometries)
1226 {
1227  NTV2GeometrySetConstIter iter (inGeometries.begin ());
1228  inOStream << inGeometries.size ()
1229  << (inGeometries.size () == 1 ? " geometry: " : " geometries: ");
1230  while (iter != inGeometries.end ())
1231  {
1232  inOStream << ::NTV2FrameGeometryToString(*iter);
1233  inOStream << (++iter == inGeometries.end () ? "" : ", ");
1234  }
1235  return inOStream;
1236 }
1237 
1238 
1240 {
1241  for (NTV2GeometrySetConstIter iter(inSet.begin ()); iter != inSet.end(); ++iter)
1242  inOutSet.insert(*iter);
1243  return inOutSet;
1244 }
1245 
1246 
1247 // Implementation of NTV2FrameBufferFormatSet's ostream writer...
1248 ostream & operator << (ostream & inOStream, const NTV2InputSourceSet & inSet)
1249 {
1250  NTV2InputSourceSetConstIter iter(inSet.begin());
1251  inOStream << inSet.size()
1252  << (inSet.size() == 1 ? " input: " : " inputs: ");
1253  while (iter != inSet.end())
1254  {
1255  inOStream << ::NTV2InputSourceToString (*iter);
1256  inOStream << (++iter == inSet.end() ? "" : ", ");
1257  }
1258  return inOStream;
1259 } // operator <<
1260 
1261 
1263 {
1264  for (NTV2InputSourceSetConstIter iter (inSet.begin ()); iter != inSet.end (); ++iter)
1265  inOutSet.insert (*iter);
1266  return inOutSet;
1267 }
1268 
1269 
1270 ostream & operator << (ostream & inOStream, const NTV2OutputDestinations & inSet)
1271 {
1272  NTV2OutputDestinationsConstIter iter(inSet.begin());
1273  inOStream << inSet.size()
1274  << (inSet.size() == 1 ? " output: " : " outputs: ");
1275  while (iter != inSet.end())
1276  {
1277  inOStream << ::NTV2OutputDestinationToString(*iter);
1278  inOStream << (++iter == inSet.end() ? "" : ", ");
1279  }
1280  return inOStream;
1281 }
1282 
1283 
1285 {
1286  for (NTV2OutputDestinationsConstIter iter(inSet.begin()); iter != inSet.end(); ++iter)
1287  inOutSet.insert(*iter);
1288  return inOutSet;
1289 }
1290 
1292 {
1293  outFormats.clear();
1294  const NTV2DeviceIDSet devIDs (::NTV2GetSupportedDevices());
1295  for (NTV2DeviceIDSetConstIter it(devIDs.begin()); it != devIDs.end(); ++it)
1296  {
1297  NTV2PixelFormats fmts;
1299  for (NTV2PixelFormatsConstIter fit(fmts.begin()); fit != fmts.end(); ++fit)
1300  if (outFormats.find(*fit) == outFormats.end())
1301  outFormats.insert(*fit);
1302  }
1303  return true;
1304 }
1305 
1307 {
1308  NTV2PixelFormats usedFormats;
1309  ::NTV2GetSupportedPixelFormats(usedFormats);
1310  for (NTV2PixelFormat pf(NTV2_FBF_FIRST); pf < NTV2_FBF_LAST; pf = NTV2PixelFormat(pf+1))
1311  if (usedFormats.find(pf) == usedFormats.end()) // if unused
1312  outFormats.insert(pf);
1313  return true;
1314 }
1315 
1317 {
1318  outStandards.clear();
1319  const NTV2DeviceIDSet devIDs (::NTV2GetSupportedDevices());
1320  for (NTV2DeviceIDSetConstIter it(devIDs.begin()); it != devIDs.end(); ++it)
1321  {
1322  NTV2StandardSet stds;
1324  for (NTV2StandardSetConstIter sit(stds.begin()); sit != stds.end(); ++sit)
1325  if (outStandards.find(*sit) == outStandards.end())
1326  outStandards.insert(*sit);
1327  }
1328  return true;
1329 }
1330 
1332 {
1333  NTV2StandardSet usedStandards;
1334  ::NTV2GetSupportedStandards(usedStandards);
1336  if (usedStandards.find(st) == usedStandards.end()) // if unused
1337  outStandards.insert(st);
1338  return true;
1339 }
1340 
1341 
1342 // This needs to be moved into a C++ compatible "device features" module:
1344 {
1345  bool isOkay(true);
1346  outFormats.clear();
1347 
1349  {
1350  if (inDeviceID != DEVICE_ID_INVALID && !::NTV2DeviceCanDoVideoFormat(inDeviceID, vf))
1351  continue; // Valid devID specified and VF not supported on that device
1352  if (inDeviceID == DEVICE_ID_INVALID && !NTV2_IS_VALID_VIDEO_FORMAT(vf))
1353  continue; // Invalid devID specified and invalid VF
1354  try
1355  {
1356  outFormats.insert(vf);
1357  }
1358  catch (const std::bad_alloc &)
1359  {
1360  isOkay = false;
1361  outFormats.clear();
1362  break;
1363  }
1364  } // for each video format
1365 
1366  NTV2_ASSERT ((isOkay && !outFormats.empty()) || (!isOkay && outFormats.empty()));
1367  return isOkay;
1368 
1369 } // NTV2DeviceGetSupportedVideoFormats
1370 
1371 // This needs to be moved into a C++ compatible "device features" module:
1373 {
1374  bool isOkay(true);
1375  outFormats.clear();
1376 
1377  for (NTV2PixelFormat pixelFormat(NTV2_FBF_FIRST); pixelFormat < NTV2_FBF_LAST; pixelFormat = NTV2PixelFormat(pixelFormat+1))
1378  if (::NTV2DeviceCanDoFrameBufferFormat (inDeviceID, pixelFormat))
1379  try
1380  {
1381  outFormats.insert(pixelFormat);
1382  }
1383  catch (const std::bad_alloc &)
1384  {
1385  isOkay = false;
1386  outFormats.clear();
1387  break;
1388  }
1389 
1391  if (supportedDevices.find(inDeviceID) != supportedDevices.end())
1392  {// NTV2_ASSERT ((isOkay && !outFormats.empty() ) || (!isOkay && outFormats.empty() ));
1393  return isOkay && !outFormats.empty();
1394  }
1395  return isOkay;
1396 
1397 } // NTV2DeviceGetSupportedPixelFormats
1398 
1399 // This needs to be moved into a C++ compatible "device features" module:
1400 bool NTV2DeviceGetSupportedStandards (const NTV2DeviceID inDeviceID, NTV2StandardSet & outStandards)
1401 {
1402  NTV2VideoFormatSet videoFormats;
1403  outStandards.clear();
1404  if (!::NTV2DeviceGetSupportedVideoFormats(inDeviceID, videoFormats))
1405  return false;
1406  for (NTV2VideoFormatSetConstIter it(videoFormats.begin()); it != videoFormats.end(); ++it)
1407  {
1409  if (NTV2_IS_VALID_STANDARD(std) && outStandards.find(std) == outStandards.end())
1410  outStandards.insert(std);
1411  }
1412  return true;
1413 }
1414 
1415 // This needs to be moved into a C++ compatible "device features" module:
1416 bool NTV2DeviceGetSupportedGeometries (const NTV2DeviceID inDeviceID, NTV2GeometrySet & outGeometries)
1417 {
1418  NTV2VideoFormatSet videoFormats;
1419  outGeometries.clear();
1420  if (!::NTV2DeviceGetSupportedVideoFormats(inDeviceID, videoFormats))
1421  return false;
1422  for (NTV2VideoFormatSetConstIter it(videoFormats.begin()); it != videoFormats.end(); ++it)
1423  {
1426  outGeometries += ::GetRelatedGeometries(fg);
1427  }
1428  return true;
1429 }
1430 
1431 bool NTV2DeviceGetSupportedInputSources (const NTV2DeviceID inDeviceID, NTV2InputSourceSet & outInputSources, const NTV2IOKinds inKinds)
1432 {
1433  outInputSources.clear();
1434  if (!NTV2_IS_VALID_IOKINDS(inKinds))
1435  return false;
1437  { const bool ok (inDeviceID == DEVICE_ID_INVALID ? true : ::NTV2DeviceCanDoInputSource(inDeviceID, src));
1438  if (ok)
1439  if ( (NTV2_INPUT_SOURCE_IS_SDI(src) && (inKinds & NTV2_IOKINDS_SDI))
1440  || (NTV2_INPUT_SOURCE_IS_HDMI(src) && (inKinds & NTV2_IOKINDS_HDMI))
1441  || (NTV2_INPUT_SOURCE_IS_ANALOG(src) && (inKinds & NTV2_IOKINDS_ANALOG)) )
1442  outInputSources.insert(src);
1443  }
1444  return true;
1445 }
1446 
1447 bool NTV2DeviceGetSupportedOutputDests (const NTV2DeviceID inDeviceID, NTV2OutputDestinations & outOutputDests, const NTV2IOKinds inKinds)
1448 {
1452  outOutputDests.clear();
1453  if (!NTV2_IS_VALID_IOKINDS(inKinds))
1454  return false;
1455  const UWord numSDI(inDeviceID == DEVICE_ID_INVALID ? 8 : ::NTV2DeviceGetNumVideoOutputs(inDeviceID)),
1456  numAnl(inDeviceID == DEVICE_ID_INVALID ? 1 : ::NTV2DeviceGetNumAnalogVideoOutputs(inDeviceID)),
1457  numHDM(inDeviceID == DEVICE_ID_INVALID ? 1 : ::NTV2DeviceGetNumHDMIVideoOutputs(inDeviceID));
1458  for (size_t ndx(0); ndx < 10; ndx++)
1459  {
1460  const NTV2OutputDest dst(sDsts[ndx]);
1461  if ( (NTV2_OUTPUT_DEST_IS_SDI(dst) && (inKinds & NTV2_IOKINDS_SDI) && (numSDI > ::NTV2OutputDestinationToChannel(dst)))
1462  || (NTV2_OUTPUT_DEST_IS_HDMI(dst) && (inKinds & NTV2_IOKINDS_HDMI) && (numHDM) )
1463  || (NTV2_OUTPUT_DEST_IS_ANALOG(dst) && (inKinds & NTV2_IOKINDS_ANALOG) && (numAnl) ) )
1464  outOutputDests.insert(dst);
1465  }
1466  return true;
1467 }
1468 
1469 ostream & operator << (ostream & oss, const NTV2FrameRateSet & inSet)
1470 {
1471  NTV2FrameRateSetConstIter it(inSet.begin());
1472  oss << inSet.size()
1473  << (inSet.size() == 1 ? " rate: " : " rates: ");
1474  while (it != inSet.end())
1475  {
1476  oss << ::NTV2FrameRateToString(*it);
1477  oss << (++it == inSet.end() ? "" : ", ");
1478  }
1479  return oss;
1480 }
1481 
1483 {
1484  for (NTV2FrameRateSetConstIter it(inSet.begin()); it != inSet.end(); ++it)
1485  if (inOutSet.find(*it) == inOutSet.end())
1486  inOutSet.insert(*it);
1487  return inOutSet;
1488 }
1489 
1491 {
1492  outRates.clear();
1493  NTV2VideoFormatSet vfs;
1494  if (!::NTV2DeviceGetSupportedVideoFormats (inDeviceID, vfs))
1495  return false;
1496  for (NTV2VideoFormatSetConstIter it(vfs.begin()); it != vfs.end(); ++it)
1497  { const NTV2FrameRate fr (::GetNTV2FrameRateFromVideoFormat(*it));
1499  outRates.insert(fr);
1500  }
1501  return true;
1502 }
1503 
1504 
1505 ostream & operator << (ostream & inOutStrm, const NTV2SegmentedXferInfo & inRun)
1506 {
1507  return inRun.Print(inOutStrm);
1508 }
1509 
1510 
1511 // Implementation of NTV2AutoCirculateStateToString...
1513 {
1514  static const char * sStateStrings [] = { "Disabled", "Initializing", "Starting", "Paused", "Stopping", "Running", "StartingAtTime", AJA_NULL};
1516  return string (sStateStrings [inState]);
1517  else
1518  return "<invalid>";
1519 }
1520 
1521 
1522 
1525  fTrailerTag (NTV2_TRAILER_TAG)
1526 {
1527 }
1528 
1529 
1530 NTV2FrameSize::operator NTV2FrameGeometry() const // Cast to NTV2FrameGeometry
1531 {
1532  return isValid() ? ::GetGeometryFromFrameDimensions(*this) : NTV2_FG_INVALID;
1533 }
1534 
1536 { // Requires C++11:
1537  static const FGSizesMap sFGWdths = { {NTV2_FG_720x486, 720},
1538  {NTV2_FG_720x508, 720},
1539  {NTV2_FG_720x514, 720},
1540  {NTV2_FG_720x576, 720},
1541  {NTV2_FG_720x598, 720},
1542  {NTV2_FG_720x612, 720},
1543  {NTV2_FG_1280x720, 1280},
1544  {NTV2_FG_1280x740, 1280},
1545  {NTV2_FG_1920x1080, 1920},
1546  {NTV2_FG_1920x1114, 1920},
1547  {NTV2_FG_1920x1112, 1920},
1548  {NTV2_FG_2048x1080, 2048},
1549  {NTV2_FG_2048x1112, 2048},
1550  {NTV2_FG_2048x1114, 2048},
1551  {NTV2_FG_2048x1556, 2048},
1552  {NTV2_FG_2048x1588, 2048},
1553  {NTV2_FG_3840x2160, 3840},
1554  {NTV2_FG_4096x2160, 4096},
1555  {NTV2_FG_7680x4320, 7680},
1556  {NTV2_FG_8192x4320, 8192} };
1557  FGSizesMapCI it (sFGWdths.find(fg));
1558  return it != sFGWdths.end() ? it->second : 0;
1559 }
1560 
1562 { // Requires C++11:
1563  static const FGSizesMap sFGHghts = { {NTV2_FG_720x486, 486},
1564  {NTV2_FG_720x508, 508},
1565  {NTV2_FG_720x514, 514},
1566  {NTV2_FG_720x576, 576},
1567  {NTV2_FG_720x598, 598},
1568  {NTV2_FG_720x612, 612},
1569  {NTV2_FG_1280x720, 720},
1570  {NTV2_FG_1280x740, 740},
1571  {NTV2_FG_2048x1556, 1556},
1572  {NTV2_FG_2048x1588, 1588},
1573  {NTV2_FG_1920x1080, 1080},
1574  {NTV2_FG_2048x1080, 1080},
1575  {NTV2_FG_1920x1114, 1114},
1576  {NTV2_FG_2048x1114, 1114},
1577  {NTV2_FG_1920x1112, 1112},
1578  {NTV2_FG_2048x1112, 1112},
1579  {NTV2_FG_3840x2160, 2160},
1580  {NTV2_FG_4096x2160, 2160},
1581  {NTV2_FG_7680x4320, 4320},
1582  {NTV2_FG_8192x4320, 4320} };
1583  FGSizesMapCI it (sFGHghts.find(fg));
1584  return it != sFGHghts.end() ? it->second : 0;
1585 }
1586 
1587 
1588 static const string sSegXferUnits[] = {"", " U8", " U16", "", " U32", "", "", "", " U64", ""};
1589 
1590 ostream & NTV2SegmentedXferInfo::Print (ostream & inStrm, const bool inDumpSegments) const
1591 {
1592  if (!isValid())
1593  return inStrm << "(invalid)";
1594  if (inDumpSegments)
1595  {
1596  // TBD
1597  }
1598  else
1599  {
1600  inStrm << DEC(getSegmentCount()) << " x " << DEC(getSegmentLength())
1601  << sSegXferUnits[getElementLength()] << " segs";
1602  if (getSourceOffset())
1603  inStrm << " srcOff=" << xHEX0N(getSourceOffset(),8);
1604  if (getSegmentCount() > 1)
1605  inStrm << " srcSpan=" << xHEX0N(getSourcePitch(),8) << (isSourceBottomUp()?" VF":"");
1606  if (getDestOffset())
1607  inStrm << " dstOff=" << xHEX0N(getDestOffset(),8);
1608  if (getSegmentCount() > 1)
1609  inStrm << " dstSpan=" << xHEX0N(getDestPitch(),8) << (isDestBottomUp()?" VF":"");
1610  inStrm << " totElm=" << DEC(getTotalElements()) << " totByt=" << xHEX0N(getTotalBytes(),8);
1611  }
1612  return inStrm;
1613 }
1614 
1615 string NTV2SegmentedXferInfo::getSourceCode (const bool inInclDecl) const
1616 {
1617  static string var("segInfo");
1618  ostringstream oss;
1619  string units("\t// bytes");
1620  if (!isValid())
1621  return "";
1622  if (inInclDecl)
1623  oss << "NTV2SegmentedXferInfo " << var << ";" << endl;
1624  if (getElementLength() > 1)
1625  {
1626  units = "\t// " + sSegXferUnits[getElementLength()] + "s";
1627  oss << var << ".setElementLength(" << getElementLength() << ");" << endl;
1628  }
1629  oss << var << ".setSegmentCount(" << DEC(getSegmentCount()) << ");" << endl;
1630  oss << var << ".setSegmentLength(" << DEC(getSegmentLength()) << ");" << units << endl;
1631  if (getSourceOffset())
1632  oss << var << ".setSourceOffset(" << DEC(getSourceOffset()) << ");" << units << endl;
1633  oss << var << ".setSourcePitch(" << DEC(getSourcePitch()) << ");" << units << endl;
1634  if (isSourceBottomUp())
1635  oss << var << ".setSourceDirection(false);" << endl;
1636  if (getDestOffset())
1637  oss << var << ".setDestOffset(" << DEC(getDestOffset()) << ");" << units << endl;
1638  if (getDestPitch())
1639  oss << var << ".setDestPitch(" << DEC(getDestPitch()) << ");" << units << endl;
1640  if (isDestBottomUp())
1641  oss << var << ".setDestDirection(false);" << endl;
1642  return oss.str();
1643 }
1644 
1645 bool NTV2SegmentedXferInfo::containsElementAtOffset (const ULWord inElementOffset) const
1646 {
1647  if (!isValid())
1648  return false;
1649  if (getSegmentCount() == 1)
1650  {
1651  if (inElementOffset >= getSourceOffset())
1652  if (inElementOffset < getSourceOffset()+getSegmentLength())
1653  return true;
1654  return false;
1655  }
1656  ULWord offset(getSourceOffset());
1657  for (ULWord seg(0); seg < getSegmentCount(); seg++)
1658  {
1659  if (inElementOffset < offset)
1660  return false; // past element of interest already
1661  if (inElementOffset < offset+getSegmentLength())
1662  return true; // must be within this segment
1663  offset += getSourcePitch(); // skip to next segment
1664  }
1665  return false;
1666 }
1667 
1669 {
1670  if (getElementLength() != inRHS.getElementLength())
1671  // FUTURE TBD: Need to transform RHS to match ElementLength so as to make apples-to-apples comparison
1672  return true; // For now, fail
1673  if (getSegmentCount() != inRHS.getSegmentCount())
1674  return true;
1675  if (getSegmentLength() != inRHS.getSegmentLength())
1676  return true;
1677  if (getSourceOffset() != inRHS.getSourceOffset())
1678  return true;
1679  if (getSourcePitch() != inRHS.getSourcePitch())
1680  return true;
1681  if (getDestOffset() != inRHS.getDestOffset())
1682  return true;
1683  if (getDestPitch() != inRHS.getDestPitch())
1684  return true;
1685  return false;
1686 }
1687 
1689 {
1690  mFlags = 0;
1691  mNumSegments = 0;
1692  mElementsPerSegment = 0;
1693  mInitialSrcOffset = 0;
1694  mInitialDstOffset = 0;
1695  mSrcElementsPerRow = 0;
1696  mDstElementsPerRow = 0;
1697  setElementLength(1); // elements == bytes
1698  return *this;
1699 }
1700 
1702 {
1703  std::swap(mSrcElementsPerRow, mDstElementsPerRow);
1704  std::swap(mInitialSrcOffset, mInitialDstOffset);
1705  const bool srcNormal(this->isSourceTopDown()), dstNormal(this->isDestTopDown());
1706  setSourceDirection(dstNormal).setDestDirection(srcNormal);
1707  return *this;
1708 }
1709 
1710 
1711 NTV2Buffer::NTV2Buffer (const void * pInUserPointer, const size_t inByteCount)
1712  : fUserSpacePtr (inByteCount ? NTV2Buffer_TO_ULWORD64(pInUserPointer) : 0),
1713  fByteCount (ULWord(pInUserPointer ? inByteCount : 0)),
1714  fFlags (0),
1715  #if defined (AJAMac)
1716  fKernelSpacePtr (0),
1717  fIOMemoryDesc (0),
1718  fIOMemoryMap (0)
1719  #else
1720  //fKernelSpacePtr (0),
1721  fKernelHandle (0)
1722  #endif
1723 {
1724 }
1725 
1726 
1727 NTV2Buffer::NTV2Buffer (const size_t inByteCount)
1728  : fUserSpacePtr (0),
1729  fByteCount (0),
1730  fFlags (0),
1731  #if defined (AJAMac)
1732  fKernelSpacePtr (0),
1733  fIOMemoryDesc (0),
1734  fIOMemoryMap (0)
1735  #else
1736  //fKernelSpacePtr (0),
1737  fKernelHandle (0)
1738  #endif
1739 {
1740  if (inByteCount)
1741  Allocate(inByteCount);
1742 }
1743 
1744 
1746  : fUserSpacePtr (0),
1747  fByteCount (0),
1748  fFlags (0),
1749  #if defined (AJAMac)
1750  fKernelSpacePtr (0),
1751  fIOMemoryDesc (0),
1752  fIOMemoryMap (0)
1753  #else
1754  //fKernelSpacePtr (0),
1755  fKernelHandle (0)
1756  #endif
1757 {
1758  if (Allocate(inObj.GetByteCount()))
1759  SetFrom(inObj);
1760 }
1761 
1762 bool NTV2Buffer::Truncate (const size_t inNewByteCount)
1763 {
1764  if (inNewByteCount == GetByteCount())
1765  return true; // Same size -- done!
1766  if (inNewByteCount > GetByteCount())
1767  return false; // Cannot enlarge -- i.e. can't be greater than my current size
1768  if (!inNewByteCount && IsAllocatedBySDK())
1769  return Deallocate(); // A newByteCount of zero calls Deallocate
1770  fByteCount = ULWord(inNewByteCount);
1771  return true;
1772 }
1773 
1775 {
1776  if (&inRHS != this)
1777  {
1778  if (inRHS.IsNULL())
1779  Set (AJA_NULL, 0);
1780  else if (GetByteCount() == inRHS.GetByteCount())
1781  SetFrom(inRHS);
1782  else if (Allocate(inRHS.GetByteCount()))
1783  SetFrom(inRHS);
1784  //else; // Error
1785  }
1786  return *this;
1787 }
1788 
1789 
1791 {
1792  Set (AJA_NULL, 0); // Call 'Set' to delete the array (if I allocated it)
1793 }
1794 
1795 
1797 {
1798  uint64_t * pU64s(reinterpret_cast<uint64_t*>(GetHostPointer()));
1799  const size_t loopCount(GetByteCount() / sizeof(uint64_t));
1800  if (IsNULL())
1801  return false;
1802  for (size_t ndx(0); ndx < loopCount; ndx++)
1803  pU64s[ndx] = NTV2EndianSwap64(pU64s[ndx]);
1804  return true;
1805 }
1806 
1807 
1809 {
1810  uint32_t * pU32s(reinterpret_cast<uint32_t*>(GetHostPointer()));
1811  const size_t loopCount(GetByteCount() / sizeof(uint32_t));
1812  if (IsNULL())
1813  return false;
1814  for (size_t ndx(0); ndx < loopCount; ndx++)
1815  pU32s[ndx] = NTV2EndianSwap32(pU32s[ndx]);
1816  return true;
1817 }
1818 
1819 
1821 {
1822  uint16_t * pU16s(reinterpret_cast<uint16_t*>(GetHostPointer()));
1823  const size_t loopCount(GetByteCount() / sizeof(uint16_t));
1824  if (IsNULL())
1825  return false;
1826  for (size_t ndx(0); ndx < loopCount; ndx++)
1827  pU16s[ndx] = NTV2EndianSwap16(pU16s[ndx]);
1828  return true;
1829 }
1830 
1831 
1832 bool NTV2Buffer::Set (const void * pInUserPointer, const size_t inByteCount)
1833 {
1834  if (uint64_t(inByteCount) >= 0x0000000100000000) // inByteCount >= 4GB?
1835  return false; // Can't store 4GB or larger value in fByteCount
1836  Deallocate();
1837  fUserSpacePtr = inByteCount ? NTV2Buffer_TO_ULWORD64(pInUserPointer) : 0;
1838  fByteCount = ULWord(pInUserPointer ? inByteCount : 0);
1839  // Return true only if both UserPointer and ByteCount are non-zero, or both are zero.
1840  return (pInUserPointer && inByteCount) || (!pInUserPointer && !inByteCount);
1841 }
1842 
1843 
1844 bool NTV2Buffer::SetAndFill (const void * pInUserPointer, const size_t inByteCount, const UByte inValue)
1845 {
1846  return Set(pInUserPointer, inByteCount) && Fill(inValue);
1847 }
1848 
1849 
1850 bool NTV2Buffer::Allocate (const size_t inByteCount, const bool inPageAligned)
1851 {
1852  if (uint64_t(inByteCount) >= 0x0000000100000000) // inByteCount >= 4GB?
1853  return false; // Can't store 4GB or more in fByteCount
1854  if (GetByteCount() && IsAllocatedBySDK()) // If already was Allocated
1855  if (inByteCount == GetByteCount()) // If same byte count
1856  {
1857  Fill(UByte(0)); // Zero it...
1858  return true; // ...and return true
1859  }
1860 
1861  bool result(Set(AJA_NULL, 0)); // Jettison existing buffer (if any)
1862  if (inByteCount)
1863  { // Allocate the byte array, and call Set...
1864  UByte * pBuffer(AJA_NULL);
1865  result = false;
1866  if (inPageAligned)
1867  pBuffer = reinterpret_cast<UByte*>(AJAMemory::AllocateAligned(inByteCount, DefaultPageSize()));
1868  else
1869  try
1870  {pBuffer = new UByte[inByteCount];}
1871  catch (const std::bad_alloc &)
1872  {pBuffer = AJA_NULL;}
1873  if (pBuffer && Set(pBuffer, inByteCount))
1874  { // SDK owns this memory -- set NTV2Buffer_ALLOCATED bit -- I'm responsible for deleting
1875  result = true;
1876  fFlags |= NTV2Buffer_ALLOCATED;
1877  if (inPageAligned)
1878  fFlags |= NTV2Buffer_PAGE_ALIGNED; // Set "page aligned" flag
1879  Fill(UByte(0)); // Zero it
1880  }
1881  } // if requested size is non-zero
1882  return result;
1883 }
1884 
1885 
1887 {
1888  if (IsAllocatedBySDK())
1889  {
1890  if (!IsNULL())
1891  {
1892  if (IsPageAligned())
1893  {
1895  fFlags &= ~NTV2Buffer_PAGE_ALIGNED;
1896  }
1897  else
1898  delete [] reinterpret_cast<UByte*>(GetHostPointer());
1899  }
1900  fUserSpacePtr = 0;
1901  fByteCount = 0;
1902  fFlags &= ~NTV2Buffer_ALLOCATED;
1903  }
1904  return true;
1905 }
1906 
1907 
1908 void * NTV2Buffer::GetHostAddress (const ULWord inByteOffset, const bool inFromEnd) const
1909 {
1910  if (IsNULL())
1911  return AJA_NULL;
1912  if (inByteOffset >= GetByteCount())
1913  return AJA_NULL;
1914  UByte * pBytes (reinterpret_cast<UByte*>(GetHostPointer()));
1915  if (inFromEnd)
1916  pBytes += GetByteCount() - inByteOffset;
1917  else
1918  pBytes += inByteOffset;
1919  return pBytes;
1920 }
1921 
1922 
1923 bool NTV2Buffer::SetFrom (const NTV2Buffer & inBuffer)
1924 {
1925  if (inBuffer.IsNULL())
1926  return false; // NULL or empty
1927  if (IsNULL())
1928  return false; // I am NULL or empty
1929  if (inBuffer.GetByteCount() == GetByteCount() && inBuffer.GetHostPointer() == GetHostPointer())
1930  return true; // Same buffer
1931 
1932  size_t bytesToCopy(inBuffer.GetByteCount());
1933  if (bytesToCopy > GetByteCount())
1934  bytesToCopy = GetByteCount();
1935  ::memcpy (GetHostPointer(), inBuffer.GetHostPointer(), bytesToCopy);
1936  return true;
1937 }
1938 
1939 
1940 bool NTV2Buffer::CopyFrom (const void * pInSrcBuffer, const ULWord inByteCount)
1941 {
1942  if (!inByteCount)
1943  return Set (AJA_NULL, 0); // Zero bytes
1944  if (!pInSrcBuffer)
1945  return false; // NULL src ptr
1946  if (!Allocate (inByteCount))
1947  return false; // Resize failed
1948  ::memcpy (GetHostPointer(), pInSrcBuffer, inByteCount);
1949  return true;
1950 }
1951 
1952 
1953 bool NTV2Buffer::CopyFrom (const NTV2Buffer & inBuffer,
1954  const ULWord inSrcByteOffset, const ULWord inDstByteOffset, const ULWord inByteCount)
1955 {
1956  if (inBuffer.IsNULL() || IsNULL())
1957  return false; // NULL or empty
1958  if (inSrcByteOffset + inByteCount > inBuffer.GetByteCount())
1959  return false; // Past end of src
1960  if (inDstByteOffset + inByteCount > GetByteCount())
1961  return false; // Past end of me
1962 
1963  const UByte * pSrc (inBuffer);
1964  pSrc += inSrcByteOffset;
1965 
1966  UByte * pDst (*this);
1967  pDst += inDstByteOffset;
1968 
1969  ::memcpy (pDst, pSrc, inByteCount);
1970  return true;
1971 }
1972 
1973 
1974 bool NTV2Buffer::CopyFrom (const NTV2Buffer & inSrcBuffer, const NTV2SegmentedXferInfo & inXferInfo)
1975 {
1976  if (!inXferInfo.isValid() || inSrcBuffer.IsNULL() || IsNULL())
1977  return false;
1978 
1979  // Copy every segment...
1980  LWord srcOffset (LWord(inXferInfo.getSourceOffset() * inXferInfo.getElementLength()));
1981  LWord dstOffset (LWord(inXferInfo.getDestOffset() * inXferInfo.getElementLength()));
1982  LWord srcPitch (LWord(inXferInfo.getSourcePitch() * inXferInfo.getElementLength()));
1983  LWord dstPitch (LWord(inXferInfo.getDestPitch() * inXferInfo.getElementLength()));
1984  const LWord bytesPerSeg (inXferInfo.getSegmentLength() * inXferInfo.getElementLength());
1985  if (inXferInfo.isSourceBottomUp())
1986  srcPitch = 0 - srcPitch;
1987  if (inXferInfo.isDestBottomUp())
1988  dstPitch = 0 - dstPitch;
1989  for (ULWord segNdx(0); segNdx < inXferInfo.getSegmentCount(); segNdx++)
1990  {
1991  const void * pSrc (inSrcBuffer.GetHostAddress(srcOffset));
1992  void * pDst (GetHostAddress(dstOffset));
1993  if (!pSrc) return false;
1994  if (!pDst) return false;
1995  if (srcOffset + bytesPerSeg > LWord(inSrcBuffer.GetByteCount()))
1996  return false; // memcpy will read past end of srcBuffer
1997  if (dstOffset + bytesPerSeg > LWord(GetByteCount()))
1998  return false; // memcpy will write past end of me
1999  ::memcpy (pDst, pSrc, size_t(bytesPerSeg));
2000  srcOffset += srcPitch; // Bump src offset
2001  dstOffset += dstPitch; // Bump dst offset
2002  } // for each segment
2003  return true;
2004 }
2005 
2006 bool NTV2Buffer::SetFromHexString (const string & inStr)
2007 {
2008  string str(inStr);
2009 
2010  // Remove all whitespace...
2011  const string newline("\n"), tab("\t");
2012  aja::replace(str, newline, string());
2013  aja::replace(str, tab, string());
2014  aja::upper(str);
2015 
2016  // Fail if any non-hex found...
2017  for (size_t ndx(0); ndx < str.size(); ndx++)
2018  if (!aja::is_hex_digit(str.at(ndx)))
2019  return false;
2020 
2021  if (str.size() & 1)
2022  return false; // Remaining length must be even
2023  if (!Allocate(str.size() / 2))
2024  return false; // Resize failed
2025 
2026  // Decode and copy in the data...
2027  for (size_t srcNdx(0), dstNdx(0); srcNdx < str.size(); srcNdx += 2)
2028  U8(int(dstNdx++)) = uint8_t(aja::stoul (str.substr(srcNdx,2), AJA_NULL, 16));
2029 
2030  return true;
2031 }
2032 
2034 {
2035  if (inBuffer.IsNULL ())
2036  return false; // NULL or empty
2037  if (IsNULL ())
2038  return false; // I am NULL or empty
2039  if (inBuffer.GetByteCount () != GetByteCount ())
2040  return false; // Different sizes
2041  if (fFlags != inBuffer.fFlags)
2042  return false; // Flags mismatch
2043  if (inBuffer.GetHostPointer () == GetHostPointer ())
2044  return true; // Same buffer
2045 
2046  ULWord64 tmp = fUserSpacePtr;
2047  fUserSpacePtr = inBuffer.fUserSpacePtr;
2048  inBuffer.fUserSpacePtr = tmp;
2049  return true;
2050 }
2051 
2052 ULWordSet & NTV2Buffer::Find (ULWordSet & outOffsets, const NTV2Buffer & inValue, const size_t inLimit) const
2053 {
2054  outOffsets.clear();
2055  if (IsNULL())
2056  return outOffsets; // NULL buffer, return "no matches"
2057  if (inValue.IsNULL())
2058  return outOffsets; // NULL buffer, return "no matches"
2059  const ULWord srchByteCount(inValue.GetByteCount());
2060  if (GetByteCount() < srchByteCount)
2061  return outOffsets; // I'm smaller than the search data, return "no matches"
2062 
2063  const ULWord maxOffset(GetByteCount() - srchByteCount); // Don't search past here
2064  const uint8_t * pSrchData (inValue); // Pointer to search data
2065  const uint8_t * pMyData (*this); // Pointer to where search starts in me
2066  ULWord offset(0); // Search starts at this byte offset
2067  do
2068  {
2069  if (!::memcmp(pMyData, pSrchData, srchByteCount))
2070  {
2071  outOffsets.insert(offset); // Record byte offset of match
2072  if (inLimit && outOffsets.size() >= inLimit)
2073  break; // reached limit, early exit
2074  }
2075  pMyData++; // Bump search pointer
2076  offset++; // Bump search byte offset
2077  } while (offset < maxOffset);
2078  return outOffsets;
2079 }
2080 
2081 bool NTV2Buffer::IsContentEqual (const NTV2Buffer & inBuffer, const ULWord inByteOffset, const ULWord inByteCount) const
2082 {
2083  if (IsNULL() || inBuffer.IsNULL())
2084  return false; // Buffer(s) are NULL/empty
2085  if (inBuffer.GetByteCount() != GetByteCount())
2086  return false; // Buffers are different sizes
2087 
2088  ULWord totalBytes(GetByteCount());
2089  if (inByteOffset >= totalBytes)
2090  return false; // Bad offset
2091 
2092  totalBytes -= inByteOffset;
2093 
2094  ULWord byteCount(inByteCount);
2095  if (byteCount > totalBytes)
2096  byteCount = totalBytes;
2097 
2098  if (inBuffer.GetHostPointer() == GetHostPointer())
2099  return true; // Same buffer
2100 
2101  const UByte * pByte1 (*this);
2102  const UByte * pByte2 (inBuffer);
2103  pByte1 += inByteOffset;
2104  pByte2 += inByteOffset;
2105  #if !defined(NTV2BUFFER_NO_MEMCMP)
2106  return ::memcmp (pByte1, pByte2, byteCount) == 0;
2107  #else // NTV2BUFFER_NO_MEMCMP
2108  ULWord offset(inByteOffset);
2109  while (byteCount)
2110  {
2111  if (*pByte1 != *pByte2)
2112  {
2113  cerr << "## ERROR: IsContentEqual: miscompare at offset " << xHEX0N(offset,8)
2114  << " (" << DEC(offset) << "): " << xHEX0N(UWord(*pByte1),2) << " != "
2115  << xHEX0N(UWord(*pByte2),2) << ", " << xHEX0N(byteCount,8) << " ("
2116  << DEC(byteCount) << ") bytes left to compare" << endl;
2117  return false;
2118  }
2119  pByte1++; pByte2++;
2120  byteCount--;
2121  offset++;
2122  }
2123  return true;
2124  #endif // NTV2BUFFER_NO_MEMCMP
2125 }
2126 
2127 bool NTV2Buffer::NextDifference (const NTV2Buffer & inBuffer, ULWord & byteOffset) const
2128 {
2129  if (byteOffset == 0xFFFFFFFF)
2130  return false; // bad offset
2131  if (IsNULL() || inBuffer.IsNULL())
2132  return false; // NULL or empty buffers
2133  if (inBuffer.GetByteCount() != GetByteCount())
2134  return false; // Different byte counts
2135  if (inBuffer.GetHostPointer() == GetHostPointer())
2136  {byteOffset = 0xFFFFFFFF; return true;} // Same buffer
2137 
2138  ULWord totalBytesToCompare(GetByteCount());
2139  if (byteOffset >= totalBytesToCompare)
2140  return false; // Bad offset
2141  totalBytesToCompare -= byteOffset;
2142 
2143  const UByte * pByte1 (*this);
2144  const UByte * pByte2 (inBuffer);
2145  while (totalBytesToCompare)
2146  {
2147  if (pByte1[byteOffset] != pByte2[byteOffset])
2148  return true;
2149  totalBytesToCompare--;
2150  byteOffset++;
2151  }
2152  byteOffset = 0xFFFFFFFF;
2153  return true;
2154 }
2155 
2156 bool NTV2Buffer::GetRingChangedByteRange (const NTV2Buffer & inBuffer, ULWord & outByteOffsetFirst, ULWord & outByteOffsetLast) const
2157 {
2158  outByteOffsetFirst = outByteOffsetLast = GetByteCount ();
2159  if (IsNULL () || inBuffer.IsNULL ())
2160  return false; // NULL or empty
2161  if (inBuffer.GetByteCount () != GetByteCount ())
2162  return false; // Different byte counts
2163  if (inBuffer.GetHostPointer () == GetHostPointer ())
2164  return true; // Same buffer
2165  if (GetByteCount() < 3)
2166  return false; // Too small
2167 
2168  const UByte * pByte1 (reinterpret_cast <const UByte *> (GetHostPointer()));
2169  const UByte * pByte2 (reinterpret_cast <const UByte *> (inBuffer.GetHostPointer()));
2170 
2171  outByteOffsetFirst = 0;
2172  while (outByteOffsetFirst < GetByteCount())
2173  {
2174  if (*pByte1 != *pByte2)
2175  break;
2176  pByte1++;
2177  pByte2++;
2178  outByteOffsetFirst++;
2179  }
2180  if (outByteOffsetFirst == 0)
2181  {
2182  // Wrap case -- look for first match...
2183  while (outByteOffsetFirst < GetByteCount())
2184  {
2185  if (*pByte1 == *pByte2)
2186  break;
2187  pByte1++;
2188  pByte2++;
2189  outByteOffsetFirst++;
2190  }
2191  if (outByteOffsetFirst < GetByteCount())
2192  outByteOffsetFirst--;
2193  }
2194  if (outByteOffsetFirst == GetByteCount())
2195  return true; // Identical --- outByteOffsetFirst == outByteOffsetLast == GetByteCount()
2196 
2197  // Now scan from the end...
2198  pByte1 = reinterpret_cast <const UByte *> (GetHostPointer());
2199  pByte2 = reinterpret_cast <const UByte *> (inBuffer.GetHostPointer());
2200  pByte1 += GetByteCount () - 1; // Point to last byte
2201  pByte2 += GetByteCount () - 1;
2202  while (--outByteOffsetLast)
2203  {
2204  if (*pByte1 != *pByte2)
2205  break;
2206  pByte1--;
2207  pByte2--;
2208  }
2209  if (outByteOffsetLast == (GetByteCount() - 1))
2210  {
2211  // Wrap case -- look for first match...
2212  while (outByteOffsetLast)
2213  {
2214  if (*pByte1 == *pByte2)
2215  break;
2216  pByte1--;
2217  pByte2--;
2218  outByteOffsetLast--;
2219  }
2220  if (outByteOffsetLast < GetByteCount())
2221  outByteOffsetLast++;
2222  if (outByteOffsetLast <= outByteOffsetFirst)
2223  cerr << "## WARNING: GetRingChangedByteRange: last " << outByteOffsetLast << " <= first " << outByteOffsetFirst << " in wrap condition" << endl;
2224  const ULWord tmp (outByteOffsetLast);
2225  outByteOffsetLast = outByteOffsetFirst;
2226  outByteOffsetFirst = tmp;
2227  if (outByteOffsetLast >= outByteOffsetFirst)
2228  cerr << "## WARNING: GetRingChangedByteRange: last " << outByteOffsetLast << " >= first " << outByteOffsetFirst << " in wrap condition" << endl;
2229  }
2230  return true;
2231 
2232 } // GetRingChangedByteRange
2233 
2234 
2235 static size_t gDefaultPageSize (AJA_PAGE_SIZE);
2236 
2238 {
2239  return gDefaultPageSize;
2240 }
2241 
2242 bool NTV2Buffer::SetDefaultPageSize (const size_t inNewSize)
2243 {
2244  const bool result (inNewSize && (!(inNewSize & (inNewSize - 1))));
2245  if (result)
2246  gDefaultPageSize = inNewSize;
2247  return result;
2248 }
2249 
2251 {
2252 #if defined(MSWindows) || defined(AJABareMetal)
2253  return AJA_PAGE_SIZE;
2254 #else
2255  return size_t(::getpagesize());
2256 #endif
2257 }
2258 
2259 
2261  : acHeader (NTV2_TYPE_ACFRAMESTAMP, sizeof(FRAME_STAMP)),
2262  acFrameTime (0),
2263  acRequestedFrame (0),
2264  acAudioClockTimeStamp (0),
2265  acAudioExpectedAddress (0),
2266  acAudioInStartAddress (0),
2267  acAudioInStopAddress (0),
2268  acAudioOutStopAddress (0),
2269  acAudioOutStartAddress (0),
2270  acTotalBytesTransferred (0),
2271  acStartSample (0),
2272  acTimeCodes (NTV2_MAX_NUM_TIMECODE_INDEXES * sizeof (NTV2_RP188)),
2273  acCurrentTime (0),
2274  acCurrentFrame (0),
2275  acCurrentFrameTime (0),
2276  acAudioClockCurrentTime (0),
2277  acCurrentAudioExpectedAddress (0),
2278  acCurrentAudioStartAddress (0),
2279  acCurrentFieldCount (0),
2280  acCurrentLineCount (0),
2281  acCurrentReps (0),
2282  acCurrentUserCookie (0),
2283  acFrame (0),
2284  acRP188 ()
2285 {
2287 }
2288 
2289 
2291  : acHeader (inObj.acHeader),
2292  acFrameTime (inObj.acFrameTime),
2293  acRequestedFrame (inObj.acRequestedFrame),
2294  acAudioClockTimeStamp (inObj.acAudioClockTimeStamp),
2295  acAudioExpectedAddress (inObj.acAudioExpectedAddress),
2296  acAudioInStartAddress (inObj.acAudioInStartAddress),
2297  acAudioInStopAddress (inObj.acAudioInStopAddress),
2298  acAudioOutStopAddress (inObj.acAudioOutStopAddress),
2299  acAudioOutStartAddress (inObj.acAudioOutStartAddress),
2300  acTotalBytesTransferred (inObj.acTotalBytesTransferred),
2301  acStartSample (inObj.acStartSample),
2302  acCurrentTime (inObj.acCurrentTime),
2303  acCurrentFrame (inObj.acCurrentFrame),
2304  acCurrentFrameTime (inObj.acCurrentFrameTime),
2305  acAudioClockCurrentTime (inObj.acAudioClockCurrentTime),
2306  acCurrentAudioExpectedAddress (inObj.acCurrentAudioExpectedAddress),
2307  acCurrentAudioStartAddress (inObj.acCurrentAudioStartAddress),
2308  acCurrentFieldCount (inObj.acCurrentFieldCount),
2309  acCurrentLineCount (inObj.acCurrentLineCount),
2310  acCurrentReps (inObj.acCurrentReps),
2311  acCurrentUserCookie (inObj.acCurrentUserCookie),
2312  acFrame (inObj.acFrame),
2313  acRP188 (inObj.acRP188),
2314  acTrailer (inObj.acTrailer)
2315 {
2317 }
2318 
2319 
2321 {
2322 }
2323 
2324 
2326 {
2328  ULWord numRP188s (acTimeCodes.GetByteCount () / sizeof (NTV2_RP188));
2329  const NTV2_RP188 * pArray (reinterpret_cast <const NTV2_RP188 *> (acTimeCodes.GetHostPointer ()));
2330  outValues.clear ();
2331  if (!pArray)
2332  return false; // No 'acTimeCodes' array!
2333 
2334  if (numRP188s > NTV2_MAX_NUM_TIMECODE_INDEXES)
2335  numRP188s = NTV2_MAX_NUM_TIMECODE_INDEXES; // clamp to this max number
2336 
2337  for (ULWord ndx (0); ndx < numRP188s; ndx++)
2338  outValues << pArray [ndx];
2339 
2340  return true;
2341 }
2342 
2343 
2344 bool FRAME_STAMP::GetInputTimeCode (NTV2_RP188 & outTimeCode, const NTV2TCIndex inTCIndex) const
2345 {
2347  ULWord numRP188s (acTimeCodes.GetByteCount () / sizeof (NTV2_RP188));
2348  const NTV2_RP188 * pArray (reinterpret_cast <const NTV2_RP188 *> (acTimeCodes.GetHostPointer ()));
2349  outTimeCode.Set (); // invalidate
2350  if (!pArray)
2351  return false; // No 'acTimeCodes' array!
2352  if (numRP188s > NTV2_MAX_NUM_TIMECODE_INDEXES)
2353  numRP188s = NTV2_MAX_NUM_TIMECODE_INDEXES; // clamp to this max number
2354  if (!NTV2_IS_VALID_TIMECODE_INDEX (inTCIndex))
2355  return false;
2356 
2357  outTimeCode = pArray [inTCIndex];
2358  return true;
2359 }
2360 
2361 
2362 bool FRAME_STAMP::GetInputTimeCodes (NTV2TimeCodes & outTimeCodes, const NTV2Channel inSDIInput, const bool inValidOnly) const
2363 {
2365  outTimeCodes.clear();
2366 
2367  if (!NTV2_IS_VALID_CHANNEL(inSDIInput))
2368  return false; // Bad SDI input
2369 
2370  NTV2TimeCodeList allTCs;
2371  if (!GetInputTimeCodes(allTCs))
2372  return false; // GetInputTimeCodes failed
2373 
2374  const NTV2TCIndexes tcIndexes (GetTCIndexesForSDIInput(inSDIInput));
2375  for (NTV2TCIndexesConstIter iter(tcIndexes.begin()); iter != tcIndexes.end(); ++iter)
2376  {
2377  const NTV2TCIndex tcIndex(*iter);
2379  const NTV2_RP188 tc(allTCs.at(tcIndex));
2380  if (!inValidOnly)
2381  outTimeCodes[tcIndex] = tc;
2382  else if (tc.IsValid())
2383  outTimeCodes[tcIndex] = tc;
2384  }
2385  return true;
2386 }
2387 
2388 
2389 bool FRAME_STAMP::GetSDIInputStatus(NTV2SDIInputStatus & outStatus, const UWord inSDIInputIndex0) const
2390 {
2392  (void)outStatus;
2393  (void)inSDIInputIndex0;
2394  return true;
2395 }
2396 
2397 bool FRAME_STAMP::SetInputTimecode (const NTV2TCIndex inTCNdx, const NTV2_RP188 & inTimecode)
2398 {
2399  ULWord numRP188s (acTimeCodes.GetByteCount() / sizeof(NTV2_RP188));
2400  NTV2_RP188 * pArray (reinterpret_cast<NTV2_RP188*>(acTimeCodes.GetHostPointer()));
2401  if (!pArray || !numRP188s)
2402  return false; // No 'acTimeCodes' array!
2403 
2404  if (numRP188s > NTV2_MAX_NUM_TIMECODE_INDEXES)
2405  numRP188s = NTV2_MAX_NUM_TIMECODE_INDEXES; // clamp to this max number
2406  if (ULWord(inTCNdx) >= numRP188s)
2407  return false; // Past end
2408 
2409  pArray[inTCNdx] = inTimecode; // Write the new value
2410  return true; // Success!
2411 }
2412 
2413 
2415 {
2416  if (this != &inRHS)
2417  {
2418  acTimeCodes = inRHS.acTimeCodes;
2419  acHeader = inRHS.acHeader;
2420  acFrameTime = inRHS.acFrameTime;
2429  acStartSample = inRHS.acStartSample;
2430  acCurrentTime = inRHS.acCurrentTime;
2438  acCurrentReps = inRHS.acCurrentReps;
2440  acFrame = inRHS.acFrame;
2441  acRP188 = inRHS.acRP188;
2442  acTrailer = inRHS.acTrailer;
2443  }
2444  return *this;
2445 }
2446 
2447 
2448 bool FRAME_STAMP::SetFrom (const FRAME_STAMP_STRUCT & inOldStruct)
2449 {
2451  //acCrosspoint = inOldStruct.channelSpec;
2452  acFrameTime = inOldStruct.frameTime;
2453  acRequestedFrame = inOldStruct.frame;
2460  acTotalBytesTransferred = inOldStruct.bytesRead;
2461  acStartSample = inOldStruct.startSample;
2462  acCurrentTime = inOldStruct.currentTime;
2463  acCurrentFrame = inOldStruct.currentFrame;
2464  acCurrentFrameTime = inOldStruct.currentFrameTime;
2468  acCurrentFieldCount = inOldStruct.currentFieldCount;
2469  acCurrentLineCount = inOldStruct.currentLineCount;
2470  acCurrentReps = inOldStruct.currentReps;
2471  acCurrentUserCookie = inOldStruct.currenthUser;
2472  acRP188 = NTV2_RP188 (inOldStruct.currentRP188);
2473  if (!acTimeCodes.IsNULL() && acTimeCodes.GetByteCount () >= sizeof (NTV2_RP188))
2474  {
2475  NTV2_RP188 * pTimecodes (reinterpret_cast <NTV2_RP188 *> (acTimeCodes.GetHostPointer ()));
2476  NTV2_ASSERT (pTimecodes);
2478  pTimecodes [NTV2_TCINDEX_DEFAULT] = acRP188;
2479  }
2480  return true;
2481 }
2482 
2483 
2484 bool FRAME_STAMP::CopyTo (FRAME_STAMP_STRUCT & outOldStruct) const
2485 {
2487  outOldStruct.frameTime = acFrameTime;
2488  outOldStruct.frame = acRequestedFrame;
2495  outOldStruct.bytesRead = acTotalBytesTransferred;
2496  outOldStruct.startSample = acStartSample;
2497  outOldStruct.currentTime = acCurrentTime;
2498  outOldStruct.currentFrame = acCurrentFrame;
2499  outOldStruct.currentFrameTime = acCurrentFrameTime;
2503  outOldStruct.currentFieldCount = acCurrentFieldCount;
2504  outOldStruct.currentLineCount = acCurrentLineCount;
2505  outOldStruct.currentReps = acCurrentReps;
2506  outOldStruct.currenthUser = ULWord(acCurrentUserCookie);
2507  outOldStruct.currentRP188 = acRP188;
2508  // Ticket 3367 -- Mark Gilbert of Gallery UK reports that after updating from AJA Retail Software 10.5 to 14.0,
2509  // their QuickTime app stopped receiving timecode during capture. Turns out the QuickTime components use the new
2510  // AutoCirculate APIs, but internally still use the old FRAME_STAMP_STRUCT for frame info, including timecode...
2511  // ...and only use the "currentRP188" field for the "retail" timecode.
2512  // Sadly, this FRAME_STAMP-to-FRAME_STAMP_STRUCT function historically only set "currentRP188" from the deprecated
2513  // (and completely unused) "acRP188" field, when it really should've been using the acTimeCodes[NTV2_TCINDEX_DEFAULT]
2514  // value all along...
2515  if (!acTimeCodes.IsNULL()) // If there's an acTimeCodes buffer...
2516  if (acTimeCodes.GetByteCount() >= sizeof(NTV2_RP188)) // ...and it has at least one timecode value...
2517  {
2518  const NTV2_RP188 * pDefaultTC (reinterpret_cast<const NTV2_RP188*>(acTimeCodes.GetHostPointer()));
2519  if (pDefaultTC)
2520  outOldStruct.currentRP188 = pDefaultTC[NTV2_TCINDEX_DEFAULT]; // Stuff the "default" (retail) timecode into "currentRP188".
2521  }
2522  return true;
2523 }
2524 
2525 
2526 string FRAME_STAMP::operator [] (const unsigned inIndexNum) const
2527 {
2528  ostringstream oss;
2529  NTV2_RP188 rp188;
2530  if (GetInputTimeCode (rp188, NTV2TimecodeIndex (inIndexNum)))
2531  {
2532  if (rp188.IsValid())
2533  {
2534  CRP188 foo (rp188);
2535  oss << foo;
2536  }
2537  else
2538  oss << "---";
2539  }
2540  else if (NTV2_IS_VALID_TIMECODE_INDEX (inIndexNum))
2541  oss << "---";
2542  return oss.str();
2543 }
2544 
2545 
2547  : mHeader(NTV2_TYPE_SDISTATS, sizeof(NTV2SDIInStatistics)),
2548  mInStatistics(NTV2_MAX_NUM_CHANNELS * sizeof(NTV2SDIInputStatus))
2549 {
2550  Clear();
2552 }
2553 
2555 {
2557  if (mInStatistics.IsNULL())
2558  return;
2559  NTV2SDIInputStatus * pArray(mInStatistics);
2560  const ULWord numElements(mInStatistics.GetByteCount() / sizeof(NTV2SDIInputStatus));
2561  for (ULWord i = 0; i < numElements; i++)
2562  pArray[i].Clear();
2563 }
2564 
2565 bool NTV2SDIInStatistics::GetSDIInputStatus(NTV2SDIInputStatus & outStatus, const UWord inSDIInputIndex0)
2566 {
2568  if (!mInStatistics)
2569  return false;
2570  const ULWord numElements(mInStatistics.GetByteCount() / sizeof(NTV2SDIInputStatus));
2571  const NTV2SDIInputStatus * pArray(mInStatistics);
2572  outStatus.Clear();
2573  if (numElements != 8)
2574  return false;
2575  if (inSDIInputIndex0 >= numElements)
2576  return false;
2577  outStatus = pArray[inSDIInputIndex0];
2578  return true;
2579 }
2580 
2582 {
2584  static NTV2SDIInputStatus dummy;
2585  if (!mInStatistics)
2586  return dummy;
2587  NTV2SDIInputStatus * pArray(mInStatistics);
2588  const ULWord numElements(mInStatistics.GetByteCount() / sizeof(NTV2SDIInputStatus));
2589  if (numElements != 8)
2590  return dummy;
2591  if (inSDIInputIndex0 >= numElements)
2592  return dummy;
2593  return pArray[inSDIInputIndex0];
2594 }
2595 
2596 std::ostream & NTV2SDIInStatistics::Print(std::ostream & inOutStream) const
2597 {
2599  inOutStream << mHeader << ", " << mInStatistics << ", " << mTrailer; return inOutStream;
2600 }
2601 
2602 
2605  acState (NTV2_AUTOCIRCULATE_DISABLED),
2606  acTransferFrame (0),
2607  acBufferLevel (0),
2608  acFramesProcessed (0),
2609  acFramesDropped (0),
2610  acFrameStamp (),
2611  acAudioTransferSize (0),
2612  acAudioStartSample (0),
2613  acAncTransferSize (0),
2614  acAncField2TransferSize (0)
2615  //acTrailer ()
2616 {
2618 }
2619 
2620 
2622  : acHeader (NTV2_TYPE_ACSTATUS, sizeof (AUTOCIRCULATE_STATUS)),
2623  acCrosspoint (inCrosspoint),
2624  acState (NTV2_AUTOCIRCULATE_DISABLED),
2625  acStartFrame (0),
2626  acEndFrame (0),
2627  acActiveFrame (0),
2628  acRDTSCStartTime (0),
2629  acAudioClockStartTime (0),
2630  acRDTSCCurrentTime (0),
2631  acAudioClockCurrentTime (0),
2632  acFramesProcessed (0),
2633  acFramesDropped (0),
2634  acBufferLevel (0),
2635  acOptionFlags (0),
2636  acAudioSystem (NTV2_AUDIOSYSTEM_INVALID)
2637 {
2639 }
2640 
2641 
2643 {
2645  outOldStruct.channelSpec = acCrosspoint;
2646  outOldStruct.state = acState;
2647  outOldStruct.startFrame = acStartFrame;
2648  outOldStruct.endFrame = acEndFrame;
2649  outOldStruct.activeFrame = acActiveFrame;
2650  outOldStruct.rdtscStartTime = acRDTSCStartTime;
2652  outOldStruct.rdtscCurrentTime = acRDTSCCurrentTime;
2654  outOldStruct.framesProcessed = acFramesProcessed;
2655  outOldStruct.framesDropped = acFramesDropped;
2656  outOldStruct.bufferLevel = acBufferLevel;
2658  outOldStruct.bWithRP188 = acOptionFlags & AUTOCIRCULATE_WITH_RP188 ? 1 : 0;
2659  outOldStruct.bFbfChange = acOptionFlags & AUTOCIRCULATE_WITH_FBFCHANGE ? 1 : 0;
2660  outOldStruct.bFboChange = acOptionFlags & AUTOCIRCULATE_WITH_FBOCHANGE ? 1 : 0;
2662  outOldStruct.bWithVidProc = acOptionFlags & AUTOCIRCULATE_WITH_VIDPROC ? 1 : 0;
2663  outOldStruct.bWithCustomAncData = acOptionFlags & AUTOCIRCULATE_WITH_ANC ? 1 : 0;
2664  return true;
2665 }
2666 
2667 
2669 {
2671  acCrosspoint = inOldStruct.channelSpec;
2672  acState = inOldStruct.state;
2673  acStartFrame = inOldStruct.startFrame;
2674  acEndFrame = inOldStruct.endFrame;
2675  acActiveFrame = inOldStruct.activeFrame;
2676  acRDTSCStartTime = inOldStruct.rdtscStartTime;
2678  acRDTSCCurrentTime = inOldStruct.rdtscCurrentTime;
2680  acFramesProcessed = inOldStruct.framesProcessed;
2681  acFramesDropped = inOldStruct.framesDropped;
2682  acBufferLevel = inOldStruct.bufferLevel;
2683  acAudioSystem = NTV2_AUDIOSYSTEM_INVALID; // NTV2_AUDIOSYSTEM_1;
2684  acOptionFlags = (inOldStruct.bWithRP188 ? AUTOCIRCULATE_WITH_RP188 : 0) |
2685  (inOldStruct.bFbfChange ? AUTOCIRCULATE_WITH_FBFCHANGE : 0) |
2686  (inOldStruct.bFboChange ? AUTOCIRCULATE_WITH_FBOCHANGE : 0) |
2688  (inOldStruct.bWithVidProc ? AUTOCIRCULATE_WITH_VIDPROC : 0) |
2689  (inOldStruct.bWithCustomAncData ? AUTOCIRCULATE_WITH_ANC : 0);
2690  return true;
2691 }
2692 
2693 
2695 {
2699  acStartFrame = 0;
2700  acEndFrame = 0;
2701  acActiveFrame = 0;
2702  acRDTSCStartTime = 0;
2704  acRDTSCCurrentTime = 0;
2706  acFramesProcessed = 0;
2707  acFramesDropped = 0;
2708  acBufferLevel = 0;
2709  acOptionFlags = 0;
2711 }
2712 
2713 
2715 {
2717 }
2718 
2719 
2720 struct ThousandsSeparator : std::numpunct <char>
2721 {
2722  virtual inline char do_thousands_sep() const {return ',';}
2723  virtual inline std::string do_grouping() const {return "\03";}
2724 };
2725 
2726 
2727 template <class T> string CommaStr (const T & inNum)
2728 {
2729  ostringstream oss;
2730  const locale loc (oss.getloc(), new ThousandsSeparator);
2731  oss.imbue (loc);
2732  oss << inNum;
2733  return oss.str();
2734 } // CommaStr
2735 
2736 
2737 string AUTOCIRCULATE_STATUS::operator [] (const unsigned inIndexNum) const
2738 {
2739  ostringstream oss;
2740  if (inIndexNum == 0)
2742  else if (!IsStopped())
2743  switch (inIndexNum)
2744  {
2745  case 1: oss << DEC(GetStartFrame()); break;
2746  case 2: oss << DEC(GetEndFrame()); break;
2747  case 3: oss << DEC(GetFrameCount()); break;
2748  case 4: oss << DEC(GetActiveFrame()); break;
2749  case 5: oss << xHEX0N(acRDTSCStartTime,16); break;
2750  case 6: oss << xHEX0N(acAudioClockStartTime,16); break;
2751  case 7: oss << DEC(acRDTSCCurrentTime); break;
2752  case 8: oss << DEC(acAudioClockCurrentTime); break;
2753  case 9: oss << CommaStr(GetProcessedFrameCount()); break;
2754  case 10: oss << CommaStr(GetDroppedFrameCount()); break;
2755  case 11: oss << DEC(GetBufferLevel()); break;
2756  case 12: oss << ::NTV2AudioSystemToString(acAudioSystem, true); break;
2757  case 13: oss << (WithRP188() ? "Yes" : "No"); break;
2758  case 14: oss << (WithLTC() ? "Yes" : "No"); break;
2759  case 15: oss << (WithFBFChange() ? "Yes" : "No"); break;
2760  case 16: oss << (WithFBOChange() ? "Yes" : "No"); break;
2761  case 17: oss << (WithColorCorrect() ? "Yes" : "No"); break;
2762  case 18: oss << (WithVidProc() ? "Yes" : "No"); break;
2763  case 19: oss << (WithCustomAnc() ? "Yes" : "No"); break;
2764  case 20: oss << (WithHDMIAuxData() ? "Yes" : "No"); break;
2765  case 21: oss << (IsFieldMode() ? "Yes" : "No"); break;
2766  default: break;
2767  }
2768  else if (inIndexNum < 22)
2769  oss << "---";
2770  return oss.str();
2771 }
2772 
2773 
2774 ostream & operator << (ostream & oss, const AUTOCIRCULATE_STATUS & inObj)
2775 {
2776  if (!inObj.IsStopped())
2777  oss << ::NTV2ChannelToString(inObj.GetChannel(), true) << ": "
2778  << (inObj.IsInput() ? "Input " : (inObj.IsOutput() ? "Output" : "*BAD* "))
2779  << setw(12) << ::NTV2AutoCirculateStateToString(inObj.acState) << " "
2780  << setw( 5) << inObj.GetStartFrame()
2781  << setw( 6) << inObj.GetEndFrame()
2782  << setw( 6) << inObj.GetActiveFrame()
2783  << setw( 8) << inObj.GetProcessedFrameCount()
2784  << setw( 8) << inObj.GetDroppedFrameCount()
2785  << setw( 7) << inObj.GetBufferLevel()
2786  << setw(10) << ::NTV2AudioSystemToString(inObj.acAudioSystem, true)
2787  << setw(10) << (inObj.WithRP188() ? "+RP188" : "-RP188")
2788  << setw(10) << (inObj.WithLTC() ? "+LTC" : "-LTC")
2789  << setw(10) << (inObj.WithFBFChange() ? "+FBFchg" : "-FBFchg")
2790  << setw(10) << (inObj.WithFBOChange() ? "+FBOchg" : "-FBOchg")
2791  << setw(10) << (inObj.WithColorCorrect() ? "+ColCor" : "-ColCor")
2792  << setw(10) << (inObj.WithVidProc() ? "+VidProc" : "-VidProc")
2793  << setw(10) << (inObj.WithCustomAnc() ? "+AncData" : "-AncData")
2794  << setw(10) << (inObj.WithHDMIAuxData() ? "+HDMIAux" : "-HDMIAux")
2795  << setw(10) << (inObj.IsFieldMode() ? "+FldMode" : "-FldMode");
2796  return oss;
2797 }
2798 
2799 
2801 {
2802  Reset ();
2803 }
2804 
2805 
2806 NTV2SegmentedDMAInfo::NTV2SegmentedDMAInfo (const ULWord inNumSegments, const ULWord inNumActiveBytesPerRow, const ULWord inHostBytesPerRow, const ULWord inDeviceBytesPerRow)
2807 {
2808  Set (inNumSegments, inNumActiveBytesPerRow, inHostBytesPerRow, inDeviceBytesPerRow);
2809 }
2810 
2811 
2812 void NTV2SegmentedDMAInfo::Set (const ULWord inNumSegments, const ULWord inNumActiveBytesPerRow, const ULWord inHostBytesPerRow, const ULWord inDeviceBytesPerRow)
2813 {
2814  acNumSegments = inNumSegments;
2815  if (acNumSegments > 1)
2816  {
2817  acNumActiveBytesPerRow = inNumActiveBytesPerRow;
2818  acSegmentHostPitch = inHostBytesPerRow;
2819  acSegmentDevicePitch = inDeviceBytesPerRow;
2820  }
2821  else
2822  Reset ();
2823 }
2824 
2825 
2827 {
2829 }
2830 
2831 
2833  : ccMode (NTV2_CCMODE_INVALID),
2834  ccSaturationValue (0)
2835 {
2836 }
2837 
2838 
2840 {
2841  Clear ();
2842 }
2843 
2844 
2846 {
2848  ccSaturationValue = 0;
2850 }
2851 
2852 
2853 bool NTV2ColorCorrectionData::Set (const NTV2ColorCorrectionMode inMode, const ULWord inSaturation, const void * pInTableData)
2854 {
2855  Clear();
2857  return false;
2858 
2859  if (pInTableData)
2861  return false;
2862  ccMode = inMode;
2863  ccSaturationValue = (inMode == NTV2_CCMODE_3WAY) ? inSaturation : 0;
2864  return true;
2865 }
2866 
2867 
2869  : acHeader (NTV2_TYPE_ACXFER, sizeof(AUTOCIRCULATE_TRANSFER)),
2870  acOutputTimeCodes (NTV2_MAX_NUM_TIMECODE_INDEXES * sizeof (NTV2_RP188)),
2871  acTransferStatus (),
2872  acInUserCookie (0),
2873  acInVideoDMAOffset (0),
2874  acInSegmentedDMAInfo (),
2875  acColorCorrection (),
2876  acFrameBufferFormat (NTV2_FBF_10BIT_YCBCR),
2877  acFrameBufferOrientation (NTV2_FRAMEBUFFER_ORIENTATION_TOPDOWN),
2878  acVidProcInfo (),
2879  acVideoQuarterSizeExpand (NTV2_QuarterSizeExpandOff),
2880  acPeerToPeerFlags (0),
2881  acFrameRepeatCount (1),
2882  acDesiredFrame (-1),
2883  acRP188 (),
2884  acCrosspoint (NTV2CROSSPOINT_INVALID)
2885 {
2889 }
2890 
2891 
2892 AUTOCIRCULATE_TRANSFER::AUTOCIRCULATE_TRANSFER (ULWord * pInVideoBuffer, const ULWord inVideoByteCount, ULWord * pInAudioBuffer,
2893  const ULWord inAudioByteCount, ULWord * pInANCBuffer, const ULWord inANCByteCount,
2894  ULWord * pInANCF2Buffer, const ULWord inANCF2ByteCount)
2895  : acHeader (NTV2_TYPE_ACXFER, sizeof(AUTOCIRCULATE_TRANSFER)),
2896  acVideoBuffer (pInVideoBuffer, inVideoByteCount),
2897  acAudioBuffer (pInAudioBuffer, inAudioByteCount),
2898  acANCBuffer (pInANCBuffer, inANCByteCount),
2899  acANCField2Buffer (pInANCF2Buffer, inANCF2ByteCount),
2900  acOutputTimeCodes (NTV2_MAX_NUM_TIMECODE_INDEXES * sizeof (NTV2_RP188)),
2901  acTransferStatus (),
2902  acInUserCookie (0),
2903  acInVideoDMAOffset (0),
2904  acInSegmentedDMAInfo (),
2905  acColorCorrection (),
2906  acFrameBufferFormat (NTV2_FBF_10BIT_YCBCR),
2907  acFrameBufferOrientation (NTV2_FRAMEBUFFER_ORIENTATION_TOPDOWN),
2908  acVidProcInfo (),
2909  acVideoQuarterSizeExpand (NTV2_QuarterSizeExpandOff),
2910  acPeerToPeerFlags (0),
2911  acFrameRepeatCount (1),
2912  acDesiredFrame (-1),
2913  acRP188 (),
2914  acCrosspoint (NTV2CROSSPOINT_INVALID)
2915 {
2919 }
2920 
2921 
2923 {
2924 }
2925 
2926 
2927 bool AUTOCIRCULATE_TRANSFER::SetBuffers (ULWord * pInVideoBuffer, const ULWord inVideoByteCount,
2928  ULWord * pInAudioBuffer, const ULWord inAudioByteCount,
2929  ULWord * pInANCBuffer, const ULWord inANCByteCount,
2930  ULWord * pInANCF2Buffer, const ULWord inANCF2ByteCount)
2931 {
2933  return SetVideoBuffer (pInVideoBuffer, inVideoByteCount)
2934  && SetAudioBuffer (pInAudioBuffer, inAudioByteCount)
2935  && SetAncBuffers (pInANCBuffer, inANCByteCount, pInANCF2Buffer, inANCF2ByteCount);
2936 }
2937 
2938 
2939 bool AUTOCIRCULATE_TRANSFER::SetVideoBuffer (ULWord * pInVideoBuffer, const ULWord inVideoByteCount)
2940 {
2942  acVideoBuffer.Set (pInVideoBuffer, inVideoByteCount);
2943  return true;
2944 }
2945 
2946 
2947 bool AUTOCIRCULATE_TRANSFER::SetAudioBuffer (ULWord * pInAudioBuffer, const ULWord inAudioByteCount)
2948 {
2950  acAudioBuffer.Set (pInAudioBuffer, inAudioByteCount);
2951  return true;
2952 }
2953 
2954 
2955 bool AUTOCIRCULATE_TRANSFER::SetAncBuffers (ULWord * pInANCBuffer, const ULWord inANCByteCount, ULWord * pInANCF2Buffer, const ULWord inANCF2ByteCount)
2956 {
2958  acANCBuffer.Set (pInANCBuffer, inANCByteCount);
2959  acANCField2Buffer.Set (pInANCF2Buffer, inANCF2ByteCount);
2960  return true;
2961 }
2962 
2964 
2965 
2967 {
2969  ULWord maxNumValues (acOutputTimeCodes.GetByteCount() / sizeof(NTV2_RP188));
2970  NTV2_RP188 * pArray (reinterpret_cast<NTV2_RP188*>(acOutputTimeCodes.GetHostPointer()));
2971  if (!pArray)
2972  return false;
2973  if (maxNumValues > NTV2_MAX_NUM_TIMECODE_INDEXES)
2974  maxNumValues = NTV2_MAX_NUM_TIMECODE_INDEXES;
2975 
2976  for (UWord ndx (0); ndx < UWord(maxNumValues); ndx++)
2977  {
2978  const NTV2TCIndex tcIndex (static_cast<NTV2TCIndex>(ndx));
2979  NTV2TimeCodesConstIter iter (inValues.find(tcIndex));
2980  pArray[ndx] = (iter != inValues.end()) ? iter->second : INVALID_TIMECODE_VALUE;
2981  } // for each possible NTV2TCSource value
2982  return true;
2983 }
2984 
2985 
2986 bool AUTOCIRCULATE_TRANSFER::SetOutputTimeCode (const NTV2_RP188 & inTimeCode, const NTV2TCIndex inTCIndex)
2987 {
2989  ULWord maxNumValues (acOutputTimeCodes.GetByteCount() / sizeof(NTV2_RP188));
2990  NTV2_RP188 * pArray (reinterpret_cast<NTV2_RP188*>(acOutputTimeCodes.GetHostPointer()));
2991  if (!pArray)
2992  return false;
2993  if (maxNumValues > NTV2_MAX_NUM_TIMECODE_INDEXES)
2994  maxNumValues = NTV2_MAX_NUM_TIMECODE_INDEXES;
2995  if (!NTV2_IS_VALID_TIMECODE_INDEX(inTCIndex))
2996  return false;
2997 
2998  pArray[inTCIndex] = inTimeCode;
2999  return true;
3000 }
3001 
3002 bool AUTOCIRCULATE_TRANSFER::SetAllOutputTimeCodes (const NTV2_RP188 & inTimeCode, const bool inIncludeF2)
3003 {
3005  ULWord maxNumValues (acOutputTimeCodes.GetByteCount() / sizeof(NTV2_RP188));
3006  NTV2_RP188 * pArray (reinterpret_cast<NTV2_RP188*>(acOutputTimeCodes.GetHostPointer()));
3007  if (!pArray)
3008  return false;
3009  if (maxNumValues > NTV2_MAX_NUM_TIMECODE_INDEXES)
3010  maxNumValues = NTV2_MAX_NUM_TIMECODE_INDEXES;
3011 
3012  for (ULWord tcIndex(0); tcIndex < maxNumValues; tcIndex++)
3013  if (NTV2_IS_ATC_VITC2_TIMECODE_INDEX(tcIndex))
3014  pArray[tcIndex] = inIncludeF2 ? inTimeCode : INVALID_TIMECODE_VALUE;
3015  else
3016  pArray[tcIndex] = inTimeCode;
3017  return true;
3018 }
3019 
3020 
3022 {
3024  if (!NTV2_IS_VALID_FRAME_BUFFER_FORMAT (inNewFormat))
3025  return false;
3026  acFrameBufferFormat = inNewFormat;
3027  return true;
3028 }
3029 
3030 
3032 {
3034  SetBuffers (AJA_NULL, 0, AJA_NULL, 0, AJA_NULL, 0, AJA_NULL, 0);
3035 }
3036 
3037 
3038 bool AUTOCIRCULATE_TRANSFER::EnableSegmentedDMAs (const ULWord inNumSegments, const ULWord inNumActiveBytesPerRow,
3039  const ULWord inHostBytesPerRow, const ULWord inDeviceBytesPerRow)
3040 {
3042  // Cannot allow segmented DMAs if video buffer was self-allocated by the SDK, since the video buffer size holds the segment size (in bytes)...
3044  return false; // Disallow
3045  acInSegmentedDMAInfo.Set (inNumSegments, inNumActiveBytesPerRow, inHostBytesPerRow, inDeviceBytesPerRow);
3046  return true;
3047 }
3048 
3049 
3051 {
3054  return true;
3055 }
3056 
3057 
3059 {
3062 }
3063 
3064 
3066 {
3068  return acTransferStatus.acFrameStamp.GetInputTimeCodes (outValues);
3069 }
3070 
3071 
3072 bool AUTOCIRCULATE_TRANSFER::GetInputTimeCode (NTV2_RP188 & outTimeCode, const NTV2TCIndex inTCIndex) const
3073 {
3075  return acTransferStatus.acFrameStamp.GetInputTimeCode (outTimeCode, inTCIndex);
3076 }
3077 
3078 
3079 bool AUTOCIRCULATE_TRANSFER::GetInputTimeCodes (NTV2TimeCodes & outTimeCodes, const NTV2Channel inSDIInput, const bool inValidOnly) const
3080 {
3082  return acTransferStatus.acFrameStamp.GetInputTimeCodes (outTimeCodes, inSDIInput, inValidOnly);
3083 }
3084 
3085 
3087  : mHeader (NTV2_TYPE_AJADEBUGLOGGING, sizeof (NTV2DebugLogging)),
3088  mSharedMemory (inEnable ? AJADebug::GetPrivateDataLoc() : AJA_NULL, inEnable ? AJADebug::GetPrivateDataLen() : 0)
3089 {
3090 }
3091 
3092 
3093 ostream & NTV2DebugLogging::Print (ostream & inOutStream) const
3094 {
3096  inOutStream << mHeader << " shMem=" << mSharedMemory << " " << mTrailer;
3097  return inOutStream;
3098 }
3099 
3100 
3101 
3103  : mHeader (NTV2_TYPE_AJABUFFERLOCK, sizeof(NTV2BufferLock))
3104 {
3106  SetFlags(0);
3107  SetMaxLockSize(0);
3108 }
3109 
3110 NTV2BufferLock::NTV2BufferLock (const NTV2Buffer & inBuffer, const ULWord inFlags)
3111  : mHeader (NTV2_TYPE_AJABUFFERLOCK, sizeof(NTV2BufferLock))
3112 {
3114  SetBuffer(inBuffer);
3115  SetFlags(inFlags);
3116  SetMaxLockSize(0);
3117 }
3118 
3119 NTV2BufferLock::NTV2BufferLock(const ULWord * pInBuffer, const ULWord inByteCount, const ULWord inFlags)
3120  : mHeader (NTV2_TYPE_AJABUFFERLOCK, sizeof(NTV2BufferLock))
3121 {
3123  SetBuffer (NTV2Buffer(pInBuffer, inByteCount));
3124  SetFlags (inFlags);
3125  SetMaxLockSize(0);
3126 }
3127 
3128 NTV2BufferLock::NTV2BufferLock(const ULWord64 inMaxLockSize, const ULWord inFlags)
3129  : mHeader (NTV2_TYPE_AJABUFFERLOCK, sizeof(NTV2BufferLock))
3130 {
3132  SetBuffer (NTV2Buffer());
3133  SetFlags (inFlags);
3134  SetMaxLockSize(inMaxLockSize);
3135 }
3136 
3137 bool NTV2BufferLock::SetBuffer (const NTV2Buffer & inBuffer)
3138 { // Just use address & length (don't deep copy)...
3140  return mBuffer.Set (inBuffer.GetHostPointer(), inBuffer.GetByteCount());
3141 }
3142 
3143 ostream & NTV2BufferLock::Print (ostream & inOutStream) const
3144 {
3146  inOutStream << mHeader << mBuffer << " flags=" << xHEX0N(mFlags,8) << " " << mTrailer;
3147  return inOutStream;
3148 }
3149 
3150 
3152  : mHeader (NTV2_TYPE_AJABITSTREAM, sizeof(NTV2Bitstream))
3153 {
3155 }
3156 
3157 NTV2Bitstream::NTV2Bitstream (const NTV2Buffer & inBuffer, const ULWord inFlags)
3158  : mHeader (NTV2_TYPE_AJABITSTREAM, sizeof(NTV2Bitstream))
3159 {
3161  SetBuffer(inBuffer);
3162  SetFlags(inFlags);
3163 }
3164 
3165 NTV2Bitstream::NTV2Bitstream(const ULWord * pInBuffer, const ULWord inByteCount, const ULWord inFlags)
3166  : mHeader (NTV2_TYPE_AJABITSTREAM, sizeof(NTV2Bitstream))
3167 {
3169  SetBuffer (NTV2Buffer(pInBuffer, inByteCount));
3170  SetFlags (inFlags);
3171 }
3172 
3173 bool NTV2Bitstream::SetBuffer (const NTV2Buffer & inBuffer)
3174 { // Just use address & length (don't deep copy)...
3176  return mBuffer.Set (inBuffer.GetHostPointer(), inBuffer.GetByteCount());
3177 }
3178 
3179 ostream & NTV2Bitstream::Print (ostream & inOutStream) const
3180 {
3182  inOutStream << mHeader << mBuffer << " flags=" << xHEX0N(mFlags,8) << " " << mTrailer;
3183  return inOutStream;
3184 }
3185 
3187  : mHeader (NTV2_TYPE_AJASTREAMCHANNEL, sizeof(NTV2StreamChannel))
3188 {
3190 }
3191 
3192 ostream & NTV2StreamChannel::Print (ostream & inOutStream) const
3193 {
3195  inOutStream << mHeader << mChannel << " flags=" << xHEX0N(mFlags,8) << xHEX0N(mStatus, 8) << " " << mTrailer;
3196  return inOutStream;
3197 }
3198 
3200  : mHeader (NTV2_TYPE_AJASTREAMBUFFER, sizeof(NTV2StreamBuffer))
3201 {
3203 }
3204 
3205 ostream & NTV2StreamBuffer::Print (ostream & inOutStream) const
3206 {
3208  inOutStream << mHeader << mChannel << " flags=" << xHEX0N(mFlags,8) << xHEX0N(mStatus, 8) << " " << mTrailer;
3209  return inOutStream;
3210 }
3211 
3213  : mHeader (NTV2_TYPE_AJAMAILBUFFER, sizeof(NTV2MailBuffer))
3214 {
3216 }
3217 
3218 ostream & NTV2MailBuffer::Print (ostream & inOutStream) const
3219 {
3221  inOutStream << mHeader << mChannel << " flags=" << xHEX0N(mFlags,8) << xHEX0N(mStatus, 8) << " " << mTrailer;
3222  return inOutStream;
3223 }
3224 
3226  : mHeader (NTV2_TYPE_GETREGS, sizeof(NTV2GetRegisters)),
3227  mInNumRegisters (ULWord (inRegisterNumbers.size ())),
3228  mOutNumRegisters (0)
3229 {
3231  ResetUsing (inRegisterNumbers);
3232 }
3233 
3234 
3236  : mHeader (NTV2_TYPE_GETREGS, sizeof(NTV2GetRegisters)),
3237  mInNumRegisters (ULWord (inRegReads.size ())),
3238  mOutNumRegisters (0)
3239 {
3241  ResetUsing (inRegReads);
3242 }
3243 
3244 
3245 bool NTV2GetRegisters::ResetUsing (const NTV2RegNumSet & inRegisterNumbers)
3246 {
3248  mInNumRegisters = ULWord(inRegisterNumbers.size());
3249  mOutNumRegisters = 0;
3250  bool result ( mInRegisters.Allocate(mInNumRegisters * sizeof(ULWord))
3251  && mOutGoodRegisters.Allocate(mInNumRegisters * sizeof(ULWord))
3252  && mOutValues.Allocate(mInNumRegisters * sizeof(ULWord)));
3253  if (!result)
3254  return false;
3255  mInRegisters.Fill(ULWord(0)); mOutGoodRegisters.Fill(ULWord(0)); mOutValues.Fill(ULWord(0));
3256 
3257  ULWord * pRegArray(mInRegisters);
3258  if (!pRegArray)
3259  return false;
3260 
3261  ULWord ndx(0);
3262  for (NTV2RegNumSetConstIter iter(inRegisterNumbers.begin()); iter != inRegisterNumbers.end(); ++iter)
3263  pRegArray[ndx++] = *iter;
3264  return (ndx * sizeof(ULWord)) == mInRegisters.GetByteCount();
3265 }
3266 
3268 {
3269  outRegNums.clear();
3270  if (!mInNumRegisters)
3271  return true; // None requested
3272  if (!mInRegisters)
3273  return false; // Empty/NULL reg num buffer
3274  if (mInRegisters.GetByteCount()/4 < mInNumRegisters)
3275  return false; // Sanity check failed: Reg num buffer too small
3276 
3277  const ULWord * pRegNums(mInRegisters);
3278  for (ULWord ndx(0); ndx < mInNumRegisters; ndx++)
3279  if (outRegNums.find(pRegNums[ndx]) == outRegNums.end())
3280  outRegNums.insert(pRegNums[ndx]);
3281  return true;
3282 }
3283 
3284 
3286 {
3288  outGoodRegNums.clear();
3289  if (!mOutGoodRegisters)
3290  return false; // Empty/NULL 'mOutGoodRegisters' array!
3291  if (!mOutNumRegisters)
3292  return false; // The driver says zero successfully read!
3293  if (mOutNumRegisters > mInNumRegisters)
3294  return false; // Sanity check failed: mOutNumRegisters must be less than or equal to mInNumRegisters!
3295 
3296  const ULWord * pRegArray (mOutGoodRegisters);
3297  for (ULWord ndx(0); ndx < mOutNumRegisters; ndx++)
3298  outGoodRegNums.insert(pRegArray[ndx]);
3299  return true;
3300 }
3301 
3303 {
3305  outBadRegNums.clear();
3306  NTV2RegNumSet reqRegNums, goodRegNums;
3307  if (!GetRequestedRegisterNumbers(reqRegNums))
3308  return false;
3309  if (!GetGoodRegisters(goodRegNums))
3310  return false;
3311  if (reqRegNums == goodRegNums)
3312  return true; // Requested reg nums identical to those that were read successfully
3313 
3314  // Subtract goodRegNums from reqRegNums...
3315  std::set_difference (reqRegNums.begin(), reqRegNums.end(),
3316  goodRegNums.begin(), goodRegNums.end(),
3317  std::inserter(outBadRegNums, outBadRegNums.begin()));
3318  return true;
3319 }
3320 
3321 bool NTV2GetRegisters::PatchRegister (const ULWord inRegNum, const ULWord inValue)
3322 {
3323  if (!mOutGoodRegisters)
3324  return false; // Empty/null 'mOutGoodRegisters' array!
3325  if (!mOutNumRegisters)
3326  return false; // Driver says zero successfully read!
3327  if (mOutNumRegisters > mInNumRegisters)
3328  return false; // Sanity check failed: mOutNumRegisters must be less than or equal to mInNumRegisters!
3329  if (!mOutValues)
3330  return false; // Empty/null 'mOutValues' array!
3331  if (mOutGoodRegisters.GetByteCount() != mOutValues.GetByteCount())
3332  return false; // Sanity check failed: These sizes should match
3333  const ULWord * pRegArray (mOutGoodRegisters);
3334  ULWord * pValArray (mOutValues);
3335  for (ULWord ndx(0); ndx < mOutNumRegisters; ndx++)
3336  if (pRegArray[ndx] == inRegNum)
3337  {
3338  pValArray[ndx] = inValue;
3339  return true;
3340  }
3341  return false; // Not found
3342 }
3343 
3344 
3346 {
3348  outValues.clear ();
3349  if (!mOutGoodRegisters)
3350  return false; // Empty/null 'mOutGoodRegisters' array!
3351  if (!mOutNumRegisters)
3352  return false; // Driver says zero successfully read!
3353  if (mOutNumRegisters > mInNumRegisters)
3354  return false; // Sanity check failed: mOutNumRegisters must be less than or equal to mInNumRegisters!
3355  if (!mOutValues)
3356  return false; // Empty/null 'mOutValues' array!
3357  if (mOutGoodRegisters.GetByteCount() != mOutValues.GetByteCount())
3358  return false; // Sanity check failed: These sizes should match
3359 
3360  const ULWord * pRegArray (mOutGoodRegisters);
3361  const ULWord * pValArray (mOutValues);
3362  for (ULWord ndx(0); ndx < mOutNumRegisters; ndx++)
3363  {
3364  outValues [pRegArray[ndx]] = pValArray[ndx];
3365 #if defined(NTV2_PRETEND_DEVICE)
3366  if (pRegArray[ndx] == kRegBoardID && pValArray[ndx] == NTV2_PRETEND_DEVICE_FROM)
3367  outValues [pRegArray[ndx]] = NTV2_PRETEND_DEVICE_TO;
3368 // else if (pRegArray[ndx] == kRegReserved83 || pRegArray[ndx] == kRegLPRJ45IP)
3369 // outValues [pRegArray[ndx]] = 0x0A03FAD9; // Local IPv4 10.3.250.217
3370 #endif // NTV2_PRETEND_DEVICE
3371  }
3372  return true;
3373 }
3374 
3375 
3377 {
3378  NTV2RegisterValueMap regValMap;
3379  if (!GetRegisterValues(regValMap))
3380  return false;
3381 
3382  if (outValues.empty())
3383  {
3384  for (NTV2RegValueMapConstIter it(regValMap.begin()); it != regValMap.end(); ++it)
3385  {
3386  NTV2RegInfo regInfo(/*regNum*/it->first, /*regVal*/it->second);
3387 #if defined(NTV2_PRETEND_DEVICE)
3388  if (regInfo.regNum() == kRegBoardID && regInfo.value() == NTV2_PRETEND_DEVICE_FROM)
3389  regInfo.setValue(NTV2_PRETEND_DEVICE_TO);
3390 // else if (regInfo.regNum() == kRegReserved83 || regInfo.regNum() == kRegLPRJ45IP)
3391 // regInfo.setValue(0x0A03FAD9); // Local IPv4 10.3.250.217
3392 #endif // NTV2_PRETEND_DEVICE
3393  outValues.push_back(regInfo);
3394  }
3395  return true;
3396  }
3397  else
3398  {
3399  uint32_t missingTally(0);
3400  for (NTV2RegisterReadsIter it (outValues.begin()); it != outValues.end(); ++it)
3401  {
3402  NTV2RegValueMapConstIter mapIter(regValMap.find(it->registerNumber));
3403  if (mapIter != regValMap.end())
3404  it->registerValue = mapIter->second;
3405  else
3406  missingTally++; // Missing register
3407 
3408 #if defined(NTV2_PRETEND_DEVICE) // Fake KONAIP25G from C4412G (see also CNTV2XXXXDriverInterface::ReadRegister):
3409  if (it->registerNumber == kRegBoardID && it->registerValue == NTV2_PRETEND_DEVICE_FROM)
3410  it->registerValue = NTV2_PRETEND_DEVICE_TO;
3411 // else if (it->registerNumber == kRegReserved83 || it->registerNumber == kRegLPRJ45IP)
3412 // it->registerValue = 0x0A03FAD9; // Local IPv4 10.3.250.217
3413 #endif // NTV2_PRETEND_DEVICE
3414  }
3415  return !missingTally;
3416  }
3417 }
3418 
3419 
3420 ostream & NTV2GetRegisters::Print (ostream & inOutStream) const
3421 {
3422  inOutStream << mHeader << ", numRegs=" << mInNumRegisters << ", inRegs=" << mInRegisters << ", outNumGoodRegs=" << mOutNumRegisters
3423  << ", outGoodRegs=" << mOutGoodRegisters << ", outValues=" << mOutValues << ", " << mTrailer;
3424  return inOutStream;
3425 }
3426 
3427 
3429  : mHeader (NTV2_TYPE_SETREGS, sizeof(NTV2SetRegisters)),
3430  mInNumRegisters (ULWord(inRegWrites.size())),
3431  mOutNumFailures (0)
3432 {
3433  ResetUsing(inRegWrites);
3434 }
3435 
3436 
3438 {
3440  mInNumRegisters = ULWord(inRegWrites.size());
3441  mOutNumFailures = 0;
3442  const bool result (mInRegInfos.Allocate (mInNumRegisters * sizeof(NTV2RegInfo))
3444  if (!result)
3445  return false;
3446 
3447  ULWord ndx (0);
3448  NTV2RegInfo * pRegInfoArray (mInRegInfos);
3449  UWord * pBadRegIndexes (mOutBadRegIndexes);
3450 
3451  for (NTV2RegisterWritesConstIter it(inRegWrites.begin()); it != inRegWrites.end(); ++it)
3452  {
3453  if (pBadRegIndexes)
3454  pBadRegIndexes[ndx] = 0;
3455  if (pRegInfoArray)
3456  pRegInfoArray[ndx++] = *it;
3457  }
3458  NTV2_ASSERT((ndx * sizeof(NTV2RegInfo)) == mInRegInfos.GetByteCount());
3459  NTV2_ASSERT((ndx * sizeof(UWord)) == mOutBadRegIndexes.GetByteCount());
3460  return result;
3461 }
3462 
3463 
3465 {
3467  outFailedRegWrites.clear();
3468  return true;
3469 }
3470 
3472 {
3473  outRegWrites.clear();
3474  if (!mInNumRegisters)
3475  return false;
3476  if (!mInRegInfos)
3477  return false;
3478 
3479  outRegWrites.reserve(size_t(mInNumRegisters));
3480  const NTV2RegInfo * pRegInfos(mInRegInfos);
3481  for (ULWord ndx(0); ndx < mInNumRegisters; ndx++)
3482  outRegWrites.push_back(pRegInfos[ndx]);
3483  return true;
3484 }
3485 
3486 ostream & NTV2SetRegisters::Print (ostream & oss) const
3487 {
3489  oss << mHeader << ": numRegs=" << mInNumRegisters << " inRegInfos=" << mInRegInfos << " numFailures=" << DEC(mOutNumFailures)
3490  << " outBadRegIndexes=" << mOutBadRegIndexes << ": " << mTrailer;
3491  const UWord * pBadRegIndexes (mOutBadRegIndexes);
3492  const UWord maxNumBadRegIndexes (UWord(mOutBadRegIndexes.GetByteCount() / sizeof(UWord)));
3493  const NTV2RegInfo * pRegInfoArray (mInRegInfos);
3494  const UWord maxNumRegInfos (UWord(mInRegInfos.GetByteCount() / sizeof(NTV2RegInfo)));
3495  if (pBadRegIndexes && maxNumBadRegIndexes && pRegInfoArray && maxNumRegInfos && mOutNumFailures)
3496  {
3497  oss << endl;
3498  for (UWord num(0); num < maxNumBadRegIndexes; num++)
3499  {
3500  const UWord badRegIndex (pBadRegIndexes[num]);
3501  if (badRegIndex < maxNumRegInfos)
3502  {
3503  const NTV2RegInfo & badRegInfo (pRegInfoArray[badRegIndex]);
3504  oss << "Failure " << num << ": " << badRegInfo << endl;
3505  }
3506  }
3507  }
3508  return oss;
3509 }
3510 
3511 
3512 bool NTV2RegInfo::operator < (const NTV2RegInfo & inRHS) const
3513 {
3514  typedef std::pair <ULWord, ULWord> ULWordPair;
3515  typedef std::pair <ULWordPair, ULWordPair> ULWordPairs;
3516  const ULWordPairs rhs (ULWordPair (inRHS.registerNumber, inRHS.registerValue), ULWordPair (inRHS.registerMask, inRHS.registerShift));
3517  const ULWordPairs mine(ULWordPair (registerNumber, registerValue), ULWordPair (registerMask, registerShift));
3518  return mine < rhs;
3519 }
3520 
3521 ostream & NTV2RegInfo::Print (ostream & oss, const bool inAsCode) const
3522 {
3523  if (inAsCode)
3524  return PrintCode(oss);
3526  oss << "[" << regName << "|" << DEC(registerNumber) << ": val=" << xHEX0N(registerValue,8);
3527  if (registerMask != 0xFFFFFFFF)
3528  oss << " msk=" << xHEX0N(registerMask,8);
3529  if (registerShift)
3530  oss << " shf=" << DEC(registerShift);
3531  return oss << "]";
3532 }
3533 
3534 ostream & NTV2RegInfo::PrintCode (ostream & oss, const int inRadix, const NTV2DeviceID inDeviceID, const string & sCard) const
3535 {
3537  const bool readOnly (CNTV2RegisterExpert::IsReadOnly(registerNumber));
3538  const bool badName (regName.find(' ') != string::npos);
3539  if (readOnly)
3540  oss << "//\t";
3541  oss << sCard << ".WriteRegister (";
3542  if (badName)
3543  oss << DEC(registerNumber);
3544  else
3545  oss << regName;
3546  switch (inRadix)
3547  {
3548  case 2: oss << ", " << BIN032(registerValue); break;
3549  case 8: oss << ", " << OCT(registerValue); break;
3550  case 10: oss << ", " << DEC(registerValue); break;
3551  default: oss << ", " << xHEX0N(registerValue,8); break;
3552  }
3553  if (registerMask != 0xFFFFFFFF)
3554  switch (inRadix)
3555  {
3556  case 2: oss << ", " << BIN032(registerMask); break;
3557  case 8: oss << ", " << OCT(registerMask); break;
3558  case 10: oss << ", " << DEC(registerMask); break;
3559  default: oss << ", " << xHEX0N(registerMask,8); break;
3560  }
3561  if (registerShift)
3562  oss << ", " << DEC(registerShift);
3563  oss << "); // ";
3564  if (badName)
3565  oss << regName;
3566  else
3567  oss << "Reg " << DEC(registerNumber);
3568  // Decode the reg value...
3570  if (!info.empty()) // and add to end of comment
3571  oss << " // " << aja::replace(info, "\n", ", ");
3572  return oss;
3573 }
3574 
3575 ostream & NTV2RegInfo::PrintLog (ostream & oss, const NTV2DeviceID inDeviceID) const
3576 {
3577  const string name ((regNum() < VIRTUALREG_START) || (regNum() > kVRegLast) ? "Register" : "VReg");
3578  oss << name << " Name: " << CNTV2RegisterExpert::GetDisplayName(regNum()) << endl
3579  << name << " Number: " << regNum() << endl
3580  << name << " Value: " << value() << " : " << xHEX0N(value(),8);
3581  //<< "Register Classes: " << CNTV2RegisterExpert::GetRegisterClasses(regNum()) << endl
3582  const string sVal(CNTV2RegisterExpert::GetDisplayValue (regNum(), value(), inDeviceID));
3583 // if (!sVal.empty()) // stay compatible with older supportlogs
3584  oss << endl
3585  << sVal << endl;
3586  return oss;
3587 }
3588 
3590 {
3591  ULWord received(0), rcvdRegNum(0), rcvdRegVal(0); // what was received
3592  static const string sNumber (" Number: "), sValue (" Value: "), sHexPrefix(" : 0x");
3593  for (size_t ndx(0); ndx < inLogLines.size(); ndx++)
3594  {
3595  string line (inLogLines.at(ndx));
3596  size_t posNumber (line.find(sNumber));
3597  if (posNumber != string::npos)
3598  { // e.g. "VReg Number: 10394" pos=4, then 4+9=13
3599  if (received & 0x0001)
3600  continue; // uh-oh, already received "Number:"
3601  line.erase(0, posNumber + sNumber.length()); // only decimal number should remain
3602  if (!aja::is_legal_decimal_number (line, line.length()))
3603  continue; // missing decimal register number, keep looking
3604  rcvdRegNum = aja::stoull(line); // Read the reg number
3605  received |= 0x00000001; // received register number
3606  continue;
3607  } // if " Number: " found
3608  size_t posValue(inLogLines.at(ndx).find(sValue));
3609  if (posValue != string::npos)
3610  { // e.g. "VReg Value: 13966 : 0x0000368E"
3611  if (received & 0x0002)
3612  continue; // uh-oh, already received "Value:"
3613  posValue += sValue.length();
3614  line.erase(0, posValue + sValue.length()); // remainder: "13966 : 0x0000368E"
3615  aja::strip(line); aja::lower(line); // strip any remaining whitespace, then force lower case
3616  // Check for non-hex digits...
3617  size_t numHexDigits(0);
3618  for (size_t ndx(0); ndx < line.size(); ndx++)
3619  if (aja::is_hex_digit(line.at(ndx)))
3620  numHexDigits++;
3621  if (numHexDigits != line.length())
3622  continue; // mismatch indicates bad hex digit(s), keep looking
3623  // Read the value...
3624  istringstream iss(line);
3625  iss >> std::hex >> rcvdRegVal;
3626  received |= 0x0002; // received register value
3627  continue;
3628  } // if " Value: " found
3629  } // for each line
3630  if (received == 3)
3631  setRegNum(rcvdRegNum).setValue(rcvdRegVal).setMask(0xFFFFFFFF).setShift(0);
3632  return received == 3; // success if we got both " Number: " and " Value: "
3633 } // ImportFromLog
3634 
3635 
3636 ostream & NTV2PrintULWordVector (const NTV2ULWordVector & inObj, ostream & inOutStream)
3637 {
3638  for (NTV2ULWordVector::const_iterator it(inObj.begin()); it != inObj.end(); ++it)
3639  inOutStream << " " << HEX0N(*it,8);
3640  return inOutStream;
3641 }
3642 
3643 
3644 ostream & NTV2PrintChannelList (const NTV2ChannelList & inObj, const bool inCompact, ostream & inOutStream)
3645 {
3646  inOutStream << (inCompact ? "Ch[" : "[");
3647  for (NTV2ChannelListConstIter it(inObj.begin()); it != inObj.end(); )
3648  {
3649  if (inCompact)
3650  inOutStream << DEC(*it+1);
3651  else
3652  inOutStream << ::NTV2ChannelToString(*it);
3653  if (++it != inObj.end())
3654  inOutStream << (inCompact ? "|" : ",");
3655  }
3656  return inOutStream << "]";
3657 }
3658 
3659 string NTV2ChannelListToStr (const NTV2ChannelList & inObj, const bool inCompact)
3660 { ostringstream oss;
3661  ::NTV2PrintChannelList (inObj, inCompact, oss);
3662  return oss.str();
3663 }
3664 
3665 ostream & NTV2PrintChannelSet (const NTV2ChannelSet & inObj, const bool inCompact, ostream & inOutStream)
3666 {
3667  inOutStream << (inCompact ? "Ch{" : "{");
3668  for (NTV2ChannelSetConstIter it(inObj.begin()); it != inObj.end(); )
3669  {
3670  if (inCompact)
3671  inOutStream << DEC(*it+1);
3672  else
3673  inOutStream << ::NTV2ChannelToString(*it);
3674  if (++it != inObj.end())
3675  inOutStream << (inCompact ? "|" : ",");
3676  }
3677  return inOutStream << "}";
3678 }
3679 
3680 string NTV2ChannelSetToStr (const NTV2ChannelSet & inObj, const bool inCompact)
3681 { ostringstream oss;
3682  ::NTV2PrintChannelSet (inObj, inCompact, oss);
3683  return oss.str();
3684 }
3685 
3686 NTV2ChannelSet NTV2MakeChannelSet (const NTV2Channel inFirstChannel, const UWord inNumChannels)
3687 {
3688  NTV2ChannelSet result;
3689  for (NTV2Channel ch(inFirstChannel); ch < NTV2Channel(inFirstChannel+inNumChannels); ch = NTV2Channel(ch+1))
3690  if (NTV2_IS_VALID_CHANNEL(ch))
3691  result.insert(ch);
3692  return result;
3693 }
3694 
3696 {
3697  NTV2ChannelSet result;
3698  for (NTV2ChannelListConstIter it(inChannels.begin()); it != inChannels.end(); ++it)
3699  result.insert(*it);
3700  return result;
3701 }
3702 
3703 NTV2ChannelList NTV2MakeChannelList (const NTV2Channel inFirstChannel, const UWord inNumChannels)
3704 {
3705  NTV2ChannelList result;
3706  for (NTV2Channel ch(inFirstChannel); ch < NTV2Channel(inFirstChannel+inNumChannels); ch = NTV2Channel(ch+1))
3707  if (NTV2_IS_VALID_CHANNEL(ch))
3708  result.push_back(ch);
3709  return result;
3710 }
3711 
3713 {
3714  NTV2ChannelList result;
3715  for (NTV2ChannelSetConstIter it(inChannels.begin()); it != inChannels.end(); ++it)
3716  result.push_back(*it);
3717  return result;
3718 }
3719 
3720 ostream & NTV2PrintAudioSystemSet (const NTV2AudioSystemSet & inObj, const bool inCompact, std::ostream & inOutStream)
3721 {
3722  inOutStream << (inCompact ? "AudSys{" : "{");
3723  for (NTV2AudioSystemSetConstIter it(inObj.begin()); it != inObj.end(); )
3724  {
3725  if (inCompact)
3726  inOutStream << DEC(*it+1);
3727  else
3728  inOutStream << ::NTV2AudioSystemToString(*it);
3729  if (++it != inObj.end())
3730  inOutStream << (inCompact ? "|" : ",");
3731  }
3732  return inOutStream << "}";
3733 }
3734 
3735 string NTV2AudioSystemSetToStr (const NTV2AudioSystemSet & inObj, const bool inCompact)
3736 { ostringstream oss;
3737  ::NTV2PrintAudioSystemSet (inObj, inCompact, oss);
3738  return oss.str();
3739 }
3740 
3741 NTV2AudioSystemSet NTV2MakeAudioSystemSet (const NTV2AudioSystem inFirstAudioSystem, const UWord inCount)
3742 {
3743  NTV2AudioSystemSet result;
3744  for (NTV2AudioSystem audSys(inFirstAudioSystem); audSys < NTV2AudioSystem(inFirstAudioSystem+inCount); audSys = NTV2AudioSystem(audSys+1))
3745  if (NTV2_IS_VALID_AUDIO_SYSTEM(audSys))
3746  result.insert(audSys);
3747  return result;
3748 }
3749 
3751 {
3752  NTV2RegNumSet result;
3753  for (NTV2RegisterReadsConstIter it(inRegInfos.begin()); it != inRegInfos.end(); ++it)
3754  if (result.find(it->registerNumber) == result.end())
3755  result.insert(it->registerNumber);
3756  return result;
3757 }
3758 
3760 {
3761  for (NTV2RegisterReadsConstIter iter(inRegInfos.begin()); iter != inRegInfos.end(); ++iter) // Ugh -- linear search
3762  if (iter->registerNumber == inRegNum)
3763  return iter;
3764  return inRegInfos.end();
3765 }
3766 
3767 
3768 ostream & operator << (std::ostream & inOutStream, const NTV2RegInfo & inObj)
3769 {
3770  return inObj.Print(inOutStream);
3771 }
3772 
3773 
3774 ostream & operator << (ostream & inOutStream, const NTV2RegisterWrites & inObj)
3775 {
3776  inOutStream << inObj.size () << " regs:" << endl;
3777  for (NTV2RegisterWritesConstIter iter (inObj.begin ()); iter != inObj.end (); ++iter)
3778  inOutStream << *iter << endl;
3779  return inOutStream;
3780 }
3781 
3782 
3783 NTV2BankSelGetSetRegs::NTV2BankSelGetSetRegs (const NTV2RegInfo & inBankSelect, const NTV2RegInfo & inOutRegInfo, const bool inDoWrite)
3784  : mHeader (NTV2_TYPE_BANKGETSET, sizeof (NTV2BankSelGetSetRegs)),
3785  mIsWriting (inDoWrite), // Default to reading
3786  mInBankInfos (sizeof(NTV2RegInfo)), // Room for one bank select
3787  mInRegInfos (sizeof(NTV2RegInfo)) // Room for one register read or write
3788 {
3789  NTV2RegInfo * pRegInfo (mInBankInfos);
3790  if (pRegInfo)
3791  *pRegInfo = inBankSelect; // Store bank select regInfo
3792  pRegInfo = mInRegInfos;
3793  if (pRegInfo)
3794  *pRegInfo = inOutRegInfo; // Store regInfo
3796 }
3797 
3798 
3800 {
3802  NTV2RegInfo result;
3803  if (mInRegInfos)
3804  {
3805  const NTV2RegInfo * pRegInfos (mInRegInfos);
3806  const ULWord maxNum (mInRegInfos.GetByteCount() / ULWord(sizeof(NTV2RegInfo)));
3807  if (ULWord(inIndex0) < maxNum)
3808  result = pRegInfos[inIndex0];
3809  }
3810  return result;
3811 }
3812 
3813 
3814 ostream & NTV2BankSelGetSetRegs::Print (ostream & oss) const
3815 {
3817  const NTV2RegInfo * pBankRegInfo (mInBankInfos);
3818  const NTV2RegInfo * pRegInfo (mInRegInfos);
3819  oss << mHeader << (mIsWriting ? " WRIT" : " READ") << " bankReg=";
3820  if (mInBankInfos) oss << *pBankRegInfo; else oss << "-";
3821  oss << " regInfos=";
3822  if (mInRegInfos) oss << *pRegInfo; else oss << "-";
3823  return oss;
3824 }
3825 
3826 
3828 {
3829  static NTV2StringList sOpStrs = {"(invalid)", /*1*/"Subscribe", /*2*/"Unsubscribe", /*3*/"Enable", /*4*/"Disable",
3830  /*5*/"GetSubscribed", /*6*/"GetEnabledIDs", /*7*/"GetIntCount", /*8*/"SetIntCount"};
3831  return op < sOpStrs.size() ? sOpStrs.at(op) : aja::to_string(op);
3832 }
3833 
3835 {
3836  if (id >= eNumInterruptTypes)
3837  return string();
3838  const char * pName (::NTV2InterruptEnumString(unsigned(id)));
3839  if (!pName)
3840  return aja::to_string(ULWord(id));
3841  return string(pName);
3842 }
3843 
3845 {
3846  NTV2StringList strs;
3847  for (ULWord id(0); id < eNumInterruptTypes; id++)
3848  if (mask & uint64_t(1ULL << id))
3849  strs.push_back(IntName(INTERRUPT_ENUMS(id)));
3850  return strs;
3851 }
3852 
3854  : mHeader (NTV2_TYPE_CONFIGINTERRUPT, sizeof(NTV2ConfigInterrupt)),
3855  mOperation (kOpINVALID),
3856  mFlags (0),
3857  mInterruptID (eNumInterruptTypes),
3858  mResult (0),
3859  mInterruptIDs (0),
3860  mEventHandle (0),
3861  mClientID (uint64_t(pClient)),
3862  mClientPID (0),
3863  mClientTID (0),
3864  mCount (0),
3865  mHandles (nullptr,0)
3866 {
3867  ::memset(mSpares, 0, sizeof(mSpares));
3869 }
3870 
3871 ostream & NTV2ConfigInterrupt::print (ostream & oss) const
3872 {
3873  oss << mHeader;
3874  if (isValid())
3875  {
3876  oss << " op=" << OpName(operation());
3877  oss << " id=" << IntName(interruptID());
3878  if (flags())
3879  oss << " flgs=" << xHEX0N(mFlags,8);
3880  if (clientID())
3881  oss << " " << HEX(clientID());
3882  if (clientPID())
3883  oss << " pid=" << HEX(clientPID());
3884  if (clientTID())
3885  oss << " tid=" << HEX(clientTID());
3886  oss << " res=" << DEC(mResult);
3887  if (interruptIDs())
3888  oss << " ids=" << aja::join(IntNames(interruptIDs()),",");
3889  if (count())
3890  oss << " num=" << DEC(count());
3891  if (mHandles)
3892  oss << " +" << maxHandleCapacity() << " hdls (max)";
3893  }
3894  oss << mTrailer;
3895  return oss;
3896 }
3897 
3899 {
3900  mOperation = op;
3903  return *this;
3904 }
3905 
3906 ostream & operator << (ostream & oss, const NTV2ConfigInterrupt & msg)
3907 {
3908  return msg.print(oss);
3909 }
3910 
3911 
3912 NTV2VirtualData::NTV2VirtualData (const ULWord inTag, const void* inVirtualData, const size_t inVirtualDataSize, const bool inDoWrite)
3913  : mHeader (NTV2_TYPE_VIRTUAL_DATA_RW, sizeof (NTV2VirtualData)),
3914  mTag (inTag), // setup tag
3915  mIsWriting (inDoWrite), // setup write/read
3916  mVirtualData (inVirtualData, inVirtualDataSize) // setup virtual data
3917 {
3919 }
3920 
3921 
3922 ostream & NTV2VirtualData::Print (ostream & inOutStream) const
3923 {
3925  inOutStream << mHeader << ", mTag=" << mTag << ", mIsWriting=" << mIsWriting;
3926  return inOutStream;
3927 }
3928 
3929 NTV2MessageData::NTV2MessageData (const void* inMessage, const size_t inMessageSize, const ULWord inFlags)
3930  : mHeader (NTV2_TYPE_MESSAGE_DATA, sizeof (NTV2MessageData)),
3931  mMessage (inMessage, inMessageSize),
3932  mFlags (inFlags),
3933  mStatus (0)
3934 {
3936 }
3937 
3938 
3939 ostream & NTV2MessageData::Print (ostream & inOutStream) const
3940 {
3942  inOutStream << mHeader;
3943  return inOutStream;
3944 }
3945 
3946 using namespace ntv2nub;
3947 
3948  /*********************************************************************************************************************
3949  RPC ENCODE/DECODE FUNCTIONS
3950  Each class/struct type that can be marshalled to go over-the-wire must have an RPCEncode and RPCDecode member function.
3951  For convenience, these Encode/Decode implementations have been consolidated together in this section.
3952 
3953  RPCEncode FUNCTION -- Calls PUSHU8, PUSHU16, PUSHU32, or PUSHU64 to add 8/16/32/64-bit data members to the RPCBlob.
3954 
3955  bool class::RPCEncode (RPCBlob & outBlob)
3956  Pushes each data member of the class or struct byte-by-byte onto the end of the provided byte sequence.
3957  outBlob A non-const reference to the byte sequence to be appended onto.
3958  Returns true if successful; otherwise false.
3959 
3960  RPCDecode FUNCTION -- Calls POPU8, POPU16, POPU32, or POPU64 to pull 8/16/32/64-bit data members out of the RPCBlob.
3961 
3962  bool class::RPCDecode (const RPCBlob & inBlob, size_t & inOutIndex)
3963  Pops each data member of the class or struct byte-by-byte from the provided byte sequence.
3964  inBlob The source byte sequence.
3965  inOutIndex A non-const reference to the zero-based byte index (offset) into the byte sequence.
3966  At entry: points to the first byte of the next field to be popped from the sequence.
3967  At exit: points to the byte that immediately follows the last field popped from the sequence.
3968  Returns true if successful; otherwise false.
3969  *********************************************************************************************************************/
3970  #define AsU8Ref(_x_) reinterpret_cast<uint8_t&>(_x_)
3971  #define AsU16Ref(_x_) reinterpret_cast<uint16_t&>(_x_)
3972  #define AsU32Ref(_x_) reinterpret_cast<uint32_t&>(_x_)
3973  #define AsU64Ref(_x_) reinterpret_cast<uint64_t&>(_x_)
3974 
3976  {
3977  PUSHU32(fHeaderTag, outBlob); // ULWord fHeaderTag
3978  PUSHU32(fType, outBlob); // ULWord fType
3979  PUSHU32(fHeaderVersion, outBlob); // ULWord fHeaderVersion
3980  PUSHU32(fVersion, outBlob); // ULWord fVersion
3981  PUSHU32(fSizeInBytes, outBlob); // ULWord fSizeInBytes
3982  PUSHU32(fPointerSize, outBlob); // ULWord fPointerSize
3983  PUSHU32(fOperation, outBlob); // ULWord fOperation
3984  PUSHU32(fResultStatus, outBlob); // ULWord fResultStatus
3985  return true;
3986  }
3987 
3988  bool NTV2_HEADER::RPCDecode (const RPCBlob & inBlob, size_t & inOutIndex)
3989  { uint32_t v32(0);
3990  POPU32(fHeaderTag, inBlob, inOutIndex); // ULWord fHeaderTag
3991  POPU32(fType, inBlob, inOutIndex); // ULWord fType
3992  POPU32(fHeaderVersion, inBlob, inOutIndex); // ULWord fHeaderVersion
3993  POPU32(fVersion, inBlob, inOutIndex); // ULWord fVersion
3994  // Do not decode fSizeInBytes, use native size because size can vary based on OS specific struct padding
3995  POPU32(v32, inBlob, inOutIndex); // ULWord fSizeInBytes - dummy read
3996  POPU32(fPointerSize, inBlob, inOutIndex); // ULWord fPointerSize
3997  POPU32(fOperation, inBlob, inOutIndex); // ULWord fOperation
3998  POPU32(fResultStatus, inBlob, inOutIndex); // ULWord fResultStatus
3999  return true;
4000  }
4001 
4003  {
4004  PUSHU32(fTrailerVersion, outBlob); // ULWord fTrailerVersion
4005  PUSHU32(fTrailerTag, outBlob); // ULWord fTrailerTag
4006  return true;
4007  }
4008 
4009  bool NTV2_TRAILER::RPCDecode (const RPCBlob & inBlob, size_t & inOutIndex)
4010  {
4011  POPU32(fTrailerVersion, inBlob, inOutIndex); // ULWord fTrailerVersion
4012  POPU32(fTrailerTag, inBlob, inOutIndex); // ULWord fTrailerTag
4013  return true;
4014  }
4015 
4016 
4017  bool NTV2Buffer::RPCEncode (RPCBlob & outBlob, bool fillBuffer)
4018  {
4019  PUSHU32(fByteCount, outBlob); // ULWord fByteCount
4020  PUSHU32(fFlags, outBlob); // ULWord fFlags
4021  if (!IsNULL() && fillBuffer)
4022  AppendU8s(outBlob); // NOTE: My buffer content should already have been made BigEndian, if necessary
4023  return true;
4024  }
4025 
4026  bool NTV2Buffer::RPCDecode (const RPCBlob & inBlob, size_t & inOutIndex, bool fillBuffer)
4027  {
4028  ULWord byteCount(0), flags(0);
4029  POPU32(byteCount, inBlob, inOutIndex); // ULWord fByteCount
4030  POPU32(flags, inBlob, inOutIndex); // ULWord fFlags
4031  if (!Allocate(byteCount, flags & NTV2Buffer_PAGE_ALIGNED))
4032  return false;
4033  if (fillBuffer)
4034  {
4035  if ((inOutIndex + byteCount) > inBlob.size())
4036  return false; // past end of inBlob
4037  ::memcpy(GetHostPointer(), inBlob.data() + inOutIndex, byteCount); // Caller is responsible for byte-swapping if needed
4038  inOutIndex += byteCount;
4039  }
4040  return true;
4041  }
4042 
4043  // Created for DMATransfer, removed Allocate().
4044  bool NTV2Buffer::RPCDecodeNoAllocate (const RPCBlob & inBlob, size_t & inOutIndex)
4045  {
4046  ULWord byteCount(0), flags(0);
4047  POPU32(byteCount, inBlob, inOutIndex); // ULWord fByteCount
4048  POPU32(flags, inBlob, inOutIndex); // ULWord fFlags
4049  if ((inOutIndex + byteCount) > inBlob.size())
4050  return false; // past end of inBlob
4051 
4052  ::memcpy(GetHostPointer(), inBlob.data() + inOutIndex, byteCount); // Caller is responsible for byte-swapping if needed
4053  inOutIndex += byteCount;
4054  return true;
4055  }
4056 
4058  {
4059  const size_t totBytes (mHeader.GetSizeInBytes() // Header + natural size of all structs/fields inbetween + Trailer
4060  + mInRegisters.GetByteCount() + mOutGoodRegisters.GetByteCount() + mOutValues.GetByteCount()); // NTV2Buffer fields
4061  if (outBlob.capacity() < totBytes)
4062  outBlob.reserve(totBytes);
4063  if (!NTV2HostIsBigEndian)
4064  { // All of my NTV2Buffers store arrays of ULWords that must be BigEndian BEFORE encoding into outBlob...
4065  mInRegisters.ByteSwap32();
4066  }
4067  bool ok = mHeader.RPCEncode(outBlob); // NTV2_HEADER mHeader
4068  PUSHU32(mInNumRegisters, outBlob); // ULWord mInNumRegisters
4069  ok &= mInRegisters.RPCEncode(outBlob, /*fillbuffer=*/true); // NTV2Buffer mInRegisters
4070  PUSHU32(mOutNumRegisters, outBlob); // ULWord mOutNumRegisters
4071  ok &= mOutGoodRegisters.RPCEncode(outBlob, /*fillbuffer=*/false) // NTV2Buffer mOutGoodRegisters
4072  && mOutValues.RPCEncode(outBlob, /*fillbuffer=*/false) // NTV2Buffer mOutValues
4073  && mTrailer.RPCEncode(outBlob); // NTV2_TRAILER mTrailer
4074  if (!NTV2HostIsBigEndian && !ok)
4075  { // FAILED: Un-byteswap NTV2Buffer data...
4076  mInRegisters.ByteSwap32();
4077  }
4078  return ok;
4079  }
4080 
4081  bool NTV2GetRegisters::RPCDecodeServer (const RPCBlob & inBlob, size_t & inOutIndex)
4082  {
4083  bool ok = mHeader.RPCDecode(inBlob, inOutIndex); // NTV2_HEADER mHeader
4084  if (!ok) return false;
4085  POPU32(mInNumRegisters, inBlob, inOutIndex); // ULWord mInNumRegisters
4086  ok &= mInRegisters.RPCDecode(inBlob, inOutIndex, /*fillbuffer=*/true); // NTV2Buffer mInRegisters
4087  POPU32(mOutNumRegisters, inBlob, inOutIndex); // ULWord mOutNumRegisters
4088  ok &= mOutGoodRegisters.RPCDecode(inBlob, inOutIndex, /*fillbuffer=*/false); // NTV2Buffer mOutGoodRegisters
4089  ok &= mOutValues.RPCDecode(inBlob, inOutIndex, /*fillbuffer=*/false); // NTV2Buffer mOutValues
4090  ok &= mTrailer.RPCDecode(inBlob, inOutIndex); // NTV2_TRAILER mTrailer
4091  if (!NTV2HostIsBigEndian)
4092  { // Re-byteswap NTV2Buffer data after decoding...
4093  mInRegisters.ByteSwap32();
4094  }
4095  return ok;
4096  }
4097 
4099  {
4100  const size_t totBytes (mHeader.GetSizeInBytes() // Header + natural size of all structs/fields inbetween + Trailer
4101  + mInRegisters.GetByteCount() + mOutGoodRegisters.GetByteCount() + mOutValues.GetByteCount()); // NTV2Buffer fields
4102  if (outBlob.capacity() < totBytes)
4103  outBlob.reserve(totBytes);
4104  if (!NTV2HostIsBigEndian)
4105  { // All of my NTV2Buffers store arrays of ULWords that must be BigEndian BEFORE encoding into outBlob...
4106  mOutGoodRegisters.ByteSwap32();
4107  mOutValues.ByteSwap32();
4108  }
4109  bool ok = mHeader.RPCEncode(outBlob); // NTV2_HEADER mHeader
4110  PUSHU32(mInNumRegisters, outBlob); // ULWord mInNumRegisters
4111  ok &= mInRegisters.RPCEncode(outBlob, /*fillbuffer=*/false); // NTV2Buffer mInRegisters
4112  PUSHU32(mOutNumRegisters, outBlob); // ULWord mOutNumRegisters
4113  ok &= mOutGoodRegisters.RPCEncode(outBlob, /*fillbuffer=*/true) // NTV2Buffer mOutGoodRegisters
4114  && mOutValues.RPCEncode(outBlob, /*fillbuffer=*/true) // NTV2Buffer mOutValues
4115  && mTrailer.RPCEncode(outBlob); // NTV2_TRAILER mTrailer
4116  if (!NTV2HostIsBigEndian && !ok)
4117  { // FAILED: Un-byteswap NTV2Buffer data...
4118  mOutGoodRegisters.ByteSwap32();
4119  mOutValues.ByteSwap32();
4120  }
4121  return ok;
4122  }
4123 
4124  bool NTV2GetRegisters::RPCDecodeClient (const RPCBlob & inBlob, size_t & inOutIndex)
4125  {
4126  bool ok = mHeader.RPCDecode(inBlob, inOutIndex); // NTV2_HEADER mHeader
4127  if (!ok) return false;
4128  POPU32(mInNumRegisters, inBlob, inOutIndex); // ULWord mInNumRegisters
4129  ok &= mInRegisters.RPCDecode(inBlob, inOutIndex, /*fillbuffer=*/false); // NTV2Buffer mInRegisters
4130  POPU32(mOutNumRegisters, inBlob, inOutIndex); // ULWord mOutNumRegisters
4131  ok &= mOutGoodRegisters.RPCDecode(inBlob, inOutIndex, /*fillbuffer=*/true); // NTV2Buffer mOutGoodRegisters
4132  ok &= mOutValues.RPCDecode(inBlob, inOutIndex, /*fillbuffer=*/true); // NTV2Buffer mOutValues
4133  ok &= mTrailer.RPCDecode(inBlob, inOutIndex); // NTV2_TRAILER mTrailer
4134  if (!NTV2HostIsBigEndian)
4135  { // Re-byteswap NTV2Buffer data after decoding...
4136  mOutGoodRegisters.ByteSwap32();
4137  mOutValues.ByteSwap32();
4138  }
4139  return ok;
4140  }
4141 
4143  {
4144  const size_t totBytes (mHeader.GetSizeInBytes() // Header + natural size of all structs/fields inbetween + Trailer
4145  + mInRegInfos.GetByteCount() + mOutBadRegIndexes.GetByteCount()); // NTV2Buffer fields
4146  if (outBlob.capacity() < totBytes)
4147  outBlob.reserve(totBytes);
4148  if (!NTV2HostIsBigEndian)
4149  { // All of my NTV2Buffers store arrays of ULWords that must be BigEndian BEFORE encoding into outBlob...
4150  mInRegInfos.ByteSwap32();
4151  mOutBadRegIndexes.ByteSwap32();
4152  }
4153  bool ok = mHeader.RPCEncode(outBlob); // NTV2_HEADER mHeader
4154  PUSHU32(mInNumRegisters, outBlob); // ULWord mInNumRegisters
4155  ok &= mInRegInfos.RPCEncode(outBlob); // NTV2Buffer mInRegInfos
4156  PUSHU32(mOutNumFailures, outBlob); // ULWord mOutNumFailures
4157  ok &= mOutBadRegIndexes.RPCEncode(outBlob) // NTV2Buffer mOutBadRegIndexes
4158  && mTrailer.RPCEncode(outBlob); // NTV2_TRAILER mTrailer
4159  if (!NTV2HostIsBigEndian && !ok)
4160  { // FAILED: Un-byteswap NTV2Buffer data...
4161  mInRegInfos.ByteSwap32();
4162  mOutBadRegIndexes.ByteSwap16();
4163  }
4164  return ok;
4165  }
4166 
4167  bool NTV2SetRegisters::RPCDecode (const RPCBlob & inBlob, size_t & inOutIndex)
4168  {
4169  bool ok = mHeader.RPCDecode(inBlob, inOutIndex); // NTV2_HEADER mHeader
4170  POPU32(mInNumRegisters, inBlob, inOutIndex); // ULWord mInNumRegisters
4171  ok &= mInRegInfos.RPCDecode(inBlob, inOutIndex); // NTV2Buffer mInRegInfos
4172  POPU32(mOutNumFailures, inBlob, inOutIndex); // ULWord mOutNumFailures
4173  ok &= mOutBadRegIndexes.RPCDecode(inBlob, inOutIndex); // NTV2Buffer mOutBadRegIndexes
4174  ok &= mTrailer.RPCDecode(inBlob, inOutIndex); // NTV2_TRAILER mTrailer
4175  if (!NTV2HostIsBigEndian)
4176  { // Re-byteswap NTV2Buffer data after decoding...
4177  mInRegInfos.ByteSwap32();
4178  mOutBadRegIndexes.ByteSwap16();
4179  }
4180  return ok;
4181  }
4182 
4184  {
4185  const size_t totBytes (mHeader.GetSizeInBytes() // Header + natural size of all structs/fields inbetween + Trailer
4186  + mInBankInfos.GetByteCount() + mInRegInfos.GetByteCount()); // NTV2Buffer fields
4187  if (outBlob.capacity() < totBytes)
4188  outBlob.reserve(totBytes);
4189  if (!NTV2HostIsBigEndian)
4190  { // All of my NTV2Buffers store arrays of ULWords that must be BigEndian BEFORE encoding into outBlob...
4191  mInBankInfos.ByteSwap32();
4192  mInRegInfos.ByteSwap32();
4193  }
4194  bool ok = mHeader.RPCEncode(outBlob); // NTV2_HEADER mHeader
4195  PUSHU32(mIsWriting, outBlob); // ULWord mIsWriting
4196  ok &= mInBankInfos.RPCEncode(outBlob); // NTV2Buffer mInBankInfos
4197  ok &= mInRegInfos.RPCEncode(outBlob) // NTV2Buffer mInRegInfos
4198  && mTrailer.RPCEncode(outBlob); // NTV2_TRAILER mTrailer
4199  if (!NTV2HostIsBigEndian && !ok)
4200  { // FAILED: Un-byteswap NTV2Buffer data...
4201  mInBankInfos.ByteSwap32();
4202  mInRegInfos.ByteSwap32();
4203  }
4204  return ok;
4205  }
4206 
4207  bool NTV2BankSelGetSetRegs::RPCDecode (const RPCBlob & inBlob, size_t & inOutIndex)
4208  {
4209  bool ok = mHeader.RPCDecode(inBlob, inOutIndex); // NTV2_HEADER mHeader
4210  POPU32(mIsWriting, inBlob, inOutIndex); // ULWord mIsWriting
4211  ok &= mInBankInfos.RPCDecode(inBlob, inOutIndex); // NTV2Buffer mInBankInfos
4212  ok &= mInRegInfos.RPCDecode(inBlob, inOutIndex); // NTV2Buffer mInRegInfos
4213  ok &= mTrailer.RPCDecode(inBlob, inOutIndex); // NTV2_TRAILER mTrailer
4214  if (!NTV2HostIsBigEndian)
4215  { // Re-byteswap NTV2Buffer data after decoding...
4216  mInBankInfos.ByteSwap32();
4217  mInRegInfos.ByteSwap32();
4218  }
4219  return ok;
4220  }
4221 
4223  {
4224  const size_t totBytes (mHeader.GetSizeInBytes() // Header + natural size of all structs/fields inbetween + Trailer
4225  + mHandles.GetByteCount()); // NTV2Buffer field
4226  if (outBlob.capacity() < totBytes)
4227  outBlob.reserve(totBytes);
4228  bool ok = true;
4229  if (!NTV2HostIsBigEndian && mHandles)
4230  ok &= mHandles.ByteSwap64(); // mHandles is array of ULWord64s that must be BigEndian BEFORE encoding into outBlob
4231  ok &= mHeader.RPCEncode(outBlob); // NTV2_HEADER mHeader
4232  PUSHU32(mOperation, outBlob); // ULWord mOperation
4233  PUSHU32(mFlags, outBlob); // ULWord mFlags
4234  PUSHU32(mInterruptID, outBlob); // ULWord mInterruptID
4235  PUSHU32(mResult, outBlob); // ULWord mResult
4236  PUSHU64(mInterruptIDs, outBlob); // ULWord64 mInterruptIDs
4237  PUSHU64(mEventHandle, outBlob); // ULWord64 mEventHandle
4238  PUSHU64(mClientID, outBlob); // ULWord64 mClientID
4239  PUSHU64(mClientPID, outBlob); // ULWord64 mClientPID
4240  PUSHU64(mClientTID, outBlob); // ULWord64 mClientTID
4241  PUSHU32(mCount, outBlob); // ULWord mCount
4242  ok &= mHandles.RPCEncode(outBlob); // NTV2Buffer mHandles
4243  ok &= mTrailer.RPCEncode(outBlob); // NTV2_TRAILER mTrailer
4244  if (!NTV2HostIsBigEndian && !ok && mHandles)
4245  ok &= mHandles.ByteSwap64(); // FAILED: Un-byteswap NTV2Buffer data
4246  return ok;
4247  }
4248 
4249  bool NTV2ConfigInterrupt::RPCDecode (const RPCBlob & inBlob, size_t & inOutIndex)
4250  {
4251  bool ok = mHeader.RPCDecode(inBlob, inOutIndex); // NTV2_HEADER mHeader
4252  ok &= POPU32(mOperation, inBlob, inOutIndex); // ULWord mOperation
4253  ok &= POPU32(mFlags, inBlob, inOutIndex); // ULWord mFlags
4254  ok &= POPU32(mInterruptID, inBlob, inOutIndex); // ULWord mInterruptID
4255  ok &= POPU32(mResult, inBlob, inOutIndex); // ULWord mResult
4256  ok &= POPU64(mInterruptIDs, inBlob, inOutIndex); // ULWord64 mInterruptIDs
4257  ok &= POPU64(mEventHandle, inBlob, inOutIndex); // ULWord64 mEventHandle
4258  ok &= POPU64(mClientID, inBlob, inOutIndex); // ULWord64 mClientID
4259  ok &= POPU64(mClientPID, inBlob, inOutIndex); // ULWord64 mClientPID
4260  ok &= POPU64(mClientTID, inBlob, inOutIndex); // ULWord64 mClientTID
4261  ok &= POPU32(mCount, inBlob, inOutIndex); // ULWord mCount
4262  ok &= mHandles.RPCDecode(inBlob, inOutIndex); // NTV2Buffer mHandles
4263  ok &= mTrailer.RPCDecode(inBlob, inOutIndex); // NTV2_TRAILER mTrailer
4264  if (!NTV2HostIsBigEndian)
4265  mHandles.ByteSwap64(); // Re-byteswap NTV2Buffer data after decoding
4266  return ok;
4267  }
4268 
4270  {
4271  const size_t totBytes (acHeader.GetSizeInBytes()); // Header + natural size of all structs/fields inbetween + Trailer
4272  if (outBlob.capacity() < totBytes)
4273  outBlob.reserve(totBytes);
4274  bool ok = acHeader.RPCEncode(outBlob); // NTV2_HEADER acHeader
4275  PUSHU16(UWord(acCrosspoint), outBlob); // NTV2Crosspoint acCrosspoint
4276  PUSHU16(UWord(acState), outBlob); // NTV2AutoCirculateState acState
4277  PUSHU32(ULWord(acStartFrame), outBlob); // LWord acStartFrame
4278  PUSHU32(ULWord(acEndFrame), outBlob); // LWord acEndFrame
4279  PUSHU32(ULWord(acActiveFrame), outBlob); // LWord acActiveFrame
4280  PUSHU64(acRDTSCStartTime, outBlob); // ULWord64 acRDTSCStartTime
4281  PUSHU64(acAudioClockStartTime, outBlob); // ULWord64 acAudioClockStartTime
4282  PUSHU64(acRDTSCCurrentTime, outBlob); // ULWord64 acRDTSCCurrentTime
4283  PUSHU64(acAudioClockCurrentTime, outBlob); // ULWord64 acAudioClockCurrentTime
4284  PUSHU32(acFramesProcessed, outBlob); // ULWord acFramesProcessed
4285  PUSHU32(acFramesDropped, outBlob); // ULWord acFramesDeopped
4286  PUSHU32(acBufferLevel, outBlob); // ULWord acBufferLevel
4287  PUSHU32(acOptionFlags, outBlob); // ULWord acOptionFlags
4288  PUSHU16(UWord(acAudioSystem), outBlob); // NTV2AudioSystem acAudioSystem
4289  ok &= acTrailer.RPCEncode(outBlob); // NTV2_TRAILER acTrailer
4290  return ok;
4291  }
4292 
4293  bool AUTOCIRCULATE_STATUS::RPCDecode (const RPCBlob & inBlob, size_t & inOutIndex)
4294  { uint16_t v16(0); uint32_t v32(0);
4295  bool ok = acHeader.RPCDecode(inBlob, inOutIndex); // NTV2_HEADER acHeader
4296  POPU16(v16, inBlob, inOutIndex); // NTV2Crosspoint acCrosspoint
4297  acCrosspoint = NTV2Crosspoint(v16);
4298  POPU16(v16, inBlob, inOutIndex); // NTV2AutoCirculateState acState
4299  acState = NTV2AutoCirculateState(v16);
4300  POPU32(v32, inBlob, inOutIndex); // LWord acStartFrame
4301  acStartFrame = LWord(v32);
4302  POPU32(v32, inBlob, inOutIndex); // LWord acEndFrame
4303  acEndFrame = LWord(v32);
4304  POPU32(v32, inBlob, inOutIndex); // LWord acActiveFrame
4305  acActiveFrame = LWord(v32);
4306  POPU64(acRDTSCStartTime, inBlob, inOutIndex); // ULWord64 acRDTSCStartTime
4307  POPU64(acAudioClockStartTime, inBlob, inOutIndex); // ULWord64 acAudioClockStartTime
4308  POPU64(acRDTSCCurrentTime, inBlob, inOutIndex); // ULWord64 acRDTSCCurrentTime
4309  POPU64(acAudioClockCurrentTime, inBlob, inOutIndex); // ULWord64 acAudioClockCurrentTime
4310  POPU32(acFramesProcessed, inBlob, inOutIndex); // ULWord acFramesProcessed
4311  POPU32(acFramesDropped, inBlob, inOutIndex); // ULWord acFramesDropped
4312  POPU32(acBufferLevel, inBlob, inOutIndex); // ULWord acBufferLevel
4313  POPU32(acOptionFlags, inBlob, inOutIndex); // ULWord acOptionFlags
4314  POPU16(v16, inBlob, inOutIndex); // NTV2AudioSystem acAudioSystem
4315  acAudioSystem = NTV2AudioSystem(v16);
4316  ok &= acTrailer.RPCDecode(inBlob, inOutIndex); // NTV2_TRAILER acTrailer
4317  return ok;
4318  }
4319 
4321  {
4322  const size_t totBytes (acHeader.GetSizeInBytes()); // Header + natural size of all structs/fields inbetween + Trailer
4323  if (outBlob.capacity() < totBytes)
4324  outBlob.reserve(totBytes);
4325  bool ok = acHeader.RPCEncode(outBlob); // NTV2_HEADER acHeader
4326  PUSHU64(ULWord64(acFrameTime), outBlob); // LWord64 acFrameTime
4327  PUSHU32(acRequestedFrame, outBlob); // ULWord acRequestedFrame
4328  PUSHU64(acAudioClockTimeStamp, outBlob); // ULWord64 acAudioClockTimeStamp
4329  PUSHU32(acAudioExpectedAddress, outBlob); // ULWord acAudioExpectedAddress
4330  PUSHU32(acAudioInStartAddress, outBlob); // ULWord acAudioInStartAddress
4331  PUSHU32(acAudioInStopAddress, outBlob); // ULWord acAudioInStopAddress
4332  PUSHU32(acAudioOutStopAddress, outBlob); // ULWord acAudioOutStopAddress
4333  PUSHU32(acAudioOutStartAddress, outBlob); // ULWord acAudioOutStartAddress
4334  PUSHU32(acTotalBytesTransferred, outBlob); // ULWord acTotalBytesTransferred
4335  PUSHU32(acStartSample, outBlob); // ULWord acStartSample
4336 
4337  ok &= acTimeCodes.RPCEncode(outBlob); // NTV2Buffer acTimeCodes
4338  PUSHU64(ULWord64(acCurrentTime), outBlob); // LWord64 acCurrentTime
4339  PUSHU32(acCurrentFrame, outBlob); // ULWord acCurrentFrame
4340  PUSHU64(ULWord64(acCurrentFrameTime), outBlob); // LWord64 acCurrentFrameTime
4341  PUSHU64(acAudioClockCurrentTime, outBlob); // ULWord64 acAudioClockCurrentTime
4342  PUSHU32(acCurrentAudioExpectedAddress, outBlob); // ULWord acCurrentAudioExpectedAddress
4343  PUSHU32(acCurrentAudioStartAddress, outBlob); // ULWord acCurrentAudioStartAddress
4344  PUSHU32(acCurrentFieldCount, outBlob); // ULWord acCurrentFieldCount
4345  PUSHU32(acCurrentLineCount, outBlob); // ULWord acCurrentLineCount
4346  PUSHU32(acCurrentReps, outBlob); // ULWord acCurrentReps
4347  PUSHU64(acCurrentUserCookie, outBlob); // ULWord64 acCurrentUserCookie
4348  PUSHU32(acFrame, outBlob); // ULWord acFrame
4349  PUSHU32(acRP188.fDBB, outBlob); // ULWord acRP188.fDBB
4350  PUSHU32(acRP188.fLo, outBlob); // ULWord acRP188.fLo
4351  PUSHU32(acRP188.fHi, outBlob); // ULWord acRP188.fHi
4352  ok &= acTrailer.RPCEncode(outBlob); // NTV2_TRAILER acTrailer
4353  return ok;
4354  }
4355 
4356  bool FRAME_STAMP::RPCDecode (const RPCBlob & inBlob, size_t & inOutIndex)
4357  { uint64_t v64(0);
4358  bool ok = acHeader.RPCDecode(inBlob, inOutIndex); // NTV2_HEADER acHeader
4359  POPU64(v64, inBlob, inOutIndex); // LWord64 acFrameTime
4360  acFrameTime = LWord64(v64);
4361  POPU32(acRequestedFrame, inBlob, inOutIndex); // ULWord acRequestedFrame
4362  POPU64(acAudioClockTimeStamp, inBlob, inOutIndex); // ULWord64 acAudioClockTimeStamp
4363  POPU32(acAudioExpectedAddress, inBlob, inOutIndex); // ULWord acAudioExpectedAddress
4364  POPU32(acAudioInStartAddress, inBlob, inOutIndex); // ULWord acAudioInStartAddress
4365  POPU32(acAudioInStopAddress, inBlob, inOutIndex); // ULWord acAudioInStopAddress
4366  POPU32(acAudioOutStopAddress, inBlob, inOutIndex); // ULWord acAudioOutStopAddress
4367  POPU32(acAudioOutStartAddress, inBlob, inOutIndex); // ULWord acAudioOutStartAddress
4368  POPU32(acTotalBytesTransferred, inBlob, inOutIndex); // ULWord acTotalBytesTransferred
4369  POPU32(acStartSample, inBlob, inOutIndex); // ULWord acStartSample
4370 
4371  ok &= acTimeCodes.RPCDecode(inBlob, inOutIndex); // NTV2Buffer acTimeCodes
4372  POPU64(v64, inBlob, inOutIndex); // LWord64 acCurrentTime
4373  acCurrentTime = LWord64(v64);
4374  POPU32(acCurrentFrame, inBlob, inOutIndex); // ULWord acCurrentFrame
4375  POPU64(v64, inBlob, inOutIndex); // LWord64 acCurrentFrameTime
4376  acCurrentFrameTime = LWord64(v64);
4377  POPU64(acAudioClockCurrentTime, inBlob, inOutIndex); // ULWord64 acAudioClockCurrentTime
4378  POPU32(acCurrentAudioExpectedAddress, inBlob, inOutIndex); // ULWord acCurrentAudioExpectedAddress
4379  POPU32(acCurrentAudioStartAddress, inBlob, inOutIndex); // ULWord acCurrentAudioStartAddress
4380  POPU32(acCurrentFieldCount, inBlob, inOutIndex); // ULWord acCurrentFieldCount
4381  POPU32(acCurrentLineCount, inBlob, inOutIndex); // ULWord acCurrentLineCount
4382  POPU32(acCurrentReps, inBlob, inOutIndex); // ULWord acCurrentReps
4383  POPU64(acCurrentUserCookie, inBlob, inOutIndex); // ULWord64 acCurrentUserCookie
4384  POPU32(acFrame, inBlob, inOutIndex); // ULWord acFrame
4385  POPU32(acRP188.fDBB, inBlob, inOutIndex); // ULWord acRP188.fDBB
4386  POPU32(acRP188.fLo, inBlob, inOutIndex); // ULWord acRP188.fLo
4387  POPU32(acRP188.fHi, inBlob, inOutIndex); // ULWord acRP188.fHi
4388  ok &= acTrailer.RPCDecode(inBlob, inOutIndex); // NTV2_TRAILER acTrailer
4389  return ok;
4390  }
4391 
4393  {
4394  const size_t totBytes (acHeader.GetSizeInBytes()); // Header + natural size of all structs/fields inbetween + Trailer
4395  if (outBlob.capacity() < totBytes)
4396  outBlob.reserve(totBytes);
4397  bool ok = acHeader.RPCEncode(outBlob); // NTV2_HEADER acHeader
4398  PUSHU16(acState, outBlob); // UWord acState
4399  PUSHU32(ULWord(acTransferFrame), outBlob); // LWord acTransferFrame
4400  PUSHU32(acBufferLevel, outBlob); // ULWord acBufferLevel
4401  PUSHU32(acFramesProcessed, outBlob); // ULWord acFramesProcessed
4402  PUSHU32(acFramesDropped, outBlob); // ULWord acFramesDropped
4403  ok &= acFrameStamp.RPCEncode(outBlob); // FRAME_STAMP acFrameStamp
4404  PUSHU32(acAudioTransferSize, outBlob); // ULWord acAudioTransferSize
4405  PUSHU32(acAudioStartSample, outBlob); // ULWord acAudioStartSample
4406  PUSHU32(acAncTransferSize, outBlob); // ULWord acAncTransferSize
4407  PUSHU32(acAncField2TransferSize, outBlob); // ULWord acAncField2TransferSize
4408  ok &= acTrailer.RPCEncode(outBlob); // NTV2_TRAILER acTrailer
4409  return ok;
4410  }
4411 
4412  bool AUTOCIRCULATE_TRANSFER_STATUS::RPCDecode (const RPCBlob & inBlob, size_t & inOutIndex)
4413  { uint16_t v16(0); uint32_t v32(0);
4414  bool ok = acHeader.RPCDecode(inBlob, inOutIndex); // NTV2_HEADER acHeader
4415  POPU16(v16, inBlob, inOutIndex); // NTV2AutoCirculateState acState
4416  acState = NTV2AutoCirculateState(v16);
4417  POPU32(v32, inBlob, inOutIndex); // LWord acTransferFrame
4418  acTransferFrame = LWord(v32);
4419  POPU32(acBufferLevel, inBlob, inOutIndex); // ULWord acBufferLevel
4420  POPU32(acFramesProcessed, inBlob, inOutIndex); // ULWord acFramesProcessed
4421  POPU32(acFramesDropped, inBlob, inOutIndex); // ULWord acFramesDropped
4422  ok &= acFrameStamp.RPCDecode(inBlob, inOutIndex); // FRAME_STAMP acFrameStamp
4423  POPU32(acAudioTransferSize, inBlob, inOutIndex); // ULWord acAudioTransferSize
4424  POPU32(acAudioStartSample, inBlob, inOutIndex); // ULWord acAudioStartSample
4425  POPU32(acAncTransferSize, inBlob, inOutIndex); // ULWord acAncTransferSize
4426  POPU32(acAncField2TransferSize, inBlob, inOutIndex); // ULWord acAncField2TransferSize
4427  ok &= acTrailer.RPCDecode(inBlob, inOutIndex); // NTV2_TRAILER acTrailer
4428  return ok;
4429  }
4430 
4432  {
4433  PUSHU32(acNumSegments, outBlob); // ULWord acNumSegments
4434  PUSHU32(acNumActiveBytesPerRow, outBlob); // ULWord acNumActiveBytesPerRow
4435  PUSHU32(acSegmentHostPitch, outBlob); // ULWord acSegmentHostPitch
4436  PUSHU32(acSegmentDevicePitch, outBlob); // ULWord acSegmentDevicePitch
4437  return true;
4438  }
4439 
4440  bool NTV2SegmentedDMAInfo::RPCDecode (const RPCBlob & inBlob, size_t & inOutIndex)
4441  {
4442  POPU32(acNumSegments, inBlob, inOutIndex); // ULWord acNumSegments
4443  POPU32(acNumActiveBytesPerRow, inBlob, inOutIndex); // ULWord acNumActiveBytesPerRow
4444  POPU32(acSegmentHostPitch, inBlob, inOutIndex); // ULWord acSegmentHostPitch
4445  POPU32(acSegmentDevicePitch, inBlob, inOutIndex); // ULWord acSegmentDevicePitch
4446  return true;
4447  }
4448 
4450  {
4451  PUSHU16(ccMode, outBlob); // NTV2ColorCorrectionMode ccMode
4452  PUSHU32(ccSaturationValue, outBlob); // ULWord ccSaturationValue
4453  return ccLookupTables.RPCEncode(outBlob); // NTV2Buffer ccLookupTables
4454  }
4455 
4456  bool NTV2ColorCorrectionData::RPCDecode (const RPCBlob & inBlob, size_t & inOutIndex)
4457  { uint16_t u16(0);
4458  POPU16(u16, inBlob, inOutIndex); // NTV2ColorCorrectionMode ccMode
4459  ccMode = NTV2ColorCorrectionMode(u16);
4460  POPU32(ccSaturationValue, inBlob, inOutIndex); // ULWord ccSaturationValue
4461  return ccLookupTables.RPCDecode(inBlob, inOutIndex); // NTV2Buffer ccLookupTables
4462  }
4463 
4465  {
4466  PUSHU16(mode, outBlob); // AutoCircVidProcMode mode
4467  PUSHU16(foregroundVideoCrosspoint, outBlob); // NTV2Crosspoint foregroundVideoCrosspoint
4468  PUSHU16(backgroundVideoCrosspoint, outBlob); // NTV2Crosspoint backgroundVideoCrosspoint
4469  PUSHU16(foregroundKeyCrosspoint, outBlob); // NTV2Crosspoint foregroundKeyCrosspoint
4470  PUSHU16(backgroundKeyCrosspoint, outBlob); // NTV2Crosspoint backgroundKeyCrosspoint
4471  PUSHU32(ULWord(transitionCoefficient), outBlob); // Fixed_ transitionCoefficient
4472  PUSHU32(ULWord(transitionSoftness), outBlob); // Fixed_ transitionSoftness
4473  return true;
4474  }
4475 
4476  bool AutoCircVidProcInfo::RPCDecode (const RPCBlob & inBlob, size_t & inOutIndex)
4477  { uint16_t v16(0); uint32_t v32(0);
4478  POPU16(v16, inBlob, inOutIndex); // AutoCircVidProcMode mode
4479  mode = AutoCircVidProcMode(v16);
4480  POPU16(v16, inBlob, inOutIndex); // NTV2Crosspoint foregroundVideoCrosspoint
4481  foregroundVideoCrosspoint = NTV2Crosspoint(v16);
4482  POPU16(v16, inBlob, inOutIndex); // NTV2Crosspoint backgroundVideoCrosspoint
4483  backgroundVideoCrosspoint = NTV2Crosspoint(v16);
4484  POPU16(v16, inBlob, inOutIndex); // NTV2Crosspoint foregroundKeyCrosspoint
4485  foregroundKeyCrosspoint = NTV2Crosspoint(v16);
4486  POPU16(v16, inBlob, inOutIndex); // NTV2Crosspoint backgroundKeyCrosspoint
4487  backgroundKeyCrosspoint = NTV2Crosspoint(v16);
4488  POPU32(v32, inBlob, inOutIndex); // Fixed_ transitionCoefficient
4489  transitionCoefficient = Fixed_(v32);
4490  POPU32(v32, inBlob, inOutIndex); // Fixed_ transitionSoftness
4491  transitionSoftness = Fixed_(v32);
4492  return true;
4493  }
4494 
4496  {
4497  PUSHU32(fDBB, outBlob); // ULWord fDBB
4498  PUSHU32(fLo, outBlob); // ULWord fLo
4499  PUSHU32(fHi, outBlob); // ULWord fHi
4500  return true;
4501  }
4502 
4503  bool NTV2_RP188::RPCDecode (const RPCBlob & inBlob, size_t & inOutIndex)
4504  {
4505  POPU32(fDBB, inBlob, inOutIndex); // ULWord fDBB
4506  POPU32(fLo, inBlob, inOutIndex); // ULWord fLo
4507  POPU32(fHi, inBlob, inOutIndex); // ULWord fHi
4508  return true;
4509  }
4510 
4512  {
4514  const size_t totBytes (acHeader.GetSizeInBytes() + acVideoBuffer.GetByteCount() + acAudioBuffer.GetByteCount()
4515  + acANCBuffer.GetByteCount() + acANCField2Buffer.GetByteCount() + acOutputTimeCodes.GetByteCount()
4516  + acHDMIAuxData.GetByteCount() + 64); // Header + natural size of all structs/fields inbetween + Trailer
4517  if (outBlob.capacity() < totBytes)
4518  outBlob.reserve(totBytes);
4519  bool ok = acHeader.RPCEncode(outBlob); // NTV2_HEADER acHeader
4520  ok &= acVideoBuffer.RPCEncode(outBlob); // NTV2Buffer acVideoBuffer
4521  ok &= acAudioBuffer.RPCEncode(outBlob); // NTV2Buffer acAudioBuffer
4522  ok &= acANCBuffer.RPCEncode(outBlob); // NTV2Buffer acANCBuffer
4523  ok &= acANCField2Buffer.RPCEncode(outBlob); // NTV2Buffer acANCField2Buffer
4524  ok &= acOutputTimeCodes.RPCEncode(outBlob); // NTV2Buffer acOutputTimeCodes
4525  ok &= acTransferStatus.RPCEncode(outBlob); // AUTOCIRCULATE_TRANSFER_STATUS acTransferStatus
4526  PUSHU64(acInUserCookie, outBlob); // ULWord64 acInUserCookie
4527  PUSHU32(acInVideoDMAOffset, outBlob); // ULWord acInVideoDMAOffset
4528  ok &= acInSegmentedDMAInfo.RPCEncode(outBlob); // NTV2SegmentedDMAInfo acInSegmentedDMAInfo
4529  ok &= acColorCorrection.RPCEncode(outBlob); // NTV2ColorCorrectionData acColorCorrection
4530  PUSHU16(acFrameBufferFormat, outBlob); // NTV2PixelFormat acFrameBufferFormat
4531  PUSHU16(acFrameBufferOrientation, outBlob); // NTV2FBOrientation acFrameBufferOrientation
4532  ok &= acVidProcInfo.RPCEncode(outBlob); // AutoCircVidProcInfo acVidProcInfo
4533  PUSHU16(acVideoQuarterSizeExpand, outBlob); // NTV2QtrSizeExpandMode acVideoQuarterSizeExpand
4534  ok &= acHDMIAuxData.RPCEncode(outBlob); // NTV2Buffer acHDMIAuxData
4535  PUSHU32(acPeerToPeerFlags, outBlob); // ULWord acPeerToPeerFlags
4536  PUSHU32(acFrameRepeatCount, outBlob); // ULWord acFrameRepeatCount
4537  PUSHU32(ULWord(acDesiredFrame), outBlob); // LWord acDesiredFrame
4538  ok &= acRP188.RPCEncode(outBlob); // NTV2_RP188 acRP188
4539  PUSHU16(acCrosspoint, outBlob); // NTV2Crosspoint acCrosspoint
4540  ok &= acTrailer.RPCEncode(outBlob); // NTV2_TRAILER acTrailer
4542  return ok;
4543  }
4544 
4545  bool AUTOCIRCULATE_TRANSFER::RPCDecode (const RPCBlob & inBlob, size_t & inOutIndex)
4546  { uint16_t v16(0); uint32_t v32(0);
4548  bool ok = acHeader.RPCDecode(inBlob, inOutIndex); // NTV2_HEADER acHeader
4549  ok &= acVideoBuffer.RPCDecode(inBlob, inOutIndex); // NTV2Buffer acVideoBuffer
4550  ok &= acAudioBuffer.RPCDecode(inBlob, inOutIndex); // NTV2Buffer acAudioBuffer
4551  ok &= acANCBuffer.RPCDecode(inBlob, inOutIndex); // NTV2Buffer acANCBuffer
4552  ok &= acANCField2Buffer.RPCDecode(inBlob, inOutIndex); // NTV2Buffer acANCField2Buffer
4553  ok &= acOutputTimeCodes.RPCDecode(inBlob, inOutIndex); // NTV2Buffer acOutputTimeCodes
4554  ok &= acTransferStatus.RPCDecode(inBlob, inOutIndex); // AUTOCIRCULATE_TRANSFER_STATUS acTransferStatus
4555  POPU64(acInUserCookie, inBlob, inOutIndex); // ULWord64 acInUserCookie
4556  POPU32(acInVideoDMAOffset, inBlob, inOutIndex); // ULWord acInVideoDMAOffset
4557  ok &= acInSegmentedDMAInfo.RPCDecode(inBlob, inOutIndex);// NTV2Buffer acInSegmentedDMAInfo
4558  ok &= acColorCorrection.RPCDecode(inBlob, inOutIndex); // NTV2Buffer acColorCorrection
4559  POPU16(v16, inBlob, inOutIndex); // NTV2PixelFormat acFrameBufferFormat
4560  acFrameBufferFormat = NTV2FrameBufferFormat(v16);
4561  POPU16(v16, inBlob, inOutIndex); // NTV2FBOrientation acFrameBufferOrientation
4562  acFrameBufferOrientation = NTV2FBOrientation(v16);
4563  ok &= acVidProcInfo.RPCDecode(inBlob, inOutIndex); // AutoCircVidProcInfo acVidProcInfo
4564  POPU16(v16, inBlob, inOutIndex); // NTV2QtrSizeExpandMode acVideoQuarterSizeExpand
4565  acVideoQuarterSizeExpand = NTV2QtrSizeExpandMode(v16);
4566  ok &= acHDMIAuxData.RPCDecode(inBlob, inOutIndex); // NTV2Buffer acHDMIAuxData
4567  POPU32(acPeerToPeerFlags, inBlob, inOutIndex); // ULWord acPeerToPeerFlags
4568  POPU32(acFrameRepeatCount, inBlob, inOutIndex); // ULWord acFrameRepeatCount
4569  POPU32(v32, inBlob, inOutIndex); // LWord acDesiredFrame
4570  acDesiredFrame = LWord(v32);
4571  ok &= acRP188.RPCDecode(inBlob, inOutIndex); // NTV2_RP188 acRP188
4572  POPU16(v16, inBlob, inOutIndex); // NTV2Crosspoint acCrosspoint
4573  acCrosspoint = NTV2Crosspoint(v16);
4574  ok &= acTrailer.RPCDecode(inBlob, inOutIndex); // NTV2_TRAILER acTrailer
4576  return ok;
4577  }
4578 
4580  {
4581  NTV2Buffer buff;
4582  PUSHU16(UWord(channelSpec), outBlob); // NTV2Crosspoint channelSpec
4583 // PUSHU64(ULWord64(videoBuffer), outBlob) // ULWord * videoBuffer
4584  PUSHU32(videoBufferSize, outBlob); // ULWord videoBufferSize
4585  if (videoBuffer && videoBufferSize)
4586  { buff.Set(videoBuffer, videoBufferSize);
4587  buff.AppendU8s(outBlob);
4588  }
4589  PUSHU32(videoDmaOffset, outBlob); // ULWord videoDmaOffset
4590 // PUSHU64(ULWord64(audioBuffer), outBlob) // ULWord * audioBuffer
4591  PUSHU32(audioBufferSize, outBlob); // ULWord audioBufferSize
4592  if (audioBuffer && audioBufferSize)
4593  { buff.Set(audioBuffer, audioBufferSize);
4594  buff.AppendU8s(outBlob);
4595  }
4596  PUSHU32(audioStartSample, outBlob); // ULWord audioStartSample
4597  PUSHU32(audioNumChannels, outBlob); // ULWord audioNumChannels
4598  PUSHU32(frameRepeatCount, outBlob); // ULWord frameRepeatCount
4599  rp188.RPCEncode(outBlob); // RP188_STRUCT rp188
4600  PUSHU32(ULWord(desiredFrame), outBlob); // LWord desiredFrame
4601  PUSHU32(hUser, outBlob); // ULWord hUser
4602  PUSHU32(transferFlags, outBlob); // ULWord transferFlags
4603  PUSHU8(bDisableExtraAudioInfo, outBlob); // BOOL_ bDisableExtraAudioInfo
4604  PUSHU16(UWord(frameBufferFormat), outBlob); // NTV2PixelFormat frameBufferFormat
4605  PUSHU16(UWord(frameBufferOrientation), outBlob); // NTV2FBOrientation frameBufferOrientation
4606  // Skip color correction for now // NTV2ColorCorrectionInfo colorCorrectionInfo
4607  vidProcInfo.RPCEncode(outBlob); // AutoCircVidProcInfo vidProcInfo
4608  PUSHU32(customAncInfo.Group1, outBlob); // CUSTOM_ANC_STRUCT customAncInfo
4609  PUSHU32(customAncInfo.Group2, outBlob);
4610  PUSHU32(customAncInfo.Group3, outBlob);
4611  PUSHU32(customAncInfo.Group4, outBlob);
4612  PUSHU32(videoNumSegments, outBlob); // ULWord videoNumSegments
4613  PUSHU32(videoSegmentHostPitch, outBlob); // ULWord videoSegmentHostPitch
4614  PUSHU32(videoSegmentCardPitch, outBlob); // ULWord videoSegmentCardPitch
4615  PUSHU16(UWord(videoQuarterSizeExpand), outBlob); // NTV2QtrSizeExpandMode videoQuarterSizeExpand
4616  return true;
4617  }
4618 
4619  bool AUTOCIRCULATE_TRANSFER_STRUCT::RPCDecode (const RPCBlob & inBlob, size_t & inOutIndex)
4620  { UWord v16(0); ULWord v32(0);
4621  POPU16(v16, inBlob, inOutIndex); // NTV2Crosspoint channelSpec
4622  channelSpec = NTV2Crosspoint(v16);
4623 // POPU64(u64, inBlob, inOutIndex); // ULWord * videoBuffer
4624 // videoBuffer = reinterpret_cast<ULWord*>(u64);
4625  POPU32(videoBufferSize, inBlob, inOutIndex); // ULWord videoBufferSize
4626  if (videoBufferSize && !videoBuffer)
4627  {
4628  videoBuffer = reinterpret_cast<ULWord*>(AJAMemory::AllocateAligned(videoBufferSize, NTV2Buffer::DefaultPageSize()));
4629  if (!videoBuffer)
4630  return false;
4631  if ((inOutIndex + videoBufferSize) >= inBlob.size())
4632  return false; // past end of inBlob
4633  UByte* pBuffer = reinterpret_cast<UByte*>(videoBuffer);
4634  for (ULWord cnt(0); cnt < videoBufferSize; cnt++)
4635  pBuffer[cnt] = inBlob.at(inOutIndex++); // Caller is responsible for byte-swapping if needed
4636  }
4637  POPU32(videoDmaOffset, inBlob, inOutIndex); // ULWord videoDmaOffset
4638 // POPU64(u64, inBlob, inOutIndex); // ULWord * audioBuffer
4639 // audioBuffer = reinterpret_cast<ULWord*>(u64);
4640  POPU32(audioBufferSize, inBlob, inOutIndex); // ULWord audioBufferSize
4641  if (audioBufferSize && !audioBuffer)
4642  {
4643  audioBuffer = reinterpret_cast<ULWord*>(AJAMemory::AllocateAligned(audioBufferSize, NTV2Buffer::DefaultPageSize()));
4644  if (!audioBuffer)
4645  return false;
4646  if ((inOutIndex + audioBufferSize) >= inBlob.size())
4647  return false; // past end of inBlob
4648  UByte* pBuffer = reinterpret_cast<UByte*>(audioBuffer);
4649  for (ULWord cnt(0); cnt < audioBufferSize; cnt++)
4650  pBuffer[cnt] = inBlob.at(inOutIndex++); // Caller is responsible for byte-swapping if needed
4651  }
4652  POPU32(audioStartSample, inBlob, inOutIndex); // ULWord audioStartSample
4653  POPU32(audioNumChannels, inBlob, inOutIndex); // ULWord audioNumChannels
4654  POPU32(frameRepeatCount, inBlob, inOutIndex); // ULWord frameRepeatCount
4655  rp188.RPCDecode(inBlob, inOutIndex); // RP188_STRUCT rp188
4656  POPU32(v32, inBlob, inOutIndex); // LWord desiredFrame
4657  desiredFrame = LWord(v32);
4658  POPU32(hUser, inBlob, inOutIndex); // ULWord hUser
4659  POPU32(transferFlags, inBlob, inOutIndex); // ULWord transferFlags
4660  POPU8(AsU8Ref(bDisableExtraAudioInfo), inBlob, inOutIndex); // BOOL_ bDisableExtraAudioInfo
4661  POPU16(v16, inBlob, inOutIndex); // NTV2PixelFormat frameBufferFormat
4662  frameBufferFormat = NTV2PixelFormat(v16);
4663  POPU16(v16, inBlob, inOutIndex); // NTV2FBOrientation frameBufferOrientation
4664  frameBufferOrientation = NTV2FBOrientation(v16);
4665  // Skip color correction for now // NTV2ColorCorrectionInfo colorCorrectionInfo
4666  vidProcInfo.RPCDecode(inBlob, inOutIndex); // AutoCircVidProcInfo vidProcInfo
4667  POPU32(customAncInfo.Group1, inBlob, inOutIndex); // CUSTOM_ANC_STRUCT customAncInfo
4668  POPU32(customAncInfo.Group2, inBlob, inOutIndex);
4669  POPU32(customAncInfo.Group3, inBlob, inOutIndex);
4670  POPU32(customAncInfo.Group4, inBlob, inOutIndex);
4671  POPU32(videoNumSegments, inBlob, inOutIndex); // ULWord videoNumSegments
4672  POPU32(videoSegmentHostPitch, inBlob, inOutIndex); // ULWord videoSegmentHostPitch
4673  POPU32(videoSegmentCardPitch, inBlob, inOutIndex); // ULWord videoSegmentCardPitch
4674  POPU16(v16, inBlob, inOutIndex); // NTV2QtrSizeExpandMode videoQuarterSizeExpand
4675  videoQuarterSizeExpand = NTV2QtrSizeExpandMode(v16);
4676  return true;
4677  }
4678 
4680  {
4681  const size_t totBytes (mHeader.GetSizeInBytes()); // Header + natural size of all structs/fields inbetween + Trailer
4682  if (outBlob.capacity() < totBytes)
4683  outBlob.reserve(totBytes);
4684  bool ok = mHeader.RPCEncode(outBlob); // NTV2_HEADER mHeader
4685  ok &= mBuffer.RPCEncode(outBlob); // NTV2Buffer mBuffer
4686  PUSHU32(mFlags, outBlob); // ULWord mFlags
4687  PUSHU32(mStatus, outBlob); // ULWord mStatus
4688  for (size_t ndx(0); ndx < 16; ndx++)
4689  PUSHU32(mRegisters[ndx], outBlob); // ULWord mRegisters[16]
4690  for (size_t ndx(0); ndx < 32; ndx++)
4691  PUSHU32(mReserved[ndx], outBlob); // ULWord mReserved[32]
4692  ok &= mTrailer.RPCEncode(outBlob); // NTV2_TRAILER mTrailer
4693  return ok;
4694  }
4695 
4696  bool NTV2Bitstream::RPCDecode (const RPCBlob & inBlob, size_t & inOutIndex)
4697  {
4698  bool ok = mHeader.RPCDecode(inBlob, inOutIndex); // NTV2_HEADER acHeader
4699  ok &= mBuffer.RPCDecode(inBlob, inOutIndex); // NTV2Buffer mBuffer
4700  POPU32(mFlags, inBlob, inOutIndex); // ULWord mFlags
4701  POPU32(mStatus, inBlob, inOutIndex); // ULWord mStatus
4702  for (size_t ndx(0); ndx < 16; ndx++)
4703  POPU32(mRegisters[ndx], inBlob, inOutIndex); // ULWord mRegisters[16]
4704  for (size_t ndx(0); ndx < 16; ndx++)
4705  POPU32(mReserved[ndx], inBlob, inOutIndex); // ULWord mReserved[16]
4706  ok &= mTrailer.RPCDecode(inBlob, inOutIndex); // NTV2_TRAILER mTrailer
4707  return ok;
4708  }
4709 
4711  {
4712  PUSHU16(UWord(channelSpec), outBlob); // NTV2Crosspoint channelSpec
4713  PUSHU16(UWord(state), outBlob); // NTV2AutoCirculateState state
4714  PUSHU32(ULWord(startFrame), outBlob); // LWord startFrame
4715  PUSHU32(ULWord(endFrame), outBlob); // LWord endFrame
4716  PUSHU32(ULWord(activeFrame), outBlob); // LWord activeFrame
4717  PUSHU64(rdtscStartTime, outBlob); // ULWord64 rdtscStartTime
4718  PUSHU64(audioClockStartTime, outBlob); // ULWord64 audioClockStartTime
4719  PUSHU64(rdtscCurrentTime, outBlob); // ULWord64 rdtscCurrentTime
4720  PUSHU64(audioClockCurrentTime, outBlob); // ULWord64 audioClockCurrentTime
4721  PUSHU32(framesProcessed, outBlob); // ULWord framesProcessed
4722  PUSHU32(framesDropped, outBlob); // ULWord framesDropped
4723  PUSHU32(bufferLevel, outBlob); // ULWord bufferLevel
4724  PUSHU8(bWithAudio, outBlob); // BOOL_ bWithAudio
4725  PUSHU8(bWithRP188, outBlob); // BOOL_ bWithRP188
4726  PUSHU8(bFbfChange, outBlob); // BOOL_ bFbfChange
4727  PUSHU8(bFboChange, outBlob); // BOOL_ bFboChange
4728  PUSHU8(bWithColorCorrection, outBlob); // BOOL_ bWithColorCorrection
4729  PUSHU8(bWithVidProc, outBlob); // BOOL_ bWithVidProc
4730  PUSHU8(bWithCustomAncData, outBlob); // BOOL_ bWithCustomAncData
4731  return true;
4732  }
4733 
4734  bool AUTOCIRCULATE_STATUS_STRUCT::RPCDecode (const RPCBlob & inBlob, size_t & inOutIndex)
4735  { uint16_t v16(0); uint32_t v32(0);
4736  POPU16(v16, inBlob, inOutIndex); // NTV2Crosspoint channelSpec
4737  channelSpec = NTV2Crosspoint(v16);
4738  POPU16(v16, inBlob, inOutIndex); // NTV2AutoCirculateState state
4739  state = NTV2AutoCirculateState(v16);
4740  POPU32(v32, inBlob, inOutIndex); // LWord startFrame
4741  startFrame = LWord(v32);
4742  POPU32(v32, inBlob, inOutIndex); // LWord endFrame
4743  endFrame = LWord(v32);
4744  POPU32(v32, inBlob, inOutIndex); // LWord activeFrame
4745  activeFrame = LWord(v32);
4746  POPU64(rdtscStartTime, inBlob, inOutIndex); // ULWord64 rdtscStartTime
4747  POPU64(audioClockStartTime, inBlob, inOutIndex); // ULWord64 audioClockStartTime
4748  POPU64(rdtscCurrentTime, inBlob, inOutIndex); // ULWord64 rdtscCurrentTime
4749  POPU64(audioClockCurrentTime, inBlob, inOutIndex); // ULWord64 audioClockCurrentTime
4750  POPU32(framesProcessed, inBlob, inOutIndex); // ULWord framesProcessed
4751  POPU32(framesDropped, inBlob, inOutIndex); // ULWord framesDropped
4752  POPU32(bufferLevel, inBlob, inOutIndex); // ULWord bufferLevel
4753  POPU8(AsU8Ref(bWithAudio), inBlob, inOutIndex); // BOOL_ bWithAudio
4754  POPU8(AsU8Ref(bWithRP188), inBlob, inOutIndex); // BOOL_ bWithRP188
4755  POPU8(AsU8Ref(bFbfChange), inBlob, inOutIndex); // BOOL_ bFbfChange
4756  POPU8(AsU8Ref(bFboChange), inBlob, inOutIndex); // BOOL_ bFboChange
4757  POPU8(AsU8Ref(bWithColorCorrection), inBlob, inOutIndex);// BOOL_ bWithColorCorrection
4758  POPU8(AsU8Ref(bWithVidProc), inBlob, inOutIndex); // BOOL_ bWithVidProc
4759  POPU8(AsU8Ref(bWithCustomAncData), inBlob, inOutIndex); // BOOL_ bWithCustomAncData
4760  return true;
4761  }
4762 
4764  {
4765  PUSHU32(DBB, outBlob); // ULWord DBB
4766  PUSHU32(Low, outBlob); // ULWord Low
4767  PUSHU32(High, outBlob); // ULWord High
4768  return true;
4769  }
4770 
4771  bool RP188_STRUCT::RPCDecode (const RPCBlob & inBlob, size_t & inOutIndex)
4772  {
4773  POPU32(DBB, inBlob, inOutIndex); // ULWord DBB
4774  POPU32(Low, inBlob, inOutIndex); // ULWord Low
4775  POPU32(High, inBlob, inOutIndex); // ULWord High
4776  return true;
4777  }
4778 
4779 
4781  {
4782  PUSHU32(taskVersion, outBlob); // ULWord taskVersion
4783  PUSHU32(taskSize, outBlob); // ULWord taskSize
4784  PUSHU32(numTasks, outBlob); // ULWord numTasks
4785  PUSHU32(maxTasks, outBlob); // ULWord maxTasks
4786  PUSHU64(ULWord64(taskArray), outBlob); // ULWord taskArray
4787  if (taskArray && numTasks)
4788  for (ULWord num(0); num < numTasks; num++)
4789  {
4790  const AutoCircGenericTask & task (taskArray[num]);
4791  PUSHU32(task.taskType, outBlob); // AutoCircTaskType taskType
4792  const ULWord * pULWords = reinterpret_cast<const ULWord*>(&task.u);
4793  ULWord numWords(0);
4794  if (NTV2_IS_REGISTER_TASK(task.taskType))
4795  numWords = sizeof(AutoCircRegisterTask)/sizeof(ULWord);
4796  else if (NTV2_IS_TIMECODE_TASK(task.taskType))
4797  numWords = sizeof(AutoCircTimeCodeTask)/sizeof(ULWord);
4798  for (ULWord word(0); word < numWords; word++)
4799  PUSHU32(pULWords[word], outBlob);
4800  }
4801  return true;
4802  }
4803 
4804  bool AUTOCIRCULATE_TASK_STRUCT::RPCDecode (const RPCBlob & inBlob, size_t & inOutIndex)
4805  { ULWord u32(0); ULWord64 u64(0);
4806  POPU32(taskVersion, inBlob, inOutIndex); // ULWord taskVersion
4807  POPU32(taskSize, inBlob, inOutIndex); // ULWord taskSize
4808  POPU32(numTasks, inBlob, inOutIndex); // ULWord numTasks
4809  POPU32(maxTasks, inBlob, inOutIndex); // ULWord maxTasks
4810  POPU64(u64, inBlob, inOutIndex); // ULWord taskArray
4811  taskArray = reinterpret_cast<AutoCircGenericTask*>(u64);
4812  if (taskArray && numTasks)
4813  for (ULWord num(0); num < numTasks; num++)
4814  {
4815  AutoCircGenericTask & task (taskArray[num]);
4816  POPU32(u32, inBlob, inOutIndex); // AutoCircTaskType taskType
4817  task.taskType = AutoCircTaskType(u32);
4818  ULWord * pULWords = reinterpret_cast<ULWord*>(&task.u);
4819  ULWord numWords(0);
4820  if (NTV2_IS_REGISTER_TASK(task.taskType))
4821  numWords = sizeof(AutoCircRegisterTask)/sizeof(ULWord);
4822  else if (NTV2_IS_TIMECODE_TASK(task.taskType))
4823  numWords = sizeof(AutoCircTimeCodeTask)/sizeof(ULWord);
4824  for (ULWord word(0); word < numWords; word++)
4825  POPU32(pULWords[word], inBlob, inOutIndex);
4826  }
4827  return true;
4828  }
4829 
4831  {
4832  PUSHU16(UWord(channelSpec), outBlob); // NTV2Crosspoint channelSpec
4833  PUSHU64(ULWord64(frameTime), outBlob); // LWord64 frameTime
4834  PUSHU32(frame, outBlob); // ULWord frame
4835  PUSHU64(audioClockTimeStamp, outBlob); // ULWord64 audioClockTimeStamp
4836  PUSHU32(audioExpectedAddress, outBlob); // ULWord audioExpectedAddress
4837  PUSHU32(audioInStartAddress, outBlob); // ULWord audioInStartAddress
4838  PUSHU32(audioInStopAddress, outBlob); // ULWord audioInStopAddress
4839  PUSHU32(audioOutStopAddress, outBlob); // ULWord audioOutStopAddress
4840  PUSHU32(audioOutStartAddress, outBlob); // ULWord audioOutStartAddress
4841  PUSHU32(bytesRead, outBlob); // ULWord bytesRead
4842  PUSHU32(startSample, outBlob); // ULWord startSample
4843  PUSHU64(ULWord64(currentTime), outBlob); // LWord64 currentTime
4844  PUSHU32(currentFrame, outBlob); // ULWord currentFrame
4845  currentRP188.RPCEncode(outBlob); // RP188_STRUCT currentRP188
4846  PUSHU64(ULWord64(currentFrameTime), outBlob); // LWord64 currentFrameTime
4847  PUSHU64(audioClockCurrentTime, outBlob); // ULWord64 audioClockCurrentTime
4848  PUSHU32(currentAudioExpectedAddress, outBlob); // ULWord currentAudioExpectedAddress
4849  PUSHU32(currentAudioStartAddress, outBlob); // ULWord currentAudioStartAddress
4850  PUSHU32(currentFieldCount, outBlob); // ULWord currentFieldCount
4851  PUSHU32(currentLineCount, outBlob); // ULWord currentLineCount
4852  PUSHU32(currentReps, outBlob); // ULWord currentReps
4853  PUSHU32(currenthUser, outBlob); // ULWord currenthUser
4854  return true;
4855  }
4856 
4857  bool FRAME_STAMP_STRUCT::RPCDecode (const RPCBlob & inBlob, size_t & inOutIndex)
4858  { uint16_t v16(0); uint64_t v64(0);
4859  POPU16(v16, inBlob, inOutIndex); // NTV2Crosspoint channelSpec
4860  channelSpec = NTV2Crosspoint(v16);
4861  POPU64(v64, inBlob, inOutIndex); // LWord64 frameTime
4862  frameTime = LWord64(v64);
4863  POPU32(frame, inBlob, inOutIndex); // ULWord frame
4864  POPU64(audioClockTimeStamp, inBlob, inOutIndex); // ULWord64 audioClockTimeStamp
4865  POPU32(audioExpectedAddress, inBlob, inOutIndex); // ULWord audioExpectedAddress
4866  POPU32(audioInStartAddress, inBlob, inOutIndex); // ULWord audioInStartAddress
4867  POPU32(audioInStopAddress, inBlob, inOutIndex); // ULWord audioInStopAddress
4868  POPU32(audioOutStopAddress, inBlob, inOutIndex); // ULWord audioOutStopAddress
4869  POPU32(audioOutStartAddress, inBlob, inOutIndex); // ULWord audioOutStartAddress
4870  POPU32(bytesRead, inBlob, inOutIndex); // ULWord bytesRead
4871  POPU32(startSample, inBlob, inOutIndex); // ULWord startSample
4872  POPU64(v64, inBlob, inOutIndex); // LWord64 currentTime
4873  currentTime = LWord64(v64);
4874  POPU32(currentFrame, inBlob, inOutIndex); // ULWord currentFrame
4875  currentRP188.RPCDecode(inBlob, inOutIndex); // RP188_STRUCT currentRP188
4876  POPU64(v64, inBlob, inOutIndex); // LWord64 currentFrameTime
4877  currentFrameTime = LWord64(v64);
4878  POPU64(audioClockCurrentTime, inBlob, inOutIndex); // ULWord64 audioClockCurrentTime
4879  POPU32(currentAudioExpectedAddress, inBlob, inOutIndex);// ULWord currentAudioExpectedAddress
4880  POPU32(currentAudioStartAddress, inBlob, inOutIndex); // ULWord currentAudioStartAddress
4881  POPU32(currentFieldCount, inBlob, inOutIndex); // ULWord currentFieldCount
4882  POPU32(currentLineCount, inBlob, inOutIndex); // ULWord currentLineCount
4883  POPU32(currentReps, inBlob, inOutIndex); // ULWord currentReps
4884  POPU32(currenthUser, inBlob, inOutIndex); // ULWord currenthUser
4885  return true;
4886  }
4887 
4889  {
4890  PUSHU16(UWord(eCommand), outBlob); // AUTO_CIRC_COMMAND eCommand
4891  PUSHU16(UWord(channelSpec), outBlob); // NTV2Crosspoint channelSpec
4892  PUSHU32(ULWord(lVal1), outBlob); // LWord lVal1
4893  PUSHU32(ULWord(lVal2), outBlob); // LWord lVal2
4894  PUSHU32(ULWord(lVal3), outBlob); // LWord lVal3
4895  PUSHU32(ULWord(lVal4), outBlob); // LWord lVal4
4896  PUSHU32(ULWord(lVal5), outBlob); // LWord lVal5
4897  PUSHU32(ULWord(lVal6), outBlob); // LWord lVal6
4898  PUSHU8(bVal1, outBlob); // BOOL_ bVal1
4899  PUSHU8(bVal2, outBlob); // BOOL_ bVal2
4900  PUSHU8(bVal3, outBlob); // BOOL_ bVal3
4901  PUSHU8(bVal4, outBlob); // BOOL_ bVal4
4902  PUSHU8(bVal5, outBlob); // BOOL_ bVal5
4903  PUSHU8(bVal6, outBlob); // BOOL_ bVal6
4904  PUSHU8(bVal7, outBlob); // BOOL_ bVal7
4905  PUSHU8(bVal8, outBlob); // BOOL_ bVal8
4906  PUSHU64(ULWord64(pvVal1), outBlob); // void* pvVal1
4907  PUSHU64(ULWord64(pvVal2), outBlob); // void* pvVal2
4908  PUSHU64(ULWord64(pvVal3), outBlob); // void* pvVal3
4909  PUSHU64(ULWord64(pvVal4), outBlob); // void* pvVal4
4910  if (eCommand == eGetAutoCirc && pvVal1)
4911  reinterpret_cast<AUTOCIRCULATE_STATUS_STRUCT*>(pvVal1)->RPCEncode(outBlob);
4912  if ((eCommand == eGetFrameStamp || eCommand == eGetFrameStampEx2) && pvVal1)
4913  reinterpret_cast<FRAME_STAMP_STRUCT*>(pvVal1)->RPCEncode(outBlob);
4914  if (eCommand == eGetFrameStampEx2 && pvVal2)
4915  reinterpret_cast<AUTOCIRCULATE_TASK_STRUCT*>(pvVal2)->RPCEncode(outBlob);
4916  if (eCommand == eTransferAutoCirculate && pvVal1)
4917  reinterpret_cast<AUTOCIRCULATE_TRANSFER_STRUCT*>(pvVal1)->RPCEncode(outBlob);
4918  return true;
4919  }
4920 
4921  bool AUTOCIRCULATE_DATA::RPCDecode (const RPCBlob & inBlob, size_t & inOutIndex)
4922  {
4923 #if defined(AJA_LINUX)
4924  #pragma GCC diagnostic push
4925  #pragma GCC diagnostic ignored "-Wstrict-aliasing"
4926 #endif
4927  uint16_t v16(0); uint32_t v32(0);
4928  POPU16(v16, inBlob, inOutIndex); // AUTO_CIRC_COMMAND eCommand
4929  eCommand = AUTO_CIRC_COMMAND(v16);
4930  POPU16(v16, inBlob, inOutIndex); // NTV2Crosspoint channelSpec
4931  channelSpec = NTV2Crosspoint(v16);
4932  POPU32(v32, inBlob, inOutIndex); lVal1 = LWord(v32); // LWord lVal1
4933  POPU32(v32, inBlob, inOutIndex); lVal2 = LWord(v32); // LWord lVal2
4934  POPU32(v32, inBlob, inOutIndex); lVal3 = LWord(v32); // LWord lVal3
4935  POPU32(v32, inBlob, inOutIndex); lVal4 = LWord(v32); // LWord lVal4
4936  POPU32(v32, inBlob, inOutIndex); lVal5 = LWord(v32); // LWord lVal5
4937  POPU32(v32, inBlob, inOutIndex); lVal6 = LWord(v32); // LWord lVal6
4938  POPU8(AsU8Ref(bVal1), inBlob, inOutIndex); // BOOL_ bVal1
4939  POPU8(AsU8Ref(bVal2), inBlob, inOutIndex); // BOOL_ bVal2
4940  POPU8(AsU8Ref(bVal3), inBlob, inOutIndex); // BOOL_ bVal3
4941  POPU8(AsU8Ref(bVal4), inBlob, inOutIndex); // BOOL_ bVal4
4942  POPU8(AsU8Ref(bVal5), inBlob, inOutIndex); // BOOL_ bVal5
4943  POPU8(AsU8Ref(bVal6), inBlob, inOutIndex); // BOOL_ bVal6
4944  POPU8(AsU8Ref(bVal7), inBlob, inOutIndex); // BOOL_ bVal7
4945  POPU8(AsU8Ref(bVal8), inBlob, inOutIndex); // BOOL_ bVal8
4946  POPU64(AsU64Ref(pvVal1), inBlob, inOutIndex); // void* pvVal1
4947  POPU64(AsU64Ref(pvVal2), inBlob, inOutIndex); // void* pvVal2
4948  POPU64(AsU64Ref(pvVal3), inBlob, inOutIndex); // void* pvVal3
4949  POPU64(AsU64Ref(pvVal4), inBlob, inOutIndex); // void* pvVal4
4950 #if defined(AJA_LINUX)
4951  #pragma GCC diagnostic pop
4952 #endif
4953  if (eCommand == eGetAutoCirc && pvVal1)
4954  reinterpret_cast<AUTOCIRCULATE_STATUS_STRUCT*>(pvVal1)->RPCDecode(inBlob, inOutIndex);
4955  if ((eCommand == eGetFrameStamp || eCommand == eGetFrameStampEx2) && pvVal1)
4956  reinterpret_cast<FRAME_STAMP_STRUCT*>(pvVal1)->RPCDecode(inBlob, inOutIndex);
4957  if (eCommand == eGetFrameStampEx2 && pvVal2)
4958  reinterpret_cast<AUTOCIRCULATE_TASK_STRUCT*>(pvVal2)->RPCDecode(inBlob, inOutIndex);
4959  if (eCommand == eTransferAutoCirculate && pvVal1)
4960  reinterpret_cast<AUTOCIRCULATE_TRANSFER_STRUCT*>(pvVal1)->RPCDecode(inBlob, inOutIndex);
4961  return true;
4962  }
NTV2_RP188 acRP188
Will be deprecated – use AUTOCIRCULATE_TRANSFER::SetOutputTimeCode instead.
bool AppendU8s(UByteSequence &outU8s) const
Appends my contents to an existing UByteSequence.
bool RPCEncode(NTV2_RPC_BLOB_TYPE &outBlob)
NTV2Channel mChannel
Stream channel.
bool SetOutputTimeCodes(const NTV2TimeCodes &inValues)
Intended for playout, replaces the contents of my acOutputTimeCodes member.
std::set< NTV2VideoFormat > NTV2VideoFormatSet
A set of distinct NTV2VideoFormat values.
NTV2SegmentedXferInfo & setSourceDirection(const bool inTopDown)
Sets the scan direction for the source.
NTV2AutoCirculateState state
ULWord acCurrentAudioStartAddress
As set by play.
NTV2Buffer acOutputTimeCodes
Intended for playout, this is an ordered sequence of NTV2_RP188 values to send to the device...
#define NTV2_TYPE_MESSAGE_DATA
Identifies NTV2MessageData struct.
const char * NTV2InterruptEnumString(const unsigned inInterruptEnum)
Definition: ntv2debug.cpp:1183
Everything needed to call CNTV2Card::ReadRegister or CNTV2Card::WriteRegister functions.
NTV2FrameRate GetNTV2FrameRateFromVideoFormat(const NTV2VideoFormat inVideoFormat)
Definition: ntv2utils.cpp:3630
bool GetBadRegisters(NTV2RegNumSet &outBadRegNums) const
Returns the set of register numbers that were not read successfully.
NTV2StandardSet::const_iterator NTV2StandardSetConstIter
A handy const iterator for iterating over an NTV2StandardSet.
#define NTV2_TYPE_AJABITSTREAM
Identifies NTV2Bitstream struct.
ULWord mFlags
Action flags.
ULWord audioInStopAddress
For record - end position (exclusive) in buffer of audio (includes base offset)
std::string NTV2FrameGeometryToString(const NTV2FrameGeometry inValue, const bool inForRetailDisplay=false)
Definition: ntv2utils.cpp:6982
bool GetRequestedRegisterNumbers(NTV2RegNumSet &outRegNums) const
Answers with the set of register numbers that were requested.
std::string NTV2AudioSystemToString(const NTV2AudioSystem inValue, const bool inCompactDisplay=false)
Definition: ntv2utils.cpp:5749
NTV2_TRAILER mTrailer
The common structure trailer – ALWAYS LAST!
ULWord frame
The frame requested or -1 if not available.
NTV2Buffer mHandles
Optional buffer to store subscribed HANDLEs.
#define NTV2EndianSwap64(__val__)
Definition: ntv2endian.h:25
bool RPCEncode(NTV2_RPC_BLOB_TYPE &outBlob)
std::string NTV2HDMIBitDepthToString(const NTV2HDMIBitDepth inValue, const bool inCompactDisplay=false)
Definition: ntv2utils.cpp:6649
std::ostream & Print(std::ostream &inOutStream) const
Prints a human-readable representation of me to the given output stream.
std::string operator[](const unsigned inIndexNum) const
NTV2AudioSystem
Used to identify an Audio System on an NTV2 device. See Audio System Operation for more information...
Definition: ntv2enums.h:3901
#define AJA_NTV2_SDK_BUILD_NUMBER
The SDK build number, an unsigned decimal integer.
Definition: ntv2version.h:16
#define NTV2_HEADER_TAG
Identifies the struct header.
ULWord acCurrentFrame
Last vertical blank frame for this autocirculate channel (when CNTV2Card::AutoCirculateGetFrameStamp ...
NTV2OutputDestinations::const_iterator NTV2OutputDestinationsConstIter
A handy const iterator for iterating over an NTV2OutputDestinations.
bool CopyTo(FRAME_STAMP_STRUCT &outOldStruct) const
Copies my fields into the given FRAME_STAMP_STRUCT.
YCbCr color space.
Definition: ntv2enums.h:3615
For devices that support it (see NTV2DeviceCanDoSDIErrorChecks ), this struct reports SDI input error...
bool PutU16s(const UWordSequence &inU16s, const size_t inU16Offset=0, const bool inByteSwap=false)
Copies a vector of unsigned 16-bit values into me.
Specifies SDI input/output kinds.
Definition: ntv2enums.h:1296
std::set< NTV2TCIndex > NTV2TCIndexes
ULWord currentAudioStartAddress
As found by isr.
bool RPCDecode(const NTV2_RPC_BLOB_TYPE &inBlob, size_t &inOutIndex)
FRAME_STAMP()
Constructs a default FRAME_STAMP structure.
bool Allocate(const size_t inByteCount, const bool inPageAligned=false)
Allocates (or re-allocates) my user-space storage using the given byte count. I assume full responsib...
ULWord64 acInUserCookie
Intended for playout, an optional app-specific cookie value that tags this frame, such that if this s...
void SetFlags(const ULWord inFlags)
Sets the action flags for use in a subsequent call to CNTV2Card::LoadBitstream.
#define NTV2HostIsBigEndian
Definition: ntv2endian.h:58
NTV2_HEADER mHeader
The common structure header – ALWAYS FIRST!
bool GetSDIInputStatus(NTV2SDIInputStatus &outStatus, const UWord inSDIInputIndex0=0) const
Answers with the NTV2SDIInputStatus for the given SDI input spigot.
NTV2Buffer & operator=(const NTV2Buffer &inRHS)
Assigns me from another NTV2Buffer instance.
LWord64 currentTime
Current processor time ... on Windows, this is derived from KeQueryPerformanceCounter.
NTV2SetRegisters(const NTV2RegWrites &inRegWrites=NTV2RegWrites())
Constructs an NTV2SetRegisters struct from the given NTV2RegisterWrites collection.
Declares the AJAMemory class.
std::set< NTV2FrameRate > NTV2FrameRateSet
A set of distinct NTV2FrameRate values. New in SDK 17.0.
NTV2StreamBuffer()
Constructs a default NTV2StreamBuffer struct.
NTV2Crosspoint
Logically, these are an NTV2Channel combined with an NTV2Mode.
Definition: ntv2enums.h:1705
mVideoBuffer Allocate(mFormatDesc.GetTotalRasterBytes())
std::ostream & Print(std::ostream &inStrm, const bool inDumpSegments=false) const
Writes a human-readable description of me into a given output stream.
void PUSHU32(const uint32_t val, RPCBlob &blob, const bool dontSwap=false)
Pushes a 32-bit value onto the given byte sequence.
Definition: ntv2nubtypes.h:63
bool CopyTo(AUTOCIRCULATE_STATUS_STRUCT &outOldStruct)
Copies my data into the given AUTOCIRCULATE_STATUS_STRUCT.
unsigned long long stoull(const std::string &str, std::size_t *idx, int base)
Definition: common.cpp:154
ULWord registerMask
My register mask value to use in a ReadRegister or WriteRegister call.
bool SetFrameBufferFormat(const NTV2FrameBufferFormat inNewFormat)
Sets my acFrameBufferFormat value to the given new value (if valid and circulating with AUTOCIRCULATE...
NTV2DeviceIDSet NTV2GetSupportedDevices(const NTV2DeviceKinds inKinds=NTV2_DEVICEKIND_ALL)
Returns an NTV2DeviceIDSet of devices supported by the SDK.
Definition: ntv2utils.cpp:7397
std::vector< double > NTV2DoubleArray
An array of double-precision floating-point values.
NTV2HDMIColorSpace
Indicates or specifies HDMI Color Space.
Definition: ntv2enums.h:3611
#define NTV2_IS_TIMECODE_TASK(_x_)
void Clear(void)
Resets the struct to its initialized state, with timecode capture disabled, freeing all buffers that ...
bool WithCustomAnc(void) const
bool IsNULL(void) const
NTV2Buffer mSharedMemory
Virtual address of AJADebug shared memory in calling process&#39; context,.
ULWord audioOutStartAddress
For play - end position (exclusive) in buffer of audio.
NTV2RegNumSet GetRegisterNumbers(const NTV2RegReads &inRegInfos)
std::ostream & Print(std::ostream &outputStream, const bool inAsCode=false) const
Renders me to the given output stream in a human-readable format.
CHAR * pName
Definition: amvideo.cpp:26
#define DEC0N(__x__, __n__)
ULWord getElementLength(void) const
NTV2RegInfo & setMask(const ULWord val)
string NTV2ChannelSetToStr(const NTV2ChannelSet &inObj, const bool inCompact)
1920x1080, for 1080i and 1080p, NTV2_VANCMODE_TALL
Definition: ntv2enums.h:363
ULWord mFlags
Action flags.
NTV2FrameBufferFormat
Identifies a particular video frame buffer pixel format. See Device Frame Buffer Formats for details...
Definition: ntv2enums.h:223
bool RPCDecode(const NTV2_RPC_BLOB_TYPE &inBlob, size_t &inOutIndex)
bool EnableSegmentedDMAs(const ULWord inNumSegments, const ULWord inNumActiveBytesPerLine, const ULWord inHostBytesPerLine, const ULWord inDeviceBytesPerLine)
Enables segmented DMAs given a segment count, a host pitch, and device pitch value.
NTV2ChannelSet::const_iterator NTV2ChannelSetConstIter
A handy const iterator into an NTV2ChannelSet.
ULWord getTotalBytes(void) const
bool SetBuffers(ULWord *pInVideoBuffer, const ULWord inVideoByteCount, ULWord *pInAudioBuffer, const ULWord inAudioByteCount, ULWord *pInANCBuffer, const ULWord inANCByteCount, ULWord *pInANCF2Buffer=NULL, const ULWord inANCF2ByteCount=0)
Sets my buffers for use in a subsequent call to CNTV2Card::AutoCirculateTransfer. ...
NTV2_HEADER acHeader
The common message header – ALWAYS FIRST!
bool RPCEncode(NTV2_RPC_BLOB_TYPE &outBlob)
#define NTV2_IS_VALID_TRAILER_TAG(_x_)
bool RPCEncode(NTV2_RPC_BLOB_TYPE &outBlob)
NTV2StringSet::const_iterator NTV2StringSetConstIter
~AUTOCIRCULATE_TRANSFER()
My default destructor, which frees all allocatable fields that I own.
Declares the AJADebug class.
bool CopyFrom(const void *pInSrcBuffer, const ULWord inByteCount)
Replaces my contents from the given memory buffer, resizing me to the new byte count.
720x576, for PAL 625i, NTV2_VANCMODE_TALL
Definition: ntv2enums.h:362
See 10-Bit YCbCr Format.
Definition: ntv2enums.h:226
#define GetTCIndexesForSDIInput
Definition: ntv2utils.h:592
bool Set(const NTV2ColorCorrectionMode inMode, const ULWord inSaturation, const void *pInTableData)
Sets this struct from the given mode, saturation and table data, replacing any existing mode...
static ULWord FGWidth(const NTV2FrameGeometry fg)
std::set< NTV2InputSource > NTV2InputSourceSet
A set of distinct NTV2InputSource values.
ULWord acCurrentReps
Contains validCount (Playout: on repeated frames, number of reps remaining; Record: drops on frame) ...
bool NTV2GetUnsupportedStandards(NTV2StandardSet &outStandards)
Returns a set of NTV2Standard values not suported by any NTV2 device.
ULWord acAudioInStopAddress
(input/ingest/capture only) Ending audio record head position (exclusive) AFTER this frame was stampe...
1280x720, for 720p, NTV2_VANCMODE_OFF
Definition: ntv2enums.h:356
std::string NTV2OutputDestinationToString(const NTV2OutputDestination inValue, const bool inForRetailDisplay=false)
Definition: ntv2utils.cpp:7066
bool RPCEncode(NTV2_RPC_BLOB_TYPE &outBlob)
int Fixed_
Definition: ajatypes.h:302
enum _NTV2VideoFormat NTV2VideoFormat
Identifies a particular video format.
static bool SetDefaultPageSize(const size_t inNewSize)
Changes the default page size for use in future page-aligned allocations.
bool ByteSwap32(void)
Byte-swaps my contents 32-bits at a time.
NTV2_HEADER mHeader
The common structure header – ALWAYS FIRST!
static std::string OpName(const ULWord op)
static uint64_t GetPid()
Definition: process.cpp:35
ULWord GetBufferLevel(void) const
NTV2StringList::const_iterator NTV2StringListConstIter
enum NTV2VideoFrameBufferOrientation NTV2FBOrientation
bool WithFBOChange(void) const
bool IsContentEqual(const NTV2Buffer &inBuffer, const ULWord inByteOffset=0, const ULWord inByteCount=0xFFFFFFFF) const
AutoCircVidProcInfo acVidProcInfo
Specifies the mixer/keyer transition to make. Ignored if AUTOCIRCULATE_WITH_VIDPROC option is not set...
bool isSourceTopDown(void) const
NTV2SDIInStatistics()
Constructs an NTV2GetSDIStatistics struct and initializes it to its default state.
void SetMaxLockSize(const ULWord64 inNumBytes)
Sets the maximum lock size for use in a subsequent call to CNTV2Card::DMABufferLock.
NTV2ConfigInterrupt & setOperation(const ULWord op)
Sets my operation; also stores caller&#39;s PID & TID.
bool ResetUsing(const NTV2RegNumSet &inRegisterNumbers)
Resets me, starting over, now using the given NTV2RegisterNumberSet.
NTV2TimeCodeList::const_iterator NTV2TimeCodeListConstIter
A handy const interator for iterating over an NTV2TimeCodeList.
AutoCircTaskType
These are the available AutoCirculate task types.
uint32_t U32(const int inIndex) const
ULWord acAudioStartSample
Starting audio sample (valid for capture only).
AutoCircVidProcMode
ULWordSequence::const_iterator ULWordSequenceConstIter
A handy const iterator for iterating over a ULWordSequence.
bool RPCDecode(const NTV2_RPC_BLOB_TYPE &inBlob, size_t &inOutIndex)
AUTOCIRCULATE_TRANSFER_STATUS()
Constructs a default AUTOCIRCULATE_TRANSFER_STATUS structure.
ULWord bytesRead
Total audio and video bytes transfered.
bool IsValid(void) const
Answers true if I&#39;m valid, or false if I&#39;m not valid.
ULWord GetByteCount(void) const
NTV2_TRAILER acTrailer
The common structure trailer – ALWAYS LAST!
#define NTV2_TYPE_AJAMAILBUFFER
Identifies NTV2MailBuffer struct.
ULWord audioExpectedAddress
The address that was used to transfer.
Configure interrupt (subscribe/unsubscribe, enable/disable, query subscribed interrupts, query enabled interrupts, etc.).
NTV2RegWrites::const_iterator NTV2RegisterWritesConstIter
bool RPCDecode(const NTV2_RPC_BLOB_TYPE &inBlob, size_t &inOutIndex, bool fillBuffer=true)
LWord acStartFrame
First frame to circulate. FIXFIXFIX Why is this signed? CHANGE TO ULWord??
#define NTV2SDKVersionDecode_Minor
std::map< ULWord, ULWord > NTV2RegisterValueMap
A mapping of distinct NTV2RegisterNumbers to their corresponding ULWord values.
ULWord getDestPitch(void) const
ULWord mSpares[32]
Reserved for future use.
std::string NTV2RegisterNumberToString(const NTV2RegisterNumber inValue)
Definition: ntv2utils.cpp:7566
ULWordSetConstIter NTV2RegNumSetConstIter
A const iterator that iterates over a set of distinct NTV2RegisterNumbers.
bool PutU64s(const ULWord64Sequence &inU64s, const size_t inU64Offset=0, const bool inByteSwap=false)
Copies a vector of unsigned 64-bit values into me.
NTV2SegmentedDMAInfo()
Constructs a disabled NTV2SegmentedDMAInfo struct.
int32_t LWord
Definition: ajatypes.h:235
bool RPCEncode(NTV2_RPC_BLOB_TYPE &outBlob)
NTV2Buffer acVideoBuffer
The host video buffer. This field is owned by the client application, and thus is responsible for all...
#define AUTOCIRCULATE_WITH_FBFCHANGE
Use this to AutoCirculate with the possibility of frame buffer format changes.
ULWord mIsWriting
If non-zero, virtual data will be written; otherwise, virtual data will be read.
Specifies HDMI input/output kinds.
Definition: ntv2enums.h:1297
NTV2ConfigInterrupt(const void *pClient=nullptr)
Default ctor, optionally set clientID if needed.
LWord64 acFrameTime
(input/ingest/capture only) The absolute timestamp at the VBI when the frame started recording into d...
NTV2AudioSystemSet NTV2MakeAudioSystemSet(const NTV2AudioSystem inFirstAudioSystem, const UWord inCount)
NTV2ChannelSet NTV2MakeChannelSet(const NTV2Channel inFirstChannel, const UWord inNumChannels)
ULWord ccSaturationValue
My saturation value, used only in 3-way color correction mode.
bool RPCDecode(const NTV2_RPC_BLOB_TYPE &inBlob, size_t &inOutIndex)
if(!(riid==IID_IUnknown) &&!(riid==IID_IClassFactory))
Definition: dllentry.cpp:196
FRAME_STAMP acFrameStamp
Frame stamp for the transferred frame.
AUTOCIRCULATE_DATA(const AUTO_CIRC_COMMAND inCommand=AUTO_CIRC_COMMAND_INVALID, const NTV2Crosspoint inCrosspoint=NTV2CROSSPOINT_INVALID)
NTV2RegisterReadsConstIter FindFirstMatchingRegisterNumber(const uint32_t inRegNum, const NTV2RegisterReads &inRegInfos)
Returns a const iterator to the first entry in the NTV2RegInfo collection with a matching register nu...
std::string NTV2ColorCorrectionModeToString(const NTV2ColorCorrectionMode inValue, const bool inCompactDisplay=false)
Definition: ntv2utils.cpp:7586
NTV2_TRAILER mTrailer
The common structure trailer – ALWAYS LAST!
NTV2AudioChannelQuads::const_iterator NTV2AudioChannelQuadsConstIter
Handy const iterator to iterate over a set of distinct NTV2AudioChannelQuad values.
bool containsElementAtOffset(const ULWord inElementOffset) const
NTV2_TRAILER mTrailer
The common structure trailer – ALWAYS LAST!
bool DisableSegmentedDMAs(void)
Disables segmented DMAs, performing a Reset on my acInSegmentedDMAInfo.
LWord64 acCurrentTime
The absolute timestamp at the moment the CNTV2Card::AutoCirculateTransfer or CNTV2Card::AutoCirculate...
Defines a number of handy byte-swapping macros.
bool GetGoodRegisters(NTV2RegNumSet &outGoodRegNums) const
Returns an NTV2RegNumSet built from my mOutGoodRegisters field.
The "default" timecode (mostly used by the AJA "Retail" service and Control Panel) ...
Definition: ntv2enums.h:3959
bool SetOutputTimeCode(const NTV2_RP188 &inTimecode, const NTV2TCIndex inTCIndex=NTV2_TCINDEX_SDI1)
Intended for playout, sets one element of my acOutputTimeCodes member.
ULWord value(void) const
NTV2_HEADER mHeader
The common structure header – ALWAYS FIRST!
bool NTV2DeviceCanDoFrameBufferFormat(const NTV2DeviceID inDeviceID, const NTV2FrameBufferFormat inFBFormat)
bool RPCDecode(const NTV2_RPC_BLOB_TYPE &inBlob, size_t &inOutIndex)
NTV2FrameBufferFormatSet NTV2PixelFormats
#define NTV2_IS_VALID_TIMECODE_INDEX(__x__)
Definition: ntv2enums.h:3990
ULWord currentFrame
Last vertical blank frame for this channel&#39;s auto-circulate. (at the time of the IOCTL_NTV2_GET_FRAME...
ULWord mResult
Out: 0=false (fail), 1 or non-zero == true (success)
static string print_address_offset(const size_t inRadix, const ULWord64 inOffset)
bool POPU8(uint8_t &outVal, const RPCBlob &blob, std::size_t &inOutNdx)
Pops an 8-bit value off the given byte sequence at the given zero-based index position.
Definition: ntv2nubtypes.h:110
2048x1080, for 2Kx1080p, NTV2_VANCMODE_TALL
Definition: ntv2enums.h:368
Definition: json.hpp:5362
FGSizesMap::const_iterator FGSizesMapCI
NTV2HDMIAudioChannels
Indicates or specifies the HDMI audio channel count.
Definition: ntv2enums.h:3673
NTV2FBOrientation acFrameBufferOrientation
Specifies the frame buffer orientation to change to. Ignored if AUTOCIRCULATE_WITH_FBOCHANGE option i...
std::ostream & Print(std::ostream &inOutStream) const
Prints a human-readable representation of me into the given output stream.
std::set< NTV2OutputDestination > NTV2OutputDestinations
A set of distinct NTV2OutputDestination values.
ULWord count(void) const
bool isSourceBottomUp(void) const
ULWord acInVideoDMAOffset
Optional byte offset into the device frame buffer. Defaults to zero. If non-zero, should be a multipl...
#define NTV2_TYPE_GETREGS
Identifies NTV2GetRegisters struct.
#define NTV2_COLORCORRECTOR_TABLESIZE
#define false
ULWord mTag
Tag for virtual data. This value is used to recall saved data by tag.
LWord acActiveFrame
Current frame actually being captured/played when CNTV2Card::AutoCirculateGetStatus called...
bool GetFailedRegisterWrites(NTV2RegWrites &outFailedRegWrites) const
Returns an NTV2RegisterWrites built from my mOutBadRegInfos field.
#define NTV2_TYPE_ACSTATUS
Identifies AUTOCIRCULATE_STATUS struct.
#define AJA_NTV2_SDK_VERSION_POINT
The SDK "point" release version, an unsigned decimal integer.
Definition: ntv2version.h:15
NTV2HDMIRange
Indicates or specifies the HDMI RGB range.
Definition: ntv2enums.h:3641
uint32_t ULWord
Definition: ajatypes.h:236
NTV2SegmentedXferInfo & setElementLength(const ULWord inBytesPerElement)
Sets my element length.
NTV2AudioFormat
Definition: ntv2enums.h:1956
NTV2Channel
These enum values are mostly used to identify a specific widget_framestore. They&#39;re also commonly use...
Definition: ntv2enums.h:1361
bool toHexString(std::string &outStr, const size_t inLineBreakInterval=0) const
Converts my contents into a hex-encoded string.
std::string NTV2AudioFormatToString(const NTV2AudioFormat inValue, const bool inCompactDisplay=false)
Definition: ntv2utils.cpp:6706
Describes a segmented data transfer (copy or move) from a source memory location to a destination loc...
#define NTV2_TYPE_BANKGETSET
Identifies NTV2BankSelGetSetRegs struct.
std::vector< NTV2RegInfo > NTV2RegWrites
An ordered sequence of zero or more NTV2RegInfo structs intended for WriteRegister.
virtual char do_thousands_sep() const
NTV2_HEADER mHeader
The common structure header – ALWAYS FIRST!
Specifies devices that internally use NTV2.
Definition: ntv2enums.h:1402
NTV2FrameRateSet::const_iterator NTV2FrameRateSetConstIter
A handy const iterator for iterating over an NTV2FrameRateSet.
NTV2FrameGeometry GetGeometryFromFrameDimensions(const NTV2FrameSize &inFD)
Definition: ntv2utils.cpp:3957
std::set< NTV2AudioChannelPair > NTV2AudioChannelPairs
A set of distinct NTV2AudioChannelPair values.
NTV2SegmentedXferInfo & swapSourceAndDestination(void)
Swaps my source and destination offsets, pitches and scan directions.
NTV2_HEADER mHeader
The common structure header – ALWAYS FIRST!
#define NTV2_TYPE_ACXFER
Identifies AUTOCIRCULATE_TRANSFER struct.
std::set< NTV2AudioChannelQuad > NTV2AudioChannelQuads
A set of distinct NTV2AudioChannelQuad values.
#define NTV2_OUTPUT_DEST_IS_HDMI(_dest_)
Definition: ntv2enums.h:1348
string NTV2ChannelListToStr(const NTV2ChannelList &inObj, const bool inCompact)
std::set< NTV2Standard > NTV2StandardSet
A set of distinct NTV2Standard values.
NTV2Crosspoint acCrosspoint
Will be deprecated – used internally by the SDK. Will be removed when the driver changes to use NTV2...
bool CopyFrom(const AUTOCIRCULATE_STATUS_STRUCT &inOldStruct)
Copies the given AUTOCIRCULATE_STATUS_STRUCT into me.
#define BIN08(__x__)
ULWord GetProcessedFrameCount(void) const
#define NTV2_ASSERT(_expr_)
Definition: ajatypes.h:489
void PUSHU8(const uint8_t val, RPCBlob &blob)
Pushes an 8-bit value onto the given byte sequence.
Definition: ntv2nubtypes.h:37
std::string AsString(UWord inDumpMaxBytes=0) const
ULWord mFlags
Action flags (lock, unlock, etc)
bool GetInputTimeCodes(NTV2TimeCodeList &outValues) const
Returns all RP188 timecodes associated with the frame in NTV2TCIndex order.
Represents an unknown or invalid frame rate.
Definition: ntv2enums.h:418
std::string operator[](const unsigned inIndexNum) const
std::vector< uint8_t > UByteSequence
An ordered sequence of UByte (uint8_t) values.
NTV2AutoCirculateState acState
Current AutoCirculate state after the transfer.
static AJAStatus StatTimerStop(const uint32_t inKey)
Definition: debug.cpp:1161
bool NTV2DeviceGetSupportedStandards(const NTV2DeviceID inDeviceID, NTV2StandardSet &outStandards)
Returns a set of distinct NTV2Standard values supported on the given device.
NTV2RegWritesConstIter NTV2RegisterReadsConstIter
bool Truncate(const size_t inByteCount)
Truncates me to the given length. No reallocation takes place.
This struct replaces the old RP188_STRUCT.
NTV2GeometrySet::const_iterator NTV2GeometrySetConstIter
A handy const iterator for iterating over an NTV2GeometrySet.
NTV2FrameBufferFormat NTV2PixelFormat
An alias for NTV2FrameBufferFormat.
Definition: ntv2enums.h:264
NTV2_HEADER acHeader
The common structure header – ALWAYS FIRST!
NTV2ColorCorrectionMode ccMode
My mode (off, RGB, YCbCr, or 3-way)
Last virtual register slot.
NTV2_TRAILER acTrailer
The common message trailer – ALWAYS LAST!
NTV2BankSelGetSetRegs(const NTV2RegInfo &inBankSelect, const NTV2RegInfo &inRegInfo, const bool inDoWrite=false)
Constructs an NTV2BankSelGetSetRegs struct for atomically reading or writing the given bank-selected ...
ULWord regNum(void) const
unsigned long stoul(const std::string &str, std::size_t *idx, int base)
Definition: common.cpp:143
NTV2RegInfo & setRegNum(const ULWord val)
2048x1556, for 2Kx1556psf film format, NTV2_VANCMODE_OFF
Definition: ntv2enums.h:366
NTV2TCIndex
These enum values are indexes into the capture/playout AutoCirculate timecode arrays.
Definition: ntv2enums.h:3957
bool Fill(const T &inValue)
Fills me with the given scalar value.
bool Find(const T &inValue, int &inOutIndex) const
Searches me for the given scalar value of type T starting at a given index position.
bool GetString(std::string &outString, const size_t inU8Offset=0, const size_t inMaxSize=128) const
Answers with my contents as a character string.
bool GetRegisterValues(NTV2RegisterValueMap &outValues) const
Returns an NTV2RegisterValueMap built from my mOutGoodRegisters and mOutValues fields.
std::string NTV2InputSourceToString(const NTV2InputSource inValue, const bool inForRetailDisplay=false)
Definition: ntv2utils.cpp:7043
bool Deallocate(void)
Deallocates my user-space storage (if I own it – i.e. from a prior call to Allocate).
bool RPCDecode(const NTV2_RPC_BLOB_TYPE &inBlob, size_t &inOutIndex)
void Clear(void)
Resets me to an invalid state.
ULWord currentReps
At Call Line# currently being OUTPUT (at the time of the IOCTL_NTV2_GET_FRAMESTAMP) ...
NTV2Channel NTV2OutputDestinationToChannel(const NTV2OutputDestination inOutputDest)
Converts a given NTV2OutputDestination to its equivalent NTV2Channel value.
Definition: ntv2utils.cpp:5159
std::string AutoCircVidProcModeToString(const AutoCircVidProcMode inValue, const bool inCompactDisplay=false)
Definition: ntv2utils.cpp:7572
UWord NTV2DeviceGetNumHDMIVideoOutputs(const NTV2DeviceID inDeviceID)
ULWord mInNumRegisters
The number of NTV2RegInfo&#39;s to be set.
ULWord operation(void) const
static bool IsReadOnly(const uint32_t inRegNum)
AutoCircVidProcMode mode
NTV2FrameRate
Identifies a particular video frame rate.
Definition: ntv2enums.h:416
NTV2_TRAILER mTrailer
The common structure trailer – ALWAYS LAST!
std::ostream & Print(std::ostream &inOutStream) const
Prints a human-readable representation of me to the given output stream.
NTV2FrameBufferFormat acFrameBufferFormat
Specifies the frame buffer format to change to. Ignored if AUTOCIRCULATE_WITH_FBFCHANGE option is not...
std::string NTV2StandardToString(const NTV2Standard inValue, const bool inForRetailDisplay=false)
Definition: ntv2utils.cpp:6914
bool RPCEncode(NTV2_RPC_BLOB_TYPE &outBlob)
#define NTV2_TYPE_SDISTATS
Identifies NTV2SDIStatus struct.
std::string NTV2AudioChannelQuadToString(const NTV2Audio4ChannelSelect inValue, const bool inCompactDisplay=false)
Definition: ntv2utils.cpp:6447
2048x1080, NTV2_VANCMODE_TALLER
Definition: ntv2enums.h:360
#define BIN032(__x__)
NTV2Standard
Identifies a particular video standard.
Definition: ntv2enums.h:169
#define NTV2_TYPE_VIRTUAL_DATA_RW
Identifies NTV2VirtualData struct.
NTV2ColorCorrectionData acColorCorrection
Color correction data. This field is ignored if AUTOCIRCULATE_WITH_COLORCORRECT option is not set...
ULWord registerValue
My register value to use in a ReadRegister or WriteRegister call.
bool IsAllocatedBySDK(void) const
ULWord acOptionFlags
AutoCirculate options used when CNTV2Card::AutoCirculateInitForInput or CNTV2Card::AutoCirculateInitF...
NTV2DeviceID
Identifies a specific AJA NTV2 device model number. The NTV2DeviceID is actually the PROM part number...
Definition: ntv2enums.h:20
ULWord registerNumber
My register number to use in a ReadRegister or WriteRegister call.
NTV2Buffer mBuffer
Virtual address of a buffer to prelock, and its length.
bool NTV2DeviceCanDoVideoFormat(const NTV2DeviceID inDeviceID, const NTV2VideoFormat inVideoFormat)
bool NTV2DeviceGetSupportedOutputDests(const NTV2DeviceID inDeviceID, NTV2OutputDestinations &outOutputDests, const NTV2IOKinds inKinds)
Returns a set of distinct NTV2OutputDest values supported on the given device.
ULWord acAncTransferSize
Total ancillary data bytes for field 1 transferred (capture only).
ULWord64 mClientTID
In: client thread identifier.
#define YesNo(__x__)
This is used to perform virtual data reads or writes.
enum NTV2QuarterSizeExpandMode NTV2QtrSizeExpandMode
1920x1080, for 1080i and 1080p, NTV2_VANCMODE_OFF
Definition: ntv2enums.h:354
Declares the AJAThread class.
ULWord mStatus
Action status.
bool PatchRegister(const ULWord inRegNum, const ULWord inValue)
Patches the given register value.
ULWord64 acRDTSCCurrentTime
Timestamp when CNTV2Card::AutoCirculateGetStatus called, using the host OS system clock...
#define NTV2_TYPE_CONFIGINTERRUPT
Identifies NTV2ConfigInterrupt struct.
std::string to_string(bool val)
Definition: common.cpp:180
#define NTV2_IS_ATC_VITC2_TIMECODE_INDEX(__x__)
Definition: ntv2enums.h:3997
#define NTV2_TYPE_ACXFERSTATUS
Identifies AUTOCIRCULATE_TRANSFER_STATUS struct.
NTV2_HEADER mHeader
The common structure header – ALWAYS FIRST!
else
Definition: ntv2vcam.cpp:789
#define AJA_NTV2_SDK_VERSION_MAJOR
The SDK major version number, an unsigned decimal integer.
Definition: ntv2version.h:13
bool WithHDMIAuxData(void) const
NTV2DeviceIDSet::const_iterator NTV2DeviceIDSetConstIter
A convenient const iterator for NTV2DeviceIDSet.
Definition: ntv2utils.h:1100
std::set< std::string > NTV2StringSet
#define NTV2_TYPE_AJABUFFERLOCK
Identifies NTV2BufferLock struct.
std::ostream & Print(std::ostream &inOutStream) const
RGB color space.
Definition: ntv2enums.h:3614
#define NTV2_INPUT_SOURCE_IS_HDMI(_inpSrc_)
Definition: ntv2enums.h:1285
#define AsU8Ref(_x_)
NTV2VideoFormatSet::const_iterator NTV2VideoFormatSetConstIter
A handy const iterator for iterating over an NTV2VideoFormatSet.
bool RPCDecode(const NTV2_RPC_BLOB_TYPE &inBlob, size_t &inOutIndex)
Specifies analog input/output kinds.
Definition: ntv2enums.h:1298
NTV2Buffer & Segment(NTV2Buffer &outPtr, const ULWord inByteOffset, const ULWord inByteCount) const
Resets an NTV2Buffer instance to reference a contiguous segment (portion) of my memory buffer...
void SetFlags(const ULWord inFlags)
Sets the action flags for use in a subsequent call to CNTV2Card::DMABufferLock.
bool RPCDecode(const NTV2_RPC_BLOB_TYPE &inBlob, size_t &inOutIndex)
#define NTV2SDKVersionEncode
bool RPCEncode(NTV2_RPC_BLOB_TYPE &outBlob)
1280x720, for 720p, NTV2_VANCMODE_TALL
Definition: ntv2enums.h:364
NTV2Channel mChannel
Stream channel.
NTV2MailBuffer()
Constructs a default NTV2MailBuffer struct.
#define AJA_NULL
Definition: ajatypes.h:180
#define NTV2_IS_VALID_IOKINDS(_k_)
Definition: ntv2enums.h:1316
NTV2ChannelList NTV2MakeChannelList(const NTV2Channel inFirstChannel, const UWord inNumChannels)
Declares the CRP188 class. See SMPTE RP188 standard for details.
NTV2TimeCodes::const_iterator NTV2TimeCodesConstIter
A handy const interator for iterating over NTV2TCIndex/NTV2TimeCodeList pairs.
NTV2AutoCirculateState acState
Current AutoCirculate state.
bool RPCDecode(const NTV2_RPC_BLOB_TYPE &inBlob, size_t &inOutIndex)
bool RPCDecode(const NTV2_RPC_BLOB_TYPE &inBlob, size_t &inOutIndex)
std::vector< ULWord > NTV2ULWordVector
An ordered sequence of ULWords.
std::string NTV2HDMIProtocolToString(const NTV2HDMIProtocol inValue, const bool inCompactDisplay=false)
Definition: ntv2utils.cpp:6672
std::ostream & Print(std::ostream &inOutStream) const
Prints a human-readable representation of me to the given output stream.
bool SetBuffer(const NTV2Buffer &inBuffer)
Sets the buffer to lock for use in a subsequent call to CNTV2Card::LoadBitstream. ...
Defines for the NTV2 SDK version number, used by ajantv2/includes/ntv2enums.h. See the ajantv2/includ...
enum _INTERRUPT_ENUMS_ INTERRUPT_ENUMS
ULWord64 acAudioClockCurrentTime
The absolute timestamp at the moment the CNTV2Card::AutoCirculateTransfer or CNTV2Card::AutoCirculate...
bool SetFrom(const NTV2Buffer &inBuffer)
Replaces my contents from the given memory buffer without resizing me.
ULWord flags(void) const
NTV2ColorCorrectionMode
Definition: ntv2enums.h:2084
ULWord fTrailerVersion
Trailer version, set when created. Before SDK 15.1: always zero; 15.1 or later: set to calling SDK ve...
bool IsStopped(void) const
NTV2RegisterNumberSet NTV2RegNumSet
A set of distinct NTV2RegisterNumbers.
This is used to atomically perform bank-selected register reads or writes.
ULWord64 acRDTSCStartTime
Timestamp of the first VBI received after CNTV2Card::AutoCirculateStart called, using host OS system ...
std::set< ULWord > ULWordSet
A collection of unique ULWord (uint32_t) values.
ULWord acRequestedFrame
On entry for NTV2_TYPE_ACFRAMESTAMP message, the requested frame. Upon exit, 0xFFFFFFFF means "not ...
ULWord acFramesDropped
Total number of frames dropped since AutoCirculateStart.
bool ImportFromLog(const NTV2StringList &inLogLines)
Resets me using the given "Number:" and "Value:" lines from the support log.
Specifies any/all devices.
Definition: ntv2enums.h:1384
ULWord acAudioTransferSize
Number of bytes captured into the audio buffer.
#define NTV2_TYPE_AJADEBUGLOGGING
Identifies NTV2DebugLogging struct.
bool RPCDecode(const NTV2_RPC_BLOB_TYPE &inBlob, size_t &inOutIndex)
bool RPCDecodeServer(const NTV2_RPC_BLOB_TYPE &inBlob, size_t &inOutIndex)
int64_t LWord64
Definition: ajatypes.h:238
All new NTV2 structs start with this common header.
std::ostream & PrintLog(std::ostream &outputStream, const NTV2DeviceID inDeviceID=DEVICE_ID_INVALID) const
Renders me to the given output stream in "supportlog" format.
static size_t DefaultPageSize(void)
NTV2RegWrites NTV2RegisterReads
static std::string FourCCToString(const ULWord in4CC, const char nonPrintable='?')
ULWord registerShift
My register shift value to use in a ReadRegister or WriteRegister call.
ULWord acSegmentDevicePitch
Offset, in bytes, between the start of one device segment and the start of the next device segment (i...
bool operator<(const NTV2RegInfo &inRHS) const
bool SetFromHexString(const std::string &inStr)
Replaces my contents from the given hex-encoded string, resizing me if necessary. ...
std::vector< uint16_t > UWordSequence
An ordered sequence of UWord (uint16_t) values.
NTV2Buffer mInRegInfos
NTV2RegInfo array of registers be read/written. The SDK owns this memory.
std::set< NTV2FrameGeometry > NTV2GeometrySet
A set of distinct NTV2FrameGeometry values.
std::ostream & Print(std::ostream &inOutStream) const
Prints a human-readable representation of me to the given output stream.
ULWord acAncField2TransferSize
Total ancillary data bytes for field 2 transferred (capture only).
AUTOCIRCULATE_STATUS(const NTV2Crosspoint inCrosspoint=NTV2CROSSPOINT_CHANNEL1)
Constructs a default AUTOCIRCULATE_STATUS struct for the given NTV2Crosspoint.
string NTV2AudioSystemSetToStr(const NTV2AudioSystemSet &inObj, const bool inCompact)
bool RPCDecode(const NTV2_RPC_BLOB_TYPE &inBlob, size_t &inOutIndex)
ULWord64 acAudioClockCurrentTime
Timestamp when CNTV2Card::AutoCirculateGetStatus called, using "64-bit clean" value of the device&#39;s 4...
UWordSequence::const_iterator UWordSequenceConstIter
A handy const iterator for iterating over a UWordSequence.
std::string NTV2HDMIAudioChannelsToString(const NTV2HDMIAudioChannels inValue, const bool inCompactDisplay=false)
Definition: ntv2utils.cpp:6661
std::set< NTV2AudioSystem > NTV2AudioSystemSet
A set of distinct NTV2AudioSystem values. New in SDK 16.2.
std::string NTV2VideoFormatToString(const NTV2VideoFormat inValue, const bool inUseFrameRate=false)
Definition: ntv2utils.cpp:6750
~NTV2ColorCorrectionData()
My destructor, which frees my private color correction table buffer.
NTV2HDMIProtocol
Indicates or specifies the HDMI protocol.
Definition: ntv2enums.h:3627
The AutoCirculate channel is starting, waiting for the start time specified in the call to CNTV2Card:...
bool NTV2GetUnsupportedPixelFormats(NTV2PixelFormats &outFormats)
Returns a set of NTV2PixelFormat values not suported by any NTV2 device.
#define NTV2_IS_VALID_STANDARD(__s__)
Definition: ntv2enums.h:192
#define NTV2_TYPE_ACFRAMESTAMP
Identifies FRAME_STAMP struct.
ULWord acFrameRepeatCount
Intended for playout. The number of times to repeat the frame being transferred.
size_t maxHandleCapacity(void) const
ULWord GetDroppedFrameCount(void) const
Declares data types and structures used in NTV2 "nub" packets.
UWord NTV2DeviceGetNumAnalogVideoOutputs(const NTV2DeviceID inDeviceID)
LWord acTransferFrame
Frame buffer number the frame was transferred to/from. (-1 if failed)
std::string getSourceCode(const bool inInclDecl=true) const
bool isValid(void) const
bool SwapWith(NTV2Buffer &inBuffer)
Swaps my underlying buffer with another&#39;s.
bool RPCEncodeServer(NTV2_RPC_BLOB_TYPE &inBlob)
ULWord64 audioClockCurrentTime
48kHz clock in reg 28 extended to 64 bits
ULWord acCurrentFieldCount
As found by ISR at Call Field0 or Field1 currently being OUTPUT (when CNTV2Card::AutoCirculateGetFram...
void PUSHU16(const uint16_t val, RPCBlob &blob, const bool dontSwap=false)
Pushes a 16-bit value onto the given byte sequence.
Definition: ntv2nubtypes.h:49
#define oOCT(__x__)
The AutoCirculate channel is stopped.
ULWord64 acAudioClockStartTime
Timestamp of the first VBI received after CNTV2Card::AutoCirculateStart called, using "64-bit clean" ...
bool WithRP188(void) const
#define AUTOCIRCULATE_WITH_ANC
Use this to AutoCirculate with ancillary data.
LWord acEndFrame
Last frame to circulate. FIXFIXFIX Why is this signed? CHANGE TO ULWord??
uint64_t ULWord64
Definition: ajatypes.h:239
std::string NTV2TCIndexToString(const NTV2TCIndex inValue, const bool inCompactDisplay=false)
Definition: ntv2utils.cpp:6398
bool RPCEncode(NTV2_RPC_BLOB_TYPE &outBlob)
void Clear(void)
Clears (zeroes) all of my member variables.
NTV2DIDSet::const_iterator NTV2DIDSetConstIter
Handy const iterator to iterate over an NTV2DIDSet.
LWord GetActiveFrame(void) const
std::string NTV2AudioChannelOctetToString(const NTV2Audio8ChannelSelect inValue, const bool inCompactDisplay=false)
Definition: ntv2utils.cpp:6459
ostream & NTV2PrintChannelSet(const NTV2ChannelSet &inObj, const bool inCompact, ostream &inOutStream)
ULWord getDestOffset(void) const
static NTV2StringList IntNames(const uint64_t mask)
bool NTV2DeviceGetSupportedVideoFormats(const NTV2DeviceID inDeviceID, NTV2VideoFormatSet &outFormats)
Returns a set of distinct NTV2VideoFormat values supported on the given device.
bool RPCEncode(NTV2_RPC_BLOB_TYPE &outBlob)
#define NTV2_IS_VALID_STRUCT_TYPE(_x_)
uint8_t UByte
Definition: ajatypes.h:231
NTV2Crosspoint channelSpec
bool IsPageAligned(void) const
This is used by the CNTV2Card::ReadRegisters function.
NTV2Buffer(const void *pInUserPointer, const size_t inByteCount)
Constructs me from a client-supplied address and size.
bool RPCDecodeClient(const NTV2_RPC_BLOB_TYPE &inBlob, size_t &inOutIndex)
1920x1080, NTV2_VANCMODE_TALLER
Definition: ntv2enums.h:359
NTV2_TRAILER mTrailer
The common structure trailer – ALWAYS LAST!
#define NTV2_OUTPUT_DEST_IS_ANALOG(_dest_)
Definition: ntv2enums.h:1349
720x486, for NTSC 525i, NTV2_VANCMODE_TALL
Definition: ntv2enums.h:361
std::string NTV2AudioChannelPairToString(const NTV2AudioChannelPair inValue, const bool inCompactDisplay=false)
Definition: ntv2utils.cpp:6435
ULWord64 acCurrentUserCookie
The frame&#39;s AUTOCIRCULATE_TRANSFER::acInUserCookie value that was set when CNTV2Card::AutoCirculateTr...
ULWord acCurrentLineCount
At Call Line# currently being OUTPUT (at the time of the IOCTL_NTV2_GET_FRAMESTAMP) ...
NTV2Crosspoint backgroundVideoCrosspoint
NTV2_HEADER mHeader
The common structure header – ALWAYS FIRST!
#define NTV2_CURRENT_HEADER_VERSION
Current version of NTV2_HEADER struct, originally 0.
NTV2_HEADER mHeader
The common structure header – ALWAYS FIRST!
std::ostream & PrintCode(std::ostream &outputStream, const int inRadix=16, const NTV2DeviceID inDeviceID=DEVICE_ID_INVALID, const std::string &sCard="card") const
Renders me to the given output stream as source code using a "WriteRegister" function call...
ostream & operator<<(ostream &inOutStream, const NTV2StringList &inData)
void Clear(void)
Clears my data.
LWord acDesiredFrame
Used to specify a different frame in the circulate ring to transfer to/from.
bool NTV2GetSupportedPixelFormats(NTV2PixelFormats &outFormats)
Returns a set of all NTV2PixelFormat values supported (used) by any/all supported NTV2 devices...
void Set(const ULWord inNumSegments, const ULWord inNumActiveBytesPerRow, const ULWord inHostBytesPerRow, const ULWord inDeviceBytesPerRow)
Sets the NTV2SegmentedDMAInfo struct members.
This is used to prelock a video/audio/anc buffer used as the source or target of DMA transfers...
bool NTV2DeviceCanDoInputSource(const NTV2DeviceID inDeviceID, const NTV2InputSource inInputSource)
bool ByteSwap16(void)
Byte-swaps my contents 16-bits at a time.
#define NTV2_OUTPUT_DEST_IS_SDI(_dest_)
Definition: ntv2enums.h:1350
NTV2AutoCirculateState
Describes the state of an AutoCirculate channel. See AUTOCIRCULATE_STATUS.
bool RPCDecode(const NTV2_RPC_BLOB_TYPE &inBlob, size_t &inOutIndex)
#define VIRTUALREG_START
ULWord getTotalElements(void) const
std::ostream & Print(std::ostream &oss) const
#define NTV2_IS_VALID_CHANNEL(__x__)
Definition: ntv2enums.h:1375
Declares the AJAProcess class.
This is used for bitstream maintainance. (New in SDK 16.0)
Describes a user-space buffer on the host computer. I have an address and a length, plus some optional attributes (allocated by SDK?, page-aligned? etc.).
ULWord audioInStartAddress
For record - first position in buffer of audio (includes base offset)
ostream & NTV2PrintULWordVector(const NTV2ULWordVector &inObj, ostream &inOutStream)
NTV2BufferLock()
Constructs a default NTV2BufferLock struct.
std::map< NTV2TCIndex, NTV2_RP188 > NTV2TimeCodes
A mapping of NTV2TCIndex enum values to NTV2_RP188 structures.
bool RPCEncode(NTV2_RPC_BLOB_TYPE &outBlob)
bool RPCEncode(NTV2_RPC_BLOB_TYPE &outBlob)
Identifies SMPTE HD 1080i or 1080psf.
Definition: ntv2enums.h:171
NTV2_HEADER mHeader
The common structure header – ALWAYS FIRST!
std::string NTV2HDMIRangeToString(const NTV2HDMIRange inValue, const bool inCompactDisplay=false)
Definition: ntv2utils.cpp:6683
bool NTV2DeviceGetSupportedPixelFormats(const NTV2DeviceID inDeviceID, NTV2PixelFormats &outFormats)
Returns a set of distinct NTV2FrameBufferFormat values supported on the given device.
static AJAStatus StatTimerStart(const uint32_t inKey)
Definition: debug.cpp:1141
static size_t gDefaultPageSize(AJA_PAGE_SIZE)
uint16_t GetEndFrame(void) const
ULWord acAudioExpectedAddress
Audio transfer address.
NTV2InputSource
Identifies a specific video input source.
Definition: ntv2enums.h:1266
bool RPCEncode(NTV2_RPC_BLOB_TYPE &outBlob, bool fillBuffer=true)
NTV2MessageData(const void *inMessage, const size_t inMessageSize, const ULWord inFlags)
Constructs an NTV2VirtualData struct for reading or writing virtual data.
bool RPCEncode(NTV2_RPC_BLOB_TYPE &outBlob)
NTV2InputSourceSet::const_iterator NTV2InputSourceSetConstIter
A handy const iterator for iterating over an NTV2InputSourceSet.
ULWord acCurrentAudioExpectedAddress
bool PutU32s(const ULWordSequence &inU32s, const size_t inU32Offset=0, const bool inByteSwap=false)
Copies a vector of unsigned 32-bit values into me.
bool GetU8s(UByteSequence &outU8s, const size_t inU8Offset=0, const size_t inMaxSize=128) const
Answers with my contents as a vector of unsigned 8-bit values.
#define AUTOCIRCULATE_WITH_FBOCHANGE
Use this to AutoCirculate with the possibility of frame buffer orientation changes.
bool RPCDecode(const NTV2_RPC_BLOB_TYPE &inBlob, size_t &inOutIndex)
bool RPCDecodeNoAllocate(const NTV2_RPC_BLOB_TYPE &inBlob, size_t &inOutIndex)
#define NTV2_IS_VALID_HEADER_TAG(_x_)
bool RPCEncodeClient(NTV2_RPC_BLOB_TYPE &inBlob)
ostream & NTV2PrintAudioSystemSet(const NTV2AudioSystemSet &inObj, const bool inCompact, std::ostream &inOutStream)
Streams a human-readable dump of the given NTV2AudioSystemSet into the specified output stream...
This object specifies the information that will be transferred to or from the AJA device in the CNTV2...
std::string & strip(std::string &str, const std::string &ws)
Definition: common.cpp:461
bool GetSDIInputStatus(NTV2SDIInputStatus &outStatus, const UWord inSDIInputIndex0=0)
Answers with the NTV2SDIInputStatus for the given SDI input spigot.
bool RPCDecode(const NTV2_RPC_BLOB_TYPE &inBlob, size_t &inOutIndex)
2048x1080, for 2Kx1080p, NTV2_VANCMODE_OFF
Definition: ntv2enums.h:365
bool RPCDecode(const NTV2_RPC_BLOB_TYPE &inBlob, size_t &inOutIndex)
ULWord acFramesProcessed
Total number of frames successfully processed since AutoCirculateStart.
ULWord acStartSample
The actual audio start sample when this frame was started at the VBI, which may be used to check sync...
bool is_hex_digit(const char inChr)
Definition: common.cpp:511
NTV2_HEADER mHeader
The common structure header – ALWAYS FIRST!
bool RPCDecode(const NTV2_RPC_BLOB_TYPE &inBlob, size_t &inOutIndex)
void Clear(void)
Resets the struct to its initialized state.
static std::string GetDisplayValue(const uint32_t inRegNum, const uint32_t inRegValue, const NTV2DeviceID inDeviceID=DEVICE_ID_NOTFOUND)
static size_t HostPageSize(void)
#define DEC(__x__)
NTV2RegisterNumber
#define NTV2SDKVersionDecode_Point
std::ostream & Print(std::ostream &inOutStream) const
Prints a human-readable representation of me to the given output stream.
NTV2FrameGeometry
Identifies a particular video frame geometry.
Definition: ntv2enums.h:352
720x576, for PAL 625i, NTV2_VANCMODE_OFF
Definition: ntv2enums.h:358
bool RPCEncode(NTV2_RPC_BLOB_TYPE &outBlob)
User cookie at last vblank.
NTV2Buffer acANCField2Buffer
The host "Field 2" ancillary data buffer. This field is owned by the client application, and thus is responsible for allocating and/or freeing it. If the pointer is NULL or the size is zero, no "Field 2" ancillary data will be transferred. Use the AUTOCIRCULATE_TRANSFER::SetAncBuffers method to set or reset this field.
FRAME_STAMP & operator=(const FRAME_STAMP &inRHS)
uint64_t clientPID(void) const
std::set< NTV2Channel > NTV2ChannelSet
A set of distinct NTV2Channel values.
NTV2AudioChannelOctets::const_iterator NTV2AudioChannelOctetsConstIter
Handy const iterator to iterate over a set of distinct NTV2AudioChannelOctet values.
std::string NTV2HDMIColorSpaceToString(const NTV2HDMIColorSpace inValue, const bool inCompactDisplay=false)
Definition: ntv2utils.cpp:6694
ULWord mFlags
Action flags (lock, unlock, etc)
uint64_t interruptIDs(void) const
NTV2_TRAILER()
Constructs a default NTV2_TRAILER having the proper version and tag.
uint64_t clientID(void) const
#define NTV2_TYPE_AJASTREAMBUFFER
Identifies NTV2StreamBuffer struct.
void Set(const ULWord inDBB=0xFFFFFFFF, const ULWord inLow=0xFFFFFFFF, const ULWord inHigh=0xFFFFFFFF)
Sets my fields from the given DBB, low and high ULWord components.
Declares numerous NTV2 utility functions.
bool GetU16s(UWordSequence &outU16s, const size_t inU16Offset=0, const size_t inMaxSize=64, const bool inByteSwap=false) const
Answers with my contents as a vector of unsigned 16-bit values.
std::ostream & Print(std::ostream &inOutStream) const
Prints a human-readable representation of me into the given output stream.
NTV2_TRAILER mTrailer
The common structure trailer – ALWAYS LAST!
NTV2Buffer mOutBadRegIndexes
Array of UWords containing index numbers of the register writes that failed. The SDK owns this memory...
#define NTV2Buffer_TO_ULWORD64(__p__)
bool NTV2DeviceGetSupportedGeometries(const NTV2DeviceID inDeviceID, NTV2GeometrySet &outGeometries)
Returns a set of distinct NTV2FrameGeometry values supported on the given device. ...
NTV2Crosspoint foregroundKeyCrosspoint
void swap(nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass > &j1, nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass > &j2) noexcept(//NOLINT(readability-inconsistent-declaration-parameter-name, cert-dcl58-cpp) is_nothrow_move_constructible< nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass > >::value &&//NOLINT(misc-redundant-expression, cppcoreguidelines-noexcept-swap, performance-noexcept-swap) is_nothrow_move_assignable< nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass > >::value)
exchanges the values of two JSON objects
Definition: json.hpp:24538
std::string NTV2CrosspointToString(const NTV2Crosspoint inChannel)
Definition: ntv2utils.cpp:5809
bool Set(const void *pInUserPointer, const size_t inByteCount)
Sets (or resets) me from a client-supplied address and size.
union AutoCircGenericTask::@15 u
ULWord acBufferLevel
Number of buffered frames in driver ready to capture or play.
std::vector< uint64_t > ULWord64Sequence
An ordered sequence of ULWord64 (uint64_t) values.
#define NTV2Buffer_PAGE_ALIGNED
Allocated page-aligned?
NTV2GetRegisters(const NTV2RegNumSet &inRegisterNumbers=NTV2RegNumSet())
Constructs an NTV2GetRegisters struct from the given set of register numbers.
#define AsU64Ref(_x_)
bool operator!=(const NTV2SegmentedXferInfo &inRHS) const
bool NTV2GetSupportedStandards(NTV2StandardSet &outStandards)
Returns a set of all NTV2Standard values supported (used) by any/all supported NTV2 devices...
std::string AsCode(const size_t inBytesPerWord=4, const std::string &inVarName="", const bool inUseSTL=false, const bool inByteSwap=false) const
std::ostream & Print(std::ostream &inOutStream) const
Prints a human-readable representation of me to the given output stream.
string NTV2AutoCirculateStateToString(const NTV2AutoCirculateState inState)
NTV2RegInfo GetRegInfo(const UWord inIndex0=0) const
AUTO_CIRC_COMMAND eCommand
NTV2SDIInputStatus & operator[](const size_t inSDIInputIndex0)
This struct is used to augment the default full-frame AutoCirculate DMA transfer to accommodate multi...
bool GetInputTimeCodes(NTV2TimeCodeList &outValues) const
Intended for capture, answers with the timecodes captured in my acTransferStatus member&#39;s acFrameStam...
bool SetInputTimecode(const NTV2TCIndex inTCNdx, const NTV2_RP188 &inTimecode)
Sets one of my input timecodes.
ULWord acAudioOutStartAddress
(output/playback only) Audio play head position (exclusive) AFTER this frame was stamped.
720x486, for NTSC 525i and 525p60, NTV2_VANCMODE_OFF
Definition: ntv2enums.h:357
ULWord GetFrameCount(void) const
This is returned from the CNTV2Card::AutoCirculateGetStatus function.
NTV2SegmentedXferInfo & reset(void)
Resets me to an invalid (all zero) state.
ULWord mFlags
Action flags.
bool NextDifference(const NTV2Buffer &inBuffer, ULWord &byteOffset) const
Iterates over each byte that differs between myself and the given buffer.
#define AUTOCIRCULATE_WITH_COLORCORRECT
Use this to AutoCirculate with color correction.
bool RPCDecode(const NTV2_RPC_BLOB_TYPE &inBlob, size_t &inOutIndex)
std::vector< NTV2_RP188 > NTV2TimeCodeList
An ordered sequence of zero or more NTV2_RP188 structures. An NTV2TCIndex enum value can be used as a...
virtual std::string do_grouping() const
bool RPCDecode(const NTV2_RPC_BLOB_TYPE &inBlob, size_t &inOutIndex)
NTV2VirtualData(const ULWord inTag, const void *inVirtualData, const size_t inVirtualDataSize, const bool inDoWrite=false)
Constructs an NTV2VirtualData struct for reading or writing virtual data.
std::string NTV2AudioRateToString(const NTV2AudioRate inValue, const bool inForRetailDisplay=false)
Definition: ntv2utils.cpp:5760
NTV2RegisterValueMap::const_iterator NTV2RegValueMapConstIter
A const iterator that iterates over NTV2RegisterValueMap entries.
bool is_legal_decimal_number(const std::string &inStr, size_t inMaxLength)
Definition: common.cpp:526
ULWord acAudioOutStopAddress
(output/playback only) Audio play head position when this frame was stamped.
void Clear(void)
Frees my private color correction table buffer and resets my mode to "invalid".
LWord64 acCurrentFrameTime
The VBI timestamp of the current/active frame currently being ingested on the device (capture)...
uint16_t UWord
Definition: ajatypes.h:234
std::ostream & Print(std::ostream &oStream) const
Prints a human-readable representation of me into the given output stream.
bool SetAndFill(const void *pInUserPointer, const size_t inByteCount, const UByte inValue)
Sets (or resets) me from a client-supplied address and size.
uint16_t U16(const int inIndex) const
NTV2DoubleArray::const_iterator NTV2DoubleArrayConstIter
Handy const iterator to iterate over an NTV2DoubleArray.
std::ostream & Dump(std::ostream &inOutputStream=std::cout, const size_t inStartByteOffset=0, const size_t inByteCount=0, const size_t inRadix=16, const size_t inBytesPerGroup=4, const size_t inGroupsPerLine=8, const size_t inAddressRadix=0, const bool inShowAscii=false, const size_t inAddrOffset=0) const
Dumps me in hex/octal/decimal, with/without Ascii, to the given output stream.
#define OCT(__x__)
ULWord acFramesDropped
Total number of frames dropped since CNTV2Card::AutoCirculateStart called.
NTV2TCIndexes & operator+=(NTV2TCIndexes &inOutSet, const NTV2TCIndexes &inSet)
Appends the given NTV2TCIndexes contents into the given set.
static void FreeAligned(void *pMemory)
Definition: memory.cpp:145
NTV2Buffer acTimeCodes
Intended for capture, this is a sequence of NTV2_RP188 values received from the device (in NTV2TCInde...
std::ostream & Print(std::ostream &inOutStream) const
AUTOCIRCULATE_TRANSFER_STATUS acTransferStatus
Contains status information that&#39;s valid after CNTV2Card::AutoCirculateTransfer returns, including the driver buffer level, number of frames processed or dropped, audio and anc transfer byte counts, and a complete FRAME_STAMP that has even more detailed clocking information.
NTV2_HEADER(const ULWord inStructureType, const ULWord inSizeInBytes)
Constructs a default NTV2_HEADER having the proper tag, version, and the given type and size...
enum _AutoCircCommand_ AUTO_CIRC_COMMAND
NTV2Channel GetChannel(void) const
#define NTV2_ASSERT_STRUCT_VALID
NTV2Buffer mBuffer
Virtual address of a bitstream buffer and its length.
#define xHEX0N(__x__, __n__)
AUTOCIRCULATE_TRANSFER()
Constructs a default AUTOCIRCULATE_TRANSFER struct.
~NTV2Buffer()
My destructor. If I&#39;m responsible for the memory, I free it here.
static std::string GetDisplayName(const uint32_t inRegNum)
~FRAME_STAMP()
My destructor.
#define NTV2_IS_VALID_AUDIO_SYSTEM(__x__)
Definition: ntv2enums.h:3920
ULWord currenthUser
Contains validCount (Play - reps remaining, Record - drops on frame)
bool SetAncBuffers(ULWord *pInANCBuffer, const ULWord inANCByteCount, ULWord *pInANCF2Buffer=NULL, const ULWord inANCF2ByteCount=0)
Sets my ancillary data buffers for use in a subsequent call to CNTV2Card::AutoCirculateTransfer.
std::string NTV2FrameBufferFormatToString(const NTV2FrameBufferFormat inValue, const bool inForRetailDisplay=false)
Definition: ntv2utils.cpp:6940
std::vector< uint8_t > RPCBlob
Definition: ntv2nubtypes.h:19
bool RPCEncode(NTV2_RPC_BLOB_TYPE &outBlob)
uint64_t clientTID(void) const
ULWord getSourcePitch(void) const
NTV2_RP188 acRP188
Deprecated – call FRAME_STAMP::GetInputTimeCode instead.
NTV2GeometrySet GetRelatedGeometries(const NTV2FrameGeometry inFrameGeometry)
Definition: ntv2utils.cpp:4002
#define NTV2_INPUT_SOURCE_IS_ANALOG(_inpSrc_)
Definition: ntv2enums.h:1286
NTV2RegWritesIter NTV2RegisterReadsIter
NTV2RegInfo & setValue(const ULWord val)
bool GetInputTimeCode(NTV2_RP188 &outTimeCode, const NTV2TCIndex inTCIndex=NTV2_TCINDEX_SDI1) const
Intended for capture, answers with a specific timecode captured in my acTransferStatus member&#39;s acFra...
ULWord mIsWriting
If non-zero, register(s) will be written; otherwise, register(s) will be read.
NTV2AudioSystemSet::const_iterator NTV2AudioSystemSetConstIter
A handy const iterator into an NTV2AudioSystemSet. New in SDK 16.2.
NTV2Buffer mInBankInfos
Bank select NTV2RegInfo. The SDK owns this memory.
#define NTV2_TYPE_AJASTREAMCHANNEL
Identifies NTV2StreamChannel struct.
This object is embedded in the AUTOCIRCULATE_TRANSFER struct that&#39;s returned from the CNTV2Card::Auto...
bool SetFromRegValue(const ULWord inData)
Sets my fields from the given status register value.
NTV2_TRAILER mTrailer
The common structure trailer – ALWAYS LAST!
bool ResetUsing(const NTV2RegWrites &inRegWrites)
Resets me, starting over, now using the given NTV2RegisterNumberSet.
ULWord acBufferLevel
The number of frames ready to record/play after the transfer.
ULWord mStatus
Action status.
std::ostream & Print(std::ostream &inOutStream) const
Prints a human-readable representation of me into the given output stream.
bool RPCEncode(NTV2_RPC_BLOB_TYPE &outBlob)
enum NTV2OutputDestination NTV2OutputDest
bool RPCDecode(const NTV2_RPC_BLOB_TYPE &inBlob, size_t &inOutIndex)
bool POPU32(uint32_t &outVal, const RPCBlob &blob, std::size_t &inOutNdx, const bool dontSwap=false)
Pops a 32-bit value off the given byte sequence at the given zero-based index position.
Definition: ntv2nubtypes.h:149
#define AUTOCIRCULATE_STRUCT_VERSION
Version number of AutoCirculate structures, originally 0.
ULWord getSegmentLength(void) const
UWord NTV2DeviceGetNumVideoOutputs(const NTV2DeviceID inDeviceID)
NTV2QuarterSizeExpandMode acVideoQuarterSizeExpand
Turns on the "quarter-size expand" (2x H + 2x V) hardware. Defaults to off (1:1). ...
bool GetRequestedRegisterWrites(NTV2RegWrites &outRegWrites) const
bool isDestBottomUp(void) const
ULWord currentAudioExpectedAddress
As set by play.
Identifies the first analog video input.
Definition: ntv2enums.h:1268
Private include file for all ajabase sources.
This class/object reports information about the current and/or requested AutoCirculate frame...
NTV2Standard GetNTV2StandardFromVideoFormat(const NTV2VideoFormat inVideoFormat)
Definition: ntv2utils.cpp:2375
std::map< NTV2FrameGeometry, ULWord > FGSizesMap
ULWord getSourceOffset(void) const
NTV2ChannelList::const_iterator NTV2ChannelListConstIter
A handy const iterator into an NTV2ChannelList.
NTV2AudioRate
Definition: ntv2enums.h:1933
std::vector< uint32_t > ULWordSequence
An ordered sequence of ULWord (uint32_t) values.
RP188_STRUCT currentRP188
Last vertical blank timecode (RP-188)
ULWord mFlags
In: option flags.
static void * AllocateAligned(size_t size, size_t alignment)
Definition: memory.cpp:115
ULWord acAudioInStartAddress
(input/ingest/capture only) Starting audio record head position when this frame was stamped...
#define NTV2_IS_VALID_VIDEO_FORMAT(__f__)
Definition: ntv2enums.h:729
std::vector< NTV2Channel > NTV2ChannelList
An ordered sequence of NTV2Channel values.
std::string & upper(std::string &str)
Definition: common.cpp:442
std::string join(const std::vector< std::string > &parts, const std::string &delim)
Definition: common.cpp:468
#define AUTOCIRCULATE_WITH_VIDPROC
Use this to AutoCirculate with video processing.
NTV2_HEADER acHeader
The common structure header – ALWAYS FIRST!
#define NTV2_TYPE_SETREGS
Identifies NTV2SetRegisters struct.
bool GetU32s(ULWordSequence &outU32s, const size_t inU32Offset=0, const size_t inMaxSize=32, const bool inByteSwap=false) const
Answers with my contents as a vector of unsigned 32-bit values.
ULWord64Sequence::const_iterator ULWord64SequenceConstIter
A handy const iterator for iterating over a ULWord64Sequence.
static ULWord FGHeight(const NTV2FrameGeometry fg)
ULWord acSegmentHostPitch
Offset, in bytes, between the start of one host segment and the start of the next host segment (i...
ULWord fLo
| BG 4 | Secs10 | BG 3 | Secs 1 | BG 2 | Frms10 | BG 1 | Frms 1 |
std::set< NTV2DeviceID > NTV2DeviceIDSet
A set of NTV2DeviceIDs.
Definition: ntv2utils.h:1098
uint64_t U64(const int inIndex) const
bool RPCEncode(NTV2_RPC_BLOB_TYPE &outBlob)
void * GetHostPointer(void) const
NTV2ColorCorrectionData()
Constructs a default NTV2ColorCorrectionData struct.
bool WithColorCorrect(void) const
NTV2SegmentedXferInfo & setDestDirection(const bool inTopDown)
Sets the scan direction for the destination.
NTV2Bitstream()
Constructs a default NTV2Bitstream struct.
#define NTV2_IS_VALID_FRAME_BUFFER_FORMAT(__s__)
Definition: ntv2enums.h:267
void Reset(void)
Resets the NTV2SegmentedDMAInfo struct members to their default values (normal, non-segmented AutoCir...
bool GetRingChangedByteRange(const NTV2Buffer &inBuffer, ULWord &outByteOffsetFirst, ULWord &outByteOffsetLast) const
Assuming my contents and the contents of the given buffer comprise ring buffers that periodically get...
bool POPU64(uint64_t &outVal, const RPCBlob &blob, std::size_t &inOutNdx, const bool dontSwap=false)
Pops a 64-bit value off the given byte sequence at the given zero-based index position.
Definition: ntv2nubtypes.h:171
ULWord64 acAudioClockTimeStamp
(input/ingest/capture only) The absolute timestamp at the VBI when the frame started recording into d...
This is used by the CNTV2Card::ReadSDIStatistics function.
string CommaStr(const T &inNum)
2048x1556, for 2Kx1556psf film format, NTV2_VANCMODE_TALL
Definition: ntv2enums.h:367
NTV2Buffer acAudioBuffer
The host audio buffer. This field is owned by the client application, and thus is responsible for all...
static const NTV2_RP188 INVALID_TIMECODE_VALUE
static std::string IntName(const INTERRUPT_ENUMS id)
NTV2TCIndexes::const_iterator NTV2TCIndexesConstIter
Color correction data used with AUTOCIRCULATE_WITH_COLORCORRECT option.
static const string sSegXferUnits[]
std::vector< std::string > NTV2StringList
ULWord64 mClientPID
In: client process identifier.
bool SetFrom(const FRAME_STAMP_STRUCT &inOldStruct)
Sets my fields from the given FRAME_STAMP_STRUCT.
std::ostream & print(std::ostream &oss) const
prints a human-readable representation of me to the given output stream
std::set< NTV2AudioChannelOctet > NTV2AudioChannelOctets
A set of distinct NTV2AudioChannelOctet values.
bool GetInputTimeCode(NTV2_RP188 &outTimeCode, const NTV2TCIndex inTCIndex=NTV2_TCINDEX_SDI1) const
Answers with a specific timecode captured in my acTimeCodes member.
#define HEX0N(__x__, __n__)
Definition: debug.cpp:1181
#define NTV2Buffer_ALLOCATED
Allocated using Allocate function?
std::ostream & Print(std::ostream &inOutStream) const
bool GetU64s(ULWord64Sequence &outU64s, const size_t inU64Offset=0, const size_t inMaxSize=16, const bool inByteSwap=false) const
Answers with my contents as a vector of unsigned 16-bit values.
#define NTV2_IS_VALID_COLOR_CORRECTION_MODE(__x__)
Definition: ntv2enums.h:2094
#define NTV2SDKVersionDecode_Build
uint8_t U8(const int inIndex) const
ULWord audioOutStopAddress
For play - first position in buffer of audio.
std::vector< NTV2RegInfo > NTV2RegisterWrites
#define OCT0N(__x__, __n__)
#define AUTOCIRCULATE_WITH_RP188
Use this to AutoCirculate with RP188.
bool RPCEncode(NTV2_RPC_BLOB_TYPE &outBlob)
LWord64 currentFrameTime
Vertical blank start of current frame.
std::string NTV2ChannelToString(const NTV2Channel inValue, const bool inForRetailDisplay=false)
Definition: ntv2utils.cpp:5731
bool ByteSwap64(void)
Byte-swaps my contents 64-bits at a time.
#define NTV2_INPUT_SOURCE_IS_SDI(_inpSrc_)
Definition: ntv2enums.h:1287
std::string & lower(std::string &str)
Definition: common.cpp:436
NTV2StreamChannel()
Constructs a default NTV2StreamChannel struct.
std::ostream & Print(std::ostream &inOutStream) const
Prints a human-readable representation of me to the given output stream.
NTV2RegWrites NTV2RegReads
An ordered sequence of zero or more NTV2RegInfo structs intended for ReadRegister.
void * GetHostAddress(const ULWord inByteOffset, const bool inFromEnd=false) const
bool RPCEncode(NTV2_RPC_BLOB_TYPE &outBlob)
bool SetAudioBuffer(ULWord *pInAudioBuffer, const ULWord inAudioByteCount)
Sets my audio buffer for use in a subsequent call to CNTV2Card::AutoCirculateTransfer.
ULWord acNumSegments
Number of segments of size ::AUTOCIRCULATE_TRANSFER::acVideoBuffer.fByteCount to transfer. Zero or 1 means normal (unsegmented) transfer.
NTV2AudioChannelPairs::const_iterator NTV2AudioChannelPairsConstIter
Handy const iterator to iterate over a set of distinct NTV2AudioChannelPair values.
#define NTV2EndianSwap16(__val__)
Definition: ntv2endian.h:15
bool NTV2DeviceGetSupportedFrameRates(const NTV2DeviceID inDeviceID, NTV2FrameRateSet &outRates)
Returns a set of distinct NTV2FrameRate values supported on the given device.
NTV2Channel mChannel
Mail buffer channel.
ostream & NTV2PrintChannelList(const NTV2ChannelList &inObj, const bool inCompact, ostream &inOutStream)
720x576, for PAL 625i, NTV2_VANCMODE_TALLER
Definition: ntv2enums.h:370
Declares enums and structs used by all platform drivers and the SDK.
NTV2Crosspoint backgroundKeyCrosspoint
ULWord mOperation
In: requested operation.
NTV2AudioSystem acAudioSystem
The audio system being used for this channel (NTV2_AUDIOSYSTEM_INVALID if none)
#define NTV2SDKVersionDecode_Major
#define HEX(__x__)
NTV2Buffer acANCBuffer
The host ancillary data buffer. This field is owned by the client application, and thus is responsibl...
#define DECN(__x__, __n__)
AutoCircTaskType taskType
#define AUTOCIRCULATE_WITH_FIELDS
Use this to AutoCirculate with fields as frames for interlaced formats.
NTV2Buffer mInRegInfos
Read-only array of NTV2RegInfo structs to be set. The SDK owns this memory.
NTV2Buffer ccLookupTables
RGB lookup tables pre-formatted for AJA hardware as a contiguous block of NTV2_COLORCORRECTOR_TABLESI...
ULWord mStatus
Action status.
bool NTV2DeviceGetSupportedInputSources(const NTV2DeviceID inDeviceID, NTV2InputSourceSet &outInputSources, const NTV2IOKinds inKinds)
Returns a set of distinct NTV2InputSource values supported on the given device.
bool SetAllOutputTimeCodes(const NTV2_RP188 &inTimecode, const bool inIncludeF2=true)
Intended for playout, replaces all elements of my acOutputTimeCodes member with the given timecode va...
std::string & replace(std::string &str, const std::string &from, const std::string &to)
Definition: common.cpp:110
std::ostream & Print(std::ostream &inOutStream) const
Prints a human-readable representation of me to the given output stream.
#define AUTOCIRCULATE_WITH_HDMIAUX
Use this to AutoCirculate with HDMI auxiliary data.
bool IsFieldMode(void) const
#define NTV2_TRAILER_TAG
Identifies the struct trailer.
bool WithFBFChange(void) const
#define NTV2_IS_VALID_NTV2FrameGeometry(__s__)
Definition: ntv2enums.h:384
NTV2Crosspoint acCrosspoint
The crosspoint (channel number with direction)
ULWord fTrailerTag
A special FourCC to identify the tail end of an NTV2 structure.
NTV2SDIInputStatus()
Constructs a default NTV2SDIInputStatus.
This is used to enable or disable AJADebug logging in the driver.
ULWord mOutNumFailures
The number of registers unsuccessfully written.
NTV2Crosspoint foregroundVideoCrosspoint
ULWord fHi
| BG 8 | Hrs 10 | BG 7 | Hrs 1 | BG 6 | Mins10 | BG 5 | Mins 1 |
bool PutU8s(const UByteSequence &inU8s, const size_t inU8Offset=0)
Copies a vector of unsigned 8-bit values into me.
NTV2HDMIBitDepth
Indicates or specifies the HDMI video bit depth.
Definition: ntv2enums.h:3698
#define NTV2_IS_REGISTER_TASK(_x_)
#define NTV2EndianSwap32(__val__)
Definition: ntv2endian.h:19
ULWord acNumActiveBytesPerRow
Number of active bytes in a row of video.
bool POPU16(uint16_t &outVal, const RPCBlob &blob, std::size_t &inOutNdx, const bool dontSwap=false)
Pops a 16-bit value off the given byte sequence at the given zero-based index position.
Definition: ntv2nubtypes.h:128
NTV2RegInfo & setShift(const ULWord val)
bool SetBuffer(const NTV2Buffer &inBuffer)
Sets the buffer to lock for use in a subsequent call to CNTV2Card::DMABufferLock. ...
#define AJA_NTV2_SDK_VERSION_MINOR
The SDK minor version number, an unsigned decimal integer.
Definition: ntv2version.h:14
uint16_t GetStartFrame(void) const
Declares device capability functions.
#define NTV2_IS_VALID_NTV2FrameRate(__r__)
Definition: ntv2enums.h:448
bool WithVidProc(void) const
NTV2Channel NTV2CrosspointToNTV2Channel(const NTV2Crosspoint inCrosspointChannel)
Definition: ntv2utils.cpp:4712
ULWord acFramesProcessed
Total number of frames successfully processed since CNTV2Card::AutoCirculateStart called...
ULWord getSegmentCount(void) const
NTV2_HEADER mHeader
The common structure header – ALWAYS FIRST!
ULWord64 GetRawHostPointer(void) const
720x486, for NTSC 525i and 525p60, NTV2_VANCMODE_TALLER
Definition: ntv2enums.h:369
std::set< UByte > NTV2DIDSet
A set of distinct NTV2DID values.
std::ostream & Print(std::ostream &inOutStream) const
Prints a human-readable representation of me to the given output stream.
NTV2DebugLogging(const bool inEnable=false)
Constructs an NTV2DebugLogging struct.
This is used by the CNTV2Card::WriteRegisters function.
bool SetVideoBuffer(ULWord *pInVideoBuffer, const ULWord inVideoByteCount)
Sets my video buffer for use in a subsequent call to CNTV2Card::AutoCirculateTransfer.
std::string NTV2FrameRateToString(const NTV2FrameRate inValue, const bool inForRetailDisplay=false)
Definition: ntv2utils.cpp:7012
NTV2_TRAILER mTrailer
The common structure trailer – ALWAYS LAST!
ULWord64 audioClockTimeStamp
48kHz clock (in reg 28, extended to 64 bits) at time of play or record.
bool SegmentedDMAsEnabled(void) const
enum NTV2TCIndex NTV2TimecodeIndex
ULWord acTotalBytesTransferred
Total audio and video bytes transferred.
NTV2FrameBufferFormatSetConstIter NTV2PixelFormatsConstIter
ULWord NTV2IOKinds
Definition: ntv2enums.h:1314
bool RPCEncode(NTV2_RPC_BLOB_TYPE &outBlob)
Declares the CNTV2RegisterExpert class.
INTERRUPT_ENUMS interruptID(void) const
bool isDestTopDown(void) const
All new NTV2 structs end with this common trailer.
static uint64_t GetThreadId()
Definition: thread.cpp:180
NTV2_TRAILER acTrailer
The common structure trailer – ALWAYS LAST!
ULWord acFrame
(input/ingest/capture only) Current/active frame number.
NTV2FrameGeometry GetNTV2FrameGeometryFromVideoFormat(const NTV2VideoFormat inVideoFormat)
Definition: ntv2utils.cpp:2644
ULWord currentFieldCount
At Call Field0 or Field1 currently being OUTPUT (at the time of the IOCTL_NTV2_GET_FRAMESTAMP) ...
void PUSHU64(const uint64_t val, RPCBlob &blob, const bool dontSwap=false)
Pushes a 64-bit value onto the given byte sequence.
Definition: ntv2nubtypes.h:78
NTV2SegmentedDMAInfo acInSegmentedDMAInfo
Optional segmented DMA info, for use with specialized data transfers.