AJA NTV2 SDK  18.1.0.2262
NTV2 SDK 18.1.0.2262
ntv2supportlogger.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MIT */
7 #include "ntv2supportlogger.h"
8 #include "ntv2devicescanner.h"
9 #include "ntv2devicefeatures.h"
10 #include "ntv2konaflashprogram.h"
11 #include "ntv2registerexpert.h"
12 #include "ntv2rp188.h"
13 #include "ajabase/common/common.h"
14 #include "ajabase/persistence/persistence.h"
15 #include "ajabase/system/info.h"
16 #include <algorithm>
17 #include <sstream>
18 #include <vector>
19 #include <iterator>
20 
21 #if defined(MSWindows)
22  #define PATH_DELIMITER "\\"
23 #else
24  #define PATH_DELIMITER "/"
25 #endif
26 
27 using namespace std;
28 
29 
30 typedef map <NTV2Channel, AUTOCIRCULATE_STATUS> ChannelToACStatus;
31 typedef ChannelToACStatus::const_iterator ChannelToACStatusConstIter;
32 typedef pair <NTV2Channel, AUTOCIRCULATE_STATUS> ChannelToACStatusPair;
33 typedef map <uint16_t, NTV2TimeCodeList> FrameToTCList;
34 typedef FrameToTCList::const_iterator FrameToTCListConstIter;
35 typedef pair <uint16_t, NTV2TimeCodeList> FrameToTCListPair;
36 typedef map <NTV2Channel, FrameToTCList> ChannelToPerFrameTCList;
37 typedef ChannelToPerFrameTCList::const_iterator ChannelToPerFrameTCListConstIter;
38 typedef pair <NTV2Channel, FrameToTCList> ChannelToPerFrameTCListPair;
39 
40 
41 static string makeHeader(ostringstream & oss, const string & inName)
42 {
43  oss << setfill('=') << setw(96) << " " << inName << ":" << setfill(' ') << endl << endl;
44  return oss.str();
45 }
46 
47 static string timecodeToString (const NTV2_RP188 & inRP188)
48 {
49  ostringstream oss;
50  if (inRP188.IsValid())
51  {
52  const CRP188 foo(inRP188);
53  oss << foo;
54  }
55  else
56  oss << "---";
57  return oss.str();
58 }
59 
60 static string pidToString (const uint32_t inPID)
61 {
62  ostringstream oss;
63  #if defined (MSWindows)
64  oss << inPID;
65  //TCHAR filename [MAX_PATH];
66  //HANDLE processHandle (OpenProcess (PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, inPID));
67  //if (processHandle)
68  //{
69  // if (GetModuleFileNameEx (processHandle, NULL, filename, MAX_PATH))
70  // oss << " (" << filename << ")";
71  // CloseHandle (processHandle);
72  //}
73  #elif defined (AJALinux)
74  oss << inPID;
75  #elif defined (AJAMac)
76  oss << inPID;
77  // char pathbuf [PROC_PIDPATHINFO_MAXSIZE];
78  // const int rc (::proc_pidpath (pid_t (inPID), pathbuf, sizeof (pathbuf)));
79  // if (rc == 0 && ::strlen (pathbuf))
80  // oss << " (" << string (pathbuf) << ")";
81  #else
82  oss << inPID;
83  #endif
84  return oss.str();
85 }
86 
87 // NTV2_AUDIO_BUFFER_SIZE_8MB 8MB buffer: 16-ch: 130,560 samples 8-ch: 261,120 samples 6-ch: 348,160 samples
88 // NTV2_AUDIO_BUFFER_SIZE_4MB 4MB buffer: 0x00400000(4,194,304 bytes) - 0x00004000(16,384 bytes) = 0x003FC000(4,177,920 bytes) 16-ch: 65,280 samples 8-ch: 130,560 samples 6-ch: 174,080 samples
89 // NTV2_AUDIO_BUFFER_SIZE_2MB 2MB buffer: 16-ch: 32,640 samples 8-ch: 65,280 samples 6-ch: 87,040 samples
90 // NTV2_AUDIO_BUFFER_SIZE_1MB 1MB buffer: 16-ch: 16,320 samples 8-ch: 32,640 samples 6-ch: 43,520 samples
91 // Returns the maximum number of samples for a given NTV2AudioBufferSize and maximum audio channel count...
92 static uint32_t maxSampleCountForNTV2AudioBufferSize (const NTV2AudioBufferSize inBufferSize, const uint16_t inChannelCount)
93 { // NTV2_AUDIO_BUFFER_SIZE_1MB NTV2_AUDIO_BUFFER_SIZE_4MB NTV2_AUDIO_BUFFER_SIZE_2MB NTV2_AUDIO_BUFFER_SIZE_8MB NTV2_AUDIO_BUFFER_INVALID
94  static uint32_t gMaxSampleCount16 [] = { 16320, 65280, 32640, 130560, 0 };
95  static uint32_t gMaxSampleCount8 [] = { 32640, 130560, 65280, 261120, 0 };
96  static uint32_t gMaxSampleCount6 [] = { 87040, 174080, 87040, 348160, 0 };
97  if (NTV2_IS_VALID_AUDIO_BUFFER_SIZE (inBufferSize))
98  switch (inChannelCount)
99  {
100  case 16: return gMaxSampleCount16 [inBufferSize];
101  case 8: return gMaxSampleCount8 [inBufferSize];
102  case 6: return gMaxSampleCount6 [inBufferSize];
103  default: break;
104  }
105  return 0;
106 }
107 
108 static NTV2VideoFormat getVideoFormat (CNTV2Card & device, const NTV2Channel inChannel)
109 {
111  device.GetVideoFormat(result, inChannel);
112  return result;
113 }
114 
115 static NTV2PixelFormat getPixelFormat (CNTV2Card & device, const NTV2Channel inChannel)
116 {
118  device.GetFrameBufferFormat(inChannel, result);
119  return result;
120 }
121 
122 static NTV2Mode getMode (CNTV2Card & device, const NTV2Channel inChannel)
123 {
124  NTV2Mode result(NTV2_MODE_INVALID);
125  device.GetMode(inChannel, result);
126  return result;
127 }
128 
129 static bool isEnabled (CNTV2Card & device, const NTV2Channel inChannel)
130 {
131  bool result(false);
132  device.IsChannelEnabled(inChannel, result);
133  return result;
134 }
135 
136 static ULWord getActiveFrame (CNTV2Card & device, const NTV2Channel inChannel)
137 {
138  ULWord frameNum(0);
139  if (NTV2_IS_INPUT_MODE(::getMode(device, inChannel)))
140  device.GetInputFrame(inChannel, frameNum);
141  else
142  device.GetOutputFrame(inChannel, frameNum);
143  return frameNum;
144 }
145 
146 static string getActiveFrameStr (CNTV2Card & device, const NTV2Channel inChannel)
147 {
148  if (!isEnabled(device, inChannel))
149  return "---";
150  ostringstream oss;
151  oss << DEC(::getActiveFrame(device, inChannel));
152  return oss.str();
153 }
154 
156 {
157  ULWord result(0);
158  if (NTV2_IS_OUTPUT_MODE (mode))
159  device.ReadAudioLastOut (result, audioSystem); // read head
160  else
161  device.ReadAudioLastIn (result, audioSystem); // write head
162  return result;
163 }
164 
165 static ULWord getNumAudioChannels (CNTV2Card & device, NTV2AudioSystem audioSystem)
166 {
167  ULWord numChannels = 1;
168  device.GetNumberAudioChannels(numChannels, audioSystem);
169  return numChannels;
170 }
171 
172 static ULWord bytesToSamples (CNTV2Card & device, NTV2AudioSystem audioSystem, const ULWord inBytes)
173 {
174  return inBytes / sizeof (uint32_t) / getNumAudioChannels(device, audioSystem);
175 }
176 
178 {
179  ULWord bytes = readCurrentAudioPosition(device, audioSystem, mode);
180  return bytesToSamples(device, audioSystem, bytes);
181 }
182 
183 static ULWord getMaxNumSamples (CNTV2Card & device, NTV2AudioSystem audioSystem)
184 {
185  NTV2AudioBufferSize bufferSize;
186  device.GetAudioBufferSize(bufferSize, audioSystem);
187 
188  return maxSampleCountForNTV2AudioBufferSize (bufferSize, uint16_t(getNumAudioChannels(device, audioSystem)));
189 }
190 
192 {
193  for (UWord chan (0); chan < ::NTV2DeviceGetNumVideoChannels (device.GetDeviceID()); chan++)
194  if (device.AutoCirculateGetStatus (NTV2Channel(chan), outStatus))
195  if (!outStatus.IsStopped())
196  if (outStatus.GetAudioSystem() == audioSystem)
197  {
199  device.GetMode(NTV2Channel(chan), mode);
200  if ((outStatus.IsInput() && NTV2_IS_INPUT_MODE (mode))
201  || (outStatus.IsOutput() && NTV2_IS_OUTPUT_MODE (mode)))
202  return NTV2Channel(chan);
203  }
204  return NTV2_CHANNEL_INVALID;
205 }
206 
207 static bool detectInputChannelPairs (CNTV2Card & device, const NTV2AudioSource inAudioSource,
208  const NTV2EmbeddedAudioInput inEmbeddedSource,
209  NTV2AudioChannelPairs & outChannelPairsPresent)
210 {
211  outChannelPairsPresent.clear();
212  switch (inAudioSource)
213  {
214  default: return false;
215 
216  case NTV2_AUDIO_EMBEDDED: return NTV2_IS_VALID_EMBEDDED_AUDIO_INPUT (inEmbeddedSource)
217  // Input detection is based on the audio de-embedder (as opposed to the SDI spigot)...
218  ? device.GetDetectedAudioChannelPairs (NTV2AudioSystem(inEmbeddedSource), outChannelPairsPresent)
219  : false;
220 
221  case NTV2_AUDIO_AES: return device.GetDetectedAESChannelPairs (outChannelPairsPresent);
222 
225  {outChannelPairsPresent.insert(NTV2_AudioChannel1_2); return true;} // Assume chls 1&2 if an analog signal present
226  break;
227 
229  {
231  if (!device.GetHDMIInputAudioChannels (hdmiChls))
232  return false;
235  chPair = NTV2AudioChannelPair(chPair + 1))
236  outChannelPairsPresent.insert (chPair);
237  return true;
238  }
239  break;
240  }
241  return false;
242 }
243 
244 static bool getBitfileDate (CNTV2Card & device, string & outDateString, NTV2XilinxFPGA whichFPGA)
245 {
246  BITFILE_INFO_STRUCT bitFileInfo;
247  memset(&bitFileInfo, 0, sizeof(BITFILE_INFO_STRUCT));
248  bitFileInfo.whichFPGA = whichFPGA;
249  bool bBitFileInfoAvailable = false; // BitFileInfo is implemented only on 5.2 and later drivers.
250  bBitFileInfoAvailable = device.DriverGetBitFileInformation(bitFileInfo);
251  if( bBitFileInfoAvailable )
252  {
253  outDateString = bitFileInfo.designNameStr;
254  if (outDateString.find(".ncd") != string::npos)
255  {
256  outDateString = outDateString.substr(0, outDateString.find(".ncd"));
257  outDateString += ".bit ";
258  outDateString += bitFileInfo.dateStr;
259  outDateString += " ";
260  outDateString += bitFileInfo.timeStr;
261  }
262  else if (outDateString.find(";") != string::npos)
263  {
264  outDateString = outDateString.substr(0, outDateString.find(";"));
265  outDateString += ".bit ";
266  outDateString += bitFileInfo.dateStr;
267  outDateString += " ";
268  outDateString += bitFileInfo.timeStr;
269  }
270  else if (outDateString.find(".bit") != string::npos && outDateString != ".bit")
271  {
272  outDateString = bitFileInfo.designNameStr;
273  outDateString += " ";
274  outDateString += bitFileInfo.dateStr;
275  outDateString += " ";
276  outDateString += bitFileInfo.timeStr;
277  }
278  else
279  {
280  outDateString = "bad bitfile date string";
281  return false;
282  }
283  }
284  else
285  return false;
286  return true;
287 }
288 
289 AJAExport ostream & operator << (ostream & outStream, const CNTV2SupportLogger & inData)
290 {
291  outStream << inData.ToString();
292  return outStream;
293 }
294 
296  : mDevice (card),
297  mDispose (false),
298  mSections (sections)
299 {
300 }
301 
303  : mDevice (*(new CNTV2Card(cardIndex))),
304  mDispose (true),
305  mSections (sections)
306 {
307 }
308 
310 {
311  if (mDispose)
312  delete &mDevice;
313 }
314 
316 {
317  // Bump this whenever the formatting of the support log changes drastically
318  return 2;
319 }
320 
321 void CNTV2SupportLogger::PrependToSection (uint32_t section, const string & sectionData)
322 {
323  if (mPrependMap.find(section) != mPrependMap.end())
324  {
325  mPrependMap.at(section).insert(0, "\n");
326  mPrependMap.at(section).insert(0, sectionData);
327  }
328  else
329  {
330  mPrependMap[section] = sectionData;
331  mPrependMap.at(section).append("\n");
332  }
333 }
334 
335 void CNTV2SupportLogger::AppendToSection (uint32_t section, const string & sectionData)
336 {
337  if (mAppendMap.find(section) != mAppendMap.end())
338  {
339  mAppendMap.at(section).append("\n");
340  mAppendMap.at(section).append(sectionData);
341  }
342  else
343  {
344  mAppendMap[section] = "\n";
345  mAppendMap.at(section).append(sectionData);
346  }
347 }
348 
349 void CNTV2SupportLogger::AddHeader (const string & sectionName, const string & sectionData)
350 {
351  ostringstream oss;
352  makeHeader(oss, sectionName);
353  oss << sectionData << "\n";
354  mHeaderStr.append(oss.str());
355 }
356 
357 void CNTV2SupportLogger::AddFooter (const string & sectionName, const string & sectionData)
358 {
359  ostringstream oss;
360  makeHeader(oss, sectionName);
361  oss << sectionData << "\n";
362  mFooterStr.append(oss.str());
363 }
364 
365 // Use this macro to handle generating text for each section
366 // - the header
367 // - the prepend if any
368 // - the method that fills the section
369 // - the append if any
370 #define LoggerSectionToFunctionMacro(_SectionEnum_, _SectionString_, _SectionMethod_) \
371  if (mSections & _SectionEnum_) \
372  { \
373  makeHeader(oss, _SectionString_); \
374  if (mPrependMap.find(_SectionEnum_) != mPrependMap.end()) \
375  oss << mPrependMap.at(_SectionEnum_); \
376  \
377  _SectionMethod_(oss); \
378  \
379  if (mAppendMap.find(_SectionEnum_) != mAppendMap.end()) \
380  oss << mAppendMap.at(_SectionEnum_); \
381  }
382 
383 string CNTV2SupportLogger::ToString (void) const
384 {
385  ostringstream oss;
386  vector<char> dateBufferLocal(128, 0);
387  vector<char> dateBufferUTC(128, 0);
388 
389  // get the wall time and format it
390  time_t now = time(AJA_NULL);
391  struct tm *localTimeinfo;
392  localTimeinfo = localtime(reinterpret_cast<const time_t*>(&now));
393  strcpy(&dateBufferLocal[0], "");
394  if (localTimeinfo)
395  ::strftime(&dateBufferLocal[0], dateBufferLocal.size(), "%B %d, %Y %I:%M:%S %p %Z (local)", localTimeinfo);
396 
397  struct tm *utcTimeinfo;
398  utcTimeinfo = gmtime(reinterpret_cast<const time_t*>(&now));
399  strcpy(&dateBufferUTC[0], "");
400  if (utcTimeinfo)
401  ::strftime(&dateBufferUTC[0], dateBufferUTC.size(), "%Y-%m-%dT%H:%M:%SZ UTC", utcTimeinfo);
402 
403  oss << "Begin NTV2 Support Log" << "\n" <<
404  "Version: " << CNTV2SupportLogger::Version() << "\n"
405  "Generated: " << &dateBufferLocal[0] <<
406  " " << &dateBufferUTC[0] << "\n\n" << flush;
407 
408  if (!mHeaderStr.empty())
409  oss << mHeaderStr;
410 
411  // Go ahead and show info even if the device is not open
413 
414  if (mDevice.IsOpen())
415  {
416  LoggerSectionToFunctionMacro(NTV2_SupportLoggerSectionAutoCirculate, "AutoCirculate", FetchAutoCirculateLog)
420  }
421 
422  if (!mFooterStr.empty())
423  oss << mFooterStr;
424  oss << endl << "End NTV2 Support Log";
425  return oss.str();
426 }
427 
428 void CNTV2SupportLogger::ToString (string & outString) const
429 {
430  outString = ToString();
431 }
432 
433 static inline string HEX0NStr (const uint32_t inNum, const uint16_t inWidth) {ostringstream oss; oss << HEX0N(inNum,inWidth); return oss.str();}
434 static inline string xHEX0NStr(const uint32_t inNum, const uint16_t inWidth) {ostringstream oss; oss << xHEX0N(inNum,inWidth); return oss.str();}
435 template <typename T> string DECStr (const T inT) {ostringstream oss; oss << DEC(inT); return oss.str();}
436 
437 void CNTV2SupportLogger::FetchInfoLog (ostringstream & oss) const
438 {
439  string str;
440  AJALabelValuePairs infoTable;
441  AJASystemInfo::append(infoTable, "SDK/DRIVER INFO", "");
442  AJASystemInfo::append(infoTable, "NTV2 SDK Version", ::NTV2GetVersionString(true));
443  AJASystemInfo::append(infoTable, "supportlog Built", string(__DATE__ " at " __TIME__));
444  if (mDevice.IsOpen())
445  {
446  AJASystemInfo::append(infoTable, "Driver Version", mDevice.GetDriverVersionString());
447  #if defined(AJAMac)
448  ULWord drvrType(0), dextType(0x44455854); // 'DEXT'
449  mDevice.ReadRegister(kVRegDriverType, drvrType);
450  if (!drvrType)
451  str = "Kernel Extension ('KEXT')";
452  else if (drvrType == dextType)
453  str = "DriverKit ('DEXT')";
454  else
455  { ostringstream oss;
456  oss << "(Unknown/Invalid " << xHEX0N(drvrType,8) << ")";
457  str = oss.str();
458  }
459  AJASystemInfo::append(infoTable, "Driver Type", str);
460  #endif // defined(AJAMac)
461  }
462  AJASystemInfo::append(infoTable, "Watcher Nub Protocol Version", "Built-in RPC support");
463 
464  if (mDevice.IsOpen())
465  {
466  AJASystemInfo::append(infoTable, "DEVICE INFO", "");
467  AJASystemInfo::append(infoTable, "Device", mDevice.GetDisplayName());
468  str = xHEX0NStr(mDevice.GetDeviceID(),8) + " (" + string(::NTV2DeviceIDString(mDevice.GetDeviceID())) + ")";
469  AJASystemInfo::append(infoTable, "Device ID", str);
470  AJASystemInfo::append(infoTable, "Serial Number", (mDevice.GetSerialNumberString(str) ? str : "Not programmed"));
471  AJASystemInfo::append(infoTable, "Video Bitfile", (getBitfileDate(mDevice, str, eFPGAVideoProc) ? str : "Not available"));
472  AJASystemInfo::append(infoTable, "PCI FPGA Version", mDevice.GetPCIFPGAVersionString());
473  ULWord numBytes(0);
474  string dateStr, timeStr, connType;
475  if (mDevice.GetInstalledBitfileInfo(numBytes, dateStr, timeStr))
476  {
477  AJASystemInfo::append(infoTable, "Installed Bitfile ByteCount", DECStr(numBytes));
478  AJASystemInfo::append(infoTable, "Installed Bitfile Build Date", dateStr + " " + timeStr);
479  }
480 
481  if (mDevice.features().HasLPProductCode())
482  {
483  AJASystemInfo::append(infoTable, "URL INFO", "");
484  std::string urlString;
485  bool hasIP = mDevice.GetLPTunnelConfigurationURLString(urlString);
486  AJASystemInfo::append(infoTable, "Tunnel URL", hasIP ? urlString : "No URL");
487  hasIP = mDevice.GetLPExternalConfigurationURLString(urlString);
488  AJASystemInfo::append(infoTable, "External URL", hasIP ? urlString : "No URL");
489  std::vector<std::string> sfpURLStings;
490  int numSFPs = mDevice.GetSFPConfigurationURLStrings(sfpURLStings);
491  for (int i = 0; i < numSFPs; i++)
492  {
493  AJASystemInfo::append(infoTable, "SFP URL", sfpURLStings[i]);
494  }
495  }
496 #if 0 // IP10G purge
497  if (mDevice.features().CanDoIP())
498  {
499  PACKAGE_INFO_STRUCT pkgInfo;
500  if (mDevice.GetPackageInformation(pkgInfo))
501  {
502  AJASystemInfo::append(infoTable, "Package", pkgInfo.packageNumber);
503  AJASystemInfo::append(infoTable, "Build", pkgInfo.buildNumber);
504  AJASystemInfo::append(infoTable, "Build Date", pkgInfo.date);
505  AJASystemInfo::append(infoTable, "Build Time", pkgInfo.time);
506  }
507 
508  CNTV2KonaFlashProgram ntv2Card(mDevice.GetIndexNumber());
509  MacAddr mac1, mac2;
510  if (ntv2Card.ReadMACAddresses(mac1, mac2))
511  {
512  AJASystemInfo::append(infoTable, "MAC1", mac1.AsString());
513  AJASystemInfo::append(infoTable, "MAC2", mac2.AsString());
514  }
515 
516  ULWord cfg(0);
517  mDevice.ReadRegister((kRegSarekFwCfg + SAREK_REGS), cfg);
518  if (cfg & SAREK_2022_2)
519  {
520  ULWord dnaLo(0), dnaHi(0);
521  if (ntv2Card.ReadRegister(kRegSarekDNALow + SAREK_REGS, dnaLo))
522  if (ntv2Card.ReadRegister(kRegSarekDNAHi + SAREK_REGS, dnaHi))
523  AJASystemInfo::append(infoTable, "Device DNA", string(HEX0NStr(dnaHi,8)+HEX0NStr(dnaLo,8)));
524  }
525 
526  string licenseInfo;
527  ntv2Card.ReadLicenseInfo(licenseInfo);
528  AJASystemInfo::append(infoTable, "License", licenseInfo);
529 
530  if (cfg & SAREK_2022_2)
531  {
532  ULWord licenseStatus(0);
533  ntv2Card.ReadRegister(kRegSarekLicenseStatus + SAREK_REGS, licenseStatus);
534  AJASystemInfo::append(infoTable, "License Present", licenseStatus & SAREK_LICENSE_PRESENT ? "Yes" : "No");
535  AJASystemInfo::append(infoTable, "License Status", licenseStatus & SAREK_LICENSE_VALID ? "License is valid" : "License NOT valid");
536  AJASystemInfo::append(infoTable, "License Enable Mask", xHEX0NStr(licenseStatus & 0xff,2));
537  }
538  } // if IsIPDevice
539 #endif // IP10G purge
540  #if defined(AJAMac)
541  connType = mDevice.GetConnectionType();
542  if (!connType.empty())
543  AJASystemInfo::append(infoTable, "Driver Connection", connType);
544  #endif // AJAMac
545  if (mDevice.IsRemote())
546  {
547  if (!mDevice.GetHostName().empty())
548  AJASystemInfo::append(infoTable, "Host Name", mDevice.GetHostName());
549  if (!mDevice.GetDescription().empty())
550  AJASystemInfo::append(infoTable, "Device Description", mDevice.GetDescription());
551  }
552  } // if IsOpen
553 
554  AJASystemInfo hostInfo;
555 
556  // append the system info from AJASystemInfo
557  AJASystemInfo::append(infoTable, "HOST INFO");
558  hostInfo.GetLabelValuePairs(infoTable, false);
559 
560  // append the health status of the persistence database files
561  std::vector<std::pair<std::string, bool> > persistenceChecks;
562  persistenceChecks.push_back(std::pair<std::string, bool>("User Persistence Health", false));
563  persistenceChecks.push_back(std::pair<std::string, bool>("System Persistence Health", true));
564  std::vector<std::pair<std::string, bool> >::const_iterator it(persistenceChecks.begin());
565  int errCode = 0;
566  std::string errMessage;
567  for (; it != persistenceChecks.end(); ++it)
568  {
569  std::string label(it->first);
570  bool shared(it->second);
571  AJAPersistence p("com.aja.devicesettings", "Unknown", "00000000", shared);
572  if (p.StorageHealthCheck(errCode, errMessage))
573  {
574  AJASystemInfo::append(infoTable, label, "exists and is good");
575  }
576  else
577  {
578  if (shared && errCode == -1)
579  AJASystemInfo::append(infoTable, label, "doesn't exist (this one is optional)");
580  else
581  AJASystemInfo::append(infoTable, label, std::string("err(") + aja::to_string(errCode) + ") '" + errMessage + "'");
582  }
583  }
584 
585  oss << AJASystemInfo::ToString(infoTable) << endl;
586 
587  if (mDevice.IsOpen() && mDevice.IsRemote())
588  {
589  const NTV2Dictionary params (mDevice.ConnectParams());
590  if (!params.empty())
591  {
592  infoTable.clear();
593  AJASystemInfo::append(infoTable, "CONNECT PARAMETERS");
594  const NTV2StringSet kys(params.keys());
595  for (NTV2StringSetConstIter pKey(kys.begin()); pKey != kys.end(); ++pKey)
596  AJASystemInfo::append(infoTable, *pKey, params.valueForKey(*pKey));
597  oss << AJASystemInfo::ToString(infoTable) << endl;
598  }
599  } // if remote/virtual/software device
600 } // FetchInfoLog
601 
602 
603 void CNTV2SupportLogger::FetchRegisterLog (ostringstream & oss) const
604 {
605  NTV2RegisterReads regs;
606  const NTV2DeviceID deviceID (mDevice.GetDeviceID());
608  static const string sDashes (96, '-');
609 
611  oss << endl << deviceRegs.size() << " Device Registers " << sDashes << endl << endl;
612  regs = ::FromRegNumSet (deviceRegs);
613  if (!mDevice.ReadRegisters (regs))
614  oss << "## NOTE: Driver failed to return one or more registers (those will be zero)" << endl;
615  for (NTV2RegisterReadsConstIter it (regs.begin()); it != regs.end(); ++it)
616  {
617  oss << endl;
618  it->PrintLog(oss, deviceID);
619  }
620 } // FetchRegisterLog
621 
622 
623 void CNTV2SupportLogger::FetchAutoCirculateLog (ostringstream & oss) const
624 {
625  ULWord appSignature (0);
626  int32_t appPID (0);
627  ChannelToACStatus perChannelStatus; // Per-channel AUTOCIRCULATE_STATUS
628  ChannelToPerFrameTCList perChannelTCs; // Per-channel collection of per-frame TCs
629  NTV2TaskMode taskMode (NTV2_DISABLE_TASKS);
630  const NTV2DeviceID deviceID (mDevice.GetDeviceID());
631  const ULWord numChannels (::NTV2DeviceGetNumVideoChannels(deviceID));
632  static const string dashes (25, '-');
633 
634  // This code block takes a snapshot of the current AutoCirculate state of the device...
635  mDevice.GetTaskMode(taskMode);
637 
638  // Grab A/C status for each channel...
639  for (NTV2Channel chan(NTV2_CHANNEL1); chan < NTV2Channel(numChannels); chan = NTV2Channel(chan+1))
640  {
641  FrameToTCList perFrameTCs;
642  AUTOCIRCULATE_STATUS acStatus;
643  mDevice.AutoCirculateGetStatus (chan, acStatus);
645  mDevice.WaitForInputVerticalInterrupt(chan);
646  else
647  mDevice.WaitForOutputVerticalInterrupt(chan);
648  mDevice.AutoCirculateGetStatus (chan, acStatus);
649  perChannelStatus.insert(ChannelToACStatusPair(chan, acStatus));
650  if (!acStatus.IsStopped())
651  {
652  for (uint16_t frameNum (acStatus.GetStartFrame()); frameNum <= acStatus.GetEndFrame(); frameNum++)
653  {
654  FRAME_STAMP frameStamp;
655  NTV2TimeCodeList timecodes;
656  mDevice.AutoCirculateGetFrameStamp (chan, frameNum, frameStamp);
657  frameStamp.GetInputTimeCodes(timecodes);
658  perFrameTCs.insert(FrameToTCListPair(frameNum, timecodes));
659  } // for each A/C frame
660  perChannelTCs.insert(ChannelToPerFrameTCListPair(chan, perFrameTCs));
661  } // if not stopped
662  } // for each channel
663 
664  bool multiFormatMode(false);
665  if (::NTV2DeviceCanDoMultiFormat(deviceID) && mDevice.GetMultiFormatMode(multiFormatMode))
666  {
667  if (!multiFormatMode)
668  oss << "UniFormat: " << ::NTV2VideoFormatToString(::getVideoFormat(mDevice, NTV2_CHANNEL1)) << endl;
669  else
670  oss << "MultiFormat Mode" << endl;
671  }
672  else
673  oss << "Board Format: " << ::NTV2VideoFormatToString(::getVideoFormat(mDevice, NTV2_CHANNEL1)) << endl;
674 
675  oss << "Task mode: " << ::NTV2TaskModeToString(taskMode) << ", PID=" << pidToString(uint32_t(appPID)) << ", signature: " << NTV2_HEADER::FourCCToString(appSignature) << endl
676  << endl
677  << "Chan/FrameStore State Start End Act FrmProc FrmDrop BufLvl Audio RP188 LTC FBFch FBOch Color VidPr Anc HDMIx Field VidFmt PixFmt" << endl
678  << "-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------" << endl;
679  for (ChannelToACStatusConstIter iter (perChannelStatus.begin()); iter != perChannelStatus.end(); ++iter)
680  {
681  const NTV2Channel chan(iter->first);
682  const AUTOCIRCULATE_STATUS & status(iter->second);
683  // The following should mirror what ntv2watcher/pages/page_autocirculate::fetchSupportLogInfo does...
684  oss << ::NTV2ChannelToString(chan, true) << ": "
685  << (::isEnabled(mDevice,chan) ? NTV2_IS_INPUT_MODE(::getMode(mDevice,chan)) ? "Input " : "Output" : "Off ")
686  << setw(12) << status[0] // State
687  << setw( 7) << status[1] // Start
688  << setw( 6) << status[2] // End
689  << setw( 6) << (status.IsStopped() ? ::getActiveFrameStr(mDevice,chan) : status[4]) // Act
690  << setw(10) << status[9] // FrmProc
691  << setw(10) << status[10] // FrmDrop
692  << setw( 7) << status[11] // BufLvl
693  << setw( 9) << status[12] // Audio
694  << setw( 8) << status[13] // RP188
695  << setw( 8) << status[14] // LTC
696  << setw( 8) << status[15] // FBFchg
697  << setw( 8) << status[16] // FBOchg
698  << setw( 8) << status[17] // ColCor
699  << setw( 8) << status[18] // VidProc
700  << setw( 8) << status[19] // Anc
701  << setw( 8) << status[20] // HDMIAux
702  << setw( 8) << status[21]; // Fld
703  if (!status.IsStopped() || isEnabled(mDevice,chan))
704  oss << setw(12) << ::NTV2VideoFormatToString(::getVideoFormat(mDevice, chan))
705  << setw(13) << ::NTV2FrameBufferFormatToString(::getPixelFormat(mDevice, chan), true)
706  << endl;
707  else
708  oss << setw(12) << "---"
709  << setw(13) << "---"
710  << endl;
711  if (!status.IsStopped() && status.WithAudio())
712  { // Not stopped and AutoCirculating audio -- check if audio buffer capacity will be exceeded...
713  ULWord audChlsPerSample(0);
716  mDevice.GetNumberAudioChannels (audChlsPerSample, status.GetAudioSystem());
717  if (mDevice.GetFrameRate (fr, status.GetChannel()) && NTV2_IS_SUPPORTED_NTV2FrameRate(fr))
718  if (mDevice.GetAudioRate (ar, status.GetAudioSystem()) && NTV2_IS_VALID_AUDIO_RATE(ar))
719  {
720  const double framesPerSecond (double(::GetScaleFromFrameRate(fr)) / 100.00);
721  const double samplesPerSecond (double(::GetAudioSamplesPerSecond(ar)));
722  const double bytesPerChannel (4.0);
723  const double channelsPerSample (double(audChlsPerSample+0));
724  const double bytesPerFrame (samplesPerSecond * bytesPerChannel * channelsPerSample / framesPerSecond);
725  const ULWord maxVideoFrames (4UL * 1024UL * 1024UL / ULWord(bytesPerFrame));
726  if (status.GetFrameCount() > maxVideoFrames)
727  oss << "## WARNING: " << DEC(status.GetFrameCount()) << " frames (" << DEC(status.GetStartFrame())
728  << " thru " << DEC(status.GetEndFrame()) << ") exceeds " << DEC(maxVideoFrames)
729  << "-frame max audio buffer capacity" << endl;
730  }
731  }
732  } // for each channel
733 
734  SDRAMAuditor ramMapper;
735  oss << endl << "Device SDRAM Map (8MB frms):" << endl;
736  ramMapper.AssessDevice(mDevice, /* ignore unused audio buffers */ true);
737  ramMapper.DumpBlocks(oss);
738  oss << endl;
739 
740  // Dump the A/C timecodes...
741  for (ChannelToACStatusConstIter iter (perChannelStatus.begin()); iter != perChannelStatus.end(); ++iter)
742  {
743  const NTV2Channel chan(iter->first);
744  const AUTOCIRCULATE_STATUS & status(iter->second);
745  if (status.IsStopped())
746  continue; // Not initialized/started/paused/running -- skip this channel
747 
748  ChannelToPerFrameTCListConstIter it(perChannelTCs.find(chan));
749  if (it == perChannelTCs.end())
750  continue; // Channel not in perChannelTCs
751 
752  const FrameToTCList perFrameTCs(it->second);
753  oss << endl << dashes << " " << (NTV2_IS_INPUT_CROSSPOINT(status.acCrosspoint) ? "Input " : "Output ") << DEC(chan+1) << " Per-Frame Valid Timecodes:" << endl;
754  for (FrameToTCListConstIter i(perFrameTCs.begin()); i != perFrameTCs.end(); ++i)
755  {
756  const uint16_t frameNum(i->first);
757  const NTV2TimeCodeList & timecodes(i->second);
758  oss << "Frame " << frameNum << ":" << endl;
759  for (uint16_t tcNdx(0); tcNdx < timecodes.size(); tcNdx++)
760  {
761  const NTV2_RP188 tcVal(timecodes[tcNdx]);
762  if (!tcVal.IsValid())
763  continue; // skip invalid timecodes
764  const string tcStr (timecodeToString(tcVal));
765  oss << "\t" << setw(10) << ::NTV2TCIndexToString(NTV2TimecodeIndex(tcNdx), true) << setw(0) << ":\t"
766  << setw(12) << tcStr << setw(0) << "\t" << tcVal << endl;
767  } // for each timecode
768  } // for each frame
769  } // for each channel
770 } // FetchAutoCirculateLog
771 
772 
773 void CNTV2SupportLogger::FetchAudioLog (ostringstream & oss) const
774 {
775  const NTV2DeviceID devID (mDevice.GetDeviceID());
776  const UWord maxNumChannels (::NTV2DeviceGetMaxAudioChannels(devID));
777  const UWord numAudSys (::NTV2DeviceGetNumAudioSystems(devID));
778  oss << " Device:\t" << mDevice.GetDisplayName() << endl;
779 
780  // loop over all the audio systems
781  for (NTV2AudioSystem audSys(NTV2_AUDIOSYSTEM_1); audSys < NTV2AudioSystem(numAudSys); audSys = NTV2AudioSystem(audSys+1))
782  {
783  AUTOCIRCULATE_STATUS acStatus;
784  NTV2Channel acChan (findActiveACChannel(mDevice, audSys, acStatus));
785  if (acChan != NTV2_CHANNEL_INVALID)
786  {
787  NTV2AudioSource audioSource (NTV2_AUDIO_EMBEDDED);
789  mDevice.GetAudioSystemInputSource(audSys, audioSource, embeddedSource);
791  mDevice.GetMode(acChan, mode);
792  NTV2AudioRate audioRate (NTV2_AUDIO_48K);
793  mDevice.GetAudioRate(audioRate, audSys);
794  NTV2AudioBufferSize audioBufferSize;
795  mDevice.GetAudioBufferSize(audioBufferSize, audSys);
797  mDevice.GetAudioLoopBack(loopbackMode, audSys);
798 
799  NTV2AudioChannelPairs channelPairsPresent;
800  if (NTV2_IS_INPUT_MODE(mode))
801  {
802  detectInputChannelPairs(mDevice, audioSource, embeddedSource, channelPairsPresent);
803  }
804  else if (NTV2_IS_OUTPUT_MODE(mode))
805  {
806  bool isEmbedderEnabled = false;
807  mDevice.GetSDIOutputAudioEnabled(NTV2Channel(audSys), isEmbedderEnabled);
808  UWord inChannelCount = isEmbedderEnabled ? maxNumChannels : 0;
809 
810  // Generates a NTV2AudioChannelPairs set for the given number of audio channels...
811  for (UWord audioChannel (0); audioChannel < inChannelCount; audioChannel++)
812  {
813  if (audioChannel & 1)
814  continue;
815  channelPairsPresent.insert(NTV2AudioChannelPair(audioChannel/2));
816  }
817  }
818 
819  if (::NTV2DeviceCanDoPCMDetection(devID))
820  mDevice.GetInputAudioChannelPairsWithPCM(acChan, channelPairsPresent);
821 
822  NTV2AudioChannelPairs nonPCMChannelPairs;
823  mDevice.GetInputAudioChannelPairsWithoutPCM(acChan, nonPCMChannelPairs);
824  bool isNonPCM (true);
825  //end temp
826 
827  const ULWord currentPosSampleNdx (getCurrentPositionSamples(mDevice, audSys, mode));
828  const ULWord maxSamples (getMaxNumSamples(mDevice, audSys));
829  oss << endl
830  << " Audio system:\t" << ::NTV2AudioSystemToString (audSys, true) << endl
831  << " Sample Rate:\t" << ::NTV2AudioRateToString (audioRate, true) << endl
832  << " Buffer Size:\t" << ::NTV2AudioBufferSizeToString (audioBufferSize, true) << endl
833  << " Audio Channels:\t" << getNumAudioChannels(mDevice, audSys);
834  if (getNumAudioChannels(mDevice, audSys) == maxNumChannels)
835  oss << " (max)" << endl;
836  else
837  oss << " (" << maxNumChannels << " (max))" << endl;
838  oss << " Total Samples:\t[" << DEC0N(maxSamples,6) << "]" << endl
839  << " Direction:\t" << ::NTV2ModeToString (mode, true) << endl
840  << " AutoCirculate:\t" << ::NTV2ChannelToString (acChan, true) << endl
841  << " Loopback Mode:\t" << ::NTV2AudioLoopBackToString (loopbackMode, true) << endl;
842  if (NTV2_IS_INPUT_MODE(mode))
843  {
844  oss << "Write Head Position:\t[" << DEC0N(currentPosSampleNdx,6) << "]" << endl
845  << " Audio source:\t" << ::NTV2AudioSourceToString(audioSource, true);
846  if (NTV2_AUDIO_SOURCE_IS_EMBEDDED(audioSource))
847  oss << " (" << ::NTV2EmbeddedAudioInputToString(embeddedSource, true) << ")";
848  oss << endl
849  << " Channels Present:\t" << channelPairsPresent << endl
850  << " Non-PCM Channels:\t" << nonPCMChannelPairs << endl;
851  }
852  else if (NTV2_IS_OUTPUT_MODE(mode))
853  {
854  oss << " Read Head Position:\t[" << DEC0N(currentPosSampleNdx,6) << "]" << endl;
855  if (::NTV2DeviceCanDoPCMControl(mDevice.GetDeviceID()))
856  oss << " Non-PCM Channels:\t" << nonPCMChannelPairs << endl;
857  else
858  oss << " Non-PCM Channels:\t" << (isNonPCM ? "All Channel Pairs" : "Normal") << endl;
859  }
860  }
861  }
862 } // FetchAudioLog
863 
864 void CNTV2SupportLogger::FetchRoutingLog (ostringstream & oss) const
865 {
866  // Dump routing info...
867  CNTV2SignalRouter router;
868  mDevice.GetRouting (router);
869  oss << "(NTV2InputCrosspointID <== NTV2OutputCrosspointID)" << endl;
870  router.Print (oss, false);
871  oss << endl;
884 }
885 
887 {
889  string registerStr;
890 };
892 {
991 };
992 
993 bool CNTV2SupportLogger::LoadFromLog (const string & inLogFilePath, const bool bForceLoad)
994 {
995  ifstream fileInput;
996  fileInput.open(inLogFilePath.c_str());
997  string lineContents;
998  int i = 0, numLines = 0;
999  int size = sizeof(registerToLoadStrings)/sizeof(registerToLoadString);
1000  string searchString;
1001  bool isCompatible = false;
1002 
1003  while(getline(fileInput, lineContents))
1004  numLines++;
1005  if(size > numLines)
1006  return false;
1007  fileInput.clear();
1008  fileInput.seekg(0, ios::beg);
1009  while(getline(fileInput, lineContents) && i < size && !bForceLoad)
1010  {
1011  searchString = "Device: ";
1012  searchString.append(NTV2DeviceIDToString(mDevice.GetDeviceID()));
1013  if (lineContents.find(searchString, 0) != string::npos)
1014  {
1015  cout << NTV2DeviceIDToString(mDevice.GetDeviceID()) << " is compatible with the log." << endl;
1016  isCompatible = true;
1017  break;
1018  }
1019  else
1020  {
1021  continue;
1022  }
1023  }
1024 
1025  if(!isCompatible)
1026  return false;
1027 
1028  while(i < size)
1029  {
1030  getline(fileInput, lineContents);
1031  if(fileInput.eof())
1032  {
1033  //Did not find the register reset stream to begin
1034  fileInput.clear();
1035  fileInput.seekg(0, ios::beg);
1036  i++;
1037  continue;
1038  }
1039  searchString = "Register Name: ";
1040  searchString.append(registerToLoadStrings[i].registerStr);
1041  if (lineContents.find(searchString, 0) != string::npos)
1042  {
1043  getline(fileInput, lineContents);
1044  getline(fileInput, lineContents);
1045  searchString = "Register Value: ";
1046  size_t start = lineContents.find(searchString);
1047  if(start != string::npos)
1048  {
1049  size_t end = lineContents.find(" : ");
1050  stringstream registerValueString(lineContents.substr(start + searchString.length(), end));
1051  uint32_t registerValue = 0;
1052  registerValueString >> registerValue;
1053  cout << "Writing register: " << registerToLoadStrings[i].registerStr << " " << registerValue << endl;
1054  mDevice.WriteRegister(registerToLoadStrings[i].registerNum, registerValue);
1055  }
1056  else
1057  {
1058  cout << "The format of the log file is not compatible with this option." << endl;
1059  return false;
1060  }
1061  }
1062  else
1063  {
1064  continue;
1065  }
1066  i++;
1067  }
1068 
1069  return true;
1070 }
1071 
1072 string CNTV2SupportLogger::InventLogFilePathAndName (CNTV2Card & inDevice, const string inPrefix, const string inExtension) // STATIC
1073 {
1074  string homePath;
1075  AJASystemInfo info;
1076  time_t rawtime;
1077  ostringstream oss;
1078  const string deviceName (CNTV2DeviceScanner::GetDeviceRefName(inDevice));
1079 
1080  info.GetValue(AJA_SystemInfoTag_Path_UserHome, homePath);
1081  if (!homePath.empty())
1082  oss << homePath << PATH_DELIMITER;
1083  oss << inPrefix << "_" << deviceName << "_" << ::time(&rawtime) << "." << inExtension;
1084  return oss.str();
1085 }
1086 
1087 bool CNTV2SupportLogger::DumpDeviceSDRAM (CNTV2Card & inDevice, const string & inFilePath, ostream & msgStrm) // STATIC
1088 {
1089  if (!inDevice.IsOpen())
1090  return false;
1091  if (inFilePath.empty())
1092  return false;
1094  const ULWord maxBytes(::NTV2DeviceGetActiveMemorySize(inDevice.GetDeviceID()));
1095  inDevice.GetFrameBufferSize(NTV2_CHANNEL1, frmsz);
1096  const ULWord byteCount(::NTV2FramesizeToByteCount(frmsz)), megs(byteCount/1024/1024), numFrames(maxBytes / byteCount);
1097  NTV2Buffer buffer(byteCount);
1098  NTV2ULWordVector goodFrames, badDMAs, badWrites;
1099  ofstream ofs(inFilePath.c_str(), ofstream::out | ofstream::binary);
1100  if (!ofs)
1101  {msgStrm << "## ERROR: Unable to open '" << inFilePath << "' for writing" << endl; return false;}
1102 
1103  for (ULWord frameNdx(0); frameNdx < numFrames; frameNdx++)
1104  {
1105  if (!inDevice.DMAReadFrame(frameNdx, buffer, byteCount, NTV2_CHANNEL1))
1106  {badDMAs.push_back(frameNdx); continue;}
1107  if (!ofs.write(buffer, streamsize(buffer.GetByteCount())).good())
1108  {badWrites.push_back(frameNdx); continue;}
1109  goodFrames.push_back(frameNdx);
1110  } // for each frame
1111  if (!badDMAs.empty())
1112  {
1113  msgStrm << "## ERROR: DMARead failed for " << DEC(badDMAs.size()) << " " << DEC(megs) << "MB frame(s): ";
1114  ::NTV2PrintULWordVector(badDMAs, msgStrm); msgStrm << endl;
1115  }
1116  if (!badWrites.empty())
1117  {
1118  msgStrm << "## ERROR: Write failures for " << DEC(badWrites.size()) << " " << DEC(megs) << "MB frame(s): ";
1119  ::NTV2PrintULWordVector(badWrites, msgStrm); msgStrm << endl;
1120  }
1121  msgStrm << "## NOTE: " << DEC(goodFrames.size()) << " x " << DEC(megs) << "MB frames from device '"
1122  << CNTV2DeviceScanner::GetDeviceRefName(inDevice) << "' written to '" << inFilePath << "'" << endl;
1123  return true;
1124 }
NTV2RegisterNumber registerNum
std::string NTV2AudioBufferSizeToString(const NTV2AudioBufferSize inValue, const bool inForRetailDisplay=false)
Definition: ntv2utils.cpp:5772
#define NTV2_IS_INPUT_MODE(__mode__)
Definition: ntv2enums.h:1251
std::string NTV2AudioSystemToString(const NTV2AudioSystem inValue, const bool inCompactDisplay=false)
Definition: ntv2utils.cpp:5748
virtual bool IsSupported(const NTV2BoolParamID inParamID)
NTV2AudioSystem
Used to identify an Audio System on an NTV2 device. See Audio System Operation for more information...
Definition: ntv2enums.h:3898
virtual bool GetLPTunnelConfigurationURLString(std::string &outURLString)
Definition: ntv2card.cpp:462
map< NTV2Channel, FrameToTCList > ChannelToPerFrameTCList
virtual bool GetMultiFormatMode(bool &outIsEnabled)
Answers if the device is operating in multiple-format per channel (independent channel) mode or not...
virtual bool GetAudioLoopBack(NTV2AudioLoopBack &outMode, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_1)
Answers if NTV2AudioLoopBack mode is currently on or off for the given NTV2AudioSystem.
Definition: ntv2audio.cpp:322
std::string NTV2ModeToString(const NTV2Mode inValue, const bool inCompactDisplay=false)
Definition: ntv2utils.cpp:6496
virtual bool GetVideoFormat(NTV2VideoFormat &outValue, NTV2Channel inChannel=NTV2_CHANNEL1)
virtual bool GetDetectedAESChannelPairs(NTV2AudioChannelPairs &outDetectedChannelPairs)
Answers which AES/EBU audio channel pairs are present on the device.
Definition: ntv2audio.cpp:1439
#define Enum2Str(e)
Definition: ntv2utils.h:24
virtual ~CNTV2SupportLogger()
My default destructor.
NTV2AudioBufferSize
Represents the size of the audio buffer used by a device audio system for storing captured samples or...
Definition: ntv2enums.h:1917
static ULWord getNumAudioChannels(CNTV2Card &device, NTV2AudioSystem audioSystem)
#define DEC0N(__x__, __n__)
bool NTV2DeviceCanDoPCMControl(const NTV2DeviceID inDeviceID)
static string HEX0NStr(const uint32_t inNum, const uint16_t inWidth)
I interrogate and control an AJA video/audio capture/playout device.
Definition: ntv2card.h:28
NTV2FrameBufferFormat
Identifies a particular video frame buffer pixel format. See Device Frame Buffer Formats for details...
Definition: ntv2enums.h:221
NTV2TaskMode
Describes the task mode state. See also: NTV2 Device Sharing.
Obtain audio samples from the device AES inputs, if available.
Definition: ntv2enums.h:2011
bool AssessDevice(CNTV2Card &inDevice, const bool inIgnoreStoppedAudioBuffers=(0))
Assesses the given device.
Definition: ntv2card.cpp:607
NTV2StringSet::const_iterator NTV2StringSetConstIter
Obtain audio samples from the device HDMI input, if available.
Definition: ntv2enums.h:2013
ULWord NTV2DeviceGetActiveMemorySize(const NTV2DeviceID inDeviceID)
virtual UWord GetIndexNumber(void) const
enum _NTV2VideoFormat NTV2VideoFormat
Identifies a particular video format.
size_t GetByteCount(void) const
Audits an NTV2 device&#39;s SDRAM utilization, and can report contiguous regions of SDRAM, whether unused/free, those being read/written by AutoCirculate, those being read/written by non-AutoCirculating FrameStores, those that are in conflict (AutoCirculate, FrameStore and/or Audio collisions), plus invalid/out-of-bounds regions being accessed.
Definition: ntv2card.h:6946
Declares the CNTV2SupportLogger class.
#define NTV2_IS_VALID_AUDIO_RATE(_x_)
Definition: ntv2enums.h:1940
static std::string InventLogFilePathAndName(CNTV2Card &inDevice, std::string inPrefix="aja_supportlog", std::string inExtension="log")
virtual bool GetAudioSystemInputSource(const NTV2AudioSystem inAudioSystem, NTV2AudioSource &outAudioSource, NTV2EmbeddedAudioInput &outEmbeddedSource)
Answers with the device&#39;s current NTV2AudioSource (and also possibly its NTV2EmbeddedAudioInput) for ...
Definition: ntv2audio.cpp:516
bool NTV2DeviceCanDoMultiFormat(const NTV2DeviceID inDeviceID)
virtual bool GetAudioRate(NTV2AudioRate &outRate, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_1)
Returns the current NTV2AudioRate for the given Audio System.
Definition: ntv2audio.cpp:227
bool IsValid(void) const
Answers true if I&#39;m valid, or false if I&#39;m not valid.
virtual bool GetOutputFrame(const NTV2Channel inChannel, ULWord &outValue)
Answers with the current output frame number for the given FrameStore (expressed as an NTV2Channel)...
std::ostream & NTV2PrintULWordVector(const NTV2ULWordVector &inObj, std::ostream &inOutStream=std::cout)
Streams a human-readable dump of the given NTV2ULWordVector into the specified output stream...
#define NTV2_IS_VALID_AUDIO_BUFFER_SIZE(_x_)
Definition: ntv2enums.h:1928
static bool isEnabled(CNTV2Card &device, const NTV2Channel inChannel)
std::vector< AJALabelValuePair > AJALabelValuePairs
An ordered sequence of label/value pairs.
Definition: info.h:71
virtual bool GetInputAudioChannelPairsWithoutPCM(const NTV2Channel inSDIInputConnector, NTV2AudioChannelPairs &outChannelPairs)
For the given SDI input (specified as a channel number), returns the set of audio channel pairs that ...
Definition: ntv2audio.cpp:1604
static ULWord getCurrentPositionSamples(CNTV2Card &device, NTV2AudioSystem audioSystem, NTV2Mode mode)
Obtain audio samples from the audio that&#39;s embedded in the video HANC.
Definition: ntv2enums.h:2010
static ULWord readCurrentAudioPosition(CNTV2Card &device, NTV2AudioSystem audioSystem, NTV2Mode mode)
#define NTV2_AUDIO_SOURCE_IS_EMBEDDED(_x_)
Definition: ntv2enums.h:2019
FrameToTCList::const_iterator FrameToTCListConstIter
static string makeHeader(ostringstream &oss, const string &inName)
virtual std::string GetConnectionType(void) const
virtual bool GetFrameBufferSize(const NTV2Channel inChannel, NTV2Framesize &outValue)
Answers with the frame size currently being used on the device.
Generates a standard support log (register log) for any NTV2 device attached to the host...
Definition: json.hpp:5362
NTV2HDMIAudioChannels
Indicates or specifies the HDMI audio channel count.
Definition: ntv2enums.h:3670
NTV2SupportLoggerSections
map< NTV2Channel, AUTOCIRCULATE_STATUS > ChannelToACStatus
#define false
uint32_t ULWord
Definition: ajatypes.h:236
virtual bool AutoCirculateGetStatus(const NTV2Channel inChannel, AUTOCIRCULATE_STATUS &outStatus)
Returns the current AutoCirculate status for the given channel.
NTV2Channel
These enum values are mostly used to identify a specific widget_framestore. They&#39;re also commonly use...
Definition: ntv2enums.h:1359
virtual NTV2Dictionary ConnectParams(void) const
pair< NTV2Channel, FrameToTCList > ChannelToPerFrameTCListPair
This class is a collection of widget input-to-output connections that can be applied all-at-once to a...
virtual class DeviceCapabilities & features(void)
Definition: ntv2card.h:148
ChannelToPerFrameTCList::const_iterator ChannelToPerFrameTCListConstIter
std::set< NTV2AudioChannelPair > NTV2AudioChannelPairs
A set of distinct NTV2AudioChannelPair values.
static bool DumpDeviceSDRAM(CNTV2Card &inDevice, const std::string &inFilePath, std::ostream &msgStream)
CNTV2SupportLogger(CNTV2Card &card, NTV2SupportLoggerSections sections=NTV2_SupportLoggerSectionsAll)
Construct from CNTV2Card instance.
virtual bool GetInstalledBitfileInfo(ULWord &outNumBytes, std::string &outDateStr, std::string &outTimeStr)
Returns the bitfile size and time/date stamp from the header of the bitfile that&#39;s currently installe...
Definition: ntv2card.cpp:320
#define PATH_DELIMITER
bool GetInputTimeCodes(NTV2TimeCodeList &outValues) const
Returns all RP188 timecodes associated with the frame in NTV2TCIndex order.
virtual bool LoadFromLog(const std::string &inLogFilePath, const bool bForceLoad)
Obtain audio samples from the device analog input(s), if available.
Definition: ntv2enums.h:2012
NTV2RegWritesConstIter NTV2RegisterReadsConstIter
This struct replaces the old RP188_STRUCT.
virtual NTV2VideoFormat GetHDMIInputVideoFormat(NTV2Channel inHDMIInput=NTV2_CHANNEL1)
int32_t appPID(0)
pair< NTV2Channel, AUTOCIRCULATE_STATUS > ChannelToACStatusPair
virtual bool IsRemote(void) const
NTV2XilinxFPGA
Definition: ntv2enums.h:3849
virtual bool GetTaskMode(NTV2TaskMode &outMode)
Retrieves the device&#39;s current task mode.
#define kIncludeOtherRegs_None
virtual void PrependToSection(uint32_t section, const std::string &sectionData)
Prepends arbitrary string data to my support log, ahead of a given section.
NTV2FrameRate
Identifies a particular video frame rate.
Definition: ntv2enums.h:414
virtual std::string GetPCIFPGAVersionString(void)
Definition: ntv2card.cpp:131
#define true
0: Disabled (never recommended): device configured exclusively by client application(s).
Playout (output) mode, which reads from device SDRAM.
Definition: ntv2enums.h:1243
virtual std::string GetDescription(void) const
Definition: ntv2card.cpp:139
NTV2DeviceID
Identifies a specific AJA NTV2 device model number. The NTV2DeviceID is actually the PROM part number...
Definition: ntv2enums.h:20
static NTV2VideoFormat getVideoFormat(CNTV2Card &device, const NTV2Channel inChannel)
virtual bool IsOpen(void) const
The invalid mode.
Definition: ntv2enums.h:1247
static string pidToString(const uint32_t inPID)
std::string to_string(bool val)
Definition: common.cpp:180
static ULWord bytesToSamples(CNTV2Card &device, NTV2AudioSystem audioSystem, const ULWord inBytes)
std::set< std::string > NTV2StringSet
std::string NTV2TaskModeToString(const NTV2TaskMode inValue, const bool inCompactDisplay=false)
Definition: ntv2utils.cpp:6356
virtual bool ReadRegisters(NTV2RegisterReads &inOutValues)
Reads the register(s) specified by the given NTV2RegInfo sequence.
#define AJA_NULL
Definition: ajatypes.h:180
virtual bool GetSerialNumberString(std::string &outSerialNumberString)
Answers with a string that contains my human-readable serial number.
Definition: ntv2card.cpp:229
virtual std::string GetDisplayName(void)
Answers with this device&#39;s display name.
Definition: ntv2card.cpp:88
Declares the CRP188 class. See SMPTE RP188 standard for details.
NTV2AudioLoopBack
This enum value determines/states if an audio output embedder will embed silence (zeroes) or de-embed...
Definition: ntv2enums.h:2031
void clear(void)
Removes all of my key/value pairs.
std::vector< ULWord > NTV2ULWordVector
An ordered sequence of ULWords.
std::string NTV2GetVersionString(const bool inDetailed=false)
Definition: ntv2utils.cpp:7538
This selects audio channels 1 and 2 (Group 1 channels 1 and 2)
Definition: ntv2enums.h:3136
virtual NTV2VideoFormat GetAnalogInputVideoFormat(void)
Returns the video format of the signal that is present on the device&#39;s analog video input...
ULWord NTV2FramesizeToByteCount(const NTV2Framesize inFrameSize)
Converts the given NTV2Framesize value into an exact byte count.
Definition: ntv2utils.cpp:5290
bool IsStopped(void) const
NTV2RegisterNumberSet NTV2RegNumSet
A set of distinct NTV2RegisterNumbers.
NTV2AudioChannelPair
Identifies a pair of audio channels.
Definition: ntv2enums.h:3134
virtual std::string ToString(void) const
virtual std::string GetDriverVersionString(void)
Answers with this device&#39;s driver&#39;s version as a human-readable string.
Definition: ntv2card.cpp:162
virtual bool ReadAudioLastIn(ULWord &outValue, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_1)
For the given Audio System, answers with the byte offset to the last byte of the latest chunk of 4-by...
Definition: ntv2audio.cpp:466
static uint32_t maxSampleCountForNTV2AudioBufferSize(const NTV2AudioBufferSize inBufferSize, const uint16_t inChannelCount)
NTV2RegWrites NTV2RegisterReads
static std::string FourCCToString(const ULWord in4CC, const char nonPrintable='?')
virtual bool GetInputFrame(const NTV2Channel inChannel, ULWord &outValue)
Answers with the current input frame index number for the given FrameStore. This identifies which par...
#define NTV2_IS_INPUT_CROSSPOINT(__x__)
Definition: ntv2enums.h:1727
std::string NTV2VideoFormatToString(const NTV2VideoFormat inValue, const bool inUseFrameRate=false)
Definition: ntv2utils.cpp:6749
Embeds silence (zeroes) into the data stream.
Definition: ntv2enums.h:2033
virtual bool GetLPExternalConfigurationURLString(std::string &outURLString)
Definition: ntv2card.cpp:436
virtual bool GetAudioBufferSize(NTV2AudioBufferSize &outSize, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_1)
Retrieves the size of the input or output audio buffer being used for a given Audio System on the AJA...
Definition: ntv2audio.cpp:269
bool NTV2DeviceCanDoPCMDetection(const NTV2DeviceID inDeviceID)
virtual NTV2DeviceID GetDeviceID(void)
std::string NTV2TCIndexToString(const NTV2TCIndex inValue, const bool inCompactDisplay=false)
Definition: ntv2utils.cpp:6397
virtual bool GetDetectedAudioChannelPairs(const NTV2AudioSystem inAudioSystem, NTV2AudioChannelPairs &outDetectedChannelPairs)
Answers which audio channel pairs are present in the given Audio System&#39;s input stream.
Definition: ntv2audio.cpp:1421
Declares the CNTV2DeviceScanner class.
#define kIncludeOtherRegs_XptROM
#define LoggerSectionToFunctionMacro(_SectionEnum_, _SectionString_, _SectionMethod_)
virtual bool ReadRegister(const ULWord inRegNum, ULWord &outValue, const ULWord inMask=0xFFFFFFFF, const ULWord inShift=0)
Reads all or part of the 32-bit contents of a specific register (real or virtual) on the AJA device...
NTV2Framesize
Kona2/Xena2 specific enums.
Definition: ntv2enums.h:2119
virtual bool GetRouting(CNTV2SignalRouter &outRouting)
Answers with the current signal routing between any and all widgets on the AJA device.
UWord NTV2DeviceGetNumAudioSystems(const NTV2DeviceID inDeviceID)
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.).
virtual bool DriverGetBitFileInformation(BITFILE_INFO_STRUCT &outBitFileInfo, const NTV2BitFileType inBitFileType=NTV2_VideoProcBitFile)
defined(NTV2_DEPRECATE_17_2)
NTV2Mode
Used to identify the mode of a widget_framestore, or the direction of an AutoCirculate stream: either...
Definition: ntv2enums.h:1241
uint16_t GetEndFrame(void) const
virtual int GetSFPConfigurationURLStrings(std::vector< std::string > &sfpURLStrings)
Definition: ntv2card.cpp:488
std::string NTV2DeviceIDToString(const NTV2DeviceID inValue, const bool inForRetailDisplay=false)
Definition: ntv2utils.cpp:4608
static NTV2Channel findActiveACChannel(CNTV2Card &device, NTV2AudioSystem audioSystem, AUTOCIRCULATE_STATUS &outStatus)
True if device has a crosspoint connection ROM (New in SDK 17.0)
virtual bool AutoCirculateGetFrameStamp(const NTV2Channel inChannel, const ULWord inFrameNumber, FRAME_STAMP &outFrameInfo)
Returns precise timing information for the given frame and channel that&#39;s currently AutoCirculating...
virtual bool ReadAudioLastOut(ULWord &outValue, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_1)
For the given Audio System, answers with the byte offset of the tail end of the last chunk of audio s...
Definition: ntv2audio.cpp:473
virtual bool GetNumberAudioChannels(ULWord &outNumChannels, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_1)
Returns the current number of audio channels being captured or played by a given Audio System on the ...
Definition: ntv2audio.cpp:181
virtual bool GetHDMIInputAudioChannels(NTV2HDMIAudioChannels &outValue, const NTV2Channel inHDMIInput=NTV2_CHANNEL1)
Answers with the current number of audio channels being received on the given HDMI input...
Definition: ntv2hdmi.cpp:280
#define NTV2_IS_VALID_EMBEDDED_AUDIO_INPUT(_x_)
Definition: ntv2enums.h:1984
static AJALabelValuePairs & append(AJALabelValuePairs &inOutTable, const std::string &inLabel, const std::string &inValue=std::string())
A convenience function that appends the given label and value strings to the provided AJALabelValuePa...
Definition: info.h:170
virtual bool GetFrameBufferFormat(NTV2Channel inChannel, NTV2FrameBufferFormat &outValue)
Returns the current frame buffer format for the given FrameStore on the AJA device.
#define DEC(__x__)
NTV2RegisterNumber
#define AJAExport
Definition: export.h:33
virtual NTV2VideoFormat GetAnalogCompositeInputVideoFormat(void)
Returns the video format of the signal that is present on the device&#39;s composite video input...
This identifies the first Audio System.
Definition: ntv2enums.h:3900
virtual bool WaitForOutputVerticalInterrupt(const NTV2Channel inChannel=NTV2_CHANNEL1, UWord inRepeatCount=1)
Efficiently sleeps the calling thread/process until the next one or more field (interlaced video) or ...
const registerToLoadString registerToLoadStrings[]
virtual std::ostream & Print(std::ostream &inOutStream, const bool inForRetailDisplay=false) const
Prints me in a human-readable format to the given output stream.
double GetAudioSamplesPerSecond(const NTV2AudioRate inAudioRate)
Returns the audio sample rate as a number of audio samples per second.
Definition: ntv2utils.cpp:3303
Declares the AJASystemInfo class.
This is returned from the CNTV2Card::AutoCirculateGetStatus function.
std::vector< NTV2_RP188 > NTV2TimeCodeList
An ordered sequence of zero or more NTV2_RP188 structures. An NTV2TCIndex enum value can be used as a...
std::string NTV2AudioRateToString(const NTV2AudioRate inValue, const bool inForRetailDisplay=false)
Definition: ntv2utils.cpp:5759
ostream & operator<<(ostream &outStream, const CNTV2SupportLogger &inData)
static ULWord getMaxNumSamples(CNTV2Card &device, NTV2AudioSystem audioSystem)
uint16_t UWord
Definition: ajatypes.h:234
virtual bool WriteRegister(const ULWord inRegNum, const ULWord inValue, const ULWord inMask=0xFFFFFFFF, const ULWord inShift=0)
Updates or replaces all or part of the 32-bit contents of a specific register (real or virtual) on th...
static bool detectInputChannelPairs(CNTV2Card &device, const NTV2AudioSource inAudioSource, const NTV2EmbeddedAudioInput inEmbeddedSource, NTV2AudioChannelPairs &outChannelPairsPresent)
Specifies channel or FrameStore 1 (or the first item).
Definition: ntv2enums.h:1361
ULWord appSignature(0)
#define xHEX0N(__x__, __n__)
static NTV2RegNumSet GetRegistersForDevice(const NTV2DeviceID inDeviceID, const int inOtherRegsToInclude=0)
A simple (not thread-safe) set of key/value pairs. (New in SDK 16.3)
std::string NTV2AudioSourceToString(const NTV2AudioSource inValue, const bool inCompactDisplay=false)
Definition: ntv2utils.cpp:6734
string DECStr(const T inT)
static std::string GetDeviceRefName(CNTV2Card &inDevice)
#define NTV2_IS_SUPPORTED_NTV2FrameRate(__r__)
Definition: ntv2enums.h:447
virtual bool GetSDIOutputAudioEnabled(const NTV2Channel inSDIOutput, bool &outIsEnabled)
Answers with the current state of the audio output embedder for the given SDI output connector (speci...
Definition: ntv2audio.cpp:1640
virtual bool GetFrameRate(NTV2FrameRate &outValue, NTV2Channel inChannel=NTV2_CHANNEL1)
Returns the AJA device&#39;s currently configured frame rate via its "value" parameter.
std::string NTV2FrameBufferFormatToString(const NTV2FrameBufferFormat inValue, const bool inForRetailDisplay=false)
Definition: ntv2utils.cpp:6939
virtual bool IsChannelEnabled(const NTV2Channel inChannel, bool &outEnabled)
Answers whether or not the given FrameStore is enabled.
Declares the CNTV2KonaFlashProgram class.
static int Version(void)
NTV2AudioSource
This enum value determines/states where an audio system will obtain its audio samples.
Definition: ntv2enums.h:2008
virtual bool GetInputAudioChannelPairsWithPCM(const NTV2Channel inSDIInputConnector, NTV2AudioChannelPairs &outChannelPairs)
For the given SDI input (specified as a channel number), returns the set of audio channel pairs that ...
Definition: ntv2audio.cpp:1576
virtual void AddFooter(const std::string &sectionName, const std::string &sectionData)
Adds footer text to my log.
virtual AJAStatus GetLabelValuePairs(AJALabelValuePairs &outTable, bool clearTable=false) const
Generates a "table" of label/value pairs that contains the complete host system info table...
Definition: info.cpp:175
#define NTV2_IS_OUTPUT_MODE(__mode__)
Definition: ntv2enums.h:1252
Private include file for all ajabase sources.
This class/object reports information about the current and/or requested AutoCirculate frame...
virtual bool DMAReadFrame(const ULWord inFrameNumber, ULWord *pOutFrameBuffer, const ULWord inByteCount)
Transfers a single frame from the AJA device to the host.
Definition: ntv2dma.cpp:41
NTV2AudioRate
Definition: ntv2enums.h:1931
#define NTV2_IS_VALID_VIDEO_FORMAT(__f__)
Definition: ntv2enums.h:727
virtual AJAStatus GetValue(const AJASystemInfoTag inTag, std::string &outValue) const
Answers with the host system info value string for the given AJASystemInfoTag.
Definition: info.cpp:153
ULWord NTV2DeviceGetNumVideoChannels(const NTV2DeviceID inDeviceID)
std::string NTV2AudioLoopBackToString(const NTV2AudioLoopBack inValue, const bool inForRetailDisplay=false)
Definition: ntv2utils.cpp:5784
const char * NTV2DeviceIDString(const NTV2DeviceID id)
Definition: ntv2debug.cpp:15
std::ostream & DumpBlocks(std::ostream &oss) const
Dumps all 8MB blocks/frames and their tags, if any, into the given stream.
Definition: ntv2card.cpp:652
8 audio channels
Definition: ntv2enums.h:3673
virtual void AppendToSection(uint32_t section, const std::string &sectionData)
Appends arbitrary string data to my support log, after a given section.
#define HEX0N(__x__, __n__)
Definition: debug.cpp:1181
static string xHEX0NStr(const uint32_t inNum, const uint16_t inWidth)
std::string NTV2ChannelToString(const NTV2Channel inValue, const bool inForRetailDisplay=false)
Definition: ntv2utils.cpp:5730
static bool getBitfileDate(CNTV2Card &device, string &outDateString, NTV2XilinxFPGA whichFPGA)
map< uint16_t, NTV2TimeCodeList > FrameToTCList
std::string NTV2EmbeddedAudioInputToString(const NTV2EmbeddedAudioInput inValue, const bool inCompactDisplay=false)
Definition: ntv2utils.cpp:6716
UWord NTV2DeviceGetMaxAudioChannels(const NTV2DeviceID inDeviceID)
NTV2AudioSystem GetAudioSystem(void) const
pair< uint16_t, NTV2TimeCodeList > FrameToTCListPair
NTV2RegisterReads FromRegNumSet(const NTV2RegNumSet &inRegNumSet)
Definition: ntv2utils.cpp:7741
This selects audio channels 9 and 10 (Group 3 channels 1 and 2)
Definition: ntv2enums.h:3140
static NTV2PixelFormat getPixelFormat(CNTV2Card &device, const NTV2Channel inChannel)
NTV2Crosspoint acCrosspoint
The crosspoint (channel number with direction)
virtual bool GetStreamingApplication(ULWord &outAppType, int32_t &outProcessID)
Answers with the four-CC type and process ID of the application that currently "owns" the AJA device ...
NTV2EmbeddedAudioInput
This enum value determines/states which SDI video input will be used to supply audio samples to an au...
Definition: ntv2enums.h:1970
virtual void ToString(std::string &outAllLabelsAndValues) const
Answers with a multi-line string that contains the complete host system info table.
static string getActiveFrameStr(CNTV2Card &device, const NTV2Channel inChannel)
static ULWord getActiveFrame(CNTV2Card &device, const NTV2Channel inChannel)
ChannelToACStatus::const_iterator ChannelToACStatusConstIter
uint16_t GetStartFrame(void) const
virtual std::string GetHostName(void) const
Declares device capability functions.
This selects audio channels 3 and 4 (Group 1 channels 3 and 4)
Definition: ntv2enums.h:3137
virtual bool WaitForInputVerticalInterrupt(const NTV2Channel inChannel=NTV2_CHANNEL1, UWord inRepeatCount=1)
Efficiently sleeps the calling thread/process until the next one or more field (interlaced video) or ...
static NTV2Mode getMode(CNTV2Card &device, const NTV2Channel inChannel)
#define kIncludeOtherRegs_VRegs
virtual bool GetMode(const NTV2Channel inChannel, NTV2Mode &outValue)
Answers with the current NTV2Mode of the given FrameStore on the AJA device.
enum NTV2TCIndex NTV2TimecodeIndex
Declares the CNTV2RegisterExpert class.
ULWord GetScaleFromFrameRate(const NTV2FrameRate inFrameRate)
Definition: ntv2utils.cpp:3454
virtual void AddHeader(const std::string &sectionName, const std::string &sectionData)
Adds header text to my log.
static string timecodeToString(const NTV2_RP188 &inRP188)