MythTV
master
|
#include <ExternalStreamHandler.h>
Public Member Functions | |
ExternalStreamHandler (const QString &path, int inputid, int majorid) | |
~ExternalStreamHandler (void) override | |
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, std::chrono::milliseconds timeout=4s, uint retry_cnt=3) |
bool | ProcessVer1 (const QString &cmd, QString &result, std::chrono::milliseconds timeout, uint retry_cnt) |
bool | ProcessVer2 (const QString &command, QString &result, std::chrono::milliseconds timeout, uint retry_cnt) |
![]() | |
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... | |
Static Public Member Functions | |
static ExternalStreamHandler * | Get (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_ioLock |
ExternIO * | m_io {nullptr} |
QStringList | m_args |
QString | m_app |
bool | m_tsOpen {false} |
int | m_ioErrCnt {0} |
bool | m_pollMode {false} |
int | m_apiVersion {1} |
uint | m_serialNo {0} |
bool | m_hasTuner {false} |
bool | m_hasPictureAttributes {false} |
QByteArray | m_replayBuffer |
bool | m_replay {false} |
bool | m_xon {false} |
QAtomicInt | m_streamingCnt |
QMutex | m_streamLock |
QMutex | m_replayLock |
QMutex | m_processLock |
Static Private Attributes | |
static QMutex | s_handlersLock |
static QMap< int, ExternalStreamHandler * > | s_handlers |
static QMap< int, uint > | s_handlersRefCnt |
Additional Inherited Members | |
![]() | |
using | StreamDataList = QHash< MPEGStreamData *, QString > |
![]() | |
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 PIDInfo * | CreatePIDInfo (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... | |
![]() | |
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 | |
MThread & | operator= (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... | |
![]() | |
virtual | ~DeviceReaderCB ()=default |
![]() | |
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) |
![]() | |
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< uint > | m_eitPids |
PIDInfoMap | m_pidInfo |
uint | m_openPidFilters {0} |
bool | m_filtersChanged {false} |
MythTimer | m_cycleTimer |
ThreadedFileWriter * | m_mptsTfw {nullptr} |
QSet< QString > | m_mptsFiles |
QString | m_mptsBaseFile |
QMutex | m_mptsLock |
QRecursiveMutex | m_listenerLock |
StreamDataList | m_streamDataList |
![]() | |
MThreadInternal * | m_thread {nullptr} |
QRunnable * | m_runnable {nullptr} |
bool | m_prologExecuted {true} |
bool | m_epilogExecuted {true} |
Definition at line 68 of file ExternalStreamHandler.h.
|
private |
Enumerator | |
---|---|
MAX_API_VERSION | |
TS_PACKET_SIZE | |
PACKET_SIZE | |
TOO_FAST_SIZE |
Definition at line 70 of file ExternalStreamHandler.h.
|
explicit |
Definition at line 535 of file ExternalStreamHandler.cpp.
Referenced by Get().
|
inlineoverride |
Definition at line 83 of file ExternalStreamHandler.h.
|
static |
Definition at line 455 of file ExternalStreamHandler.cpp.
Referenced by ExternalRecChannelFetcher::ExternalRecChannelFetcher(), ExternalSignalMonitor::ExternalSignalMonitor(), ExternalChannel::Open(), and ExternalRecorder::Open().
|
static |
Definition at line 486 of file ExternalStreamHandler.cpp.
Referenced by ExternalChannel::Close(), ExternalRecorder::Close(), ExternalRecChannelFetcher::Close(), ExternalSignalMonitor::ExternalSignalMonitor(), ExternalRecorder::Open(), and ExternalSignalMonitor::~ExternalSignalMonitor().
|
overridevirtual |
Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.
Reimplemented from MThread.
Definition at line 574 of file ExternalStreamHandler.cpp.
|
overridevirtual |
Implements DeviceReaderCB.
Definition at line 1559 of file ExternalStreamHandler.cpp.
|
inline |
Definition at line 88 of file ExternalStreamHandler.h.
Referenced by ExternalChannel::GetDescription().
QString ExternalStreamHandler::UpdateDescription | ( | void | ) |
Definition at line 891 of file ExternalStreamHandler.cpp.
Referenced by OpenApp(), StartStreaming(), and ExternalChannel::UpdateDescription().
bool ExternalStreamHandler::IsAppOpen | ( | void | ) |
Definition at line 999 of file ExternalStreamHandler.cpp.
Referenced by ExternalChannel::Open(), ExternalRecorder::Open(), OpenApp(), StartStreaming(), and StopStreaming().
bool ExternalStreamHandler::IsTSOpen | ( | void | ) |
Definition at line 1012 of file ExternalStreamHandler.cpp.
Referenced by run().
|
inline |
Definition at line 92 of file ExternalStreamHandler.h.
Referenced by ExternalChannel::Tune(), and ExternalRecChannelFetcher::Valid().
|
inline |
Definition at line 93 of file ExternalStreamHandler.h.
bool ExternalStreamHandler::RestartStream | ( | void | ) |
Definition at line 1064 of file ExternalStreamHandler.cpp.
Referenced by run().
|
inline |
Definition at line 97 of file ExternalStreamHandler.h.
Definition at line 98 of file ExternalStreamHandler.h.
void ExternalStreamHandler::ReplayStream | ( | void | ) |
Definition at line 1081 of file ExternalStreamHandler.cpp.
bool ExternalStreamHandler::StartStreaming | ( | void | ) |
Definition at line 1124 of file ExternalStreamHandler.cpp.
Referenced by RestartStream(), ExternalRecorder::StartStreaming(), and ExternalSignalMonitor::UpdateValues().
bool ExternalStreamHandler::StopStreaming | ( | void | ) |
Definition at line 1172 of file ExternalStreamHandler.cpp.
Referenced by RestartStream(), ExternalSignalMonitor::Stop(), and ExternalRecorder::StopStreaming().
bool ExternalStreamHandler::CheckForError | ( | void | ) |
Definition at line 1500 of file ExternalStreamHandler.cpp.
Referenced by run().
void ExternalStreamHandler::PurgeBuffer | ( | void | ) |
Definition at line 1549 of file ExternalStreamHandler.cpp.
Referenced by StopStreaming().
bool ExternalStreamHandler::ProcessCommand | ( | const QString & | cmd, |
QString & | result, | ||
std::chrono::milliseconds | timeout = 4s , |
||
uint | retry_cnt = 3 |
||
) |
Definition at line 1231 of file ExternalStreamHandler.cpp.
Referenced by CloseApp(), ExternalRecChannelFetcher::FetchChannel(), ExternalSignalMonitor::GetLockTimeout(), ExternalSignalMonitor::GetSignalStrengthPercent(), ExternalChannel::GetTuneStatus(), ExternalSignalMonitor::HasLock(), IsAppOpen(), IsTSOpen(), ExternalRecChannelFetcher::LoadChannels(), OpenApp(), ReplayStream(), run(), SetAPIVersion(), StartStreaming(), StopStreaming(), ExternalChannel::Tune(), and UpdateDescription().
bool ExternalStreamHandler::ProcessVer1 | ( | const QString & | cmd, |
QString & | result, | ||
std::chrono::milliseconds | timeout, | ||
uint | retry_cnt | ||
) |
Definition at line 1248 of file ExternalStreamHandler.cpp.
Referenced by ProcessCommand().
bool ExternalStreamHandler::ProcessVer2 | ( | const QString & | command, |
QString & | result, | ||
std::chrono::milliseconds | timeout, | ||
uint | retry_cnt | ||
) |
Definition at line 1354 of file ExternalStreamHandler.cpp.
Referenced by ProcessCommand().
|
private |
Definition at line 569 of file ExternalStreamHandler.cpp.
Referenced by RestartStream(), run(), StartStreaming(), and StopStreaming().
|
private |
Definition at line 861 of file ExternalStreamHandler.cpp.
Referenced by OpenApp().
|
private |
Definition at line 906 of file ExternalStreamHandler.cpp.
Referenced by ExternalStreamHandler().
|
private |
Definition at line 1026 of file ExternalStreamHandler.cpp.
Referenced by run(), and ~ExternalStreamHandler().
|
private |
Definition at line 122 of file ExternalStreamHandler.h.
Referenced by GetDescription(), and UpdateDescription().
|
private |
Definition at line 123 of file ExternalStreamHandler.h.
Referenced by Return().
|
private |
Definition at line 124 of file ExternalStreamHandler.h.
Referenced by CheckForError(), CloseApp(), OpenApp(), ProcessVer1(), and ProcessVer2().
|
private |
Definition at line 125 of file ExternalStreamHandler.h.
Referenced by CheckForError(), CloseApp(), IsAppOpen(), OpenApp(), ProcessVer1(), ProcessVer2(), PurgeBuffer(), and run().
|
private |
Definition at line 126 of file ExternalStreamHandler.h.
Referenced by CloseApp(), ExternalStreamHandler(), and OpenApp().
|
private |
Definition at line 127 of file ExternalStreamHandler.h.
Referenced by ExternalStreamHandler(), and OpenApp().
Definition at line 128 of file ExternalStreamHandler.h.
Referenced by IsTSOpen().
|
private |
Definition at line 129 of file ExternalStreamHandler.h.
Referenced by ProcessVer1(), and ProcessVer2().
Definition at line 130 of file ExternalStreamHandler.h.
Referenced by OpenApp(), ReplayStream(), run(), and StopStreaming().
|
private |
Definition at line 132 of file ExternalStreamHandler.h.
Referenced by CheckForError(), OpenApp(), ProcessCommand(), SetAPIVersion(), and UpdateDescription().
|
private |
Definition at line 133 of file ExternalStreamHandler.h.
Referenced by ProcessVer2().
Definition at line 134 of file ExternalStreamHandler.h.
Referenced by HasTuner(), and OpenApp().
Definition at line 135 of file ExternalStreamHandler.h.
Referenced by HasPictureAttributes(), and OpenApp().
|
private |
Definition at line 137 of file ExternalStreamHandler.h.
Referenced by ReplayStream(), and run().
Definition at line 138 of file ExternalStreamHandler.h.
Referenced by ReplayStream(), run(), and UnlockReplay().
Definition at line 139 of file ExternalStreamHandler.h.
Referenced by ReplayStream(), run(), and StopStreaming().
|
staticprivate |
Definition at line 142 of file ExternalStreamHandler.h.
|
staticprivate |
Definition at line 143 of file ExternalStreamHandler.h.
|
staticprivate |
Definition at line 144 of file ExternalStreamHandler.h.
|
private |
Definition at line 146 of file ExternalStreamHandler.h.
Referenced by StartStreaming(), StopStreaming(), and StreamingCount().
|
private |
Definition at line 147 of file ExternalStreamHandler.h.
Referenced by run(), StartStreaming(), and StopStreaming().
|
private |
Definition at line 148 of file ExternalStreamHandler.h.
Referenced by LockReplay(), and UnlockReplay().
|
private |
Definition at line 149 of file ExternalStreamHandler.h.
Referenced by ProcessCommand().