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

#include <streamhandler.h>

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

Public Member Functions

virtual void AddListener (MPEGStreamData *data, bool allow_section_reader=false, bool needs_buffering=false, 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 = QMap< 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 (unsigned long time=ULONG_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
 
QMutex m_pidLock {QMutex::Recursive}
 
vector< uintm_eitPids
 
PIDInfoMap m_pidInfo
 
uint m_openPidFilters {0}
 
MythTimer m_cycleTimer
 
ThreadedFileWriterm_mptsTfw {nullptr}
 
QSet< QString > m_mptsFiles
 
QString m_mptsBaseFile
 
QMutex m_mptsLock
 
QMutex m_listenerLock {QMutex::Recursive}
 
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 sleep (unsigned long time)
 
static void msleep (unsigned long time)
 
static void usleep (unsigned long 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)
 
- Static Protected Attributes inherited from MThread
static const int kDefaultStartTimeout
 

Detailed Description

Definition at line 55 of file streamhandler.h.

Member Typedef Documentation

◆ StreamDataList

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

Definition at line 141 of file streamhandler.h.

Constructor & Destructor Documentation

◆ StreamHandler()

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

Definition at line 72 of file streamhandler.h.

◆ ~StreamHandler()

StreamHandler::~StreamHandler ( )
overrideprotected

Definition at line 15 of file streamhandler.cpp.

Member Function Documentation

◆ AddListener()

void StreamHandler::AddListener ( MPEGStreamData data,
bool  allow_section_reader = false,
bool  needs_buffering = false,
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 356 of file streamhandler.cpp.

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

◆ RemoveNamedOutputFile()

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

Called with _listener_lock locked just before removing old output file.

Definition at line 402 of file streamhandler.cpp.

Referenced by RemoveListener().

◆ Start()

void StreamHandler::Start ( void  )
protected

Definition at line 115 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 253 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 89 of file streamhandler.h.

Referenced by RemoveAllPIDFilters().

◆ CycleFiltersByPriority()

virtual void StreamHandler::CycleFiltersByPriority ( )
inlineprotectedvirtual

Reimplemented in DVBStreamHandler.

Definition at line 90 of file streamhandler.h.

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

◆ GetPIDPriority()

PIDPriority StreamHandler::GetPIDPriority ( uint  pid) const
protected

Definition at line 337 of file streamhandler.cpp.

Referenced by DVBStreamHandler::CycleFiltersByPriority().

◆ ReaderPaused()

void StreamHandler::ReaderPaused ( int  fd)
inlineoverrideprotectedvirtual

Implements DeviceReaderCB.

Definition at line 95 of file streamhandler.h.

◆ PriorityEvent()

void StreamHandler::PriorityEvent ( int  fd)
inlineoverrideprotectedvirtual

Implements DeviceReaderCB.

Definition at line 96 of file streamhandler.h.

◆ CreatePIDInfo()

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

Reimplemented in DVBStreamHandler.

Definition at line 98 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 349 of file streamhandler.cpp.

Referenced by ASIStreamHandler::run(), HDHRStreamHandler::run(), DVBStreamHandler::RunTS(), and SatIPRTSPWriteHelper::timerEvent().

◆ 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 182 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 111 of file streamhandler.h.

◆ m_needsBuffering

bool StreamHandler::m_needsBuffering {false}
protected

◆ m_allowSectionReader

bool StreamHandler::m_allowSectionReader {false}
protected

Definition at line 113 of file streamhandler.h.

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

◆ m_addRmLock

QMutex StreamHandler::m_addRmLock
protected

Definition at line 115 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 125 of file streamhandler.h.

Referenced by IsRunning(), and Start().

◆ m_usingBuffering

bool StreamHandler::m_usingBuffering {false}
protected

Definition at line 126 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 128 of file streamhandler.h.

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

◆ m_pidLock

QMutex StreamHandler::m_pidLock {QMutex::Recursive}
mutableprotected

◆ m_eitPids

vector<uint> StreamHandler::m_eitPids
protected

Definition at line 131 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 133 of file streamhandler.h.

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

◆ m_cycleTimer

MythTimer StreamHandler::m_cycleTimer
protected

◆ m_mptsTfw

ThreadedFileWriter* StreamHandler::m_mptsTfw {nullptr}
protected

Definition at line 136 of file streamhandler.h.

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

◆ m_mptsFiles

QSet<QString> StreamHandler::m_mptsFiles
protected

Definition at line 137 of file streamhandler.h.

Referenced by AddNamedOutputFile(), and RemoveNamedOutputFile().

◆ m_mptsBaseFile

QString StreamHandler::m_mptsBaseFile
protected

Definition at line 138 of file streamhandler.h.

Referenced by AddNamedOutputFile().

◆ m_mptsLock

QMutex StreamHandler::m_mptsLock
protected

Definition at line 139 of file streamhandler.h.

Referenced by AddNamedOutputFile(), and RemoveNamedOutputFile().

◆ m_listenerLock

QMutex StreamHandler::m_listenerLock {QMutex::Recursive}
mutableprotected

◆ m_streamDataList

StreamDataList StreamHandler::m_streamDataList
protected

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