20 #define NTV2_BUFFER_LOCK 57 while (mConsumerThread.
Active())
60 while (mProducerThread.
Active())
91 { cerr <<
"## ERROR: '" << mDevice.
GetDisplayName() <<
"' doesn't support '" 105 cerr <<
"## ERROR: Unable to acquire '" << mDevice.
GetDisplayName() <<
"' because another app (pid " <<
appPID <<
") owns it" << endl;
151 cerr <<
"Device Description: " << mDevice.
GetDescription() << endl;
153 #endif // defined(_DEBUG) 180 {cerr <<
"## ERROR: No input signal or unknown format" << endl;
return AJA_STATUS_NOINPUT;}
189 <<
" input signal -- try 'ntv2capture4k' or 'ntv2capture8k' demo" << endl;
230 ULWord F1AncSize(0), F2AncSize(0);
233 ULWord F1OffsetFromEnd(0), F2OffsetFromEnd(0);
237 F1AncSize = F2OffsetFromEnd > F1OffsetFromEnd ? 0 : F1OffsetFromEnd - F2OffsetFromEnd;
238 F2AncSize = F2OffsetFromEnd > F1OffsetFromEnd ? F2OffsetFromEnd - F1OffsetFromEnd : F2OffsetFromEnd;
250 frameData.fAncBuffer.Allocate(F1AncSize);
251 frameData.fAncBuffer2.Allocate(F2AncSize);
252 mAVCircularBuffer.
Add(&frameData);
254 #ifdef NTV2_BUFFER_LOCK 256 if (frameData.fVideoBuffer)
258 if (frameData.fAudioBuffer)
260 if (frameData.fAncBuffer)
301 mConsumerThread.
Start();
313 NTV2Capture * pApp (reinterpret_cast<NTV2Capture*>(pContext));
323 uint64_t ancTally(0);
336 if (pOFS && !ancTally++)
338 <<
DEC(pFrameData->AncBufferSize() + pFrameData->AncBuffer2Size())
339 <<
" bytes per frame" << endl;
340 if (pOFS && pFrameData->AncBuffer())
341 pOFS->write(pFrameData->AncBuffer(), streamsize(pFrameData->AncBufferSize()));
342 if (pOFS && pFrameData->AncBuffer2())
343 pOFS->write(pFrameData->AncBuffer2(), streamsize(pFrameData->AncBuffer2Size()));
350 {
delete pOFS; cerr <<
"Wrote " <<
DEC(ancTally) <<
" frames of raw anc data" << endl;}
352 CAPNOTE(
"Thread completed, will exit");
365 mProducerThread.
Start();
377 NTV2Capture * pApp (reinterpret_cast<NTV2Capture*>(pContext));
433 {
bool overrun(
false);
436 {overruns++;
CAPWARN(overruns <<
" anc overrun(s)");}
440 stale.
Fill(uint8_t(0));
447 stale.
Fill(uint8_t(0));
458 set_difference (oldNonPcmPairs.begin(), oldNonPcmPairs.end(), nonPcmPairs.begin(), nonPcmPairs.end(), inserter(becomingPCM, becomingPCM.begin()));
459 set_difference (nonPcmPairs.begin(), nonPcmPairs.end(), oldNonPcmPairs.begin(), oldNonPcmPairs.end(), inserter(becomingNonPCM, becomingNonPCM.begin()));
460 if (!becomingNonPCM.empty())
461 CAPNOTE(
"Audio channel pair(s) '" << becomingNonPCM <<
"' now non-PCM");
462 if (!becomingPCM.empty())
463 CAPNOTE(
"Audio channel pair(s) '" << becomingPCM <<
"' now PCM");
464 oldNonPcmPairs = nonPcmPairs;
494 CAPNOTE(
"Thread completed, will exit");
NTV2Channel NTV2InputSourceToChannel(const NTV2InputSource inInputSource)
Converts a given NTV2InputSource to its equivalent NTV2Channel value.
Anc Field2 byte offset from end of frame buffer (GUMP on all boards except RTP for SMPTE2022/IP) ...
virtual bool SetTaskMode(const NTV2TaskMode inMode)
Sets the device's task mode.
Instances of me capture frames in real time from a video signal provided to an input of an AJA device...
Specifies SDI input/output kinds.
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...
Specifies the device's internal clock.
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...
bool WithCustomAnc(void) const
AJAStatus Add(FrameDataPtr pInFrameData)
Appends a new frame buffer to me, increasing my frame storage capacity by one frame.
Declares the NTV2Capture class.
ULWord AncBuffer2Size(void) const
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.
ULWord VideoBufferSize(void) const
bool fDoMultiFormat
If true, use multi-format/multi-channel mode, if device supports it; otherwise normal mode...
ULWord GetCapturedAudioByteCount(void) const
virtual bool IsDeviceReady(const bool inCheckValid=(0))
ULWord AudioBufferSize(void) const
ULWord GetBufferLevel(void) const
virtual AJAStatus SetupVideo(void)
Sets up everything I need for capturing video.
#define AJA_FAILURE(_status_)
bool CanDoSDIErrorChecks(void)
NTV2InputSource NTV2ChannelToInputSource(const NTV2Channel inChannel, const NTV2IOKinds inKinds=NTV2_IOKINDS_SDI)
ULWord GetByteCount(void) const
bool WithAudio(void) const
#define NTV2_IS_4K_VIDEO_FORMAT(__f__)
NTV2AudioSystemSet NTV2MakeAudioSystemSet(const NTV2AudioSystem inFirstAudioSystem, const UWord inCount=1)
virtual AJAStatus SetPriority(AJAThreadPriority priority)
Specifies HDMI input/output kinds.
virtual bool GetInputAudioChannelPairsWithoutPCM(const NTV2Channel inSDIInputConnector, NTV2AudioChannelPairs &outChannelPairs)
For the given SDI input (specified as a channel number), returns the set of audio channel pairs that ...
FrameDataPtr StartConsumeNextBuffer(void)
The thread that's responsible for processing incoming frames – the consumer – calls this function t...
bool fWithAnc
If true, also capture Anc.
virtual AJAStatus SetupAudio(void)
Sets up everything I need for capturing audio.
ULWord fNumAudioBytes
Actual number of captured audio bytes.
virtual AJAStatus Start()
virtual bool EnableInputInterrupt(const NTV2Channel channel=NTV2_CHANNEL1)
Allows the CNTV2Card instance to wait for and respond to input vertical blanking interrupts originati...
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 class DeviceCapabilities & features(void)
bool CanDoInputSource(const NTV2InputSource inSrc)
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.
std::set< NTV2AudioChannelPair > NTV2AudioChannelPairs
A set of distinct NTV2AudioChannelPair values.
bool CanDoCustomAnc(void)
virtual AJAStatus Run(void)
Runs me.
ULWord GetProcessedFrameCount(void) const
bool fWithAudio
If true, also capture Audio.
virtual bool RouteInputSignal(void)
Sets up device routing for capture.
virtual void GetACStatus(ULWord &outGoodFrames, ULWord &outDroppedFrames, ULWord &outBufferLevel)
Provides status information about my input (capture) process.
Anc Field1 byte offset from end of frame buffer (GUMP on all boards except RTP for SMPTE2022/IP) ...
#define NTV2_AUDIOSIZE_MAX
NTV2Channel fInputChannel
The device channel to use.
UWord GetNumAudioSystems(void)
virtual bool IsRemote(void) const
static void ConsumerThreadStatic(AJAThread *pThread, void *pContext)
This is the consumer thread's static callback function that gets called when the consumer thread runs...
bool Fill(const T &inValue)
Fills me with the given scalar value.
virtual bool GetTaskMode(NTV2TaskMode &outMode)
Retrieves the device's current task mode.
#define AJA_NTV2_AUDIO_RECORD_END
std::string NTV2InputSourceToString(const NTV2InputSource inValue, const bool inForRetailDisplay=false)
0: Disabled (never recommended): device configured exclusively by client application(s).
virtual void CaptureFrames(void)
Repeatedly captures frames using AutoCirculate (until global quit flag set).
virtual std::string GetDescription(void) const
std::string fAncDataFilePath
Optional path to Anc binary data file.
This class is used to configure an NTV2Capture instance.
ULWord AncBufferSize(void) const
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.
virtual void StartProducerThread(void)
Starts my capture thread.
bool HasBiDirectionalSDI(void)
#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 ...
virtual bool DMABufferLock(const NTV2Buffer &inBuffer, bool inMap=(0), bool inRDMA=(0))
Page-locks the given host buffer to reduce transfer time and CPU usage of DMA transfers.
NTV2Buffer & AncBuffer2(void)
NTV2LHIHDMIColorSpace inputColorSpace(NTV2_LHIHDMIColorSpaceYCbCr)
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...
virtual std::string GetDisplayName(void)
Answers with this device's display name.
NTV2Buffer & AncBuffer(void)
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.
2: OEM (recommended): device configured by client application(s) with some driver involvement...
virtual bool ApplySignalRoute(const CNTV2SignalRouter &inRouter, const bool inReplace=(0))
Applies the given routing table to the AJA device.
ULWord GetIndexForNTV2InputSource(const NTV2InputSource inValue)
NTV2XptConnections connections
std::set< NTV2AudioSystem > NTV2AudioSystemSet
A set of distinct NTV2AudioSystem values. New in SDK 16.2.
std::string NTV2VideoFormatToString(const NTV2VideoFormat inValue, const bool inUseFrameRate=false)
NTV2Buffer & VideoBuffer(void)
ULWord GetDroppedFrameCount(void) const
NTV2Buffer fAncBuffer
Host ancillary data buffer.
#define AUTOCIRCULATE_WITH_ANC
Use this to AutoCirculate with ancillary data.
virtual NTV2DeviceID GetDeviceID(void)
ULWord fNumAnc2Bytes
Actual number of captured F2 anc bytes.
virtual void Quit(void)
Gracefully stops me from running.
Declares the CNTV2DeviceScanner class.
NTV2Buffer fAncBuffer2
Additional "F2" host anc buffer.
virtual bool ReadRegister(const ULWord inRegNum, ULWord &outValue, const ULWord inMask=0xFFFFFFFF, const ULWord inShift=0)
Reads all or part of the 32-bit contents of a specific register (real or virtual) on the AJA device...
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...
#define NTV2_IS_VALID_CHANNEL(__x__)
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 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...
ULWord fNumAncBytes
Actual number of captured F1 anc bytes.
NTV2Buffer & AudioBuffer(void)
This object specifies the information that will be transferred to or from the AJA device in the CNTV2...
bool GetSDIInputStatus(NTV2SDIInputStatus &outStatus, const UWord inSDIInputIndex0=0)
Answers with the NTV2SDIInputStatus for the given SDI input spigot.
NTV2InputSource fInputSource
The device input connector to use.
virtual void ConsumeFrames(void)
Repeatedly consumes frames from the circular buffer (until global quit flag set). ...
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 void SetupHostBuffers(void)
Sets up my circular buffers.
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 ...
#define NTV2_IS_VALID_INPUT_SOURCE(_inpSrc_)
static const size_t CIRCULAR_BUFFER_SIZE(10)
Number of NTV2FrameData's in our ring.
static const ULWord kDemoAppSignature((((uint32_t)( 'D'))<< 24)|(((uint32_t)( 'E'))<< 16)|(((uint32_t)( 'M'))<< 8)|(((uint32_t)( 'O'))<< 0))
Declares numerous NTV2 utility functions.
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 GetInputTimeCodes(NTV2TimeCodeList &outValues) const
Intended for capture, answers with the timecodes captured in my acTransferStatus member's acFrameStam...
static void ProducerThreadStatic(AJAThread *pThread, void *pContext)
This is the capture thread's static callback function that gets called when the capture thread runs...
#define NTV2_IS_QUAD_QUAD_FORMAT(__f__)
This is returned from the CNTV2Card::AutoCirculateGetStatus function.
virtual bool AncExtractGetBufferOverrun(const UWord inSDIInput, bool &outIsOverrun, const UWord inField=0)
Answers whether or not the given SDI input's Anc extractor reached its buffer limits. (Call NTV2DeviceCanDoCustomAnc to determine if the device supports Anc extractor firmware.)
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...
bool CanDoFrameBufferFormat(const NTV2PixelFormat inPF)
virtual bool SubscribeOutputVerticalEvent(const NTV2Channel inChannel)
Causes me to be notified when an output vertical blanking interrupt is generated for the given output...
NTV2ACFrameRange fFrames
AutoCirculate frame count or range.
NTV2PixelFormat fPixelFormat
Pixel format to use.
static bool GetInputRouting(NTV2XptConnections &outConnections, const CaptureConfig &inConfig, const bool isInputRGB=(0))
Answers with the crosspoint connections needed to implement the given capture configuration.
#define NTV2_IS_VALID_AUDIO_SYSTEM(__x__)
bool SetAncBuffers(ULWord *pInANCBuffer, const ULWord inANCByteCount, ULWord *pInANCF2Buffer=NULL, const ULWord inANCF2ByteCount=0)
Sets my ancillary data buffers for use in a subsequent call to CNTV2Card::AutoCirculateTransfer.
std::string NTV2FrameBufferFormatToString(const NTV2FrameBufferFormat inValue, const bool inForRetailDisplay=false)
I encapsulate the video, audio and anc host buffers used in the AutoCirculate demos. I'm a more modern version of the AVDataBuffer.
virtual void StartConsumerThread(void)
Starts my frame consumer thread.
NTV2Buffer fVideoBuffer
Host video buffer.
NTV2AudioSystem NTV2ChannelToAudioSystem(const NTV2Channel inChannel)
Converts the given NTV2Channel value into its equivalent NTV2AudioSystem.
bool HasAvailableInputFrame(void) const
static bool ConfigureAudioSystems(CNTV2Card &inDevice, const CaptureConfig &inConfig, const NTV2AudioSystemSet inAudioSystems)
Configures capture audio systems.
bool IsRunning(void) const
virtual AJAStatus Init(void)
Initializes me and prepares me to Run.
std::string fDeviceSpec
The AJA device to use.
UWord GetNumHDMIVideoInputs(void)
std::map< NTV2InputXptID, NTV2OutputXptID > NTV2XptConnections
This is used by the CNTV2Card::ReadSDIStatistics function.
#define AJA_NTV2_AUDIO_RECORD_DO
ULWord GetCapturedAncByteCount(const bool inField2=false) const
bool CanDoVideoFormat(const NTV2VideoFormat inVF)
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 ...
#define AUTOCIRCULATE_WITH_RP188
Use this to AutoCirculate with RP188.
#define NTV2_INPUT_SOURCE_IS_SDI(_inpSrc_)
void * GetHostAddress(const ULWord inByteOffset, const bool inFromEnd=false) const
bool SetAudioBuffer(ULWord *pInAudioBuffer, const ULWord inAudioByteCount)
Sets my audio buffer for use in a subsequent call to CNTV2Card::AutoCirculateTransfer.
NTV2Capture(const CaptureConfig &inConfig)
Constructs me using the given settings.
virtual bool SetVANCMode(const NTV2VANCMode inVancMode, const NTV2Channel inChannel=NTV2_CHANNEL1)
Sets the VANC mode for the given FrameStore.
#define AJA_NTV2_AUDIO_RECORD_BEGIN
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 ...
NTV2TimeCodes fTimecodes
Map of TC indexes to NTV2_RP188 values.
Declares device capability functions.
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 ...
bool CanDoMultiFormat(void)
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.
virtual bool ReadSDIStatistics(NTV2SDIInStatistics &outStats)
For devices that support it (see the NTV2DeviceCanDoSDIErrorChecks function in "ntv2devicefeatures.h"), this function fetches the SDI statistics for all SDI input spigots.
virtual bool EnableChannel(const NTV2Channel inChannel)
Enables the given FrameStore.