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, &pTcSource, 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 {cout << argv[0] <<
", NTV2 SDK " <<
::NTV2Version() << endl;
return 0;}
121 const string deviceSpec (pDeviceSpec ? pDeviceSpec :
"0");
128 if ((channelNumber < 1) || (channelNumber > 8))
129 {cerr <<
"## ERROR: Invalid channel number " << channelNumber <<
" -- expected 1 thru 8" << endl;
return 1;}
137 pDeviceSpec ? deviceSpec :
"");
138 if (inputSourceStr ==
"?" || inputSourceStr ==
"list")
139 {cout << legalSources << endl;
return 0;}
140 if (!inputSourceStr.empty())
143 {cerr <<
"## ERROR: Input source '" << inputSourceStr <<
"' not one of these:" << endl << legalSources << endl;
return 1;}
150 if (tcSourceStr ==
"?" || tcSourceStr ==
"list")
151 {cout << legalTCSources << endl;
return 0;}
153 {cerr <<
"## ERROR: Timecode source '" << tcSourceStr <<
"' not one of these:" << endl << legalTCSources << endl;
return 1;}
156 const string pixelFormatStr (pPixelFormat ? pPixelFormat :
"");
158 if (pixelFormatStr ==
"?" || pixelFormatStr ==
"list")
160 else if (!pixelFormatStr.empty())
164 {cerr <<
"## ERROR: Invalid '--pixelFormat' value '" << pixelFormatStr <<
"' -- expected values:" << endl << legalFBFs << endl;
return 2;}
172 {cerr <<
"## ERROR: Bad '608chan' value '" << pCaptionChannel <<
"' -- expected '" << legalChannels <<
"'" << endl;
return 1;}
176 const string captionSrcStr (pCaptionSource ? pCaptionSource :
"");
177 if (captionSrcStr ==
"?" || captionSrcStr ==
"list")
178 {cout <<
"## NOTE: Legal --608src values: " << legal608Sources << endl;
return 0;}
179 else if (!captionSrcStr.empty())
183 {cerr <<
"## ERROR: Bad '608src' value '" << captionSrcStr <<
"' -- expected '" << legal608Sources <<
"'" << endl;
return 1;}
187 const string outputModeStr (pOutputMode ? pOutputMode :
"");
188 if (outputModeStr ==
"?" || outputModeStr ==
"list")
189 {cout <<
"## NOTE: Legal --output values: " << legalOutputModes << endl;
return 0;}
190 else if (!outputModeStr.empty())
194 {cerr <<
"## ERROR: Bad 'output' value '" << outputModeStr <<
"' -- expected '" << legalOutputModes <<
"'" << endl;
return 1;}
199 cerr <<
"## WARNING: No input channel, or input source, or timecode source specified -- will use NTV2_INPUTSOURCE_SDI1, NTV2_CHANNEL1" << endl;
205 const string framesSpec (pFramesSpec ? pFramesSpec :
"");
206 if (!framesSpec.empty())
209 if (!parseResult.empty())
210 {cerr <<
"## ERROR: Bad 'frames' spec '" << framesSpec <<
"'\n## " << parseResult << endl;
return 1;}
213 {cerr <<
"## ERROR: Bad 'frames' spec '" << framesSpec <<
"'\n## Expected " << legalFramesSpec << endl;
return 1;}
226 {cerr <<
"## ERROR: 'ntv2ccgrabber' initialization failed with status " << status << endl;
return 2;}
236 {cerr <<
"## ERROR: 'ntv2ccgrabber' capture thread failed to run -- check for AutoCirculate messages in AJALogger?" << endl;
return 2;}
242 if (keyPressed ==
'q' || keyPressed ==
'Q')
244 else if (keyPressed >=
'1' && keyPressed <=
'9')
246 else if (keyPressed ==
'?')
247 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;
248 else if (keyPressed ==
'h' || keyPressed ==
'H')
250 else if (keyPressed ==
'v' || keyPressed ==
'V')
252 else if (keyPressed ==
'o' || keyPressed ==
'O')
254 else if (keyPressed ==
'p' || keyPressed ==
'P')
256 else if (keyPressed ==
's' || keyPressed ==
'S')
virtual void SetCaptionDisplayChannel(const NTV2Line21Channel inNewChannel)
Changes the caption channel I'm displaying.
int main(int argc, const char **argv)
Specifies SDI input/output kinds.
CaptionDataSrc fCaptionSrc
Caption data source (Line21? 608 VANC? 608 Anc? etc)
bool fDoMultiFormat
If true, use multi-format/multi-channel mode, if device supports it; otherwise normal mode...
virtual AJAStatus Uninstall()
Uninstalls any previously-installed callback notifier.
static AJAStatus Open(bool incrementRefCount=false)
bool fUseVanc
If true, use Vanc, even if the device supports Anc insertion.
#define AJA_FAILURE(_status_)
static std::string GetInputSourceStrings(const NTV2IOKinds inKinds=NTV2_IOKINDS_ALL, const std::string inDevSpec=std::string())
static std::string GetPixelFormatStrings(const NTV2PixelFormatKinds inKinds=PIXEL_FORMATS_ALL, const std::string inDevSpec=std::string())
bool fBurnCaptions
If true, burn-in captions on 2nd channel.
std::string setFromString(const std::string &inStr)
I can decode captions from frames captured from an AJA device in real time. I can optionally play the...
#define NTV2_IS_VALID_TIMECODE_INDEX(__x__)
virtual AJAStatus Run(void)
Runs me.
This class is used to configure an NTV2CCGrabber instance.
NTV2Channel
These enum values are mostly used to identify a specific widget_framestore. They're also commonly use...
static void PnpCallback(const AJAPnpMessage inMessage, void *pUserData)
This function gets called whenever an AJA device is attached or detached to/from the host...
virtual void ToggleVANC(void)
Toggles the use of VANC. (Debug, experimental)
unsigned GetNumSourceSpecs(void) const
bool fWithAudio
If true, also capture Audio.
NTV2Channel fInputChannel
The device channel to use.
std::string NTV2Version(const bool inDetailed=false)
virtual AJAStatus Init(void)
Initializes me and prepares me to Run.
Specifies analog input/output kinds.
Declares the most fundamental data types used by NTV2. Since Windows NT was the first principal devel...
virtual void Switch608Source(void)
Switches/rotates –608src.
static void Sleep(const int32_t inMilliseconds)
Suspends execution of the current thread for a given number of milliseconds.
#define IS_VALID_OutputMode(_x_)
static NTV2TCIndex GetTCIndexFromString(const std::string &inStr, const NTV2TCIndexKinds inKinds=TC_INDEXES_ALL, const std::string inDevSpec=std::string())
Returns the NTV2TCIndex that matches the given string.
NTV2Line21Channel fCaptionChannel
Caption channel to monitor (defaults to CC1)
static std::string ToLower(const std::string &inStr)
Returns the given string after converting it to lower case.
virtual const std::string & errorStr(void) const
virtual void SwitchPixelFormat(void)
Switches/rotates –pixelFormat.
static std::string OutputModeToString(const OutputMode inMode)
static AJAPnp gPlugAndPlay
This is a platform-agnostic plug-and-play class that notifies a client when AJA devices are attached/...
static char ReadCharacterPress(void)
Returns the character that represents the last key that was pressed on the keyboard without waiting f...
NTV2InputSource fInputSource
The device input connector to use.
#define NTV2_IS_VALID_INPUT_SOURCE(_inpSrc_)
virtual void SwitchOutput(void)
Switches/rotates –output mode.
Declares numerous NTV2 utility functions.
NTV2Line21Channel StrToNTV2Line21Channel(const std::string &inStr)
Converts the given string into the equivalent NTV2Line21Channel value.
Header file for NTV2CCGrabber demonstration class.
Specifies channel or FrameStore 1 (or the first item).
static NTV2InputSource GetInputSourceFromString(const std::string &inStr, const NTV2IOKinds inKinds=NTV2_IOKINDS_ALL, const std::string inDevSpec=std::string())
Returns the NTV2InputSource that matches the given string.
NTV2ACFrameRange fFrames
AutoCirculate frame count or range.
static CaptionDataSrc StringToCaptionDataSrc(const std::string &inDataSrcStr)
static OutputMode StringToOutputMode(const std::string &inModeStr)
NTV2PixelFormat fPixelFormat
Pixel format to use.
static bool IsValidDevice(const std::string &inDeviceSpec)
static bool gGlobalQuit((0))
#define IS_VALID_CaptionDataSrc(_x_)
NTV2TCIndex fTimecodeSource
Timecode source to use (if any)
virtual void ToggleHUD(void)
Toggles the Head-Up-Display.
Declares the AJAPnp (plug-and-play) class.
#define NTV2_IS_VALID_FRAME_BUFFER_FORMAT(__s__)
OutputMode fOutputMode
Desired output (captionStream, Screen etc)
virtual AJAStatus Install(AJAPnpCallback pInCallback, void *inRefCon=NULL, uint32_t inDeviceMask=0xFFFFFFFF)
Installs the given plug & play notification callback function, replacing any callback function that m...
NTV2Line21Channel
The CEA-608 caption channels: CC1 thru CC4, TX1 thru TX4, plus XDS.
Identifies the 1st SDI video input.
static void SignalHandler(int inSignal)
static std::string GetLine21ChannelNames(std::string inDelimiter=", ")
Returns a string containing a concatenation of human-readable names of every available NTV2Line21Chan...
static NTV2PixelFormat GetPixelFormatFromString(const std::string &inStr, const NTV2PixelFormatKinds inKinds=PIXEL_FORMATS_ALL, const std::string inDevSpec=std::string())
Returns the NTV2PixelFormat that matches the given string.
static std::string GetTCIndexStrings(const NTV2TCIndexKinds inKinds=TC_INDEXES_ALL, const std::string inDeviceSpecifier=std::string(), const bool inIsInputOnly=(!(0)))
static std::string CaptionDataSrcToString(const CaptionDataSrc inDataSrc)