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.
remotesource.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_REMOTESRC_H_
19 #define PLUGINS_CHANNELTX_REMOTESRC_REMOTESRC_H_
20 
24 
25 #include <QObject>
26 #include <QNetworkRequest>
27 
28 #include "cm256cc/cm256.h"
29 
31 #include "channel/channelapi.h"
32 #include "util/message.h"
33 
34 #include "../remotesource/remotesourcesettings.h"
35 
37 class UpChannelizer;
38 class DeviceAPI;
39 class RemoteSourceThread;
40 class RemoteDataBlock;
41 class QNetworkAccessManager;
42 class QNetworkReply;
43 
45  Q_OBJECT
46 
47 public:
50 
51  public:
52  const RemoteSourceSettings& getSettings() const { return m_settings; }
53  bool getForce() const { return m_force; }
54 
55  static MsgConfigureRemoteSource* create(const RemoteSourceSettings& settings, bool force)
56  {
57  return new MsgConfigureRemoteSource(settings, force);
58  }
59 
60  private:
62  bool m_force;
63 
64  MsgConfigureRemoteSource(const RemoteSourceSettings& settings, bool force) :
65  Message(),
66  m_settings(settings),
67  m_force(force)
68  { }
69  };
70 
73 
74  public:
75  static MsgSampleRateNotification* create(int sampleRate) {
76  return new MsgSampleRateNotification(sampleRate);
77  }
78 
79  int getSampleRate() const { return m_sampleRate; }
80 
81  private:
82 
83  MsgSampleRateNotification(int sampleRate) :
84  Message(),
85  m_sampleRate(sampleRate)
86  { }
87 
89  };
90 
91  class MsgQueryStreamData : public Message {
93  public:
95  return new MsgQueryStreamData();
96  }
97  private:
99  };
100 
101  class MsgReportStreamData : public Message {
103 
104  public:
105  uint32_t get_tv_sec() const { return m_tv_sec; }
106  uint32_t get_tv_usec() const { return m_tv_usec; }
107  uint32_t get_queueSize() const { return m_queueSize; }
108  uint32_t get_queueLength() const { return m_queueLength; }
109  uint32_t get_readSamplesCount() const { return m_readSamplesCount; }
112  uint32_t get_nbOriginalBlocks() const { return m_nbOriginalBlocks; }
113  uint32_t get_nbFECBlocks() const { return m_nbFECBlocks; }
114  uint32_t get_centerFreq() const { return m_centerFreq; }
115  uint32_t get_sampleRate() const { return m_sampleRate; }
116 
118  uint32_t tv_sec,
119  uint32_t tv_usec,
120  uint32_t queueSize,
121  uint32_t queueLength,
122  uint32_t readSamplesCount,
123  uint32_t nbCorrectableErrors,
124  uint32_t nbUncorrectableErrors,
125  uint32_t nbOriginalBlocks,
126  uint32_t nbFECBlocks,
127  uint32_t centerFreq,
128  uint32_t sampleRate)
129  {
130  return new MsgReportStreamData(
131  tv_sec,
132  tv_usec,
133  queueSize,
134  queueLength,
135  readSamplesCount,
136  nbCorrectableErrors,
137  nbUncorrectableErrors,
138  nbOriginalBlocks,
139  nbFECBlocks,
140  centerFreq,
141  sampleRate);
142  }
143 
144  protected:
156 
158  uint32_t tv_sec,
159  uint32_t tv_usec,
160  uint32_t queueSize,
161  uint32_t queueLength,
162  uint32_t readSamplesCount,
163  uint32_t nbCorrectableErrors,
164  uint32_t nbUncorrectableErrors,
165  uint32_t nbOriginalBlocks,
166  uint32_t nbFECBlocks,
167  uint32_t centerFreq,
168  uint32_t sampleRate) :
169  Message(),
170  m_tv_sec(tv_sec),
171  m_tv_usec(tv_usec),
172  m_queueSize(queueSize),
173  m_queueLength(queueLength),
174  m_readSamplesCount(readSamplesCount),
175  m_nbCorrectableErrors(nbCorrectableErrors),
176  m_nbUncorrectableErrors(nbUncorrectableErrors),
177  m_nbOriginalBlocks(nbOriginalBlocks),
178  m_nbFECBlocks(nbFECBlocks),
179  m_centerFreq(centerFreq),
180  m_sampleRate(sampleRate)
181  { }
182  };
183 
184  RemoteSource(DeviceAPI *deviceAPI);
185  ~RemoteSource();
186 
187  virtual void destroy() { delete this; }
188 
189  virtual void pull(Sample& sample);
190  virtual void pullAudio(int nbSamples);
191  virtual void start();
192  virtual void stop();
193  virtual bool handleMessage(const Message& cmd);
194 
195  virtual void getIdentifier(QString& id) { id = objectName(); }
196  virtual void getTitle(QString& title) { title = m_settings.m_title; }
197  virtual qint64 getCenterFrequency() const { return 0; }
198 
199  virtual int getNbSinkStreams() const { return 0; }
200  virtual int getNbSourceStreams() const { return 1; }
201 
202  virtual qint64 getStreamCenterFrequency(int streamIndex, bool sinkElseSource) const
203  {
204  (void) streamIndex;
205  (void) sinkElseSource;
206  return 0;
207  }
208 
209  virtual QByteArray serialize() const;
210  virtual bool deserialize(const QByteArray& data);
211 
212  virtual int webapiSettingsGet(
214  QString& errorMessage);
215 
216  virtual int webapiSettingsPutPatch(
217  bool force,
218  const QStringList& channelSettingsKeys,
220  QString& errorMessage);
221 
222  virtual int webapiReportGet(
224  QString& errorMessage);
225 
226  void setDataLink(const QString& dataAddress, uint16_t dataPort);
227 
228  static const QString m_channelIdURI;
229  static const QString m_channelId;
230 
231 private:
237  CM256 m_cm256;
238  CM256 *m_cm256p;
239  bool m_running;
240 
242 
243  CM256::cm256_block m_cm256DescriptorBlocks[2*RemoteNbOrginalBlocks];
245 
247 
250 
251  QNetworkAccessManager *m_networkManager;
252  QNetworkRequest m_networkRequest;
253 
254  void applySettings(const RemoteSourceSettings& settings, bool force = false);
255  void handleDataBlock(RemoteDataBlock *dataBlock);
256  void printMeta(const QString& header, RemoteMetaDataFEC *metaData);
257  uint32_t calculateDataReadQueueSize(int sampleRate);
260  void webapiReverseSendSettings(QList<QString>& channelSettingsKeys, const RemoteSourceSettings& settings, bool force);
261 
262 private slots:
263  void networkManagerFinished(QNetworkReply *reply);
264  void handleData();
265 };
266 
267 #endif // PLUGINS_CHANNELTX_REMOTESRC_REMOTESRC_H_
uint32_t get_nbOriginalBlocks() const
Definition: remotesource.h:112
RemoteSourceThread * m_sourceThread
Definition: remotesource.h:236
virtual bool deserialize(const QByteArray &data)
QNetworkAccessManager * m_networkManager
Definition: remotesource.h:251
uint32_t m_nbCorrectableErrors
count of correctable errors in number of blocks
Definition: remotesource.h:248
RemoteDataReadQueue m_dataReadQueue
Definition: remotesource.h:246
void webapiReverseSendSettings(QList< QString > &channelSettingsKeys, const RemoteSourceSettings &settings, bool force)
virtual void start()
virtual QByteArray serialize() const
void handleDataBlock(RemoteDataBlock *dataBlock)
virtual int getNbSinkStreams() const
Definition: remotesource.h:199
const RemoteSourceSettings & getSettings() const
Definition: remotesource.h:52
void webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings &response, const RemoteSourceSettings &settings)
void setDataLink(const QString &dataAddress, uint16_t dataPort)
uint32_t get_readSamplesCount() const
Definition: remotesource.h:109
virtual void getTitle(QString &title)
Definition: remotesource.h:196
void applySettings(const RemoteSourceSettings &settings, bool force=false)
unsigned int uint32_t
Definition: rtptypes_win.h:46
virtual void pullAudio(int nbSamples)
DeviceAPI * m_deviceAPI
Definition: remotesource.h:232
#define MESSAGE_CLASS_DECLARATION
Definition: message.h:43
unsigned short uint16_t
Definition: rtptypes_win.h:44
static MsgConfigureRemoteSource * create(const RemoteSourceSettings &settings, bool force)
Definition: remotesource.h:55
MsgReportStreamData(uint32_t tv_sec, uint32_t tv_usec, uint32_t queueSize, uint32_t queueLength, uint32_t readSamplesCount, uint32_t nbCorrectableErrors, uint32_t nbUncorrectableErrors, uint32_t nbOriginalBlocks, uint32_t nbFECBlocks, uint32_t centerFreq, uint32_t sampleRate)
Definition: remotesource.h:157
virtual qint64 getCenterFrequency() const
Applies to a default stream.
Definition: remotesource.h:197
ThreadedBasebandSampleSource * m_threadedChannelizer
Definition: remotesource.h:233
RemoteDataQueue m_dataQueue
Definition: remotesource.h:235
CM256 * m_cm256p
Definition: remotesource.h:238
uint32_t m_nbUncorrectableErrors
count of uncorrectable errors in number of blocks
Definition: remotesource.h:249
virtual qint64 getStreamCenterFrequency(int streamIndex, bool sinkElseSource) const
Definition: remotesource.h:202
virtual bool handleMessage(const Message &cmd)
Processing of a message. Returns true if message has actually been processed.
static MsgSampleRateNotification * create(int sampleRate)
Definition: remotesource.h:75
void printMeta(const QString &header, RemoteMetaDataFEC *metaData)
CM256::cm256_block m_cm256DescriptorBlocks[2 *RemoteNbOrginalBlocks]
CM256 decoder descriptors (block addresses and block indexes)
Definition: remotesource.h:243
static MsgQueryStreamData * create()
Definition: remotesource.h:94
RemoteSourceSettings m_settings
Definition: remotesource.h:241
void networkManagerFinished(QNetworkReply *reply)
virtual void stop()
uint32_t get_nbCorrectableErrors() const
Definition: remotesource.h:110
uint32_t get_nbUncorrectableErrors() const
Definition: remotesource.h:111
virtual void getIdentifier(QString &id)
Definition: remotesource.h:195
MsgConfigureRemoteSource(const RemoteSourceSettings &settings, bool force)
Definition: remotesource.h:64
static MsgReportStreamData * create(uint32_t tv_sec, uint32_t tv_usec, uint32_t queueSize, uint32_t queueLength, uint32_t readSamplesCount, uint32_t nbCorrectableErrors, uint32_t nbUncorrectableErrors, uint32_t nbOriginalBlocks, uint32_t nbFECBlocks, uint32_t centerFreq, uint32_t sampleRate)
Definition: remotesource.h:117
virtual int webapiSettingsGet(SWGSDRangel::SWGChannelSettings &response, QString &errorMessage)
RemoteMetaDataFEC m_currentMeta
Definition: remotesource.h:244
virtual int webapiSettingsPutPatch(bool force, const QStringList &channelSettingsKeys, SWGSDRangel::SWGChannelSettings &response, QString &errorMessage)
static const QString m_channelIdURI
Definition: remotesource.h:228
virtual void pull(Sample &sample)
UpChannelizer * m_channelizer
Definition: remotesource.h:234
static const QString m_channelId
Definition: remotesource.h:229
RemoteSource(DeviceAPI *deviceAPI)
virtual int webapiReportGet(SWGSDRangel::SWGChannelReport &response, QString &errorMessage)
virtual void destroy()
Definition: remotesource.h:187
uint32_t calculateDataReadQueueSize(int sampleRate)
QNetworkRequest m_networkRequest
Definition: remotesource.h:252
void webapiFormatChannelReport(SWGSDRangel::SWGChannelReport &response)
virtual int getNbSourceStreams() const
Definition: remotesource.h:200