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.
Classes | Signals | Public Member Functions | Static Public Attributes | Private Slots | Private Member Functions | Private Attributes | List of all members
RemoteSink Class Reference

#include <remotesink.h>

+ Inheritance diagram for RemoteSink:
+ Collaboration diagram for RemoteSink:

Classes

class  MsgConfigureChannelizer
 
class  MsgConfigureRemoteSink
 
class  MsgSampleRateNotification
 

Signals

void dataBlockAvailable (RemoteDataBlock *dataBlock)
 

Public Member Functions

 RemoteSink (DeviceAPI *deviceAPI)
 
virtual ~RemoteSink ()
 
virtual void destroy ()
 
virtual void feed (const SampleVector::const_iterator &begin, const SampleVector::const_iterator &end, bool po)
 
virtual void start ()
 
virtual void stop ()
 
virtual bool handleMessage (const Message &cmd)
 Processing of a message. Returns true if message has actually been processed. More...
 
virtual void getIdentifier (QString &id)
 
virtual void getTitle (QString &title)
 
virtual qint64 getCenterFrequency () const
 Applies to a default stream. More...
 
virtual QByteArray serialize () const
 
virtual bool deserialize (const QByteArray &data)
 
virtual int getNbSinkStreams () const
 
virtual int getNbSourceStreams () const
 
virtual qint64 getStreamCenterFrequency (int streamIndex, bool sinkElseSource) const
 
virtual int webapiSettingsGet (SWGSDRangel::SWGChannelSettings &response, QString &errorMessage)
 
virtual int webapiSettingsPutPatch (bool force, const QStringList &channelSettingsKeys, SWGSDRangel::SWGChannelSettings &response, QString &errorMessage)
 
void setCenterFrequency (uint64_t centerFrequency)
 
void setSampleRate (uint32_t sampleRate)
 
void setNbBlocksFEC (int nbBlocksFEC)
 
void setTxDelay (int txDelay, int nbBlocksFEC)
 
void setDataAddress (const QString &address)
 
void setDataPort (uint16_t port)
 
void setChannelizer (unsigned int log2Decim, unsigned int filterChainHash)
 
- Public Member Functions inherited from BasebandSampleSink
 BasebandSampleSink ()
 
virtual ~BasebandSampleSink ()
 
MessageQueuegetInputMessageQueue ()
 Get the queue for asynchronous inbound communication. More...
 
virtual void setMessageQueueToGUI (MessageQueue *queue)
 
MessageQueuegetMessageQueueToGUI ()
 
- Public Member Functions inherited from ChannelAPI
 ChannelAPI (const QString &name, StreamType streamType)
 
virtual ~ChannelAPI ()
 
virtual void setName (const QString &name)
 
virtual const QString & getName () const
 
virtual int webapiReportGet (SWGSDRangel::SWGChannelReport &response, QString &errorMessage)
 
int getIndexInDeviceSet () const
 
void setIndexInDeviceSet (int indexInDeviceSet)
 
int getDeviceSetIndex () const
 
void setDeviceSetIndex (int deviceSetIndex)
 
DeviceAPIgetDeviceAPI ()
 
void setDeviceAPI (DeviceAPI *deviceAPI)
 
uint64_t getUID () const
 
StreamType getStreamType () const
 

Static Public Attributes

static const QString m_channelIdURI = "sdrangel.channel.remotesink"
 
static const QString m_channelId = "RemoteSink"
 

Private Slots

void networkManagerFinished (QNetworkReply *reply)
 

Private Member Functions

void applySettings (const RemoteSinkSettings &settings, bool force=false)
 
void validateFilterChainHash (RemoteSinkSettings &settings)
 
void calculateFrequencyOffset ()
 
void webapiFormatChannelSettings (SWGSDRangel::SWGChannelSettings &response, const RemoteSinkSettings &settings)
 
void webapiReverseSendSettings (QList< QString > &channelSettingsKeys, const RemoteSinkSettings &settings, bool force)
 

Private Attributes

DeviceAPIm_deviceAPI
 
ThreadedBasebandSampleSinkm_threadedChannelizer
 
DownChannelizerm_channelizer
 
bool m_running
 
RemoteSinkSettings m_settings
 
RemoteSinkThreadm_sinkThread
 
int m_txBlockIndex
 Current index in blocks to transmit in the Tx row. More...
 
uint16_t m_frameCount
 transmission frame count More...
 
int m_sampleIndex
 Current sample index in protected block data. More...
 
RemoteSuperBlock m_superBlock
 
RemoteMetaDataFEC m_currentMetaFEC
 
RemoteDataBlockm_dataBlock
 
QMutex m_dataBlockMutex
 
uint64_t m_centerFrequency
 
int64_t m_frequencyOffset
 
uint32_t m_sampleRate
 
uint32_t m_deviceSampleRate
 
int m_nbBlocksFEC
 
int m_txDelay
 
QString m_dataAddress
 
uint16_t m_dataPort
 
QNetworkAccessManager * m_networkManager
 
QNetworkRequest m_networkRequest
 

