Go to the documentation of this file.
15 #define LOC QString("SH[%1]: ").arg(m_inputId)
25 LOG(VB_GENERAL, LOG_ERR,
LOC +
26 "dtor & _stream_data_list not empty");
36 bool allow_section_reader,
38 const QString& output_file)
42 LOG(VB_RECORD, LOG_INFO,
LOC + QString(
"AddListener(0x%1) -- begin")
43 .arg((uint64_t)data,0,16));
46 LOG(VB_GENERAL, LOG_ERR,
LOC +
47 QString(
"AddListener(0x%1) -- null data")
48 .arg((uint64_t)data,0,16));
54 LOG(VB_RECORD, LOG_INFO,
LOC + QString(
"AddListener(0x%1) -- locked")
55 .arg((uint64_t)data,0,16));
76 LOG(VB_RECORD, LOG_INFO,
LOC + QString(
"AddListener(0x%1) -- end")
77 .arg((uint64_t)data,0,16));
84 LOG(VB_RECORD, LOG_INFO,
LOC + QString(
"RemoveListener(0x%1) -- begin")
85 .arg((uint64_t)data,0,16));
88 LOG(VB_GENERAL, LOG_ERR,
LOC +
89 QString(
"RemoveListener(0x%1) -- null data")
90 .arg((uint64_t)data,0,16));
96 LOG(VB_RECORD, LOG_INFO,
LOC + QString(
"RemoveListener(0x%1) -- locked")
97 .arg((uint64_t)data,0,16));
103 if (!(*it).isEmpty())
113 LOG(VB_RECORD, LOG_INFO,
LOC + QString(
"RemoveListener(0x%1) -- end")
114 .arg((uint64_t)data,0,16));
126 LOG(VB_RECORD, LOG_INFO,
LOC +
"Restarting StreamHandler");
150 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Start failed");
157 LOG(VB_RECORD, LOG_DEBUG,
LOC +
"Stopping");
160 LOG(VB_RECORD, LOG_DEBUG,
LOC +
"Stopped");
174 bool is_using_buffering,
175 bool is_using_section_reader)
193 #ifdef DEBUG_PID_FILTERS
194 LOG(VB_RECORD, LOG_DEBUG,
LOC + QString(
"AddPIDFilter(0x%1)")
195 .arg(info->
m_pid, 0, 16));
196 #endif // DEBUG_PID_FILTERS
210 #ifdef DEBUG_PID_FILTERS
211 LOG(VB_RECORD, LOG_DEBUG,
LOC +
212 QString(
"RemovePIDFilter(0x%1)").arg(pid, 0, 16));
213 #endif // DEBUG_PID_FILTERS
217 PIDInfoMap::iterator it =
m_pidInfo.find(pid);
244 #ifdef DEBUG_PID_FILTERS
245 LOG(VB_RECORD, LOG_DEBUG,
LOC +
"RemoveAllPIDFilters()");
246 #endif // DEBUG_PID_FILTERS
248 std::vector<int> del_pids;
250 del_pids.push_back(it.key());
253 for (
int & pid : del_pids)
265 std::vector<uint> add_eit;
266 std::vector<uint> del_eit;
272 for (
uint eit : del_eit)
274 uint_vec_t::iterator it2;
281 for (
uint eit : add_eit)
299 it.key()->GetPIDs(pids);
302 QMap<uint, PIDInfo*> add_pids;
303 std::vector<uint> del_pids;
309 for (
auto lit = pids.constBegin(); lit != pids.constEnd(); ++lit)
321 bool in_pids = pids.find(fit.key()) != pids.end();
323 del_pids.push_back(fit.key());
329 for (
uint & pid : del_pids)
333 for (
auto & pid : add_pids)
350 tmp = std::max(
tmp, it.key()->GetPIDPriority(pid));
364 #if !defined( USING_MINGW ) && !defined( _MSC_VER )
368 QString fn = QString(
"%1.raw").arg(
file);
382 LOG(VB_RECORD, LOG_INFO,
LOC +
389 LOG(VB_GENERAL, LOG_ERR,
LOC +
390 QString(
"Failed to link '%1' to '%2'")
395 LOG(VB_RECORD, LOG_INFO,
LOC +
396 QString(
"linked '%1' to '%2'")
400 #endif // !defined( USING_MINGW ) && !defined( _MSC_VER )
406 #if !defined( USING_MINGW ) && !defined( _MSC_VER )
419 #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