4#if QT_VERSION >= QT_VERSION_CHECK(6,5,0)
5#include <QtSystemDetection>
12#include <sys/select.h>
32#include <dveo/master.h>
34#define LOC QString("ASISH[%1](%2): ").arg(m_inputId).arg(m_device)
45 const QString& devkey = devname;
47 QMap<QString,ASIStreamHandler*>::iterator it =
s_handlers.find(devkey);
56 LOG(VB_RECORD, LOG_INFO,
57 QString(
"ASISH[%1]: Creating new stream handler %2 for %3")
58 .arg(QString::number(inputid), devkey, devname));
64 LOG(VB_RECORD, LOG_INFO,
65 QString(
"ASISH[%1]: Using existing stream handler %2 for %3")
66 .arg(QString::number(inputid), devkey, devname) +
67 QString(
" (%1 in use)").arg(rcount));
83 QMap<QString,ASIStreamHandler*>::iterator it =
s_handlers.find(devname);
94 LOG(VB_RECORD, LOG_INFO, QString(
"ASISH[%1]: Closing handler for %2")
95 .arg(inputid).arg(devname));
102 LOG(VB_GENERAL, LOG_ERR,
103 QString(
"ASISH[%1] Error: Couldn't find handler for %2")
104 .arg(inputid).arg(devname));
142 LOG(VB_RECORD, LOG_INFO,
LOC +
"run(): begin");
146 LOG(VB_GENERAL, LOG_ERR,
LOC + QString(
"Failed to open device %1 : %2")
157 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Failed to allocate DRB buffer");
167 auto *buffer =
new unsigned char[buffer_size];
170 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Failed to allocate buffer");
178 memset(buffer, 0, buffer_size);
197 &(buffer[remainder]), buffer_size - remainder);
203 if (drb->IsErrored())
205 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Device error detected");
211 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Device EOF detected");
237 remainder = sit.key()->ProcessData(buffer, len);
243 if (remainder > 0 && (len > remainder))
244 memmove(buffer, &(buffer[len - remainder]), remainder);
246 LOG(VB_RECORD, LOG_INFO,
LOC +
"run(): " +
"shutdown");
255 if (drb->IsRunning())
262 LOG(VB_RECORD, LOG_INFO,
LOC +
"run(): " +
"end");
297 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Failed to set RX Mode: " +
error);
302 m_fd = open(
m_device.toLocal8Bit().constData(), O_RDONLY, 0);
305 LOG(VB_GENERAL, LOG_ERR,
LOC +
306 QString(
"Failed to open '%1'").arg(
m_device) +
ENO);
311 unsigned int cap = 0;
312 if (ioctl(
m_fd, ASI_IOC_RXGETCAP, &cap) < 0)
314 LOG(VB_GENERAL, LOG_ERR,
LOC +
315 QString(
"Failed to query capabilities '%1'").arg(
m_device) +
ENO);
355 if(ioctl(fd, ASI_IOC_RXGETEVENTS, &val) < 0)
357 LOG(VB_GENERAL, LOG_ERR,
LOC + QString(
"Failed to open device %1: ")
362 if(val & ASI_EVENT_RX_BUFFER)
364 LOG(VB_RECORD, LOG_ERR,
LOC +
365 QString(
"Driver receive buffer queue overrun detected %1")
368 if(val & ASI_EVENT_RX_FIFO)
370 LOG(VB_RECORD, LOG_ERR,
LOC +
371 QString(
"Driver receive FIFO overrun detected %1")
374 if(val & ASI_EVENT_RX_CARRIER)
376 LOG(VB_RECORD, LOG_NOTICE,
LOC +
377 QString(
"Carrier Status change detected %1")
380 if(val & ASI_EVENT_RX_LOS)
382 LOG(VB_RECORD, LOG_ERR,
LOC +
383 QString(
"Loss of Packet Sync detected %1")
386 if(val & ASI_EVENT_RX_AOS)
388 LOG(VB_RECORD, LOG_NOTICE,
LOC +
389 QString(
"Acquisition of Sync detected %1")
392 if(val & ASI_EVENT_RX_DATA)
394 LOG(VB_RECORD, LOG_NOTICE,
LOC +
395 QString(
"Receive data status change detected %1")
@ kASIRXSyncOnActualConvertTo188
@ kASIRXSyncOn204ConvertTo188
static ASIStreamHandler * Get(const QString &devname, int inputid)
static QMutex s_handlersLock
static QMap< QString, ASIStreamHandler * > s_handlers
ASIClockSource m_clockSource
void SetRunningDesired(bool desired) override
At minimum this sets _running_desired, this may also send signals to anything that might be blocking ...
void run(void) override
Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.
ASIStreamHandler(const QString &device, int inputid)
void SetRXMode(ASIRXMode m)
void PriorityEvent(int fd) override
void SetClockSource(ASIClockSource cs)
static void Return(ASIStreamHandler *&ref, int inputid)
static QMap< QString, uint > s_handlersRefCnt
static int GetASIDeviceNumber(const QString &device, QString *error=nullptr)
static uint GetASINumBuffers(uint device_num, QString *error=nullptr)
static uint GetASIBufferSize(uint device_num, QString *error=nullptr)
static bool SetASIMode(uint device_num, uint mode, QString *error=nullptr)
Buffers reads from device files.
void RunProlog(void)
Sets up a thread, call this if you reimplement run().
void RunEpilog(void)
Cleans up a thread's resources, call this if you reimplement run().
void setObjectName(const QString &name)
StreamDataList m_streamDataList
void WriteMPTS(const unsigned char *buffer, uint len)
Write out a copy of the raw MPTS.
virtual void SetRunningDesired(bool desired)
At minimum this sets _running_desired, this may also send signals to anything that might be blocking ...
volatile bool m_runningDesired
bool RemoveAllPIDFilters(void)
void SetRunning(bool running, bool using_buffering, bool using_section_reader)
bool UpdateFiltersFromStreamData(void)
QRecursiveMutex m_listenerLock
static constexpr unsigned int kDVBEmissionSize
static constexpr unsigned int kSize
#define ENO
This can be appended to the LOG args with "+".
#define LOG(_MASK_, _LEVEL_, _QSTRING_)