Additional Inherited Members

- Public Types inherited from ChannelAPI
enum  StreamType { StreamSingleSink, StreamSingleSource, StreamMIMO }
 < This is the same enum as in PluginInterface More...
 
- Protected Slots inherited from BasebandSampleSink
void handleInputMessages ()
 
- Protected Attributes inherited from BasebandSampleSink
MessageQueue m_inputMessageQueue
 Queue for asynchronous inbound communication. More...
 
MessageQueuem_guiMessageQueue
 Input message queue to the GUI. More...
 

Detailed Description

Definition at line 43 of file remotesink.h.

Constructor & Destructor Documentation

◆ RemoteSink()

RemoteSink::RemoteSink ( DeviceAPI deviceAPI)

Definition at line 58 of file remotesink.cpp.

References DeviceAPI::addChannelSink(), DeviceAPI::addChannelSinkAPI(), m_channelId, m_channelizer, m_deviceAPI, m_networkManager, m_threadedChannelizer, and networkManagerFinished().

Referenced by RemoteSink::MsgConfigureChannelizer::MsgConfigureChannelizer().

58  :
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),
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 }
void networkManagerFinished(QNetworkReply *reply)
Definition: remotesink.cpp:634
void addChannelSinkAPI(ChannelAPI *channelAPI, int streamIndex=0)
Definition: deviceapi.cpp:156
int m_txDelay
Definition: remotesink.h:188
uint32_t m_sampleRate
Definition: remotesink.h:185
uint16_t m_frameCount
transmission frame count
Definition: remotesink.h:176
RemoteSinkThread * m_sinkThread
Definition: remotesink.h:173
uint64_t m_centerFrequency
Definition: remotesink.h:183
QNetworkAccessManager * m_networkManager
Definition: remotesink.h:191
int64_t m_frequencyOffset
Definition: remotesink.h:184
QString m_dataAddress
Definition: remotesink.h:189
DownChannelizer * m_channelizer
Definition: remotesink.h:169
RemoteDataBlock * m_dataBlock
Definition: remotesink.h:180
uint32_t m_deviceSampleRate
Definition: remotesink.h:186
ThreadedBasebandSampleSink * m_threadedChannelizer
Definition: remotesink.h:168
static const QString m_channelIdURI
Definition: remotesink.h:160
static const QString m_channelId
Definition: remotesink.h:161
int m_txBlockIndex
Current index in blocks to transmit in the Tx row.
Definition: remotesink.h:175
ChannelAPI(const QString &name, StreamType streamType)
Definition: channelapi.cpp:23
int m_nbBlocksFEC
Definition: remotesink.h:187
Exposes a single sink stream (input, Rx)
Definition: channelapi.h:41
void addChannelSink(ThreadedBasebandSampleSink *sink, int streamIndex=0)
Add a channel sink (Rx)
Definition: deviceapi.cpp:118
DeviceAPI * m_deviceAPI
Definition: remotesink.h:167
bool m_running
Definition: remotesink.h:170
int m_sampleIndex
Current sample index in protected block data.
Definition: remotesink.h:177
uint16_t m_dataPort
Definition: remotesink.h:190
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ~RemoteSink()

RemoteSink::~RemoteSink ( )
virtual

Definition at line 87 of file remotesink.cpp.

References m_channelizer, RemoteTxControlBlock::m_complete, m_dataBlock, m_dataBlockMutex, m_deviceAPI, m_networkManager, m_threadedChannelizer, RemoteDataBlock::m_txControlBlock, networkManagerFinished(), DeviceAPI::removeChannelSink(), and DeviceAPI::removeChannelSinkAPI().

Referenced by RemoteSink::MsgConfigureChannelizer::MsgConfigureChannelizer().

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 }
void networkManagerFinished(QNetworkReply *reply)
Definition: remotesink.cpp:634
void removeChannelSinkAPI(ChannelAPI *channelAPI, int streamIndex=0)
Definition: deviceapi.cpp:163
QNetworkAccessManager * m_networkManager
Definition: remotesink.h:191
DownChannelizer * m_channelizer
Definition: remotesink.h:169
RemoteDataBlock * m_dataBlock
Definition: remotesink.h:180
ThreadedBasebandSampleSink * m_threadedChannelizer
Definition: remotesink.h:168
void removeChannelSink(ThreadedBasebandSampleSink *sink, int streamIndex=0)
Remove a channel sink (Rx)
Definition: deviceapi.cpp:127
RemoteTxControlBlock m_txControlBlock
DeviceAPI * m_deviceAPI
Definition: remotesink.h:167
QMutex m_dataBlockMutex
Definition: remotesink.h:181
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Function Documentation

◆ applySettings()

void RemoteSink::applySettings ( const RemoteSinkSettings settings,
bool  force = false 
)
private

Definition at line 366 of file remotesink.cpp.

