|
AJA NTV2 SDK
17.1.3.1410
NTV2 SDK 17.1.3.1410
|
Go to the documentation of this file.
19 #if defined (MSWindows) || defined (AJAWindows)
20 #define SIGQUIT SIGBREAK
49 static unsigned sAttaches (0);
50 static unsigned sDetaches (0);
58 cerr <<
"## WARNING: Terminating 'ntv2ccgrabber' due to device " << (inMessage ==
AJA_Pnp_DeviceAdded ?
"attach" :
"detach") << endl;
66 int main (
int argc,
const char ** argv)
71 const string legalFramesSpec (
"{frameCount}[@{firstFrameNum}] or {firstFrameNum}-{lastFrameNum}");
80 int channelNumber (1);
82 int doMultiFormat (0);
88 ::setlocale (LC_ALL,
"");
96 {
"device",
'd',
POPT_ARG_STRING, &pDeviceSpec, 0,
"device to use",
"index#, serial#, or model" },
97 {
"channel",
'c',
POPT_ARG_INT, &channelNumber, 0,
"channel to use",
"1-8" },
99 {
"pixelFormat",
'p',
POPT_ARG_STRING, &pPixelFormat, 0,
"pixel format to use",
"'?' or 'list' to list" },
100 {
"frames", 0,
POPT_ARG_STRING, &pFramesSpec, 0,
"frames to AutoCirculate",
"num[@min] or min-max" },
101 {
"input",
'i',
POPT_ARG_STRING, &pInputSrcSpec, 0,
"which SDI input",
"1-8, ?=list" },
102 {
"tcsource",
't',
POPT_ARG_STRING, &pTimecodeSpec, 0,
"timecode source",
"'?' or 'list' to list" },
103 {
"608chan", 0,
POPT_ARG_STRING, &pCaptionChannel, 0,
"608 cap chan to monitor", legalChannels.c_str() },
104 {
"608src", 0,
POPT_ARG_STRING, &pCaptionSource, 0,
"608 source to use", legal608Sources.c_str() },
105 {
"output", 0,
POPT_ARG_STRING, &pOutputMode, 0,
"608 output mode", legalOutputModes.c_str() },
116 {cerr <<
"## ERROR: " << popt.
errorStr() << endl;
return 2;}
118 const string deviceSpec (pDeviceSpec ? pDeviceSpec :
"0");
121 const string pixelFormatStr (pPixelFormat ? pPixelFormat :
"");
122 const string framesSpec (pFramesSpec ? pFramesSpec :
"");
124 {cout << argv[0] <<
", NTV2 SDK " <<
::NTV2Version() << endl;
return 0;}
128 if (deviceSpec ==
"?" || deviceSpec ==
"list")
129 {cout << legalDevices << endl;
return 0;}
131 {cout <<
"## ERROR: No such device '" << deviceSpec <<
"'" << endl << legalDevices;
return 1;}
136 if ((channelNumber < 1) || (channelNumber > 8))
137 {cerr <<
"## ERROR: Invalid channel number " << channelNumber <<
" -- expected 1 thru 8" << endl;
return 1;}
142 if (inputSourceStr ==
"?" || inputSourceStr ==
"list")
143 {cout << legalSources << endl;
return 0;}
144 if (!inputSourceStr.empty())
148 {cerr <<
"## ERROR: Input source '" << inputSourceStr <<
"' not one of these:" << endl << legalSources << endl;
return 1;}
153 if (tcSourceStr ==
"?" || tcSourceStr ==
"list")
154 {cout << legalTCSources << endl;
return 0;}
155 if (!tcSourceStr.empty())
159 {cerr <<
"## ERROR: Timecode source '" << tcSourceStr <<
"' not one of these:" << endl << legalTCSources << endl;
return 1;}
164 if (pixelFormatStr ==
"?" || pixelFormatStr ==
"list")
166 else if (!pixelFormatStr.empty())
170 {cerr <<
"## ERROR: Invalid '--pixelFormat' value '" << pixelFormatStr <<
"' -- expected values:" << endl << legalFBFs << endl;
return 2;}
178 {cerr <<
"## ERROR: Bad '608chan' value '" << pCaptionChannel <<
"' -- expected '" << legalChannels <<
"'" << endl;
return 1;}
182 const string captionSrcStr(pCaptionSource ? pCaptionSource :
"");
183 if (captionSrcStr ==
"?" || captionSrcStr ==
"list")
184 {cout <<
"## NOTE: Legal --608src values: " << legal608Sources << endl;
return 0;}
185 else if (!captionSrcStr.empty())
189 {cerr <<
"## ERROR: Bad '608src' value '" << captionSrcStr <<
"' -- expected '" << legal608Sources <<
"'" << endl;
return 1;}
193 const string outputModeStr(pOutputMode ? pOutputMode :
"");
194 if (outputModeStr ==
"?" || outputModeStr ==
"list")
195 {cout <<
"## NOTE: Legal --output values: " << legalOutputModes << endl;
return 0;}
196 else if (!outputModeStr.empty())
200 {cerr <<
"## ERROR: Bad 'output' value '" << outputModeStr <<
"' -- expected '" << legalOutputModes <<
"'" << endl;
return 1;}
205 cerr <<
"## WARNING: No input channel, or input source, or timecode source specified -- will use NTV2_INPUTSOURCE_SDI1, NTV2_CHANNEL1" << endl;
211 if (!framesSpec.empty())
214 if (!parseResult.empty())
215 {cerr <<
"## ERROR: Bad 'frames' spec '" << framesSpec <<
"'\n## " << parseResult << endl;
return 1;}
218 {cerr <<
"## ERROR: Bad 'frames' spec '" << framesSpec <<
"'\n## Expected " << legalFramesSpec << endl;
return 1;}
231 {cerr <<
"## ERROR: 'ntv2ccgrabber' initialization failed with status " << status << endl;
return 2;}
241 {cerr <<
"## ERROR: 'ntv2ccgrabber' capture thread failed to run -- check for AutoCirculate messages in AJALogger?" << endl;
return 2;}
247 if (keyPressed ==
'q' || keyPressed ==
'Q')
249 else if (keyPressed >=
'1' && keyPressed <=
'9')
251 else if (keyPressed ==
'?')
252 cerr << endl <<
"## HELP: 1=CC1 2=CC2 3=CC3 4=CC4 5=Txt1 6=Txt2 7=Txt3 8=Txt4 Q=Quit H=HUD O=Output S=608Src P=PixFmt ?=Help" << endl;
253 else if (keyPressed ==
'h' || keyPressed ==
'H')
255 else if (keyPressed ==
'v' || keyPressed ==
'V')
257 else if (keyPressed ==
'o' || keyPressed ==
'O')
259 else if (keyPressed ==
'p' || keyPressed ==
'P')
261 else if (keyPressed ==
's' || keyPressed ==
'S')
bool fDoMultiFormat
If true, use multi-format/multi-channel mode, if device supports it; otherwise normal mode.
This is a platform-agnostic plug-and-play class that notifies a client when AJA devices are attached/...
NTV2TCIndex fTimecodeSrc
Timecode source to use (if any)
static OutputMode StringToOutputMode(const std::string &inModeStr)
static NTV2InputSource GetInputSourceFromString(const std::string &inStr)
Returns the NTV2InputSource that matches the given string.
OutputMode fOutputMode
Desired output (captionStream, Screen etc)
Header file for NTV2CCGrabber demonstration class.
NTV2Line21Channel fCaptionChannel
Caption channel to monitor (defaults to CC1)
static void PnpCallback(const AJAPnpMessage inMessage, void *pUserData)
This function gets called whenever an AJA device is attached or detached to/from the host.
static char ReadCharacterPress(void)
Returns the character that represents the last key that was pressed on the keyboard without waiting f...
NTV2Channel
These enum values are mostly used to identify a specific widget_framestore. They're also commonly use...
virtual void SwitchPixelFormat(void)
Switches/rotates –pixelFormat.
#define NTV2_IS_VALID_TIMECODE_INDEX(__x__)
NTV2PixelFormat fPixelFormat
Pixel format to use.
int main(int argc, const char **argv)
@ AJA_Pnp_PciVideoDevices
@ kCaptionDataSrc_INVALID
std::string setFromString(const std::string &inStr)
@ NTV2_CHANNEL1
Specifies channel or Frame Store 1 (or the first item).
virtual AJAStatus Install(AJAPnpCallback callback, void *refCon=NULL, uint32_t devices=0)
Installs the given plug-n-play notification callback function, replacing any callback function that m...
virtual AJAStatus Run(void)
Runs me.
CaptionDataSrc fCaptionSrc
Caption data source (Line21? 608 VANC? 608 Anc? etc)
virtual void ToggleHUD(void)
Toggles the Head-Up-Display.
Declares the most fundamental data types used by NTV2. Since Windows NT was the first principal devel...
static NTV2TCIndex GetTCIndexFromString(const std::string &inStr)
Returns the NTV2TCIndex that matches the given string.
static std::string GetDeviceStrings(const NTV2DeviceKinds inKinds=NTV2_DEVICEKIND_ALL)
virtual void SwitchOutput(void)
Switches/rotates –output mode.
@ NTV2_INPUTSOURCE_SDI1
Identifies the 1st SDI video input.
virtual AJAStatus Uninstall()
Uninstalls any previously-installed callback notifier.
static bool IsValidDevice(const std::string &inDeviceSpec)
static bool gGlobalQuit((0))
static void Sleep(const int32_t inMilliseconds)
Suspends execution of the current thread for a given number of milliseconds.
static std::string ToLower(const std::string &inStr)
Returns the given string after converting it to lower case.
static std::string GetLine21ChannelNames(std::string inDelimiter=", ")
Returns a string containing a concatenation of human-readable names of every available NTV2Line21Chan...
static NTV2FrameBufferFormat GetPixelFormatFromString(const std::string &inStr)
Returns the NTV2FrameBufferFormat that matches the given string.
This class is used to configure an NTV2CCGrabber instance.
virtual AJAStatus Init(void)
Initializes me and prepares me to Run.
static void SignalHandler(int inSignal)
NTV2Line21Channel StrToNTV2Line21Channel(const std::string &inStr)
Converts the given string into the equivalent NTV2Line21Channel value.
#define NTV2_IS_VALID_INPUT_SOURCE(_inpSrc_)
Declares numerous NTV2 utility functions.
virtual const std::string & errorStr(void) const
std::string NTV2Version(const bool inDetailed=false)
static std::string CaptionDataSrcToString(const CaptionDataSrc inDataSrc)
static std::string GetTCIndexStrings(const NTV2TCIndexKinds inKinds=TC_INDEXES_ALL, const std::string inDeviceSpecifier=std::string(), const bool inIsInputOnly=(!(0)))
#define IS_VALID_OutputMode(_x_)
Declares the AJAPnp (plug-and-play) class.
#define IS_VALID_CaptionDataSrc(_x_)
static AJAStatus Open(bool incrementRefCount=false)
NTV2ACFrameRange fFrames
AutoCirculate frame count or range.
NTV2Channel fInputChannel
The device channel to use.
static std::string GetInputSourceStrings(const NTV2IOKinds inKinds=NTV2_IOKINDS_ALL, const std::string inDeviceSpecifier=std::string())
virtual void SetCaptionDisplayChannel(const NTV2Line21Channel inNewChannel)
Changes the caption channel I'm displaying.
I can decode captions from frames captured from an AJA device in real time. I can optionally play the...
NTV2Line21Channel
The CEA-608 caption channels: CC1 thru CC4, TX1 thru TX4, plus XDS.
virtual void Switch608Source(void)
Switches/rotates –608src.
static std::string OutputModeToString(const OutputMode inMode)
static std::string GetPixelFormatStrings(const NTV2PixelFormatKinds inKinds=PIXEL_FORMATS_ALL, const std::string inDeviceSpecifier=std::string())
static AJAPnp gPlugAndPlay
@ NTV2_IOKINDS_SDI
Specifies SDI input/output kinds.
bool fUseVanc
If true, use Vanc, even if the device supports Anc insertion.
static CaptionDataSrc StringToCaptionDataSrc(const std::string &inDataSrcStr)
#define NTV2_IS_VALID_FRAME_BUFFER_FORMAT(__s__)
#define AJA_FAILURE(_status_)
bool fBurnCaptions
If true, burn-in captions on 2nd channel.
unsigned GetNumSourceSpecs(void) const
NTV2InputSource fInputSource
The device input connector to use.
virtual void ToggleVANC(void)
Toggles the use of VANC. (Debug, experimental)
bool fWithAudio
If true, also capture Audio.