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_drb=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

typedef QMap< MPEGStreamData *, QString > StreamDataList
 

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 _device
 
int _inputid
 
bool _needs_buffering
 
bool _allow_section_reader
 
QMutex _add_rm_lock
 
QMutex _start_stop_lock
 
volatile bool _running_desired
 
volatile bool _error
 
bool _running
 
bool _using_buffering
 
bool _using_section_reader
 
QWaitCondition _running_state_changed
 
QMutex _pid_lock
 
vector< uint_eit_pids
 
PIDInfoMap _pid_info
 
uint _open_pid_filters
 
MythTimer _cycle_timer
 
ThreadedFileWriter_mpts_tfw
 
QSet< QString > _mpts_files
 
QString _mpts_base_file
 
QMutex _mpts_lock
 
QMutex _listener_lock
 
StreamDataList _stream_data_list
 
- Protected Attributes inherited from MThread
MThreadInternalm_thread
 
QRunnable * m_runnable
 
bool m_prolog_executed
 
bool m_epilog_executed
 

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

typedef QMap<MPEGStreamData*,QString> StreamHandler::StreamDataList
protected

Definition at line 135 of file streamhandler.h.

Constructor & Destructor Documentation

◆ StreamHandler()

StreamHandler::StreamHandler ( const QString &  device,
int  inputid 
)
explicitprotected

Definition at line 13 of file streamhandler.cpp.

◆ ~StreamHandler()

StreamHandler::~StreamHandler ( )
protected

Definition at line 31 of file streamhandler.cpp.

Member Function Documentation

◆ AddListener()

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

Referenced by RemoveListener().

◆ Start()

void StreamHandler::Start ( void  )
protected

◆ 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 269 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 88 of file streamhandler.h.

Referenced by RemoveAllPIDFilters().

◆ CycleFiltersByPriority()

virtual void StreamHandler::CycleFiltersByPriority ( void  )
inlineprotectedvirtual

Reimplemented in DVBStreamHandler.

Definition at line 89 of file streamhandler.h.

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

◆ GetPIDPriority()

PIDPriority StreamHandler::GetPIDPriority ( uint  pid) const
protected

Definition at line 358 of file streamhandler.cpp.

Referenced by DVBStreamHandler::CycleFiltersByPriority().

◆ ReaderPaused()

void StreamHandler::ReaderPaused ( int  fd)
inlineoverrideprotectedvirtual

Implements DeviceReaderCB.

Definition at line 94 of file streamhandler.h.

◆ PriorityEvent()

void StreamHandler::PriorityEvent ( int  fd)
inlineoverrideprotectedvirtual

Implements DeviceReaderCB.

Definition at line 95 of file streamhandler.h.

◆ CreatePIDInfo()

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

Reimplemented in DVBStreamHandler.

Definition at line 97 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 371 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, and DVBStreamHandler.

Definition at line 196 of file streamhandler.cpp.

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

Member Data Documentation

◆ _device

QString StreamHandler::_device
protected

◆ _inputid

int StreamHandler::_inputid
protected

Definition at line 110 of file streamhandler.h.

◆ _needs_buffering

bool StreamHandler::_needs_buffering
protected

◆ _allow_section_reader

bool StreamHandler::_allow_section_reader
protected

Definition at line 112 of file streamhandler.h.

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

◆ _add_rm_lock

QMutex StreamHandler::_add_rm_lock
protected

Definition at line 114 of file streamhandler.h.

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

◆ _start_stop_lock

QMutex StreamHandler::_start_stop_lock
mutableprotected

◆ _running_desired

volatile bool StreamHandler::_running_desired
protected

◆ _error

volatile bool StreamHandler::_error
protected

◆ _running

bool StreamHandler::_running
protected

◆ _using_buffering

bool StreamHandler::_using_buffering
protected

Definition at line 120 of file streamhandler.h.

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

◆ _using_section_reader

bool StreamHandler::_using_section_reader
protected

◆ _running_state_changed

QWaitCondition StreamHandler::_running_state_changed
protected

Definition at line 122 of file streamhandler.h.

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

◆ _pid_lock

QMutex StreamHandler::_pid_lock
mutableprotected

◆ _eit_pids

vector<uint> StreamHandler::_eit_pids
protected

Definition at line 125 of file streamhandler.h.

Referenced by Start(), and UpdateListeningForEIT().

◆ _pid_info

PIDInfoMap StreamHandler::_pid_info
protected

◆ _open_pid_filters

uint StreamHandler::_open_pid_filters
protected

Definition at line 127 of file streamhandler.h.

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

◆ _cycle_timer

MythTimer StreamHandler::_cycle_timer
protected

◆ _mpts_tfw

ThreadedFileWriter* StreamHandler::_mpts_tfw
protected

Definition at line 130 of file streamhandler.h.

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

◆ _mpts_files

QSet<QString> StreamHandler::_mpts_files
protected

Definition at line 131 of file streamhandler.h.

Referenced by AddNamedOutputFile(), and RemoveNamedOutputFile().

◆ _mpts_base_file

QString StreamHandler::_mpts_base_file
protected

Definition at line 132 of file streamhandler.h.

Referenced by AddNamedOutputFile().

◆ _mpts_lock

QMutex StreamHandler::_mpts_lock
protected

Definition at line 133 of file streamhandler.h.

Referenced by AddNamedOutputFile(), and RemoveNamedOutputFile().

◆ _listener_lock

QMutex StreamHandler::_listener_lock
mutableprotected

◆ _stream_data_list

StreamDataList StreamHandler::_stream_data_list
protected

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