References RemoteSinkSettings::m_dataAddress, m_dataAddress, RemoteSinkSettings::m_dataPort, m_dataPort, RemoteSinkSettings::m_nbFECBlocks, RemoteSinkSettings::m_reverseAPIAddress, RemoteSinkSettings::m_reverseAPIChannelIndex, RemoteSinkSettings::m_reverseAPIDeviceIndex, RemoteSinkSettings::m_reverseAPIPort, m_settings, RemoteSinkSettings::m_txDelay, RemoteSinkSettings::m_useReverseAPI, setNbBlocksFEC(), setTxDelay(), and webapiReverseSendSettings().

Referenced by handleMessage().

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 }
uint16_t m_reverseAPIDeviceIndex
QString m_dataAddress
Definition: remotesink.h:189
RemoteSinkSettings m_settings
Definition: remotesink.h:172
uint16_t m_reverseAPIChannelIndex
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
void setTxDelay(int txDelay, int nbBlocksFEC)
Definition: remotesink.cpp:104
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calculateFrequencyOffset()

void RemoteSink::calculateFrequencyOffset ( )
private

Definition at line 426 of file remotesink.cpp.

References HBFilterChainConverter::getShiftFactor(), m_deviceSampleRate, RemoteSinkSettings::m_filterChainHash, m_frequencyOffset, RemoteSinkSettings::m_log2Decim, and m_settings.

Referenced by handleMessage().

427 {
429  m_frequencyOffset = m_deviceSampleRate * shiftFactor;
430 }
int64_t m_frequencyOffset
Definition: remotesink.h:184
RemoteSinkSettings m_settings
Definition: remotesink.h:172
uint32_t m_deviceSampleRate
Definition: remotesink.h:186
static double getShiftFactor(unsigned int log2, unsigned int chainHash)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dataBlockAvailable

void RemoteSink::dataBlockAvailable ( RemoteDataBlock dataBlock)
signal

Referenced by start().

+ Here is the caller graph for this function:

◆ deserialize()

bool RemoteSink::deserialize ( const QByteArray &  data)
virtual

Implements ChannelAPI.

Definition at line 348 of file remotesink.cpp.

References RemoteSink::MsgConfigureRemoteSink::create(), RemoteSinkSettings::deserialize(), BasebandSampleSink::m_inputMessageQueue, m_settings, MessageQueue::push(), and RemoteSinkSettings::resetToDefaults().

Referenced by getCenterFrequency().

349 {
350  (void) data;
351  if (m_settings.deserialize(data))
352  {
353  MsgConfigureRemoteSink *msg = MsgConfigureRemoteSink::create(m_settings, true);
355  return true;
356  }
357  else
358  {
360  MsgConfigureRemoteSink *msg = MsgConfigureRemoteSink::create(m_settings, true);
362  return false;
363  }
364 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
bool deserialize(const QByteArray &data)
MessageQueue m_inputMessageQueue
Queue for asynchronous inbound communication.
RemoteSinkSettings m_settings
Definition: remotesink.h:172
static MsgConfigureRemoteSink * create(const RemoteSinkSettings &settings, bool force)
Definition: remotesink.h:53
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ destroy()

virtual void RemoteSink::destroy ( )
inlinevirtual

Implements ChannelAPI.

Definition at line 114 of file remotesink.h.

References feed(), handleMessage(), start(), and stop().

114 { delete this; }
+ Here is the call graph for this function:

◆ feed()

void RemoteSink::feed ( const SampleVector::const_iterator &  begin,
const SampleVector::const_iterator &  end,
bool  po 
)
virtual

Implements BasebandSampleSink.

Definition at line 123 of file remotesink.cpp.

References m_centerFrequency, m_frequencyOffset, m_sampleRate, m_txBlockIndex, and SDR_RX_SAMP_SZ.

Referenced by destroy().

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 }
int m_txDelay
Definition: remotesink.h:188
RemoteSuperBlock * m_superBlocks
uint32_t m_sampleRate
Definition: remotesink.h:185
uint16_t m_frameCount
transmission frame count
Definition: remotesink.h:176
RemoteProtectedBlock m_protectedBlock
uint64_t m_centerFrequency
Definition: remotesink.h:183
int64_t m_frequencyOffset
Definition: remotesink.h:184
RemoteMetaDataFEC m_currentMetaFEC
Definition: remotesink.h:179
QString m_dataAddress
Definition: remotesink.h:189
RemoteDataBlock * m_dataBlock
Definition: remotesink.h:180
#define SDR_RX_SAMP_SZ
Definition: dsptypes.h:32
uint8_t buf[RemoteNbBytesPerBlock]
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
uint8_t m_blockIndex
int m_nbBlocksFEC
Definition: remotesink.h:187
RemoteTxControlBlock m_txControlBlock
RemoteHeader m_header
QMutex m_dataBlockMutex
Definition: remotesink.h:181
uint16_t m_frameIndex
void dataBlockAvailable(RemoteDataBlock *dataBlock)
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
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
+ Here is the caller graph for this function:

◆ getCenterFrequency()

virtual qint64 RemoteSink::getCenterFrequency ( ) const
inlinevirtual

Applies to a default stream.

Implements ChannelAPI.

Definition at line 123 of file remotesink.h.

