AJA NTV2 SDK
18.1.0.2262
NTV2 SDK 18.1.0.2262
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?
33
AJADebug::Open
();
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"
},
40
POPT_AUTOHELP
41
POPT_TABLEEND
42
};
43
CNTV2DemoCommon::Popt
popt(argc, argv, optionsTable);
44
if
(!popt)
45
{cerr <<
"## ERROR: "
<< popt.
errorStr
() << endl;
return
2;}
46
if
(!popt.
otherArgs
().empty())
47
{cerr <<
"## WARNING: ignored argument(s): '"
<<
aja::join
(popt.
otherArgs
(),
"', '"
) <<
"'"
<< endl;
return
2;}
48
if
(showVersion)
49
{cout << argv[0] <<
", NTV2 SDK "
<<
::NTV2Version
() << endl;
return
0;}
50
51
// Device
52
const
string
deviceSpec (pDeviceSpec ? pDeviceSpec :
"0"
);
53
OverlayConfig
config(deviceSpec);
54
config.
fInputSource
=
NTV2_INPUTSOURCE_SDI1
;
// Use NTV2_INPUTSOURCE_HDMI1 or NTV2_INPUTSOURCE_SDI1
55
config.
fPixelFormat
=
NTV2_FBF_ARGB
;
// Use NTV2_FBF_8BIT_YCBCR or NTV2_FBF_ARGB
56
config.
fDoMultiFormat
=
true
;
57
58
// Instantiate the NTV2Overlay object...
59
NTV2Overlay
overlayer (config);
60
61
// Initialize the NTV2Burn instance...
62
AJAStatus
status (overlayer.
Init
());
63
if
(
AJA_FAILURE
(status))
64
{cerr <<
"## ERROR: Initialization failed, status="
<< status << endl;
return
4;}
65
66
::signal (SIGINT,
SignalHandler
);
67
#if defined (AJAMac)
68
::signal (SIGHUP,
SignalHandler
);
69
::signal (SIGQUIT,
SignalHandler
);
70
#endif
71
72
// Start the burner's capture and playout threads...
73
overlayer.
Run
();
74
75
// Loop until told to stop...
76
ULWord
counter(0);
77
do
78
{
79
cout << setw(9) << ++counter <<
"\r"
<< flush;
80
AJATime::Sleep
(2000);
81
}
while
(!
gGlobalQuit
);
// loop until signaled
82
83
cout << endl;
84
return
0;
85
86
}
// main
main
int main(int argc, const char **argv)
Definition:
main.cpp:30
gGlobalQuit
static bool gGlobalQuit((0))
Set this "true" to exit gracefully.
AJAStatus
AJAStatus
Definition:
types.h:380
AJADebug::Open
static AJAStatus Open(bool incrementRefCount=false)
Definition:
debug.cpp:44
AJA_FAILURE
#define AJA_FAILURE(_status_)
Definition:
types.h:373
ntv2overlay.h
Header file for the NTV2Overlay demonstration class.
std
Definition:
json.hpp:5362
SignalHandler
void SignalHandler(int inSignal)
Definition:
main.cpp:26
ULWord
uint32_t ULWord
Definition:
ajatypes.h:236
POPT_AUTOHELP
#define POPT_AUTOHELP
Definition:
options_popt.h:227
BurnConfig::fPixelFormat
NTV2PixelFormat fPixelFormat
The pixel format to use.
Definition:
ntv2democommon.h:408
NTV2Version
std::string NTV2Version(const bool inDetailed=false)
Definition:
ntv2version.cpp:41
NTV2Overlay::Run
AJAStatus Run(void)
Runs me (only after Init called)
Definition:
ntv2overlay.cpp:370
AJA_NULL
#define AJA_NULL
Definition:
ajatypes.h:180
CNTV2DemoCommon::Popt::otherArgs
virtual const NTV2StringList & otherArgs(void) const
Definition:
ntv2democommon.h:861
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
CNTV2DemoCommon::Popt::errorStr
virtual const std::string & errorStr(void) const
Definition:
ntv2democommon.h:860
NTV2_FBF_ARGB
See 8-Bit ARGB, RGBA, ABGR Formats.
Definition:
ntv2enums.h:226
BurnConfig
Configures an NTV2Burn or NTV2FieldBurn instance.
Definition:
ntv2democommon.h:397
NTV2Overlay::Init
AJAStatus Init(void)
Prepares me to Run()
Definition:
ntv2overlay.cpp:68
CNTV2DemoCommon::Popt
Definition:
ntv2democommon.h:852
BurnConfig::fDoMultiFormat
bool fDoMultiFormat
If true, enables device-sharing; otherwise takes exclusive control of the device. ...
Definition:
ntv2democommon.h:410
POPT_TABLEEND
#define POPT_TABLEEND
Definition:
options_popt.h:222
aja::join
std::string join(const std::vector< std::string > &parts, const std::string &delim)
Definition:
common.cpp:468
NTV2Overlay
Outputs live input video overlaid with image having transparency.
Definition:
ntv2overlay.h:22
poptOption
Definition:
options_popt.h:155
POPT_ARG_STRING
#define POPT_ARG_STRING
Definition:
options_popt.h:57
NTV2_INPUTSOURCE_SDI1
Identifies the 1st SDI video input.
Definition:
ntv2enums.h:1271
POPT_ARG_NONE
#define POPT_ARG_NONE
Definition:
options_popt.h:56
nlohmann::json_abi_v3_11_3::detail::void
j template void())
Definition:
json.hpp:4893
BurnConfig::fInputSource
NTV2InputSource fInputSource
The device input connector to use.
Definition:
ntv2democommon.h:404
libajantv2
demos
ntv2overlay
main.cpp
Generated on Thu Jun 4 2026 06:18:26 for AJA NTV2 SDK by
1.8.14