MythTV  master
iptvstreamhandler.h
Go to the documentation of this file.
1 // -*- Mode: c++ -*-
2 
3 #ifndef _IPTVSTREAMHANDLER_H_
4 #define _IPTVSTREAMHANDLER_H_
5 
6 #include <vector>
7 using namespace std;
8 
9 #include <QHostAddress>
10 #include <QUdpSocket>
11 #include <QString>
12 #include <QMutex>
13 #include <QMap>
14 
15 #include <QNetworkAccessManager>
16 #include <QtNetwork>
17 
18 #include "channelutil.h"
19 #include "streamhandler.h"
20 
21 #define IPTV_SOCKET_COUNT 3
22 #define RTCP_TIMER 10
23 
24 class IPTVStreamHandler;
25 class DTVSignalMonitor;
26 class MPEGStreamData;
27 class PacketBuffer;
28 class IPTVChannel;
29 
31 {
32  Q_OBJECT
33 
34  public:
35  IPTVStreamHandlerReadHelper(IPTVStreamHandler *p, QUdpSocket *s, uint stream);
36 
37  public slots:
38  void ReadPending(void);
39 
40  private:
41  IPTVStreamHandler *m_parent {nullptr};
42  QUdpSocket *m_socket {nullptr};
43  QHostAddress m_sender;
45 };
46 
48 {
49  Q_OBJECT
50 
51 public:
53  : m_parent(p) {}
55 
56  void Start(void)
57  {
58  m_timer = startTimer(200);
59  }
60  void StartRTCPRR(void)
61  {
62  m_timer_rtcp = startTimer(RTCP_TIMER * 1000);
63  }
64 
65  void SendRTCPReport(void);
66 
67 private:
68  void timerEvent(QTimerEvent*) override; // QObject
69 
70 private:
71  IPTVStreamHandler *m_parent {nullptr};
72  int m_timer {0};
73  int m_timer_rtcp {0};
74  uint m_last_sequence_number {0};
75  uint m_last_timestamp {0};
76  uint m_previous_last_sequence_number {0};
77  int m_lost {0};
78  int m_lost_interval {0};
79 };
80 
82 {
85  public:
86  static IPTVStreamHandler *Get(const IPTVTuningData &tuning, int inputid);
87  static void Return(IPTVStreamHandler * & ref, int inputid);
88 
90  bool /*allow_section_reader*/ = false,
91  bool /*needs_drb*/ = false,
92  QString output_file = QString()) override // StreamHandler
93  {
94  // Force allow_section_reader and needs_buffering to false;
95  StreamHandler::AddListener(data, false, false, output_file);
96  }
97 
98  protected:
99  explicit IPTVStreamHandler(const IPTVTuningData &tuning, int inputid);
100 
101  void run(void) override; // MThread
102 
103  protected:
105  QUdpSocket *m_sockets[IPTV_SOCKET_COUNT] {};
107  QHostAddress m_sender[IPTV_SOCKET_COUNT];
108  IPTVStreamHandlerWriteHelper *m_write_helper {nullptr};
109  PacketBuffer *m_buffer {nullptr};
110 
112  ushort m_rtsp_rtp_port {0};
113  ushort m_rtsp_rtcp_port {0};
114  uint32_t m_rtsp_ssrc {0};
115  QHostAddress m_rtcp_dest;
116 
117  // for implementing Get & Return
118  static QMutex s_iptvhandlers_lock;
119  static QMap<QString, IPTVStreamHandler*> s_iptvhandlers;
120  static QMap<QString, uint> s_iptvhandlers_refcnt;
121 
122 private:
123  void timerEvent(QTimerEvent*);
124 
125 };
126 
127 #endif // _IPTVSTREAMHANDLER_H_
unsigned int slots[4]
Definition: element.c:38
IPTVTuningData m_tuning
static QMap< QString, IPTVStreamHandler * > s_iptvhandlers
IPTVStreamHandlerWriteHelper(IPTVStreamHandler *p)
#define IPTV_SOCKET_COUNT
static QMap< QString, uint > s_iptvhandlers_refcnt
virtual void AddListener(MPEGStreamData *data, bool allow_section_reader=false, bool needs_buffering=false, QString output_file=QString())
void timerEvent(QTimerEvent *) override
unsigned int uint
Definition: compat.h:140
This class is intended to detect the presence of needed tables.
QHostAddress m_rtcp_dest
static QMutex s_iptvhandlers_lock
Encapsulates data about MPEG stream and emits events for each table.
#define RTCP_TIMER
void AddListener(MPEGStreamData *data, bool=false, bool=false, QString output_file=QString()) override