MythTV  master
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
StreamHandler Class Reference

#include <libmythtv/recorders/streamhandler.h>

Inheritance diagram for StreamHandler:
[legend]
Collaboration diagram for StreamHandler:
[legend]

Public Member Functions

virtual void AddListener (MPEGStreamData *data, bool allow_section_reader=false, bool needs_buffering=false, const QString &output_file=QString())
 
virtual void RemoveListener (MPEGStreamData *data)
 
bool IsRunning (void) const
 
bool HasError (void) const
 
virtual bool AddNamedOutputFile (const QString &filename)
 Called with _listener_lock locked just after adding new output file. More...
 
virtual void RemoveNamedOutputFile (const QString &filename)
 Called with _listener_lock locked just before removing old output file. More...
 

Protected Types

using StreamDataList = QHash< MPEGStreamData *, QString >
 

Protected Member Functions

 StreamHandler (QString device, int inputid)
 
 ~StreamHandler () override
 
void Start (void)
 
void Stop (void)
 
void SetRunning (bool running, bool using_buffering, bool using_section_reader)
 
bool AddPIDFilter (PIDInfo *info)
 
bool RemovePIDFilter (uint pid)
 
bool RemoveAllPIDFilters (void)
 
void UpdateListeningForEIT (void)
 
bool UpdateFiltersFromStreamData (void)
 
virtual bool UpdateFilters (void)
 
virtual void CycleFiltersByPriority ()
 
PIDPriority GetPIDPriority (uint pid) const
 
void ReaderPaused (int fd) override
 
void PriorityEvent (int fd) override
 
virtual PIDInfoCreatePIDInfo (uint pid, uint stream_type, int pes_type)
 
void WriteMPTS (const unsigned char *buffer, uint len)
 Write out a copy of the raw MPTS. More...
 
virtual void SetRunningDesired (bool desired)
 At minimum this sets _running_desired, this may also send signals to anything that might be blocking the run() loop. More...
 
- Protected Member Functions inherited from MThread
virtual void run (void)
 Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead. More...
 
int exec (void)
 Enters the qt event loop. call exit or quit to exit thread. More...
 
 MThread (const QString &objectName)
 Standard constructor. More...
 
 MThread (const QString &objectName, QRunnable *runnable)
 Use this constructor if you want the default run() method to run the QRunnable's run() method instead of entering the Qt event loop. More...
 
virtual ~MThread ()
 
 MThread (const MThread &)=delete
 
MThreadoperator= (const MThread &)=delete
 
void RunProlog (void)
 Sets up a thread, call this if you reimplement run(). More...
 
void RunEpilog (void)
 Cleans up a thread's resources, call this if you reimplement run(). More...
 
QThread * qthread (void)
 Returns the thread, this will always return the same pointer no matter how often you restart the thread. More...
 
void setObjectName (const QString &name)
 
QString objectName (void) const
 
void setPriority (QThread::Priority priority)
 
QThread::Priority priority (void) const
 
bool isFinished (void) const
 
bool isRunning (void) const
 
void setStackSize (uint stackSize)
 
uint stackSize (void) const
 
void exit (int retcode=0)
 Use this to exit from the thread if you are using a Qt event loop. More...
 
void start (QThread::Priority p=QThread::InheritPriority)
 Tell MThread to start running the thread in the near future. More...
 
void terminate (void)
 Kill a thread unsafely. More...
 
void quit (void)
 calls exit(0) More...
 
bool wait (std::chrono::milliseconds time=std::chrono::milliseconds::max())
 Wait for the MThread to exit, with a maximum timeout. More...
 
- Protected Member Functions inherited from DeviceReaderCB
virtual ~DeviceReaderCB ()=default
 

Protected Attributes

QString m_device
 
int m_inputId
 
bool m_needsBuffering {false}
 
bool m_allowSectionReader {false}
 
QMutex m_addRmLock
 
QMutex m_startStopLock
 
volatile bool m_runningDesired {false}
 
volatile bool m_bError {false}
 
bool m_running {false}
 
bool m_restarting {false}
 
bool m_usingBuffering {false}
 
bool m_usingSectionReader {false}
 
QWaitCondition m_runningStateChanged
 
QRecursiveMutex m_pidLock
 
std::vector< uintm_eitPids
 
PIDInfoMap m_pidInfo
 
uint m_openPidFilters {0}
 
bool m_filtersChanged {false}
 
MythTimer m_cycleTimer
 
ThreadedFileWriterm_mptsTfw {nullptr}
 
QSet< QString > m_mptsFiles
 
QString m_mptsBaseFile
 
QMutex m_mptsLock
 
QRecursiveMutex m_listenerLock
 
StreamDataList m_streamDataList
 
- Protected Attributes inherited from MThread
MThreadInternalm_thread {nullptr}
 
QRunnable * m_runnable {nullptr}
 
bool m_prologExecuted {true}
 
bool m_epilogExecuted {true}
 

