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.
remotesink.h
Go to the documentation of this file.
1 // Copyright (C) 2018 Edouard Griffiths, F4EXB. //
3 // //
4 // Remote sink channel (Rx) UDP sender thread //
5 // //
6 // SDRangel can work as a detached SDR front end. With this plugin it can //
7 // sends the I/Q samples stream to another SDRangel instance via UDP. //
8 // It is controlled via a Web REST API. //
9 // //
10 // This program is free software; you can redistribute it and/or modify //
11 // it under the terms of the GNU General Public License as published by //
12 // the Free Software Foundation as version 3 of the License, or //
13 // (at your option) any later version. //
14 // //
15 // This program is distributed in the hope that it will be useful, //
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
18 // GNU General Public License V3 for more details. //
19 // //
20 // You should have received a copy of the GNU General Public License //
21 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
23 
24 #ifndef INCLUDE_REMOTESINK_H_
25 #define INCLUDE_REMOTESINK_H_
26 
28 #include <QObject>
29 #include <QMutex>
30 #include <QNetworkRequest>
31 
32 #include "dsp/basebandsamplesink.h"
33 #include "channel/channelapi.h"
34 #include "remotesinksettings.h"
35 
36 class QNetworkAccessManager;
37 class QNetworkReply;
38 class DeviceAPI;
40 class DownChannelizer;
41 class RemoteSinkThread;
42 
43 class RemoteSink : public BasebandSampleSink, public ChannelAPI {
44  Q_OBJECT
45 public:
48 
49  public:
50  const RemoteSinkSettings& getSettings() const { return m_settings; }
51  bool getForce() const { return m_force; }
52 
53  static MsgConfigureRemoteSink* create(const RemoteSinkSettings& settings, bool force)
54  {
55  return new MsgConfigureRemoteSink(settings, force);
56  }
57 
58  private:
60  bool m_force;
61 
62  MsgConfigureRemoteSink(const RemoteSinkSettings& settings, bool force) :
63  Message(),
64  m_settings(settings),
65  m_force(force)
66  { }
67  };
68 
71 
72  public:
73  static MsgSampleRateNotification* create(int sampleRate) {
74  return new MsgSampleRateNotification(sampleRate);
75  }
76 
77  int getSampleRate() const { return m_sampleRate; }
78 
79  private:
80 
81  MsgSampleRateNotification(int sampleRate) :
82  Message(),
83  m_sampleRate(sampleRate)
84  { }
85 
87  };
88 
91 
92  public:
93  int getLog2Decim() const { return m_log2Decim; }
94  int getFilterChainHash() const { return m_filterChainHash; }
95 
96  static MsgConfigureChannelizer* create(int sampleRate, int centerFrequency)
97  {
98  return new MsgConfigureChannelizer(sampleRate, centerFrequency);
99  }
100 
101  private:
102  unsigned int m_log2Decim;
103  unsigned int m_filterChainHash;
104 
105  MsgConfigureChannelizer(unsigned int log2Decim, int filterChainHash) :
106  Message(),
107  m_log2Decim(log2Decim),
108  m_filterChainHash(filterChainHash)
109  { }
110  };
111 
112  RemoteSink(DeviceAPI *deviceAPI);
113  virtual ~RemoteSink();
114  virtual void destroy() { delete this; }
115 
116  virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool po);
117  virtual void start();
118  virtual void stop();
119  virtual bool handleMessage(const Message& cmd);
120 
121  virtual void getIdentifier(QString& id) { id = objectName(); }
122  virtual void getTitle(QString& title) { title = "Remote Sink"; }
123  virtual qint64 getCenterFrequency() const { return m_frequencyOffset; }
124 
125  virtual QByteArray serialize() const;
126  virtual bool deserialize(const QByteArray& data);
127 
128  virtual int getNbSinkStreams() const { return 1; }
129  virtual int getNbSourceStreams() const { return 0; }
130 
131  virtual qint64 getStreamCenterFrequency(int streamIndex, bool sinkElseSource) const
132  {
133  (void) streamIndex;
134  (void) sinkElseSource;
135  return m_frequencyOffset;
136  }
137 
138  virtual int webapiSettingsGet(
140  QString& errorMessage);
141 
142  virtual int webapiSettingsPutPatch(
143  bool force,
144  const QStringList& channelSettingsKeys,
146  QString& errorMessage);
147 
149  void setCenterFrequency(uint64_t centerFrequency) { m_centerFrequency = centerFrequency; }
150 
152  void setSampleRate(uint32_t sampleRate) { m_sampleRate = sampleRate; }
153 
154  void setNbBlocksFEC(int nbBlocksFEC);
155  void setTxDelay(int txDelay, int nbBlocksFEC);
156  void setDataAddress(const QString& address) { m_dataAddress = address; }
157  void setDataPort(uint16_t port) { m_dataPort = port; }
158  void setChannelizer(unsigned int log2Decim, unsigned int filterChainHash);
159 
160  static const QString m_channelIdURI;
161  static const QString m_channelId;
162 
163 signals:
164  void dataBlockAvailable(RemoteDataBlock *dataBlock);
165 
166 private:
170  bool m_running;
171 
174 
182 
189  QString m_dataAddress;
191  QNetworkAccessManager *m_networkManager;
192  QNetworkRequest m_networkRequest;
193 
194  void applySettings(const RemoteSinkSettings& settings, bool force = false);
198  void webapiReverseSendSettings(QList<QString>& channelSettingsKeys, const RemoteSinkSettings& settings, bool force);
199 
200 private slots:
201  void networkManagerFinished(QNetworkReply *reply);
202 };
203 
204 #endif /* INCLUDE_REMOTESINK_H_ */
virtual int getNbSinkStreams() const
Definition: remotesink.h:128
void networkManagerFinished(QNetworkReply *reply)
Definition: remotesink.cpp:634
void validateFilterChainHash(RemoteSinkSettings &settings)
Definition: remotesink.cpp:415
int m_txDelay
Definition: remotesink.h:188
uint32_t m_sampleRate
Definition: remotesink.h:185
virtual void start()
Definition: remotesink.cpp:233
uint16_t m_frameCount
transmission frame count
Definition: remotesink.h:176
void webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings &response, const RemoteSinkSettings &settings)
Definition: remotesink.cpp:542
virtual ~RemoteSink()
Definition: remotesink.cpp:87
RemoteSinkThread * m_sinkThread
Definition: remotesink.h:173
uint64_t m_centerFrequency
Definition: remotesink.h:183
QNetworkAccessManager * m_networkManager
Definition: remotesink.h:191
static MsgConfigureChannelizer * create(int sampleRate, int centerFrequency)
Definition: remotesink.h:96
__int64 int64_t
Definition: rtptypes_win.h:47
QNetworkRequest m_networkRequest
Definition: remotesink.h:192
int64_t m_frequencyOffset
Definition: remotesink.h:184
RemoteMetaDataFEC m_currentMetaFEC
Definition: remotesink.h:179
QString m_dataAddress
Definition: remotesink.h:189
unsigned int uint32_t
Definition: rtptypes_win.h:46
const RemoteSinkSettings & getSettings() const
Definition: remotesink.h:50
RemoteSinkSettings m_settings
Definition: remotesink.h:172
virtual qint64 getStreamCenterFrequency(int streamIndex, bool sinkElseSource) const
Definition: remotesink.h:131
void calculateFrequencyOffset()
Definition: remotesink.cpp:426
DownChannelizer * m_channelizer
Definition: remotesink.h:169
RemoteDataBlock * m_dataBlock
Definition: remotesink.h:180
void setDataAddress(const QString &address)
Definition: remotesink.h:156
MsgConfigureRemoteSink(const RemoteSinkSettings &settings, bool force)
Definition: remotesink.h:62
uint32_t m_deviceSampleRate
Definition: remotesink.h:186
ThreadedBasebandSampleSink * m_threadedChannelizer
Definition: remotesink.h:168
virtual qint64 getCenterFrequency() const
Applies to a default stream.
Definition: remotesink.h:123
virtual int getNbSourceStreams() const
Definition: remotesink.h:129
static const QString m_channelIdURI
Definition: remotesink.h:160
virtual void getIdentifier(QString &id)
Definition: remotesink.h:121
static const QString m_channelId
Definition: remotesink.h:161
void setChannelizer(unsigned int log2Decim, unsigned int filterChainHash)
#define MESSAGE_CLASS_DECLARATION
Definition: message.h:43
unsigned short uint16_t
Definition: rtptypes_win.h:44
void applySettings(const RemoteSinkSettings &settings, bool force=false)
Definition: remotesink.cpp:366
int m_txBlockIndex
Current index in blocks to transmit in the Tx row.
Definition: remotesink.h:175
int m_nbBlocksFEC
Definition: remotesink.h:187
void setSampleRate(uint32_t sampleRate)
Definition: remotesink.h:152
virtual void feed(const SampleVector::const_iterator &begin, const SampleVector::const_iterator &end, bool po)
Definition: remotesink.cpp:123
MsgSampleRateNotification(int sampleRate)
Definition: remotesink.h:81
DeviceAPI * m_deviceAPI
Definition: remotesink.h:167
static MsgSampleRateNotification * create(int sampleRate)
Definition: remotesink.h:73
virtual void getTitle(QString &title)
Definition: remotesink.h:122
void setDataPort(uint16_t port)
Definition: remotesink.h:157
virtual int webapiSettingsGet(SWGSDRangel::SWGChannelSettings &response, QString &errorMessage)
Definition: remotesink.cpp:432
bool m_running
Definition: remotesink.h:170
QMutex m_dataBlockMutex
Definition: remotesink.h:181
RemoteSink(DeviceAPI *deviceAPI)
Definition: remotesink.cpp:58
void dataBlockAvailable(RemoteDataBlock *dataBlock)
static MsgConfigureRemoteSink * create(const RemoteSinkSettings &settings, bool force)
Definition: remotesink.h:53
RemoteSinkSettings m_settings
Definition: remotesink.h:59
virtual QByteArray serialize() const
Definition: remotesink.cpp:343
RemoteSuperBlock m_superBlock
Definition: remotesink.h:178
virtual int webapiSettingsPutPatch(bool force, const QStringList &channelSettingsKeys, SWGSDRangel::SWGChannelSettings &response, QString &errorMessage)
Definition: remotesink.cpp:443
MsgConfigureChannelizer(unsigned int log2Decim, int filterChainHash)
Definition: remotesink.h:105
virtual bool deserialize(const QByteArray &data)
Definition: remotesink.cpp:348
int m_sampleIndex
Current sample index in protected block data.
Definition: remotesink.h:177
virtual void destroy()
Definition: remotesink.h:114
uint16_t m_dataPort
Definition: remotesink.h:190
void webapiReverseSendSettings(QList< QString > &channelSettingsKeys, const RemoteSinkSettings &settings, bool force)
Definition: remotesink.cpp:577
void setNbBlocksFEC(int nbBlocksFEC)
Definition: remotesink.cpp:117
virtual void stop()
Definition: remotesink.cpp:253
void setCenterFrequency(uint64_t centerFrequency)
Definition: remotesink.h:149
void setTxDelay(int txDelay, int nbBlocksFEC)
Definition: remotesink.cpp:104
unsigned __int64 uint64_t
Definition: rtptypes_win.h:48
virtual bool handleMessage(const Message &cmd)
Processing of a message. Returns true if message has actually been processed.
Definition: remotesink.cpp:267