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
LocalSink Class Reference

#include <localsink.h>

+ Inheritance diagram for LocalSink:
+ Collaboration diagram for LocalSink:

Classes

class  MsgConfigureChannelizer
 
class  MsgConfigureLocalSink
 
class  MsgSampleRateNotification
 

Signals

void samplesAvailable (const quint8 *data, uint count)
 

Public Member Functions

 LocalSink (DeviceAPI *deviceAPI)
 
virtual ~LocalSink ()
 
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 setChannelizer (unsigned int log2Decim, unsigned int filterChainHash)
 
void getLocalDevices (std::vector< uint32_t > &indexes)
 
- 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.localsink"
 
static const QString m_channelId = "LocalSink"
 

Private Slots

void networkManagerFinished (QNetworkReply *reply)
 

Private Member Functions

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

Private Attributes

DeviceAPIm_deviceAPI
 
ThreadedBasebandSampleSinkm_threadedChannelizer
 
DownChannelizerm_channelizer
 
bool m_running
 
LocalSinkSettings m_settings
 
LocalSinkThreadm_sinkThread
 
uint64_t m_centerFrequency
 
int64_t m_frequencyOffset
 
uint32_t m_sampleRate
 
uint32_t m_deviceSampleRate
 
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 37 of file localsink.h.

Constructor & Destructor Documentation

◆ LocalSink()

LocalSink::LocalSink ( DeviceAPI deviceAPI)

Definition at line 48 of file localsink.cpp.

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

Referenced by LocalSink::MsgConfigureChannelizer::MsgConfigureChannelizer().

48  :
50  m_deviceAPI(deviceAPI),
51  m_running(false),
52  m_sinkThread(0),
55  m_sampleRate(48000),
56  m_deviceSampleRate(48000)
57 {
58  setObjectName(m_channelId);
59 
60  m_channelizer = new DownChannelizer(this);
64 
65  m_networkManager = new QNetworkAccessManager();
66  connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
67 }
int64_t m_frequencyOffset
Definition: localsink.h:166
void networkManagerFinished(QNetworkReply *reply)
Definition: localsink.cpp:488
uint64_t m_centerFrequency
Definition: localsink.h:165
uint32_t m_sampleRate
Definition: localsink.h:167
void addChannelSinkAPI(ChannelAPI *channelAPI, int streamIndex=0)
Definition: deviceapi.cpp:156
DownChannelizer * m_channelizer
Definition: localsink.h:159
uint32_t m_deviceSampleRate
Definition: localsink.h:168
bool m_running
Definition: localsink.h:160
ThreadedBasebandSampleSink * m_threadedChannelizer
Definition: localsink.h:158
ChannelAPI(const QString &name, StreamType streamType)
Definition: channelapi.cpp:23
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
static const QString m_channelId
Definition: localsink.h:151
DeviceAPI * m_deviceAPI
Definition: localsink.h:157
LocalSinkThread * m_sinkThread
Definition: localsink.h:163
static const QString m_channelIdURI
Definition: localsink.h:150
QNetworkAccessManager * m_networkManager
Definition: localsink.h:170
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ~LocalSink()

LocalSink::~LocalSink ( )
virtual

Definition at line 69 of file localsink.cpp.

References m_channelizer, m_deviceAPI, m_networkManager, m_threadedChannelizer, networkManagerFinished(), DeviceAPI::removeChannelSink(), and DeviceAPI::removeChannelSinkAPI().

Referenced by LocalSink::MsgConfigureChannelizer::MsgConfigureChannelizer().

70 {
71  disconnect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
72  delete m_networkManager;
75  delete m_threadedChannelizer;
76  delete m_channelizer;
77 }
void networkManagerFinished(QNetworkReply *reply)
Definition: localsink.cpp:488
void removeChannelSinkAPI(ChannelAPI *channelAPI, int streamIndex=0)
Definition: deviceapi.cpp:163
DownChannelizer * m_channelizer
Definition: localsink.h:159
ThreadedBasebandSampleSink * m_threadedChannelizer
Definition: localsink.h:158
void removeChannelSink(ThreadedBasebandSampleSink *sink, int streamIndex=0)
Remove a channel sink (Rx)
Definition: deviceapi.cpp:127
DeviceAPI * m_deviceAPI
Definition: localsink.h:157
QNetworkAccessManager * m_networkManager
Definition: localsink.h:170
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Function Documentation

◆ applySettings()

void LocalSink::applySettings ( const LocalSinkSettings settings,
bool  force = false 
)
private

Definition at line 282 of file localsink.cpp.

References getLocalDevice(), DeviceSampleSource::getSampleFifo(), LocalSinkSettings::m_localDeviceIndex, LocalSinkSettings::m_reverseAPIAddress, LocalSinkSettings::m_reverseAPIChannelIndex, LocalSinkSettings::m_reverseAPIDeviceIndex, LocalSinkSettings::m_reverseAPIPort, m_settings, m_sinkThread, LocalSinkSettings::m_useReverseAPI, propagateSampleRateAndFrequency(), LocalSinkThread::setSampleFifo(), and webapiReverseSendSettings().

