19 #define TCFAIL(_expr_) AJA_sERROR (AJA_DebugUnit_TimecodeGeneric, AJAFUNC << ": " << _expr_) 20 #define TCWARN(_expr_) AJA_sWARNING(AJA_DebugUnit_TimecodeGeneric, AJAFUNC << ": " << _expr_) 21 #define TCNOTE(_expr_) AJA_sNOTICE (AJA_DebugUnit_TimecodeGeneric, AJAFUNC << ": " << _expr_) 22 #define TCINFO(_expr_) AJA_sINFO (AJA_DebugUnit_TimecodeGeneric, AJAFUNC << ": " << _expr_) 23 #define TCDBG(_expr_) AJA_sDEBUG (AJA_DebugUnit_TimecodeGeneric, AJAFUNC << ": " << _expr_) 56 while (mProducerThread.
Active())
59 while (mConsumerThread.
Active())
93 <<
" -- only supports Ch1" << (maxNumChannels > 1 ? string(
"-Ch") + string(1,
char(maxNumChannels+
'0')) :
"") << endl;
129 {cerr <<
"## ERROR: RenderTimeCodeFont failed for: " << mFormatDesc << endl;
return AJA_STATUS_UNSUPPORTED;}
136 #endif // defined(_DEBUG) 148 { cerr <<
"## ERROR: '" << mDevice.
GetDisplayName() <<
"' doesn't support " 153 { cerr <<
"## ERROR: '" << mDevice.
GetDisplayName() <<
"' doesn't support " 162 {cerr <<
"## ERROR: No CSC for channel " <<
DEC(mConfig.
fOutputChannel+1) <<
" to convert RGB pixel format" << endl;
207 mHostBuffers.push_back(FrameData());
208 FrameData & frameData(mHostBuffers.back());
219 frameData.fDataReady =
false;
232 vector<NTV2TestPatternSelect> testPatIDs;
243 mTestPatRasters.clear();
244 for (
size_t tpNdx(0); tpNdx < testPatIDs.size(); tpNdx++)
253 for (
size_t tpNdx(0); tpNdx < testPatIDs.size(); tpNdx++)
257 {
PLFAIL(
"Test pattern buffer " <<
DEC(tpNdx+1) <<
" of " <<
DEC(testPatIDs.size()) <<
": " 264 if (!testPatternGen.
DrawTestPattern (testPatIDs.at(tpNdx), mFormatDesc, mTestPatRasters.at(tpNdx)))
266 cerr <<
"## ERROR: DrawTestPattern " <<
DEC(tpNdx) <<
" failed: " << mFormatDesc << endl;
282 UWord connectFailures (0);
288 if (!mDevice.
Connect (cscInputXpt, fsVidOutXpt, canVerify))
309 if (!mDevice.
Connect (cscInputXpt, fsVidOutXpt, canVerify))
336 PLWARN(
DEC(connectFailures) <<
" 'Connect' call(s) failed");
337 return connectFailures == 0;
361 mConsumerThread.
Start();
382 ULWord goodQueue(0), badQueue(0), goodRelease(0), badRelease(0), starves(0), noRoomWaits(0), status(0);
386 for (FrameDataArrayIter iterHost (mHostBuffers.begin()); iterHost != mHostBuffers.end(); ++iterHost)
387 if (iterHost->fVideoBuffer)
394 cerr <<
"## ERROR: Stream initialize failed: " << status << endl;
403 {cerr <<
"## ERROR: Stream status failed: " << status << endl;
return;}
407 FrameData * pFrameData (&mHostBuffers[mConsumerIndex]);
408 if (pFrameData->fDataReady)
420 cerr <<
"## ERROR: Stream buffer add failed: " << status << endl;
428 {cerr <<
"## ERROR: Stream stop failed: " << status << endl;
return;}
432 while (!strStatus.
IsIdle())
436 for (
int i = 0; i < 30; i++)
442 {cerr <<
"## ERROR: Stream start failed: " << status << endl;
return;}
476 {cerr <<
"## ERROR: Stream initialize failed: " << status << endl;
return;}
494 cerr <<
"## ERROR: Stream release failed: " << status << endl;
498 PLNOTE(
"Thread completed: " <<
DEC(goodQueue) <<
" queued, " <<
DEC(badQueue) <<
" failed, " 499 <<
DEC(starves) <<
" starves, " <<
DEC(noRoomWaits) <<
" waits, " 500 <<
DEC(goodRelease) <<
" releases (" <<
DEC(badRelease) <<
" failed)");
514 mProducerThread.
Start();
530 ULWord testPatNdx(0), badTally(0);
531 double timeOfLastSwitch (0.0);
544 FrameData * pFrameData (&mHostBuffers[mProducerIndex]);
545 if (pFrameData->fDataReady)
553 pFrameData->fVideoBuffer.CopyFrom (mTestPatRasters.at(testPatNdx),
556 ULWord(pFrameData->fVideoBuffer.GetByteCount()));
558 const CRP188 rp188Info (mCurrentFrame++, 0, 0, 10, tcFormat);
569 if (isPAL) tcF2.
fHi |=
BIT(27);
else tcF2.
fLo |=
BIT(27);
572 if (pFrameData->fVideoBuffer.GetHostAddress(0))
574 mTCBurner.
BurnTimeCode (pFrameData->fVideoBuffer.GetHostAddress(0), tcString.c_str(), 80);
576 TCDBG(
"F" <<
DEC0N(mCurrentFrame-1,6) <<
": " << tcF1 <<
": " << tcString);
580 if (currentTime > timeOfLastSwitch + 4.0)
582 testPatNdx = (testPatNdx + 1) %
ULWord(mTestPatRasters.size());
583 timeOfLastSwitch = currentTime;
584 PLINFO(
"F" <<
DEC0N(mCurrentFrame,6) <<
": " << tcString <<
"pattern='" << tpNames.at(testPatNdx) <<
"'");
588 pFrameData->fDataReady =
true;
592 PLNOTE(
"Thread completed: " <<
DEC(mCurrentFrame) <<
" frame(s) produced, " <<
DEC(badTally) <<
" failed");
NTV2FrameRate GetNTV2FrameRateFromVideoFormat(const NTV2VideoFormat inVideoFormat)
virtual ULWord StreamChannelInitialize(const NTV2Channel inChannel)
Initialize a stream. Put the stream queue and hardware in a known good state ready for use...
double FramesToSeconds(int64_t frames) const
virtual bool SetTaskMode(const NTV2TaskMode inMode)
Sets the device's task mode.
virtual ULWord StreamBufferQueue(const NTV2Channel inChannel, NTV2Buffer &inBuffer, ULWord64 bufferCookie, NTV2StreamBuffer &status)
Queue a buffer to the stream. The bufferCookie is a user defined identifier of the buffer used by the...
#define NTV2_IS_VALID_TASK_MODE(__m__)
virtual void ConsumeFrames(void)
My consumer thread that repeatedly plays frames using AutoCirculate (until quit). ...
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...
The NTV2 test pattern generator.
virtual void Quit(void)
Gracefully stops me from running.
#define DEC0N(__x__, __n__)
I play out SD or HD test pattern (with timecode) to an output of an AJA device with or without audio ...
virtual ULWord StreamChannelRelease(const NTV2Channel inChannel)
Release a stream. Releases all buffers remaining in the queue.
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.
virtual void StartConsumerThread(void)
Starts my consumer thread.
virtual bool IsDeviceReady(const bool inCheckValid=(0))
virtual bool DisableChannel(const NTV2Channel inChannel)
Disables the given FrameStore.
#define AJA_FAILURE(_status_)
virtual AJAStatus SetUpHostBuffers(void)
Sets up my host video & audio buffers.
Declares the NTV2TestPatternGen class.
static void ConsumerThreadStatic(AJAThread *pThread, void *pContext)
This is the consumer thread's static callback function that gets called when the consumer thread star...
virtual AJAStatus Run(void)
Runs me.
#define NTV2_VIDEO_FORMAT_HAS_PROGRESSIVE_PICTURE(__f__)
UWord GetNumHDMIVideoOutputs(void)
virtual AJAStatus SetPriority(AJAThreadPriority priority)
if(!(riid==IID_IUnknown) &&!(riid==IID_IClassFactory))
bool CanDoFrameStore1Display(void)
virtual bool RouteOutputSignal(void)
Performs all widget/signal routing for playout.
bool fDoABConversion
If true, do level-A/B conversion; otherwise don't.
bool IsIdle(void)
Is the stream idle.
virtual AJAStatus Start()
std::string fDeviceSpec
The AJA device to use.
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.
NTV2Channel
These enum values are mostly used to identify a specific widget_framestore. They're also commonly use...
virtual class DeviceCapabilities & features(void)
virtual bool SetMultiFormatMode(const bool inEnable)
Enables or disables multi-format (per channel) device operation. If enabled, each device channel can ...
virtual bool ClearRouting(void)
Removes all existing signal path connections between any and all widgets on the AJA device...
Declares the AJATimeBase class.
This struct replaces the old RP188_STRUCT.
virtual bool GetTaskMode(NTV2TaskMode &outMode)
Retrieves the device's current task mode.
static AJA_PixelFormat GetAJAPixelFormat(const NTV2PixelFormat inFormat)
NTV2FrameRate
Identifies a particular video frame rate.
virtual bool DrawTestPattern(const std::string &inTPName, const NTV2FormatDescriptor &inFormatDesc, NTV2Buffer &inBuffer)
Renders the given test pattern or color into a host raster buffer.
NTV2Standard
Identifies a particular video standard.
Playout (output) mode, which reads from device SDRAM.
virtual std::string GetDescription(void) const
virtual AJAStatus SetUpVideo(void)
Performs all video setup.
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...
static TimecodeFormat NTV2FrameRate2TimecodeFormat(const NTV2FrameRate inFrameRate)
#define NTV2_IS_PAL_VIDEO_FORMAT(__f__)
NTV2InputXptID GetOutputDestInputXpt(const NTV2OutputDestination inOutputDest, const bool inIsSDI_DS2=false, const UWord inHDMI_Quadrant=99)
virtual bool IsOpen(void) const
virtual ~NTV2StreamPlayer(void)
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.
bool HasBiDirectionalSDI(void)
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.
virtual std::string GetDisplayName(void)
Answers with this device's display name.
NTV2InputXptID GetCSCInputXptFromChannel(const NTV2Channel inCSC, const bool inIsKeyInput=false)
virtual ULWord StreamBufferRelease(const NTV2Channel inChannel, NTV2StreamBuffer &status)
Remove the oldest buffer released by the streaming engine from the buffer queue.
static const bool BUFFER_PAGE_ALIGNED((!(0)))
static void Sleep(const int32_t inMilliseconds)
Suspends execution of the current thread for a given number of milliseconds.
NTV2PixelFormat fPixelFormat
The pixel format to use.
2: OEM (recommended): device configured by client application(s) with some driver involvement...
virtual ULWord StreamChannelStart(const NTV2Channel inChannel, NTV2StreamChannel &status)
Start a stream. Put the stream is the active state to start processing queued buffers. For frame based video, the stream will start with the current buffer on the next frame sync.
NTV2VideoFormat fVideoFormat
The video format to use.
std::string NTV2VideoFormatToString(const NTV2VideoFormat inValue, const bool inUseFrameRate=false)
virtual bool SetVANCShiftMode(NTV2Channel inChannel, NTV2VANCDataShiftMode inMode)
Enables or disables the "VANC Shift Mode" feature for the given channel.
AJA_EXPORT bool RenderTimeCodeFont(AJA_PixelFormat pixelFormat, uint32_t numPixels, uint32_t numLines)
Specifies the PTP source on SFP 1.
bool IsVideoFormatA(const NTV2VideoFormat format)
virtual ULWord StreamChannelStatus(const NTV2Channel inChannel, NTV2StreamChannel &status)
Get the current stream status.
Specifies channel or FrameStore 2 (or the 2nd item).
virtual AJAStatus Init(void)
Initializes me and prepares me to Run.
UWord GetNumFrameStores(void)
Declares the CNTV2DeviceScanner class.
bool CanDo3GLevelConversion(void)
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).
bool fDoMultiFormat
If true, enable device-sharing; otherwise take exclusive control of device.
static NTV2TestPatternNames getTestPatternNames(void)
bool IsRGBFormat(const NTV2FrameBufferFormat format)
virtual ULWord StreamChannelWait(const NTV2Channel inChannel, NTV2StreamChannel &status)
Wait for any stream event. Returns for any state or buffer change.
static void ProducerThreadStatic(AJAThread *pThread, void *pContext)
This is the producer thread's static callback function that gets called when the producer thread star...
virtual void GetStreamStatus(NTV2StreamChannel &outStatus)
Provides status information about my output (playout) process.
virtual void StartProducerThread(void)
Starts my producer thread.
NTV2StreamPlayer(const PlayerConfig &inConfig)
Constructs me using the given configuration settings.
NTV2Channel fOutputChannel
The device channel to use.
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))
virtual AJAStatus Attach(AJAThreadFunction *pThreadFunction, void *pUserContext)
virtual bool SetSDIOutLevelAtoLevelBConversion(const UWord inOutputSpigot, const bool inEnable)
Enables or disables 3G level A to 3G level B conversion at the SDI output widget (assuming the AJA de...
NTV2OutputXptID GetFrameStoreOutputXptFromChannel(const NTV2Channel inFrameStore, const bool inIsRGB=false, const bool inIs425=false)
Specifies channel or FrameStore 1 (or the first item).
bool CanDoFrameBufferFormat(const NTV2PixelFormat inPF)
#define xHEX0N(__x__, __n__)
UWord GetNumAnalogVideoOutputs(void)
virtual ULWord StreamChannelStop(const NTV2Channel inChannel, NTV2StreamChannel &status)
Stop a stream. Put the stream is the idle state. For frame based video, the stream will idle on the b...
static AJA_FrameRate GetAJAFrameRate(const NTV2FrameRate inFrameRate)
#define NTV2_STREAM_STATUS_SUCCESS
Used in NTV2Stream success.
bool CanDoStreamingDMA(void)
AJA_EXPORT bool BurnTimeCode(void *pBaseVideoAddress, const std::string &inTimeCodeStr, const uint32_t inYPercent)
enum NTV2InputCrosspointID NTV2InputXptID
NTV2Standard GetNTV2StandardFromVideoFormat(const NTV2VideoFormat inVideoFormat)
Configures an NTV2Player instance.
bool GetRP188Reg(RP188_STRUCT &outRP188) const
ULWord fLo
| BG 4 | Secs10 | BG 3 | Secs 1 | BG 2 | Frms10 | BG 1 | Frms 1 |
static size_t SetDefaultPageSize(void)
std::vector< std::string > NTV2StringList
bool CanDoVideoFormat(const NTV2VideoFormat inVF)
bool HasCrosspointConnectROM(void)
const char * NTV2FrameBufferFormatString(NTV2FrameBufferFormat fmt)
UWord GetNumVideoOutputs(void)
bool GetRP188Str(std::string &sRP188) const
bool WithVideo(void) const
virtual AJAStatus SetUpTestPatternBuffers(void)
Creates my test pattern buffers.
virtual bool SetSDIOutputStandard(const UWord inOutputSpigot, const NTV2Standard inValue)
Sets the SDI output spigot's video standard.
NTV2InputXptID GetSDIOutputInputXpt(const NTV2Channel inSDIOutput, const bool inIsDS2=false)
ULWord GetQueueDepth(void)
Gets the queue depth.
virtual bool SetVANCMode(const NTV2VANCMode inVancMode, const NTV2Channel inChannel=NTV2_CHANNEL1)
Sets the VANC mode for the given FrameStore.
ULWord fHi
| BG 8 | Hrs 10 | BG 7 | Hrs 1 | BG 6 | Mins10 | BG 5 | Mins 1 |
enum NTV2OutputCrosspointID NTV2OutputXptID
ULWord64 mBufferCookie
Buffer User cookie.
NTV2OutputXptID GetCSCOutputXptFromChannel(const NTV2Channel inCSC, const bool inIsKey=false, const bool inIsRGB=false)
bool CanDoMultiFormat(void)
This identifies the mode in which there are no VANC lines in the frame buffer.
virtual void ProduceFrames(void)
My producer thread that repeatedly produces video frames.
virtual bool EnableChannel(const NTV2Channel inChannel)
Enables the given FrameStore.