MythTV  master
Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
ExternalStreamHandler Class Reference

#include <ExternalStreamHandler.h>

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

Public Member Functions

 ExternalStreamHandler (const QString &path, int inputid, int majorid)
 
 ~ExternalStreamHandler (void)
 
void run (void) override
 Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead. More...
 
void PriorityEvent (int fd) override
 
QString GetDescription (void)
 
QString UpdateDescription (void)
 
bool IsAppOpen (void)
 
bool IsTSOpen (void)
 
bool HasTuner (void) const
 
bool HasPictureAttributes (void) const
 
bool RestartStream (void)
 
void LockReplay (void)
 
void UnlockReplay (bool enable_replay=false)
 
void ReplayStream (void)
 
bool StartStreaming (void)
 
bool StopStreaming (void)
 
bool CheckForError (void)
 
void PurgeBuffer (void)
 
bool ProcessCommand (const QString &cmd, QString &result, int timeout=4000, uint retry_cnt=3)
 
bool ProcessVer1 (const QString &cmd, QString &result, int timeout, uint retry_cnt)
 
bool ProcessVer2 (const QString &command, QString &result, int timeout, uint retry_cnt)
 
- Public Member Functions inherited from StreamHandler
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...
 

Static Public Member Functions

static ExternalStreamHandlerGet (const QString &devname, int inputid, int majorid)
 
static void Return (ExternalStreamHandler *&ref, int inputid)
 

Private Types

enum  constants { MAX_API_VERSION = 2, TS_PACKET_SIZE = 188, PACKET_SIZE = TS_PACKET_SIZE * 8192, TOO_FAST_SIZE = TS_PACKET_SIZE * 32768 }
 

Private Member Functions

int StreamingCount (void) const
 
bool SetAPIVersion (void)
 
bool OpenApp (void)
 
void CloseApp (void)
 

Private Attributes

QString m_loc
 
int m_majorid
 
QMutex m_io_lock
 
ExternIOm_io {nullptr}
 
QStringList m_args
 
QString m_app
 
bool m_tsopen {false}
 
int m_io_errcnt {0}
 
bool m_poll_mode {false}
 
int m_apiVersion {1}
 
uint m_serialNo {0}
 
bool m_hasTuner
 
bool m_hasPictureAttributes
 
QByteArray m_replay_buffer
 
bool m_replay {false}
 
bool m_xon {false}
 
QAtomicInt m_streaming_cnt
 
QMutex m_stream_lock
 
QMutex m_replay_lock
 
QMutex m_process_lock
 

Static Private Attributes

static QMutex s_handlers_lock
 
static QMap< int, ExternalStreamHandler * > s_handlers
 
static QMap< int, uints_handlers_refcnt
 

Additional Inherited Members

- Protected Types inherited from StreamHandler
typedef QMap< MPEGStreamData *, QString > StreamDataList
 
- Protected Member Functions inherited from StreamHandler
 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
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
 
- 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)
 
- Protected Attributes inherited from StreamHandler
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}
 
- Static Protected Attributes inherited from MThread
static const int kDefaultStartTimeout
 

Detailed Description

Definition at line 60 of file ExternalStreamHandler.h.

Member Enumeration Documentation

◆ constants

Enumerator
MAX_API_VERSION 
TS_PACKET_SIZE 
PACKET_SIZE 
TOO_FAST_SIZE 

Definition at line 62 of file ExternalStreamHandler.h.

Constructor & Destructor Documentation

◆ ExternalStreamHandler()

ExternalStreamHandler::ExternalStreamHandler ( const QString &  path,
int  inputid,
int  majorid 
)
explicit

Definition at line 535 of file ExternalStreamHandler.cpp.

Referenced by Get().

◆ ~ExternalStreamHandler()

ExternalStreamHandler::~ExternalStreamHandler ( void  )
inline

Definition at line 75 of file ExternalStreamHandler.h.

Member Function Documentation

◆ Get()

ExternalStreamHandler * ExternalStreamHandler::Get ( const QString &  devname,
int  inputid,
int  majorid 
)
static

◆ Return()

void ExternalStreamHandler::Return ( ExternalStreamHandler *&  ref,
int  inputid 
)
static

◆ run()

void ExternalStreamHandler::run ( void  )
overridevirtual

Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.

