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.cpp
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 #include "remotesink.h"
25 
26 #if (defined _WIN32_) || (defined _MSC_VER)
27 #include "windows_time.h"
28 #include <stdint.h>
29 #else
30 #include <sys/time.h>
31 #include <unistd.h>
32 #endif
33 #include <boost/crc.hpp>
34 #include <boost/cstdint.hpp>
35 
36 #include <QNetworkAccessManager>
37 #include <QNetworkReply>
38 #include <QBuffer>
39 
40 #include "SWGChannelSettings.h"
41 
42 #include "util/simpleserializer.h"
44 #include "dsp/downchannelizer.h"
45 #include "dsp/dspcommands.h"
47 #include "device/deviceapi.h"
48 
49 #include "remotesinkthread.h"
50 
54 
55 const QString RemoteSink::m_channelIdURI = "sdrangel.channel.remotesink";
56 const QString RemoteSink::m_channelId = "RemoteSink";
57 
59  ChannelAPI(m_channelIdURI, ChannelAPI::StreamSingleSink),
60  m_deviceAPI(deviceAPI),
61  m_running(false),
62  m_sinkThread(0),
63  m_txBlockIndex(0),
64  m_frameCount(0),
65  m_sampleIndex(0),
66  m_dataBlock(0),
67  m_centerFrequency(0),
68  m_frequencyOffset(0),
69  m_sampleRate(48000),
70  m_deviceSampleRate(48000),
71  m_nbBlocksFEC(0),
72  m_txDelay(35),
73  m_dataAddress("127.0.0.1"),
74  m_dataPort(9090)
75 {
76  setObjectName(m_channelId);
77 
78  m_channelizer = new DownChannelizer(this);
82 
83  m_networkManager = new QNetworkAccessManager();
84  connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
85 }
86 
88 {
89  disconnect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
90  delete m_networkManager;
91  m_dataBlockMutex.lock();
92 
94  delete m_dataBlock;
95  }
96 
97  m_dataBlockMutex.unlock();
100  delete m_threadedChannelizer;
101  delete m_channelizer;
102 }
103 
104 void RemoteSink::setTxDelay(int txDelay, int nbBlocksFEC)
105 {
106  double txDelayRatio = txDelay / 100.0;
107  int samplesPerBlock = RemoteNbBytesPerBlock / sizeof(Sample);
108  double delay = m_sampleRate == 0 ? 1.0 : (127*samplesPerBlock*txDelayRatio) / m_sampleRate;
109  delay /= 128 + nbBlocksFEC;
110  m_txDelay = roundf(delay*1e6); // microseconds
111  qDebug() << "RemoteSink::setTxDelay:"
112  << " " << txDelay
113  << "% m_txDelay: " << m_txDelay << "us"
114  << " m_sampleRate: " << m_sampleRate << "S/s";
115 }
116 
117 void RemoteSink::setNbBlocksFEC(int nbBlocksFEC)
118 {
119  qDebug() << "RemoteSink::setNbBlocksFEC: nbBlocksFEC: " << nbBlocksFEC;
120  m_nbBlocksFEC = nbBlocksFEC;
121 }
122 
123 void RemoteSink::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool firstOfBurst)
124 {
125  (void) firstOfBurst;
126  SampleVector::const_iterator it = begin;
127 
128  while (it != end)
129  {
130  int inSamplesIndex = it - begin;
131  int inRemainingSamples = end - it;
132 
133  if (m_txBlockIndex == 0)
134  {
135  struct timeval tv;
136  RemoteMetaDataFEC metaData;
137  gettimeofday(&tv, 0);
138 
139  metaData.m_centerFrequency = m_centerFrequency + m_frequencyOffset;
140  metaData.m_sampleRate = m_sampleRate;
141  metaData.m_sampleBytes = (SDR_RX_SAMP_SZ <= 16 ? 2 : 4);
142  metaData.m_sampleBits = SDR_RX_SAMP_SZ;
143  metaData.m_nbOriginalBlocks = RemoteNbOrginalBlocks;
144  metaData.m_nbFECBlocks = m_nbBlocksFEC;
145  metaData.m_tv_sec = tv.tv_sec;
146  metaData.m_tv_usec = tv.tv_usec;
147 
148  if (!m_dataBlock) { // on the very first cycle there is no data block allocated
150  }
151 
152  boost::crc_32_type crc32;
153  crc32.process_bytes(&metaData, sizeof(RemoteMetaDataFEC)-4);
154  metaData.m_crc32 = crc32.checksum();
155  RemoteSuperBlock& superBlock = m_dataBlock->m_superBlocks[0]; // first block
156  superBlock.init();
157  superBlock.m_header.m_frameIndex = m_frameCount;
158  superBlock.m_header.m_blockIndex = m_txBlockIndex;
159  superBlock.m_header.m_sampleBytes = (SDR_RX_SAMP_SZ <= 16 ? 2 : 4);
160  superBlock.m_header.m_sampleBits = SDR_RX_SAMP_SZ;
161 
162  RemoteMetaDataFEC *destMeta = (RemoteMetaDataFEC *) &superBlock.m_protectedBlock;
163  *destMeta = metaData;
164 
165  if (!(metaData == m_currentMetaFEC))
166  {
167  qDebug() << "RemoteSink::feed: meta: "
168  << "|" << metaData.m_centerFrequency
169  << ":" << metaData.m_sampleRate
170  << ":" << (int) (metaData.m_sampleBytes & 0xF)
171  << ":" << (int) metaData.m_sampleBits
172  << "|" << (int) metaData.m_nbOriginalBlocks
173  << ":" << (int) metaData.m_nbFECBlocks
174  << "|" << metaData.m_tv_sec
175  << ":" << metaData.m_tv_usec;
176 
177  m_currentMetaFEC = metaData;
178  }
179 
180  m_txBlockIndex = 1; // next Tx block with data
181  } // block zero
182 
183  // handle different sample sizes...
184  int samplesPerBlock = RemoteNbBytesPerBlock / (SDR_RX_SAMP_SZ <= 16 ? 4 : 8); // two I or Q samples
185  if (m_sampleIndex + inRemainingSamples < samplesPerBlock) // there is still room in the current super block
186  {
187  memcpy((void *) &m_superBlock.m_protectedBlock.buf[m_sampleIndex*sizeof(Sample)],
188  (const void *) &(*(begin+inSamplesIndex)),
189  inRemainingSamples * sizeof(Sample));
190  m_sampleIndex += inRemainingSamples;
191  it = end; // all input samples are consumed
192  }
193  else // complete super block and initiate the next if not end of frame
194  {
195  memcpy((void *) &m_superBlock.m_protectedBlock.buf[m_sampleIndex*sizeof(Sample)],
196  (const void *) &(*(begin+inSamplesIndex)),
197  (samplesPerBlock - m_sampleIndex) * sizeof(Sample));
198  it += samplesPerBlock - m_sampleIndex;
199  m_sampleIndex = 0;
200 
206 
207  if (m_txBlockIndex == RemoteNbOrginalBlocks - 1) // frame complete
208  {
209  m_dataBlockMutex.lock();
217 
219  m_dataBlock = new RemoteDataBlock(); // create a new one immediately
220  m_dataBlockMutex.unlock();
221 
222  m_txBlockIndex = 0;
223  m_frameCount++;
224  }
225  else
226  {
227  m_txBlockIndex++;
228  }
229  }
230  }
231 }
232 
234 {
235  qDebug("RemoteSink::start");
236 
237  memset((void *) &m_currentMetaFEC, 0, sizeof(RemoteMetaDataFEC));
238 
239  if (m_running) {
240  stop();
241  }
242 
244  connect(this,
246  m_sinkThread,
247  SLOT(processDataBlock(RemoteDataBlock *)),
248  Qt::QueuedConnection);
249  m_sinkThread->startStop(true);
250  m_running = true;
251 }
252 
254 {
255  qDebug("RemoteSink::stop");
256 
257  if (m_sinkThread != 0)
258  {
259  m_sinkThread->startStop(false);
260  m_sinkThread->deleteLater();
261  m_sinkThread = 0;
262  }
263 
264  m_running = false;
265 }
266 
268 {
269  (void) cmd;
271  {
273 
274  qDebug() << "RemoteSink::handleMessage: MsgChannelizerNotification:"
275  << " channelSampleRate: " << notif.getSampleRate()
276  << " offsetFrequency: " << notif.getFrequencyOffset();
277 
278  if (notif.getSampleRate() > 0) {
279  setSampleRate(notif.getSampleRate());
280  }
281 
283 
284  return true;
285  }
286  else if (DSPSignalNotification::match(cmd))
287  {
289 
290  qDebug() << "RemoteSink::handleMessage: DSPSignalNotification:"
291  << " inputSampleRate: " << notif.getSampleRate()
292  << " centerFrequency: " << notif.getCenterFrequency();
293 
296  calculateFrequencyOffset(); // This is when device sample rate changes
297 
298  // Redo the channelizer stuff with the new sample rate to re-synchronize everything
302 
303  if (m_guiMessageQueue)
304  {
306  m_guiMessageQueue->push(msg);
307  }
308 
309  return true;
310  }
311  else if (MsgConfigureRemoteSink::match(cmd))
312  {
314  qDebug() << "RemoteSink::handleMessage: MsgConfigureRemoteSink";
315  applySettings(cfg.getSettings(), cfg.getForce());
316 
317  return true;
318  }
319  else if (MsgConfigureChannelizer::match(cmd))
320  {
324 
325  qDebug() << "RemoteSink::handleMessage: MsgConfigureChannelizer:"
326  << " log2Decim: " << m_settings.m_log2Decim
327  << " filterChainHash: " << m_settings.m_filterChainHash;
328 
332 
333  calculateFrequencyOffset(); // This is when decimation or filter chain changes
334 
335  return true;
336  }
337  else
338  {
339  return false;
340  }
341 }
342 
343 QByteArray RemoteSink::serialize() const
344 {
345  return m_settings.serialize();
346 }
347 
348 bool RemoteSink::deserialize(const QByteArray& data)
349 {
350  (void) data;
351  if (m_settings.deserialize(data))
352  {
355  return true;
356  }
357  else
358  {
362  return false;
363  }
364 }
365 
366 void RemoteSink::applySettings(const RemoteSinkSettings& settings, bool force)
367 {
368  qDebug() << "RemoteSink::applySettings:"
369  << " m_nbFECBlocks: " << settings.m_nbFECBlocks
370  << " m_txDelay: " << settings.m_txDelay
371  << " m_dataAddress: " << settings.m_dataAddress
372  << " m_dataPort: " << settings.m_dataPort
373  << " force: " << force;
374 
375  QList<QString> reverseAPIKeys;
376 
377  if ((m_settings.m_nbFECBlocks != settings.m_nbFECBlocks) || force)
378  {
379  reverseAPIKeys.append("nbFECBlocks");
380  setNbBlocksFEC(settings.m_nbFECBlocks);
381  setTxDelay(settings.m_txDelay, settings.m_nbFECBlocks);
382  }
383 
384  if ((m_settings.m_txDelay != settings.m_txDelay) || force)
385  {
386  reverseAPIKeys.append("txDelay");
387  setTxDelay(settings.m_txDelay, settings.m_nbFECBlocks);
388  }
389 
390  if ((m_settings.m_dataAddress != settings.m_dataAddress) || force)
391  {
392  reverseAPIKeys.append("dataAddress");
393  m_dataAddress = settings.m_dataAddress;
394  }
395 
396  if ((m_settings.m_dataPort != settings.m_dataPort) || force)
397  {
398  reverseAPIKeys.append("dataPort");
399  m_dataPort = settings.m_dataPort;
400  }
401 
402  if ((settings.m_useReverseAPI) && (reverseAPIKeys.size() != 0))
403  {
404  bool fullUpdate = ((m_settings.m_useReverseAPI != settings.m_useReverseAPI) && settings.m_useReverseAPI) ||
409  webapiReverseSendSettings(reverseAPIKeys, settings, fullUpdate || force);
410  }
411 
412  m_settings = settings;
413 }
414 
416 {
417  unsigned int s = 1;
418 
419  for (unsigned int i = 0; i < settings.m_log2Decim; i++) {
420  s *= 3;
421  }
422 
423  settings.m_filterChainHash = settings.m_filterChainHash >= s ? s-1 : settings.m_filterChainHash;
424 }
425 
427 {
429  m_frequencyOffset = m_deviceSampleRate * shiftFactor;
430 }
431 
434  QString& errorMessage)
435 {
436  (void) errorMessage;
438  response.getRemoteSinkSettings()->init();
440  return 200;
441 }
442 
444  bool force,
445  const QStringList& channelSettingsKeys,
447  QString& errorMessage)
448 {
449  (void) errorMessage;
450  RemoteSinkSettings settings = m_settings;
451 
452  if (channelSettingsKeys.contains("nbFECBlocks"))
453  {
454  int nbFECBlocks = response.getRemoteSinkSettings()->getNbFecBlocks();
455 
456  if ((nbFECBlocks < 0) || (nbFECBlocks > 127)) {
457  settings.m_nbFECBlocks = 8;
458  } else {
459  settings.m_nbFECBlocks = response.getRemoteSinkSettings()->getNbFecBlocks();
460  }
461  }
462 
463  if (channelSettingsKeys.contains("txDelay"))
464  {
465  int txDelay = response.getRemoteSinkSettings()->getTxDelay();
466 
467  if (txDelay < 0) {
468  settings.m_txDelay = 35;
469  } else {
470  settings.m_txDelay = txDelay;
471  }
472  }
473 
474  if (channelSettingsKeys.contains("dataAddress")) {
475  settings.m_dataAddress = *response.getRemoteSinkSettings()->getDataAddress();
476  }
477 
478  if (channelSettingsKeys.contains("dataPort"))
479  {
480  int dataPort = response.getRemoteSinkSettings()->getDataPort();
481 
482  if ((dataPort < 1024) || (dataPort > 65535)) {
483  settings.m_dataPort = 9090;
484  } else {
485  settings.m_dataPort = dataPort;
486  }
487  }
488 
489  if (channelSettingsKeys.contains("rgbColor")) {
490  settings.m_rgbColor = response.getRemoteSinkSettings()->getRgbColor();
491  }
492  if (channelSettingsKeys.contains("title")) {
493  settings.m_title = *response.getRemoteSinkSettings()->getTitle();
494  }
495  if (channelSettingsKeys.contains("log2Decim")) {
496  settings.m_log2Decim = response.getRemoteSinkSettings()->getLog2Decim();
497  }
498 
499  if (channelSettingsKeys.contains("filterChainHash"))
500  {
502  validateFilterChainHash(settings);
503  }
504 
505  if (channelSettingsKeys.contains("useReverseAPI")) {
506  settings.m_useReverseAPI = response.getRemoteSinkSettings()->getUseReverseApi() != 0;
507  }
508  if (channelSettingsKeys.contains("reverseAPIAddress")) {
510  }
511  if (channelSettingsKeys.contains("reverseAPIPort")) {
513  }
514  if (channelSettingsKeys.contains("reverseAPIDeviceIndex")) {
516  }
517  if (channelSettingsKeys.contains("reverseAPIChannelIndex")) {
519  }
520 
523 
524  if ((settings.m_log2Decim != m_settings.m_log2Decim) || (settings.m_filterChainHash != m_settings.m_filterChainHash) || force)
525  {
528  }
529 
530  qDebug("RemoteSink::webapiSettingsPutPatch: forward to GUI: %p", m_guiMessageQueue);
531  if (m_guiMessageQueue) // forward to GUI if any
532  {
533  MsgConfigureRemoteSink *msgToGUI = MsgConfigureRemoteSink::create(settings, force);
534  m_guiMessageQueue->push(msgToGUI);
535  }
536 
537  webapiFormatChannelSettings(response, settings);
538 
539  return 200;
540 }
541 
543 {
544  response.getRemoteSinkSettings()->setNbFecBlocks(settings.m_nbFECBlocks);
545  response.getRemoteSinkSettings()->setTxDelay(settings.m_txDelay);
546 
547  if (response.getRemoteSinkSettings()->getDataAddress()) {
548  *response.getRemoteSinkSettings()->getDataAddress() = settings.m_dataAddress;
549  } else {
550  response.getRemoteSinkSettings()->setDataAddress(new QString(settings.m_dataAddress));
551  }
552 
553  response.getRemoteSinkSettings()->setDataPort(settings.m_dataPort);
554  response.getRemoteSinkSettings()->setRgbColor(settings.m_rgbColor);
555 
556  if (response.getRemoteSinkSettings()->getTitle()) {
557  *response.getRemoteSinkSettings()->getTitle() = settings.m_title;
558  } else {
559  response.getRemoteSinkSettings()->setTitle(new QString(settings.m_title));
560  }
561 
562  response.getRemoteSinkSettings()->setLog2Decim(settings.m_log2Decim);
564  response.getRemoteSinkSettings()->setUseReverseApi(settings.m_useReverseAPI ? 1 : 0);
565 
566  if (response.getRemoteSinkSettings()->getReverseApiAddress()) {
568  } else {
569  response.getRemoteSinkSettings()->setReverseApiAddress(new QString(settings.m_reverseAPIAddress));
570  }
571 
575 }
576 
577 void RemoteSink::webapiReverseSendSettings(QList<QString>& channelSettingsKeys, const RemoteSinkSettings& settings, bool force)
578 {
580  swgChannelSettings->setDirection(0); // single sink (Rx)
581  swgChannelSettings->setOriginatorChannelIndex(getIndexInDeviceSet());
582  swgChannelSettings->setOriginatorDeviceSetIndex(getDeviceSetIndex());
583  swgChannelSettings->setChannelType(new QString("RemoteSink"));
585  SWGSDRangel::SWGRemoteSinkSettings *swgRemoteSinkSettings = swgChannelSettings->getRemoteSinkSettings();
586 
587  // transfer data that has been modified. When force is on transfer all data except reverse API data
588 
589  if (channelSettingsKeys.contains("nbFECBlocks") || force) {
590  swgRemoteSinkSettings->setNbFecBlocks(settings.m_nbFECBlocks);
591  }
592  if (channelSettingsKeys.contains("txDelay") || force)
593  {
594  swgRemoteSinkSettings->setTxDelay(settings.m_txDelay);
595  }
596  if (channelSettingsKeys.contains("dataAddress") || force) {
597  swgRemoteSinkSettings->setDataAddress(new QString(settings.m_dataAddress));
598  }
599  if (channelSettingsKeys.contains("dataPort") || force) {
600  swgRemoteSinkSettings->setDataPort(settings.m_dataPort);
601  }
602  if (channelSettingsKeys.contains("rgbColor") || force) {
603  swgRemoteSinkSettings->setRgbColor(settings.m_rgbColor);
604  }
605  if (channelSettingsKeys.contains("title") || force) {
606  swgRemoteSinkSettings->setTitle(new QString(settings.m_title));
607  }
608  if (channelSettingsKeys.contains("log2Decim") || force) {
609  swgRemoteSinkSettings->setLog2Decim(settings.m_log2Decim);
610  }
611  if (channelSettingsKeys.contains("filterChainHash") || force) {
612  swgRemoteSinkSettings->setFilterChainHash(settings.m_filterChainHash);
613  }
614 
615  QString channelSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/channel/%4/settings")
616  .arg(settings.m_reverseAPIAddress)
617  .arg(settings.m_reverseAPIPort)
618  .arg(settings.m_reverseAPIDeviceIndex)
619  .arg(settings.m_reverseAPIChannelIndex);
620  m_networkRequest.setUrl(QUrl(channelSettingsURL));
621  m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
622 
623  QBuffer *buffer=new QBuffer();
624  buffer->open((QBuffer::ReadWrite));
625  buffer->write(swgChannelSettings->asJson().toUtf8());
626  buffer->seek(0);
627 
628  // Always use PATCH to avoid passing reverse API settings
629  m_networkManager->sendCustomRequest(m_networkRequest, "PATCH", buffer);
630 
631  delete swgChannelSettings;
632 }
633 
634 void RemoteSink::networkManagerFinished(QNetworkReply *reply)
635 {
636  QNetworkReply::NetworkError replyError = reply->error();
637 
638  if (replyError)
639  {
640  qWarning() << "RemoteSink::networkManagerFinished:"
641  << " error(" << (int) replyError
642  << "): " << replyError
643  << ": " << reply->errorString();
644  return;
645  }
646 
647  QString answer = reply->readAll();
648  answer.chop(1); // remove last \n
649  qDebug("RemoteSink::networkManagerFinished: reply:\n%s", answer.toStdString().c_str());
650 }
void networkManagerFinished(QNetworkReply *reply)
Definition: remotesink.cpp:634
void setOriginatorChannelIndex(qint32 originator_channel_index)
void validateFilterChainHash(RemoteSinkSettings &settings)
Definition: remotesink.cpp:415
void push(Message *message, bool emitSignal=true)
Push message onto queue.
uint16_t m_reverseAPIDeviceIndex
void removeChannelSinkAPI(ChannelAPI *channelAPI, int streamIndex=0)
Definition: deviceapi.cpp:163
void addChannelSinkAPI(ChannelAPI *channelAPI, int streamIndex=0)
Definition: deviceapi.cpp:156
int m_txDelay
Definition: remotesink.h:188
void setNbFecBlocks(qint32 nb_fec_blocks)
RemoteSuperBlock * m_superBlocks
MessageQueue * getInputMessageQueue()
Get the queue for asynchronous inbound communication.
uint32_t m_sampleRate
Definition: remotesink.h:185
bool deserialize(const QByteArray &data)
virtual void start()
Definition: remotesink.cpp:233
int getDeviceSetIndex() const
Definition: channelapi.h:89
uint16_t m_frameCount
transmission frame count
Definition: remotesink.h:176
void webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings &response, const RemoteSinkSettings &settings)
Definition: remotesink.cpp:542
RemoteProtectedBlock m_protectedBlock
void setFilterChainHash(qint32 filter_chain_hash)
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
void setChannelType(QString *channel_type)
void setOriginatorDeviceSetIndex(qint32 originator_device_set_index)
void setDataAddress(QString *data_address)
static MsgConfigureChannelizer * create(int sampleRate, int centerFrequency)
Definition: remotesink.h:96
QNetworkRequest m_networkRequest
Definition: remotesink.h:192
MessageQueue m_inputMessageQueue
Queue for asynchronous inbound communication.
int64_t m_frequencyOffset
Definition: remotesink.h:184
RemoteMetaDataFEC m_currentMetaFEC
Definition: remotesink.h:179
QString m_dataAddress
Definition: remotesink.h:189
const RemoteSinkSettings & getSettings() const
Definition: remotesink.h:50
RemoteSinkSettings m_settings
Definition: remotesink.h:172
void calculateFrequencyOffset()
Definition: remotesink.cpp:426
DownChannelizer * m_channelizer
Definition: remotesink.h:169
uint16_t m_reverseAPIChannelIndex
RemoteDataBlock * m_dataBlock
Definition: remotesink.h:180
qint64 getCenterFrequency() const
Definition: dspcommands.h:329
#define SDR_RX_SAMP_SZ
Definition: dsptypes.h:32
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
uint32_t m_deviceSampleRate
Definition: remotesink.h:186
ThreadedBasebandSampleSink * m_threadedChannelizer
Definition: remotesink.h:168
#define MESSAGE_CLASS_DEFINITION(Name, BaseClass)
Definition: message.h:52
static const QString m_channelIdURI
Definition: remotesink.h:160
static const QString m_channelId
Definition: remotesink.h:161
uint8_t buf[RemoteNbBytesPerBlock]
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
uint8_t m_sampleBytes
number of bytes per sample (2 or 4) for this block
int32_t i
Definition: decimators.h:244
uint8_t m_blockIndex
void set(MessageQueue *messageQueue, unsigned int log2Decim, unsigned int filterChainHash)
static bool match(const Message *message)
Definition: message.cpp:45
int m_nbBlocksFEC
Definition: remotesink.h:187
void setReverseApiPort(qint32 reverse_api_port)
void removeChannelSink(ThreadedBasebandSampleSink *sink, int streamIndex=0)
Remove a channel sink (Rx)
Definition: deviceapi.cpp:127
void setSampleRate(uint32_t sampleRate)
Definition: remotesink.h:152
virtual QString asJson() override
RemoteTxControlBlock m_txControlBlock
virtual void feed(const SampleVector::const_iterator &begin, const SampleVector::const_iterator &end, bool po)
Definition: remotesink.cpp:123
QByteArray serialize() const
RemoteHeader m_header
void addChannelSink(ThreadedBasebandSampleSink *sink, int streamIndex=0)
Add a channel sink (Rx)
Definition: deviceapi.cpp:118
DeviceAPI * m_deviceAPI
Definition: remotesink.h:167
static MsgSampleRateNotification * create(int sampleRate)
Definition: remotesink.h:73
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
int getSampleRate() const
Definition: dspcommands.h:328
uint16_t m_frameIndex
void startStop(bool start)
void setRemoteSinkSettings(SWGRemoteSinkSettings *remote_sink_settings)
void dataBlockAvailable(RemoteDataBlock *dataBlock)
static MsgConfigureRemoteSink * create(const RemoteSinkSettings &settings, bool force)
Definition: remotesink.h:53
void setReverseApiDeviceIndex(qint32 reverse_api_device_index)
virtual QByteArray serialize() const
Definition: remotesink.cpp:343
uint32_t crc32(const uint8_t *buf, int len)
Definition: crc.h:58
uint64_t m_centerFrequency
8 center frequency in kHz
RemoteSuperBlock m_superBlock
Definition: remotesink.h:178
virtual int webapiSettingsPutPatch(bool force, const QStringList &channelSettingsKeys, SWGSDRangel::SWGChannelSettings &response, QString &errorMessage)
Definition: remotesink.cpp:443
SWGRemoteSinkSettings * getRemoteSinkSettings()
int getIndexInDeviceSet() const
Definition: channelapi.h:87
void setReverseApiChannelIndex(qint32 reverse_api_channel_index)
virtual bool deserialize(const QByteArray &data)
Definition: remotesink.cpp:348
static double getShiftFactor(unsigned int log2, unsigned int chainHash)
int m_sampleIndex
Current sample index in protected block data.
Definition: remotesink.h:177
uint16_t m_dataPort
Definition: remotesink.h:190
uint8_t m_sampleBits
number of bits per sample
void setReverseApiAddress(QString *reverse_api_address)
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
void setUseReverseApi(qint32 use_reverse_api)
virtual bool handleMessage(const Message &cmd)
Processing of a message. Returns true if message has actually been processed.
Definition: remotesink.cpp:267