16#define LOC QString("SH[%1]: ").arg(m_inputId)
26 LOG(VB_GENERAL, LOG_ERR,
LOC +
27 "dtor & _stream_data_list not empty");
37 bool allow_section_reader,
39 const QString& output_file)
43 LOG(VB_RECORD, LOG_INFO,
LOC + QString(
"AddListener(0x%1) -- begin")
44 .arg((uint64_t)data,0,16));
47 LOG(VB_GENERAL, LOG_ERR,
LOC +
48 QString(
"AddListener(0x%1) -- null data")
49 .arg((uint64_t)data,0,16));
55 LOG(VB_RECORD, LOG_INFO,
LOC + QString(
"AddListener(0x%1) -- locked")
56 .arg((uint64_t)data,0,16));
77 LOG(VB_RECORD, LOG_INFO,
LOC + QString(
"AddListener(0x%1) -- end")
78 .arg((uint64_t)data,0,16));
85 LOG(VB_RECORD, LOG_INFO,
LOC + QString(
"RemoveListener(0x%1) -- begin")
86 .arg((uint64_t)data,0,16));
89 LOG(VB_GENERAL, LOG_ERR,
LOC +
90 QString(
"RemoveListener(0x%1) -- null data")
91 .arg((uint64_t)data,0,16));
97 LOG(VB_RECORD, LOG_INFO,
LOC + QString(
"RemoveListener(0x%1) -- locked")
98 .arg((uint64_t)data,0,16));
104 if (!(*it).isEmpty())
114 LOG(VB_RECORD, LOG_INFO,
LOC + QString(
"RemoveListener(0x%1) -- end")
115 .arg((uint64_t)data,0,16));
127 LOG(VB_RECORD, LOG_INFO,
LOC +
"Restarting StreamHandler");
151 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Start failed");
158 LOG(VB_RECORD, LOG_DEBUG,
LOC +
"Stopping");
161 LOG(VB_RECORD, LOG_DEBUG,
LOC +
"Stopped");
175 bool is_using_buffering,
176 bool is_using_section_reader)
194#ifdef DEBUG_PID_FILTERS
195 LOG(VB_RECORD, LOG_DEBUG,
LOC + QString(
"AddPIDFilter(0x%1)")
196 .arg(
info->m_pid, 0, 16));
211#ifdef DEBUG_PID_FILTERS
212 LOG(VB_RECORD, LOG_DEBUG,
LOC +
213 QString(
"RemovePIDFilter(0x%1)").arg(pid, 0, 16));
218 PIDInfoMap::iterator it =
m_pidInfo.find(pid);
245#ifdef DEBUG_PID_FILTERS
246 LOG(VB_RECORD, LOG_DEBUG,
LOC +
"RemoveAllPIDFilters()");
249 std::vector<int> del_pids;
251 del_pids.push_back(it.key());
254 for (
int & pid : del_pids)
266 std::vector<uint> add_eit;
267 std::vector<uint> del_eit;
273 for (
uint eit : del_eit)
275 uint_vec_t::iterator it2;
282 for (
uint eit : add_eit)
300 it.key()->GetPIDs(pids);
303 QMap<uint, PIDInfo*> add_pids;
304 std::vector<uint> del_pids;
310 for (
auto lit = pids.constBegin(); lit != pids.constEnd(); ++lit)
312 if ((*lit != 0U) && (!
m_pidInfo.contains(lit.key())))
322 bool in_pids = pids.contains(fit.key());
324 del_pids.push_back(fit.key());
330 for (
uint & pid : del_pids)
334 for (
auto & pid : add_pids)
351 tmp = std::max(
tmp, it.key()->GetPIDPriority(pid));
365#if !defined( _WIN32 )
369 QString fn = QString(
"%1.raw").arg(
file);
383 LOG(VB_RECORD, LOG_INFO,
LOC +
390 LOG(VB_GENERAL, LOG_ERR,
LOC +
391 QString(
"Failed to link '%1' to '%2'")
396 LOG(VB_RECORD, LOG_INFO,
LOC +
397 QString(
"linked '%1' to '%2'")
407#if !defined( _WIN32 )
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...
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_)