Note
If you override this method you must call RunProlog before you do any work and RunEpilog before you exit the run method.

Reimplemented from MThread.

Definition at line 569 of file ExternalStreamHandler.cpp.

◆ PriorityEvent()

void ExternalStreamHandler::PriorityEvent ( int  fd)
overridevirtual

Implements DeviceReaderCB.

Definition at line 1537 of file ExternalStreamHandler.cpp.

◆ GetDescription()

QString ExternalStreamHandler::GetDescription ( void  )
inline

Definition at line 80 of file ExternalStreamHandler.h.

Referenced by ExternalChannel::GetDescription().

◆ UpdateDescription()

QString ExternalStreamHandler::UpdateDescription ( void  )

◆ IsAppOpen()

bool ExternalStreamHandler::IsAppOpen ( void  )

◆ IsTSOpen()

bool ExternalStreamHandler::IsTSOpen ( void  )

Definition at line 1001 of file ExternalStreamHandler.cpp.

Referenced by run().

◆ HasTuner()

bool ExternalStreamHandler::HasTuner ( void  ) const
inline

◆ HasPictureAttributes()

bool ExternalStreamHandler::HasPictureAttributes ( void  ) const
inline

Definition at line 85 of file ExternalStreamHandler.h.

◆ RestartStream()

bool ExternalStreamHandler::RestartStream ( void  )

Definition at line 1053 of file ExternalStreamHandler.cpp.

Referenced by run().

◆ LockReplay()

void ExternalStreamHandler::LockReplay ( void  )
inline

Definition at line 89 of file ExternalStreamHandler.h.

◆ UnlockReplay()

void ExternalStreamHandler::UnlockReplay ( bool  enable_replay = false)
inline

Definition at line 90 of file ExternalStreamHandler.h.

◆ ReplayStream()

void ExternalStreamHandler::ReplayStream ( void  )

Definition at line 1070 of file ExternalStreamHandler.cpp.

◆ StartStreaming()

bool ExternalStreamHandler::StartStreaming ( void  )

◆ StopStreaming()

bool ExternalStreamHandler::StopStreaming ( void  )

◆ CheckForError()

bool ExternalStreamHandler::CheckForError ( void  )

Definition at line 1482 of file ExternalStreamHandler.cpp.

Referenced by run().

◆ PurgeBuffer()

void ExternalStreamHandler::PurgeBuffer ( void  )

Definition at line 1527 of file ExternalStreamHandler.cpp.

Referenced by StopStreaming().

◆ ProcessCommand()

bool ExternalStreamHandler::ProcessCommand ( const QString &  cmd,
QString &  result,
int  timeout = 4000,
uint  retry_cnt = 3 
)

◆ ProcessVer1()

bool ExternalStreamHandler::ProcessVer1 ( const QString &  cmd,
QString &  result,
int  timeout,
uint  retry_cnt 
)

Definition at line 1234 of file ExternalStreamHandler.cpp.

Referenced by ProcessCommand().

◆ ProcessVer2()

bool ExternalStreamHandler::ProcessVer2 ( const QString &  command,
QString &  result,
int  timeout,
uint  retry_cnt 
)

Definition at line 1341 of file ExternalStreamHandler.cpp.

Referenced by ProcessCommand().

◆ StreamingCount()

int ExternalStreamHandler::StreamingCount ( void  ) const
private

Definition at line 564 of file ExternalStreamHandler.cpp.

Referenced by RestartStream(), run(), StartStreaming(), and StopStreaming().

◆ SetAPIVersion()

bool ExternalStreamHandler::SetAPIVersion ( void  )
private

Definition at line 854 of file ExternalStreamHandler.cpp.

Referenced by OpenApp().

◆ OpenApp()

bool ExternalStreamHandler::OpenApp ( void  )
private

Definition at line 895 of file ExternalStreamHandler.cpp.

Referenced by ExternalStreamHandler().

◆ CloseApp()

void ExternalStreamHandler::CloseApp ( void  )
private

Definition at line 1015 of file ExternalStreamHandler.cpp.

Referenced by run().

Member Data Documentation

◆ m_loc

QString ExternalStreamHandler::m_loc
private

Definition at line 113 of file ExternalStreamHandler.h.