Referenced by handleMessage().

283 {
284  qDebug() << "LocalSink::applySettings:"
285  << " m_localDeviceIndex: " << settings.m_localDeviceIndex
286  << " force: " << force;
287 
288  QList<QString> reverseAPIKeys;
289 
290  if ((settings.m_localDeviceIndex != m_settings.m_localDeviceIndex) || force)
291  {
292  reverseAPIKeys.append("localDeviceIndex");
293  DeviceSampleSource *deviceSource = getLocalDevice(settings.m_localDeviceIndex);
294 
295  if (deviceSource)
296  {
297  if (m_sinkThread) {
298  m_sinkThread->setSampleFifo(deviceSource->getSampleFifo());
299  }
300 
302  }
303  else
304  {
305  qWarning("LocalSink::applySettings: invalid local device for index %u", settings.m_localDeviceIndex);
306  }
307  }
308 
309  if ((settings.m_useReverseAPI) && (reverseAPIKeys.size() != 0))
310  {
311  bool fullUpdate = ((m_settings.m_useReverseAPI != settings.m_useReverseAPI) && settings.m_useReverseAPI) ||
316  webapiReverseSendSettings(reverseAPIKeys, settings, fullUpdate || force);
317  }
318 
319  m_settings = settings;
320 }
DeviceSampleSource * getLocalDevice(uint32_t index)
Definition: localsink.cpp:239
SampleSinkFifo * getSampleFifo()
uint16_t m_reverseAPIChannelIndex
uint16_t m_reverseAPIDeviceIndex
void propagateSampleRateAndFrequency(uint32_t index)
Definition: localsink.cpp:271
void webapiReverseSendSettings(QList< QString > &channelSettingsKeys, const LocalSinkSettings &settings, bool force)
Definition: localsink.cpp:441
void setSampleFifo(SampleSinkFifo *sampleFifo)
LocalSinkSettings m_settings
Definition: localsink.h:162
LocalSinkThread * m_sinkThread
Definition: localsink.h:163
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calculateFrequencyOffset()

void LocalSink::calculateFrequencyOffset ( )
private

Definition at line 333 of file localsink.cpp.

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

Referenced by handleMessage().

334 {
336  m_frequencyOffset = m_deviceSampleRate * shiftFactor;
337 }
int64_t m_frequencyOffset
Definition: localsink.h:166
uint32_t m_deviceSampleRate
Definition: localsink.h:168
LocalSinkSettings m_settings
Definition: localsink.h:162
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:

◆ deserialize()

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

Implements ChannelAPI.

Definition at line 205 of file localsink.cpp.

References LocalSink::MsgConfigureLocalSink::create(), LocalSinkSettings::deserialize(), BasebandSampleSink::m_inputMessageQueue, m_settings, MessageQueue::push(), and LocalSinkSettings::resetToDefaults().

Referenced by getCenterFrequency().

