AJA NTV2 SDK  17.5.0.1242
NTV2 SDK 17.5.0.1242
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  string serial;
26 
27  // Print the display name...
28  cout << "Device " << DEC(inCard.GetIndexNumber()+1) << ":" << endl
29 
30  // Print description, device ID and serial number...
31  << "\t" << "Description: " << inCard.GetDescription() << endl
32  << "\t" << "Name: '" << inCard.GetDisplayName() << "'" << endl
33  << "\t" << "Device ID: " << xHEX0N(deviceID,8) << endl
34  << "\t" << "Serial Number: '" << (inCard.GetSerialNumberString(serial) ? serial : serial) << "'" << endl
35 
36  // Print some additional info gleaned from the device features API...
37  << "\t" << inCard.features().GetNumVideoInputs() << " SDI Input(s)" << endl
38  << "\t" << inCard.features().GetNumVideoOutputs() << " SDI Output(s)" << endl
39  << "\t" << inCard.features().GetNumHDMIVideoInputs() << " HDMI Input(s)" << endl
40  << "\t" << inCard.features().GetNumHDMIVideoOutputs() << " HDMI Output(s)" << endl
41  << "\t" << inCard.features().GetNumAnalogVideoInputs() << " Analog Input(s)" << endl
42  << "\t" << inCard.features().GetNumAnalogVideoOutputs() << " Analog Output(s)" << endl
43  << "\t" << inCard.features().GetNumEmbeddedAudioInputChannels() << " channel(s) of Embedded Audio Input" << endl
44  << "\t" << inCard.features().GetNumEmbeddedAudioOutputChannels() << " channel(s) of Embedded Audio Output" << endl;
45 
46  // Show its video and pixel format capabilities:
47  const NTV2VideoFormatSet videoFormats(inCard.features().VideoFormats());
48  const NTV2PixelFormats pixelFormats(inCard.features().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  cout << "AJA NTV2 SDK " << ::NTV2Version() << " supports devices: " << ::NTV2GetSupportedDevices() << endl;
93 
94  // Discover the AJA device(s) on the local host...
95  ULWord deviceCount(0);
96  while (CNTV2DeviceScanner::GetDeviceAtIndex(deviceCount, device))
97  {
98  if (deviceCount)
99  cout << endl << endl << endl;
100  ShowDeviceInfo(device);
101  deviceCount++;
102  } // for each device
103  if (!deviceCount)
104  cout << "No AJA devices found" << endl;
105 
106  return deviceCount ? 0 : 1;
107 
108 } // main
CNTV2DemoCommon::Popt::otherArgs
virtual const NTV2StringList & otherArgs(void) const
Definition: ntv2democommon.h:857
poptOption
Definition: options_popt.h:148
NTV2PixelFormats
NTV2FrameBufferFormatSet NTV2PixelFormats
Definition: ntv2publicinterface.h:8807
NTV2GetSupportedDevices
NTV2DeviceIDSet NTV2GetSupportedDevices(const NTV2DeviceKinds inKinds=NTV2_DEVICEKIND_ALL)
Returns an NTV2DeviceIDSet of devices supported by the SDK.
Definition: ntv2utils.cpp:7591
NTV2VideoFormatSet
std::set< NTV2VideoFormat > NTV2VideoFormatSet
A set of distinct NTV2VideoFormat values.
Definition: ntv2publicinterface.h:8802
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:374
NTV2DeviceID
NTV2DeviceID
Identifies a specific AJA NTV2 device model number. The NTV2DeviceID is actually the PROM part number...
Definition: ntv2enums.h:20
DeviceCapabilities::VideoFormats
NTV2VideoFormatSet VideoFormats(void)
Definition: ntv2devicecapabilities.h:286
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
nlohmann::json_abiNLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON_v3_11_NLOHMANN_JSON_VERSION_PATCH::detail::void
j template void())
Definition: json.hpp:4893
DeviceCapabilities::PixelFormats
NTV2PixelFormats PixelFormats(void)
Definition: ntv2devicecapabilities.h:275
CNTV2Card::features
virtual class DeviceCapabilities & features(void)
Definition: ntv2card.h:141
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:86
CNTV2DemoCommon::IsValidDevice
static bool IsValidDevice(const std::string &inDeviceSpec)
Definition: ntv2democommon.cpp:455
ULWord
uint32_t ULWord
Definition: ajatypes.h:255
CNTV2Card::GetDescription
virtual std::string GetDescription(void) const
Definition: ntv2card.cpp:124
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:214
CNTV2DemoCommon::Popt
Definition: ntv2democommon.h:848
CNTV2DemoCommon::Popt::errorStr
virtual const std::string & errorStr(void) const
Definition: ntv2democommon.h:856
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:28
AJADebug::Open
static AJAStatus Open(bool incrementRefCount=false)
Definition: debug.cpp:44
AJA_NULL
#define AJA_NULL
Definition: ajatypes.h:199
DEC
#define DEC(__x__)
Definition: ntv2publicinterface.h:5606
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:274
std
Definition: json.hpp:5362
POPT_TABLEEND
#define POPT_TABLEEND
Definition: options_popt.h:215
CNTV2DriverInterface::GetDeviceID
virtual NTV2DeviceID GetDeviceID(void)
Definition: ntv2driverinterface.cpp:407
xHEX0N
#define xHEX0N(__x__, __n__)
Definition: ntv2publicinterface.h:5605
POPT_ARG_STRING
#define POPT_ARG_STRING
Definition: options_popt.h:57
POPT_ARG_NONE
#define POPT_ARG_NONE
Definition: options_popt.h:56