Additional Inherited Members

- Static Protected Member Functions inherited from MThread
static void setTerminationEnabled (bool enabled=true)
 
static void usleep (std::chrono::microseconds time)
 
template<typename R , typename P >
static std::enable_if_t< std::chrono::treat_as_floating_point< R >::value, void > usleep (std::chrono::duration< R, P > time)
 
static void ThreadSetup (const QString &name)
 This is to be called on startup in those few threads that haven't been ported to MThread. More...
 
static void ThreadCleanup (void)
 This is to be called on exit in those few threads that haven't been ported to MThread. More...
 
static void Cleanup (void)
 This will print out all the running threads, call exit(1) on each and then wait up to 5 seconds total for all the threads to exit. More...
 
static void GetAllThreadNames (QStringList &list)
 
static void GetAllRunningThreadNames (QStringList &list)
 

Detailed Description

Definition at line 56 of file streamhandler.h.

Member Typedef Documentation

◆ StreamDataList

using StreamHandler::StreamDataList = QHash<MPEGStreamData*,QString>
protected

Definition at line 143 of file streamhandler.h.

Constructor & Destructor Documentation

◆ StreamHandler()

StreamHandler::StreamHandler ( QString  device,
int  inputid 
)
inlineexplicitprotected

Definition at line 73 of file streamhandler.h.

◆ ~StreamHandler()

StreamHandler::~StreamHandler ( )
overrideprotected

Definition at line 17 of file streamhandler.cpp.

Member Function Documentation

◆ AddListener()

void StreamHandler::AddListener ( MPEGStreamData data,
bool  allow_section_reader = false,
bool  needs_buffering = false,
const QString &  output_file = QString() 
)
virtual

◆ RemoveListener()

void StreamHandler::RemoveListener ( MPEGStreamData data)
virtual

◆ IsRunning()

bool StreamHandler::IsRunning ( void  ) const

◆ HasError()

bool StreamHandler::HasError ( void  ) const
inline

◆ AddNamedOutputFile()

bool StreamHandler::AddNamedOutputFile ( const QString &  filename)
virtual

Called with _listener_lock locked just after adding new output file.

Definition at line 362 of file streamhandler.cpp.

Referenced by SatIPRecorder::StartNewFile(), HDHRRecorder::StartNewFile(), DVBRecorder::StartNewFile(), and ASIRecorder::StartNewFile().

◆ RemoveNamedOutputFile()

void StreamHandler::RemoveNamedOutputFile ( const QString &  filename)
virtual

Called with _listener_lock locked just before removing old output file.

Definition at line 404 of file streamhandler.cpp.

Referenced by RemoveListener().

◆ Start()

void StreamHandler::Start ( void  )
protected

Definition at line 117 of file streamhandler.cpp.

Referenced by AddListener().

◆ Stop()

void StreamHandler::Stop ( void  )
protected

◆ SetRunning()

void StreamHandler::SetRunning ( bool  running,
bool  using_buffering,
bool  using_section_reader 
)
protected

◆ AddPIDFilter()

bool StreamHandler::AddPIDFilter ( PIDInfo info)
protected

◆ RemovePIDFilter()

bool StreamHandler::RemovePIDFilter ( uint  pid)
protected

◆ RemoveAllPIDFilters()

bool StreamHandler::RemoveAllPIDFilters ( void  )
protected

◆ UpdateListeningForEIT()

void StreamHandler::UpdateListeningForEIT ( void  )
protected

Definition at line 259 of file streamhandler.cpp.

Referenced by UpdateFiltersFromStreamData().

◆ UpdateFiltersFromStreamData()

bool StreamHandler::UpdateFiltersFromStreamData ( void  )
protected

◆ UpdateFilters()

virtual bool StreamHandler::UpdateFilters ( void  )
inlineprotectedvirtual

Reimplemented in HDHRStreamHandler, and SatIPStreamHandler.

Definition at line 90 of file streamhandler.h.

Referenced by RemoveAllPIDFilters().

◆ CycleFiltersByPriority()

virtual void StreamHandler::CycleFiltersByPriority ( )
inlineprotectedvirtual

Reimplemented in DVBStreamHandler.

Definition at line 91 of file streamhandler.h.

Referenced by AddPIDFilter(), RemovePIDFilter(), and UpdateFiltersFromStreamData().

◆ GetPIDPriority()

PIDPriority StreamHandler::GetPIDPriority ( uint  pid) const
protected

Definition at line 343 of file streamhandler.cpp.

Referenced by DVBStreamHandler::CycleFiltersByPriority().

◆ ReaderPaused()

void StreamHandler::ReaderPaused ( int  fd)
inlineoverrideprotectedvirtual

Implements DeviceReaderCB.

Definition at line 96 of file streamhandler.h.

◆ PriorityEvent()

void StreamHandler::PriorityEvent ( int  fd)
inlineoverrideprotectedvirtual

Implements DeviceReaderCB.

