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 (const QString &device, int inputid)
 
 ~StreamHandler ()
 
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 (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 ()
 
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=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_needs_buffering {false}
 
bool m_allow_section_reader {false}
 
QMutex m_add_rm_lock
 
QMutex m_start_stop_lock
 
volatile bool m_running_desired {false}
 
volatile bool m_bError {false}
 
bool m_running {false}
 
bool m_restarting {false}
 
bool m_using_buffering {false}
 
bool m_using_section_reader {false}
 
QWaitCondition m_running_state_changed
 
QMutex m_pid_lock {QMutex::Recursive}
 
vector< uintm_eit_pids
 
PIDInfoMap m_pid_info
 
uint m_open_pid_filters {0}
 
MythTimer m_cycle_timer
 
ThreadedFileWriterm_mpts_tfw {nullptr}
 
QSet< QString > m_mpts_files
 
QString m_mpts_base_file
 
QMutex m_mpts_lock
 
QMutex m_listener_lock {QMutex::Recursive}
 
StreamDataList m_stream_data_list
 
- Protected Attributes inherited from MThread
MThreadInternalm_thread {nullptr}
 
QRunnable * m_runnable {nullptr}
 
bool m_prolog_executed {true}
 
bool m_epilog_executed {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 &)
 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 ( const QString &  device,
int  inputid 
)
inlineexplicitprotected

Definition at line 72 of file streamhandler.h.

◆ ~StreamHandler()

StreamHandler::~StreamHandler ( )
protected

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 364 of file streamhandler.cpp.

Referenced by 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 410 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 255 of file streamhandler.cpp.

Referenced by UpdateFiltersFromStreamData().

◆ UpdateFiltersFromStreamData()

bool StreamHandler::UpdateFiltersFromStreamData ( void  )
protected

◆ UpdateFilters()

virtual bool StreamHandler::UpdateFilters ( void  )
inlineprotectedvirtual

Reimplemented in HDHRStreamHandler.

Definition at line 89 of file streamhandler.h.

Referenced by RemoveAllPIDFilters().

◆ CycleFiltersByPriority()

virtual void StreamHandler::CycleFiltersByPriority ( void  )
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 344 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 ( unsigned char *  buffer,
uint  len 
)
protected

Write out a copy of the raw MPTS.

Definition at line 357 of file streamhandler.cpp.

Referenced by 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 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_needs_buffering

bool StreamHandler::m_needs_buffering {false}
protected

◆ m_allow_section_reader

bool StreamHandler::m_allow_section_reader {false}
protected

Definition at line 113 of file streamhandler.h.

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

◆ m_add_rm_lock

QMutex StreamHandler::m_add_rm_lock
protected

Definition at line 115 of file streamhandler.h.

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

◆ m_start_stop_lock

QMutex StreamHandler::m_start_stop_lock
mutableprotected

◆ m_running_desired

volatile bool StreamHandler::m_running_desired {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_using_buffering

bool StreamHandler::m_using_buffering {false}
protected

Definition at line 126 of file streamhandler.h.

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

◆ m_using_section_reader

bool StreamHandler::m_using_section_reader {false}
protected

◆ m_running_state_changed

QWaitCondition StreamHandler::m_running_state_changed
protected

Definition at line 128 of file streamhandler.h.

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

◆ m_pid_lock

QMutex StreamHandler::m_pid_lock {QMutex::Recursive}
mutableprotected

◆ m_eit_pids

vector<uint> StreamHandler::m_eit_pids
protected

Definition at line 131 of file streamhandler.h.

Referenced by Start(), and UpdateListeningForEIT().

◆ m_pid_info

PIDInfoMap StreamHandler::m_pid_info
protected

◆ m_open_pid_filters

uint StreamHandler::m_open_pid_filters {0}
protected

Definition at line 133 of file streamhandler.h.

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

◆ m_cycle_timer

MythTimer StreamHandler::m_cycle_timer
protected

◆ m_mpts_tfw

ThreadedFileWriter* StreamHandler::m_mpts_tfw {nullptr}
protected

Definition at line 136 of file streamhandler.h.

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

◆ m_mpts_files

QSet<QString> StreamHandler::m_mpts_files
protected

Definition at line 137 of file streamhandler.h.

Referenced by AddNamedOutputFile(), and RemoveNamedOutputFile().

◆ m_mpts_base_file

QString StreamHandler::m_mpts_base_file
protected

Definition at line 138 of file streamhandler.h.

Referenced by AddNamedOutputFile().

◆ m_mpts_lock

QMutex StreamHandler::m_mpts_lock
protected

Definition at line 139 of file streamhandler.h.

Referenced by AddNamedOutputFile(), and RemoveNamedOutputFile().

◆ m_listener_lock

QMutex StreamHandler::m_listener_lock {QMutex::Recursive}
mutableprotected

◆ m_stream_data_list

StreamDataList StreamHandler::m_stream_data_list
protected

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