Referenced by UpdateDescription().

◆ m_majorid

int ExternalStreamHandler::m_majorid
private

Definition at line 114 of file ExternalStreamHandler.h.

Referenced by Return().

◆ m_io_lock

QMutex ExternalStreamHandler::m_io_lock
private

Definition at line 115 of file ExternalStreamHandler.h.

Referenced by CheckForError(), CloseApp(), OpenApp(), ProcessVer1(), and ProcessVer2().

◆ m_io

ExternIO* ExternalStreamHandler::m_io {nullptr}
private

◆ m_args

QStringList ExternalStreamHandler::m_args
private

Definition at line 117 of file ExternalStreamHandler.h.

Referenced by CloseApp(), ExternalStreamHandler(), and OpenApp().

◆ m_app

QString ExternalStreamHandler::m_app
private

Definition at line 118 of file ExternalStreamHandler.h.

Referenced by ExternalStreamHandler(), and OpenApp().

◆ m_tsopen

bool ExternalStreamHandler::m_tsopen {false}
private

Definition at line 119 of file ExternalStreamHandler.h.

Referenced by IsTSOpen().

◆ m_io_errcnt

int ExternalStreamHandler::m_io_errcnt {0}
private

Definition at line 120 of file ExternalStreamHandler.h.

Referenced by ProcessVer1(), and ProcessVer2().

◆ m_poll_mode

bool ExternalStreamHandler::m_poll_mode {false}
private

Definition at line 121 of file ExternalStreamHandler.h.

Referenced by OpenApp(), ReplayStream(), run(), and StopStreaming().

◆ m_apiVersion

int ExternalStreamHandler::m_apiVersion {1}
private

◆ m_serialNo

uint ExternalStreamHandler::m_serialNo {0}
private

Definition at line 124 of file ExternalStreamHandler.h.

Referenced by ProcessVer2().

◆ m_hasTuner

bool ExternalStreamHandler::m_hasTuner
private

Definition at line 125 of file ExternalStreamHandler.h.

Referenced by OpenApp().

◆ m_hasPictureAttributes

bool ExternalStreamHandler::m_hasPictureAttributes
private

Definition at line 126 of file ExternalStreamHandler.h.

Referenced by OpenApp().

◆ m_replay_buffer

QByteArray ExternalStreamHandler::m_replay_buffer
private

Definition at line 128 of file ExternalStreamHandler.h.

Referenced by ReplayStream(), and run().

◆ m_replay

bool ExternalStreamHandler::m_replay {false}
private

Definition at line 129 of file ExternalStreamHandler.h.

Referenced by ReplayStream(), and run().

◆ m_xon

bool ExternalStreamHandler::m_xon {false}
private

Definition at line 130 of file ExternalStreamHandler.h.

Referenced by ReplayStream(), run(), and StopStreaming().

◆ s_handlers_lock

QMutex ExternalStreamHandler::s_handlers_lock
staticprivate

Definition at line 133 of file ExternalStreamHandler.h.

Referenced by Get(), and Return().

◆ s_handlers

QMap< int, ExternalStreamHandler * > ExternalStreamHandler::s_handlers
staticprivate

Definition at line 134 of file ExternalStreamHandler.h.

Referenced by Get(), and Return().

◆ s_handlers_refcnt

QMap< int, uint > ExternalStreamHandler::s_handlers_refcnt
staticprivate

Definition at line 135 of file ExternalStreamHandler.h.

Referenced by Get(), and Return().

◆ m_streaming_cnt

QAtomicInt ExternalStreamHandler::m_streaming_cnt
private

Definition at line 137 of file ExternalStreamHandler.h.

Referenced by StartStreaming(), StopStreaming(), and StreamingCount().

◆ m_stream_lock

QMutex ExternalStreamHandler::m_stream_lock
private

Definition at line 138 of file ExternalStreamHandler.h.

Referenced by run(), StartStreaming(), and StopStreaming().

◆ m_replay_lock

QMutex ExternalStreamHandler::m_replay_lock
private

Definition at line 139 of file ExternalStreamHandler.h.

◆ m_process_lock

QMutex ExternalStreamHandler::m_process_lock
private

Definition at line 140 of file ExternalStreamHandler.h.

Referenced by ProcessCommand().


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