SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
remotesourcethread.h
Go to the documentation of this file.
1 // Copyright (C) 2018-2019 Edouard Griffiths, F4EXB //
3 // //
4 // This program is free software; you can redistribute it and/or modify //
5 // it under the terms of the GNU General Public License as published by //
6 // the Free Software Foundation as version 3 of the License, or //
7 // (at your option) any later version. //
8 // //
9 // This program is distributed in the hope that it will be useful, //
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
12 // GNU General Public License V3 for more details. //
13 // //
14 // You should have received a copy of the GNU General Public License //
15 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
17 
18 #ifndef PLUGINS_CHANNELTX_REMOTESRC_REMOTESRCTHREAD_H_
19 #define PLUGINS_CHANNELTX_REMOTESRC_REMOTESRCTHREAD_H_
20 
21 #include <QThread>
22 #include <QMutex>
23 #include <QWaitCondition>
24 #include <QHostAddress>
25 
26 #include "util/message.h"
27 #include "util/messagequeue.h"
28 
29 class RemoteDataQueue;
30 class RemoteDataBlock;
31 class QUdpSocket;
32 
33 class RemoteSourceThread : public QThread {
34  Q_OBJECT
35 public:
36  class MsgStartStop : public Message {
38 
39  public:
40  bool getStartStop() const { return m_startStop; }
41 
42  static MsgStartStop* create(bool startStop) {
43  return new MsgStartStop(startStop);
44  }
45 
46  protected:
48 
50  Message(),
51  m_startStop(startStop)
52  { }
53  };
54 
55  class MsgDataBind : public Message {
57 
58  public:
59  QHostAddress getAddress() const { return m_address; }
60  uint16_t getPort() const { return m_port; }
61 
62  static MsgDataBind* create(const QString& address, uint16_t port) {
63  return new MsgDataBind(address, port);
64  }
65 
66  protected:
67  QHostAddress m_address;
69 
70  MsgDataBind(const QString& address, uint16_t port) :
71  Message(),
72  m_port(port)
73  {
74  m_address.setAddress(address);
75  }
76  };
77 
78  RemoteSourceThread(RemoteDataQueue *dataQueue, QObject* parent = 0);
80 
81  void startStop(bool start);
82  void dataBind(const QString& address, uint16_t port);
83 
84 private:
86  QWaitCondition m_startWaiter;
87  volatile bool m_running;
88 
91 
92  QHostAddress m_address;
93  QUdpSocket *m_socket;
94 
95  static const uint32_t m_nbDataBlocks = 4;
97 
98  void startWork();
99  void stopWork();
100 
101  void run();
102 
103 private slots:
104  void handleInputMessages();
105  void readPendingDatagrams();
106 };
107 
108 
109 
110 #endif /* PLUGINS_CHANNELTX_REMOTESRC_REMOTESRCTHREAD_H_ */
QWaitCondition m_startWaiter
RemoteDataQueue * m_dataQueue
volatile bool m_running
static MsgDataBind * create(const QString &address, uint16_t port)
static const uint32_t m_nbDataBlocks
number of data blocks in the ring buffer
unsigned int uint32_t
Definition: rtptypes_win.h:46
#define MESSAGE_CLASS_DECLARATION
Definition: message.h:43
unsigned short uint16_t
Definition: rtptypes_win.h:44
MessageQueue m_inputMessageQueue
void dataBind(const QString &address, uint16_t port)
static MsgStartStop * create(bool startStop)
RemoteDataBlock * m_dataBlocks[m_nbDataBlocks]
ring buffer of data blocks indexed by frame affinity
MsgDataBind(const QString &address, uint16_t port)
void startStop(bool start)
RemoteSourceThread(RemoteDataQueue *dataQueue, QObject *parent=0)