AJA NTV2 SDK  17.6.0.2675
NTV2 SDK 17.6.0.2675
main.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MIT */
9 // Includes
10 #include "ntv2overlay.h"
11 #include <signal.h>
12 #include <iostream>
13 #include <iomanip>
14 
15 using namespace std;
16 
17 
18 // Globals
19 static bool gGlobalQuit (false);
20 
21 
22 static void SignalHandler (int inSignal)
23 {
24  (void) inSignal;
25  gGlobalQuit = true;
26 }
27 
28 
29 int main (int argc, const char ** argv)
30 {
31  char * pDeviceSpec (AJA_NULL); // Which device to use
32  int showVersion (0); // Show version?
34 
35  // Command line option descriptions:
36  const struct poptOption optionsTable [] =
37  {
38  {"version", 0, POPT_ARG_NONE, &showVersion, 0, "show version & exit", AJA_NULL },
39  {"device", 'd', POPT_ARG_STRING, &pDeviceSpec, 0, "device to use", "index#, serial#, or model" },
42  };
43  CNTV2DemoCommon::Popt popt(argc, argv, optionsTable);
44  if (!popt)
45  {cerr << "## ERROR: " << popt.errorStr() << endl; return 2;}
46  if (showVersion)
47  {cout << argv[0] << ", NTV2 SDK " << ::NTV2Version() << endl; return 0;}
48 
49  // Device
50  const string deviceSpec (pDeviceSpec ? pDeviceSpec : "0");
51  OverlayConfig config(deviceSpec);
52  config.fInputSource = NTV2_INPUTSOURCE_SDI1; // Use NTV2_INPUTSOURCE_HDMI1 or NTV2_INPUTSOURCE_SDI1
53  config.fPixelFormat = NTV2_FBF_ARGB; // Use NTV2_FBF_8BIT_YCBCR or NTV2_FBF_ARGB
54  config.fDoMultiFormat = true;
55 
56  // Instantiate the NTV2Overlay object...
57  NTV2Overlay overlayer (config);
58 
59  // Initialize the NTV2Burn instance...
60  AJAStatus status (overlayer.Init());
61  if (AJA_FAILURE(status))
62  {cerr << "## ERROR: Initialization failed, status=" << status << endl; return 4;}
63 
64  ::signal (SIGINT, SignalHandler);
65  #if defined (AJAMac)
66  ::signal (SIGHUP, SignalHandler);
67  ::signal (SIGQUIT, SignalHandler);
68  #endif
69 
70  // Start the burner's capture and playout threads...
71  overlayer.Run();
72 
73  // Loop until told to stop...
74  ULWord counter(0);
75  do
76  {
77  cout << setw(9) << ++counter << "\r" << flush;
78  AJATime::Sleep(2000);
79  } while (!gGlobalQuit); // loop until signaled
80 
81  cout << endl;
82  return 0;
83 
84 } // main
NTV2_FBF_ARGB
@ NTV2_FBF_ARGB
See 8-Bit ARGB, RGBA, ABGR Formats.
Definition: ntv2enums.h:218
poptOption
Definition: options_popt.h:148
SignalHandler
void SignalHandler(int inSignal)
Definition: main.cpp:26
BurnConfig::fDoMultiFormat
bool fDoMultiFormat
If true, enables device-sharing; otherwise takes exclusive control of the device.
Definition: ntv2democommon.h:396
gGlobalQuit
static bool gGlobalQuit((0))
Set this "true" to exit gracefully.
ntv2overlay.h
Header file for the NTV2Overlay demonstration class.
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
BurnConfig::fPixelFormat
NTV2PixelFormat fPixelFormat
The pixel format to use.
Definition: ntv2democommon.h:394
POPT_AUTOHELP
#define POPT_AUTOHELP
Definition: options_popt.h:220
NTV2Overlay::Run
AJAStatus Run(void)
Runs me (only after Init called)
Definition: ntv2overlay.cpp:370
NTV2_INPUTSOURCE_SDI1
@ NTV2_INPUTSOURCE_SDI1
Identifies the 1st SDI video input.
Definition: ntv2enums.h:1263
AJAStatus
AJAStatus
Definition: types.h:378
AJATime::Sleep
static void Sleep(const int32_t inMilliseconds)
Suspends execution of the current thread for a given number of milliseconds.
Definition: systemtime.cpp:284
ULWord
uint32_t ULWord
Definition: ajatypes.h:256
CNTV2DemoCommon::Popt
Definition: ntv2democommon.h:849
CNTV2DemoCommon::Popt::errorStr
virtual const std::string & errorStr(void) const
Definition: ntv2democommon.h:857
NTV2Version
std::string NTV2Version(const bool inDetailed=false)
Definition: ntv2version.cpp:41
NTV2Overlay::Init
AJAStatus Init(void)
Prepares me to Run()
Definition: ntv2overlay.cpp:68
AJADebug::Open
static AJAStatus Open(bool incrementRefCount=false)
Definition: debug.cpp:44
AJA_NULL
#define AJA_NULL
Definition: ajatypes.h:200
BurnConfig::fInputSource
NTV2InputSource fInputSource
The device input connector to use.
Definition: ntv2democommon.h:390
std
Definition: json.hpp:5362
POPT_TABLEEND
#define POPT_TABLEEND
Definition: options_popt.h:215
AJA_FAILURE
#define AJA_FAILURE(_status_)
Definition: types.h:371
BurnConfig
Configures an NTV2Burn or NTV2FieldBurn instance.
Definition: ntv2democommon.h:383
NTV2Overlay
Outputs live input video overlaid with image having transparency.
Definition: ntv2overlay.h:22
POPT_ARG_STRING
#define POPT_ARG_STRING
Definition: options_popt.h:57
POPT_ARG_NONE
#define POPT_ARG_NONE
Definition: options_popt.h:56