References deserialize(), m_frequencyOffset, and serialize().

123 { return m_frequencyOffset; }
int64_t m_frequencyOffset
Definition: remotesink.h:184
+ Here is the call graph for this function:

◆ getIdentifier()

virtual void RemoteSink::getIdentifier ( QString &  id)
inlinevirtual

Implements ChannelAPI.

Definition at line 121 of file remotesink.h.

121 { id = objectName(); }

◆ getNbSinkStreams()

virtual int RemoteSink::getNbSinkStreams ( ) const
inlinevirtual

Implements ChannelAPI.

Definition at line 128 of file remotesink.h.

128 { return 1; }

◆ getNbSourceStreams()

virtual int RemoteSink::getNbSourceStreams ( ) const
inlinevirtual

Implements ChannelAPI.

Definition at line 129 of file remotesink.h.

129 { return 0; }

◆ getStreamCenterFrequency()

virtual qint64 RemoteSink::getStreamCenterFrequency ( int  streamIndex,
bool  sinkElseSource 
) const
inlinevirtual

Implements ChannelAPI.

Definition at line 131 of file remotesink.h.

References m_frequencyOffset, webapiSettingsGet(), and webapiSettingsPutPatch().

132  {
133  (void) streamIndex;
134  (void) sinkElseSource;
135  return m_frequencyOffset;
136  }
int64_t m_frequencyOffset
Definition: remotesink.h:184
+ Here is the call graph for this function:

◆ getTitle()

virtual void RemoteSink::getTitle ( QString &  title)
inlinevirtual

Implements ChannelAPI.

Definition at line 122 of file remotesink.h.

122 { title = "Remote Sink"; }

◆ handleMessage()

bool RemoteSink::handleMessage ( const Message cmd)
virtual

Processing of a message. Returns true if message has actually been processed.

Implements BasebandSampleSink.

Definition at line 267 of file remotesink.cpp.

References applySettings(), calculateFrequencyOffset(), RemoteSink::MsgSampleRateNotification::create(), DSPSignalNotification::getCenterFrequency(), RemoteSink::MsgConfigureChannelizer::getFilterChainHash(), RemoteSink::MsgConfigureRemoteSink::getForce(), DownChannelizer::MsgChannelizerNotification::getFrequencyOffset(), BasebandSampleSink::getInputMessageQueue(), RemoteSink::MsgConfigureChannelizer::getLog2Decim(), DownChannelizer::MsgChannelizerNotification::getSampleRate(), DSPSignalNotification::getSampleRate(), RemoteSink::MsgConfigureRemoteSink::getSettings(), m_channelizer, m_deviceSampleRate, RemoteSinkSettings::m_filterChainHash, BasebandSampleSink::m_guiMessageQueue, RemoteSinkSettings::m_log2Decim, RemoteSinkSettings::m_nbFECBlocks, m_settings, RemoteSinkSettings::m_txDelay, Message::match(), MessageQueue::push(), DownChannelizer::set(), setCenterFrequency(), setSampleRate(), and setTxDelay().

Referenced by destroy().

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  {
305  MsgSampleRateNotification *msg = MsgSampleRateNotification::create(notif.getSampleRate());
306  m_guiMessageQueue->push(msg);
307  }
308 
309  return true;
310  }
311  else if (MsgConfigureRemoteSink::match(cmd))
312  {
313  MsgConfigureRemoteSink& cfg = (MsgConfigureRemoteSink&) cmd;
314  qDebug() << "RemoteSink::handleMessage: MsgConfigureRemoteSink";
315  applySettings(cfg.getSettings(), cfg.getForce());
316 
317  return true;
318  }
319  else if (MsgConfigureChannelizer::match(cmd))
320  {
321  MsgConfigureChannelizer& cfg = (MsgConfigureChannelizer&) cmd;
322  m_settings.m_log2Decim = cfg.getLog2Decim();
323  m_settings.m_filterChainHash = cfg.getFilterChainHash();
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 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
MessageQueue * getInputMessageQueue()
Get the queue for asynchronous inbound communication.
RemoteSinkSettings m_settings
Definition: remotesink.h:172
void calculateFrequencyOffset()
Definition: remotesink.cpp:426
DownChannelizer * m_channelizer
Definition: remotesink.h:169
qint64 getCenterFrequency() const
Definition: dspcommands.h:329
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
uint32_t m_deviceSampleRate
Definition: remotesink.h:186
void applySettings(const RemoteSinkSettings &settings, bool force=false)
Definition: remotesink.cpp:366
void set(MessageQueue *messageQueue, unsigned int log2Decim, unsigned int filterChainHash)
static bool match(const Message *message)
Definition: message.cpp:45
void setSampleRate(uint32_t sampleRate)
Definition: remotesink.h:152
static MsgSampleRateNotification * create(int sampleRate)
Definition: remotesink.h:73
int getSampleRate() const
Definition: dspcommands.h:328
void setCenterFrequency(uint64_t centerFrequency)
Definition: remotesink.h:149
void setTxDelay(int txDelay, int nbBlocksFEC)
Definition: remotesink.cpp:104
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ networkManagerFinished

void RemoteSink::networkManagerFinished ( QNetworkReply *  reply)
privateslot

Definition at line 634 of file remotesink.cpp.

Referenced by RemoteSink(), and ~RemoteSink().

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 }
+ Here is the caller graph for this function:

