AJA NTV2 SDK  17.0.1.1246
NTV2 SDK 17.0.1.1246
main.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MIT */
10 // Includes
11 #include "ntv2democommon.h"
12 #include "ntv2devicescanner.h"
13 
14 using namespace std;
15 
16 
21 static int ShowDeviceInfo (CNTV2Card & inCard)
22 {
23  // Get detailed device information...
24  const NTV2DeviceID deviceID (inCard.GetDeviceID());
25  NTV2VideoFormatSet videoFormats;
26  NTV2PixelFormats pixelFormats;
27  string serial;
28 
29  // Print the display name...
30  cout << "Device '" << inCard.GetDisplayName() << "'" << endl
31 
32  // Print device ID and serial number...
33  << "\t" << "Device ID: " << xHEX0N(deviceID,8) << endl
34  << "\t" << "Serial Number: '" << (inCard.GetSerialNumberString(serial) ? serial : serial) << "'" << endl
35 
36  // Print additional info gleaned from the device features API...
37  << "\t" << ::NTV2DeviceGetNumVideoInputs(deviceID) << " SDI Input(s)" << endl
38  << "\t" << ::NTV2DeviceGetNumVideoOutputs(deviceID) << " SDI Output(s)" << endl
39  << "\t" << ::NTV2DeviceGetNumHDMIVideoInputs(deviceID) << " HDMI Input(s)" << endl
40  << "\t" << ::NTV2DeviceGetNumHDMIVideoOutputs(deviceID) << " HDMI Output(s)" << endl
41  << "\t" << ::NTV2DeviceGetNumAnalogVideoInputs(deviceID) << " Analog Input(s)" << endl
42  << "\t" << ::NTV2DeviceGetNumAnalogVideoOutputs(deviceID) << " Analog Output(s)" << endl
43  << "\t" << ::NTV2DeviceGetNumEmbeddedAudioInputChannels(deviceID) << " channel(s) of Embedded Audio Input" << endl
44  << "\t" << ::NTV2DeviceGetNumEmbeddedAudioOutputChannels(deviceID) << " channel(s) of Embedded Audio Output" << endl;
45 
46  // Show its video and pixel format capabilities:
47  inCard.GetSupportedVideoFormats(videoFormats);
48  NTV2DeviceGetSupportedPixelFormats (deviceID, pixelFormats);
49  cout << "\t" << videoFormats << endl
50  << "\t" << pixelFormats << endl;
51  return 0;
52 }
53 
54 
55 // Main Program
56 
57 int main (int argc, const char ** argv)
58 { (void)argc; (void)argv;
59  int showVersion (0);
60  char * pDeviceSpec (AJA_NULL);
62 
63  // Command line option descriptions:
64  const struct poptOption optionsTable [] =
65  {
66  {"version", 0, POPT_ARG_NONE, &showVersion, 0, "show version & exit", AJA_NULL },
67  {"device", 'd', POPT_ARG_STRING, &pDeviceSpec, 0, "device to use", "index#, serial#, or model" },
70  };
71  CNTV2DemoCommon::Popt popt(argc, argv, optionsTable);
72  if (!popt)
73  {cerr << "## ERROR: " << popt.errorStr() << endl; return 2;}
74  if (!popt.otherArgs().empty())
75  {cerr << "## ERROR: Unexpected argument(s): " << popt.otherArgs() << endl; return 2;}
76  if (showVersion)
77  {cout << argv[0] << ", NTV2 SDK " << ::NTV2Version() << endl; return 0;}
78 
79  // Device
80  CNTV2Card device;
81  const string deviceSpec (pDeviceSpec ? pDeviceSpec : "");
82  if (!deviceSpec.empty())
83  {
84  if (!CNTV2DemoCommon::IsValidDevice(deviceSpec))
85  return 2;
86  else if (CNTV2DeviceScanner::GetFirstDeviceFromArgument(deviceSpec, device))
87  return ShowDeviceInfo(device); // Show info for a single device
88  else
89  {cerr << "## ERROR: Failed to open '" << deviceSpec << "'"; return 2;}
90  } // if -d option used
91 
92  // Discover the AJA device(s) on the local host...
93  CNTV2DeviceScanner scanner;
94  const size_t deviceCount (scanner.GetNumDevices());
95 
96  cout << "AJA NTV2 SDK " << ::NTV2Version() << " supports devices: " << ::NTV2GetSupportedDevices() << endl;
97 
98  // Print the results of the scan...
99  if (deviceCount)
100  {
101  cout << deviceCount << " AJA device(s) found" << endl;
102  uint32_t deviceIndex(0);
103  while (CNTV2DeviceScanner::GetDeviceAtIndex(deviceIndex, device))
104  {
105  if (deviceIndex)
106  cout << endl << endl << endl;
107  ShowDeviceInfo(device);
108  deviceIndex++;
109  } // for each device
110  } // if deviceCount > 0
111  else
112  cout << "No AJA devices found" << endl;
113 
114  return deviceCount ? 0 : 1;
115 
116 } // main
NTV2DeviceGetNumEmbeddedAudioOutputChannels
UWord NTV2DeviceGetNumEmbeddedAudioOutputChannels(const NTV2DeviceID inDeviceID)
Definition: ntv2devicefeatures.hpp:10398
CNTV2DemoCommon::Popt::otherArgs
virtual const NTV2StringList & otherArgs(void) const
Definition: ntv2democommon.h:810
NTV2DeviceGetNumHDMIVideoInputs
UWord NTV2DeviceGetNumHDMIVideoInputs(const NTV2DeviceID inDeviceID)
Definition: ntv2devicefeatures.hpp:10766
poptOption
Definition: options_popt.h:148
NTV2PixelFormats
NTV2FrameBufferFormatSet NTV2PixelFormats
Definition: ntv2publicinterface.h:8782
CNTV2DeviceScanner
This class is used to enumerate AJA devices that are attached and known to the local host computer.
Definition: ntv2devicescanner.h:208
NTV2GetSupportedDevices
NTV2DeviceIDSet NTV2GetSupportedDevices(const NTV2DeviceKinds inKinds=NTV2_DEVICEKIND_ALL)
Returns an NTV2DeviceIDSet of devices supported by the SDK.
Definition: ntv2utils.cpp:7552
NTV2VideoFormatSet
std::set< NTV2VideoFormat > NTV2VideoFormatSet
A set of distinct NTV2VideoFormat values.
Definition: ntv2publicinterface.h:8777
CNTV2DeviceScanner::GetFirstDeviceFromArgument
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...
Definition: ntv2devicescanner.cpp:327
NTV2DeviceGetNumAnalogVideoInputs
UWord NTV2DeviceGetNumAnalogVideoInputs(const NTV2DeviceID inDeviceID)
Definition: ntv2devicefeatures.hpp:9686
NTV2DeviceID
NTV2DeviceID
Identifies a specific AJA NTV2 device model number. The NTV2DeviceID is actually the PROM part number...
Definition: ntv2enums.h:20
ShowDeviceInfo
static int ShowDeviceInfo(CNTV2Card &inCard)
Prints a variety of information about the given device.
Definition: main.cpp:21
main
int main(int argc, const char **argv)
Definition: main.cpp:30
POPT_AUTOHELP
#define POPT_AUTOHELP
Definition: options_popt.h:220
CNTV2Card::GetDisplayName
virtual std::string GetDisplayName(void)
Answers with this device's display name.
Definition: ntv2card.cpp:84
CNTV2DemoCommon::IsValidDevice
static bool IsValidDevice(const std::string &inDeviceSpec)
Definition: ntv2democommon.cpp:433
ntv2devicescanner.h
Declares the CNTV2DeviceScanner class.
CNTV2Card::GetSerialNumberString
virtual bool GetSerialNumberString(std::string &outSerialNumberString)
Answers with a string that contains my human-readable serial number.
Definition: ntv2card.cpp:219
NTV2DeviceGetNumVideoInputs
UWord NTV2DeviceGetNumVideoInputs(const NTV2DeviceID inDeviceID)
Definition: ntv2devicefeatures.hpp:11923
NTV2DeviceGetNumHDMIVideoOutputs
UWord NTV2DeviceGetNumHDMIVideoOutputs(const NTV2DeviceID inDeviceID)
Definition: ntv2devicefeatures.hpp:10855
CNTV2DemoCommon::Popt
Definition: ntv2democommon.h:801
CNTV2DemoCommon::Popt::errorStr
virtual const std::string & errorStr(void) const
Definition: ntv2democommon.h:809
NTV2Version
std::string NTV2Version(const bool inDetailed=false)
Definition: ntv2version.cpp:41
CNTV2Card
I interrogate and control an AJA video/audio capture/playout device.
Definition: ntv2card.h:262
NTV2DeviceGetNumAnalogVideoOutputs
UWord NTV2DeviceGetNumAnalogVideoOutputs(const NTV2DeviceID inDeviceID)
Definition: ntv2devicefeatures.hpp:9775
NTV2DeviceGetNumEmbeddedAudioInputChannels
UWord NTV2DeviceGetNumEmbeddedAudioInputChannels(const NTV2DeviceID inDeviceID)
Definition: ntv2devicefeatures.hpp:10309
AJADebug::Open
static AJAStatus Open(bool incrementRefCount=false)
Definition: debug.cpp:44
AJA_NULL
#define AJA_NULL
Definition: ajatypes.h:190
ntv2democommon.h
This file contains some structures, constants, classes and functions that are used in some of the dem...
CNTV2DeviceScanner::GetDeviceAtIndex
static bool GetDeviceAtIndex(const ULWord inDeviceIndexNumber, CNTV2Card &outDevice)
Rescans the host, and returns an open CNTV2Card instance for the AJA device having the given zero-bas...
Definition: ntv2devicescanner.cpp:237
NTV2DeviceGetSupportedPixelFormats
bool NTV2DeviceGetSupportedPixelFormats(const NTV2DeviceID inDeviceID, NTV2PixelFormats &outFormats)
Returns a set of distinct NTV2FrameBufferFormat values supported on the given device.
Definition: ntv2publicinterface.cpp:1157
CNTV2DeviceScanner::GetNumDevices
virtual size_t GetNumDevices(void) const
Returns the number of AJA devices found on the local host.
Definition: ntv2devicescanner.h:346
POPT_TABLEEND
#define POPT_TABLEEND
Definition: options_popt.h:215
CNTV2DriverInterface::GetDeviceID
virtual NTV2DeviceID GetDeviceID(void)
Definition: ntv2driverinterface.cpp:371
NTV2DeviceGetNumVideoOutputs
UWord NTV2DeviceGetNumVideoOutputs(const NTV2DeviceID inDeviceID)
Definition: ntv2devicefeatures.hpp:12012
CNTV2Card::GetSupportedVideoFormats
virtual bool GetSupportedVideoFormats(NTV2VideoFormatSet &outFormats)
Returns a std::set of NTV2VideoFormat values that I support.
Definition: ntv2register.cpp:364
xHEX0N
#define xHEX0N(__x__, __n__)
Definition: ntv2publicinterface.h:5578
POPT_ARG_STRING
#define POPT_ARG_STRING
Definition: options_popt.h:57
POPT_ARG_NONE
#define POPT_ARG_NONE
Definition: options_popt.h:56