diff --git a/plugins/channelrx/remotesink/remotesink.cpp b/plugins/channelrx/remotesink/remotesink.cpp index ef2259428..cd06ca480 100644 --- a/plugins/channelrx/remotesink/remotesink.cpp +++ b/plugins/channelrx/remotesink/remotesink.cpp @@ -96,6 +96,8 @@ void RemoteSink::start() { qDebug("RemoteSink::start: m_basebandSampleRate: %d", m_basebandSampleRate); m_basebandSink->reset(); + m_basebandSink->setDeviceIndex(m_deviceAPI->getDeviceSetIndex()); + m_basebandSink->setChannelIndex(getIndexInDeviceSet()); m_basebandSink->startWork(); m_thread.start(); diff --git a/plugins/channelrx/remotesink/remotesinkbaseband.h b/plugins/channelrx/remotesink/remotesinkbaseband.h index af7de697e..450d443b1 100644 --- a/plugins/channelrx/remotesink/remotesinkbaseband.h +++ b/plugins/channelrx/remotesink/remotesinkbaseband.h @@ -70,6 +70,8 @@ public: MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; } //!< Get the queue for asynchronous inbound communication int getChannelSampleRate() const; void setBasebandSampleRate(int sampleRate); + void setDeviceIndex(uint32_t deviceIndex) { m_sink.setDeviceIndex(deviceIndex); } + void setChannelIndex(uint32_t channelIndex) { m_sink.setChannelIndex(channelIndex); } private: bool m_running; diff --git a/plugins/channelrx/remotesink/remotesinksender.cpp b/plugins/channelrx/remotesink/remotesinksender.cpp index 8ec91c1d5..a36d27216 100644 --- a/plugins/channelrx/remotesink/remotesinksender.cpp +++ b/plugins/channelrx/remotesink/remotesinksender.cpp @@ -68,6 +68,12 @@ void RemoteSinkSender::started() void RemoteSinkSender::stopWork() { qDebug("RemoteSinkSender::stopWork"); + QObject::disconnect( + &m_fifo, + &RemoteSinkFifo::dataBlockServed, + this, + &RemoteSinkSender::handleData + ); } void RemoteSinkSender::finished() diff --git a/plugins/channelrx/remotesink/remotesinksettings.cpp b/plugins/channelrx/remotesink/remotesinksettings.cpp index 4f4614aff..a34ac83bd 100644 --- a/plugins/channelrx/remotesink/remotesinksettings.cpp +++ b/plugins/channelrx/remotesink/remotesinksettings.cpp @@ -38,6 +38,8 @@ void RemoteSinkSettings::resetToDefaults() { m_nbFECBlocks = 0; m_nbTxBytes = 2; + m_deviceCenterFrequency = 0; + m_deviceSampleRate = 48000; m_dataAddress = "127.0.0.1"; m_dataPort = 9090; m_rgbColor = QColor(140, 4, 4).rgb(); @@ -71,6 +73,8 @@ QByteArray RemoteSinkSettings::serialize() const s.writeU32(13, m_filterChainHash); s.writeS32(14, m_streamIndex); s.writeBlob(15, m_rollupState); + s.writeU64(16, m_deviceCenterFrequency); + s.writeU32(17, m_deviceSampleRate); return s.final(); } @@ -129,6 +133,8 @@ bool RemoteSinkSettings::deserialize(const QByteArray& data) d.readU32(13, &m_filterChainHash, 0); d.readS32(14, &m_streamIndex, 0); d.readBlob(15, &m_rollupState); + d.readU64(16, &m_deviceCenterFrequency, 0); + d.readU32(17, &m_deviceSampleRate, 48000); return true; } diff --git a/plugins/channelrx/remotesink/remotesinksettings.h b/plugins/channelrx/remotesink/remotesinksettings.h index 06544a40d..30419560c 100644 --- a/plugins/channelrx/remotesink/remotesinksettings.h +++ b/plugins/channelrx/remotesink/remotesinksettings.h @@ -33,6 +33,8 @@ struct RemoteSinkSettings { uint16_t m_nbFECBlocks; uint32_t m_nbTxBytes; + quint64 m_deviceCenterFrequency; + uint32_t m_deviceSampleRate; QString m_dataAddress; uint16_t m_dataPort; quint32 m_rgbColor; diff --git a/plugins/channelrx/remotesink/remotesinksink.cpp b/plugins/channelrx/remotesink/remotesinksink.cpp index eb638eab1..1ae7d6e08 100644 --- a/plugins/channelrx/remotesink/remotesinksink.cpp +++ b/plugins/channelrx/remotesink/remotesinksink.cpp @@ -131,6 +131,10 @@ void RemoteSinkSink::feed(const SampleVector::const_iterator& begin, const Sampl metaData.m_sampleBits = getNbSampleBits(); metaData.m_nbOriginalBlocks = RemoteNbOrginalBlocks; metaData.m_nbFECBlocks = m_nbBlocksFEC; + metaData.m_deviceCenterFrequency = m_deviceCenterFrequency; + metaData.m_basebandSampleRate = m_basebandSampleRate; + metaData.m_deviceIndex = m_deviceIndex % 256; + metaData.m_channelIndex = m_channelIndex % 256; metaData.m_tv_sec = nowus / 1000000UL; // tv.tv_sec; metaData.m_tv_usec = nowus % 1000000UL; // tv.tv_usec; @@ -160,6 +164,10 @@ void RemoteSinkSink::feed(const SampleVector::const_iterator& begin, const Sampl << ":" << (int) metaData.m_sampleBits << "|" << (int) metaData.m_nbOriginalBlocks << ":" << (int) metaData.m_nbFECBlocks + << "|" << metaData.m_deviceCenterFrequency + << ":" << metaData.m_basebandSampleRate + << "|" << metaData.m_deviceIndex + << ":" << metaData.m_channelIndex << "|" << metaData.m_tv_sec << ":" << metaData.m_tv_usec; diff --git a/plugins/channelrx/remotesink/remotesinksink.h b/plugins/channelrx/remotesink/remotesinksink.h index 34730daf1..4f85dc90f 100644 --- a/plugins/channelrx/remotesink/remotesinksink.h +++ b/plugins/channelrx/remotesink/remotesinksink.h @@ -46,6 +46,8 @@ public: void applySettings(const RemoteSinkSettings& settings, bool force = false); void applyBasebandSampleRate(uint32_t sampleRate); void setDeviceCenterFrequency(uint64_t frequency) { m_deviceCenterFrequency = frequency; } + void setDeviceIndex(uint32_t deviceIndex) { m_deviceIndex = deviceIndex; } + void setChannelIndex(uint32_t channelIndex) { m_channelIndex = channelIndex; } private: RemoteSinkSettings m_settings; @@ -63,6 +65,8 @@ private: uint64_t m_deviceCenterFrequency; int64_t m_frequencyOffset; uint32_t m_basebandSampleRate; + uint32_t m_deviceIndex; + uint32_t m_channelIndex; int m_nbBlocksFEC; uint32_t m_nbTxBytes; QString m_dataAddress; diff --git a/plugins/channeltx/remotesource/remotesourcesource.cpp b/plugins/channeltx/remotesource/remotesourcesource.cpp index c3601163d..662df46ed 100644 --- a/plugins/channeltx/remotesource/remotesourcesource.cpp +++ b/plugins/channeltx/remotesource/remotesourcesource.cpp @@ -218,6 +218,10 @@ void RemoteSourceSource::printMeta(const QString& header, RemoteMetaDataFEC *met << ":" << (int) metaData->m_sampleBits << ":" << (int) metaData->m_nbOriginalBlocks << ":" << (int) metaData->m_nbFECBlocks + << "|" << metaData->m_deviceCenterFrequency + << ":" << metaData->m_basebandSampleRate + << "|" << metaData->m_deviceIndex + << ":" << metaData->m_channelIndex << "|" << metaData->m_tv_sec << ":" << metaData->m_tv_usec << "|"; diff --git a/plugins/samplesink/remoteoutput/remoteoutput.cpp b/plugins/samplesink/remoteoutput/remoteoutput.cpp index b698847f9..b13201d30 100644 --- a/plugins/samplesink/remoteoutput/remoteoutput.cpp +++ b/plugins/samplesink/remoteoutput/remoteoutput.cpp @@ -90,6 +90,7 @@ bool RemoteOutput::start() m_remoteOutputWorker = new RemoteOutputWorker(&m_sampleSourceFifo); m_remoteOutputWorker->moveToThread(&m_remoteOutputWorkerThread); + m_remoteOutputWorker->setDeviceIndex(m_deviceAPI->getDeviceSetIndex()); m_remoteOutputWorker->setDataAddress(m_settings.m_dataAddress, m_settings.m_dataPort); m_remoteOutputWorker->setSamplerate(m_sampleRate); m_remoteOutputWorker->setNbBlocksFEC(m_settings.m_nbFECBlocks); diff --git a/plugins/samplesink/remoteoutput/remoteoutputgui.cpp b/plugins/samplesink/remoteoutput/remoteoutputgui.cpp index 790604b9f..393dead1e 100644 --- a/plugins/samplesink/remoteoutput/remoteoutputgui.cpp +++ b/plugins/samplesink/remoteoutput/remoteoutputgui.cpp @@ -41,8 +41,6 @@ #include "channel/remotedatablock.h" -#include "udpsinkfec.h" - RemoteOutputSinkGui::RemoteOutputSinkGui(DeviceUISet *deviceUISet, QWidget* parent) : DeviceGUI(parent), ui(new Ui::RemoteOutputGui), diff --git a/plugins/samplesink/remoteoutput/remoteoutputworker.h b/plugins/samplesink/remoteoutput/remoteoutputworker.h index 4fcbbd8f5..f9eb7d1ef 100644 --- a/plugins/samplesink/remoteoutput/remoteoutputworker.h +++ b/plugins/samplesink/remoteoutput/remoteoutputworker.h @@ -47,6 +47,7 @@ public: void startWork(); void stopWork(); + void setDeviceIndex(uint32_t deviceIndex) { m_udpSinkFEC.setDeviceIndex(deviceIndex); } void setSamplerate(int samplerate); void setNbBlocksFEC(uint32_t nbBlocksFEC) { m_udpSinkFEC.setNbBlocksFEC(nbBlocksFEC); }; void setNbTxBytes(uint32_t nbTxBytes) { m_udpSinkFEC.setNbTxBytes(nbTxBytes); }; diff --git a/plugins/samplesink/remoteoutput/udpsinkfec.cpp b/plugins/samplesink/remoteoutput/udpsinkfec.cpp index dec5c6248..961881c21 100644 --- a/plugins/samplesink/remoteoutput/udpsinkfec.cpp +++ b/plugins/samplesink/remoteoutput/udpsinkfec.cpp @@ -120,6 +120,10 @@ void UDPSinkFEC::write(const SampleVector::iterator& begin, uint32_t sampleChunk metaData.m_sampleBits = getNbSampleBits(); metaData.m_nbOriginalBlocks = RemoteNbOrginalBlocks; metaData.m_nbFECBlocks = m_nbBlocksFEC; + metaData.m_deviceCenterFrequency = 0; // frequency not set by device + metaData.m_basebandSampleRate = m_sampleRate; // same as sample rate + metaData.m_deviceIndex = m_deviceIndex; // index of device set in the instance + metaData.m_channelIndex = 0; // irrelavant metaData.m_tv_sec = nowus / 1000000UL; // tv.tv_sec; metaData.m_tv_usec = nowus % 1000000UL; // tv.tv_usec; @@ -149,6 +153,10 @@ void UDPSinkFEC::write(const SampleVector::iterator& begin, uint32_t sampleChunk << ":" << (int) metaData.m_sampleBits << "|" << (int) metaData.m_nbOriginalBlocks << ":" << (int) metaData.m_nbFECBlocks + << "|" << metaData.m_deviceCenterFrequency + << ":" << metaData.m_basebandSampleRate + << "|" << metaData.m_deviceIndex + << ":" << metaData.m_channelIndex << "|" << metaData.m_tv_sec << ":" << metaData.m_tv_usec; diff --git a/plugins/samplesink/remoteoutput/udpsinkfec.h b/plugins/samplesink/remoteoutput/udpsinkfec.h index 06da1c87d..c9c24a222 100644 --- a/plugins/samplesink/remoteoutput/udpsinkfec.h +++ b/plugins/samplesink/remoteoutput/udpsinkfec.h @@ -64,6 +64,7 @@ public: return ret; } + void setDeviceIndex(uint32_t deviceIndex) { m_deviceIndex = deviceIndex; } /** Set sample rate given in S/s */ void setSampleRate(uint32_t sampleRate); @@ -94,6 +95,7 @@ private: int m_txBlockIndex; //!< Current index in blocks to transmit in the Tx row uint16_t m_frameCount; //!< transmission frame count int m_sampleIndex; //!< Current sample index in protected block data + uint32_t m_deviceIndex; //!< Index of current device set RemoteOutputSender *m_remoteOutputSender; QThread *m_senderThread; diff --git a/plugins/samplesource/remoteinput/remoteinputbuffer.cpp b/plugins/samplesource/remoteinput/remoteinputbuffer.cpp index 80882c63c..420c4cba9 100644 --- a/plugins/samplesource/remoteinput/remoteinputbuffer.cpp +++ b/plugins/samplesource/remoteinput/remoteinputbuffer.cpp @@ -415,6 +415,10 @@ void RemoteInputBuffer::printMeta(const QString& header, RemoteMetaDataFEC *meta << ":" << (int) metaData->m_sampleBits << ":" << (int) metaData->m_nbOriginalBlocks << ":" << (int) metaData->m_nbFECBlocks + << "|" << metaData->m_deviceCenterFrequency + << ":" << metaData->m_basebandSampleRate + << "|" << metaData->m_deviceIndex + << ":" << metaData->m_channelIndex << "|" << metaData->m_tv_sec << ":" << metaData->m_tv_usec << "|"; diff --git a/sdrbase/channel/remotedatablock.h b/sdrbase/channel/remotedatablock.h index e1b094baf..477efd38b 100644 --- a/sdrbase/channel/remotedatablock.h +++ b/sdrbase/channel/remotedatablock.h @@ -38,16 +38,20 @@ #pragma pack(push, 1) struct RemoteMetaDataFEC { - uint64_t m_centerFrequency; //!< 8 center frequency in kHz - uint32_t m_sampleRate; //!< 12 sample rate in Hz - uint8_t m_sampleBytes; //!< 13 4 LSB: number of bytes per sample (2 or 4) - uint8_t m_sampleBits; //!< 14 number of effective bits per sample (deprecated) - uint8_t m_nbOriginalBlocks; //!< 15 number of blocks with original (protected) data - uint8_t m_nbFECBlocks; //!< 16 number of blocks carrying FEC + uint64_t m_centerFrequency; //!< 8 center frequency in kHz + uint32_t m_sampleRate; //!< 12 sample rate in Hz + uint8_t m_sampleBytes; //!< 13 4 LSB: number of bytes per sample (2 or 4) + uint8_t m_sampleBits; //!< 14 number of effective bits per sample (deprecated) + uint8_t m_nbOriginalBlocks; //!< 15 number of blocks with original (protected) data + uint8_t m_nbFECBlocks; //!< 16 number of blocks carrying FEC + uint64_t m_deviceCenterFrequency; //!< 24 device center frequency in Hz + uint32_t m_basebandSampleRate; //!< 28 basebabd sample rate in Hz + uint8_t m_deviceIndex; //!< 29 index of device set in instance + uint8_t m_channelIndex; //!< 30 index of channel in device set - uint32_t m_tv_sec; //!< 20 seconds of timestamp at start time of super-frame processing - uint32_t m_tv_usec; //!< 24 microseconds of timestamp at start time of super-frame processing - uint32_t m_crc32; //!< 28 CRC32 of the above + uint32_t m_tv_sec; //!< 34 seconds of timestamp at start time of super-frame processing + uint32_t m_tv_usec; //!< 38 microseconds of timestamp at start time of super-frame processing + uint32_t m_crc32; //!< 42 CRC32 of the above bool operator==(const RemoteMetaDataFEC& rhs) { @@ -68,6 +72,10 @@ struct RemoteMetaDataFEC m_sampleBits = 0; m_nbOriginalBlocks = 0; m_nbFECBlocks = 0; + m_deviceCenterFrequency = 0; + m_basebandSampleRate = 1; + m_deviceIndex = 0; + m_channelIndex = 0; m_tv_sec = 0; m_tv_usec = 0; m_crc32 = 0;