◆ serialize()

QByteArray RemoteSink::serialize ( ) const
virtual

Implements ChannelAPI.

Definition at line 343 of file remotesink.cpp.

References m_settings, and RemoteSinkSettings::serialize().

Referenced by getCenterFrequency().

344 {
345  return m_settings.serialize();
346 }
RemoteSinkSettings m_settings
Definition: remotesink.h:172
QByteArray serialize() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCenterFrequency()

void RemoteSink::setCenterFrequency ( uint64_t  centerFrequency)
inline

Set center frequency given in Hz

Definition at line 149 of file remotesink.h.

References m_centerFrequency.

Referenced by handleMessage().

149 { m_centerFrequency = centerFrequency; }
uint64_t m_centerFrequency
Definition: remotesink.h:183
+ Here is the caller graph for this function:

◆ setChannelizer()

void RemoteSink::setChannelizer ( unsigned int  log2Decim,
unsigned int  filterChainHash 
)

Referenced by setDataPort().

+ Here is the caller graph for this function:

◆ setDataAddress()

void RemoteSink::setDataAddress ( const QString &  address)
inline

Definition at line 156 of file remotesink.h.

References m_dataAddress.

156 { m_dataAddress = address; }
QString m_dataAddress
Definition: remotesink.h:189

◆ setDataPort()

void RemoteSink::setDataPort ( uint16_t  port)
inline

Definition at line 157 of file remotesink.h.

References m_dataPort, and setChannelizer().

157 { m_dataPort = port; }
uint16_t m_dataPort
Definition: remotesink.h:190
+ Here is the call graph for this function:

◆ setNbBlocksFEC()

void RemoteSink::setNbBlocksFEC ( int  nbBlocksFEC)

Definition at line 117 of file remotesink.cpp.

References m_nbBlocksFEC.

Referenced by applySettings(), and setSampleRate().

118 {
119  qDebug() << "RemoteSink::setNbBlocksFEC: nbBlocksFEC: " << nbBlocksFEC;
120  m_nbBlocksFEC = nbBlocksFEC;
121 }
int m_nbBlocksFEC
Definition: remotesink.h:187
+ Here is the caller graph for this function:

◆ setSampleRate()

void RemoteSink::setSampleRate ( uint32_t  sampleRate)
inline

Set sample rate given in Hz

Definition at line 152 of file remotesink.h.

References m_sampleRate, setNbBlocksFEC(), and setTxDelay().

Referenced by handleMessage().

152 { m_sampleRate = sampleRate; }
uint32_t m_sampleRate
Definition: remotesink.h:185
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setTxDelay()

void RemoteSink::setTxDelay ( int  txDelay,
int  nbBlocksFEC 
)

Definition at line 104 of file remotesink.cpp.

Referenced by applySettings(), handleMessage(), and setSampleRate().

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 }
int m_txDelay
Definition: remotesink.h:188
uint32_t m_sampleRate
Definition: remotesink.h:185
+ Here is the caller graph for this function:

◆ start()

void RemoteSink::start ( )
virtual

Implements BasebandSampleSink.

Definition at line 233 of file remotesink.cpp.

References dataBlockAvailable(), m_currentMetaFEC, m_running, m_sinkThread, RemoteSinkThread::startStop(), and stop().

Referenced by destroy().

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 }
RemoteSinkThread * m_sinkThread
Definition: remotesink.h:173
RemoteMetaDataFEC m_currentMetaFEC
Definition: remotesink.h:179
bool m_running
Definition: remotesink.h:170
void startStop(bool start)
void dataBlockAvailable(RemoteDataBlock *dataBlock)
virtual void stop()
Definition: remotesink.cpp:253
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ stop()

void RemoteSink::stop ( )
virtual

Implements BasebandSampleSink.

Definition at line 253 of file remotesink.cpp.

References m_running, m_sinkThread, and RemoteSinkThread::startStop().

Referenced by destroy(), and start().

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 }
RemoteSinkThread * m_sinkThread
Definition: remotesink.h:173
bool m_running
Definition: remotesink.h:170
void startStop(bool start)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ validateFilterChainHash()

void RemoteSink::validateFilterChainHash ( RemoteSinkSettings settings)
private

Definition at line 415 of file remotesink.cpp.

References i, RemoteSinkSettings::m_filterChainHash, and RemoteSinkSettings::m_log2Decim.

Referenced by webapiSettingsPutPatch().

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 }
int32_t i
Definition: decimators.h:244
+ Here is the caller graph for this function:

◆ webapiFormatChannelSettings()

void RemoteSink::webapiFormatChannelSettings ( SWGSDRangel::SWGChannelSettings response,
const RemoteSinkSettings settings 
)
private

Definition at line 542 of file remotesink.cpp.

