AJA NTV2 SDK  18.1.0.2149
NTV2 SDK 18.1.0.2149
ntv2democommon.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MIT */
8 #include "ntv2democommon.h"
9 #include "ntv2devicescanner.h"
10 #include "ntv2devicefeatures.h"
11 #include "ntv2testpatterngen.h"
12 #include "ntv2debug.h"
13 #include "ntv2utils.h"
14 #include "ajabase/common/common.h"
15 #include <algorithm>
16 #include <map>
17 #include <iomanip>
18 #if defined (AJAMac) || defined (AJALinux)
19  #include <unistd.h>
20  #include <termios.h>
21 #endif
22 
23 using namespace std;
24 
25 typedef multimap <string, NTV2VideoFormat> String2VideoFormatMMap;
26 typedef String2VideoFormatMMap::const_iterator String2VideoFormatMMapCI;
27 
28 typedef map <string, NTV2FrameBufferFormat> String2PixelFormatMap;
29 typedef String2PixelFormatMap::const_iterator String2PixelFormatMapConstIter;
30 
31 typedef map <string, NTV2AudioSystem> String2AudioSystemMap;
32 typedef String2AudioSystemMap::const_iterator String2AudioSystemMapConstIter;
33 
34 typedef map <string, NTV2VANCMode> String2VANCModeMap;
35 typedef String2VANCModeMap::const_iterator String2VANCModeMapConstIter;
36 
37 typedef map <string, NTV2InputSource> String2InputSourceMap;
38 typedef String2InputSourceMap::const_iterator String2InputSourceMapConstIter;
39 
40 typedef map <string, NTV2OutputDestination> String2OutputDestMap;
41 typedef String2OutputDestMap::const_iterator String2OutputDestMapConstIter;
42 
43 typedef map <string, NTV2TCIndex> String2TCIndexMap;
44 typedef pair <string, NTV2TCIndex> String2TCIndexPair;
45 typedef String2TCIndexMap::const_iterator String2TCIndexMapConstIter;
46 
47 typedef map <string, string> String2TPNamesMap;
48 typedef pair <string, string> String2TPNamePair;
49 typedef String2TPNamesMap::const_iterator String2TPNamesMapConstIter;
50 
51 
52 static const string gGlobalMutexName ("com.aja.ntv2.mutex.demo");
88 
89 
91 {
92  public:
94  {
95  typedef pair <string, NTV2VideoFormat> String2VideoFormatPair;
96  typedef pair <string, NTV2FrameBufferFormat> String2PixelFormatPair;
97  typedef pair <string, NTV2AudioSystem> String2AudioSystemPair;
98  typedef pair <string, NTV2VANCMode> String2VANCModePair;
99  typedef pair <string, NTV2InputSource> String2InputSourcePair;
100  typedef pair <string, NTV2OutputDestination> String2OutputDestPair;
101 
102  NTV2_ASSERT (gSDHDFormats.empty());
103  for (NTV2VideoFormat legalFormat(NTV2_FORMAT_UNKNOWN); legalFormat < NTV2_MAX_NUM_VIDEO_FORMATS; legalFormat = NTV2VideoFormat(legalFormat + 1))
104  {
105  if (!NTV2_IS_VALID_VIDEO_FORMAT(legalFormat))
106  continue;
107  string str(::NTV2VideoFormatToString (legalFormat));
108 
109  if (NTV2_IS_QUAD_QUAD_FORMAT(legalFormat))
110  g8KFormats.insert(legalFormat);
111  else if (NTV2_IS_4K_VIDEO_FORMAT(legalFormat))
112  g4KFormats.insert(legalFormat);
113  else
114  gSDHDFormats.insert(legalFormat);
115  gAllFormats.insert(legalFormat);
116 
117  if (legalFormat == NTV2_FORMAT_525_5994) str = "525i2997";
118  else if (legalFormat == NTV2_FORMAT_625_5000) str = "625i25";
119  else if (legalFormat == NTV2_FORMAT_525_2398) str = "525i2398";
120  else if (legalFormat == NTV2_FORMAT_525_2400) str = "525i24";
121  else
122  {
123  if (str.at (str.length() - 1) == 'a') // If it ends in "a"...
124  str.erase (str.length() - 1); // ...lop off the "a"
125 
126  if (str.find(".00") != string::npos) // If it ends in ".00"...
127  str.erase (str.find(".00"), 3); // ...lop off the ".00" (but keep the "b", if any)
128 
129  while (str.find(" ") != string::npos)
130  str.erase (str.find(" "), 1); // Remove all spaces
131 
132  if (str.find(".") != string::npos)
133  str.erase (str.find("."), 1); // Remove "."
134 
135  str = CNTV2DemoCommon::ToLower(str); // Fold to lower case
136  }
137  gString2VideoFormatMMap.insert (String2VideoFormatPair (str, legalFormat));
138  gString2VideoFormatMMap.insert (String2VideoFormatPair (ULWordToString(legalFormat), legalFormat));
139  } // for each video format supported in demo apps
140 
141  // Add popular format names...
142  gString2VideoFormatMMap.insert (String2VideoFormatPair ("sd", NTV2_FORMAT_525_5994));
143  gString2VideoFormatMMap.insert (String2VideoFormatPair ("525i", NTV2_FORMAT_525_5994));
144  gString2VideoFormatMMap.insert (String2VideoFormatPair ("625i", NTV2_FORMAT_625_5000));
145  gString2VideoFormatMMap.insert (String2VideoFormatPair ("720p", NTV2_FORMAT_720p_5994));
146  gString2VideoFormatMMap.insert (String2VideoFormatPair ("hd", NTV2_FORMAT_1080i_5994));
147  gString2VideoFormatMMap.insert (String2VideoFormatPair ("1080i", NTV2_FORMAT_1080i_5994));
148  gString2VideoFormatMMap.insert (String2VideoFormatPair ("1080i50", NTV2_FORMAT_1080i_5000));
149  gString2VideoFormatMMap.insert (String2VideoFormatPair ("1080p", NTV2_FORMAT_1080p_5994_B));
150  gString2VideoFormatMMap.insert (String2VideoFormatPair ("1080p50", NTV2_FORMAT_1080p_5000_B));
151 
152  gString2VideoFormatMMap.insert (String2VideoFormatPair ("uhd", NTV2_FORMAT_4x1920x1080p_6000));
153  gString2VideoFormatMMap.insert (String2VideoFormatPair ("uhd", NTV2_FORMAT_3840x2160p_6000));
154  gString2VideoFormatMMap.insert (String2VideoFormatPair ("uhd2398", NTV2_FORMAT_4x1920x1080p_2398));
155  gString2VideoFormatMMap.insert (String2VideoFormatPair ("uhd2398", NTV2_FORMAT_3840x2160p_2398));
156  gString2VideoFormatMMap.insert (String2VideoFormatPair ("uhd24", NTV2_FORMAT_4x1920x1080p_2400));
157  gString2VideoFormatMMap.insert (String2VideoFormatPair ("uhd24", NTV2_FORMAT_3840x2160p_2400));
158  gString2VideoFormatMMap.insert (String2VideoFormatPair ("uhd25", NTV2_FORMAT_4x1920x1080p_2500));
159  gString2VideoFormatMMap.insert (String2VideoFormatPair ("uhd25", NTV2_FORMAT_3840x2160p_2500));
160  gString2VideoFormatMMap.insert (String2VideoFormatPair ("uhd50", NTV2_FORMAT_4x1920x1080p_5000));
161  gString2VideoFormatMMap.insert (String2VideoFormatPair ("uhd50", NTV2_FORMAT_3840x2160p_5000));
162  gString2VideoFormatMMap.insert (String2VideoFormatPair ("uhd5994", NTV2_FORMAT_4x1920x1080p_5994));
163  gString2VideoFormatMMap.insert (String2VideoFormatPair ("uhd5994", NTV2_FORMAT_3840x2160p_5994));
164  gString2VideoFormatMMap.insert (String2VideoFormatPair ("uhd60", NTV2_FORMAT_4x1920x1080p_6000));
165  gString2VideoFormatMMap.insert (String2VideoFormatPair ("uhd60", NTV2_FORMAT_3840x2160p_6000));
166 
167  gString2VideoFormatMMap.insert (String2VideoFormatPair ("4k", NTV2_FORMAT_4x2048x1080p_6000));
168  gString2VideoFormatMMap.insert (String2VideoFormatPair ("4k", NTV2_FORMAT_4096x2160p_6000));
169  gString2VideoFormatMMap.insert (String2VideoFormatPair ("4k2398", NTV2_FORMAT_4x2048x1080p_2398));
170  gString2VideoFormatMMap.insert (String2VideoFormatPair ("4k2398", NTV2_FORMAT_4096x2160p_2398));
171  gString2VideoFormatMMap.insert (String2VideoFormatPair ("4k24", NTV2_FORMAT_4x2048x1080p_2400));
172  gString2VideoFormatMMap.insert (String2VideoFormatPair ("4k24", NTV2_FORMAT_4096x2160p_2400));
173  gString2VideoFormatMMap.insert (String2VideoFormatPair ("4k25", NTV2_FORMAT_4x2048x1080p_2500));
174  gString2VideoFormatMMap.insert (String2VideoFormatPair ("4k25", NTV2_FORMAT_4096x2160p_2500));
175  gString2VideoFormatMMap.insert (String2VideoFormatPair ("4k4795", NTV2_FORMAT_4x2048x1080p_4795));
176  gString2VideoFormatMMap.insert (String2VideoFormatPair ("4k4795", NTV2_FORMAT_4096x2160p_4795));
177  gString2VideoFormatMMap.insert (String2VideoFormatPair ("4k48", NTV2_FORMAT_4x2048x1080p_4800));
178  gString2VideoFormatMMap.insert (String2VideoFormatPair ("4k48", NTV2_FORMAT_4096x2160p_4800));
179  gString2VideoFormatMMap.insert (String2VideoFormatPair ("4k50", NTV2_FORMAT_4x2048x1080p_5000));
180  gString2VideoFormatMMap.insert (String2VideoFormatPair ("4k50", NTV2_FORMAT_4096x2160p_5000));
181  gString2VideoFormatMMap.insert (String2VideoFormatPair ("4k5994", NTV2_FORMAT_4x2048x1080p_5994));
182  gString2VideoFormatMMap.insert (String2VideoFormatPair ("4k5994", NTV2_FORMAT_4096x2160p_5994));
183  gString2VideoFormatMMap.insert (String2VideoFormatPair ("4k60", NTV2_FORMAT_4x2048x1080p_6000));
184  gString2VideoFormatMMap.insert (String2VideoFormatPair ("4k60", NTV2_FORMAT_4096x2160p_6000));
185  gString2VideoFormatMMap.insert (String2VideoFormatPair ("4k11988", NTV2_FORMAT_4x2048x1080p_11988));
186  gString2VideoFormatMMap.insert (String2VideoFormatPair ("4k11988", NTV2_FORMAT_4096x2160p_11988));
187  gString2VideoFormatMMap.insert (String2VideoFormatPair ("4k120", NTV2_FORMAT_4x2048x1080p_12000));
188  gString2VideoFormatMMap.insert (String2VideoFormatPair ("4k120", NTV2_FORMAT_4096x2160p_12000));
189 
190  gString2VideoFormatMMap.insert (String2VideoFormatPair ("uhd2", NTV2_FORMAT_4x3840x2160p_2398));
191  gString2VideoFormatMMap.insert (String2VideoFormatPair ("uhd22398", NTV2_FORMAT_4x3840x2160p_2398));
192  gString2VideoFormatMMap.insert (String2VideoFormatPair ("uhd224", NTV2_FORMAT_4x3840x2160p_2400));
193  gString2VideoFormatMMap.insert (String2VideoFormatPair ("uhd225", NTV2_FORMAT_4x3840x2160p_2500));
194  gString2VideoFormatMMap.insert (String2VideoFormatPair ("uhd250", NTV2_FORMAT_4x3840x2160p_5000));
195  gString2VideoFormatMMap.insert (String2VideoFormatPair ("uhd25994", NTV2_FORMAT_4x3840x2160p_5994));
196  gString2VideoFormatMMap.insert (String2VideoFormatPair ("uhd260", NTV2_FORMAT_4x3840x2160p_6000));
197 
198  gString2VideoFormatMMap.insert (String2VideoFormatPair ("8k", NTV2_FORMAT_4x4096x2160p_6000));
199  gString2VideoFormatMMap.insert (String2VideoFormatPair ("8k2398", NTV2_FORMAT_4x4096x2160p_2398));
200  gString2VideoFormatMMap.insert (String2VideoFormatPair ("8k24", NTV2_FORMAT_4x4096x2160p_2400));
201  gString2VideoFormatMMap.insert (String2VideoFormatPair ("8k25", NTV2_FORMAT_4x4096x2160p_2500));
202  gString2VideoFormatMMap.insert (String2VideoFormatPair ("8k4795", NTV2_FORMAT_4x4096x2160p_4795));
203  gString2VideoFormatMMap.insert (String2VideoFormatPair ("8k48", NTV2_FORMAT_4x4096x2160p_4800));
204  gString2VideoFormatMMap.insert (String2VideoFormatPair ("8k50", NTV2_FORMAT_4x4096x2160p_5000));
205  gString2VideoFormatMMap.insert (String2VideoFormatPair ("8k5994", NTV2_FORMAT_4x4096x2160p_5994));
206  gString2VideoFormatMMap.insert (String2VideoFormatPair ("8k60", NTV2_FORMAT_4x4096x2160p_6000));
207 
208  NTV2_ASSERT (gPixelFormats.empty ());
209  for (NTV2FrameBufferFormat legalFormat (NTV2_FBF_10BIT_YCBCR); legalFormat < NTV2_FBF_NUMFRAMEBUFFERFORMATS; legalFormat = NTV2FrameBufferFormat (legalFormat + 1))
210  {
211  string str;
212  if (!NTV2_IS_VALID_FRAME_BUFFER_FORMAT (legalFormat))
213  continue;
214 
215  gPixelFormats.insert (legalFormat);
216  if (NTV2_IS_FBF_PLANAR (legalFormat))
217  gFBFsPlanar.insert (legalFormat);
218  if (NTV2_IS_FBF_RGB (legalFormat))
219  gFBFsRGB.insert (legalFormat);
220  if (NTV2_IS_FBF_PRORES (legalFormat))
221  gFBFsProRes.insert (legalFormat);
222  if (NTV2_FBF_HAS_ALPHA (legalFormat))
223  gFBFsAlpha.insert (legalFormat);
224  if (NTV2_FBF_IS_RAW (legalFormat))
225  gFBFsRaw.insert (legalFormat);
226 
227  str = ::NTV2FrameBufferFormatToString (legalFormat, true);
228  while (str.find (" ") != string::npos)
229  str.erase (str.find (" "), 1); // Remove all spaces
230 
231  while (str.find ("-") != string::npos)
232  str.erase (str.find ("-"), 1); // Remove all "-"
233 
234  if (str.find ("compatible") != string::npos)
235  str.erase (str.find ("compatible"), 10); // Remove "compatible"
236 
237  if (str.find ("ittle") != string::npos)
238  str.erase (str.find ("ittle"), 5); // Remove "ittle"
239 
240  if (str.find ("ndian") != string::npos)
241  str.erase (str.find ("ndian"), 5); // Remove "ndian"
242 
243  str = CNTV2DemoCommon::ToLower (str); // Fold to lower case
244 
245  gString2PixelFormatMap.insert (String2PixelFormatPair (str, legalFormat));
246 
247  str = ::NTV2FrameBufferFormatToString (legalFormat, false);
248  if (str.find ("NTV2_FBF_") == 0) // If it starts with "NTV2_FBF_"...
249  str.erase (0, 9); // ...lop it off
250 
251  while (str.find (" ") != string::npos)
252  str.erase (str.find (" "), 1); // Remove all spaces
253 
254  while (str.find ("_") != string::npos)
255  str.erase (str.find ("_"), 1); // Remove all "_"
256 
257  str = CNTV2DemoCommon::ToLower (str); // Fold to lower case
258 
259  gString2PixelFormatMap.insert (String2PixelFormatPair (str, legalFormat));
260  gString2PixelFormatMap.insert (String2PixelFormatPair (::NTV2FrameBufferFormatToString (legalFormat, false), legalFormat));
261  gString2PixelFormatMap.insert (String2PixelFormatPair (ULWordToString (legalFormat), legalFormat));
262  } // for each pixel format supported in demo apps
263 
264  // Add popular pixel format names...
265  gString2PixelFormatMap.insert (String2PixelFormatPair ("v210", NTV2_FBF_10BIT_YCBCR));
266  gString2PixelFormatMap.insert (String2PixelFormatPair ("yuv10", NTV2_FBF_10BIT_YCBCR));
267  gString2PixelFormatMap.insert (String2PixelFormatPair ("2vuy", NTV2_FBF_8BIT_YCBCR));
268  gString2PixelFormatMap.insert (String2PixelFormatPair ("uyvy", NTV2_FBF_8BIT_YCBCR));
269  gString2PixelFormatMap.insert (String2PixelFormatPair ("argb", NTV2_FBF_ARGB));
270  gString2PixelFormatMap.insert (String2PixelFormatPair ("argb8", NTV2_FBF_ARGB));
271  gString2PixelFormatMap.insert (String2PixelFormatPair ("bgra", NTV2_FBF_RGBA));
272  gString2PixelFormatMap.insert (String2PixelFormatPair ("bgra8", NTV2_FBF_RGBA));
273  gString2PixelFormatMap.insert (String2PixelFormatPair ("rgba", NTV2_FBF_RGBA));
274  gString2PixelFormatMap.insert (String2PixelFormatPair ("rgba8", NTV2_FBF_RGBA));
275  gString2PixelFormatMap.insert (String2PixelFormatPair ("rgb10", NTV2_FBF_10BIT_RGB));
276  gString2PixelFormatMap.insert (String2PixelFormatPair ("yuy2", NTV2_FBF_8BIT_YCBCR_YUY2));
277  gString2PixelFormatMap.insert (String2PixelFormatPair ("abgr", NTV2_FBF_ABGR));
278  gString2PixelFormatMap.insert (String2PixelFormatPair ("abgr8", NTV2_FBF_ABGR));
279  gString2PixelFormatMap.insert (String2PixelFormatPair ("rgb10dpx", NTV2_FBF_10BIT_DPX));
280  gString2PixelFormatMap.insert (String2PixelFormatPair ("yuv10dpx", NTV2_FBF_10BIT_YCBCR_DPX));
281  gString2PixelFormatMap.insert (String2PixelFormatPair ("ycbcr10dpx", NTV2_FBF_10BIT_YCBCR_DPX));
282  gString2PixelFormatMap.insert (String2PixelFormatPair ("dvcpro8", NTV2_FBF_8BIT_DVCPRO));
283  gString2PixelFormatMap.insert (String2PixelFormatPair ("i420", NTV2_FBF_8BIT_YCBCR_420PL3));
284  gString2PixelFormatMap.insert (String2PixelFormatPair ("hdv", NTV2_FBF_8BIT_HDV));
285  gString2PixelFormatMap.insert (String2PixelFormatPair ("hdv8", NTV2_FBF_8BIT_HDV));
286  gString2PixelFormatMap.insert (String2PixelFormatPair ("rgb24", NTV2_FBF_24BIT_RGB));
287  gString2PixelFormatMap.insert (String2PixelFormatPair ("bgr24", NTV2_FBF_24BIT_BGR));
288  gString2PixelFormatMap.insert (String2PixelFormatPair ("ycbcra10", NTV2_FBF_10BIT_YCBCRA));
289  gString2PixelFormatMap.insert (String2PixelFormatPair ("rgb10dpxle", NTV2_FBF_10BIT_DPX_LE));
290  gString2PixelFormatMap.insert (String2PixelFormatPair ("proresdvcpro", NTV2_FBF_PRORES_DVCPRO));
291  gString2PixelFormatMap.insert (String2PixelFormatPair ("proreshdv", NTV2_FBF_PRORES_HDV));
292  gString2PixelFormatMap.insert (String2PixelFormatPair ("rgb10packed", NTV2_FBF_10BIT_RGB_PACKED));
293  gString2PixelFormatMap.insert (String2PixelFormatPair ("argb10", NTV2_FBF_10BIT_ARGB));
294  gString2PixelFormatMap.insert (String2PixelFormatPair ("argb16", NTV2_FBF_16BIT_ARGB));
295  gString2PixelFormatMap.insert (String2PixelFormatPair ("rgb10raw", NTV2_FBF_10BIT_RAW_RGB));
296  gString2PixelFormatMap.insert (String2PixelFormatPair ("ycbcr10raw", NTV2_FBF_10BIT_RAW_YCBCR));
297  gString2PixelFormatMap.insert (String2PixelFormatPair ("yuv10raw", NTV2_FBF_10BIT_RAW_YCBCR));
298 
299  // Audio systems...
300  for (uint8_t ndx (0); ndx < 8; ndx++)
301  gString2AudioSystemMap.insert (String2AudioSystemPair(ULWordToString (ndx + 1), NTV2AudioSystem(ndx)));
302 
303  // VANC Modes...
305  {
306  gString2VANCModeMap.insert (String2VANCModePair(aja::to_string(vm), vm));
307 // gString2VANCModeMap.insert (String2VANCModePair(::NTV2VANCModeToString(vm, false), vm));
308  gString2VANCModeMap.insert (String2VANCModePair(::NTV2VANCModeToString(vm, true), vm));
309  }
310 
311  // Input Sources...
316  for (NTV2InputSourceSetConstIter it(gInputSources.begin()); it != gInputSources.end(); ++it)
317  {
318  const NTV2InputSource src(*it);
319  string sSmall(::NTV2InputSourceToString(src, true)), sBig(::NTV2InputSourceToString(src, false));
320  gString2InputSourceMap.insert(String2InputSourcePair(sBig, src));
321  gString2InputSourceMap.insert(String2InputSourcePair(sSmall, src));
322  gString2InputSourceMap.insert(String2InputSourcePair(CNTV2DemoCommon::ToLower(sSmall), src));
323  if (NTV2_INPUT_SOURCE_IS_SDI(src))
324  {
325  sSmall.erase(0, 3); // Erase first 3 chars to leave just the number (e.g. "SDI3" becomes "3")
326  gString2InputSourceMap.insert(String2InputSourcePair(sSmall, src));
327  }
328  } // for each input source
329  gString2InputSourceMap.insert(String2InputSourcePair(string("hdmi"),NTV2_INPUTSOURCE_HDMI1));
330 
331  // Output Destinations...
336  for (NTV2OutputDestinationsConstIter it(gOutputDestinations.begin()); it != gOutputDestinations.end(); ++it)
337  {
338  const NTV2OutputDest dst(*it);
339  string sSmall(::NTV2OutputDestinationToString(dst, true)), sBig(::NTV2OutputDestinationToString(dst, false));
340  gString2OutputDestMap.insert(String2OutputDestPair(sBig, dst));
341  gString2OutputDestMap.insert(String2OutputDestPair(sSmall, dst));
342  gString2OutputDestMap.insert(String2OutputDestPair(CNTV2DemoCommon::ToLower(sSmall), dst));
343  if (NTV2_OUTPUT_DEST_IS_SDI(dst))
344  {
345  const string str(aja::to_string(UWord(::NTV2OutputDestinationToChannel(dst)+1)));
346  gString2OutputDestMap.insert(String2OutputDestPair(str, dst));
347  }
348  } // for each output dest
349  gString2OutputDestMap.insert(String2OutputDestPair(string("hdmi1"), NTV2_OUTPUTDESTINATION_HDMI1));
350 
351  // TCIndexes...
352  for (uint16_t ndx (0); ndx < NTV2_MAX_NUM_TIMECODE_INDEXES; ndx++)
353  {
354  const NTV2TCIndex tcIndex (NTV2TCIndex(ndx+0));
355  if (tcIndex == NTV2_TCINDEX_DEFAULT)
356  continue; // Skip NTV2_TCINDEX_DEFAULT
357  gTCIndexes.insert (tcIndex);
358  gString2TCIndexMap.insert (String2TCIndexPair(ULWordToString(ndx), tcIndex));
359  gString2TCIndexMap.insert (String2TCIndexPair(::NTV2TCIndexToString(tcIndex, false), tcIndex));
361  if (NTV2_IS_ANALOG_TIMECODE_INDEX(tcIndex))
362  gTCIndexesAnalog.insert (tcIndex);
363  else
364  gTCIndexesSDI.insert (tcIndex);
365  if (NTV2_IS_ATC_LTC_TIMECODE_INDEX(tcIndex))
366  gTCIndexesATCLTC.insert (tcIndex);
368  gTCIndexesVITC1.insert (tcIndex);
370  gTCIndexesVITC2.insert (tcIndex);
371  }
372 
373  { // Test Patterns...
377  {
378  string tpName(tpNames.at(tp));
379  aja::replace(aja::replace(aja::replace(tpName, " ", ""), "%", ""), "_", "");
380  gString2TPNamesMap.insert(String2TPNamePair(aja::lower(tpName), tpNames.at(tp)));
381  ostringstream oss; oss << DEC(tp);
382  gString2TPNamesMap.insert(String2TPNamePair(oss.str(), tpNames.at(tp)));
383  }
384  for (NTV2StringListConstIter it(colorNames.begin()); it != colorNames.end(); ++it)
385  {
386  string colorName(*it);
387  aja::replace(aja::replace(aja::replace(colorName, " ", ""), "%", ""), "_", "");
388  gString2TPNamesMap.insert(String2TPNamePair(aja::lower(colorName), *it));
389  }
390  }
391  } // constructor
392  private:
393  string ULWordToString (const ULWord inNum)
394  {
395  ostringstream oss;
396  oss << inNum;
397  return oss.str ();
398  }
399 }; // constructor
400 
402 
403 
405 {
406  NTV2TimeCodesConstIter it(fTimecodes.find(inTCNdx));
407  if (it != fTimecodes.end())
408  return it->second;
409  return NTV2_RP188();
410 }
411 
413 {
414  size_t errorCount(0);
415  if (fVideoBuffer)
416  if (!inDevice.DMABufferLock(fVideoBuffer, true))
417  errorCount++;
418  if (fVideoBuffer2)
419  if (!inDevice.DMABufferLock(fVideoBuffer2, true))
420  errorCount++;
421  if (fAudioBuffer)
422  if (!inDevice.DMABufferLock(fAudioBuffer, true))
423  errorCount++;
424  if (fAncBuffer)
425  if (!inDevice.DMABufferLock(fAncBuffer, true))
426  errorCount++;
427  if (fAncBuffer2)
428  if (!inDevice.DMABufferLock(fAncBuffer2, true))
429  errorCount++;
430  return !errorCount;
431 }
432 
434 {
435  size_t errorCount(0);
436  if (fVideoBuffer)
437  if (!inDevice.DMABufferUnlock(fVideoBuffer))
438  errorCount++;
439  if (fVideoBuffer2)
440  if (!inDevice.DMABufferUnlock(fVideoBuffer2))
441  errorCount++;
442  if (fAudioBuffer)
443  if (!inDevice.DMABufferUnlock(fAudioBuffer))
444  errorCount++;
445  if (fAncBuffer)
446  if (!inDevice.DMABufferUnlock(fAncBuffer))
447  errorCount++;
448  if (fAncBuffer2)
449  if (!inDevice.DMABufferUnlock(fAncBuffer2))
450  errorCount++;
451  return !errorCount;
452 }
453 
455 {
456  fTimeStampAud = inXferInfo.GetFrameInfo().acAudioClockTimeStamp; // Grab VBI timestamp (audio clock)
457  fTimeStampOS = inXferInfo.GetFrameInfo().acFrameTime; // Grab VBI timestamp (OS clock)
458  if (acStatus.WithRP188() || acStatus.WithLTC())
459  inXferInfo.GetInputTimeCodes (fTimecodes, acStatus.GetChannel(), /*ValidOnly*/ true);
460  if (acStatus.WithAudio())
461  {
462  fNumAudioBytes = inXferInfo.GetCapturedAudioByteCount();
463  NTV2Buffer zero (fAudioBuffer.GetHostAddress(fNumAudioBytes),
464  fAudioBuffer.GetByteCount() - fNumAudioBytes);
465  zero.Fill(uint32_t(0));
466  }
467  if (acStatus.WithCustomAnc() && AncBuffer())
468  {
469  fNumAncBytes = inXferInfo.GetCapturedAncByteCount(/*isF2*/false);
470  // Clear stale anc data from the anc buffers...
471  NTV2Buffer stale (fAncBuffer.GetHostAddress(fNumAncBytes),
472  fAncBuffer.GetByteCount() - fNumAncBytes);
473  stale.Fill(uint8_t(0));
474  }
475  if (acStatus.WithCustomAnc() && AncBuffer2())
476  {
477  fNumAnc2Bytes = inXferInfo.GetCapturedAncByteCount(/*isF2*/true);
478  // Clear stale anc data from the anc buffers...
479  NTV2Buffer stale (fAncBuffer2.GetHostAddress(fNumAnc2Bytes),
480  fAncBuffer2.GetByteCount() - fNumAnc2Bytes);
481  stale.Fill(uint8_t(0));
482  }
483  return true;
484 }
485 
486 
487 bool CNTV2DemoCommon::IsValidDevice (const string & inDeviceSpec)
488 {
489  CNTV2Card device;
490  const string deviceSpec (inDeviceSpec.empty() ? "0" : inDeviceSpec);
491  if (! CNTV2DeviceScanner::GetFirstDeviceFromArgument (deviceSpec, device))
492  {
493  if (deviceSpec != "LIST" && deviceSpec != "list" && deviceSpec != "?")
494  cerr << "## ERROR: Failed to open device spec '" << deviceSpec << "'" << endl;
495  return false;
496  }
497  return true;
498 }
499 
500 
502 {
503  if ((inKinds & VIDEO_FORMATS_ALL) == VIDEO_FORMATS_ALL)
504  return gAllFormats;
505 
506  NTV2VideoFormatSet result;
507  if (inKinds & VIDEO_FORMATS_SDHD)
508  result += gSDHDFormats;
509  if (inKinds & VIDEO_FORMATS_4KUHD)
510  result += g4KFormats;
511  if (inKinds & VIDEO_FORMATS_8KUHD2)
512  result += g8KFormats;
513  return result;
514 }
515 
516 
517 string CNTV2DemoCommon::GetVideoFormatStrings (const NTV2VideoFormatKinds inKinds, const string inDevSpec)
518 {
519  const NTV2VideoFormatSet & formatSet(GetSupportedVideoFormats(inKinds));
520  ostringstream oss;
521  CNTV2Card dev;
522  if (!inDevSpec.empty())
523  dev.Open(inDevSpec);
524 
525  oss << setw(25) << left << "Supported Video Format" << "\t" << setw(16) << left << "Legal -v Values" << endl
526  << setw(25) << left << "------------------------" << "\t" << setw(16) << left << "----------------" << endl;
527  for (NTV2VideoFormatSetConstIter iter(formatSet.begin()); iter != formatSet.end(); ++iter)
528  { const NTV2VideoFormat vf(*iter);
529  const string vfName (::NTV2VideoFormatToString(vf, true));
530  if (vfName == "Unknown")
531  continue;
532  NTV2StringList vfNames;
534  if (vf == it->second)
535  {
536  if (!inDevSpec.empty() && dev.IsOpen() && !dev.features().CanDoVideoFormat(vf))
537  continue;
538  vfNames.push_back(it->first);
539  }
540  if (!vfNames.empty())
541  oss << setw(25) << left << vfName << "\t" << aja::join(vfNames,", ") << endl;
542  }
543  return oss.str();
544 }
545 
546 
547 NTV2VideoFormat CNTV2DemoCommon::GetVideoFormatFromString (const string & inStr, const NTV2VideoFormatKinds inKinds, const string & inDevSpec)
548 {
550  if (iter == gString2VideoFormatMMap.end())
551  return NTV2_FORMAT_UNKNOWN;
552 
553  CNTV2Card dev;
554  if (!inDevSpec.empty())
555  dev.Open(inDevSpec);
556 
557  // If a device was specifed, look for the first name-matching format it supports...
558  NTV2VideoFormat vf(iter->second);
559  while (dev.IsOpen() && !dev.features().CanDoVideoFormat(vf))
560  {
561  if (++iter == gString2VideoFormatMMap.end())
562  return NTV2_FORMAT_UNKNOWN;
563  if (inStr != iter->first)
564  return NTV2_FORMAT_UNKNOWN;
565  vf = iter->second;
566  }
567  if ((inKinds & VIDEO_FORMATS_ALL) == VIDEO_FORMATS_ALL)
568  return vf;
569  if (inKinds & VIDEO_FORMATS_4KUHD && NTV2_IS_4K_VIDEO_FORMAT(vf))
570  return vf;
571  if (inKinds & VIDEO_FORMATS_8KUHD2 && NTV2_IS_QUAD_QUAD_FORMAT(vf))
572  return vf;
573  if (inKinds & VIDEO_FORMATS_SDHD && !NTV2_IS_4K_VIDEO_FORMAT(vf))
574  return vf;
575  return NTV2_FORMAT_UNKNOWN;
576 }
577 
578 
580 {
581  if (inKinds == PIXEL_FORMATS_ALL)
582  return gPixelFormats;
583 
585  if (inKinds & PIXEL_FORMATS_RGB)
586  result += gFBFsRGB;
587  if (inKinds & PIXEL_FORMATS_PLANAR)
588  result += gFBFsPlanar;
589  if (inKinds & PIXEL_FORMATS_RAW)
590  result += gFBFsRaw;
591  if (inKinds & PIXEL_FORMATS_PACKED)
592  result += gFBFsPacked;
593  if (inKinds & PIXEL_FORMATS_ALPHA)
594  result += gFBFsAlpha;
595  return result;
596 }
597 
598 
599 string CNTV2DemoCommon::GetPixelFormatStrings (const NTV2PixelFormatKinds inKinds, const string inDevSpec)
600 {
601  const NTV2FrameBufferFormatSet & formatSet (GetSupportedPixelFormats(inKinds));
602  CNTV2Card dev;
603  ostringstream oss;
604 
605  if (!inDevSpec.empty())
606  dev.Open(inDevSpec);
607 
608  oss << setw(34) << left << "Frame Buffer Format" << "\t" << setw(32) << left << "Legal -p Values" << endl
609  << setw(34) << left << "----------------------------------" << "\t" << setw(32) << left << "--------------------------------" << endl;
610  for (NTV2FrameBufferFormatSetConstIter iter(formatSet.begin()); iter != formatSet.end(); ++iter)
611  {
612  const NTV2PixelFormat pf(*iter);
613  const string pfName (::NTV2FrameBufferFormatToString (pf, true));
614  if (pfName.empty())
615  continue;
616  NTV2StringList pfNames;
618  if (pf == it->second)
619  {
620  if (!inDevSpec.empty() && dev.IsOpen() && !dev.features().CanDoFrameBufferFormat(pf))
621  continue;
622  pfNames.push_back(it->first);
623  }
624  if (!pfNames.empty())
625  oss << setw(35) << left << pfName << "\t" << aja::join(pfNames, ", ") << endl;
626  }
627  return oss.str();
628 }
629 
630 
631 NTV2PixelFormat CNTV2DemoCommon::GetPixelFormatFromString (const string & inStr, const NTV2PixelFormatKinds inKinds, const string inDevSpec)
632 {
634  if (iter == gString2PixelFormatMap.end())
635  return NTV2_FBF_INVALID;
636 
637  CNTV2Card dev;
638  if (!inDevSpec.empty())
639  dev.Open(inDevSpec);
640 
641  // If a device was specifed, look for the first name-matching format it supports...
642  NTV2PixelFormat pf(iter->second);
643  while (dev.IsOpen() && !dev.features().CanDoPixelFormat(pf))
644  {
645  if (++iter == gString2PixelFormatMap.end())
646  return NTV2_FBF_INVALID;
647  if (inStr != iter->first)
648  return NTV2_FBF_INVALID;
649  pf = iter->second;
650  }
651  if ((inKinds & PIXEL_FORMATS_ALL) == PIXEL_FORMATS_ALL)
652  return pf;
653  if (inKinds & PIXEL_FORMATS_RGB && NTV2_IS_FBF_RGB(pf))
654  return pf;
655  if (inKinds & PIXEL_FORMATS_PLANAR && NTV2_IS_FBF_PLANAR(pf))
656  return pf;
657  if (inKinds & PIXEL_FORMATS_RAW && !NTV2_FBF_IS_RAW(pf))
658  return pf;
659  if (inKinds & PIXEL_FORMATS_PACKED && !NTV2_IS_FBF_PRORES(pf))
660  return pf;
661  if (inKinds & PIXEL_FORMATS_ALPHA && !NTV2_FBF_HAS_ALPHA(pf))
662  return pf;
663  return NTV2_FBF_INVALID;
664 }
665 
666 
668 {
669  if (inKinds == NTV2_IOKINDS_ALL)
670  return gInputSources;
671 
672  NTV2InputSourceSet result;
673  if (inKinds & NTV2_IOKINDS_SDI)
674  result += gInputSourcesSDI;
675  if (inKinds & NTV2_IOKINDS_HDMI)
676  result += gInputSourcesHDMI;
677  if (inKinds & NTV2_IOKINDS_ANALOG)
678  result += gInputSourcesAnalog;
679  return result;
680 }
681 
682 
683 string CNTV2DemoCommon::GetInputSourceStrings (const NTV2IOKinds inKinds, const string inDevSpec)
684 {
685  const NTV2InputSourceSet & sourceSet (GetSupportedInputSources(inKinds));
686  CNTV2Card dev;
687  ostringstream oss;
688 
689  if (!inDevSpec.empty())
690  dev.Open(inDevSpec);
691 
692  oss << setw(25) << left << "Input Source" << "\t" << setw(16) << left << "Legal -i Values" << endl
693  << setw(25) << left << "------------------------" << "\t" << setw(16) << left << "----------------" << endl;
694  for (NTV2InputSourceSetConstIter iter(sourceSet.begin()); iter != sourceSet.end(); ++iter)
695  {
696  const NTV2InputSource src(*iter);
697  const string srcName (::NTV2InputSourceToString(src));
698  if (srcName.empty())
699  continue;
700  NTV2StringList srcNames;
702  if (src == it->second)
703  {
704  if (!inDevSpec.empty() && dev.IsOpen() && !dev.features().CanDoInputSource(src))
705  continue;
706  srcNames.push_back(it->first);
707  }
708  if (!srcNames.empty())
709  oss << setw(25) << left << srcName << "\t" << aja::join(srcNames, ", ") << endl;
710  }
711  return oss.str();
712 }
713 
714 
715 NTV2InputSource CNTV2DemoCommon::GetInputSourceFromString (const string & inStr, const NTV2IOKinds inKinds, const string inDevSpec)
716 {
718  if (iter == gString2InputSourceMap.end())
720 
721  CNTV2Card dev;
722  if (!inDevSpec.empty())
723  dev.Open(inDevSpec);
724 
725  // If a device was specifed, look for the first name-matching input source it supports...
726  NTV2InputSource src(iter->second);
727  while (dev.IsOpen() && !dev.features().CanDoInputSource(src))
728  {
729  if (++iter == gString2InputSourceMap.end())
731  if (inStr != iter->first)
733  src = iter->second;
734  }
735  if ((inKinds & NTV2_IOKINDS_ALL) == NTV2_IOKINDS_ALL)
736  return src;
737  if (inKinds & NTV2_IOKINDS_SDI && NTV2_INPUT_SOURCE_IS_SDI(src))
738  return src;
739  if (inKinds & NTV2_IOKINDS_HDMI && NTV2_INPUT_SOURCE_IS_HDMI(src))
740  return src;
741  if (inKinds & NTV2_IOKINDS_ANALOG && NTV2_INPUT_SOURCE_IS_ANALOG(src))
742  return src;
744 }
745 
746 
748 {
749  if (inKinds == NTV2_IOKINDS_ALL)
750  return gOutputDestinations;
751 
752  NTV2OutputDestinations result;
753  if (inKinds & NTV2_IOKINDS_SDI)
754  result += gOutputDestsSDI;
755  if (inKinds & NTV2_IOKINDS_HDMI)
756  result += gOutputDestsHDMI;
757  if (inKinds & NTV2_IOKINDS_ANALOG)
758  result += gOutputDestsAnalog;
759  return result;
760 }
761 
762 
763 string CNTV2DemoCommon::GetOutputDestinationStrings (const NTV2IOKinds inKinds, const string inDevSpec)
764 {
765  const NTV2OutputDestinations & dests (GetSupportedOutputDestinations(inKinds));
766  CNTV2Card dev;
767  ostringstream oss;
768 
769  if (!inDevSpec.empty())
770  dev.Open(inDevSpec);
771 
772  oss << setw(25) << left << "Output Destination" << "\t" << setw(16) << left << "Legal -o Values" << endl
773  << setw(25) << left << "------------------------" << "\t" << setw(16) << left << "----------------" << endl;
774  for (NTV2OutputDestinationsConstIter iter(dests.begin()); iter != dests.end(); ++iter)
775  {
776  const NTV2OutputDest dest(*iter);
777  const string destName(::NTV2OutputDestinationToString(dest));
778  if (destName.empty())
779  continue;
780  NTV2StringList destNames;
782  if (*iter == it->second)
783  {
784  if (!inDevSpec.empty() && dev.IsOpen() && !dev.features().CanDoOutputDestination(dest))
785  continue;
786  destNames.push_back(it->first);
787  }
788  if (!destNames.empty())
789  oss << setw(25) << left << destName << "\t" << aja::join(destNames, ", ") << endl;
790  }
791  return oss.str();
792 }
793 
794 
795 NTV2OutputDestination CNTV2DemoCommon::GetOutputDestinationFromString (const string & inStr, const NTV2IOKinds inKinds, const string inDevSpec)
796 {
798  if (iter == gString2OutputDestMap.end())
800 
801  CNTV2Card dev;
802  if (!inDevSpec.empty())
803  dev.Open(inDevSpec);
804 
805  // If a device was specifed, look for the first name-matching output destination it supports...
806  NTV2OutputDest dst(iter->second);
807  while (dev.IsOpen() && !dev.features().CanDoOutputDestination(dst))
808  {
809  if (++iter == gString2OutputDestMap.end())
811  if (inStr != iter->first)
813  dst = iter->second;
814  }
815  if ((inKinds & NTV2_IOKINDS_ALL) == NTV2_IOKINDS_ALL)
816  return dst;
817  if (inKinds & NTV2_IOKINDS_SDI && NTV2_OUTPUT_DEST_IS_SDI(dst))
818  return dst;
819  if (inKinds & NTV2_IOKINDS_HDMI && NTV2_OUTPUT_DEST_IS_HDMI(dst))
820  return dst;
821  if (inKinds & NTV2_IOKINDS_ANALOG && NTV2_OUTPUT_DEST_IS_ANALOG(dst))
822  return dst;
824 }
825 
826 
828 {
829  if (inKinds == TC_INDEXES_ALL)
830  return gTCIndexes;
831 
832  NTV2TCIndexes result;
833  if (inKinds & TC_INDEXES_SDI)
834  result += gTCIndexesSDI;
835  if (inKinds & TC_INDEXES_ANALOG)
836  result += gTCIndexesAnalog;
837  if (inKinds & TC_INDEXES_ATCLTC)
838  result += gTCIndexesATCLTC;
839  if (inKinds & TC_INDEXES_VITC1)
840  result += gTCIndexesVITC1;
841  if (inKinds & TC_INDEXES_VITC2)
842  result += gTCIndexesVITC2;
843  return result;
844 }
845 
847  const string inDevSpec,
848  const bool inIsInputOnly)
849 {
850  const NTV2TCIndexes & tcIndexes (GetSupportedTCIndexes(inKinds));
851  CNTV2Card dev;
852  ostringstream oss;
853 
854  if (!inDevSpec.empty())
855  dev.Open(inDevSpec);
856 
857  oss << setw(25) << left << "Timecode Index" << "\t" << setw(16) << left << "Legal Values" << endl
858  << setw(25) << left << "------------------------" << "\t" << setw(16) << left << "----------------" << endl;
859  for (NTV2TCIndexesConstIter iter (tcIndexes.begin()); iter != tcIndexes.end(); ++iter)
860  {
861  const NTV2TCIndex tcNdx(*iter);
862  const string tcNdxName (::NTV2TCIndexToString(tcNdx));
863  if (tcNdxName.empty())
864  continue;
865  NTV2StringList tcNdxNames;
866  for (String2TCIndexMapConstIter it (gString2TCIndexMap.begin()); it != gString2TCIndexMap.end(); ++it)
867  if (tcNdx == it->second)
868  {
869  if (!inDevSpec.empty() && dev.IsOpen())
870  if (!(inIsInputOnly ? dev.features().CanDoInputTCIndex(tcNdx) : dev.features().CanDoOutputTCIndex(tcNdx)))
871  continue;
872  tcNdxNames.push_back(it->first);
873  }
874  if (!tcNdxNames.empty())
875  oss << setw(25) << left << tcNdxName << "\t" << aja::join(tcNdxNames, ", ") << endl;
876  }
877  return oss.str();
878 }
879 
880 
881 NTV2TCIndex CNTV2DemoCommon::GetTCIndexFromString (const string & inStr, const NTV2TCIndexKinds inKinds, const string inDevSpec)
882 {
884  if (iter == gString2TCIndexMap.end())
885  return NTV2_TCINDEX_INVALID;
886 
887  CNTV2Card dev;
888  if (!inDevSpec.empty())
889  dev.Open(inDevSpec);
890 
891  // If a device was specifed, look for the first name-matching format it supports...
892  NTV2TCIndex tcNdx(iter->second);
894  while (dev.IsOpen() && !dev.features().CanDoInputSource(tcInpSrc))
895  {
896  if (++iter == gString2TCIndexMap.end())
897  return NTV2_TCINDEX_INVALID;
898  if (inStr != iter->first)
899  return NTV2_TCINDEX_INVALID;
900  tcNdx = iter->second;
901  tcInpSrc = ::NTV2TimecodeIndexToInputSource(tcNdx);
902  }
903  if ((inKinds & TC_INDEXES_ALL) == TC_INDEXES_ALL)
904  return tcNdx;
906  return tcNdx;
907  if (inKinds & TC_INDEXES_ANALOG && NTV2_IS_ANALOG_TIMECODE_INDEX(tcNdx))
908  return tcNdx;
909  if (inKinds & TC_INDEXES_ATCLTC && NTV2_IS_ATC_LTC_TIMECODE_INDEX(tcNdx))
910  return tcNdx;
911  if (inKinds & TC_INDEXES_VITC1 && NTV2_IS_ATC_VITC1_TIMECODE_INDEX(tcNdx))
912  return tcNdx;
913  if (inKinds & TC_INDEXES_VITC2 && NTV2_IS_ATC_VITC2_TIMECODE_INDEX(tcNdx))
914  return tcNdx;
915  return NTV2_TCINDEX_INVALID;
916 }
917 
918 
919 string CNTV2DemoCommon::GetAudioSystemStrings (const string inDeviceSpecifier)
920 {
921  CNTV2Card device;
922  string displayName;
923  ostringstream oss;
924 
925  if (!inDeviceSpecifier.empty())
926  {
927  CNTV2DeviceScanner::GetFirstDeviceFromArgument (inDeviceSpecifier, device);
928  if (device.IsOpen())
929  displayName = device.GetDisplayName();
930  }
931 
932  const UWord numAudioSystems (device.features().GetNumAudioSystems());
933  oss << setw(12) << left << "Audio System" << endl
934  << setw(12) << left << "------------" << endl;
935  for (UWord ndx(0); ndx < 8; ndx++)
936  {
937  oss << setw(12) << left << (ndx+1);
938  if (!displayName.empty() && ndx >= numAudioSystems)
939  oss << "\t## Incompatible with " << displayName;
940  oss << endl;
941  }
942  return oss.str();
943 }
944 
945 
947 {
949  return iter != gString2AudioSystemMap.end() ? iter->second : NTV2_AUDIOSYSTEM_INVALID;
950 }
951 
953 {
954  typedef map<string,string> NTV2StringMap;
955  NTV2StringSet keys;
956  for (String2VANCModeMapConstIter it(gString2VANCModeMap.begin()); it != gString2VANCModeMap.end(); ++it)
957  {
958  const string val(aja::to_string(it->second));
959  if (keys.find(val) == keys.end())
960  keys.insert(val);
961  }
962 
963  NTV2StringMap legals;
964  for (NTV2StringSet::const_iterator kit(keys.begin()); kit != keys.end(); ++kit)
965  {
966  NTV2VANCMode officialVM(NTV2VANCMode(aja::stoul(*kit)));
967  NTV2StringList legalValues;
968  for (String2VANCModeMapConstIter it(gString2VANCModeMap.begin()); it != gString2VANCModeMap.end(); ++it)
969  if (it->second == officialVM)
970  legalValues.push_back(it->first);
971  legals[aja::to_string(officialVM)] = aja::join(legalValues, ", ");
972  }
973 
974  ostringstream oss;
975  oss << setw(12) << left << "VANC Mode" << "\t" << setw(32) << left << "Legal --vanc Values " << endl
976  << setw(12) << left << "---------" << "\t" << setw(32) << left << "--------------------------------" << endl;
977  for (NTV2StringMap::const_iterator it(legals.begin()); it != legals.end(); ++it)
978  oss << setw(12) << left << it->first << "\t" << setw(32) << left << it->second << endl;
979  return oss.str();
980 }
981 
982 
984 {
986  return iter != gString2VANCModeMap.end() ? iter->second : NTV2_VANCMODE_INVALID;
987 }
988 
989 
991 {
992  typedef map<string,string> NTV2StringMap;
993  NTV2StringSet keys;
994  for (String2TPNamesMapConstIter it(gString2TPNamesMap.begin()); it != gString2TPNamesMap.end(); ++it)
995  if (keys.find(it->second) == keys.end())
996  keys.insert(it->second);
997 
998  NTV2StringMap legals;
999  for (NTV2StringSet::const_iterator kit(keys.begin()); kit != keys.end(); ++kit)
1000  {
1001  const string & officialPatName(*kit);
1002  NTV2StringList legalValues;
1003  for (String2TPNamesMapConstIter it(gString2TPNamesMap.begin()); it != gString2TPNamesMap.end(); ++it)
1004  if (it->second == officialPatName)
1005  legalValues.push_back(it->first);
1006  legals[officialPatName] = aja::join(legalValues, ", ");
1007  }
1008 
1009  ostringstream oss;
1010  oss << setw(25) << left << "Test Pattern or Color " << "\t" << setw(22) << left << "Legal --pattern Values" << endl
1011  << setw(25) << left << "------------------------" << "\t" << setw(22) << left << "----------------------" << endl;
1012  for (NTV2StringMap::const_iterator it(legals.begin()); it != legals.end(); ++it)
1013  oss << setw(25) << left << it->first << "\t" << setw(22) << left << it->second << endl;
1014  return oss.str();
1015 }
1016 
1017 
1019 {
1020  string tpName(inStr);
1021  aja::lower(aja::strip(aja::replace(tpName, " ", "")));
1023  return (it != gString2TPNamesMap.end()) ? it->second : "";
1024 }
1025 
1026 
1027 string CNTV2DemoCommon::ToLower (const string & inStr)
1028 {
1029  string result(inStr);
1030  return aja::lower(result);
1031 }
1032 
1033 
1034 string CNTV2DemoCommon::StripFormatString (const std::string & inStr)
1035 {
1036  string result (inStr);
1037  while (result.find (" ") != string::npos)
1038  result.erase (result.find (" "), 1);
1039  while (result.find ("00") != string::npos)
1040  result.erase (result.find ("00"), 2);
1041  while (result.find (".") != string::npos)
1042  result.erase (result.find ("."), 1);
1043  return result;
1044 }
1045 
1046 
1048 {
1049  char result (0);
1050  #if defined (AJAMac) || defined (AJALinux)
1051  struct termios terminalStatus;
1052  ::memset (&terminalStatus, 0, sizeof (terminalStatus));
1053  if (::tcgetattr (0, &terminalStatus) < 0)
1054  cerr << "tcsetattr()";
1055  terminalStatus.c_lflag &= ~uint32_t(ICANON);
1056  terminalStatus.c_lflag &= ~uint32_t(ECHO);
1057  terminalStatus.c_cc[VMIN] = 1;
1058  terminalStatus.c_cc[VTIME] = 0;
1059  if (::tcsetattr (0, TCSANOW, &terminalStatus) < 0)
1060  cerr << "tcsetattr ICANON";
1061  if (::read (0, &result, 1) < 0)
1062  cerr << "read()" << endl;
1063  terminalStatus.c_lflag |= ICANON;
1064  terminalStatus.c_lflag |= ECHO;
1065  if (::tcsetattr (0, TCSADRAIN, &terminalStatus) < 0)
1066  cerr << "tcsetattr ~ICANON" << endl;
1067  #elif defined (MSWindows) || defined (AJAWindows)
1068  HANDLE hdl (GetStdHandle (STD_INPUT_HANDLE));
1069  DWORD nEvents (0);
1070  INPUT_RECORD buffer;
1071  PeekConsoleInput (hdl, &buffer, 1, &nEvents);
1072  if (nEvents > 0)
1073  {
1074  ReadConsoleInput (hdl, &buffer, 1, &nEvents);
1075  result = char (buffer.Event.KeyEvent.wVirtualKeyCode);
1076  }
1077  #endif
1078  return result;
1079 }
1080 
1081 
1083 {
1084  cout << "## Press Enter/Return key to exit: ";
1085  cout.flush();
1086  cin.get();
1087 }
1088 
1089 
1091 {
1093  switch (inFrameRate)
1094  {
1095  case NTV2_FRAMERATE_6000: result = kTCFormat60fps; break;
1096  case NTV2_FRAMERATE_5994: result = kTCFormat60fpsDF; break;
1097  case NTV2_FRAMERATE_4800: result = kTCFormat48fps; break;
1098  case NTV2_FRAMERATE_4795: result = kTCFormat48fps; break;
1099  case NTV2_FRAMERATE_3000: result = kTCFormat30fps; break;
1100  case NTV2_FRAMERATE_2997: result = kTCFormat30fpsDF; break;
1101  case NTV2_FRAMERATE_2500: result = kTCFormat25fps; break;
1102  case NTV2_FRAMERATE_2400: result = kTCFormat24fps; break;
1103  case NTV2_FRAMERATE_2398: result = kTCFormat24fps; break;
1104  case NTV2_FRAMERATE_5000: result = kTCFormat50fps; break;
1105  default: break;
1106  }
1107  return result;
1108 
1109 } // NTV2FrameRate2TimecodeFormat
1110 
1111 
1113 {
1114  switch (inFrameRate)
1115  {
1118 #if !defined(NTV2_DEPRECATE_16_0)
1123 #endif
1124  case NTV2_FRAMERATE_5000: return AJA_FrameRate_5000;
1136 
1137  case NTV2_NUM_FRAMERATES:
1138  case NTV2_FRAMERATE_UNKNOWN: break;
1139  }
1140  return AJA_FrameRate_Unknown;
1141 } // GetAJAFrameRate
1142 
1143 
1145 {
1146  switch (inFormat)
1147  {
1150  case NTV2_FBF_ARGB: return AJA_PixelFormat_ARGB8;
1151  case NTV2_FBF_RGBA: return AJA_PixelFormat_RGBA8;
1154  case NTV2_FBF_ABGR: return AJA_PixelFormat_ABGR8;
1168 
1173 
1178 
1181  case NTV2_FBF_10BIT_ARGB:
1182  case NTV2_FBF_16BIT_ARGB:
1183  case NTV2_FBF_INVALID: break;
1184  }
1185  return AJA_PixelFormat_Unknown;
1186 } // GetAJAPixelFormat
1187 
1188 
1190 {
1191  static struct VideoFormatPair
1192  {
1193  NTV2VideoFormat vIn;
1194  NTV2VideoFormat vOut;
1195  } VideoFormatPairs[] = { // vIn vOut
1214 
1218 
1222  };
1223  for (size_t formatNdx(0); formatNdx < sizeof(VideoFormatPairs) / sizeof(VideoFormatPair); formatNdx++)
1224  if (VideoFormatPairs[formatNdx].vIn == inOutVideoFormat)
1225  {
1226  inOutVideoFormat = VideoFormatPairs[formatNdx].vOut;
1227  return true;
1228  }
1229  return false;
1230 
1231 } // get4KInputFormat
1232 
1234 {
1235  static struct VideoFormatPair
1236  {
1237  NTV2VideoFormat vIn;
1238  NTV2VideoFormat vOut;
1239  } VideoFormatPairs[] = { // vIn vOut
1266  };
1267  for (size_t formatNdx(0); formatNdx < sizeof(VideoFormatPairs) / sizeof(VideoFormatPair); formatNdx++)
1268  if (VideoFormatPairs[formatNdx].vIn == inOutVideoFormat)
1269  {
1270  inOutVideoFormat = VideoFormatPairs[formatNdx].vOut;
1271  return true;
1272  }
1273  return false;
1274 
1275 } // get8KInputFormat
1276 
1277 
1279 {
1280  return gGlobalMutexName.c_str();
1281 }
1282 
1284 {
1285  UWord totFrameStores(inDevice.features().GetNumFrameStores());
1286  UWord totTSIMuxers(inDevice.features().GetNumTSIMuxers());
1287  UWord firstFramestoreIndex = UWord(::GetIndexForNTV2Channel(in1stFrameStore));
1288  UWord tsiMux(firstFramestoreIndex);
1289  NTV2ChannelList result;
1290  if (totFrameStores > totTSIMuxers)
1291  tsiMux = firstFramestoreIndex/2;
1292  else if (totFrameStores < totTSIMuxers)
1293  tsiMux = firstFramestoreIndex*2;
1294  for (UWord num(0); num < inCount; num++)
1295  result.push_back(NTV2Channel(tsiMux + num));
1296  return result;
1297 }
1298 
1299 
1301  const CaptureConfig & inConfig,
1302  const bool isInputRGB)
1303 {
1304  const bool isFrameRGB (::IsRGBFormat(inConfig.fPixelFormat));
1306  const NTV2OutputXptID inputOXpt (::GetInputSourceOutputXpt(inConfig.fInputSource, false, isInputRGB));
1307  const NTV2InputXptID cscVidIXpt (::GetCSCInputXptFromChannel(inConfig.fInputChannel));
1308  NTV2OutputXptID cscOXpt (::GetCSCOutputXptFromChannel(inConfig.fInputChannel, /*key?*/false, /*RGB?*/isFrameRGB));
1309 
1310  conns.clear();
1311  if (isInputRGB && !isFrameRGB)
1312  {
1313  conns.insert(NTV2Connection(fbIXpt, cscOXpt)); // FB <== CSC
1314  conns.insert(NTV2Connection(cscVidIXpt, inputOXpt)); // CSC <== SDIIn/HDMIin
1315  }
1316  else if (!isInputRGB && isFrameRGB)
1317  {
1318  conns.insert(NTV2Connection(fbIXpt, cscOXpt)); // FB <== CSC
1319  conns.insert(NTV2Connection(cscVidIXpt, inputOXpt)); // CSC <== SDIIn/HDMIIn
1320  }
1321  else
1322  conns.insert(NTV2Connection(fbIXpt, inputOXpt)); // FB <== SDIIn/HDMIin
1323 
1324  return !conns.empty();
1325 
1326 } // GetRoutingCapture
1327 
1328 
1330  const CaptureConfig & inConfig,
1331  const NTV2DeviceID devID,
1332  const bool isInputRGB)
1333 {
1334  UWord sdi(0), mux(0), csc(0), fb(0), path(0);
1337  const bool isFrameRGB (::IsRGBFormat(inConfig.fPixelFormat));
1338  conns.clear();
1340  { // HDMI
1341  if (inConfig.fInputChannel == NTV2_CHANNEL1)
1342  { // HDMI CH1234
1343  if (isInputRGB == isFrameRGB)
1344  { // HDMI CH1234 RGB SIGNAL AND RGB FBF OR YUV SIGNAL AND YUV FBF
1345  for (path = 0; path < 4; path++)
1346  { // MUX <== HDMIIn
1347  in = ::GetTSIMuxInputXptFromChannel(NTV2Channel(mux+path/2), /*LinkB*/path & 1);
1348  out = ::GetInputSourceOutputXpt(inConfig.fInputSource, /*DS2*/false, isInputRGB, /*quadrant*/path);
1349  conns.insert(NTV2Connection(in, out));
1350  // FB <== MUX
1351  in = ::GetFrameStoreInputXptFromChannel(NTV2Channel(fb+path/2), /*Binput*/path & 1);
1352  out = ::GetTSIMuxOutputXptFromChannel(NTV2Channel(mux+path/2), /*LinkB*/path & 1, /*RGB*/isInputRGB);
1353  conns.insert(NTV2Connection(in, out));
1354  }
1355  } // HDMI CH1234 RGB SIGNAL AND RGB FBF
1356  else if (isInputRGB && !isFrameRGB)
1357  { // HDMI CH1234 RGB SIGNAL AND YUV FBF
1358  for (path = 0; path < 4; path++)
1359  {
1360  // CSC <== HDMIIn
1361  in = ::GetCSCInputXptFromChannel(NTV2Channel(csc+path));
1362  out = ::GetInputSourceOutputXpt(inConfig.fInputSource, /*DS2*/false, isInputRGB, /*quadrant*/path);
1363  conns.insert(NTV2Connection(in, out));
1364  // MUX <== CSC
1365  in = ::GetTSIMuxInputXptFromChannel(NTV2Channel(mux+path/2), /*LinkB*/path & 1);
1366  out = ::GetCSCOutputXptFromChannel(NTV2Channel(csc+path), /*key*/false, /*rgb*/isFrameRGB);
1367  conns.insert(NTV2Connection(in, out));
1368  // FB <== MUX
1369  in = ::GetFrameStoreInputXptFromChannel(NTV2Channel(fb+path/2), /*DS2*/path & 1);
1370  out = ::GetTSIMuxOutputXptFromChannel(NTV2Channel(mux+path/2), /*LinkB*/path & 1, /*rgb*/isFrameRGB);
1371  conns.insert(NTV2Connection(in, out));
1372  }
1373  } // HDMI CH1234 RGB SIGNAL AND YUV FBF
1374  else // !isInputRGB && isFrameRGB
1375  { // HDMI CH1234 YUV SIGNAL AND RGB FBF
1376  for (path = 0; path < 4; path++)
1377  {
1378  // CSC <== HDMIIn
1379  in = ::GetCSCInputXptFromChannel(NTV2Channel(csc+path));
1380  out = ::GetInputSourceOutputXpt(inConfig.fInputSource, /*DS2*/false, isInputRGB, /*quadrant*/path);
1381  conns.insert(NTV2Connection(in, out));
1382  // MUX <== CSC
1383  in = ::GetTSIMuxInputXptFromChannel(NTV2Channel(mux+path/2), /*LinkB*/path & 1);
1384  out = ::GetCSCOutputXptFromChannel(NTV2Channel(csc+path), /*key*/false, /*rgb*/isFrameRGB);
1385  conns.insert(NTV2Connection(in, out));
1386  // FB <== MUX
1387  in = ::GetFrameStoreInputXptFromChannel(NTV2Channel(fb+path/2), /*DS2*/path & 1);
1388  out = ::GetTSIMuxOutputXptFromChannel(NTV2Channel(mux+path/2), /*LinkB*/path & 1, /*rgb*/isFrameRGB);
1389  conns.insert(NTV2Connection(in, out));
1390  }
1391  } // HDMI CH1234 YUV SIGNAL AND RGB FBF
1392  } // HDMI CH1234
1393  else
1394  { // HDMI CH5678
1395  cerr << "## ERROR: Ch5678 must be for Corvid88, but no HDMI on that device" << endl;
1396  } // HDMI CH5678
1397  } // HDMI
1398  else
1399  { // SDI
1400  if (::NTV2DeviceCanDo12gRouting(devID))
1401  { // FB <== SDIIn
1403  out = ::GetInputSourceOutputXpt(inConfig.fInputSource);
1404  conns.insert(NTV2Connection(in, out));
1405  }
1406  else
1407  { // SDI CH1234 or CH5678
1408  if (inConfig.fInputChannel != NTV2_CHANNEL1)
1409  {fb = 4; sdi = fb; mux = fb / 2; csc = fb;}
1410  if (isFrameRGB)
1411  { // RGB FB
1412  if (inConfig.fDoTSIRouting)
1413  { // SDI CH1234 RGB TSI
1414  for (path = 0; path < 4; path++)
1415  {
1416  // CSC <== SDIIn
1417  in = ::GetCSCInputXptFromChannel(NTV2Channel(csc+path));
1419  conns.insert(NTV2Connection(in, out));
1420  // MUX <== CSC
1421  in = ::GetTSIMuxInputXptFromChannel(NTV2Channel(mux+path/2), /*LinkB*/path & 1);
1422  out = ::GetCSCOutputXptFromChannel(NTV2Channel(csc+path), /*key*/false, /*rgb*/isFrameRGB);
1423  conns.insert(NTV2Connection(in, out));
1424  // FB <== MUX
1425  in = ::GetFrameStoreInputXptFromChannel(NTV2Channel(fb+path/2), /*DS2*/path & 1);
1426  out = ::GetTSIMuxOutputXptFromChannel(NTV2Channel(mux+path/2), /*LinkB*/path & 1, /*rgb*/isFrameRGB);
1427  conns.insert(NTV2Connection(in, out));
1428  } // for each spigot
1429  } // SDI CH1234 RGB TSI
1430  else
1431  { // SDI CH1234 RGB SQUARES
1432  for (path = 0; path < 4; path++)
1433  {
1434  // CSC <== SDIIn
1435  in = ::GetCSCInputXptFromChannel(NTV2Channel(csc+path));
1437  conns.insert(NTV2Connection(in, out));
1438  // FB <== CSC
1440  out = ::GetCSCOutputXptFromChannel(NTV2Channel(csc+path), /*key*/false, /*rgb*/isFrameRGB);
1441  conns.insert(NTV2Connection(in, out));
1442  } // for each spigot
1443  } // SDI CH1234 RGB SQUARES
1444  } // SDI CH1234 RGB FBF
1445  else // YUV FBF
1446  {
1447  if (inConfig.fDoTSIRouting)
1448  { // SDI CH1234 YUV TSI
1449  for (path = 0; path < 4; path++)
1450  {
1451  // MUX <== SDIIn
1452  in = ::GetTSIMuxInputXptFromChannel(NTV2Channel(mux+path/2), /*LinkB*/path & 1);
1454  conns.insert(NTV2Connection(in, out));
1455  // FB <== MUX
1456  in = ::GetFrameStoreInputXptFromChannel(NTV2Channel(fb+path/2), /*DS2*/path & 1);
1457  out = ::GetTSIMuxOutputXptFromChannel(NTV2Channel(mux+path/2), /*LinkB*/path & 1, /*rgb*/isFrameRGB);
1458  conns.insert(NTV2Connection(in, out));
1459  } // for each spigot
1460  } // SDI CH1234 YUV TSI
1461  else
1462  {
1463  for (path = 0; path < 4; path++)
1464  { // FB <== SDIIn
1467  conns.insert(NTV2Connection(in, out));
1468  } // for each path
1469  } // SDI CH1234 YUV SQUARES
1470  } // YUV FBF
1471  } // 3G SDI CH1234 or CH5678
1472  } // SDI
1473  return !conns.empty();
1474 } // GetRoutingCapture4K
1475 
1476 
1478  const CaptureConfig & inConfig,
1479  const NTV2VideoFormat inVideoFormat,
1480  const NTV2DeviceID devID,
1481  const bool isInputRGB)
1482 { (void)isInputRGB; (void) devID;
1483  UWord fb(0), path(0);
1486  const bool isFrameRGB (::IsRGBFormat(inConfig.fPixelFormat));
1487  const bool isQuadQuadHFR (NTV2_IS_QUAD_QUAD_HFR_VIDEO_FORMAT(inVideoFormat));
1488  conns.clear();
1489  if (inConfig.fInputChannel % 2)
1490  return false; // Input channel cannot be Ch2/Ch4/Ch6/etc
1491  if (inConfig.fInputChannel > 3)
1492  return false; // Input channel cannot be Ch5 or greater
1493  if (::NTV2InputSourceToChannel(inConfig.fInputSource) % 2)
1494  return false; // Input source cannot be SDIIn2/4/6/etc
1495  if (::NTV2InputSourceToChannel(inConfig.fInputSource) > 3)
1496  return false; // Input source cannot be SDIIn5 or greater
1497 
1498  if (inConfig.fDoTSIRouting)
1499  { // TSI
1500  if (inConfig.fInputChannel)
1501  fb = 2;
1502  for (path = 0; path < 4; path++)
1503  if (isFrameRGB) // Uses 2 FBs, 4 SDIs
1504  { // RGB
1505  // DLInDS1 <== SDIInDS1
1506  in = ::GetDLInInputXptFromChannel (NTV2Channel(path), /*B*/false);
1507  out = ::GetSDIInputOutputXptFromChannel (NTV2Channel(path), /*DS2*/false);
1508  conns.insert(NTV2Connection(in, out));
1509  // DLInDS2 <== SDIInDS2
1510  in = ::GetDLInInputXptFromChannel (NTV2Channel(path), /*B*/true);
1511  out = ::GetSDIInputOutputXptFromChannel (NTV2Channel(path), /*DS2*/true);
1512  conns.insert(NTV2Connection(in, out));
1513  // FB <== DLIn
1514  in = ::GetFrameStoreInputXptFromChannel (NTV2Channel(fb+path/2), /*B*/path & 1);
1516  conns.insert(NTV2Connection(in, out));
1517  } // if RGB
1518  else if (isQuadQuadHFR) // Uses 2 FBs, 4 SDIs
1519  { // FB <== SDIIn, FBDS2 <== SDIIn
1520  in = ::GetFrameStoreInputXptFromChannel (NTV2Channel(fb+path/2), /*DS2?*/path & 1);
1522  conns.insert(NTV2Connection(in, out));
1523  } // else if YUV QuadQuad
1524  else // Uses 2 FBs, 2 SDIs
1525  { // FB <== SDIIn, FBDS2 <== SDIInDS2
1526  in = ::GetFrameStoreInputXptFromChannel (NTV2Channel(fb+path/2), /*DS2?*/path & 1);
1527  out = ::GetSDIInputOutputXptFromChannel (NTV2Channel(fb+path/2), /*DS2?*/path & 1);
1528  conns.insert(NTV2Connection(in, out));
1529  } // else YUV non-QuadQuad
1530  } // if TSI
1531  else
1532  { // Square-division routing
1533  if (inConfig.fInputChannel)
1534  return false; // Sorry, Ch1 only
1535  if (inConfig.fInputSource != NTV2_INPUTSOURCE_SDI1)
1536  return false; // Sorry, SDI1 only (1st SDI of 4 links)
1537  for (path = 0; path < 4; path++) // 4 FBs, 4 SDIs
1538  if (isFrameRGB)
1539  { // RGB
1540  // DLInDS1 <== SDIInDS1
1541  in = ::GetDLInInputXptFromChannel (NTV2Channel(path), /*B*/false);
1542  out = ::GetSDIInputOutputXptFromChannel (NTV2Channel(path), /*DS2*/false);
1543  conns.insert(NTV2Connection(in, out));
1544  // DLInDS2 <== SDIInDS2
1545  in = ::GetDLInInputXptFromChannel (NTV2Channel(path), /*B*/true);
1546  out = ::GetSDIInputOutputXptFromChannel (NTV2Channel(path), /*DS2*/true);
1547  conns.insert(NTV2Connection(in, out));
1548  // FB <== DLIn
1551  conns.insert(NTV2Connection(in, out));
1552  } // for each path
1553  else // YUV
1554  { // FB <== SDIIn
1557  conns.insert(NTV2Connection(in, out));
1558  } // for each path
1559  } // else Squares
1560  return !conns.empty();
1561 } // GetInputRouting8K
1562 
1563 
1564 bool CNTV2DemoCommon::ConfigureAudioSystems (CNTV2Card & inDevice, const CaptureConfig & inConfig, const NTV2AudioSystemSet inAudioSystems)
1565 {
1566  UWord failures(0);
1567  UWord numAudChannels(inDevice.features().GetMaxAudioChannels());
1568  for (NTV2AudioSystemSetConstIter it(inAudioSystems.begin()); it != inAudioSystems.end(); ++it)
1569  { const NTV2AudioSystem audSys(*it);
1570  // Have the audio system capture audio from the designated device input...
1571  if (!inDevice.SetAudioSystemInputSource (audSys, NTV2_AUDIO_EMBEDDED,
1573  failures++;
1574 
1575  // Configure for max available audio channels, 48KHz, 4MB buffers, and disable loopback...
1576  if (!inDevice.SetNumberAudioChannels (numAudChannels, audSys)) failures++;
1577  if (!inDevice.SetAudioRate (NTV2_AUDIO_48K, audSys)) failures++;
1578  if (!inDevice.SetAudioBufferSize (NTV2_AUDIO_BUFFER_SIZE_4MB, audSys)) failures++;
1579  if (!inDevice.SetAudioLoopBack(NTV2_AUDIO_LOOPBACK_OFF, audSys)) failures++;
1580  }
1581  return !failures;
1582 }
1583 
1584 
1586 {
1587  const size_t hwPageSizeBytes (NTV2Buffer::HostPageSize());
1588  const size_t sdkPageSizeBytes (NTV2Buffer::DefaultPageSize());
1589  if (hwPageSizeBytes != sdkPageSizeBytes)
1590  {
1591  if (NTV2Buffer::SetDefaultPageSize(hwPageSizeBytes))
1592  cerr << "## NOTE: Page size changed from " << DEC(sdkPageSizeBytes/1024) << "K to " << DEC(hwPageSizeBytes/1024) << "K" << endl;
1593  else
1594  cerr << "## WARNING: Failed to change page size from " << DEC(sdkPageSizeBytes/1024) << "K to " << DEC(hwPageSizeBytes/1024) << "K" << endl;
1595  }
1596  return hwPageSizeBytes;
1597 }
1598 
1599 
1600 CNTV2DemoCommon::Popt::Popt (const int inArgc, const char ** pArgs, const PoptOpts * pInOptionsTable)
1601 {
1602  mContext = ::poptGetContext(AJA_NULL, inArgc, pArgs, pInOptionsTable, 0);
1603  mResult = ::poptGetNextOpt(mContext);
1604  if (mResult < -1)
1605  { ostringstream oss;
1606  oss << ::poptBadOption(mContext, 0) << ": " << ::poptStrerror(mResult);
1607  mError = oss.str();
1608  }
1609  else
1610  {
1611  const char * pStr (::poptGetArg(mContext));
1612  while (pStr)
1613  {
1614  mOtherArgs.push_back(string(pStr)); // Append to file list
1615  pStr = ::poptGetArg(mContext);
1616  } // for each additional positional argument
1617  }
1618 }
1619 
1621 {
1622  mContext = ::poptFreeContext(mContext);
1623 }
1624 
1625 
1627 {
1628  typedef struct {string fName; NTV2VideoFormat fFormat;} FormatNameDictionary;
1629  static const FormatNameDictionary sVFmtDict[] = {
1630  {"1080i50", NTV2_FORMAT_1080i_5000},
1631  {"1080i", NTV2_FORMAT_1080i_5994},
1632  {"1080i5994", NTV2_FORMAT_1080i_5994},
1633  {"hd", NTV2_FORMAT_1080i_5994},
1634  {"1080i60", NTV2_FORMAT_1080i_6000},
1635  {"720p", NTV2_FORMAT_720p_5994},
1636  {"720p5994", NTV2_FORMAT_720p_5994},
1637  {"720p60", NTV2_FORMAT_720p_6000},
1638  {"1080psf2398", NTV2_FORMAT_1080psf_2398},
1639  {"1080psf24", NTV2_FORMAT_1080psf_2400},
1640  {"1080p2997", NTV2_FORMAT_1080p_2997},
1641  {"1080p30", NTV2_FORMAT_1080p_3000},
1642  {"1080p25", NTV2_FORMAT_1080p_2500},
1643  {"1080p2398", NTV2_FORMAT_1080p_2398},
1644  {"1080p24", NTV2_FORMAT_1080p_2400},
1645  {"2048x1080p2398", NTV2_FORMAT_1080p_2K_2398},
1646  {"2048x1080p24", NTV2_FORMAT_1080p_2K_2400},
1647  {"2048x1080psf2398", NTV2_FORMAT_1080psf_2K_2398},
1648  {"2048x1080psf24", NTV2_FORMAT_1080psf_2K_2400},
1649  {"720p50", NTV2_FORMAT_720p_5000},
1650  {"1080p50b", NTV2_FORMAT_1080p_5000_B},
1651  {"1080p", NTV2_FORMAT_1080p_5994_B},
1652  {"1080p5994b", NTV2_FORMAT_1080p_5994_B},
1653  {"1080p60b", NTV2_FORMAT_1080p_6000_B},
1654  {"720p2398", NTV2_FORMAT_720p_2398},
1655  {"720p25", NTV2_FORMAT_720p_2500},
1656  {"1080p50", NTV2_FORMAT_1080p_5000_A},
1657  {"1080p5994", NTV2_FORMAT_1080p_5994_A},
1658  {"1080p60", NTV2_FORMAT_1080p_6000_A},
1659  {"2048x1080p25", NTV2_FORMAT_1080p_2K_2500},
1660  {"2048x1080psf25", NTV2_FORMAT_1080psf_2K_2500},
1661  {"1080psf25", NTV2_FORMAT_1080psf_2500_2},
1662  {"1080psf2997", NTV2_FORMAT_1080psf_2997_2},
1663  {"1080psf30", NTV2_FORMAT_1080psf_3000_2},
1664  {"525i", NTV2_FORMAT_525_5994},
1665  {"525i2997", NTV2_FORMAT_525_5994},
1666  {"sd", NTV2_FORMAT_525_5994},
1667  {"625i", NTV2_FORMAT_625_5000},
1668  {"625i25", NTV2_FORMAT_625_5000},
1669  {"525i2398", NTV2_FORMAT_525_2398},
1670  {"525i24", NTV2_FORMAT_525_2400},
1671  {"525psf2997", NTV2_FORMAT_525psf_2997},
1672  {"625psf25", NTV2_FORMAT_625psf_2500},
1673  {"2048x1556psf1498", NTV2_FORMAT_2K_1498},
1674  {"2048x1556psf15", NTV2_FORMAT_2K_1500},
1675  {"2048x1556psf2398", NTV2_FORMAT_2K_2398},
1676  {"2048x1556psf24", NTV2_FORMAT_2K_2400},
1677  {"2048x1556psf25", NTV2_FORMAT_2K_2500},
1678  {"4x1920x1080psf2398", NTV2_FORMAT_4x1920x1080psf_2398},
1679  {"4x1920x1080psf24", NTV2_FORMAT_4x1920x1080psf_2400},
1680  {"4x1920x1080psf25", NTV2_FORMAT_4x1920x1080psf_2500},
1681  {"4x1920x1080p2398", NTV2_FORMAT_4x1920x1080p_2398},
1682  {"uhd2398", NTV2_FORMAT_4x1920x1080p_2398},
1683  {"4x1920x1080p24", NTV2_FORMAT_4x1920x1080p_2400},
1684  {"uhd24", NTV2_FORMAT_4x1920x1080p_2400},
1685  {"4x1920x1080p25", NTV2_FORMAT_4x1920x1080p_2500},
1686  {"uhd25", NTV2_FORMAT_4x1920x1080p_2500},
1687  {"4x2048x1080psf2398", NTV2_FORMAT_4x2048x1080psf_2398},
1688  {"4x2048x1080psf24", NTV2_FORMAT_4x2048x1080psf_2400},
1689  {"4x2048x1080psf25", NTV2_FORMAT_4x2048x1080psf_2500},
1690  {"4k2398", NTV2_FORMAT_4x2048x1080p_2398},
1691  {"4x2048x1080p2398", NTV2_FORMAT_4x2048x1080p_2398},
1693  {"4x2048x1080p24", NTV2_FORMAT_4x2048x1080p_2400},
1695  {"4x2048x1080p25", NTV2_FORMAT_4x2048x1080p_2500},
1696  {"4x1920x1080p2997", NTV2_FORMAT_4x1920x1080p_2997},
1697  {"4x1920x1080p30", NTV2_FORMAT_4x1920x1080p_3000},
1698  {"4x1920x1080psf2997", NTV2_FORMAT_4x1920x1080psf_2997},
1699  {"4x1920x1080psf30", NTV2_FORMAT_4x1920x1080psf_3000},
1700  {"4x2048x1080p2997", NTV2_FORMAT_4x2048x1080p_2997},
1701  {"4x2048x1080p30", NTV2_FORMAT_4x2048x1080p_3000},
1702  {"4x2048x1080psf2997", NTV2_FORMAT_4x2048x1080psf_2997},
1703  {"4x2048x1080psf30", NTV2_FORMAT_4x2048x1080psf_3000},
1704  {"4x1920x1080p50", NTV2_FORMAT_4x1920x1080p_5000},
1705  {"uhd50", NTV2_FORMAT_4x1920x1080p_5000},
1706  {"4x1920x1080p5994", NTV2_FORMAT_4x1920x1080p_5994},
1707  {"uhd5994", NTV2_FORMAT_4x1920x1080p_5994},
1708  {"4x1920x1080p60", NTV2_FORMAT_4x1920x1080p_6000},
1710  {"uhd60", NTV2_FORMAT_4x1920x1080p_6000},
1712  {"4x2048x1080p50", NTV2_FORMAT_4x2048x1080p_5000},
1713  {"4k5994", NTV2_FORMAT_4x2048x1080p_5994},
1714  {"4x2048x1080p5994", NTV2_FORMAT_4x2048x1080p_5994},
1717  {"4x2048x1080p60", NTV2_FORMAT_4x2048x1080p_6000},
1718  {"4k4795", NTV2_FORMAT_4x2048x1080p_4795},
1719  {"4x2048x1080p4795", NTV2_FORMAT_4x2048x1080p_4795},
1721  {"4x2048x1080p48", NTV2_FORMAT_4x2048x1080p_4800},
1722  {"4k11988", NTV2_FORMAT_4x2048x1080p_11988},
1723  {"4x2048x1080p11988", NTV2_FORMAT_4x2048x1080p_11988},
1724  {"4k120", NTV2_FORMAT_4x2048x1080p_12000},
1725  {"4x2048x1080p120", NTV2_FORMAT_4x2048x1080p_12000},
1726  {"2048x1080p60", NTV2_FORMAT_1080p_2K_6000_A},
1727  {"2048x1080p5994", NTV2_FORMAT_1080p_2K_5994_A},
1728  {"2048x1080p2997", NTV2_FORMAT_1080p_2K_2997},
1729  {"2048x1080p30", NTV2_FORMAT_1080p_2K_3000},
1730  {"2048x1080p50", NTV2_FORMAT_1080p_2K_5000_A},
1731  {"2048x1080p4795", NTV2_FORMAT_1080p_2K_4795_A},
1732  {"2048x1080p48", NTV2_FORMAT_1080p_2K_4800_A},
1733  {"2048x1080p60b", NTV2_FORMAT_1080p_2K_6000_B},
1734  {"2048x1080p5994b", NTV2_FORMAT_1080p_2K_5994_B},
1735  {"2048x1080p50b", NTV2_FORMAT_1080p_2K_5000_B},
1736  {"2048x1080p48b", NTV2_FORMAT_1080p_2K_4800_B},
1737  {"2048x1080p4795b", NTV2_FORMAT_1080p_2K_4795_B},
1738  {"", NTV2_FORMAT_UNKNOWN} };
1739  if (true)
1740  {
1741  // Dump the gString2VideoFormatMMap map...
1742  for (String2VideoFormatMMapCI it(gString2VideoFormatMMap.begin()); it != gString2VideoFormatMMap.end(); ++it)
1743  {
1744  cout << "'" << it->first << "'\t'" << ::NTV2VideoFormatToString(it->second) << "'\t" << ::NTV2VideoFormatString(it->second) << "\t" << DEC(it->second) << endl;
1745  }
1746  }
1747  cout << endl << endl;
1748  for (unsigned ndx(0); !sVFmtDict[ndx].fName.empty(); ndx++)
1749  {
1750  const string & str (sVFmtDict[ndx].fName);
1751  const NTV2VideoFormat vFormat (sVFmtDict[ndx].fFormat);
1753  const NTV2VideoFormat vFormat2 (it != gString2VideoFormatMMap.end() ? it->second : NTV2_FORMAT_UNKNOWN);
1754  if (vFormat != vFormat2)
1755  cerr << "'" << str << "': '" << ::NTV2VideoFormatString(vFormat) << "' (" << DEC(vFormat) << ") != '" << ::NTV2VideoFormatString(vFormat2) << "' (" << DEC(vFormat2) << ")" << endl;
1756  //SHOULD_BE_EQUAL(vFormat, vFormat2);
1757  }
1758  return true;
1759 }
1760 
1761 
1763 
1764 
1765 AJALabelValuePairs CaptureConfig::Get (const bool inCompact) const
1766 {
1767  AJALabelValuePairs result;
1768  AJASystemInfo::append (result, "Capture Config");
1769  AJASystemInfo::append (result, "Device Specifier", fDeviceSpec);
1770  AJASystemInfo::append (result, "Input Channel", ::NTV2ChannelToString(fInputChannel, inCompact));
1771  AJASystemInfo::append (result, "Input Source", ::NTV2InputSourceToString(fInputSource, inCompact));
1772  AJASystemInfo::append (result, "Pixel Format", ::NTV2FrameBufferFormatToString(fPixelFormat, inCompact));
1773  AJASystemInfo::append (result, "AutoCirc Frames", fFrames.toString());
1774  AJASystemInfo::append (result, "A/B Conversion", fDoABConversion ? "Y" : "N");
1775  AJASystemInfo::append (result, "MultiFormat Mode", fDoMultiFormat ? "Y" : "N");
1776  AJASystemInfo::append (result, "Capture Anc", fWithAnc ? "Y" : "N");
1777  AJASystemInfo::append (result, "Anc Capture File", fAncDataFilePath.empty() ? "---" : fAncDataFilePath);
1778  AJASystemInfo::append (result, "Capture Audio", fWithAudio ? "Y" : "N");
1779  AJASystemInfo::append (result, "Num Audio Links", aja::to_string(fNumAudioLinks));
1780  AJASystemInfo::append (result, "TSI Routing", fDoTSIRouting ? "Y" : "N");
1781  return result;
1782 }
1783 
1784 
1785 std::ostream & operator << (std::ostream & ioStrm, const CaptureConfig & inObj)
1786 {
1787  ioStrm << AJASystemInfo::ToString(inObj.Get());
1788  return ioStrm;
1789 }
1790 
1791 
1793 
1794 
1795 AJALabelValuePairs PlayerConfig::Get (const bool inCompact) const
1796 {
1797  AJALabelValuePairs result;
1798  AJASystemInfo::append (result, "NTV2Player Config");
1799  AJASystemInfo::append (result, "Device Specifier", fDeviceSpec);
1800  AJASystemInfo::append (result, "Video Format", ::NTV2VideoFormatToString(fVideoFormat));
1801  AJASystemInfo::append (result, "Pixel Format", ::NTV2FrameBufferFormatToString(fPixelFormat, inCompact));
1802  AJASystemInfo::append (result, "AutoCirc Frames", fFrames.toString());
1803  AJASystemInfo::append (result, "MultiFormat Mode", fDoMultiFormat ? "Y" : "N");
1804  AJASystemInfo::append (result, "VANC Mode", ::NTV2VANCModeToString(fVancMode));
1805  AJASystemInfo::append (result, "Output Channel", ::NTV2ChannelToString(fOutputChannel, inCompact));
1806  AJASystemInfo::append (result, "Output Connector", ::NTV2OutputDestinationToString(fOutputDest, inCompact));
1807  AJASystemInfo::append (result, "Anc Playback File", fAncDataFilePath.empty() ? "---" : fAncDataFilePath);
1808  AJASystemInfo::append (result, "Suppress Audio", fSuppressAudio ? "Y" : "N");
1809  AJASystemInfo::append (result, "Num Audio Links", aja::to_string(fNumAudioLinks));
1810  AJASystemInfo::append (result, "Suppress Video", fSuppressVideo ? "Y" : "N");
1811  AJASystemInfo::append (result, "Embedded Timecode", fTransmitLTC ? "LTC" : "VITC");
1812  AJASystemInfo::append (result, "Level Conversion", fDoABConversion ? "Y" : "N");
1813  AJASystemInfo::append (result, "HDMI Output", fDoHDMIOutput ? "Yes" : "No");
1814  AJASystemInfo::append (result, "RGB-On-SDI", fDoRGBOnWire ? "Yes" : "No");
1815  AJASystemInfo::append (result, "TSI Routing", fDoTsiRouting ? "Yes" : "No");
1816  AJASystemInfo::append (result, "6G/12G Output", fDoLinkGrouping ? "Yes" : "No");
1817  return result;
1818 }
1819 
1820 
1821 std::ostream & operator << (std::ostream & ioStrm, const PlayerConfig & inObj)
1822 {
1823  ioStrm << AJASystemInfo::ToString(inObj.Get());
1824  return ioStrm;
1825 }
1826 
1827 
1829 
1830 
1831 AJALabelValuePairs BurnConfig::Get (const bool inCompact) const
1832 {
1833  AJALabelValuePairs result;
1834  AJASystemInfo::append(result, "NTV2Burn Config");
1835  if (fDeviceSpec2.empty())
1836  AJASystemInfo::append(result, "Device Specifier", fDeviceSpec);
1837  else
1838  {
1839  AJASystemInfo::append(result, "Input Device", fDeviceSpec);
1840  AJASystemInfo::append(result, "Output Device", fDeviceSpec2);
1841  }
1842  AJASystemInfo::append(result, "Input Channel", ::NTV2ChannelToString(fInputChannel, inCompact));
1843  AJASystemInfo::append(result, "Output Channel", ::NTV2ChannelToString(fOutputChannel, inCompact));
1844  AJASystemInfo::append(result, "Input Source", ::NTV2InputSourceToString(fInputSource, inCompact));
1845  if (WithTimecode())
1846  AJASystemInfo::append(result, "Timecode Source", ::NTV2TCIndexToString(fTimecodeSource, inCompact));
1847  AJASystemInfo::append(result, "Output Destination", ::NTV2OutputDestinationToString(fOutputDest, inCompact));
1848  AJASystemInfo::append(result, "Pixel Format", ::NTV2FrameBufferFormatToString(fPixelFormat, inCompact));
1849  AJASystemInfo::append(result, "AC Input Frames", fInputFrames.toString());
1850  AJASystemInfo::append(result, "AC Output Frames", fOutputFrames.toString());
1851  AJASystemInfo::append(result, "Include Video", WithVideo() ? "Y" : "N");
1852  AJASystemInfo::append(result, "Include Audio", WithAudio() ? "Y" : "N");
1853  AJASystemInfo::append(result, "Include Anc", WithAnc() ? "Y" : "N");
1854  AJASystemInfo::append(result, "Include HANC", WithHanc() ? "Y" : "N");
1855  AJASystemInfo::append(result, "MultiFormat Mode", fDoMultiFormat ? "Y" : "N");
1856  AJASystemInfo::append(result, "Field Mode", FieldMode() ? "Y" : "N");
1857  AJASystemInfo::append(result, "Verbose Mode", IsVerbose() ? "Y" : "N");
1858  return result;
1859 }
NTV2Channel NTV2InputSourceToChannel(const NTV2InputSource inInputSource)
Converts a given NTV2InputSource to its equivalent NTV2Channel value.
Definition: ntv2utils.cpp:5049
pair< string, string > String2TPNamePair
String2PixelFormatMap::const_iterator String2PixelFormatMapConstIter
Fractional rate of 15,000 frames per 1,001 seconds.
Definition: ntv2enums.h:431
AJALabelValuePairs Get(const bool inCompact=(0)) const
Renders a human-readable representation of me.
std::set< NTV2VideoFormat > NTV2VideoFormatSet
A set of distinct NTV2VideoFormat values.
static std::string GetTestPatternNameFromString(const std::string &inStr)
static NTV2OutputDestinations gOutputDestinations
enum _NTV2TCIndexKinds NTV2TCIndexKinds
The invalid video input.
Definition: ntv2enums.h:1279
static NTV2TCIndexSet gTCIndexesVITC1
static String2TPNamesMap gString2TPNamesMap
const FRAME_STAMP & GetFrameInfo(void) const
Returns a constant reference to my FRAME_STAMP.
static const char * GetGlobalMutexName(void)
#define NTV2_IS_ATC_VITC1_TIMECODE_INDEX(__x__)
Definition: ntv2enums.h:3991
std::set< NTV2FrameBufferFormat > NTV2FrameBufferFormatSet
A set of distinct NTV2FrameBufferFormat values.
String2VideoFormatMMap::const_iterator String2VideoFormatMMapCI
map< string, NTV2VANCMode > String2VANCModeMap
map< string, NTV2InputSource > String2InputSourceMap
NTV2AudioSystem
Used to identify an Audio System on an NTV2 device. See Audio System Operation for more information...
Definition: ntv2enums.h:3898
std::set< NTV2TCIndex > NTV2TCIndexSet
A set of distinct NTV2TCIndex values.
map< string, NTV2FrameBufferFormat > String2PixelFormatMap
NTV2OutputDestinations::const_iterator NTV2OutputDestinationsConstIter
A handy const iterator for iterating over an NTV2OutputDestinations.
Specifies SDI input/output kinds.
Definition: ntv2enums.h:1294
std::set< NTV2TCIndex > NTV2TCIndexes
virtual bool SetAudioLoopBack(const NTV2AudioLoopBack inMode, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_1)
Enables or disables NTV2AudioLoopBack mode for the given NTV2AudioSystem.
Definition: ntv2audio.cpp:301
static NTV2TCIndexSet gTCIndexesAnalog
static NTV2VideoFormatSet GetSupportedVideoFormats(const NTV2VideoFormatKinds inKinds=VIDEO_FORMATS_SDHD)
This identifies the invalid (unspecified, uninitialized) VANC mode.
Definition: ntv2enums.h:3805
static NTV2AudioSystem GetAudioSystemFromString(const std::string &inStr)
Returns the NTV2AudioSystem that matches the given string.
AJA_PixelFormat
Definition: videotypes.h:121
bool WithCustomAnc(void) const
bool CanDoPixelFormat(const NTV2PixelFormat inPF)
Same as DeviceCapabilities::CanDoFrameBufferFormat.
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
#define NTV2_IS_ATC_LTC_TIMECODE_INDEX(__x__)
Definition: ntv2enums.h:3996
10-Bit 4:2:2 2-Plane YCbCr
Definition: ntv2enums.h:254
NTV2OutputDestination
Identifies a specific video output destination.
Definition: ntv2enums.h:1326
#define NTV2_IS_QUAD_QUAD_HFR_VIDEO_FORMAT(__f__)
Definition: ntv2enums.h:828
See 10-Bit YCbCr Format.
Definition: ntv2enums.h:224
ULWord GetCapturedAudioByteCount(void) const
std::set< NTV2InputSource > NTV2InputSourceSet
A set of distinct NTV2InputSource values.
Apple ProRes DVC Pro.
Definition: ntv2enums.h:243
std::string NTV2OutputDestinationToString(const NTV2OutputDestination inValue, const bool inForRetailDisplay=false)
Definition: ntv2utils.cpp:7402
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.
Identifies the 1st HDMI video input.
Definition: ntv2enums.h:1267
Fractional rate of 120,000 frames per 1,001 seconds.
Definition: ntv2enums.h:429
NTV2StringList::const_iterator NTV2StringListConstIter
#define NTV2_IS_FBF_PLANAR(__s__)
Definition: ntv2enums.h:269
ULWord GetIndexForNTV2Channel(const NTV2Channel inChannel)
Definition: ntv2utils.cpp:4704
Declares the NTV2TestPatternGen class.
static bool GetInputRouting8K(NTV2XptConnections &outConnections, const CaptureConfig &inConfig, const NTV2VideoFormat inVidFormat, const NTV2DeviceID inDevID=DEVICE_ID_INVALID, const bool isInputRGB=(0))
Answers with the crosspoint connections needed to implement the given 8K/UHD2 capture configuration...
static NTV2ChannelList GetTSIMuxesForFrameStore(CNTV2Card &inDevice, const NTV2Channel in1stFrameStore, const UWord inCount)
See 10-Bit Raw YCbCr (CION).
Definition: ntv2enums.h:250
static NTV2VideoFormat GetVideoFormatFromString(const std::string &inStr, const NTV2VideoFormatKinds inKinds=VIDEO_FORMATS_SDHD, const std::string &inDevSpec=std::string())
Returns the NTV2VideoFormat that matches the given string.
NTV2EmbeddedAudioInput NTV2InputSourceToEmbeddedAudioInput(const NTV2InputSource inInputSource)
Converts a given NTV2InputSource to its equivalent NTV2EmbeddedAudioInput value.
Definition: ntv2utils.cpp:4879
NTV2InputSource NTV2ChannelToInputSource(const NTV2Channel inChannel, const NTV2IOKinds inKinds=NTV2_IOKINDS_SDI)
Definition: ntv2utils.cpp:5134
multimap< string, NTV2VideoFormat > String2VideoFormatMMap
static std::string GetInputSourceStrings(const NTV2IOKinds inKinds=NTV2_IOKINDS_ALL, const std::string inDevSpec=std::string())
static void WaitForEnterKeyPress(void)
Prompts the user (via stdout) to press the Return or Enter key, then waits for it to happen...
See Alternate 8-Bit YCbCr (&#39;YUY2&#39;).
Definition: ntv2enums.h:229
See 10-Bit YCbCr - DPX Format.
Definition: ntv2enums.h:233
std::vector< AJALabelValuePair > AJALabelValuePairs
An ordered sequence of label/value pairs.
Definition: info.h:71
bool WithAudio(void) const
#define NTV2_IS_4K_VIDEO_FORMAT(__f__)
Definition: ntv2enums.h:785
See 3-Plane 10-Bit YCbCr 4:2:2 (&#39;I422_10LE&#39; a.k.a. &#39;YUV-P-L10&#39;).
Definition: ntv2enums.h:252
Specifies HDMI input/output kinds.
Definition: ntv2enums.h:1295
LWord64 acFrameTime
(input/ingest/capture only) The absolute timestamp at the VBI when the frame started recording into d...
virtual bool Open(const UWord inDeviceIndex)
Opens a local/physical AJA device so it can be monitored/controlled.
NTV2OutputXptID GetTSIMuxOutputXptFromChannel(const NTV2Channel inTSIMuxer, const bool inLinkB=false, const bool inIsRGB=false)
static std::string GetPixelFormatStrings(const NTV2PixelFormatKinds inKinds=PIXEL_FORMATS_ALL, const std::string inDevSpec=std::string())
Obtain audio samples from the audio that&#39;s embedded in the video HANC.
Definition: ntv2enums.h:2010
NTV2InputXptID GetDLInInputXptFromChannel(const NTV2Channel inChannel, const bool inLinkB=false)
String2VANCModeMap::const_iterator String2VANCModeMapConstIter
Specifies any/all input/output kinds.
Definition: ntv2enums.h:1297
The "default" timecode (mostly used by the AJA "Retail" service and Control Panel) ...
Definition: ntv2enums.h:3956
static NTV2OutputDestinations gOutputDestsHDMI
See 3-Plane 8-Bit YCbCr 4:2:0 (&#39;I420&#39; a.k.a. &#39;YUV-P420&#39;).
Definition: ntv2enums.h:235
static NTV2VideoFormatSet gSDHDFormats
Definition: json.hpp:5362
virtual bool SetAudioRate(const NTV2AudioRate inRate, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_1)
Sets the NTV2AudioRate for the given Audio System.
Definition: ntv2audio.cpp:206
Fractional rate of 60,000 frames per 1,001 seconds.
Definition: ntv2enums.h:419
static std::string GetTestPatternStrings(void)
std::set< NTV2OutputDestination > NTV2OutputDestinations
A set of distinct NTV2OutputDestination values.
std::pair< NTV2InputXptID, NTV2OutputXptID > NTV2Connection
This links an NTV2InputXptID and an NTV2OutputXptID.
See 8-Bit DVCPro.
Definition: ntv2enums.h:234
uint32_t ULWord
Definition: ajatypes.h:236
static String2InputSourceMap gString2InputSourceMap
NTV2Channel
These enum values are mostly used to identify a specific widget_framestore. They&#39;re also commonly use...
Definition: ntv2enums.h:1359
short HANDLE
Definition: ajatypes.h:298
map< string, NTV2TCIndex > String2TCIndexMap
virtual class DeviceCapabilities & features(void)
Definition: ntv2card.h:148
bool CanDoInputSource(const NTV2InputSource inSrc)
AJALabelValuePairs Get(const bool inCompact=(0)) const
Renders a human-readable representation of me.
#define NTV2_OUTPUT_DEST_IS_HDMI(_dest_)
Definition: ntv2enums.h:1346
static String2TCIndexMap gString2TCIndexMap
static NTV2VideoFormatSet gAllFormats
#define NTV2_ASSERT(_expr_)
Definition: ajatypes.h:489
String2InputSourceMap::const_iterator String2InputSourceMapConstIter
See 3-Plane 8-Bit YCbCr 4:2:2 (Weitek &#39;Y42B&#39; a.k.a. &#39;YUV-P8&#39;).
Definition: ntv2enums.h:248
Represents an unknown or invalid frame rate.
Definition: ntv2enums.h:416
This struct replaces the old RP188_STRUCT.
poptContext poptGetContext(const char *name, int argc, const char **argv, const struct poptOption *options, unsigned int flags)
50 frames per second
Definition: ntv2enums.h:425
#define NTV2_IS_ANALOG_TIMECODE_INDEX(__x__)
Definition: ntv2enums.h:3989
NTV2Channel fInputChannel
The device channel to use.
unsigned long stoul(const std::string &str, std::size_t *idx, int base)
Definition: common.cpp:143
NTV2TCIndex
These enum values are indexes into the capture/playout AutoCirculate timecode arrays.
Definition: ntv2enums.h:3954
bool Fill(const T &inValue)
Fills me with the given scalar value.
static NTV2StringList gTestPatternNames
Fractional rate of 48,000 frames per 1,001 seconds.
Definition: ntv2enums.h:427
virtual bool SetAudioSystemInputSource(const NTV2AudioSystem inAudioSystem, const NTV2AudioSource inAudioSource, const NTV2EmbeddedAudioInput inEmbeddedInput)
Sets the audio source for the given NTV2AudioSystem on the device.
Definition: ntv2audio.cpp:486
std::string NTV2InputSourceToString(const NTV2InputSource inValue, const bool inForRetailDisplay=false)
Definition: ntv2utils.cpp:7379
30 frames per second
Definition: ntv2enums.h:420
NTV2OutputXptID GetInputSourceOutputXpt(const NTV2InputSource inInputSource, const bool inIsSDI_DS2=false, const bool inIsHDMI_RGB=false, const UWord inHDMI_Quadrant=0)
static AJA_PixelFormat GetAJAPixelFormat(const NTV2PixelFormat inFormat)
NTV2Channel NTV2OutputDestinationToChannel(const NTV2OutputDestination inOutputDest)
Converts a given NTV2OutputDestination to its equivalent NTV2Channel value.
Definition: ntv2utils.cpp:5157
NTV2FrameRate
Identifies a particular video frame rate.
Definition: ntv2enums.h:414
8-Bit 4:2:2 2-Plane YCbCr
Definition: ntv2enums.h:256
NTV2DeviceID
Identifies a specific AJA NTV2 device model number. The NTV2DeviceID is actually the PROM part number...
Definition: ntv2enums.h:20
bool CanDoOutputDestination(const NTV2OutputDestination inDest)
This class is used to configure an NTV2Capture instance.
static TimecodeFormat NTV2FrameRate2TimecodeFormat(const NTV2FrameRate inFrameRate)
static NTV2TCIndexSet gTCIndexesVITC2
virtual bool DMABufferUnlock(const NTV2Buffer &inBuffer)
Unlocks the given host buffer that was previously locked using CNTV2Card::DMABufferLock.
Definition: ntv2dma.cpp:444
virtual bool IsOpen(void) const
16-Bit ARGB
Definition: ntv2enums.h:247
static NTV2PixelFormats GetSupportedPixelFormats(const NTV2PixelFormatKinds inKinds=PIXEL_FORMATS_ALL)
std::string to_string(bool val)
Definition: common.cpp:180
#define NTV2_IS_ATC_VITC2_TIMECODE_INDEX(__x__)
Definition: ntv2enums.h:3994
static bool GetFirstDeviceFromArgument(const std::string &inArgument, CNTV2Card &outDevice)
Rescans the host, and returns an open CNTV2Card instance for the AJA device that matches a command li...
std::set< std::string > NTV2StringSet
String2AudioSystemMap::const_iterator String2AudioSystemMapConstIter
#define NTV2_INPUT_SOURCE_IS_HDMI(_inpSrc_)
Definition: ntv2enums.h:1283
static std::string GetVideoFormatStrings(const NTV2VideoFormatKinds inKinds=VIDEO_FORMATS_SDHD, const std::string inDevSpec=std::string())
NTV2VideoFormatSet::const_iterator NTV2VideoFormatSetConstIter
A handy const iterator for iterating over an NTV2VideoFormatSet.
static NTV2FrameBufferFormatSet gFBFsAlpha
Specifies analog input/output kinds.
Definition: ntv2enums.h:1296
virtual bool DMABufferLock(const NTV2Buffer &inBuffer, bool inMap=(0), bool inRDMA=(0))
Page-locks the given host buffer to reduce transfer time and CPU usage of DMA transfers.
Definition: ntv2dma.cpp:429
static NTV2StringList getColorNames(void)
const char * poptBadOption(poptContext con, unsigned int flags)
#define AJA_NULL
Definition: ajatypes.h:180
See 10-Bit RGB Format.
Definition: ntv2enums.h:228
map< string, string > String2TPNamesMap
virtual std::string GetDisplayName(void)
Answers with this device&#39;s display name.
Definition: ntv2card.cpp:88
#define NTV2_IS_FBF_RGB(__fbf__)
Definition: ntv2enums.h:285
NTV2TimeCodes::const_iterator NTV2TimeCodesConstIter
A handy const interator for iterating over NTV2TCIndex/NTV2TimeCodeList pairs.
static String2VANCModeMap gString2VANCModeMap
static NTV2VideoFormatSet g8KFormats
NTV2InputXptID GetCSCInputXptFromChannel(const NTV2Channel inCSC, const bool inIsKeyInput=false)
String2TPNamesMap::const_iterator String2TPNamesMapConstIter
bool SetCapturedFrameInfo(const AUTOCIRCULATE_TRANSFER &inXferInfo, const AUTOCIRCULATE_STATUS &acStatus)
bool LockAll(CNTV2Card &inDevice)
static NTV2TCIndex GetTCIndexFromString(const std::string &inStr, const NTV2TCIndexKinds inKinds=TC_INDEXES_ALL, const std::string inDevSpec=std::string())
Returns the NTV2TCIndex that matches the given string.
static String2OutputDestMap gString2OutputDestMap
NTV2InputXptID GetFrameStoreInputXptFromChannel(const NTV2Channel inFrameStore, const bool inIsBInput=false)
static NTV2OutputDestination GetOutputDestinationFromString(const std::string &inStr, const NTV2IOKinds inKinds=NTV2_IOKINDS_ALL, const std::string inDevSpec=std::string())
Returns the NTV2OutputDestination that matches the given string.
std::string NTV2VANCModeToString(const NTV2VANCMode inValue, const bool inCompactDisplay=false)
Definition: ntv2utils.cpp:6507
static std::string ToLower(const std::string &inStr)
Returns the given string after converting it to lower case.
static size_t DefaultPageSize(void)
bool CanDoOutputTCIndex(const NTV2TCIndex inTCNdx)
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:6748
See 8-Bit ARGB, RGBA, ABGR Formats.
Definition: ntv2enums.h:230
See 8-Bit ARGB, RGBA, ABGR Formats.
Definition: ntv2enums.h:226
static NTV2VANCMode GetVANCModeFromString(const std::string &inStr)
Embeds silence (zeroes) into the data stream.
Definition: ntv2enums.h:2033
static bool Get8KInputFormat(NTV2VideoFormat &inOutVideoFormat)
Given a video format, if all 4 inputs are the same and promotable to 8K, this function does the promo...
static NTV2VideoFormatSet g4KFormats
static String2VideoFormatMMap gString2VideoFormatMMap
pair< string, NTV2TCIndex > String2TCIndexPair
bool WithRP188(void) const
static bool BFT(void)
static String2PixelFormatMap gString2PixelFormatMap
std::string NTV2TCIndexToString(const NTV2TCIndex inValue, const bool inCompactDisplay=false)
Definition: ntv2utils.cpp:6396
static NTV2TCIndexSet gTCIndexesSDI
See 12-Bit Packed RGB.
Definition: ntv2enums.h:242
#define NTV2_OUTPUT_DEST_IS_ANALOG(_dest_)
Definition: ntv2enums.h:1347
See 3-Plane 10-Bit YCbCr 4:2:0 (&#39;I420_10LE&#39; a.k.a. &#39;YUV-P420-L10&#39;).
Definition: ntv2enums.h:251
NTV2OutputXptID GetDLInOutputXptFromChannel(const NTV2Channel inDLInput)
Declares the CNTV2DeviceScanner class.
static NTV2FrameBufferFormatSet gFBFsPacked
ULWord NTV2PixelFormatKinds
static NTV2OutputDestinations gOutputDestsAnalog
#define NTV2_OUTPUT_DEST_IS_SDI(_dest_)
Definition: ntv2enums.h:1348
10-Bit DPX Little-Endian
Definition: ntv2enums.h:240
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.).
static NTV2TestPatternNames getTestPatternNames(void)
bool NTV2DeviceGetSupportedOutputDests(const NTV2DeviceID inDeviceID, NTV2OutputDestinations &outOutputDests, const NTV2IOKinds inKinds=NTV2_IOKINDS_ALL)
Returns a set of distinct NTV2OutputDest values supported on the given device.
Fractional rate of 30,000 frames per 1,001 seconds.
Definition: ntv2enums.h:421
10-Bit 4:2:0 2-Plane YCbCr
Definition: ntv2enums.h:253
NTV2InputSource
Identifies a specific video input source.
Definition: ntv2enums.h:1264
NTV2InputSourceSet::const_iterator NTV2InputSourceSetConstIter
A handy const iterator for iterating over an NTV2InputSourceSet.
bool IsRGBFormat(const NTV2FrameBufferFormat format)
Definition: ntv2utils.cpp:5412
static NTV2InputSourceSet gInputSourcesSDI
static char ReadCharacterPress(void)
Returns the character that represents the last key that was pressed on the keyboard without waiting f...
This object specifies the information that will be transferred to or from the AJA device in the CNTV2...
bool NTV2DeviceCanDo12gRouting(const NTV2DeviceID inDeviceID)
std::string & strip(std::string &str, const std::string &ws)
Definition: common.cpp:461
virtual bool SetAudioBufferSize(const NTV2AudioBufferSize inValue, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_1)
Changes the size of the audio buffer that is used for a given Audio System in the AJA device...
Definition: ntv2audio.cpp:250
NTV2InputSource fInputSource
The device input connector to use.
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
static size_t HostPageSize(void)
#define DEC(__x__)
static NTV2OutputDestinations gOutputDestsSDI
NTV2InputXptID GetTSIMuxInputXptFromChannel(const NTV2Channel inTSIMuxer, const bool inLinkB=false)
map< string, NTV2OutputDestination > String2OutputDestMap
See 8-Bit HDV.
Definition: ntv2enums.h:236
static std::string GetAudioSystemStrings(const std::string inDeviceSpecifier=std::string())
Apple ProRes HDV.
Definition: ntv2enums.h:244
60 frames per second
Definition: ntv2enums.h:417
15 frames per second
Definition: ntv2enums.h:430
10-Bit ARGB
Definition: ntv2enums.h:246
Declares numerous NTV2 utility functions.
static NTV2TCIndexSet gTCIndexesHDMI
static NTV2FrameBufferFormatSet gFBFsRGB
bool CanDoInputTCIndex(const NTV2TCIndex inTCNdx)
static NTV2TCIndexSet gTCIndexesATCLTC
static NTV2FrameBufferFormatSet gPixelFormats
bool GetInputTimeCodes(NTV2TimeCodeList &outValues) const
Intended for capture, answers with the timecodes captured in my acTransferStatus member&#39;s acFrameStam...
static bool Get4KInputFormat(NTV2VideoFormat &inOutVideoFormat)
Given a video format, if all 4 inputs are the same and promotable to 4K, this function does the promo...
See 8-Bit ARGB, RGBA, ABGR Formats.
Definition: ntv2enums.h:227
#define NTV2_IS_QUAD_QUAD_FORMAT(__f__)
Definition: ntv2enums.h:821
This is returned from the CNTV2Card::AutoCirculateGetStatus function.
static const NTV2InputSourceSet GetSupportedInputSources(const NTV2IOKinds inKinds=NTV2_IOKINDS_ALL)
bool UnlockAll(CNTV2Card &inDevice)
uint16_t UWord
Definition: ajatypes.h:234
static NTV2InputSourceSet gInputSources
Specifies channel or FrameStore 1 (or the first item).
Definition: ntv2enums.h:1361
120 frames per second
Definition: ntv2enums.h:428
See 48-Bit RGB.
Definition: ntv2enums.h:241
static bool GetInputRouting4K(NTV2XptConnections &outConnections, const CaptureConfig &inConfig, const NTV2DeviceID inDevID=DEVICE_ID_INVALID, const bool isInputRGB=(0))
Answers with the crosspoint connections needed to implement the given 4K/UHD capture configuration...
bool CanDoFrameBufferFormat(const NTV2PixelFormat inPF)
static NTV2InputSource GetInputSourceFromString(const std::string &inStr, const NTV2IOKinds inKinds=NTV2_IOKINDS_ALL, const std::string inDevSpec=std::string())
Returns the NTV2InputSource that matches the given string.
bool NTV2DeviceGetSupportedInputSources(const NTV2DeviceID inDeviceID, NTV2InputSourceSet &outInputSources, const NTV2IOKinds inKinds=NTV2_IOKINDS_ALL)
Returns a set of distinct NTV2InputSource values supported on the given device.
NTV2Channel GetChannel(void) const
NTV2VANCMode
These enum values identify the available VANC modes.
Definition: ntv2enums.h:3800
25 frames per second
Definition: ntv2enums.h:422
TimecodeFormat
Definition: ntv2rp188.h:22
NTV2PixelFormat fPixelFormat
Pixel format to use.
static bool GetInputRouting(NTV2XptConnections &outConnections, const CaptureConfig &inConfig, const bool isInputRGB=(0))
Answers with the crosspoint connections needed to implement the given capture configuration.
static String2AudioSystemMap gString2AudioSystemMap
std::string NTV2FrameBufferFormatToString(const NTV2FrameBufferFormat inValue, const bool inForRetailDisplay=false)
Definition: ntv2utils.cpp:6938
static AJA_FrameRate GetAJAFrameRate(const NTV2FrameRate inFrameRate)
static bool IsValidDevice(const std::string &inDeviceSpec)
10-Bit YCbCrA
Definition: ntv2enums.h:239
#define NTV2_INPUT_SOURCE_IS_ANALOG(_inpSrc_)
Definition: ntv2enums.h:1284
ULWord NTV2VideoFormatKinds
NTV2AudioSystemSet::const_iterator NTV2AudioSystemSetConstIter
A handy const iterator into an NTV2AudioSystemSet. New in SDK 16.2.
String2TCIndexMap::const_iterator String2TCIndexMapConstIter
String2OutputDestMap::const_iterator String2OutputDestMapConstIter
NTV2InputSource NTV2TimecodeIndexToInputSource(const NTV2TCIndex inTCIndex)
Converts the given NTV2TCIndex value into the appropriate NTV2InputSource value.
Definition: ntv2utils.cpp:4990
enum NTV2OutputDestination NTV2OutputDest
static NTV2TCIndexSet gTCIndexes
enum NTV2InputCrosspointID NTV2InputXptID
This file contains some structures, constants, classes and functions that are used in some of the dem...
const char * poptGetArg(poptContext con)
std::ostream & operator<<(std::ostream &ioStrm, const CaptureConfig &inObj)
Private include file for all ajabase sources.
poptContext poptFreeContext(poptContext con)
Configures an NTV2Player instance.
See 10-Bit RGB - DPX Format.
Definition: ntv2enums.h:232
static bool ConfigureAudioSystems(CNTV2Card &inDevice, const CaptureConfig &inConfig, const NTV2AudioSystemSet inAudioSystems)
Configures capture audio systems.
static std::string GetVANCModeStrings(void)
static const NTV2TCIndexes GetSupportedTCIndexes(const NTV2TCIndexKinds inKinds)
#define NTV2_IS_VALID_VIDEO_FORMAT(__f__)
Definition: ntv2enums.h:727
std::vector< NTV2Channel > NTV2ChannelList
An ordered sequence of NTV2Channel values.
AJALabelValuePairs Get(const bool inCompact=(0)) const
std::string join(const std::vector< std::string > &parts, const std::string &delim)
Definition: common.cpp:468
See 24-Bit RGB.
Definition: ntv2enums.h:237
10-Bit Raw RGB
Definition: ntv2enums.h:249
#define NTV2_FBF_HAS_ALPHA(__fbf__)
Definition: ntv2enums.h:325
int poptGetNextOpt(poptContext con)
NTV2_RP188 Timecode(const NTV2TCIndex inTCNdx) const
static std::string StripFormatString(const std::string &inStr)
static size_t SetDefaultPageSize(void)
#define NTV2_IS_VALID_FRAME_BUFFER_FORMAT(__s__)
Definition: ntv2enums.h:265
ULWord64 acAudioClockTimeStamp
(input/ingest/capture only) The absolute timestamp at the VBI when the frame started recording into d...
std::map< NTV2InputXptID, NTV2OutputXptID > NTV2XptConnections
NTV2OutputXptID GetSDIInputOutputXptFromChannel(const NTV2Channel inSDIInput, const bool inIsDS2=false)
Popt(const int inArgc, const char **pArgs, const PoptOpts *pInOptionsTable)
NTV2TCIndexes::const_iterator NTV2TCIndexesConstIter
ULWord GetCapturedAncByteCount(const bool inField2=false) const
std::vector< std::string > NTV2StringList
static const string gGlobalMutexName("com.aja.ntv2.mutex.demo")
bool CanDoVideoFormat(const NTV2VideoFormat inVF)
48 frames per second
Definition: ntv2enums.h:426
std::string NTV2ChannelToString(const NTV2Channel inValue, const bool inForRetailDisplay=false)
Definition: ntv2utils.cpp:5729
map< string, NTV2AudioSystem > String2AudioSystemMap
#define NTV2_INPUT_SOURCE_IS_SDI(_inpSrc_)
Definition: ntv2enums.h:1285
std::string & lower(std::string &str)
Definition: common.cpp:436
static NTV2InputSourceSet gInputSourcesHDMI
24 frames per second
Definition: ntv2enums.h:423
10-Bit Packed RGB
Definition: ntv2enums.h:245
8-Bit 4:2:0 2-Plane YCbCr
Definition: ntv2enums.h:255
Identifies the 1st SDI video input.
Definition: ntv2enums.h:1271
std::string & replace(std::string &str, const std::string &from, const std::string &to)
Definition: common.cpp:110
static std::string GetOutputDestinationStrings(const NTV2IOKinds inKinds, const std::string inDevSpec=std::string())
static NTV2FrameBufferFormatSet gFBFsPlanar
const char * poptStrerror(const int error)
static NTV2FrameBufferFormatSet gFBFsProRes
AJA_FrameRate
Definition: videotypes.h:210
virtual bool SetNumberAudioChannels(const ULWord inNumChannels, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_1)
Sets the number of audio channels to be concurrently captured or played for a given Audio System on t...
Definition: ntv2audio.cpp:147
const char * NTV2VideoFormatString(NTV2VideoFormat fmt)
Definition: ntv2debug.cpp:331
virtual void ToString(std::string &outAllLabelsAndValues) const
Answers with a multi-line string that contains the complete host system info table.
static const DemoCommonInitializer gInitializer
enum NTV2OutputCrosspointID NTV2OutputXptID
static NTV2InputSourceSet gInputSourcesAnalog
Declares device capability functions.
See 24-Bit BGR.
Definition: ntv2enums.h:238
static NTV2PixelFormat GetPixelFormatFromString(const std::string &inStr, const NTV2PixelFormatKinds inKinds=PIXEL_FORMATS_ALL, const std::string inDevSpec=std::string())
Returns the NTV2PixelFormat that matches the given string.
static NTV2FrameBufferFormatSet gFBFsRaw
NTV2OutputXptID GetCSCOutputXptFromChannel(const NTV2Channel inCSC, const bool inIsKey=false, const bool inIsRGB=false)
This identifies the mode in which there are no VANC lines in the frame buffer.
Definition: ntv2enums.h:3802
static std::string GetTCIndexStrings(const NTV2TCIndexKinds inKinds=TC_INDEXES_ALL, const std::string inDeviceSpecifier=std::string(), const bool inIsInputOnly=(!(0)))
Fractional rate of 24,000 frames per 1,001 seconds.
Definition: ntv2enums.h:424
ULWord NTV2IOKinds
Definition: ntv2enums.h:1312
#define NTV2_FBF_IS_RAW(__fbf__)
Definition: ntv2enums.h:333
See 8-Bit YCbCr Format.
Definition: ntv2enums.h:225
#define NTV2_IS_FBF_PRORES(__fbf__)
Definition: ntv2enums.h:281
bool fDoTSIRouting
If true, do TSI routing; otherwise squares.
static const NTV2OutputDestinations GetSupportedOutputDestinations(const NTV2IOKinds inKinds)
NTV2FrameBufferFormatSet::const_iterator NTV2FrameBufferFormatSetConstIter
A handy const iterator for iterating over an NTV2FrameBufferFormatSet.
NTV2TestPatternSelect
Identifies a predefined NTV2 test pattern.