13 #include <mach/mach_time.h> 14 #include <CoreServices/CoreServices.h> 15 static int64_t s_PerformanceFrequency;
16 static bool s_bPerformanceInit =
false;
20 #if defined(MSWindows) 21 static LARGE_INTEGER s_PerformanceFrequency;
22 static bool s_bPerformanceInit =
false;
25 #if defined(AJALinux) || defined(AJA_LINUX) 27 #if (_POSIX_TIMERS > 0) 28 #ifdef _POSIX_MONOTONIC_CLOCK 29 #define AJA_USE_CLOCK_GETTIME 31 #undef AJA_USE_CLOCK_GETTIME 35 #ifdef AJA_USE_CLOCK_GETTIME 49 memset(rxBuf,0,
sizeof(rxBuf));
62 int byte_len = (int)strlen((
char*)
txBuf);
63 int word_len = ((byte_len + 4) - (byte_len %4))/4;
85 uint32_t * pBuf =
txBuf;
86 for (
int i = 0; i < word_len; i++)
104 uint32_t * pBuf = (uint32_t*)rxBuf;
105 memset(rxBuf,0,
sizeof(rxBuf));
126 if (seqNum == currentSeqNum())
152 for (uint32_t i=0; i<count; i++)
187 while (SOM != 0xffffffff)
189 bool rv =
readMB(SOM,timeout);
209 if (getElapsedTime() > timeout)
222 if (getElapsedTime() > timeout)
253 chanOffset = channelOffset;
254 chanNumber = channelNumber;
303 response.assign((
char*)rxBuf);
306 void CNTV2MailBox::startTimer()
308 _startTime = getSystemMilliseconds();
311 uint64_t CNTV2MailBox::getElapsedTime()
313 return (getSystemMilliseconds() - _startTime);
316 int64_t CNTV2MailBox::getSystemCounter()
318 #if defined(MSWindows) 319 LARGE_INTEGER performanceCounter;
321 performanceCounter.QuadPart = 0;
322 if (!QueryPerformanceCounter(&performanceCounter))
327 return (int64_t)performanceCounter.QuadPart;
331 return (int64_t) mach_absolute_time();
334 #if defined(AJALinux) || defined(AJA_LINUX) 335 #ifdef AJA_USE_CLOCK_GETTIME 338 return (ts.tv_sec * ((int64_t)1000000)) + (ts.tv_nsec / (int64_t)1000);
343 gettimeofday( &tv, &tz );
344 return (int64_t)((int64_t)tv.tv_sec * (int64_t)1000000 + tv.tv_usec);
350 int64_t CNTV2MailBox::getSystemFrequency()
352 #if defined(MSWindows) 353 if (!s_bPerformanceInit)
355 QueryPerformanceFrequency(&s_PerformanceFrequency);
356 s_bPerformanceInit =
true;
359 return (int64_t)s_PerformanceFrequency.QuadPart;
363 if (!s_bPerformanceInit)
366 static mach_timebase_info_data_t sTimebaseInfo;
367 uint64_t ticks = 1000000000;
369 if ( sTimebaseInfo.denom == 0 )
371 (
void) mach_timebase_info(&sTimebaseInfo);
376 int64_t nanoSeconds = ticks * sTimebaseInfo.numer / sTimebaseInfo.denom;
379 s_PerformanceFrequency = ticks * 1000000000 / nanoSeconds;
380 s_bPerformanceInit =
true;
383 return s_PerformanceFrequency;
386 #if defined(AJALinux) || defined(AJA_LINUX) 391 uint64_t CNTV2MailBox::getSystemMilliseconds()
393 uint64_t ticks = getSystemCounter();
394 uint64_t ticksPerSecond = getSystemFrequency();
400 ms = uint64_t((
double(ticks) /
double(ticksPerSecond)) * 1000.);
Everything needed to call CNTV2Card::ReadRegister or CNTV2Card::WriteRegister functions.
std::string NTV2IpErrorEnumToString(const NTV2IpError inIpErrorEnumValue)
virtual bool AcquireMailBoxLock(void)
virtual bool BankSelectReadRegister(const NTV2RegInfo &inBankSelect, NTV2RegInfo &inOutRegInfo)
Reads the given set of registers from the bank specified in position 0.
bool rcvMsg(uint32_t timeout)
I interrogate and control an AJA video/audio capture/playout device.
virtual bool ReleaseMailBoxLock(void)
bool WriteChannelRegister(ULWord reg, ULWord value, ULWord mask=0xFFFFFFFF, ULWord shift=0x0)
void getError(std::string &error)
bool waitRxReady(uint32_t timeout)
ULWord registerValue
My register value to use in a ReadRegister or WriteRegister call.
void getResponse(std::string &response)
bool waitSOM(uint32_t timeout)
std::string mIpInternalErrorString
bool waitTxReady(uint32_t timeout)
bool sendMsg(char *msg, uint32_t timeout)
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...
Declares the CNTV2MailBox class.
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 ...
Declares numerous NTV2 utility functions.
virtual bool WriteRegister(const ULWord inRegNum, const ULWord inValue, const ULWord inMask=0xFFFFFFFF, const ULWord inShift=0)
Updates or replaces all or part of the 32-bit contents of a specific register (real or virtual) on th...
virtual bool BankSelectWriteRegister(const NTV2RegInfo &inBankSelect, const NTV2RegInfo &inRegInfo)
Writes the given set of registers to the bank specified at position 0.
CNTV2MailBox(CNTV2Card &device)
bool writeMB(uint32_t val, uint32_t timeout=50)
bool ReadChannelRegister(const ULWord inReg, ULWord &outValue, const ULWord inMask=0xFFFFFFFF, const ULWord inShift=0x0)
bool readMB(uint32_t &val, uint32_t timeout=50)
void SetChannel(ULWord channelOffset, ULWord channelNumber)