References SWGSDRangel::SWGRemoteSinkSettings::getDataAddress(), SWGSDRangel::SWGChannelSettings::getRemoteSinkSettings(), SWGSDRangel::SWGRemoteSinkSettings::getReverseApiAddress(), SWGSDRangel::SWGRemoteSinkSettings::getTitle(), RemoteSinkSettings::m_dataAddress, RemoteSinkSettings::m_dataPort, RemoteSinkSettings::m_filterChainHash, RemoteSinkSettings::m_log2Decim, RemoteSinkSettings::m_nbFECBlocks, RemoteSinkSettings::m_reverseAPIAddress, RemoteSinkSettings::m_reverseAPIChannelIndex, RemoteSinkSettings::m_reverseAPIDeviceIndex, RemoteSinkSettings::m_reverseAPIPort, RemoteSinkSettings::m_rgbColor, RemoteSinkSettings::m_title, RemoteSinkSettings::m_txDelay, RemoteSinkSettings::m_useReverseAPI, SWGSDRangel::SWGRemoteSinkSettings::setDataAddress(), SWGSDRangel::SWGRemoteSinkSettings::setDataPort(), SWGSDRangel::SWGRemoteSinkSettings::setFilterChainHash(), SWGSDRangel::SWGRemoteSinkSettings::setLog2Decim(), SWGSDRangel::SWGRemoteSinkSettings::setNbFecBlocks(), SWGSDRangel::SWGRemoteSinkSettings::setReverseApiAddress(), SWGSDRangel::SWGRemoteSinkSettings::setReverseApiChannelIndex(), SWGSDRangel::SWGRemoteSinkSettings::setReverseApiDeviceIndex(), SWGSDRangel::SWGRemoteSinkSettings::setReverseApiPort(), SWGSDRangel::SWGRemoteSinkSettings::setRgbColor(), SWGSDRangel::SWGRemoteSinkSettings::setTitle(), SWGSDRangel::SWGRemoteSinkSettings::setTxDelay(), and SWGSDRangel::SWGRemoteSinkSettings::setUseReverseApi().

Referenced by webapiSettingsGet(), and webapiSettingsPutPatch().

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 }
uint16_t m_reverseAPIDeviceIndex
void setNbFecBlocks(qint32 nb_fec_blocks)
void setFilterChainHash(qint32 filter_chain_hash)
void setDataAddress(QString *data_address)
uint16_t m_reverseAPIChannelIndex
void setReverseApiPort(qint32 reverse_api_port)
void setReverseApiDeviceIndex(qint32 reverse_api_device_index)
SWGRemoteSinkSettings * getRemoteSinkSettings()
void setReverseApiChannelIndex(qint32 reverse_api_channel_index)
void setReverseApiAddress(QString *reverse_api_address)
void setUseReverseApi(qint32 use_reverse_api)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiReverseSendSettings()

void RemoteSink::webapiReverseSendSettings ( QList< QString > &  channelSettingsKeys,
const RemoteSinkSettings settings,
bool  force 
)
private

Definition at line 577 of file remotesink.cpp.

References SWGSDRangel::SWGChannelSettings::asJson(), ChannelAPI::getDeviceSetIndex(), ChannelAPI::getIndexInDeviceSet(), SWGSDRangel::SWGChannelSettings::getRemoteSinkSettings(), RemoteSinkSettings::m_dataAddress, RemoteSinkSettings::m_dataPort, RemoteSinkSettings::m_filterChainHash, RemoteSinkSettings::m_log2Decim, RemoteSinkSettings::m_nbFECBlocks, m_networkManager, m_networkRequest, RemoteSinkSettings::m_reverseAPIAddress, RemoteSinkSettings::m_reverseAPIChannelIndex, RemoteSinkSettings::m_reverseAPIDeviceIndex, RemoteSinkSettings::m_reverseAPIPort, RemoteSinkSettings::m_rgbColor, RemoteSinkSettings::m_title, RemoteSinkSettings::m_txDelay, SWGSDRangel::SWGChannelSettings::setChannelType(), SWGSDRangel::SWGRemoteSinkSettings::setDataAddress(), SWGSDRangel::SWGRemoteSinkSettings::setDataPort(), SWGSDRangel::SWGChannelSettings::setDirection(), SWGSDRangel::SWGRemoteSinkSettings::setFilterChainHash(), SWGSDRangel::SWGRemoteSinkSettings::setLog2Decim(), SWGSDRangel::SWGRemoteSinkSettings::setNbFecBlocks(), SWGSDRangel::SWGChannelSettings::setOriginatorChannelIndex(), SWGSDRangel::SWGChannelSettings::setOriginatorDeviceSetIndex(), SWGSDRangel::SWGChannelSettings::setRemoteSinkSettings(), SWGSDRangel::SWGRemoteSinkSettings::setRgbColor(), SWGSDRangel::SWGRemoteSinkSettings::setTitle(), and SWGSDRangel::SWGRemoteSinkSettings::setTxDelay().

