11#if QT_VERSION >= QT_VERSION_CHECK(6,5,0)
12#include <QtSystemDetection>
22#define LOC QString("SH[%1]: ").arg(m_inputId)
32 LOG(VB_GENERAL, LOG_ERR,
LOC +
33 "dtor & _stream_data_list not empty");
43 bool allow_section_reader,
45 const QString& output_file)
49 LOG(VB_RECORD, LOG_INFO,
LOC + QString(
"AddListener(0x%1) -- begin")
50 .arg((uint64_t)data,0,16));
53 LOG(VB_GENERAL, LOG_ERR,
LOC +
54 QString(
"AddListener(0x%1) -- null data")
55 .arg((uint64_t)data,0,16));
61 LOG(VB_RECORD, LOG_INFO,
LOC + QString(
"AddListener(0x%1) -- locked")
62 .arg((uint64_t)data,0,16));
83 LOG(VB_RECORD, LOG_INFO,
LOC + QString(
"AddListener(0x%1) -- end")
84 .arg((uint64_t)data,0,16));
91 LOG(VB_RECORD, LOG_INFO,
LOC + QString(
"RemoveListener(0x%1) -- begin")
92 .arg((uint64_t)data,0,16));
95 LOG(VB_GENERAL, LOG_ERR,
LOC +
96 QString(
"RemoveListener(0x%1) -- null data")
97 .arg((uint64_t)data,0,16));
103 LOG(VB_RECORD, LOG_INFO,
LOC + QString(
"RemoveListener(0x%1) -- locked")
104 .arg((uint64_t)data,0,16));
110 if (!(*it).isEmpty())
120 LOG(VB_RECORD, LOG_INFO,
LOC + QString(
"RemoveListener(0x%1) -- end")
121 .arg((uint64_t)data,0,16));
133 LOG(VB_RECORD, LOG_INFO,
LOC +
"Restarting StreamHandler");
157 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Start failed");
164 LOG(VB_RECORD, LOG_DEBUG,
LOC +
"Stopping");
167 LOG(VB_RECORD, LOG_DEBUG,
LOC +
"Stopped");
181 bool is_using_buffering,
182 bool is_using_section_reader)
200#ifdef DEBUG_PID_FILTERS
201 LOG(VB_RECORD, LOG_DEBUG,
LOC + QString(
"AddPIDFilter(0x%1)")
202 .arg(
info->m_pid, 0, 16));
217#ifdef DEBUG_PID_FILTERS
218 LOG(VB_RECORD, LOG_DEBUG,
LOC +
219 QString(
"RemovePIDFilter(0x%1)").arg(pid, 0, 16));
224 PIDInfoMap::iterator it =
m_pidInfo.find(pid);
251#ifdef DEBUG_PID_FILTERS
252 LOG(VB_RECORD, LOG_DEBUG,
LOC +
"RemoveAllPIDFilters()");
255 std::vector<int> del_pids;
257 del_pids.push_back(it.key());
260 for (
int & pid : del_pids)
272 std::vector<uint> add_eit;
273 std::vector<uint> del_eit;
279 for (
uint eit : del_eit)
281 uint_vec_t::iterator it2;
288 for (
uint eit : add_eit)
306 it.key()->GetPIDs(pids);
309 QMap<uint, PIDInfo*> add_pids;
310 std::vector<uint> del_pids;
316 for (
auto lit = pids.constBegin(); lit != pids.constEnd(); ++lit)
318 if ((*lit != 0U) && (!
m_pidInfo.contains(lit.key())))
328 bool in_pids = pids.contains(fit.key());
330 del_pids.push_back(fit.key());
336 for (
uint & pid : del_pids)
340 for (
auto & pid : add_pids)
357 tmp = std::max(tmp, it.key()->GetPIDPriority(pid));
375 QString fn = QString(
"%1.raw").arg(
file);
389 LOG(VB_RECORD, LOG_INFO,
LOC +
395 fn.toLocal8Bit().constData())
398 LOG(VB_GENERAL, LOG_ERR,
LOC +
399 QString(
"Failed to link '%1' to '%2'")
404 LOG(VB_RECORD, LOG_INFO,
LOC +
405 QString(
"linked '%1' to '%2'")
Encapsulates data about MPEG stream and emits events for each table.
virtual bool GetEITPIDChanges(const uint_vec_t &, uint_vec_t &, uint_vec_t &) const
virtual void RemoveListeningPID(uint pid)
virtual bool HasEITPIDChanges(const uint_vec_t &) const
virtual void AddListeningPID(uint pid, PIDPriority priority=kPIDPriorityNormal)
void start(QThread::Priority p=QThread::InheritPriority)
Tell MThread to start running the thread in the near future.
bool wait(std::chrono::milliseconds time=std::chrono::milliseconds::max())
Wait for the MThread to exit, with a maximum timeout.
void exit(int retcode=0)
Use this to exit from the thread if you are using a Qt event loop.
std::chrono::milliseconds elapsed(void)
Returns milliseconds elapsed since last start() or restart()
bool isRunning(void) const
Returns true if start() or restart() has been called at least once since construction and since any c...
virtual bool Close(const QString &)
QRecursiveMutex m_pidLock
bool AddPIDFilter(PIDInfo *info)
virtual bool AddNamedOutputFile(const QString &filename)
Called with _listener_lock locked just after adding new output file.
StreamDataList m_streamDataList
bool RemovePIDFilter(uint pid)
void WriteMPTS(const unsigned char *buffer, uint len)
Write out a copy of the raw MPTS.
virtual void RemoveNamedOutputFile(const QString &filename)
Called with _listener_lock locked just before removing old output file.
virtual void CycleFiltersByPriority()
virtual void SetRunningDesired(bool desired)
At minimum this sets _running_desired, this may also send signals to anything that might be blocking ...
void UpdateListeningForEIT(void)
ThreadedFileWriter * m_mptsTfw
volatile bool m_runningDesired
bool RemoveAllPIDFilters(void)
void SetRunning(bool running, bool using_buffering, bool using_section_reader)
bool m_usingSectionReader
bool UpdateFiltersFromStreamData(void)
bool IsRunning(void) const
std::vector< uint > m_eitPids
PIDPriority GetPIDPriority(uint pid) const
QSet< QString > m_mptsFiles
~StreamHandler() override
QWaitCondition m_runningStateChanged
virtual void RemoveListener(MPEGStreamData *data)
virtual void AddListener(MPEGStreamData *data, bool allow_section_reader=false, bool needs_buffering=false, const QString &output_file=QString())
bool m_allowSectionReader
virtual bool UpdateFilters(void)
virtual PIDInfo * CreatePIDInfo(uint pid, uint stream_type, int pes_type)
QRecursiveMutex m_listenerLock
@ PrivSec
ISO 13818-1 private tables & ITU H.222.0.
This class supports the writing of recordings to disk.
bool Open(void)
Opens the file we will be writing to.
int Write(const void *data, uint count)
Writes data to the end of the write buffer.
static pid_list_t::iterator find(const PIDInfoMap &map, pid_list_t &list, pid_list_t::iterator begin, pid_list_t::iterator end, bool find_open)
QMap< uint, PIDPriority > pid_map_t
#define ENO
This can be appended to the LOG args with "+".
#define LOG(_MASK_, _LEVEL_, _QSTRING_)