206 {
207  (void) data;
208  if (m_settings.deserialize(data))
209  {
210  MsgConfigureLocalSink *msg = MsgConfigureLocalSink::create(m_settings, true);
212  return true;
213  }
214  else
215  {
217  MsgConfigureLocalSink *msg = MsgConfigureLocalSink::create(m_settings, true);
219  return false;
220  }
221 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
MessageQueue m_inputMessageQueue
Queue for asynchronous inbound communication.
bool deserialize(const QByteArray &data)
static MsgConfigureLocalSink * create(const LocalSinkSettings &settings, bool force)
Definition: localsink.h:47
LocalSinkSettings m_settings
Definition: localsink.h:162
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ destroy()

virtual void LocalSink::destroy ( )
inlinevirtual

Implements ChannelAPI.

Definition at line 107 of file localsink.h.

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

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

◆ feed()

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

Implements BasebandSampleSink.

Definition at line 79 of file localsink.cpp.

References samplesAvailable().

Referenced by destroy().

80 {
81  (void) firstOfBurst;
82  emit samplesAvailable((const quint8*) &(*begin), (end-begin)*sizeof(Sample));
83 }
void samplesAvailable(const quint8 *data, uint count)
+ Here is the caller graph for this function:

◆ getCenterFrequency()

virtual qint64 LocalSink::getCenterFrequency ( ) const
inlinevirtual

Applies to a default stream.

Implements ChannelAPI.

Definition at line 116 of file localsink.h.

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

116 { return m_frequencyOffset; }
int64_t m_frequencyOffset
Definition: localsink.h:166
+ Here is the call graph for this function:

◆ getIdentifier()

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

Implements ChannelAPI.

Definition at line 114 of file localsink.h.

114 { id = objectName(); }

◆ getLocalDevice()

DeviceSampleSource * LocalSink::getLocalDevice ( uint32_t  index)
private

Definition at line 239 of file localsink.cpp.

References ChannelAPI::getDeviceAPI(), DeviceSampleSource::getDeviceDescription(), DSPEngine::getDeviceSourceEngineByIndex(), DSPDeviceSourceEngine::getSource(), DSPDeviceSourceEngine::getUID(), and DSPEngine::instance().

Referenced by applySettings(), propagateSampleRateAndFrequency(), and start().

240 {
241  DSPEngine *dspEngine = DSPEngine::instance();
242 
243  if (index < dspEngine->getDeviceSourceEnginesNumber())
244  {
245  DSPDeviceSourceEngine *deviceSourceEngine = dspEngine->getDeviceSourceEngineByIndex(index);
246  DeviceSampleSource *deviceSource = deviceSourceEngine->getSource();
247 
248  if (deviceSource->getDeviceDescription() == "LocalInput")
249  {
250  if (!getDeviceAPI()) {
251  qDebug("LocalSink::getLocalDevice: the parent device is unset");
252  } else if (getDeviceAPI()->getDeviceUID() == deviceSourceEngine->getUID()) {
253  qDebug("LocalSink::getLocalDevice: source device at index %u is the parent device", index);
254  } else {
255  return deviceSource;
256  }
257  }
258  else
259  {
260  qDebug("LocalSink::getLocalDevice: source device at index %u is not a Local Input source", index);
261  }
262  }
263  else
264  {
265  qDebug("LocalSink::getLocalDevice: non existent source device index: %u", index);
266  }
267 
268  return nullptr;
269 }
DeviceSampleSource * getSource()
DSPDeviceSourceEngine * getDeviceSourceEngineByIndex(uint deviceIndex)
Definition: dspengine.h:59
virtual const QString & getDeviceDescription() const =0
static DSPEngine * instance()
Definition: dspengine.cpp:51
DeviceAPI * getDeviceAPI()
Definition: channelapi.h:91
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLocalDevices()

void LocalSink::getLocalDevices ( std::vector< uint32_t > &  indexes)

Definition at line 223 of file localsink.cpp.

References DeviceSampleSource::getDeviceDescription(), DSPEngine::getDeviceSourceEngineByIndex(), DSPEngine::getDeviceSourceEnginesNumber(), DSPDeviceSourceEngine::getSource(), i, and DSPEngine::instance().

Referenced by setSampleRate(), and LocalSinkGUI::updateLocalDevices().

224 {
225  indexes.clear();
226  DSPEngine *dspEngine = DSPEngine::instance();
227 
228  for (uint32_t i = 0; i < dspEngine->getDeviceSourceEnginesNumber(); i++)
229  {
230  DSPDeviceSourceEngine *deviceSourceEngine = dspEngine->getDeviceSourceEngineByIndex(i);
231  DeviceSampleSource *deviceSource = deviceSourceEngine->getSource();
232 
233  if (deviceSource->getDeviceDescription() == "LocalInput") {
234  indexes.push_back(i);
235  }
236  }
237 }
DeviceSampleSource * getSource()
DSPDeviceSourceEngine * getDeviceSourceEngineByIndex(uint deviceIndex)
Definition: dspengine.h:59
unsigned int uint32_t
Definition: rtptypes_win.h:46
virtual const QString & getDeviceDescription() const =0
static DSPEngine * instance()
Definition: dspengine.cpp:51
int32_t i
Definition: decimators.h:244
uint32_t getDeviceSourceEnginesNumber() const
Definition: dspengine.h:58
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getNbSinkStreams()

virtual int LocalSink::getNbSinkStreams ( ) const
inlinevirtual

Implements ChannelAPI.

Definition at line 121 of file localsink.h.

121 { return 1; }

◆ getNbSourceStreams()

virtual int LocalSink::getNbSourceStreams ( ) const
inlinevirtual

Implements ChannelAPI.

Definition at line 122 of file localsink.h.

122 { return 0; }

◆ getStreamCenterFrequency()

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

Implements ChannelAPI.

Definition at line 124 of file localsink.h.

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

125  {
126  (void) streamIndex;
127  (void) sinkElseSource;
128  return m_frequencyOffset;
129  }
int64_t m_frequencyOffset
Definition: localsink.h:166
+ Here is the call graph for this function:

◆ getTitle()

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

Implements ChannelAPI.

Definition at line 115 of file localsink.h.

115 { title = "Local Sink"; }

◆ handleMessage()

bool LocalSink::handleMessage ( const Message cmd)
virtual

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

Implements BasebandSampleSink.

Definition at line 124 of file localsink.cpp.

References applySettings(), calculateFrequencyOffset(), LocalSink::MsgSampleRateNotification::create(), DSPSignalNotification::getCenterFrequency(), LocalSink::MsgConfigureChannelizer::getFilterChainHash(), LocalSink::MsgConfigureLocalSink::getForce(), DownChannelizer::MsgChannelizerNotification::getFrequencyOffset(), BasebandSampleSink::getInputMessageQueue(), LocalSink::MsgConfigureChannelizer::getLog2Decim(), DownChannelizer::MsgChannelizerNotification::getSampleRate(), DSPSignalNotification::getSampleRate(), LocalSink::MsgConfigureLocalSink::getSettings(), m_channelizer, m_deviceSampleRate, LocalSinkSettings::m_filterChainHash, BasebandSampleSink::m_guiMessageQueue, LocalSinkSettings::m_localDeviceIndex, LocalSinkSettings::m_log2Decim, m_settings, Message::match(), propagateSampleRateAndFrequency(), MessageQueue::push(), DownChannelizer::set(), setCenterFrequency(), and setSampleRate().

Referenced by destroy().

125 {
127  {
129 
130  qDebug() << "LocalSink::handleMessage: MsgChannelizerNotification:"
131  << " channelSampleRate: " << notif.getSampleRate()
132  << " offsetFrequency: " << notif.getFrequencyOffset();
133 
134  if (notif.getSampleRate() > 0)
135  {
136  setSampleRate(notif.getSampleRate());
137  }
138 
139  return true;
140  }
141  else if (DSPSignalNotification::match(cmd))
142  {
144 
145  qDebug() << "LocalSink::handleMessage: DSPSignalNotification:"
146  << " inputSampleRate: " << notif.getSampleRate()
147  << " centerFrequency: " << notif.getCenterFrequency();
148 
151  calculateFrequencyOffset(); // This is when device sample rate changes
153 
154  // Redo the channelizer stuff with the new sample rate to re-synchronize everything
158 
159  if (m_guiMessageQueue)
160  {
161  MsgSampleRateNotification *msg = MsgSampleRateNotification::create(notif.getSampleRate());
162  m_guiMessageQueue->push(msg);
163  }
164 
165  return true;
166  }
167  else if (MsgConfigureLocalSink::match(cmd))
168  {
169  MsgConfigureLocalSink& cfg = (MsgConfigureLocalSink&) cmd;
170  qDebug() << "LocalSink::handleMessage: MsgConfigureLocalSink";
171  applySettings(cfg.getSettings(), cfg.getForce());
172 
173  return true;
174  }
175  else if (MsgConfigureChannelizer::match(cmd))
176  {
177  MsgConfigureChannelizer& cfg = (MsgConfigureChannelizer&) cmd;
178  m_settings.m_log2Decim = cfg.getLog2Decim();
179  m_settings.m_filterChainHash = cfg.getFilterChainHash();
180 
181  qDebug() << "LocalSink::handleMessage: MsgConfigureChannelizer:"
182  << " log2Decim: " << m_settings.m_log2Decim
183  << " filterChainHash: " << m_settings.m_filterChainHash;
184 
188 
189  calculateFrequencyOffset(); // This is when decimation or filter chain changes
191 
192  return true;
193  }
194  else
195  {
196  return false;
197  }
198 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
MessageQueue * getInputMessageQueue()
Get the queue for asynchronous inbound communication.
DownChannelizer * m_channelizer
Definition: localsink.h:159
uint32_t m_deviceSampleRate
Definition: localsink.h:168
void setCenterFrequency(uint64_t centerFrequency)
Definition: localsink.h:142
qint64 getCenterFrequency() const
Definition: dspcommands.h:329
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
void setSampleRate(uint32_t sampleRate)
Definition: localsink.h:145
void applySettings(const LocalSinkSettings &settings, bool force=false)
Definition: localsink.cpp:282
static MsgSampleRateNotification * create(int sampleRate)
Definition: localsink.h:67
void set(MessageQueue *messageQueue, unsigned int log2Decim, unsigned int filterChainHash)
static bool match(const Message *message)
Definition: message.cpp:45
void propagateSampleRateAndFrequency(uint32_t index)
Definition: localsink.cpp:271
int getSampleRate() const
Definition: dspcommands.h:328
LocalSinkSettings m_settings
Definition: localsink.h:162
void calculateFrequencyOffset()
Definition: localsink.cpp:333
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ networkManagerFinished

void LocalSink::networkManagerFinished ( QNetworkReply *  reply)
privateslot

Definition at line 488 of file localsink.cpp.

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

489 {
490  QNetworkReply::NetworkError replyError = reply->error();
491 
492  if (replyError)
493  {
494  qWarning() << "LocalSink::networkManagerFinished:"
495  << " error(" << (int) replyError
496  << "): " << replyError
497  << ": " << reply->errorString();
498  return;
499  }
500 
501  QString answer = reply->readAll();
502  answer.chop(1); // remove last \n
503  qDebug("LocalSink::networkManagerFinished: reply:\n%s", answer.toStdString().c_str());
504 }
+ Here is the caller graph for this function:

◆ propagateSampleRateAndFrequency()

void LocalSink::propagateSampleRateAndFrequency ( uint32_t  index)
private

Definition at line 271 of file localsink.cpp.

References getLocalDevice(), m_centerFrequency, m_deviceSampleRate, m_frequencyOffset, LocalSinkSettings::m_log2Decim, m_settings, DeviceSampleSource::setCenterFrequency(), and DeviceSampleSource::setSampleRate().

Referenced by applySettings(), and handleMessage().

272 {
273  DeviceSampleSource *deviceSource = getLocalDevice(index);
274 
275  if (deviceSource)
276  {
279  }
280 }
int64_t m_frequencyOffset
Definition: localsink.h:166
uint64_t m_centerFrequency
Definition: localsink.h:165
virtual void setSampleRate(int sampleRate)=0
For when the source sample rate is set externally.
DeviceSampleSource * getLocalDevice(uint32_t index)
Definition: localsink.cpp:239
uint32_t m_deviceSampleRate
Definition: localsink.h:168
virtual void setCenterFrequency(qint64 centerFrequency)=0
LocalSinkSettings m_settings
Definition: localsink.h:162
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ samplesAvailable

void LocalSink::samplesAvailable ( const quint8 *  data,
uint  count 
)
signal

Referenced by feed(), and start().

+ Here is the caller graph for this function:

◆ serialize()

QByteArray LocalSink::serialize ( ) const
virtual

Implements ChannelAPI.

Definition at line 200 of file localsink.cpp.

References m_settings, and LocalSinkSettings::serialize().

Referenced by getCenterFrequency().

201 {
202  return m_settings.serialize();
203 }
QByteArray serialize() const
LocalSinkSettings m_settings
Definition: localsink.h:162
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCenterFrequency()

void LocalSink::setCenterFrequency ( uint64_t  centerFrequency)
inline

Set center frequency given in Hz

Definition at line 142 of file localsink.h.

References m_centerFrequency.

Referenced by handleMessage().

142 { m_centerFrequency = centerFrequency; }
uint64_t m_centerFrequency
Definition: localsink.h:165
+ Here is the caller graph for this function:

◆ setChannelizer()

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

Referenced by setSampleRate().

+ Here is the caller graph for this function:

◆ setSampleRate()

void LocalSink::setSampleRate ( uint32_t  sampleRate)
inline

Set sample rate given in Hz

Definition at line 145 of file localsink.h.

References getLocalDevices(), m_sampleRate, and setChannelizer().

Referenced by handleMessage().

145 { m_sampleRate = sampleRate; }
uint32_t m_sampleRate
Definition: localsink.h:167
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ start()

void LocalSink::start ( )
virtual

Implements BasebandSampleSink.

Definition at line 85 of file localsink.cpp.

References getLocalDevice(), DeviceSampleSource::getSampleFifo(), LocalSinkSettings::m_localDeviceIndex, m_running, m_settings, m_sinkThread, samplesAvailable(), LocalSinkThread::setSampleFifo(), LocalSinkThread::startStop(), and stop().

Referenced by destroy().

86 {
87  qDebug("LocalSink::start");
88 
89  if (m_running) {
90  stop();
91  }
92 
95 
96  if (deviceSource) {
97  m_sinkThread->setSampleFifo(deviceSource->getSampleFifo());
98  }
99 
100  connect(this,
101  SIGNAL(samplesAvailable(const quint8*, uint)),
102  m_sinkThread,
103  SLOT(processSamples(const quint8*, uint)),
104  Qt::QueuedConnection);
105 
106  m_sinkThread->startStop(true);
107  m_running = true;
108 }
DeviceSampleSource * getLocalDevice(uint32_t index)
Definition: localsink.cpp:239
SampleSinkFifo * getSampleFifo()
bool m_running
Definition: localsink.h:160
void samplesAvailable(const quint8 *data, uint count)
void startStop(bool start)
void setSampleFifo(SampleSinkFifo *sampleFifo)
virtual void stop()
Definition: localsink.cpp:110
LocalSinkSettings m_settings
Definition: localsink.h:162
LocalSinkThread * m_sinkThread
Definition: localsink.h:163
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ stop()

void LocalSink::stop ( )
virtual

Implements BasebandSampleSink.

Definition at line 110 of file localsink.cpp.

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

Referenced by destroy(), and start().

111 {
112  qDebug("LocalSink::stop");
113 
114  if (m_sinkThread != 0)
115  {
116  m_sinkThread->startStop(false);
117  m_sinkThread->deleteLater();
118  m_sinkThread = 0;
119  }
120 
121  m_running = false;
122 }
bool m_running
Definition: localsink.h:160
void startStop(bool start)
LocalSinkThread * m_sinkThread
Definition: localsink.h:163
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ validateFilterChainHash()

void LocalSink::validateFilterChainHash ( LocalSinkSettings settings)
private

Definition at line 322 of file localsink.cpp.

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

Referenced by webapiSettingsPutPatch().

323 {
324  unsigned int s = 1;
325 
326  for (unsigned int i = 0; i < settings.m_log2Decim; i++) {
327  s *= 3;
328  }
329 
330  settings.m_filterChainHash = settings.m_filterChainHash >= s ? s-1 : settings.m_filterChainHash;
331 }
int32_t i
Definition: decimators.h:244
+ Here is the caller graph for this function:

◆ webapiFormatChannelSettings()

void LocalSink::webapiFormatChannelSettings ( SWGSDRangel::SWGChannelSettings response,
const LocalSinkSettings settings 
)
private

Definition at line 415 of file localsink.cpp.

References SWGSDRangel::SWGChannelSettings::getLocalSinkSettings(), SWGSDRangel::SWGLocalSinkSettings::getReverseApiAddress(), SWGSDRangel::SWGLocalSinkSettings::getTitle(), LocalSinkSettings::m_filterChainHash, LocalSinkSettings::m_localDeviceIndex, LocalSinkSettings::m_log2Decim, LocalSinkSettings::m_reverseAPIAddress, LocalSinkSettings::m_reverseAPIChannelIndex, LocalSinkSettings::m_reverseAPIDeviceIndex, LocalSinkSettings::m_reverseAPIPort, LocalSinkSettings::m_rgbColor, LocalSinkSettings::m_title, LocalSinkSettings::m_useReverseAPI, SWGSDRangel::SWGLocalSinkSettings::setFilterChainHash(), SWGSDRangel::SWGLocalSinkSettings::setLocalDeviceIndex(), SWGSDRangel::SWGLocalSinkSettings::setLog2Decim(), SWGSDRangel::SWGLocalSinkSettings::setReverseApiAddress(), SWGSDRangel::SWGLocalSinkSettings::setReverseApiChannelIndex(), SWGSDRangel::SWGLocalSinkSettings::setReverseApiDeviceIndex(), SWGSDRangel::SWGLocalSinkSettings::setReverseApiPort(), SWGSDRangel::SWGLocalSinkSettings::setRgbColor(), SWGSDRangel::SWGLocalSinkSettings::setTitle(), and SWGSDRangel::SWGLocalSinkSettings::setUseReverseApi().

Referenced by webapiSettingsGet(), and webapiSettingsPutPatch().

416 {
418  response.getLocalSinkSettings()->setRgbColor(settings.m_rgbColor);
419 
420  if (response.getLocalSinkSettings()->getTitle()) {
421  *response.getLocalSinkSettings()->getTitle() = settings.m_title;
422  } else {
423  response.getLocalSinkSettings()->setTitle(new QString(settings.m_title));
424  }
425 
426  response.getLocalSinkSettings()->setLog2Decim(settings.m_log2Decim);
428  response.getLocalSinkSettings()->setUseReverseApi(settings.m_useReverseAPI ? 1 : 0);
429 
430  if (response.getLocalSinkSettings()->getReverseApiAddress()) {
432  } else {
433  response.getLocalSinkSettings()->setReverseApiAddress(new QString(settings.m_reverseAPIAddress));
434  }
435 
439 }
void setReverseApiChannelIndex(qint32 reverse_api_channel_index)
void setLocalDeviceIndex(qint32 local_device_index)
void setReverseApiDeviceIndex(qint32 reverse_api_device_index)
void setReverseApiAddress(QString *reverse_api_address)
uint16_t m_reverseAPIChannelIndex
void setUseReverseApi(qint32 use_reverse_api)
uint16_t m_reverseAPIDeviceIndex
SWGLocalSinkSettings * getLocalSinkSettings()
void setReverseApiPort(qint32 reverse_api_port)
void setFilterChainHash(qint32 filter_chain_hash)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiReverseSendSettings()

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

Definition at line 441 of file localsink.cpp.

References SWGSDRangel::SWGChannelSettings::asJson(), ChannelAPI::getDeviceSetIndex(), ChannelAPI::getIndexInDeviceSet(), SWGSDRangel::SWGChannelSettings::getLocalSinkSettings(), LocalSinkSettings::m_filterChainHash, LocalSinkSettings::m_localDeviceIndex, LocalSinkSettings::m_log2Decim, m_networkManager, m_networkRequest, LocalSinkSettings::m_reverseAPIAddress, LocalSinkSettings::m_reverseAPIChannelIndex, LocalSinkSettings::m_reverseAPIDeviceIndex, LocalSinkSettings::m_reverseAPIPort, LocalSinkSettings::m_rgbColor, LocalSinkSettings::m_title, SWGSDRangel::SWGChannelSettings::setChannelType(), SWGSDRangel::SWGChannelSettings::setDirection(), SWGSDRangel::SWGLocalSinkSettings::setFilterChainHash(), SWGSDRangel::SWGLocalSinkSettings::setLocalDeviceIndex(), SWGSDRangel::SWGChannelSettings::setLocalSinkSettings(), SWGSDRangel::SWGLocalSinkSettings::setLog2Decim(), SWGSDRangel::SWGChannelSettings::setOriginatorChannelIndex(), SWGSDRangel::SWGChannelSettings::setOriginatorDeviceSetIndex(), SWGSDRangel::SWGLocalSinkSettings::setRgbColor(), and SWGSDRangel::SWGLocalSinkSettings::setTitle().

Referenced by applySettings().

442 {
444  swgChannelSettings->setDirection(0); // single sink (Rx)
445  swgChannelSettings->setOriginatorChannelIndex(getIndexInDeviceSet());
446  swgChannelSettings->setOriginatorDeviceSetIndex(getDeviceSetIndex());
447  swgChannelSettings->setChannelType(new QString("LocalSink"));
448  swgChannelSettings->setLocalSinkSettings(new SWGSDRangel::SWGLocalSinkSettings());
449  SWGSDRangel::SWGLocalSinkSettings *swgLocalSinkSettings = swgChannelSettings->getLocalSinkSettings();
450 
451  // transfer data that has been modified. When force is on transfer all data except reverse API data
452 
453  if (channelSettingsKeys.contains("localDeviceIndex") || force) {
454  swgLocalSinkSettings->setLocalDeviceIndex(settings.m_localDeviceIndex);
455  }
456  if (channelSettingsKeys.contains("rgbColor") || force) {
457  swgLocalSinkSettings->setRgbColor(settings.m_rgbColor);
458  }
459  if (channelSettingsKeys.contains("title") || force) {
460  swgLocalSinkSettings->setTitle(new QString(settings.m_title));
461  }
462  if (channelSettingsKeys.contains("log2Decim") || force) {
463  swgLocalSinkSettings->setLog2Decim(settings.m_log2Decim);
464  }
465  if (channelSettingsKeys.contains("filterChainHash") || force) {
466  swgLocalSinkSettings->setFilterChainHash(settings.m_filterChainHash);
467  }
468 
469  QString channelSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/channel/%4/settings")
470  .arg(settings.m_reverseAPIAddress)
471  .arg(settings.m_reverseAPIPort)
472  .arg(settings.m_reverseAPIDeviceIndex)
473  .arg(settings.m_reverseAPIChannelIndex);
474  m_networkRequest.setUrl(QUrl(channelSettingsURL));
475  m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
476 
477  QBuffer *buffer=new QBuffer();
478  buffer->open((QBuffer::ReadWrite));
479  buffer->write(swgChannelSettings->asJson().toUtf8());
480  buffer->seek(0);
481 
482  // Always use PATCH to avoid passing reverse API settings
483  m_networkManager->sendCustomRequest(m_networkRequest, "PATCH", buffer);
484 
485  delete swgChannelSettings;
486 }
void setOriginatorChannelIndex(qint32 originator_channel_index)
void setLocalDeviceIndex(qint32 local_device_index)
int getDeviceSetIndex() const
Definition: channelapi.h:89
void setChannelType(QString *channel_type)
void setLocalSinkSettings(SWGLocalSinkSettings *local_sink_settings)
void setOriginatorDeviceSetIndex(qint32 originator_device_set_index)
uint16_t m_reverseAPIChannelIndex
QNetworkRequest m_networkRequest
Definition: localsink.h:171
uint16_t m_reverseAPIDeviceIndex
virtual QString asJson() override
SWGLocalSinkSettings * getLocalSinkSettings()
int getIndexInDeviceSet() const
Definition: channelapi.h:87
QNetworkAccessManager * m_networkManager
Definition: localsink.h:170
void setFilterChainHash(qint32 filter_chain_hash)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiSettingsGet()

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

Reimplemented from ChannelAPI.

Definition at line 339 of file localsink.cpp.

References SWGSDRangel::SWGChannelSettings::getLocalSinkSettings(), SWGSDRangel::SWGLocalSinkSettings::init(), m_settings, SWGSDRangel::SWGChannelSettings::setLocalSinkSettings(), and webapiFormatChannelSettings().

Referenced by getStreamCenterFrequency().

342 {
343  (void) errorMessage;
345  response.getLocalSinkSettings()->init();
347  return 200;
348 }
void setLocalSinkSettings(SWGLocalSinkSettings *local_sink_settings)
void webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings &response, const LocalSinkSettings &settings)
Definition: localsink.cpp:415
SWGLocalSinkSettings * getLocalSinkSettings()
LocalSinkSettings m_settings
Definition: localsink.h:162
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiSettingsPutPatch()

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

Reimplemented from ChannelAPI.

Definition at line 350 of file localsink.cpp.

References LocalSink::MsgConfigureLocalSink::create(), LocalSink::MsgConfigureChannelizer::create(), SWGSDRangel::SWGLocalSinkSettings::getFilterChainHash(), SWGSDRangel::SWGLocalSinkSettings::getLocalDeviceIndex(), SWGSDRangel::SWGChannelSettings::getLocalSinkSettings(), SWGSDRangel::SWGLocalSinkSettings::getLog2Decim(), SWGSDRangel::SWGLocalSinkSettings::getReverseApiAddress(), SWGSDRangel::SWGLocalSinkSettings::getReverseApiChannelIndex(), SWGSDRangel::SWGLocalSinkSettings::getReverseApiDeviceIndex(), SWGSDRangel::SWGLocalSinkSettings::getReverseApiPort(), SWGSDRangel::SWGLocalSinkSettings::getRgbColor(), SWGSDRangel::SWGLocalSinkSettings::getTitle(), SWGSDRangel::SWGLocalSinkSettings::getUseReverseApi(), LocalSinkSettings::m_filterChainHash, BasebandSampleSink::m_guiMessageQueue, BasebandSampleSink::m_inputMessageQueue, LocalSinkSettings::m_localDeviceIndex, LocalSinkSettings::m_log2Decim, LocalSinkSettings::m_reverseAPIAddress, LocalSinkSettings::m_reverseAPIChannelIndex, LocalSinkSettings::m_reverseAPIDeviceIndex, LocalSinkSettings::m_reverseAPIPort, LocalSinkSettings::m_rgbColor, m_settings, LocalSinkSettings::m_title, LocalSinkSettings::m_useReverseAPI, MessageQueue::push(), validateFilterChainHash(), and webapiFormatChannelSettings().

Referenced by getStreamCenterFrequency().

355 {
356  (void) errorMessage;
357  LocalSinkSettings settings = m_settings;
358 
359  if (channelSettingsKeys.contains("localDeviceIndex")) {
361  }
362  if (channelSettingsKeys.contains("rgbColor")) {
363  settings.m_rgbColor = response.getLocalSinkSettings()->getRgbColor();
364  }
365  if (channelSettingsKeys.contains("title")) {
366  settings.m_title = *response.getLocalSinkSettings()->getTitle();
367  }
368  if (channelSettingsKeys.contains("log2Decim")) {
369  settings.m_log2Decim = response.getLocalSinkSettings()->getLog2Decim();
370  }
371 
372  if (channelSettingsKeys.contains("filterChainHash"))
373  {
375  validateFilterChainHash(settings);
376  }
377 
378  if (channelSettingsKeys.contains("useReverseAPI")) {
379  settings.m_useReverseAPI = response.getLocalSinkSettings()->getUseReverseApi() != 0;
380  }
381  if (channelSettingsKeys.contains("reverseAPIAddress")) {
383  }
384  if (channelSettingsKeys.contains("reverseAPIPort")) {
386  }
387  if (channelSettingsKeys.contains("reverseAPIDeviceIndex")) {
389  }
390  if (channelSettingsKeys.contains("reverseAPIChannelIndex")) {
392  }
393 
394  MsgConfigureLocalSink *msg = MsgConfigureLocalSink::create(settings, force);
396 
397  if ((settings.m_log2Decim != m_settings.m_log2Decim) || (settings.m_filterChainHash != m_settings.m_filterChainHash) || force)
398  {
399  MsgConfigureChannelizer *msg = MsgConfigureChannelizer::create(settings.m_log2Decim, settings.m_filterChainHash);
401  }
402 
403  qDebug("LocalSink::webapiSettingsPutPatch: forward to GUI: %p", m_guiMessageQueue);
404  if (m_guiMessageQueue) // forward to GUI if any
405  {
406  MsgConfigureLocalSink *msgToGUI = MsgConfigureLocalSink::create(settings, force);
407  m_guiMessageQueue->push(msgToGUI);
408  }
409 
410  webapiFormatChannelSettings(response, settings);
411 
412  return 200;
413 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
MessageQueue m_inputMessageQueue
Queue for asynchronous inbound communication.
uint16_t m_reverseAPIChannelIndex
void webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings &response, const LocalSinkSettings &settings)
Definition: localsink.cpp:415
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
uint16_t m_reverseAPIDeviceIndex
static MsgConfigureLocalSink * create(const LocalSinkSettings &settings, bool force)
Definition: localsink.h:47
SWGLocalSinkSettings * getLocalSinkSettings()
static MsgConfigureChannelizer * create(unsigned int log2Decim, unsigned int filterChainHash)
Definition: localsink.h:90
LocalSinkSettings m_settings
Definition: localsink.h:162
void validateFilterChainHash(LocalSinkSettings &settings)
Definition: localsink.cpp:322
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_centerFrequency

uint64_t LocalSink::m_centerFrequency
private

Definition at line 165 of file localsink.h.

Referenced by propagateSampleRateAndFrequency(), and setCenterFrequency().

◆ m_channelId

const QString LocalSink::m_channelId = "LocalSink"
static

Definition at line 151 of file localsink.h.

Referenced by LocalSinkPlugin::initPlugin(), and LocalSink().

◆ m_channelIdURI

const QString LocalSink::m_channelIdURI = "sdrangel.channel.localsink"
static

Definition at line 150 of file localsink.h.

Referenced by LocalSinkPlugin::initPlugin(), and LocalSinkGUI::LocalSinkGUI().

◆ m_channelizer

DownChannelizer* LocalSink::m_channelizer
private

Definition at line 159 of file localsink.h.

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

◆ m_deviceAPI

DeviceAPI* LocalSink::m_deviceAPI
private

Definition at line 157 of file localsink.h.

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

◆ m_deviceSampleRate

uint32_t LocalSink::m_deviceSampleRate
private

◆ m_frequencyOffset

int64_t LocalSink::m_frequencyOffset
private

◆ m_networkManager

QNetworkAccessManager* LocalSink::m_networkManager
private

Definition at line 170 of file localsink.h.

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

◆ m_networkRequest

QNetworkRequest LocalSink::m_networkRequest
private

Definition at line 171 of file localsink.h.

Referenced by webapiReverseSendSettings().

◆ m_running

bool LocalSink::m_running
private

Definition at line 160 of file localsink.h.

Referenced by start(), and stop().

◆ m_sampleRate

uint32_t LocalSink::m_sampleRate
private

◆ m_settings

LocalSinkSettings LocalSink::m_settings
private

◆ m_sinkThread

LocalSinkThread* LocalSink::m_sinkThread
private

Definition at line 163 of file localsink.h.

Referenced by applySettings(), start(), and stop().

◆ m_threadedChannelizer

ThreadedBasebandSampleSink* LocalSink::m_threadedChannelizer
private

Definition at line 158 of file localsink.h.

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


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