1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2025-02-03 09:44:01 -05:00

Remove TCP references in attributes and variables of the UDP source plugin

This commit is contained in:
f4exb 2015-11-19 08:55:58 +01:00
parent 34e6c93a89
commit 10783906cb
4 changed files with 71 additions and 71 deletions

View File

@ -26,21 +26,21 @@ MESSAGE_CLASS_DEFINITION(UDPSrc::MsgUDPSrcConfigure, Message)
MESSAGE_CLASS_DEFINITION(UDPSrc::MsgUDPSrcConnection, Message)
MESSAGE_CLASS_DEFINITION(UDPSrc::MsgUDPSrcSpectrum, Message)
UDPSrc::UDPSrc(MessageQueue* uiMessageQueue, UDPSrcGUI* tcpSrcGUI, SampleSink* spectrum) :
UDPSrc::UDPSrc(MessageQueue* uiMessageQueue, UDPSrcGUI* udpSrcGUI, SampleSink* spectrum) :
m_settingsMutex(QMutex::Recursive)
{
setObjectName("TCPSrc");
setObjectName("UDPSrc");
m_inputSampleRate = 96000;
m_sampleFormat = FormatSSB;
m_outputSampleRate = 48000;
m_rfBandwidth = 32000;
m_tcpPort = 9999;
m_udpPort = 9999;
m_nco.setFreq(0, m_inputSampleRate);
m_interpolator.create(16, m_inputSampleRate, m_rfBandwidth / 2.0);
m_sampleDistanceRemain = m_inputSampleRate / m_outputSampleRate;
m_uiMessageQueue = uiMessageQueue;
m_tcpSrcGUI = tcpSrcGUI;
m_udpSrcGUI = udpSrcGUI;
m_spectrum = spectrum;
m_spectrumEnabled = false;
m_nextSSBId = 0;
@ -51,19 +51,19 @@ UDPSrc::UDPSrc(MessageQueue* uiMessageQueue, UDPSrcGUI* tcpSrcGUI, SampleSink* s
m_scale = 0;
m_boost = 0;
m_magsq = 0;
m_sampleBufferSSB.resize(tcpFftLen);
TCPFilter = new fftfilt(0.3 / 48.0, 16.0 / 48.0, tcpFftLen);
m_sampleBufferSSB.resize(udpFftLen);
UDPFilter = new fftfilt(0.3 / 48.0, 16.0 / 48.0, udpFftLen);
// if (!TCPFilter) segfault;
}
UDPSrc::~UDPSrc()
{
if (TCPFilter) delete TCPFilter;
if (UDPFilter) delete UDPFilter;
}
void UDPSrc::configure(MessageQueue* messageQueue, SampleFormat sampleFormat, Real outputSampleRate, Real rfBandwidth, int tcpPort, int boost)
void UDPSrc::configure(MessageQueue* messageQueue, SampleFormat sampleFormat, Real outputSampleRate, Real rfBandwidth, int udpPort, int boost)
{
Message* cmd = MsgUDPSrcConfigure::create(sampleFormat, outputSampleRate, rfBandwidth, tcpPort, boost);
Message* cmd = MsgUDPSrcConfigure::create(sampleFormat, outputSampleRate, rfBandwidth, udpPort, boost);
messageQueue->push(cmd);
}
@ -114,7 +114,7 @@ void UDPSrc::feed(const SampleVector::const_iterator& begin, const SampleVector:
for(SampleVector::const_iterator it = m_sampleBuffer.begin(); it != m_sampleBuffer.end(); ++it) {
//Complex cj(it->real() / 30000.0, it->imag() / 30000.0);
Complex cj(it->real(), it->imag());
int n_out = TCPFilter->runSSB(cj, &sideband, true);
int n_out = UDPFilter->runSSB(cj, &sideband, true);
if (n_out) {
for (int i = 0; i < n_out; i+=2) {
//l = (sideband[i].real() + sideband[i].imag()) * 0.7 * 32000.0;
@ -134,7 +134,7 @@ void UDPSrc::feed(const SampleVector::const_iterator& begin, const SampleVector:
for(SampleVector::const_iterator it = m_sampleBuffer.begin(); it != m_sampleBuffer.end(); ++it) {
Complex cj(it->real() / 32768.0f, it->imag() / 32768.0f);
// An FFT filter here is overkill, but was already set up for SSB
int n_out = TCPFilter->runFilt(cj, &sideband);
int n_out = UDPFilter->runFilt(cj, &sideband);
if (n_out) {
Real sum = 1.0;
for (int i = 0; i < n_out; i+=2) {
@ -148,7 +148,7 @@ void UDPSrc::feed(const SampleVector::const_iterator& begin, const SampleVector:
sum += m_this.real() * m_this.real() + m_this.imag() * m_this.imag();
}
// TODO: correct levels
m_scale = 24000 * tcpFftLen / sum;
m_scale = 24000 * udpFftLen / sum;
for(int i = 0; i < m_ssbSockets.count(); i++)
m_ssbSockets[i].socket->write((const char*)&m_sampleBufferSSB[0], n_out * 2);
m_sampleBufferSSB.clear();
@ -161,10 +161,10 @@ void UDPSrc::feed(const SampleVector::const_iterator& begin, const SampleVector:
void UDPSrc::start()
{
m_tcpServer = new QTcpServer();
connect(m_tcpServer, SIGNAL(newConnection()), this, SLOT(onNewConnection()));
connect(m_tcpServer, SIGNAL(acceptError(QAbstractSocket::SocketError)), this, SLOT(onTcpServerError(QAbstractSocket::SocketError)));
m_tcpServer->listen(QHostAddress::Any, m_tcpPort);
m_udpServer = new QTcpServer();
connect(m_udpServer, SIGNAL(newConnection()), this, SLOT(onNewConnection()));
connect(m_udpServer, SIGNAL(acceptError(QAbstractSocket::SocketError)), this, SLOT(onUdpServerError(QAbstractSocket::SocketError)));
m_udpServer->listen(QHostAddress::Any, m_udpPort);
}
void UDPSrc::stop()
@ -172,9 +172,9 @@ void UDPSrc::stop()
closeAllSockets(&m_ssbSockets);
closeAllSockets(&m_s16leSockets);
if(m_tcpServer->isListening())
m_tcpServer->close();
delete m_tcpServer;
if(m_udpServer->isListening())
m_udpServer->close();
delete m_udpServer;
}
bool UDPSrc::handleMessage(const Message& cmd)
@ -194,7 +194,7 @@ bool UDPSrc::handleMessage(const Message& cmd)
m_settingsMutex.unlock();
qDebug() << "TCPSrc::handleMessage: MsgChannelizerNotification: m_inputSampleRate: " << m_inputSampleRate
qDebug() << "UDPSrc::handleMessage: MsgChannelizerNotification: m_inputSampleRate: " << m_inputSampleRate
<< " frequencyOffset: " << notif.getFrequencyOffset();
return true;
@ -209,16 +209,16 @@ bool UDPSrc::handleMessage(const Message& cmd)
m_outputSampleRate = cfg.getOutputSampleRate();
m_rfBandwidth = cfg.getRFBandwidth();
if (cfg.getTCPPort() != m_tcpPort)
if (cfg.getUDPPort() != m_udpPort)
{
m_tcpPort = cfg.getTCPPort();
m_udpPort = cfg.getUDPPort();
if(m_tcpServer->isListening())
if(m_udpServer->isListening())
{
m_tcpServer->close();
m_udpServer->close();
}
m_tcpServer->listen(QHostAddress::Any, m_tcpPort);
m_udpServer->listen(QHostAddress::Any, m_udpPort);
}
m_boost = cfg.getBoost();
@ -227,16 +227,16 @@ bool UDPSrc::handleMessage(const Message& cmd)
if (m_sampleFormat == FormatSSB)
{
TCPFilter->create_filter(0.3 / 48.0, m_rfBandwidth / 2.0 / m_outputSampleRate);
UDPFilter->create_filter(0.3 / 48.0, m_rfBandwidth / 2.0 / m_outputSampleRate);
}
else
{
TCPFilter->create_filter(0.0, m_rfBandwidth / 2.0 / m_outputSampleRate);
UDPFilter->create_filter(0.0, m_rfBandwidth / 2.0 / m_outputSampleRate);
}
m_settingsMutex.unlock();
qDebug() << " - MsgTCPSrcConfigure: m_sampleFormat: " << m_sampleFormat
qDebug() << " - MsgUDPSrcConfigure: m_sampleFormat: " << m_sampleFormat
<< " m_outputSampleRate: " << m_outputSampleRate
<< " m_rfBandwidth: " << m_rfBandwidth
<< " m_boost: " << m_boost;
@ -249,7 +249,7 @@ bool UDPSrc::handleMessage(const Message& cmd)
m_spectrumEnabled = spc.getEnabled();
qDebug() << " - MsgTCPSrcSpectrum: m_spectrumEnabled: " << m_spectrumEnabled;
qDebug() << " - MsgUDPSrcSpectrum: m_spectrumEnabled: " << m_spectrumEnabled;
return true;
}
@ -280,10 +280,10 @@ void UDPSrc::onNewConnection()
{
qDebug("UDPSrc::onNewConnection");
while(m_tcpServer->hasPendingConnections())
while(m_udpServer->hasPendingConnections())
{
qDebug("UDPSrc::onNewConnection: has a pending connection");
QTcpSocket* connection = m_tcpServer->nextPendingConnection();
QTcpSocket* connection = m_udpServer->nextPendingConnection();
connection->setSocketOption(QAbstractSocket:: KeepAliveOption, 1);
connect(connection, SIGNAL(disconnected()), this, SLOT(onDisconnected()));
@ -362,7 +362,7 @@ void UDPSrc::onDisconnected()
}
}
void UDPSrc::onTcpServerError(QAbstractSocket::SocketError socketError)
void UDPSrc::onUdpServerError(QAbstractSocket::SocketError socketError)
{
qDebug("UDPSrc::onTcpServerError: %s", qPrintable(m_tcpServer->errorString()));
qDebug("UDPSrc::onUdpServerError: %s", qPrintable(m_udpServer->errorString()));
}

View File

@ -1,5 +1,5 @@
#ifndef INCLUDE_TCPSRC_H
#define INCLUDE_TCPSRC_H
#ifndef INCLUDE_UDPSRC_H
#define INCLUDE_UDPSRC_H
#include <QMutex>
#include <QHostAddress>
@ -9,7 +9,7 @@
#include "dsp/interpolator.h"
#include "util/message.h"
#define tcpFftLen 2048
#define udpFftLen 2048
class QTcpServer;
class QTcpSocket;
@ -29,7 +29,7 @@ public:
UDPSrc(MessageQueue* uiMessageQueue, UDPSrcGUI* udpSrcGUI, SampleSink* spectrum);
virtual ~UDPSrc();
void configure(MessageQueue* messageQueue, SampleFormat sampleFormat, Real outputSampleRate, Real rfBandwidth, int tcpPort, int boost);
void configure(MessageQueue* messageQueue, SampleFormat sampleFormat, Real outputSampleRate, Real rfBandwidth, int udpPort, int boost);
void setSpectrum(MessageQueue* messageQueue, bool enabled);
Real getMagSq() const { return m_magsq; }
@ -75,27 +75,27 @@ protected:
SampleFormat getSampleFormat() const { return m_sampleFormat; }
Real getOutputSampleRate() const { return m_outputSampleRate; }
Real getRFBandwidth() const { return m_rfBandwidth; }
int getTCPPort() const { return m_tcpPort; }
int getUDPPort() const { return m_udpPort; }
int getBoost() const { return m_boost; }
static MsgUDPSrcConfigure* create(SampleFormat sampleFormat, Real sampleRate, Real rfBandwidth, int tcpPort, int boost)
static MsgUDPSrcConfigure* create(SampleFormat sampleFormat, Real sampleRate, Real rfBandwidth, int udpPort, int boost)
{
return new MsgUDPSrcConfigure(sampleFormat, sampleRate, rfBandwidth, tcpPort, boost);
return new MsgUDPSrcConfigure(sampleFormat, sampleRate, rfBandwidth, udpPort, boost);
}
private:
SampleFormat m_sampleFormat;
Real m_outputSampleRate;
Real m_rfBandwidth;
int m_tcpPort;
int m_udpPort;
int m_boost;
MsgUDPSrcConfigure(SampleFormat sampleFormat, Real outputSampleRate, Real rfBandwidth, int tcpPort, int boost) :
MsgUDPSrcConfigure(SampleFormat sampleFormat, Real outputSampleRate, Real rfBandwidth, int udpPort, int boost) :
Message(),
m_sampleFormat(sampleFormat),
m_outputSampleRate(outputSampleRate),
m_rfBandwidth(rfBandwidth),
m_tcpPort(tcpPort),
m_udpPort(udpPort),
m_boost(boost)
{ }
};
@ -120,14 +120,14 @@ protected:
};
MessageQueue* m_uiMessageQueue;
UDPSrcGUI* m_tcpSrcGUI;
UDPSrcGUI* m_udpSrcGUI;
int m_inputSampleRate;
int m_sampleFormat;
Real m_outputSampleRate;
Real m_rfBandwidth;
int m_tcpPort;
int m_udpPort;
int m_boost;
Real m_magsq;
@ -137,14 +137,14 @@ protected:
NCO m_nco;
Interpolator m_interpolator;
Real m_sampleDistanceRemain;
fftfilt* TCPFilter;
fftfilt* UDPFilter;
SampleVector m_sampleBuffer;
SampleVector m_sampleBufferSSB;
SampleSink* m_spectrum;
bool m_spectrumEnabled;
QTcpServer* m_tcpServer;
QTcpServer* m_udpServer;
struct Socket {
quint32 id;
QTcpSocket* socket;
@ -166,7 +166,7 @@ protected:
protected slots:
void onNewConnection();
void onDisconnected();
void onTcpServerError(QAbstractSocket::SocketError socketError);
void onUdpServerError(QAbstractSocket::SocketError socketError);
};
#endif // INCLUDE_TCPSRC_H
#endif // INCLUDE_UDPSRC_H

View File

@ -67,7 +67,7 @@ QByteArray UDPSrcGUI::serialize() const
s.writeS32(3, m_sampleFormat);
s.writeReal(4, m_outputSampleRate);
s.writeReal(5, m_rfBandwidth);
s.writeS32(6, m_tcpPort);
s.writeS32(6, m_udpPort);
s.writeBlob(7, ui->spectrumGUI->serialize());
s.writeS32(8, (qint32)m_boost);
s.writeS32(9, m_channelMarker.getCenterFrequency());
@ -140,7 +140,7 @@ bool UDPSrcGUI::deserialize(const QByteArray& data)
bool UDPSrcGUI::handleMessage(const Message& message)
{
qDebug() << "TCPSrcGUI::handleMessage";
qDebug() << "UDPSrcGUI::handleMessage";
if (UDPSrc::MsgUDPSrcConnection::match(message))
{
@ -155,7 +155,7 @@ bool UDPSrcGUI::handleMessage(const Message& message)
delConnection(con.getID());
}
qDebug() << "UDPSrcGUI::handleMessage: TCPSrc::MsgTCPSrcConnection: " << con.getConnect()
qDebug() << "UDPSrcGUI::handleMessage: UDPSrc::MsgUDPSrcConnection: " << con.getConnect()
<< " ID: " << con.getID()
<< " peerAddress: " << con.getPeerAddress()
<< " peerPort: " << con.getPeerPort();
@ -175,7 +175,7 @@ void UDPSrcGUI::channelMarkerChanged()
void UDPSrcGUI::tick()
{
Real powDb = CalcDb::dbPower(m_tcpSrc->getMagSq());
Real powDb = CalcDb::dbPower(m_udpSrc->getMagSq());
m_channelPowerDbAvg.feed(powDb);
ui->channelPower->setText(QString::number(m_channelPowerDbAvg.average(), 'f', 1));
}
@ -184,7 +184,7 @@ UDPSrcGUI::UDPSrcGUI(PluginAPI* pluginAPI, QWidget* parent) :
RollupWidget(parent),
ui(new Ui::UDPSrcGUI),
m_pluginAPI(pluginAPI),
m_tcpSrc(0),
m_udpSrc(0),
m_channelMarker(this),
m_channelPowerDbAvg(40,0),
m_basicSettingsShown(false),
@ -197,8 +197,8 @@ UDPSrcGUI::UDPSrcGUI(PluginAPI* pluginAPI, QWidget* parent) :
setAttribute(Qt::WA_DeleteOnClose, true);
m_spectrumVis = new SpectrumVis(ui->glSpectrum);
m_tcpSrc = new UDPSrc(m_pluginAPI->getMainWindowMessageQueue(), this, m_spectrumVis);
m_channelizer = new Channelizer(m_tcpSrc);
m_udpSrc = new UDPSrc(m_pluginAPI->getMainWindowMessageQueue(), this, m_spectrumVis);
m_channelizer = new Channelizer(m_udpSrc);
m_threadedChannelizer = new ThreadedSampleSink(m_channelizer, this);
DSPEngine::instance()->addThreadedSink(m_threadedChannelizer);
@ -233,7 +233,7 @@ UDPSrcGUI::~UDPSrcGUI()
DSPEngine::instance()->removeThreadedSink(m_threadedChannelizer);
delete m_threadedChannelizer;
delete m_channelizer;
delete m_tcpSrc;
delete m_udpSrc;
delete m_spectrumVis;
//delete m_channelMarker;
delete ui;
@ -264,11 +264,11 @@ void UDPSrcGUI::applySettings()
rfBandwidth = outputSampleRate;
}
int tcpPort = ui->udpPort->text().toInt(&ok);
int udpPort = ui->udpPort->text().toInt(&ok);
if((!ok) || (tcpPort < 1) || (tcpPort > 65535))
if((!ok) || (udpPort < 1) || (udpPort > 65535))
{
tcpPort = 9999;
udpPort = 9999;
}
int boost = ui->boost->value();
@ -278,7 +278,7 @@ void UDPSrcGUI::applySettings()
ui->deltaMinus->setChecked(m_channelMarker.getCenterFrequency() < 0);
ui->sampleRate->setText(QString("%1").arg(outputSampleRate, 0));
ui->rfBandwidth->setText(QString("%1").arg(rfBandwidth, 0));
ui->udpPort->setText(QString("%1").arg(tcpPort));
ui->udpPort->setText(QString("%1").arg(udpPort));
ui->boost->setValue(boost);
m_channelMarker.disconnect(this, SLOT(channelMarkerChanged()));
m_channelMarker.setBandwidth((int)rfBandwidth);
@ -310,14 +310,14 @@ void UDPSrcGUI::applySettings()
m_sampleFormat = sampleFormat;
m_outputSampleRate = outputSampleRate;
m_rfBandwidth = rfBandwidth;
m_tcpPort = tcpPort;
m_udpPort = udpPort;
m_boost = boost;
m_tcpSrc->configure(m_tcpSrc->getInputMessageQueue(),
m_udpSrc->configure(m_udpSrc->getInputMessageQueue(),
sampleFormat,
outputSampleRate,
rfBandwidth,
tcpPort,
udpPort,
boost);
ui->applyBtn->setEnabled(false);
@ -378,9 +378,9 @@ void UDPSrcGUI::on_boost_valueChanged(int value)
void UDPSrcGUI::onWidgetRolled(QWidget* widget, bool rollDown)
{
if ((widget == ui->spectrumBox) && (m_tcpSrc != 0))
if ((widget == ui->spectrumBox) && (m_udpSrc != 0))
{
m_tcpSrc->setSpectrum(m_tcpSrc->getInputMessageQueue(), rollDown);
m_udpSrc->setSpectrum(m_udpSrc->getInputMessageQueue(), rollDown);
}
}

View File

@ -1,5 +1,5 @@
#ifndef INCLUDE_TCPSRCGUI_H
#define INCLUDE_TCPSRCGUI_H
#ifndef INCLUDE_UDPSRCGUI_H
#define INCLUDE_UDPSRCGUI_H
#include <QHostAddress>
#include "gui/rollupwidget.h"
@ -54,7 +54,7 @@ private slots:
private:
Ui::UDPSrcGUI* ui;
PluginAPI* m_pluginAPI;
UDPSrc* m_tcpSrc;
UDPSrc* m_udpSrc;
ChannelMarker m_channelMarker;
MovingAverage<Real> m_channelPowerDbAvg;
@ -63,7 +63,7 @@ private:
Real m_outputSampleRate;
Real m_rfBandwidth;
int m_boost;
int m_tcpPort;
int m_udpPort;
bool m_basicSettingsShown;
bool m_doApplySettings;
@ -82,4 +82,4 @@ private:
void delConnection(quint32 id);
};
#endif // INCLUDE_TCPSRCGUI_H
#endif // INCLUDE_UDPSRCGUI_H