MythTV  master
cetonrtsp.h
Go to the documentation of this file.
1 
7 #ifndef CETONRTSP_H
8 #define CETONRTSP_H
9 
10 #include <cstdint>
11 
12 #include <QObject>
13 #include <QMap>
14 #include <QString>
15 #include <QMutex>
16 #include <QUrl>
17 #include <QTimerEvent>
18 
19 class QTcpSocket;
20 class QUdpSocket;
21 
22 typedef QMap<QString, QString> Params;
23 
24 class CetonRTSP : QObject
25 {
26  Q_OBJECT
27 
28  public:
29  explicit CetonRTSP(const QString &ip, uint tuner, ushort port);
30  explicit CetonRTSP(const QUrl&);
31  ~CetonRTSP();
32 
33  bool GetOptions(QStringList &options);
34  bool Describe(void);
35  bool Setup(ushort clientPort1, ushort clientPort2,
36  ushort &rtpPort, ushort &rtcpPort, uint32_t &ssrc);
37  bool Play(void);
38  bool Teardown(void);
39 
40  void StartKeepAlive(void);
41  void StopKeepAlive(void);
42 
43 protected:
44  bool ProcessRequest(
45  const QString &method, const QStringList *headers = nullptr,
46  bool use_control = false, bool waitforanswer = true,
47  const QString &alternative = QString());
48 
49  private:
50  QStringList splitLines(const QByteArray &lines);
51  QString readParameters(const QString &key, Params &parameters);
52  QUrl GetBaseUrl(void);
53  void timerEvent(QTimerEvent*) override; // QObject
54 
55  QTcpSocket *m_socket {nullptr};
57  QString m_sessionId {"0"};
60 
61  int m_responseCode {-1};
64  QByteArray m_responseContent;
65  int m_timeout {60};
66  int m_timer {0};
67  bool m_canGetParameter {false};
68 
69  static QMutex s_rtspMutex;
70 
71 };
72 
73 #endif // CETONRTSP_H
QTcpSocket * m_socket
Definition: cetonrtsp.h:55
QUrl GetBaseUrl(void)
Return the base URL for the last DESCRIBE answer.
Definition: cetonrtsp.cpp:309
QString readParameters(const QString &key, Params &parameters)
readParameters.
Definition: cetonrtsp.cpp:278
QMap< QString, QString > Params
Definition: cetonrtsp.h:20
bool Setup(ushort clientPort1, ushort clientPort2, ushort &rtpPort, ushort &rtcpPort, uint32_t &ssrc)
Definition: cetonrtsp.cpp:393
QUrl m_controlUrl
Definition: cetonrtsp.h:59
unsigned int uint
Definition: compat.h:140
QString m_responseMessage
Definition: cetonrtsp.h:62
uint m_sequenceNumber
Definition: cetonrtsp.h:56
void timerEvent(QTimerEvent *) override
Definition: cetonrtsp.cpp:492
bool Describe(void)
Definition: cetonrtsp.cpp:322
QStringList splitLines(const QByteArray &lines)
splitLines.
Definition: cetonrtsp.cpp:255
int m_responseCode
Definition: cetonrtsp.h:61
bool Play(void)
Definition: cetonrtsp.cpp:449
int m_timeout
Definition: cetonrtsp.h:65
Params m_responseHeaders
Definition: cetonrtsp.h:63
void StopKeepAlive(void)
Definition: cetonrtsp.cpp:482
QUrl m_requestUrl
Definition: cetonrtsp.h:58
bool GetOptions(QStringList &options)
Definition: cetonrtsp.cpp:240
CetonRTSP(const QString &ip, uint tuner, ushort port)
Definition: cetonrtsp.cpp:22
QByteArray m_responseContent
Definition: cetonrtsp.h:64
bool Teardown(void)
Definition: cetonrtsp.cpp:457
bool ProcessRequest(const QString &method, const QStringList *headers=nullptr, bool use_control=false, bool waitforanswer=true, const QString &alternative=QString())
Definition: cetonrtsp.cpp:45
int m_timer
Definition: cetonrtsp.h:66
void StartKeepAlive(void)
Definition: cetonrtsp.cpp:472
static QMutex s_rtspMutex
Definition: cetonrtsp.h:69
bool m_canGetParameter
Definition: cetonrtsp.h:67
QString m_sessionId
Definition: cetonrtsp.h:57