Go to the documentation of this file.
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));
197 #endif // DEBUG_PID_FILTERS
211 #ifdef DEBUG_PID_FILTERS
212 LOG(VB_RECORD, LOG_DEBUG,
LOC +
213 QString(
"RemovePIDFilter(0x%1)").arg(pid, 0, 16));
214 #endif // DEBUG_PID_FILTERS
218 PIDInfoMap::iterator it =
m_pidInfo.find(pid);
245 #ifdef DEBUG_PID_FILTERS
246 LOG(VB_RECORD, LOG_DEBUG,
LOC +
"RemoveAllPIDFilters()");
247 #endif // DEBUG_PID_FILTERS
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)
322 bool in_pids = pids.find(fit.key()) != pids.end();
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( USING_MINGW ) && !defined( _MSC_VER )
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'")
401 #endif // !defined( USING_MINGW ) && !defined( _MSC_VER )
407 #if !defined( USING_MINGW ) && !defined( _MSC_VER )
420 #endif // !defined( USING_MINGW ) && !defined( _MSC_VER )
std::chrono::milliseconds elapsed(void)
Returns milliseconds elapsed since last start() or restart()
void start(QThread::Priority p=QThread::InheritPriority)
Tell MThread to start running the thread in the near future.
#define ENO
This can be appended to the LOG args with "+".
bool RemoveAllPIDFilters(void)
void SetRunning(bool running, bool using_buffering, bool using_section_reader)
void WriteMPTS(const unsigned char *buffer, uint len)
Write out a copy of the raw MPTS.
virtual void CycleFiltersByPriority()
ThreadedFileWriter * m_mptsTfw
bool wait(std::chrono::milliseconds time=std::chrono::milliseconds::max())
Wait for the MThread to exit, with a maximum timeout.
bool isRunning(void) const
Returns true if start() or restart() has been called at least once since construction and since any c...
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
virtual bool AddNamedOutputFile(const QString &filename)
Called with _listener_lock locked just after adding new output file.
PIDPriority GetPIDPriority(uint pid) const
virtual void RemoveListener(MPEGStreamData *data)
bool m_usingSectionReader
QRecursiveMutex m_listenerLock
@ PrivSec
ISO 13818-1 private tables & ITU H.222.0.
QRecursiveMutex m_pidLock
virtual void SetRunningDesired(bool desired)
At minimum this sets _running_desired, this may also send signals to anything that might be blocking ...
bool UpdateFiltersFromStreamData(void)
Encapsulates data about MPEG stream and emits events for each table.
virtual void RemoveNamedOutputFile(const QString &filename)
Called with _listener_lock locked just before removing old output file.
virtual PIDInfo * CreatePIDInfo(uint pid, uint stream_type, int pes_type)
QMap< uint, PIDPriority > pid_map_t
~StreamHandler() override
int Write(const void *data, uint count)
Writes data to the end of the write buffer.
void UpdateListeningForEIT(void)
bool AddPIDFilter(PIDInfo *info)
This class supports the writing of recordings to disk.
QSet< QString > m_mptsFiles
virtual bool UpdateFilters(void)
volatile bool m_runningDesired
QWaitCondition m_runningStateChanged
StreamDataList m_streamDataList
bool RemovePIDFilter(uint pid)
void exit(int retcode=0)
Use this to exit from the thread if you are using a Qt event loop.
virtual bool GetEITPIDChanges(const uint_vec_t &, uint_vec_t &, uint_vec_t &) const
std::vector< uint > m_eitPids
virtual void AddListener(MPEGStreamData *data, bool allow_section_reader=false, bool needs_buffering=false, const QString &output_file=QString())
virtual void AddListeningPID(uint pid, PIDPriority priority=kPIDPriorityNormal)
bool Open(void)
Opens the file we will be writing to.
bool IsRunning(void) const
virtual bool HasEITPIDChanges(const uint_vec_t &) const
virtual void RemoveListeningPID(uint pid)
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)
bool m_allowSectionReader