30 mInputPixFormat (inConfig.fPixelFormat),
53 while (mPlayThread.
Active())
56 while (mCaptureThread.
Active())
78 cerr <<
"## WARNING: Device '" << mDevice.
GetDescription() <<
"' is not KONA X" << endl;
87 cerr <<
"## ERROR: Cannot acquire '" << mDevice.
GetDescription() <<
"' because another app (pid " <<
appPID <<
") owns it" << endl;
119 cerr <<
"Device Description: " << mDevice.
GetDescription() << endl;
122 CAPINFO(
"Configuration: " << mConfig);
PLINFO(
"Configuration: " << mConfig);
145 const UWord mixerNum (0);
187 if (isCaptureBufferRGB && !isSignalRGB)
192 else if (!isCaptureBufferRGB && isSignalRGB)
244 if (!frameData.fVideoBuffer.Allocate(captureBufferSize,
true))
246 mAVCircularBuffer.
Add(&frameData);
255 mAVCircularBuffer.
Clear();
263 for (
ULWord y(yTop); y < (yTop + height); y++)
264 for (
ULWord w(0); w < pixThickness; w++)
273 for (
ULWord v(0); v < vThickness; v++)
274 for (
ULWord x(xLeft); x < (xLeft + width); x++)
275 buf.
U32((yPos + v) * info.
linePitch + x) = argbPixValue;
283 DrawVLine (buf, info, argbPixValue, pixThickness, topLeftX, topLeftY, height);
284 DrawVLine (buf, info, argbPixValue, pixThickness, topLeftX + width - pixThickness, topLeftY, height);
285 DrawHLine (buf, info, argbPixValue, pixThickness, topLeftY, topLeftX, width);
286 DrawHLine (buf, info, argbPixValue, pixThickness, topLeftY + height - pixThickness, topLeftX, width);
292 static const ULWord sOpaqueRed(0xFFFF0000), sOpaqueBlue(0xFF0000FF), sOpaqueGreen(0xFF008000),
293 sOpaqueWhite(0xFFFFFFFF), sOpaqueBlack(0xFF000000);
300 static const vector<ULWord> sColors = {sOpaqueWhite, sOpaqueRed, sOpaqueBlue, sOpaqueGreen};
301 const ULWord hght(256), wdth(256), thickness(wdth/16);
312 DrawBox (mBug, mBugRasterInfo, sColors.at(
n), thickness,
n*2*thickness,
n*2*thickness, wdth-2*
n*2*thickness, hght-2*
n*2*thickness);
315 DrawVLine (mBug, mBugRasterInfo, sOpaqueBlack, 1, wdth/2, hght/2-thickness, 2*thickness);
316 DrawHLine (mBug, mBugRasterInfo, sOpaqueBlack, 1, hght/2, wdth/2-thickness, 2*thickness);
324 ULWord numConsecutiveFrames(0), MIN_NUM_CONSECUTIVE_FRAMES(6);
341 if (++loopCount % 500 == 0)
344 else if (numConsecutiveFrames == 0)
347 numConsecutiveFrames++;
349 else if (numConsecutiveFrames == MIN_NUM_CONSECUTIVE_FRAMES)
351 numConsecutiveFrames = 0;
355 numConsecutiveFrames = (lastVF == currVF) ? numConsecutiveFrames + 1 : 0;
394 NTV2Overlay * pApp (reinterpret_cast<NTV2Overlay*>(pContext));
415 ULWord goodWaits(0), badWaits(0), goodBlits(0), badBlits(0), goodXfers(0), badXfers(0), pingPong(0);
426 {cerr <<
"## ERROR: Failed to allocate " << rasterInfo.
GetTotalRasterBytes() <<
"-byte vid buffer" << endl;
return;}
433 {cerr <<
"## NOTE: Allocate 2-frame AC" <<
DEC(mConfig.
fOutputChannel+1) <<
" range failed" << endl;
return;}
436 <<
" raster:" << rasterInfo <<
", bug:" << mBugRasterInfo);
484 pingPong = pingPong ? 0 : 1;
490 if (++loops % 500 == 0)
491 PLDBG(
DEC(thrdNum) <<
": " <<
DEC(goodXfers) <<
" xfers (" <<
DEC(badXfers) <<
" failed), " <<
DEC(goodBlits)
492 <<
" blits (" <<
DEC(badBlits) <<
" failed), " <<
DEC(goodWaits) <<
" waits (" 493 <<
DEC(badWaits) <<
" failed)");
498 PLNOTE(
DEC(thrdNum) <<
" done: " <<
DEC(goodXfers) <<
" xfers (" <<
DEC(badXfers) <<
" failed), " 499 <<
DEC(goodBlits) <<
" blits (" <<
DEC(badBlits) <<
" failed), " <<
DEC(goodWaits) <<
" waits (" <<
DEC(badWaits) <<
" failed)");
514 mCaptureThread.
Start();
522 NTV2Overlay * pApp (reinterpret_cast<NTV2Overlay*>(pContext));
540 ULWord loops(0), bails(0), vfChgTally(0), badWaits(0), waitTally(0), goodXfers(0), badXfers(0);
561 { cerr <<
"## NOTE: Failed to [re]allocate host buffers" << endl;
568 { cerr <<
"## NOTE: Input A/C allocate device frame buffer range failed" << endl;
589 xferInfo.
SetVideoBuffer (pCaptureData->VideoBuffer(), pCaptureData->VideoBufferSize());
601 if (++loops % 500 == 0)
602 CAPDBG(
DEC(vfChgTally) <<
" sigChgs, " <<
DEC(bails) <<
" bails, " <<
DEC(waitTally)
603 <<
" waits (" <<
DEC(badWaits) <<
" failed), " <<
DEC(goodXfers) <<
" xfers (" 604 <<
DEC(badXfers) <<
" failed)");
620 CAPNOTE(
"Done: " <<
DEC(vfChgTally) <<
" sigChgs, " <<
DEC(bails) <<
" bails, " <<
DEC(waitTally)
621 <<
" waits (" <<
DEC(badWaits) <<
" failed), " <<
DEC(goodXfers) <<
" xfers (" 622 <<
DEC(badXfers) <<
" failed)");
NTV2Channel NTV2InputSourceToChannel(const NTV2InputSource inInputSource)
Converts a given NTV2InputSource to its equivalent NTV2Channel value.
virtual bool SetMixerBGMatteEnabled(const UWord inWhichMixer, const bool inIsEnabled)
Answers if the given mixer/keyer's background matte is enabled or not.
virtual bool SetTaskMode(const NTV2TaskMode inMode)
Sets the device's task mode.
#define NTV2_IS_VALID_TASK_MODE(__m__)
void StartInputThread(void)
Starts input thread.
NTV2AudioSystem
Used to identify an Audio System on an NTV2 device. See Audio System Operation for more information...
virtual bool SetHDMIOutAudioSource2Channel(const NTV2AudioChannelPair inNewValue, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_1, const NTV2Channel inWhichHDMIOut=NTV2_CHANNEL1)
Sets the HDMI output's 2-channel audio source.
bool Allocate(const size_t inByteCount, const bool inPageAligned=false)
Allocates (or re-allocates) my user-space storage using the given byte count. I assume full responsib...
NTV2VideoFormat WaitForStableInputSignal(void)
Waits for stable input signal.
void RouteInputSignal(void)
Performs input routing.
Declares common types used in the ajabase library.
virtual bool SetAudioLoopBack(const NTV2AudioLoopBack inMode, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_1)
Enables or disables NTV2AudioLoopBack mode for the given NTV2AudioSystem.
virtual bool SetReference(const NTV2ReferenceSource inRefSource, const bool inKeepFramePulseSelect=(0))
Sets the device's clock reference source. See Video Output Clocking & Synchronization for more inform...
virtual bool ReleaseStreamForApplication(ULWord inApplicationType, int32_t inProcessID)
Releases exclusive use of the AJA device for the given process, permitting other processes to acquire...
static bool DrawBox(NTV2Buffer &buf, const NTV2RasterInfo &info, const ULWord argbPixValue, const UWord pixThickness, const UWord topLeftX, const UWord topLeftY, const ULWord width, const ULWord height)
static void InputThreadStatic(AJAThread *pThread, void *pInstance)
Static output/playout thread function.
AJAStatus Add(FrameDataPtr pInFrameData)
Appends a new frame buffer to me, increasing my frame storage capacity by one frame.
virtual bool SetMixerMode(const UWord inWhichMixer, const NTV2MixerKeyerMode inMode)
Sets the mode for the given mixer/keyer.
virtual bool SetVideoFormat(const NTV2VideoFormat inVideoFormat, const bool inIsAJARetail=(!(0)), const bool inKeepVancSettings=(0), const NTV2Channel inChannel=NTV2_CHANNEL1)
Configures the AJA device to handle a specific video format.
void ReleaseCaptureBuffers(void)
Frees capture buffers & ring.
static bool DrawHLine(NTV2Buffer &buf, const NTV2RasterInfo &info, const ULWord argbPixValue, const ULWord vThickness, const ULWord yPos, const ULWord xLeft, const ULWord width)
void Quit(void)
Gracefully stops me.
virtual bool IsDeviceReady(const bool inCheckValid=(0))
enum _NTV2VideoFormat NTV2VideoFormat
Identifies a particular video format.
static ULWord gPlayEnterCount(0)
AJAStatus SetupCaptureBuffers(void)
Allocates capture buffers & ring.
#define AJA_FAILURE(_status_)
uint32_t U32(const int inIndex) const
ULWord GetByteCount(void) const
virtual bool DMAWriteFrame(const ULWord inFrameNumber, const ULWord *pInFrameBuffer, const ULWord inByteCount)
Transfers a single frame from the host to the AJA device.
Capture (input) mode, which writes into device SDRAM.
void RouteOutputSignal(void)
Performs output routing.
LWord acStartFrame
First frame to circulate. FIXFIXFIX Why is this signed? CHANGE TO ULWord??
void Clear(void)
Clears my frame collection, their locks, everything.
Declares the AJATime class.
virtual AJAStatus SetPriority(AJAThreadPriority priority)
FrameDataPtr StartConsumeNextBuffer(void)
The thread that's responsible for processing incoming frames – the consumer – calls this function t...
#define NTV2_FOURCC(_a_, _b_, _c_, _d_)
Header file for the NTV2Overlay demonstration class.
void OutputThread(void)
The output/playout thread function.
virtual bool SetMixerBGInputControl(const UWord inWhichMixer, const NTV2MixerKeyerInputControl inInputControl)
Sets the background input control value for the given mixer/keyer.
virtual AJAStatus Start()
virtual bool SubscribeInputVerticalEvent(const NTV2Channel inChannel=NTV2_CHANNEL1)
Causes me to be notified when an input vertical blanking interrupt occurs on the given input channel...
void EndConsumeNextBuffer(void)
The consumer thread calls this function to signal that it has finished processing the frame it obtain...
virtual bool AutoCirculateGetStatus(const NTV2Channel inChannel, AUTOCIRCULATE_STATUS &outStatus)
Returns the current AutoCirculate status for the given channel.
virtual bool SetFrameBufferFormat(NTV2Channel inChannel, NTV2FrameBufferFormat inNewFormat, bool inIsAJARetail=(!(0)), NTV2HDRXferChars inXferChars=NTV2_VPID_TC_SDR_TV, NTV2HDRColorimetry inColorimetry=NTV2_VPID_Color_Rec709, NTV2HDRLuminance inLuminance=NTV2_VPID_Luminance_YCbCr)
Sets the frame buffer format for the given FrameStore on the AJA device.
virtual bool SetMultiFormatMode(const bool inEnable)
Enables or disables multi-format (per channel) device operation. If enabled, each device channel can ...
virtual bool GetHDMIInputColor(NTV2LHIHDMIColorSpace &outValue, const NTV2Channel inHDMIInput=NTV2_CHANNEL1)
Answers with the current colorspace for the given HDMI input.
NTV2Overlay(const OverlayConfig &inConfig)
Construct from OverlayConfig.
#define NTV2_ASSERT(_expr_)
virtual bool ClearRouting(void)
Removes all existing signal path connections between any and all widgets on the AJA device...
A handy class that makes it easy to "bounce" an unsigned integer value between a minimum and maximum ...
virtual bool IsRemote(void) const
bool CopyRaster(const NTV2PixelFormat inPixelFormat, UByte *pDstBuffer, const ULWord inDstBytesPerLine, const UWord inDstTotalLines, const UWord inDstVertLineOffset, const UWord inDstHorzPixelOffset, const UByte *pSrcBuffer, const ULWord inSrcBytesPerLine, const UWord inSrcTotalLines, const UWord inSrcVertLineOffset, const UWord inSrcVertLinesToCopy, const UWord inSrcHorzPixelOffset, const UWord inSrcHorzPixelsToCopy)
Copies all or part of a source raster image into a destination raster at a given position.
bool Fill(const T &inValue)
Fills me with the given scalar value.
virtual bool GetTaskMode(NTV2TaskMode &outMode)
Retrieves the device's current task mode.
AutoCirculate Frame Range.
std::string NTV2InputSourceToString(const NTV2InputSource inValue, const bool inForRetailDisplay=false)
NTV2OutputXptID GetInputSourceOutputXpt(const NTV2InputSource inInputSource, const bool inIsSDI_DS2=false, const bool inIsHDMI_RGB=false, const UWord inHDMI_Quadrant=0)
NTV2PixelFormat fPixelFormat
The pixel format to use.
static bool DrawVLine(NTV2Buffer &buf, const NTV2RasterInfo &info, const ULWord argbPixValue, const ULWord pixThickness, const ULWord xPos, const ULWord yTop, const ULWord height)
NTV2Channel fOutputChannel
The output channel to use.
AJAStatus SetupAudio(void)
Performs all audio setup.
virtual bool SetOutputFrame(const NTV2Channel inChannel, const ULWord inValue)
Sets the output frame index number for the given FrameStore. This identifies which frame in device SD...
0: Disabled (never recommended): device configured exclusively by client application(s).
Playout (output) mode, which reads from device SDRAM.
virtual std::string GetDescription(void) const
virtual bool SetMode(const NTV2Channel inChannel, const NTV2Mode inNewValue, const bool inIsRetail=(!(0)))
Determines if a given FrameStore on the AJA device will be used to capture or playout video...
AJAStatus Run(void)
Runs me (only after Init called)
virtual bool UnsubscribeOutputVerticalEvent(const NTV2Channel inChannel)
Unregisters me so I'm no longer notified when an output VBI is signaled on the given output channel...
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...
virtual bool SetSDITransmitEnable(const NTV2Channel inChannel, const bool inEnable)
Sets the specified bidirectional SDI connector to act as an input or an output.
#define NTV2_INPUT_SOURCE_IS_HDMI(_inpSrc_)
virtual bool AutoCirculateTransfer(const NTV2Channel inChannel, AUTOCIRCULATE_TRANSFER &transferInfo)
Transfers all or part of a frame as specified in the given AUTOCIRCULATE_TRANSFER object to/from the ...
virtual bool AcquireStreamForApplication(ULWord inApplicationType, int32_t inProcessID)
Reserves exclusive use of the AJA device for a given process, preventing other processes on the host ...
void SetAbortFlag(const bool *pAbortFlag)
Tells me the boolean variable I should monitor such that when it gets set to "true" will cause any th...
#define NTV2_IS_FBF_RGB(__fbf__)
virtual NTV2VideoFormat GetInputVideoFormat(const NTV2InputSource inVideoSource=NTV2_INPUTSOURCE_SDI1, const bool inIsProgressive=(0))
Returns the video format of the signal that is present on the given input source. ...
static void Sleep(const int32_t inMilliseconds)
Suspends execution of the current thread for a given number of milliseconds.
This selects audio channels 1 and 2 (Group 1 channels 1 and 2)
virtual ~NTV2Overlay()
My destructor.
2: OEM (recommended): device configured by client application(s) with some driver involvement...
virtual bool SetSDIOutputAudioSystem(const NTV2Channel inSDIOutputConnector, const NTV2AudioSystem inAudioSystem)
Sets the device's NTV2AudioSystem that will provide audio for the given SDI output's audio embedder...
std::string NTV2VideoFormatToString(const NTV2VideoFormat inValue, const bool inUseFrameRate=false)
See 8-Bit ARGB, RGBA, ABGR Formats.
Embeds silence (zeroes) into the data stream.
AJAStatus SetupVideo(void)
Performs all video setup.
virtual bool SetMixerCoefficient(const UWord inWhichMixer, const ULWord inMixCoefficient)
Sets the current mix coefficient of the given mixer/keyer.
static int32_t Increment(int32_t volatile *pTarget)
Configures an NTV2Burn or NTV2FieldBurn instance.
Specifies channel or FrameStore 2 (or the 2nd item).
virtual NTV2DeviceID GetDeviceID(void)
static void OutputThreadStatic(AJAThread *pThread, void *pInstance)
ULWord GetVideoWriteSize(const NTV2VideoFormat inVideoFormat, const NTV2FrameBufferFormat inFBFormat, const NTV2VANCMode inVancMode=NTV2_VANCMODE_OFF)
Identical to the GetVideoActiveSize function, except rounds the result up to the nearest 4K page size...
Overlays foreground video on top of background video.
Declares the CNTV2DeviceScanner class.
AJAStatus Init(void)
Prepares me to Run()
std::string fDeviceSpec
The AJA device to use.
virtual bool AutoCirculateStop(const NTV2Channel inChannel, const bool inAbort=(0))
Stops AutoCirculate for the given channel, and releases the on-device frame buffers that were allocat...
Declares the AJAProcess class.
Describes a user-space buffer on the host computer. I have an address and a length, plus some optional attributes (allocated by SDK?, page-aligned? etc.).
virtual bool Connect(const NTV2InputCrosspointID inInputXpt, const NTV2OutputCrosspointID inOutputXpt, const bool inValidate=(0))
Connects the given widget signal input (sink) to the given widget signal output (source).
virtual bool SetMixerVancOutputFromForeground(const UWord inWhichMixer, const bool inFromForegroundSource=(!(0)))
Sets the VANC source for the given mixer/keyer to the foreground video (or not). See the SDI Ancillar...
virtual bool UnsubscribeInputVerticalEvent(const NTV2Channel inChannel=NTV2_CHANNEL1)
Unregisters me so I'm no longer notified when an input VBI is signaled on the given input channel...
Declares the AJAAtomic class.
This object specifies the information that will be transferred to or from the AJA device in the CNTV2...
virtual bool SetMixerFGInputControl(const UWord inWhichMixer, const NTV2MixerKeyerInputControl inInputControl)
Sets the foreground input control value for the given mixer/keyer.
void EndProduceNextBuffer(void)
The producer thread calls this function to signal that it has finished populating the frame it obtain...
This identifies the first Audio System.
virtual bool WaitForOutputVerticalInterrupt(const NTV2Channel inChannel=NTV2_CHANNEL1, UWord inRepeatCount=1)
Efficiently sleeps the calling thread/process until the next one or more field (interlaced video) or ...
static const size_t CIRCULAR_BUFFER_SIZE(10)
Number of NTV2FrameData's in our ring.
virtual AJAStatus Attach(AJAThreadFunction *pThreadFunction, void *pUserContext)
FrameDataPtr StartProduceNextBuffer(void)
The thread that's responsible for providing frames – the producer – calls this function to populate...
bool fDoMultiFormat
If true, enables device-sharing; otherwise takes exclusive control of the device. ...
This is returned from the CNTV2Card::AutoCirculateGetStatus function.
Specifies channel or FrameStore 1 (or the first item).
virtual bool AutoCirculateStart(const NTV2Channel inChannel, const ULWord64 inStartTime=0)
Starts AutoCirculating the specified channel that was previously initialized by CNTV2Card::AutoCircul...
AJAStatus SetupOverlayBug(void)
Sets up overlay "bug".
virtual bool SubscribeOutputVerticalEvent(const NTV2Channel inChannel)
Causes me to be notified when an output vertical blanking interrupt is generated for the given output...
virtual bool AutoCirculateInitForOutput(const NTV2Channel inChannel, const UWord inFrameCount=7, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_INVALID, const ULWord inOptionFlags=0, const UByte inNumChannels=1, const UWord inStartFrameNumber=0, const UWord inEndFrameNumber=0)
Prepares for subsequent AutoCirculate playout, designating a contiguous block of frame buffers on the...
I encapsulate the video, audio and anc host buffers used in the AutoCirculate demos. I'm a more modern version of the AVDataBuffer.
bool HasAvailableInputFrame(void) const
NTV2Channel fInputChannel
The input channel to use.
#define NTV2_IS_VALID_VIDEO_FORMAT(__f__)
bool IsRunning(void) const
Outputs live input video overlaid with image having transparency.
virtual bool AutoCirculateInitForInput(const NTV2Channel inChannel, const UWord inFrameCount=7, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_INVALID, const ULWord inOptionFlags=0, const UByte inNumChannels=1, const UWord inStartFrameNumber=0, const UWord inEndFrameNumber=0)
Prepares for subsequent AutoCirculate ingest, designating a contiguous block of frame buffers on the ...
Declares the AJAAncillaryList class.
void InputThread(void)
The input/capture thread function.
virtual bool SetVANCMode(const NTV2VANCMode inVancMode, const NTV2Channel inChannel=NTV2_CHANNEL1)
Sets the VANC mode for the given FrameStore.
bool IsInputSignalRGB(void)
static ULWord gPlayExitCount(0)
void RouteOverlaySignal(void)
Performs overlay routing.
virtual bool GetStreamingApplication(ULWord &outAppType, int32_t &outProcessID)
Answers with the four-CC type and process ID of the application that currently "owns" the AJA device ...
virtual bool SetMixerFGMatteEnabled(const UWord inWhichMixer, const bool inIsEnabled)
Answers if the given mixer/keyer's foreground matte is enabled or not.
enum NTV2OutputCrosspointID NTV2OutputXptID
virtual bool WaitForInputVerticalInterrupt(const NTV2Channel inChannel=NTV2_CHANNEL1, UWord inRepeatCount=1)
Efficiently sleeps the calling thread/process until the next one or more field (interlaced video) or ...
This identifies the mode in which there are no VANC lines in the frame buffer.
bool SetVideoBuffer(ULWord *pInVideoBuffer, const ULWord inVideoByteCount)
Sets my video buffer for use in a subsequent call to CNTV2Card::AutoCirculateTransfer.
NTV2ReferenceSource NTV2InputSourceToReferenceSource(const NTV2InputSource inInputSource)
Converts a given NTV2InputSource to its equivalent NTV2ReferenceSource value.
static const uint32_t kAppSignature(((((uint32_t)( 'O'))<< 24)|(((uint32_t)( 'v'))<< 16)|(((uint32_t)( 'r'))<< 8)|(((uint32_t)( 'l'))<< 0)))
NTV2InputSource fInputSource
The device input connector to use.
void StartOutputThread(void)
Starts output thread.
virtual bool EnableChannel(const NTV2Channel inChannel)
Enables the given FrameStore.