Referenced by applySettings().

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 }
void setOriginatorChannelIndex(qint32 originator_channel_index)
uint16_t m_reverseAPIDeviceIndex
void setNbFecBlocks(qint32 nb_fec_blocks)
int getDeviceSetIndex() const
Definition: channelapi.h:89
void setFilterChainHash(qint32 filter_chain_hash)
QNetworkAccessManager * m_networkManager
Definition: remotesink.h:191
void setChannelType(QString *channel_type)
void setOriginatorDeviceSetIndex(qint32 originator_device_set_index)
void setDataAddress(QString *data_address)
QNetworkRequest m_networkRequest
Definition: remotesink.h:192
uint16_t m_reverseAPIChannelIndex
virtual QString asJson() override
void setRemoteSinkSettings(SWGRemoteSinkSettings *remote_sink_settings)
SWGRemoteSinkSettings * getRemoteSinkSettings()
int getIndexInDeviceSet() const
Definition: channelapi.h:87
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiSettingsGet()

int RemoteSink::webapiSettingsGet ( SWGSDRangel::SWGChannelSettings response,
QString &  errorMessage 
)
virtual

Reimplemented from ChannelAPI.

Definition at line 432 of file remotesink.cpp.

References SWGSDRangel::SWGChannelSettings::getRemoteSinkSettings(), SWGSDRangel::SWGRemoteSinkSettings::init(), m_settings, SWGSDRangel::SWGChannelSettings::setRemoteSinkSettings(), and webapiFormatChannelSettings().

Referenced by getStreamCenterFrequency().

435 {
436  (void) errorMessage;
438  response.getRemoteSinkSettings()->init();
440  return 200;
441 }
void webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings &response, const RemoteSinkSettings &settings)
Definition: remotesink.cpp:542
RemoteSinkSettings m_settings
Definition: remotesink.h:172
void setRemoteSinkSettings(SWGRemoteSinkSettings *remote_sink_settings)
SWGRemoteSinkSettings * getRemoteSinkSettings()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiSettingsPutPatch()

int RemoteSink::webapiSettingsPutPatch ( bool  force,
const QStringList &  channelSettingsKeys,
SWGSDRangel::SWGChannelSettings response,
QString &  errorMessage 
)
virtual

Reimplemented from ChannelAPI.

Definition at line 443 of file remotesink.cpp.

References RemoteSink::MsgConfigureRemoteSink::create(), RemoteSink::MsgConfigureChannelizer::create(), SWGSDRangel::SWGRemoteSinkSettings::getDataAddress(), SWGSDRangel::SWGRemoteSinkSettings::getDataPort(), SWGSDRangel::SWGRemoteSinkSettings::getFilterChainHash(), SWGSDRangel::SWGRemoteSinkSettings::getLog2Decim(), SWGSDRangel::SWGRemoteSinkSettings::getNbFecBlocks(), SWGSDRangel::SWGChannelSettings::getRemoteSinkSettings(), SWGSDRangel::SWGRemoteSinkSettings::getReverseApiAddress(), SWGSDRangel::SWGRemoteSinkSettings::getReverseApiChannelIndex(), SWGSDRangel::SWGRemoteSinkSettings::getReverseApiDeviceIndex(), SWGSDRangel::SWGRemoteSinkSettings::getReverseApiPort(), SWGSDRangel::SWGRemoteSinkSettings::getRgbColor(), SWGSDRangel::SWGRemoteSinkSettings::getTitle(), SWGSDRangel::SWGRemoteSinkSettings::getTxDelay(), SWGSDRangel::SWGRemoteSinkSettings::getUseReverseApi(), RemoteSinkSettings::m_dataAddress, RemoteSinkSettings::m_dataPort, RemoteSinkSettings::m_filterChainHash, BasebandSampleSink::m_guiMessageQueue, BasebandSampleSink::m_inputMessageQueue, RemoteSinkSettings::m_log2Decim, RemoteSinkSettings::m_nbFECBlocks, RemoteSinkSettings::m_reverseAPIAddress, RemoteSinkSettings::m_reverseAPIChannelIndex, RemoteSinkSettings::m_reverseAPIDeviceIndex, RemoteSinkSettings::m_reverseAPIPort, RemoteSinkSettings::m_rgbColor, m_settings, RemoteSinkSettings::m_title, RemoteSinkSettings::m_txDelay, RemoteSinkSettings::m_useReverseAPI, MessageQueue::push(), validateFilterChainHash(), and webapiFormatChannelSettings().