Definition at line 97 of file streamhandler.h.

◆ CreatePIDInfo()

virtual PIDInfo* StreamHandler::CreatePIDInfo ( uint  pid,
uint  stream_type,
int  pes_type 
)
inlineprotectedvirtual

Reimplemented in DVBStreamHandler.

Definition at line 99 of file streamhandler.h.

Referenced by UpdateFiltersFromStreamData().

◆ WriteMPTS()

void StreamHandler::WriteMPTS ( const unsigned char *  buffer,
uint  len 
)
protected

Write out a copy of the raw MPTS.

Definition at line 355 of file streamhandler.cpp.

Referenced by SatIPDataReadHelper::ReadPending(), ASIStreamHandler::run(), HDHRStreamHandler::run(), and DVBStreamHandler::RunTS().

◆ SetRunningDesired()

void StreamHandler::SetRunningDesired ( bool  desired)
protectedvirtual

At minimum this sets _running_desired, this may also send signals to anything that might be blocking the run() loop.

Note
: The _start_stop_lock must be held when this is called.

Reimplemented in ASIStreamHandler.

Definition at line 184 of file streamhandler.cpp.

Referenced by ASIStreamHandler::SetRunningDesired(), Start(), and Stop().

Member Data Documentation

◆ m_device

QString StreamHandler::m_device
protected

◆ m_inputId

int StreamHandler::m_inputId
protected

Definition at line 112 of file streamhandler.h.

◆ m_needsBuffering

bool StreamHandler::m_needsBuffering {false}
protected

◆ m_allowSectionReader

bool StreamHandler::m_allowSectionReader {false}
protected

Definition at line 114 of file streamhandler.h.

Referenced by AddListener(), DVBStreamHandler::run(), and Start().

◆ m_addRmLock

QMutex StreamHandler::m_addRmLock
protected

Definition at line 116 of file streamhandler.h.

Referenced by AddListener(), RemoveListener(), and ~StreamHandler().

◆ m_startStopLock

QMutex StreamHandler::m_startStopLock
mutableprotected

◆ m_runningDesired

volatile bool StreamHandler::m_runningDesired {false}
protected

◆ m_bError

volatile bool StreamHandler::m_bError {false}
protected

◆ m_running

bool StreamHandler::m_running {false}
protected

◆ m_restarting

bool StreamHandler::m_restarting {false}
protected

Definition at line 126 of file streamhandler.h.

Referenced by IsRunning(), and Start().

◆ m_usingBuffering

bool StreamHandler::m_usingBuffering {false}
protected

Definition at line 127 of file streamhandler.h.

Referenced by DVBStreamHandler::RunTS(), SetRunning(), and Start().

◆ m_usingSectionReader

bool StreamHandler::m_usingSectionReader {false}
protected

◆ m_runningStateChanged

QWaitCondition StreamHandler::m_runningStateChanged
protected

Definition at line 129 of file streamhandler.h.

Referenced by V4L2encStreamHandler::run(), SetRunning(), and Start().

◆ m_pidLock

QRecursiveMutex StreamHandler::m_pidLock
mutableprotected

◆ m_eitPids

std::vector<uint> StreamHandler::m_eitPids
protected

Definition at line 132 of file streamhandler.h.

Referenced by Start(), and UpdateListeningForEIT().

◆ m_pidInfo

PIDInfoMap StreamHandler::m_pidInfo
protected

◆ m_openPidFilters

uint StreamHandler::m_openPidFilters {0}
protected

Definition at line 134 of file streamhandler.h.

Referenced by DVBStreamHandler::CycleFiltersByPriority(), and RemovePIDFilter().

◆ m_filtersChanged

bool StreamHandler::m_filtersChanged {false}
protected

◆ m_cycleTimer

MythTimer StreamHandler::m_cycleTimer
protected

◆ m_mptsTfw

ThreadedFileWriter* StreamHandler::m_mptsTfw {nullptr}
protected

Definition at line 138 of file streamhandler.h.

Referenced by AddNamedOutputFile(), RemoveNamedOutputFile(), and WriteMPTS().

◆ m_mptsFiles

QSet<QString> StreamHandler::m_mptsFiles
protected

Definition at line 139 of file streamhandler.h.

Referenced by AddNamedOutputFile(), and RemoveNamedOutputFile().

◆ m_mptsBaseFile

QString StreamHandler::m_mptsBaseFile
protected

Definition at line 140 of file streamhandler.h.

Referenced by AddNamedOutputFile().

◆ m_mptsLock

QMutex StreamHandler::m_mptsLock
protected

Definition at line 141 of file streamhandler.h.

Referenced by AddNamedOutputFile(), and RemoveNamedOutputFile().

◆ m_listenerLock

QRecursiveMutex StreamHandler::m_listenerLock
mutableprotected

◆ m_streamDataList

StreamDataList StreamHandler::m_streamDataList
protected

The documentation for this class was generated from the following files: