MythTV  master
satiprtsp.h
Go to the documentation of this file.
1 
3 #ifndef SATIPRTSP_H
4 #define SATIPRTSP_H
5 
6 // C++ includes
7 #include <cstdint>
8 
9 // Qt includes
10 #include <QObject>
11 #include <QMap>
12 #include <QString>
13 #include <QMutex>
14 #include <QUrl>
15 #include <QTimerEvent>
16 #include <QUdpSocket>
17 #include <QTime>
18 
19 // MythTV includes
20 #include "mythchrono.h"
21 #include "packetbuffer.h"
22 
23 class SatIPRTSP;
24 class SatIPStreamHandler;
25 using Headers = QMap<QString, QString>;
26 
27 // --- SatIPRTSPReadHelper ---------------------------------------------------
28 
29 class SatIPRTSPReadHelper : public QObject
30 {
31  friend class SatIPRTSP;
32  Q_OBJECT
33 
34  public:
35  explicit SatIPRTSPReadHelper(SatIPRTSP *p);
36  ~SatIPRTSPReadHelper() override;
37 
38  public slots:
39  void ReadPending(void);
40 
41  protected:
42  QUdpSocket *m_socket {nullptr};
43 
44  private:
45  SatIPRTSP *m_parent {nullptr};
46 };
47 
48 // --- SatIPRTCPReadHelper ---------------------------------------------------
49 
50 class SatIPRTCPReadHelper : public QObject
51 {
52  friend class SatIPRTSP;
53  Q_OBJECT
54 
55  public:
56  explicit SatIPRTCPReadHelper(SatIPRTSP *p);
57  ~SatIPRTCPReadHelper() override;
58 
59  public slots:
60  void ReadPending(void);
61 
62  protected:
63  QUdpSocket *m_socket {nullptr};
64 
65  private:
66  SatIPRTSP *m_parent {nullptr};
67 };
68 
69 // --- SatIPRTSPWriteHelper --------------------------------------------------
70 
71 class SatIPRTSPWriteHelper : public QObject
72 {
73  Q_OBJECT
74 
75  public:
77 
78  protected:
79  void timerEvent(QTimerEvent* /*event*/) override; // QObject
80 
81  private:
82  SatIPRTSP *m_parent {nullptr};
84  int m_timer {0};
88 };
89 
90 // --- SatIPRTSP -------------------------------------------------------------
91 
92 class SatIPRTSP : public QObject
93 {
94  friend class SatIPRTSPReadHelper;
95  friend class SatIPRTCPReadHelper;
96  friend class SatIPRTSPWriteHelper;
97  friend class SatIPSignalMonitor;
98 
99  Q_OBJECT
100 
101  public:
102  explicit SatIPRTSP(SatIPStreamHandler* handler);
103  ~SatIPRTSP() override;
104 
105  bool Setup(const QUrl& url);
106  bool Play(QStringList &pids);
107  bool Teardown();
108 
109  bool HasLock();
110  int GetSignalStrength();
111 
112  protected:
113  void timerEvent(QTimerEvent* /*timerEvent*/) override; // QObject
114  void SetSigmonValues(bool lock, int level);
115 
116  signals:
117  void startKeepAlive(std::chrono::milliseconds timeout);
118  void stopKeepAlive(void);
119 
120  protected slots:
121  void startKeepAliveRequested(std::chrono::milliseconds timeout);
122  void stopKeepAliveRequested(void);
123 
124  protected:
126  PacketBuffer *m_buffer {nullptr};
127 
128  private:
129  bool sendMessage(const QUrl& url, const QString& msg, QStringList* additionalHeaders = nullptr);
130 
131  private:
133 
135  QString m_sessionid;
136  QString m_streamid;
138 
139  int m_timer {0};
140  std::chrono::milliseconds m_timeout {0ms};
141 
143  QMutex m_sigmonLock;
144 
145  bool m_valid {false};
146  bool m_validOld {false};
147  bool m_hasLock {false};
149 
153 };
154 
155 #endif // SATIPRTSP_H
SatIPRTSPReadHelper
Definition: satiprtsp.h:29
SatIPSignalMonitor
Definition: satipsignalmonitor.h:11
SatIPRTSP::m_valid
bool m_valid
Definition: satiprtsp.h:145
SatIPRTSP::Setup
bool Setup(const QUrl &url)
Definition: satiprtsp.cpp:104
SatIPRTSP::stopKeepAlive
void stopKeepAlive(void)
hardwareprofile.smolt.timeout
float timeout
Definition: smolt.py:103
SatIPRTCPReadHelper::m_parent
SatIPRTSP * m_parent
Definition: satiprtsp.h:66
SatIPRTSP::Play
bool Play(QStringList &pids)
Definition: satiprtsp.cpp:180
SatIPRTSP::startKeepAlive
void startKeepAlive(std::chrono::milliseconds timeout)
SatIPRTSPWriteHelper::m_timer
int m_timer
Definition: satiprtsp.h:84
SatIPRTSP::SatIPRTSP
SatIPRTSP(SatIPStreamHandler *handler)
Definition: satiprtsp.cpp:37
SatIPRTSP::GetSignalStrength
int GetSignalStrength()
Definition: satiprtsp.cpp:253
SatIPRTSP::m_buffer
PacketBuffer * m_buffer
Definition: satiprtsp.h:126
PacketBuffer
Definition: packetbuffer.h:15
SatIPRTSPWriteHelper::m_lastTimeStamp
uint m_lastTimeStamp
Definition: satiprtsp.h:86
SatIPRTSP::sendMessage
bool sendMessage(const QUrl &url, const QString &msg, QStringList *additionalHeaders=nullptr)
Definition: satiprtsp.cpp:266
SatIPRTSP::m_writeHelper
SatIPRTSPWriteHelper * m_writeHelper
Definition: satiprtsp.h:151
SatIPRTSP::stopKeepAliveRequested
void stopKeepAliveRequested(void)
Definition: satiprtsp.cpp:397
SatIPRTSP::m_requestUrl
QUrl m_requestUrl
Definition: satiprtsp.h:125
SatIPRTSPWriteHelper
Definition: satiprtsp.h:71
SatIPRTSP::m_headers
Headers m_headers
Definition: satiprtsp.h:137
SatIPRTSP::startKeepAliveRequested
void startKeepAliveRequested(std::chrono::milliseconds timeout)
Definition: satiprtsp.cpp:388
SatIPRTSP::SetSigmonValues
void SetSigmonValues(bool lock, int level)
Definition: satiprtsp.cpp:259
SatIPRTSP::m_readHelper
SatIPRTSPReadHelper * m_readHelper
Definition: satiprtsp.h:150
SatIPRTSP::m_rtcpReadHelper
SatIPRTCPReadHelper * m_rtcpReadHelper
Definition: satiprtsp.h:152
SatIPRTSPWriteHelper::SatIPRTSPWriteHelper
SatIPRTSPWriteHelper(SatIPRTSP *parent, SatIPStreamHandler *handler)
Definition: satiprtsp.cpp:540
SatIPRTCPReadHelper::m_socket
QUdpSocket * m_socket
Definition: satiprtsp.h:63
SatIPRTSPReadHelper::~SatIPRTSPReadHelper
~SatIPRTSPReadHelper() override
Definition: satiprtsp.cpp:438
SatIPRTSP::timerEvent
void timerEvent(QTimerEvent *) override
Definition: satiprtsp.cpp:407
hardwareprofile.config.p
p
Definition: config.py:33
SatIPRTSP::HasLock
bool HasLock()
Definition: satiprtsp.cpp:247
SatIPRTCPReadHelper::SatIPRTCPReadHelper
SatIPRTCPReadHelper(SatIPRTSP *p)
Definition: satiprtsp.cpp:465
SatIPRTCPReadHelper::~SatIPRTCPReadHelper
~SatIPRTCPReadHelper() override
Definition: satiprtsp.cpp:477
SatIPRTSP::m_streamid
QString m_streamid
Definition: satiprtsp.h:136
SatIPRTSP::m_ctrlSocketLock
QMutex m_ctrlSocketLock
Definition: satiprtsp.h:142
SatIPRTSP::Teardown
bool Teardown()
Definition: satiprtsp.cpp:214
uint
unsigned int uint
Definition: compat.h:140
SatIPRTSP::~SatIPRTSP
~SatIPRTSP() override
Definition: satiprtsp.cpp:96
SatIPRTSP::m_timer
int m_timer
Definition: satiprtsp.h:139
SatIPRTSPReadHelper::m_socket
QUdpSocket * m_socket
Definition: satiprtsp.h:42
SatIPRTSP::m_validOld
bool m_validOld
Definition: satiprtsp.h:146
SatIPRTSP::m_cseq
uint m_cseq
Definition: satiprtsp.h:134
SatIPRTSP::m_hasLock
bool m_hasLock
Definition: satiprtsp.h:147
SatIPRTSPReadHelper::SatIPRTSPReadHelper
SatIPRTSPReadHelper(SatIPRTSP *p)
Definition: satiprtsp.cpp:426
SatIPRTCPReadHelper::ReadPending
void ReadPending(void)
Definition: satiprtsp.cpp:483
SatIPRTSP::m_sessionid
QString m_sessionid
Definition: satiprtsp.h:135
SatIPRTSP
Definition: satiprtsp.h:92
SatIPRTCPReadHelper
Definition: satiprtsp.h:50
mythchrono.h
SatIPRTSP::m_sigmonLock
QMutex m_sigmonLock
Definition: satiprtsp.h:143
SatIPRTSP::m_streamHandler
const SatIPStreamHandler * m_streamHandler
Definition: satiprtsp.h:132
Headers
QMap< QString, QString > Headers
Definition: satiprtsp.h:25
SatIPRTSPWriteHelper::m_previousLastSequenceNumber
uint m_previousLastSequenceNumber
Definition: satiprtsp.h:87
SatIPRTSPWriteHelper::m_parent
SatIPRTSP * m_parent
Definition: satiprtsp.h:82
SatIPRTSPReadHelper::m_parent
SatIPRTSP * m_parent
Definition: satiprtsp.h:45
SatIPRTSP::m_signalStrength
int m_signalStrength
Definition: satiprtsp.h:148
SatIPRTSPWriteHelper::m_streamHandler
SatIPStreamHandler * m_streamHandler
Definition: satiprtsp.h:83
SatIPRTSP::m_timeout
std::chrono::milliseconds m_timeout
Definition: satiprtsp.h:140
SatIPRTSPWriteHelper::timerEvent
void timerEvent(QTimerEvent *) override
Definition: satiprtsp.cpp:547
packetbuffer.h
SatIPRTSPWriteHelper::m_lastSequenceNumber
uint m_lastSequenceNumber
Definition: satiprtsp.h:85
SatIPStreamHandler
Definition: satipstreamhandler.h:28
SatIPRTSPReadHelper::ReadPending
void ReadPending(void)
Definition: satiprtsp.cpp:443