Referenced by getStreamCenterFrequency().

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 
521  MsgConfigureRemoteSink *msg = MsgConfigureRemoteSink::create(settings, force);
523 
524  if ((settings.m_log2Decim != m_settings.m_log2Decim) || (settings.m_filterChainHash != m_settings.m_filterChainHash) || force)
525  {
526  MsgConfigureChannelizer *msg = MsgConfigureChannelizer::create(settings.m_log2Decim, settings.m_filterChainHash);
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 }
void validateFilterChainHash(RemoteSinkSettings &settings)
Definition: remotesink.cpp:415
void push(Message *message, bool emitSignal=true)
Push message onto queue.
uint16_t m_reverseAPIDeviceIndex
void webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings &response, const RemoteSinkSettings &settings)
Definition: remotesink.cpp:542
static MsgConfigureChannelizer * create(int sampleRate, int centerFrequency)
Definition: remotesink.h:96
MessageQueue m_inputMessageQueue
Queue for asynchronous inbound communication.
RemoteSinkSettings m_settings
Definition: remotesink.h:172
uint16_t m_reverseAPIChannelIndex
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
static MsgConfigureRemoteSink * create(const RemoteSinkSettings &settings, bool force)
Definition: remotesink.h:53
SWGRemoteSinkSettings * getRemoteSinkSettings()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_centerFrequency

uint64_t RemoteSink::m_centerFrequency
private

Definition at line 183 of file remotesink.h.

Referenced by feed(), and setCenterFrequency().

◆ m_channelId

const QString RemoteSink::m_channelId = "RemoteSink"
static

Definition at line 161 of file remotesink.h.

Referenced by RemoteSinkPlugin::initPlugin(), and RemoteSink().

◆ m_channelIdURI

const QString RemoteSink::m_channelIdURI = "sdrangel.channel.remotesink"
static

Definition at line 160 of file remotesink.h.

Referenced by RemoteSinkPlugin::initPlugin(), and RemoteSinkGUI::RemoteSinkGUI().

◆ m_channelizer

DownChannelizer* RemoteSink::m_channelizer
private

Definition at line 169 of file remotesink.h.

Referenced by handleMessage(), RemoteSink(), and ~RemoteSink().

◆ m_currentMetaFEC

RemoteMetaDataFEC RemoteSink::m_currentMetaFEC
private

Definition at line 179 of file remotesink.h.

Referenced by start().

◆ m_dataAddress

QString RemoteSink::m_dataAddress
private

Definition at line 189 of file remotesink.h.

Referenced by applySettings(), and setDataAddress().

◆ m_dataBlock

RemoteDataBlock* RemoteSink::m_dataBlock
private

Definition at line 180 of file remotesink.h.

Referenced by ~RemoteSink().

◆ m_dataBlockMutex

QMutex RemoteSink::m_dataBlockMutex
private

Definition at line 181 of file remotesink.h.

Referenced by ~RemoteSink().

◆ m_dataPort

uint16_t RemoteSink::m_dataPort
private

Definition at line 190 of file remotesink.h.

Referenced by applySettings(), and setDataPort().

◆ m_deviceAPI

DeviceAPI* RemoteSink::m_deviceAPI
private

Definition at line 167 of file remotesink.h.

Referenced by RemoteSink(), and ~RemoteSink().

◆ m_deviceSampleRate

uint32_t RemoteSink::m_deviceSampleRate
private

Definition at line 186 of file remotesink.h.

Referenced by calculateFrequencyOffset(), and handleMessage().

◆ m_frameCount

uint16_t RemoteSink::m_frameCount
private

transmission frame count

Definition at line 176 of file remotesink.h.

◆ m_frequencyOffset

int64_t RemoteSink::m_frequencyOffset
private

◆ m_nbBlocksFEC

int RemoteSink::m_nbBlocksFEC
private

Definition at line 187 of file remotesink.h.

Referenced by setNbBlocksFEC().

◆ m_networkManager

QNetworkAccessManager* RemoteSink::m_networkManager
private

Definition at line 191 of file remotesink.h.

Referenced by RemoteSink(), webapiReverseSendSettings(), and ~RemoteSink().

◆ m_networkRequest

QNetworkRequest RemoteSink::m_networkRequest
private

Definition at line 192 of file remotesink.h.

Referenced by webapiReverseSendSettings().

◆ m_running

bool RemoteSink::m_running
private

Definition at line 170 of file remotesink.h.

Referenced by start(), and stop().

◆ m_sampleIndex

int RemoteSink::m_sampleIndex
private

Current sample index in protected block data.

Definition at line 177 of file remotesink.h.

◆ m_sampleRate

uint32_t RemoteSink::m_sampleRate
private

◆ m_settings

RemoteSinkSettings RemoteSink::m_settings
private

◆ m_sinkThread

RemoteSinkThread* RemoteSink::m_sinkThread
private

Definition at line 173 of file remotesink.h.

Referenced by start(), and stop().

◆ m_superBlock

RemoteSuperBlock RemoteSink::m_superBlock
private

Definition at line 178 of file remotesink.h.

◆ m_threadedChannelizer

ThreadedBasebandSampleSink* RemoteSink::m_threadedChannelizer
private

Definition at line 168 of file remotesink.h.

Referenced by RemoteSink(), and ~RemoteSink().

◆ m_txBlockIndex

int RemoteSink::m_txBlockIndex
private

Current index in blocks to transmit in the Tx row.

Definition at line 175 of file remotesink.h.

Referenced by feed().

◆ m_txDelay

int RemoteSink::m_txDelay
private

Definition at line 188 of file remotesink.h.


The documentation for this class was generated from the following files: