From 80992c01e015726aa94ca1ac6871e1d5d7a2a295 Mon Sep 17 00:00:00 2001 From: f4exb Date: Sat, 4 Dec 2021 21:36:12 +0100 Subject: [PATCH] RemoteInput: set system UDP buffer length for 250 ms of samples. RemoteSink: removed UDP Tx delay. Implements #1069 --- plugins/channelrx/remotesink/remotesink.cpp | 20 ------ .../channelrx/remotesink/remotesinkgui.cpp | 24 ------- plugins/channelrx/remotesink/remotesinkgui.h | 2 - plugins/channelrx/remotesink/remotesinkgui.ui | 64 ------------------- .../remotesink/remotesinksettings.cpp | 3 - .../channelrx/remotesink/remotesinksettings.h | 1 - .../channelrx/remotesink/remotesinksink.cpp | 20 +----- plugins/channelrx/remotesink/remotesinksink.h | 3 +- .../remoteinput/remoteinputudphandler.cpp | 25 ++++++-- .../remoteinput/remoteinputudphandler.h | 1 + sdrbase/resources/webapi/doc/html2/index.html | 6 +- .../doc/swagger/include/RemoteSink.yaml | 3 - .../api/swagger/include/RemoteSink.yaml | 3 - swagger/sdrangel/code/html2/index.html | 6 +- .../code/qt5/client/SWGRemoteSinkSettings.cpp | 23 ------- .../code/qt5/client/SWGRemoteSinkSettings.h | 6 -- 16 files changed, 24 insertions(+), 186 deletions(-) diff --git a/plugins/channelrx/remotesink/remotesink.cpp b/plugins/channelrx/remotesink/remotesink.cpp index 4dc1fba00..9b42adfd2 100644 --- a/plugins/channelrx/remotesink/remotesink.cpp +++ b/plugins/channelrx/remotesink/remotesink.cpp @@ -173,7 +173,6 @@ void RemoteSink::applySettings(const RemoteSinkSettings& settings, bool force) { qDebug() << "RemoteSink::applySettings:" << " m_nbFECBlocks: " << settings.m_nbFECBlocks - << " m_txDelay: " << settings.m_txDelay << " m_dataAddress: " << settings.m_dataAddress << " m_dataPort: " << settings.m_dataPort << " m_streamIndex: " << settings.m_streamIndex @@ -185,9 +184,6 @@ void RemoteSink::applySettings(const RemoteSinkSettings& settings, bool force) if ((m_settings.m_nbFECBlocks != settings.m_nbFECBlocks) || force) { reverseAPIKeys.append("nbFECBlocks"); } - if ((m_settings.m_txDelay != settings.m_txDelay) || force) { - reverseAPIKeys.append("txDelay"); - } if ((m_settings.m_dataAddress != settings.m_dataAddress) || force) { reverseAPIKeys.append("dataAddress"); } @@ -322,17 +318,6 @@ void RemoteSink::webapiUpdateChannelSettings( } } - if (channelSettingsKeys.contains("txDelay")) - { - int txDelay = response.getRemoteSinkSettings()->getTxDelay(); - - if (txDelay < 0) { - settings.m_txDelay = 35; - } else { - settings.m_txDelay = txDelay; - } - } - if (channelSettingsKeys.contains("dataAddress")) { settings.m_dataAddress = *response.getRemoteSinkSettings()->getDataAddress(); } @@ -391,7 +376,6 @@ void RemoteSink::webapiUpdateChannelSettings( void RemoteSink::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& response, const RemoteSinkSettings& settings) { response.getRemoteSinkSettings()->setNbFecBlocks(settings.m_nbFECBlocks); - response.getRemoteSinkSettings()->setTxDelay(settings.m_txDelay); if (response.getRemoteSinkSettings()->getDataAddress()) { *response.getRemoteSinkSettings()->getDataAddress() = settings.m_dataAddress; @@ -504,10 +488,6 @@ void RemoteSink::webapiFormatChannelSettings( if (channelSettingsKeys.contains("nbFECBlocks") || force) { swgRemoteSinkSettings->setNbFecBlocks(settings.m_nbFECBlocks); } - if (channelSettingsKeys.contains("txDelay") || force) - { - swgRemoteSinkSettings->setTxDelay(settings.m_txDelay); - } if (channelSettingsKeys.contains("dataAddress") || force) { swgRemoteSinkSettings->setDataAddress(new QString(settings.m_dataAddress)); } diff --git a/plugins/channelrx/remotesink/remotesinkgui.cpp b/plugins/channelrx/remotesink/remotesinkgui.cpp index b48804d52..f1b30e3de 100644 --- a/plugins/channelrx/remotesink/remotesinkgui.cpp +++ b/plugins/channelrx/remotesink/remotesinkgui.cpp @@ -81,7 +81,6 @@ bool RemoteSinkGUI::handleMessage(const Message& message) DSPSignalNotification& cfg = (DSPSignalNotification&) message; m_basebandSampleRate = cfg.getSampleRate(); qDebug("RemoteSinkGUI::handleMessage: DSPSignalNotification: m_basebandSampleRate: %d", m_basebandSampleRate); - updateTxDelayTime(); displayRateAndShift(); return true; @@ -169,9 +168,6 @@ void RemoteSinkGUI::displaySettings() QString s = QString::number(128 + m_settings.m_nbFECBlocks, 'f', 0); QString s1 = QString::number(m_settings.m_nbFECBlocks, 'f', 0); ui->nominalNbBlocksText->setText(tr("%1/%2").arg(s).arg(s1)); - ui->txDelayText->setText(tr("%1%").arg(m_settings.m_txDelay)); - ui->txDelay->setValue(m_settings.m_txDelay); - updateTxDelayTime(); applyDecimation(); displayStreamIndex(); restoreState(m_settings.m_rollupState); @@ -278,7 +274,6 @@ void RemoteSinkGUI::onMenuDialogCalled(const QPoint &p) void RemoteSinkGUI::on_decimationFactor_currentIndexChanged(int index) { m_settings.m_log2Decim = index; - updateTxDelayTime(); applyDecimation(); } @@ -327,14 +322,6 @@ void RemoteSinkGUI::on_dataApplyButton_clicked(bool checked) applySettings(); } -void RemoteSinkGUI::on_txDelay_valueChanged(int value) -{ - m_settings.m_txDelay = value; // percentage - ui->txDelayText->setText(tr("%1%").arg(value)); - updateTxDelayTime(); - applySettings(); -} - void RemoteSinkGUI::on_nbFECBlocks_valueChanged(int value) { m_settings.m_nbFECBlocks = value; @@ -343,20 +330,9 @@ void RemoteSinkGUI::on_nbFECBlocks_valueChanged(int value) QString s = QString::number(nbOriginalBlocks + nbFECBlocks, 'f', 0); QString s1 = QString::number(nbFECBlocks, 'f', 0); ui->nominalNbBlocksText->setText(tr("%1/%2").arg(s).arg(s1)); - updateTxDelayTime(); applySettings(); } -void RemoteSinkGUI::updateTxDelayTime() -{ - double txDelayRatio = m_settings.m_txDelay / 100.0; - int samplesPerBlock = RemoteNbBytesPerBlock / sizeof(Sample); - int channelSampleRate = m_basebandSampleRate / (1<txDelayTime->setText(tr("%1µs").arg(QString::number(delay*1e6, 'f', 0))); -} - void RemoteSinkGUI::applyDecimation() { uint32_t maxHash = 1; diff --git a/plugins/channelrx/remotesink/remotesinkgui.h b/plugins/channelrx/remotesink/remotesinkgui.h index bedfd2b3c..f9130ec02 100644 --- a/plugins/channelrx/remotesink/remotesinkgui.h +++ b/plugins/channelrx/remotesink/remotesinkgui.h @@ -72,7 +72,6 @@ private: void displaySettings(); void displayStreamIndex(); void displayRateAndShift(); - void updateTxDelayTime(); bool handleMessage(const Message& message); void leaveEvent(QEvent*); @@ -89,7 +88,6 @@ private slots: void on_dataPort_returnPressed(); void on_dataApplyButton_clicked(bool checked); void on_nbFECBlocks_valueChanged(int value); - void on_txDelay_valueChanged(int value); void onWidgetRolled(QWidget* widget, bool rollDown); void onMenuDialogCalled(const QPoint& p); void tick(); diff --git a/plugins/channelrx/remotesink/remotesinkgui.ui b/plugins/channelrx/remotesink/remotesinkgui.ui index 4c1f35ab0..807e887f4 100644 --- a/plugins/channelrx/remotesink/remotesinkgui.ui +++ b/plugins/channelrx/remotesink/remotesinkgui.ui @@ -395,70 +395,6 @@ - - - - Udly - - - - - - - - 24 - 24 - - - - Delay between consecutive UDP packets in percentage of nominal UDP packet process time - - - 0 - - - 70 - - - 1 - - - 35 - - - - - - - - 30 - 0 - - - - 50% - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 55 - 0 - - - - 10000us - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - diff --git a/plugins/channelrx/remotesink/remotesinksettings.cpp b/plugins/channelrx/remotesink/remotesinksettings.cpp index 9b69e468c..4819ee3a5 100644 --- a/plugins/channelrx/remotesink/remotesinksettings.cpp +++ b/plugins/channelrx/remotesink/remotesinksettings.cpp @@ -37,7 +37,6 @@ RemoteSinkSettings::RemoteSinkSettings() void RemoteSinkSettings::resetToDefaults() { m_nbFECBlocks = 0; - m_txDelay = 35; m_dataAddress = "127.0.0.1"; m_dataPort = 9090; m_rgbColor = QColor(140, 4, 4).rgb(); @@ -57,7 +56,6 @@ QByteArray RemoteSinkSettings::serialize() const { SimpleSerializer s(1); s.writeU32(1, m_nbFECBlocks); - s.writeU32(2, m_txDelay); s.writeString(3, m_dataAddress); s.writeU32(4, m_dataPort); s.writeU32(5, m_rgbColor); @@ -98,7 +96,6 @@ bool RemoteSinkSettings::deserialize(const QByteArray& data) m_nbFECBlocks = 0; } - d.readU32(2, &m_txDelay, 35); d.readString(3, &m_dataAddress, "127.0.0.1"); d.readU32(4, &tmp, 0); diff --git a/plugins/channelrx/remotesink/remotesinksettings.h b/plugins/channelrx/remotesink/remotesinksettings.h index cc22dd658..6f62d3717 100644 --- a/plugins/channelrx/remotesink/remotesinksettings.h +++ b/plugins/channelrx/remotesink/remotesinksettings.h @@ -32,7 +32,6 @@ class Serializable; struct RemoteSinkSettings { uint16_t m_nbFECBlocks; - uint32_t m_txDelay; 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 221356bfd..1818a4802 100644 --- a/plugins/channelrx/remotesink/remotesinksink.cpp +++ b/plugins/channelrx/remotesink/remotesinksink.cpp @@ -69,20 +69,6 @@ void RemoteSinkSink::stopSender() m_senderThread->wait(); } -void RemoteSinkSink::setTxDelay(int txDelay, int nbBlocksFEC, int log2Decim) -{ - double txDelayRatio = txDelay / 100.0; - int samplesPerBlock = RemoteNbBytesPerBlock / sizeof(Sample); - int sampleRate = m_basebandSampleRate / (1<setSocketOption(QAbstractSocket::ReceiveBufferSizeSocketOption, getDataSocketBufferSize()); } if (!m_dataConnected) @@ -167,7 +169,7 @@ void RemoteInputUDPHandler::applyUDPLink(const QString& address, quint16 port, c << " address: " << address << " port: " << port << " multicastAddress: " << multicastAddress - << " multicastJoin: " << multicastJoin; + << " multicastJoin: " << multicastJoin; bool addressOK = m_dataAddress.setAddress(address); @@ -253,6 +255,7 @@ void RemoteInputUDPHandler::processData() m_messageQueueToGUI->push(report); } + m_dataSocket->setSocketOption(QAbstractSocket::ReceiveBufferSizeSocketOption, getDataSocketBufferSize()); connectTimer(); } } @@ -436,9 +439,9 @@ void RemoteInputUDPHandler::handleMessages() bool RemoteInputUDPHandler::handleMessage(const Message& cmd) { - if (RemoteInputUDPHandler::MsgUDPAddressAndPort::match(cmd)) + if (MsgUDPAddressAndPort::match(cmd)) { - RemoteInputUDPHandler::MsgUDPAddressAndPort& notif = (RemoteInputUDPHandler::MsgUDPAddressAndPort&) cmd; + MsgUDPAddressAndPort& notif = (MsgUDPAddressAndPort&) cmd; applyUDPLink(notif.getAddress(), notif.getPort(), notif.getMulticastAddress(), notif.getMulticastJoin()); return true; } @@ -447,3 +450,13 @@ bool RemoteInputUDPHandler::handleMessage(const Message& cmd) return false; } } + +int RemoteInputUDPHandler::getDataSocketBufferSize() +{ + // set a floor value at 24 kS/s + uint32_t samplerate = m_samplerate < 24000 ? 24000 : m_samplerate; + // 250 ms (1/4s) at current sample rate + int bufferSize = (samplerate * 2 * (SDR_RX_SAMP_SZ == 16 ? 2 : 4)) / 4; + qDebug("RemoteInputUDPHandler::getDataSocketBufferSize: %d bytes", bufferSize); + return bufferSize; +} diff --git a/plugins/samplesource/remoteinput/remoteinputudphandler.h b/plugins/samplesource/remoteinput/remoteinputudphandler.h index 4e498dd21..de5423226 100644 --- a/plugins/samplesource/remoteinput/remoteinputudphandler.h +++ b/plugins/samplesource/remoteinput/remoteinputudphandler.h @@ -147,6 +147,7 @@ private: void disconnectTimer(); void processData(); void adjustNbDecoderSlots(const RemoteMetaDataFEC& metaData); + int getDataSocketBufferSize(); void applyUDPLink(const QString& address, quint16 port, const QString& multicastAddress, bool muticastJoin); bool handleMessage(const Message& message); diff --git a/sdrbase/resources/webapi/doc/html2/index.html b/sdrbase/resources/webapi/doc/html2/index.html index 7a079394a..1322a2293 100644 --- a/sdrbase/resources/webapi/doc/html2/index.html +++ b/sdrbase/resources/webapi/doc/html2/index.html @@ -9897,10 +9897,6 @@ margin-bottom: 20px; "type" : "integer", "description" : "Receiving USB data port" }, - "txDelay" : { - "type" : "integer", - "description" : "Minimum delay in ms between consecutive USB blocks transmissions" - }, "rgbColor" : { "type" : "integer" }, @@ -51605,7 +51601,7 @@ except ApiException as e:
- Generated 2021-12-03T22:37:52.628+01:00 + Generated 2021-12-04T20:19:18.225+01:00
diff --git a/sdrbase/resources/webapi/doc/swagger/include/RemoteSink.yaml b/sdrbase/resources/webapi/doc/swagger/include/RemoteSink.yaml index 89d2e2a29..93a3c9293 100644 --- a/sdrbase/resources/webapi/doc/swagger/include/RemoteSink.yaml +++ b/sdrbase/resources/webapi/doc/swagger/include/RemoteSink.yaml @@ -10,9 +10,6 @@ RemoteSinkSettings: dataPort: description: "Receiving USB data port" type: integer - txDelay: - description: "Minimum delay in ms between consecutive USB blocks transmissions" - type: integer rgbColor: type: integer title: diff --git a/swagger/sdrangel/api/swagger/include/RemoteSink.yaml b/swagger/sdrangel/api/swagger/include/RemoteSink.yaml index a7a946818..0efd3158f 100644 --- a/swagger/sdrangel/api/swagger/include/RemoteSink.yaml +++ b/swagger/sdrangel/api/swagger/include/RemoteSink.yaml @@ -10,9 +10,6 @@ RemoteSinkSettings: dataPort: description: "Receiving USB data port" type: integer - txDelay: - description: "Minimum delay in ms between consecutive USB blocks transmissions" - type: integer rgbColor: type: integer title: diff --git a/swagger/sdrangel/code/html2/index.html b/swagger/sdrangel/code/html2/index.html index 7a079394a..1322a2293 100644 --- a/swagger/sdrangel/code/html2/index.html +++ b/swagger/sdrangel/code/html2/index.html @@ -9897,10 +9897,6 @@ margin-bottom: 20px; "type" : "integer", "description" : "Receiving USB data port" }, - "txDelay" : { - "type" : "integer", - "description" : "Minimum delay in ms between consecutive USB blocks transmissions" - }, "rgbColor" : { "type" : "integer" }, @@ -51605,7 +51601,7 @@ except ApiException as e:
- Generated 2021-12-03T22:37:52.628+01:00 + Generated 2021-12-04T20:19:18.225+01:00
diff --git a/swagger/sdrangel/code/qt5/client/SWGRemoteSinkSettings.cpp b/swagger/sdrangel/code/qt5/client/SWGRemoteSinkSettings.cpp index af2b80266..d4c808a0f 100644 --- a/swagger/sdrangel/code/qt5/client/SWGRemoteSinkSettings.cpp +++ b/swagger/sdrangel/code/qt5/client/SWGRemoteSinkSettings.cpp @@ -34,8 +34,6 @@ SWGRemoteSinkSettings::SWGRemoteSinkSettings() { m_data_address_isSet = false; data_port = 0; m_data_port_isSet = false; - tx_delay = 0; - m_tx_delay_isSet = false; rgb_color = 0; m_rgb_color_isSet = false; title = nullptr; @@ -72,8 +70,6 @@ SWGRemoteSinkSettings::init() { m_data_address_isSet = false; data_port = 0; m_data_port_isSet = false; - tx_delay = 0; - m_tx_delay_isSet = false; rgb_color = 0; m_rgb_color_isSet = false; title = new QString(""); @@ -106,7 +102,6 @@ SWGRemoteSinkSettings::cleanup() { } - if(title != nullptr) { delete title; } @@ -142,8 +137,6 @@ SWGRemoteSinkSettings::fromJsonObject(QJsonObject &pJson) { ::SWGSDRangel::setValue(&data_port, pJson["dataPort"], "qint32", ""); - ::SWGSDRangel::setValue(&tx_delay, pJson["txDelay"], "qint32", ""); - ::SWGSDRangel::setValue(&rgb_color, pJson["rgbColor"], "qint32", ""); ::SWGSDRangel::setValue(&title, pJson["title"], "QString", "QString"); @@ -191,9 +184,6 @@ SWGRemoteSinkSettings::asJsonObject() { if(m_data_port_isSet){ obj->insert("dataPort", QJsonValue(data_port)); } - if(m_tx_delay_isSet){ - obj->insert("txDelay", QJsonValue(tx_delay)); - } if(m_rgb_color_isSet){ obj->insert("rgbColor", QJsonValue(rgb_color)); } @@ -261,16 +251,6 @@ SWGRemoteSinkSettings::setDataPort(qint32 data_port) { this->m_data_port_isSet = true; } -qint32 -SWGRemoteSinkSettings::getTxDelay() { - return tx_delay; -} -void -SWGRemoteSinkSettings::setTxDelay(qint32 tx_delay) { - this->tx_delay = tx_delay; - this->m_tx_delay_isSet = true; -} - qint32 SWGRemoteSinkSettings::getRgbColor() { return rgb_color; @@ -395,9 +375,6 @@ SWGRemoteSinkSettings::isSet(){ if(m_data_port_isSet){ isObjectUpdated = true; break; } - if(m_tx_delay_isSet){ - isObjectUpdated = true; break; - } if(m_rgb_color_isSet){ isObjectUpdated = true; break; } diff --git a/swagger/sdrangel/code/qt5/client/SWGRemoteSinkSettings.h b/swagger/sdrangel/code/qt5/client/SWGRemoteSinkSettings.h index b913f5669..186f3775d 100644 --- a/swagger/sdrangel/code/qt5/client/SWGRemoteSinkSettings.h +++ b/swagger/sdrangel/code/qt5/client/SWGRemoteSinkSettings.h @@ -52,9 +52,6 @@ public: qint32 getDataPort(); void setDataPort(qint32 data_port); - qint32 getTxDelay(); - void setTxDelay(qint32 tx_delay); - qint32 getRgbColor(); void setRgbColor(qint32 rgb_color); @@ -101,9 +98,6 @@ private: qint32 data_port; bool m_data_port_isSet; - qint32 tx_delay; - bool m_tx_delay_isSet; - qint32 rgb_color; bool m_rgb_color_isSet;