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.
udpsinkfecworker.h
Go to the documentation of this file.
1 // Copyright (C) 2017 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_SAMPLESINK_REMOTEOUTPUT_UDPSINKFECWORKER_H_
19 #define PLUGINS_SAMPLESINK_REMOTEOUTPUT_UDPSINKFECWORKER_H_
20 
22 #include <QThread>
23 #include <QMutex>
24 #include <QWaitCondition>
25 #include <QHostAddress>
26 
27 #include "cm256cc/cm256.h"
28 
29 #include "util/messagequeue.h"
30 #include "util/message.h"
31 
32 class QUdpSocket;
33 
34 class UDPSinkFECWorker : public QThread
35 {
36  Q_OBJECT
37 public:
39  {
41  public:
43  uint32_t getNbBlocsFEC() const { return m_nbBlocksFEC; }
44  uint32_t getTxDelay() const { return m_txDelay; }
45  uint16_t getFrameIndex() const { return m_frameIndex; }
46 
48  RemoteSuperBlock *txBlocks,
49  uint32_t nbBlocksFEC,
50  uint32_t txDelay,
51  uint16_t frameIndex)
52  {
53  return new MsgUDPFECEncodeAndSend(txBlocks, nbBlocksFEC, txDelay, frameIndex);
54  }
55 
56  private:
61 
63  RemoteSuperBlock *txBlocks,
64  uint32_t nbBlocksFEC,
65  uint32_t txDelay,
66  uint16_t frameIndex) :
67  m_txBlockx(txBlocks),
68  m_nbBlocksFEC(nbBlocksFEC),
69  m_txDelay(txDelay),
70  m_frameIndex(frameIndex)
71  {}
72  };
73 
75  {
77  public:
78  const QString& getAddress() const { return m_address; }
79  uint16_t getPort() const { return m_port; }
80 
81  static MsgConfigureRemoteAddress* create(const QString& address, uint16_t port)
82  {
83  return new MsgConfigureRemoteAddress(address, port);
84  }
85 
86  private:
87  QString m_address;
89 
90  MsgConfigureRemoteAddress(const QString& address, uint16_t port) :
91  m_address(address),
92  m_port(port)
93  {}
94  };
95 
96  class MsgStartStop : public Message {
98 
99  public:
100  bool getStartStop() const { return m_startStop; }
101 
102  static MsgStartStop* create(bool startStop) {
103  return new MsgStartStop(startStop);
104  }
105 
106  protected:
108 
110  Message(),
111  m_startStop(startStop)
112  { }
113  };
114 
117 
118  void startStop(bool start);
119 
120  void pushTxFrame(RemoteSuperBlock *txBlocks,
121  uint32_t nbBlocksFEC,
122  uint32_t txDelay,
123  uint16_t frameIndex);
124  void setRemoteAddress(const QString& address, uint16_t port);
125 
127 
128 private slots:
129  void handleInputMessages();
130 
131 private:
132  void startWork();
133  void stopWork();
134  void run();
135  void encodeAndTransmit(RemoteSuperBlock *txBlockx, uint16_t frameIndex, uint32_t nbBlocksFEC, uint32_t txDelay);
136 
138  QWaitCondition m_startWaiter;
139  volatile bool m_running;
140  CM256 m_cm256;
142  QUdpSocket *m_udpSocket;
145  QHostAddress m_remoteHostAddress;
146 };
147 
148 #endif /* PLUGINS_SAMPLESINK_REMOTEOUTPUT_UDPSINKFECWORKER_H_ */
QWaitCondition m_startWaiter
static MsgStartStop * create(bool startStop)
QHostAddress m_remoteHostAddress
void pushTxFrame(RemoteSuperBlock *txBlocks, uint32_t nbBlocksFEC, uint32_t txDelay, uint16_t frameIndex)
static MsgUDPFECEncodeAndSend * create(RemoteSuperBlock *txBlocks, uint32_t nbBlocksFEC, uint32_t txDelay, uint16_t frameIndex)
QUdpSocket * m_udpSocket
void encodeAndTransmit(RemoteSuperBlock *txBlockx, uint16_t frameIndex, uint32_t nbBlocksFEC, uint32_t txDelay)
unsigned int uint32_t
Definition: rtptypes_win.h:46
void startStop(bool start)
#define MESSAGE_CLASS_DECLARATION
Definition: message.h:43
unsigned short uint16_t
Definition: rtptypes_win.h:44
MessageQueue m_inputMessageQueue
Queue for asynchronous inbound communication.
MsgConfigureRemoteAddress(const QString &address, uint16_t port)
void setRemoteAddress(const QString &address, uint16_t port)
RemoteSuperBlock * getTxBlocks() const
CM256 m_cm256
CM256 library object.
bool m_cm256Valid
true if CM256 library is initialized correctly
static MsgConfigureRemoteAddress * create(const QString &address, uint16_t port)
MsgUDPFECEncodeAndSend(RemoteSuperBlock *txBlocks, uint32_t nbBlocksFEC, uint32_t txDelay, uint16_t frameIndex)
volatile bool m_running