20 #include <boost/crc.hpp> 21 #include <boost/cstdint.hpp> 23 #include <QNetworkAccessManager> 24 #include <QNetworkReply> 50 m_deviceAPI(deviceAPI),
52 m_sinkThread(nullptr),
53 m_localSampleSourceFifo(nullptr),
55 m_localSamplesIndex(0),
56 m_localSamplesIndexOffset(0),
60 m_deviceSampleRate(48000),
61 m_settingsMutex(QMutex::Recursive)
119 SampleVector::iterator beginSource;
120 SampleVector::iterator beginDestination =
m_localSamples.begin() + destOffset;
122 std::copy(beginSource, beginSource +
m_chunkSize, beginDestination);
133 qDebug(
"LocalSource::start");
159 Qt::QueuedConnection);
162 SIGNAL(samplesAvailable(
int)),
165 Qt::QueuedConnection);
173 qDebug(
"LocalSource::stop");
192 qDebug() <<
"LocalSource::handleMessage: MsgChannelizerNotification:" 193 <<
" channelSampleRate: " << sampleRate
217 qDebug() <<
"LocalSource::handleMessage: DSPSignalNotification:" 242 qDebug() <<
"LocalSource::handleMessage: MsgConfigureLocalSink";
253 qDebug() <<
"LocalSource::handleMessage: MsgConfigureChannelizer:" 306 indexes.push_back(
i);
315 if (index < dspEngine->getDeviceSinkEnginesNumber())
323 qDebug(
"LocalSource::getLocalDevice: the parent device is unset");
325 qDebug(
"LocalSource::getLocalDevice: sink device at index %u is the parent device", index);
332 qDebug(
"LocalSource::getLocalDevice: sink device at index %u is not a Local Output source", index);
337 qDebug(
"LocalSource::getLocalDevice: non existent sink device index: %u", index);
356 qDebug() <<
"LocalSource::applySettings:" 358 <<
" force: " << force;
360 QList<QString> reverseAPIKeys;
364 reverseAPIKeys.append(
"localDeviceIndex");
377 qWarning(
"LocalSource::applySettings: invalid local device for index %u", settings.
m_localDeviceIndex);
413 QString& errorMessage)
424 const QStringList& channelSettingsKeys,
426 QString& errorMessage)
431 if (channelSettingsKeys.contains(
"localDeviceIndex")) {
434 if (channelSettingsKeys.contains(
"rgbColor")) {
437 if (channelSettingsKeys.contains(
"title")) {
440 if (channelSettingsKeys.contains(
"log2Interp")) {
444 if (channelSettingsKeys.contains(
"filterChainHash"))
450 if (channelSettingsKeys.contains(
"useReverseAPI")) {
453 if (channelSettingsKeys.contains(
"reverseAPIAddress")) {
456 if (channelSettingsKeys.contains(
"reverseAPIPort")) {
459 if (channelSettingsKeys.contains(
"reverseAPIDeviceIndex")) {
462 if (channelSettingsKeys.contains(
"reverseAPIChannelIndex")) {
475 qDebug(
"LocalSource::webapiSettingsPutPatch: forward to GUI: %p",
m_guiMessageQueue);
525 if (channelSettingsKeys.contains(
"localDeviceIndex") || force) {
528 if (channelSettingsKeys.contains(
"rgbColor") || force) {
531 if (channelSettingsKeys.contains(
"title") || force) {
534 if (channelSettingsKeys.contains(
"log2Interp") || force) {
537 if (channelSettingsKeys.contains(
"filterChainHash") || force) {
541 QString channelSettingsURL = QString(
"http://%1:%2/sdrangel/deviceset/%3/channel/%4/settings")
547 m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader,
"application/json");
549 QBuffer *buffer=
new QBuffer();
550 buffer->open((QBuffer::ReadWrite));
551 buffer->write(swgChannelSettings->
asJson().toUtf8());
557 delete swgChannelSettings;
562 QNetworkReply::NetworkError replyError = reply->error();
566 qWarning() <<
"LocalSource::networkManagerFinished:" 567 <<
" error(" << (int) replyError
568 <<
"): " << replyError
569 <<
": " << reply->errorString();
573 QString answer = reply->readAll();
575 qDebug(
"LocalSource::networkManagerFinished: reply:\n%s", answer.toStdString().c_str());
qint32 getUseReverseApi()
void setOriginatorChannelIndex(qint32 originator_channel_index)
void pullSamples(unsigned int count)
void processSamples(int offset)
void setLog2Interp(qint32 log2_interp)
DeviceSampleSink * getSink()
SWGLocalSourceSettings * getLocalSourceSettings()
void setReverseApiChannelIndex(qint32 reverse_api_channel_index)
void setRgbColor(qint32 rgb_color)
void push(Message *message, bool emitSignal=true)
Push message onto queue.
static const QString m_channelId
ThreadedBasebandSampleSource * m_threadedChannelizer
SampleSourceFifo * m_localSampleSourceFifo
void removeChannelSourceAPI(ChannelAPI *channelAPI, int streamIndex=0)
uint64_t m_centerFrequency
uint16_t m_reverseAPIDeviceIndex
void setTitle(QString *title)
virtual bool deserialize(const QByteArray &data)
virtual int webapiSettingsGet(SWGSDRangel::SWGChannelSettings &response, QString &errorMessage)
uint16_t m_reverseAPIChannelIndex
int getDeviceSetIndex() const
void networkManagerFinished(QNetworkReply *reply)
void removeChannelSource(ThreadedBasebandSampleSource *sink, int streamIndex=0)
Remove a channel source (Tx)
QNetworkAccessManager * m_networkManager
void setSampleRate(uint32_t sampleRate)
static const QString m_channelIdURI
virtual int webapiSettingsPutPatch(bool force, const QStringList &channelSettingsKeys, SWGSDRangel::SWGChannelSettings &response, QString &errorMessage)
MessageQueue * getInputMessageQueue()
Get the queue for asynchronous inbound communication.
qint32 getFilterChainHash()
void setLocalDeviceIndex(qint32 local_device_index)
QNetworkRequest m_networkRequest
void getLocalDevices(std::vector< uint32_t > &indexes)
virtual void setCenterFrequency(qint64 centerFrequency)=0
LocalSource(DeviceAPI *deviceAPI)
void calculateFrequencyOffset()
void setChannelType(QString *channel_type)
void addChannelSource(ThreadedBasebandSampleSource *sink, int streamIndex=0)
Add a channel source (Tx)
void setOriginatorDeviceSetIndex(qint32 originator_device_set_index)
static MsgSampleRateNotification * create(int sampleRate)
void startStop(bool start)
void set(MessageQueue *messageQueue, unsigned int log2Interp, unsigned int filterChainHash)
void setSampleFifo(SampleSourceFifo *sampleFifo)
void setUseReverseApi(qint32 use_reverse_api)
uint16_t m_reverseAPIPort
virtual QByteArray serialize() const
virtual void pull(Sample &sample)
qint64 getCenterFrequency() const
int64_t m_frequencyOffset
QByteArray serialize() const
#define MESSAGE_CLASS_DEFINITION(Name, BaseClass)
void validateFilterChainHash(LocalSourceSettings &settings)
uint32_t m_deviceSampleRate
static DSPEngine * instance()
SampleSourceFifo * getSampleFifo()
QString m_reverseAPIAddress
qint32 getReverseApiPort()
DeviceSampleSink * getLocalDevice(uint32_t index)
virtual void pullAudio(int nbSamples)
void setReverseApiDeviceIndex(qint32 reverse_api_device_index)
uint32_t getDeviceSinkEnginesNumber() const
qint32 getReverseApiDeviceIndex()
void setReverseApiPort(qint32 reverse_api_port)
static bool match(const Message *message)
UpChannelizer * m_channelizer
virtual void setSampleRate(int sampleRate)=0
For when the sink sample rate is set externally.
uint32_t m_localDeviceIndex
void setDirection(qint32 direction)
qint32 getReverseApiChannelIndex()
bool deserialize(const QByteArray &data)
virtual QString asJson() override
void resize(uint32_t size)
void setIteratorFromOffset(SampleVector::iterator &iterator, int offset)
QString * getReverseApiAddress()
void propagateSampleRateAndFrequency(uint32_t index)
qint64 getFrequencyOffset() const
qint32 getLocalDeviceIndex()
void setCenterFrequency(uint64_t centerFrequency)
void applySettings(const LocalSourceSettings &settings, bool force=false)
virtual bool handleMessage(const Message &cmd)
Processing of a message. Returns true if message has actually been processed.
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
int getSampleRate() const
void setReverseApiAddress(QString *reverse_api_address)
void setFilterChainHash(qint32 filter_chain_hash)
MessageQueue m_inputMessageQueue
Queue for asynchronous inbound communication.
LocalSourceThread * m_sinkThread
int m_localSamplesIndexOffset
DeviceAPI * getDeviceAPI()
int getSampleRate() const
void addChannelSourceAPI(ChannelAPI *channelAPI, int streamIndex=0)
void webapiReverseSendSettings(QList< QString > &channelSettingsKeys, const LocalSourceSettings &settings, bool force)
uint32_t m_filterChainHash
int getIndexInDeviceSet() const
SampleVector m_localSamples
DSPDeviceSinkEngine * getDeviceSinkEngineByIndex(uint deviceIndex)
static double getShiftFactor(unsigned int log2, unsigned int chainHash)
void webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings &response, const LocalSourceSettings &settings)
virtual const QString & getDeviceDescription() const =0
LocalSourceSettings m_settings
void setLocalSourceSettings(SWGLocalSourceSettings *local_source_settings)