20 #include <boost/crc.hpp> 21 #include <boost/cstdint.hpp> 23 #include <QNetworkAccessManager> 24 #include <QNetworkReply> 50 m_deviceAPI(deviceAPI),
56 m_deviceSampleRate(48000)
79 void LocalSink::feed(
const SampleVector::const_iterator& begin,
const SampleVector::const_iterator& end,
bool firstOfBurst)
87 qDebug(
"LocalSink::start");
103 SLOT(processSamples(
const quint8*, uint)),
104 Qt::QueuedConnection);
112 qDebug(
"LocalSink::stop");
130 qDebug() <<
"LocalSink::handleMessage: MsgChannelizerNotification:" 145 qDebug() <<
"LocalSink::handleMessage: DSPSignalNotification:" 170 qDebug() <<
"LocalSink::handleMessage: MsgConfigureLocalSink";
181 qDebug() <<
"LocalSink::handleMessage: MsgConfigureChannelizer:" 234 indexes.push_back(
i);
243 if (index < dspEngine->getDeviceSourceEnginesNumber())
251 qDebug(
"LocalSink::getLocalDevice: the parent device is unset");
253 qDebug(
"LocalSink::getLocalDevice: source device at index %u is the parent device", index);
260 qDebug(
"LocalSink::getLocalDevice: source device at index %u is not a Local Input source", index);
265 qDebug(
"LocalSink::getLocalDevice: non existent source device index: %u", index);
284 qDebug() <<
"LocalSink::applySettings:" 286 <<
" force: " << force;
288 QList<QString> reverseAPIKeys;
292 reverseAPIKeys.append(
"localDeviceIndex");
305 qWarning(
"LocalSink::applySettings: invalid local device for index %u", settings.
m_localDeviceIndex);
341 QString& errorMessage)
352 const QStringList& channelSettingsKeys,
354 QString& errorMessage)
359 if (channelSettingsKeys.contains(
"localDeviceIndex")) {
362 if (channelSettingsKeys.contains(
"rgbColor")) {
365 if (channelSettingsKeys.contains(
"title")) {
368 if (channelSettingsKeys.contains(
"log2Decim")) {
372 if (channelSettingsKeys.contains(
"filterChainHash"))
378 if (channelSettingsKeys.contains(
"useReverseAPI")) {
381 if (channelSettingsKeys.contains(
"reverseAPIAddress")) {
384 if (channelSettingsKeys.contains(
"reverseAPIPort")) {
387 if (channelSettingsKeys.contains(
"reverseAPIDeviceIndex")) {
390 if (channelSettingsKeys.contains(
"reverseAPIChannelIndex")) {
403 qDebug(
"LocalSink::webapiSettingsPutPatch: forward to GUI: %p",
m_guiMessageQueue);
453 if (channelSettingsKeys.contains(
"localDeviceIndex") || force) {
456 if (channelSettingsKeys.contains(
"rgbColor") || force) {
459 if (channelSettingsKeys.contains(
"title") || force) {
462 if (channelSettingsKeys.contains(
"log2Decim") || force) {
465 if (channelSettingsKeys.contains(
"filterChainHash") || force) {
469 QString channelSettingsURL = QString(
"http://%1:%2/sdrangel/deviceset/%3/channel/%4/settings")
475 m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader,
"application/json");
477 QBuffer *buffer=
new QBuffer();
478 buffer->open((QBuffer::ReadWrite));
479 buffer->write(swgChannelSettings->
asJson().toUtf8());
485 delete swgChannelSettings;
490 QNetworkReply::NetworkError replyError = reply->error();
494 qWarning() <<
"LocalSink::networkManagerFinished:" 495 <<
" error(" << (int) replyError
496 <<
"): " << replyError
497 <<
": " << reply->errorString();
501 QString answer = reply->readAll();
503 qDebug(
"LocalSink::networkManagerFinished: reply:\n%s", answer.toStdString().c_str());
int64_t m_frequencyOffset
void networkManagerFinished(QNetworkReply *reply)
void setOriginatorChannelIndex(qint32 originator_channel_index)
uint64_t m_centerFrequency
virtual void setSampleRate(int sampleRate)=0
For when the source sample rate is set externally.
DeviceSampleSource * getLocalDevice(uint32_t index)
SampleSinkFifo * getSampleFifo()
void push(Message *message, bool emitSignal=true)
Push message onto queue.
void setReverseApiChannelIndex(qint32 reverse_api_channel_index)
virtual QByteArray serialize() const
void removeChannelSinkAPI(ChannelAPI *channelAPI, int streamIndex=0)
void addChannelSinkAPI(ChannelAPI *channelAPI, int streamIndex=0)
QByteArray serialize() const
MessageQueue * getInputMessageQueue()
Get the queue for asynchronous inbound communication.
void setLocalDeviceIndex(qint32 local_device_index)
virtual int webapiSettingsPutPatch(bool force, const QStringList &channelSettingsKeys, SWGSDRangel::SWGChannelSettings &response, QString &errorMessage)
qint32 getReverseApiChannelIndex()
int getDeviceSetIndex() const
DeviceSampleSource * getSource()
int getSampleRate() const
DownChannelizer * m_channelizer
uint32_t m_deviceSampleRate
virtual void setCenterFrequency(qint64 centerFrequency)=0
void setReverseApiDeviceIndex(qint32 reverse_api_device_index)
QString * getReverseApiAddress()
void setReverseApiAddress(QString *reverse_api_address)
qint32 getFilterChainHash()
DSPDeviceSourceEngine * getDeviceSourceEngineByIndex(uint deviceIndex)
void setCenterFrequency(uint64_t centerFrequency)
void setChannelType(QString *channel_type)
void setLocalSinkSettings(SWGLocalSinkSettings *local_sink_settings)
void setOriginatorDeviceSetIndex(qint32 originator_device_set_index)
MessageQueue m_inputMessageQueue
Queue for asynchronous inbound communication.
void samplesAvailable(const quint8 *data, uint count)
virtual bool deserialize(const QByteArray &data)
ThreadedBasebandSampleSink * m_threadedChannelizer
uint16_t m_reverseAPIChannelIndex
qint64 getCenterFrequency() const
void webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings &response, const LocalSinkSettings &settings)
virtual const QString & getDeviceDescription() const =0
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
virtual int webapiSettingsGet(SWGSDRangel::SWGChannelSettings &response, QString &errorMessage)
void setSampleRate(uint32_t sampleRate)
void applySettings(const LocalSinkSettings &settings, bool force=false)
#define MESSAGE_CLASS_DEFINITION(Name, BaseClass)
LocalSink(DeviceAPI *deviceAPI)
void setLog2Decim(qint32 log2_decim)
static DSPEngine * instance()
bool deserialize(const QByteArray &data)
uint16_t m_reverseAPIPort
void setRgbColor(qint32 rgb_color)
void startStop(bool start)
qint32 getReverseApiDeviceIndex()
static MsgSampleRateNotification * create(int sampleRate)
void setUseReverseApi(qint32 use_reverse_api)
QNetworkRequest m_networkRequest
void set(MessageQueue *messageQueue, unsigned int log2Decim, unsigned int filterChainHash)
static bool match(const Message *message)
void removeChannelSink(ThreadedBasebandSampleSink *sink, int streamIndex=0)
Remove a channel sink (Rx)
qint32 getLocalDeviceIndex()
uint32_t getDeviceSourceEnginesNumber() const
uint16_t m_reverseAPIDeviceIndex
void setDirection(qint32 direction)
virtual bool handleMessage(const Message &cmd)
Processing of a message. Returns true if message has actually been processed.
virtual QString asJson() override
QString m_reverseAPIAddress
void propagateSampleRateAndFrequency(uint32_t index)
void webapiReverseSendSettings(QList< QString > &channelSettingsKeys, const LocalSinkSettings &settings, bool force)
void addChannelSink(ThreadedBasebandSampleSink *sink, int streamIndex=0)
Add a channel sink (Rx)
void setSampleFifo(SampleSinkFifo *sampleFifo)
qint32 getUseReverseApi()
int getSampleRate() const
static const QString m_channelId
SWGLocalSinkSettings * getLocalSinkSettings()
qint32 getReverseApiPort()
DeviceAPI * getDeviceAPI()
uint32_t m_localDeviceIndex
void setReverseApiPort(qint32 reverse_api_port)
LocalSinkSettings m_settings
int getIndexInDeviceSet() const
LocalSinkThread * m_sinkThread
static const QString m_channelIdURI
void validateFilterChainHash(LocalSinkSettings &settings)
uint32_t m_filterChainHash
static double getShiftFactor(unsigned int log2, unsigned int chainHash)
void setTitle(QString *title)
qint64 getFrequencyOffset() const
QNetworkAccessManager * m_networkManager
void getLocalDevices(std::vector< uint32_t > &indexes)
void calculateFrequencyOffset()
virtual void feed(const SampleVector::const_iterator &begin, const SampleVector::const_iterator &end, bool po)
void setFilterChainHash(qint32 filter_chain_hash)