1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-21 15:51:47 -05:00

RemoteInput: set system UDP buffer length for 250 ms of samples. RemoteSink: removed UDP Tx delay. Implements #1069

This commit is contained in:
f4exb 2021-12-04 21:36:12 +01:00
parent 71f63e3a9c
commit 80992c01e0
16 changed files with 24 additions and 186 deletions

View File

@ -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));
}

View File

@ -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<<m_settings.m_log2Decim);
double delay = channelSampleRate == 0 ? 0.0 : (127*samplesPerBlock*txDelayRatio) / channelSampleRate;
delay /= 128 + m_settings.m_nbFECBlocks;
ui->txDelayTime->setText(tr("%1µs").arg(QString::number(delay*1e6, 'f', 0)));
}
void RemoteSinkGUI::applyDecimation()
{
uint32_t maxHash = 1;

View File

@ -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();

View File

@ -395,70 +395,6 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="txDelayLabel">
<property name="text">
<string>Udly</string>
</property>
</widget>
</item>
<item>
<widget class="QDial" name="txDelay">
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="toolTip">
<string>Delay between consecutive UDP packets in percentage of nominal UDP packet process time</string>
</property>
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>70</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>35</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="txDelayText">
<property name="minimumSize">
<size>
<width>30</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>50%</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="txDelayTime">
<property name="minimumSize">
<size>
<width>55</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>10000us</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">

View File

@ -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);

View File

@ -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;

View File

@ -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<<log2Decim);
double delay = sampleRate == 0 ? 1.0 : (127*samplesPerBlock*txDelayRatio) / sampleRate;
delay /= 128 + nbBlocksFEC;
m_txDelay = roundf(delay*1e6); // microseconds
qDebug() << "RemoteSinkSink::setTxDelay:"
<< "txDelay:" << txDelay << "%"
<< "m_txDelay:" << m_txDelay << "us"
<< "sampleRate: " << sampleRate << "S/s";
}
void RemoteSinkSink::setNbBlocksFEC(int nbBlocksFEC)
{
qDebug() << "RemoteSinkSink::setNbBlocksFEC: nbBlocksFEC: " << nbBlocksFEC;
@ -200,7 +186,6 @@ void RemoteSinkSink::applySettings(const RemoteSinkSettings& settings, bool forc
{
qDebug() << "RemoteSinkSink::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
@ -216,13 +201,11 @@ void RemoteSinkSink::applySettings(const RemoteSinkSettings& settings, bool forc
if ((m_settings.m_log2Decim != settings.m_log2Decim)
|| (m_settings.m_filterChainHash != settings.m_filterChainHash)
|| (m_settings.m_nbFECBlocks != settings.m_nbFECBlocks)
|| (m_settings.m_txDelay != settings.m_txDelay) || force)
|| (m_settings.m_nbFECBlocks != settings.m_nbFECBlocks) || force)
{
double shiftFactor = HBFilterChainConverter::getShiftFactor(settings.m_log2Decim, settings.m_filterChainHash);
m_frequencyOffset = round(shiftFactor*m_basebandSampleRate);
setNbBlocksFEC(settings.m_nbFECBlocks);
setTxDelay(settings.m_txDelay, settings.m_nbFECBlocks, settings.m_log2Decim);
}
m_settings = settings;
@ -233,5 +216,4 @@ void RemoteSinkSink::applyBasebandSampleRate(uint32_t sampleRate)
m_basebandSampleRate = sampleRate;
double shiftFactor = HBFilterChainConverter::getShiftFactor(m_settings.m_log2Decim, m_settings.m_filterChainHash);
m_frequencyOffset = round(shiftFactor*m_basebandSampleRate);
setTxDelay(m_settings.m_txDelay, m_settings.m_nbFECBlocks, m_settings.m_log2Decim);
}

View File

@ -66,7 +66,6 @@ private:
uint16_t m_dataPort;
void setNbBlocksFEC(int nbBlocksFEC);
void setTxDelay(int txDelay, int nbBlocksFEC, int log2Decim);
};
#endif // INCLUDE_REMOTESINKSINK_H_
#endif // INCLUDE_REMOTESINKSINK_H_

View File

@ -35,14 +35,14 @@ RemoteInputUDPHandler::RemoteInputUDPHandler(SampleSinkFifo *sampleFifo, DeviceA
m_masterTimerConnected(false),
m_running(false),
m_rateDivider(1000/REMOTEINPUT_THROTTLE_MS),
m_dataSocket(0),
m_dataSocket(nullptr),
m_dataAddress(QHostAddress::LocalHost),
m_remoteAddress(QHostAddress::LocalHost),
m_dataPort(9090),
m_multicastAddress(QStringLiteral("224.0.0.1")),
m_multicast(false),
m_dataConnected(false),
m_udpBuf(0),
m_udpBuf(nullptr),
m_udpReadBytes(0),
m_sampleFifo(sampleFifo),
m_samplerate(0),
@ -95,8 +95,10 @@ void RemoteInputUDPHandler::start()
return;
}
if (!m_dataSocket) {
if (!m_dataSocket)
{
m_dataSocket = new QUdpSocket(this);
m_dataSocket->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;
}

View File

@ -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);

View File

@ -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:
</div>
<div id="generator">
<div class="content">
Generated 2021-12-03T22:37:52.628+01:00
Generated 2021-12-04T20:19:18.225+01:00
</div>
</div>
</div>

View File

@ -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:

View File

@ -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:

View File

@ -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:
</div>
<div id="generator">
<div class="content">
Generated 2021-12-03T22:37:52.628+01:00
Generated 2021-12-04T20:19:18.225+01:00
</div>
</div>
</div>

View File

@ -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;
}

View File

@ -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;