1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-22 16:08:39 -05:00

Renamed UDPSink to UDPSource

This commit is contained in:
f4exb 2018-09-11 22:36:16 +02:00
parent 87b9cff3c2
commit f58cc3cc07
17 changed files with 272 additions and 269 deletions

View File

@ -75,8 +75,6 @@ private:
int m_srate;
//UDPSink<Real> m_udpDebug; // UDP debug
static const Real m_pllBeta;
static const Real m_fsc;
};

View File

@ -1,27 +1,27 @@
project(udpsink)
project(udpsource)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(udpsink_SOURCES
udpsink.cpp
udpsinkgui.cpp
udpsinkplugin.cpp
udpsinkudphandler.cpp
udpsinkmsg.cpp
udpsinksettings.cpp
set(udpsource_SOURCES
udpsource.cpp
udpsourcegui.cpp
udpsourceplugin.cpp
udpsourceudphandler.cpp
udpsourcemsg.cpp
udpsourcesettings.cpp
)
set(udpsink_HEADERS
udpsink.h
udpsinkgui.h
udpsinkplugin.h
udpsinkudphandler.h
udpsinkmsg.h
udpsinksettings.h
set(udpsource_HEADERS
udpsource.h
udpsourcegui.h
udpsourceplugin.h
udpsourceudphandler.h
udpsourcemsg.h
udpsourcesettings.h
)
set(udpsink_FORMS
udpsinkgui.ui
set(udpsource_FORMS
udpsourcegui.ui
)
include_directories(
@ -35,21 +35,21 @@ add_definitions(${QT_DEFINITIONS})
add_definitions(-DQT_PLUGIN)
add_definitions(-DQT_SHARED)
qt5_wrap_ui(udpsink_FORMS_HEADERS ${udpsink_FORMS})
qt5_wrap_ui(udpsource_FORMS_HEADERS ${udpsource_FORMS})
add_library(modudpsink SHARED
${udpsink_SOURCES}
${udpsink_HEADERS_MOC}
${udpsink_FORMS_HEADERS}
add_library(udpsource SHARED
${udpsource_SOURCES}
${udpsource_HEADERS_MOC}
${udpsource_FORMS_HEADERS}
)
target_link_libraries(modudpsink
target_link_libraries(udpsource
${QT_LIBRARIES}
sdrbase
sdrgui
swagger
)
target_link_libraries(modudpsink Qt5::Core Qt5::Widgets Qt5::Network)
target_link_libraries(udpsource Qt5::Core Qt5::Widgets Qt5::Network)
install(TARGETS modudpsink DESTINATION lib/plugins/channeltx)
install(TARGETS udpsource DESTINATION lib/plugins/channeltx)

View File

@ -26,18 +26,18 @@
#include "dsp/dspcommands.h"
#include "util/db.h"
#include "udpsinkmsg.h"
#include "udpsink.h"
#include "udpsource.h"
#include "udpsourcemsg.h"
MESSAGE_CLASS_DEFINITION(UDPSink::MsgConfigureUDPSink, Message)
MESSAGE_CLASS_DEFINITION(UDPSink::MsgConfigureChannelizer, Message)
MESSAGE_CLASS_DEFINITION(UDPSink::MsgUDPSinkSpectrum, Message)
MESSAGE_CLASS_DEFINITION(UDPSink::MsgResetReadIndex, Message)
MESSAGE_CLASS_DEFINITION(UDPSource::MsgConfigureUDPSink, Message)
MESSAGE_CLASS_DEFINITION(UDPSource::MsgConfigureChannelizer, Message)
MESSAGE_CLASS_DEFINITION(UDPSource::MsgUDPSinkSpectrum, Message)
MESSAGE_CLASS_DEFINITION(UDPSource::MsgResetReadIndex, Message)
const QString UDPSink::m_channelIdURI = "sdrangel.channeltx.udpsink";
const QString UDPSink::m_channelId = "UDPSink";
const QString UDPSource::m_channelIdURI = "sdrangel.channeltx.udpsource";
const QString UDPSource::m_channelId = "UDPSource";
UDPSink::UDPSink(DeviceSinkAPI *deviceAPI) :
UDPSource::UDPSource(DeviceSinkAPI *deviceAPI) :
ChannelSourceAPI(m_channelIdURI),
m_deviceAPI(deviceAPI),
m_basebandSampleRate(48000),
@ -80,7 +80,7 @@ UDPSink::UDPSink(DeviceSinkAPI *deviceAPI) :
m_deviceAPI->addChannelAPI(this);
}
UDPSink::~UDPSink()
UDPSource::~UDPSource()
{
m_deviceAPI->removeChannelAPI(this);
m_deviceAPI->removeThreadedSource(m_threadedChannelizer);
@ -90,18 +90,18 @@ UDPSink::~UDPSink()
delete[] m_SSBFilterBuffer;
}
void UDPSink::start()
void UDPSource::start()
{
m_udpHandler.start();
applyChannelSettings(m_basebandSampleRate, m_outputSampleRate, m_inputFrequencyOffset, true);
}
void UDPSink::stop()
void UDPSource::stop()
{
m_udpHandler.stop();
}
void UDPSink::pull(Sample& sample)
void UDPSource::pull(Sample& sample)
{
if (m_settings.m_channelMute)
{
@ -147,9 +147,9 @@ void UDPSink::pull(Sample& sample)
sample.m_imag = (FixReal) ci.imag();
}
void UDPSink::modulateSample()
void UDPSource::modulateSample()
{
if (m_settings.m_sampleFormat == UDPSinkSettings::FormatSnLE) // Linear I/Q transponding
if (m_settings.m_sampleFormat == UDPSourceSettings::FormatSnLE) // Linear I/Q transponding
{
Sample s;
@ -173,7 +173,7 @@ void UDPSink::modulateSample()
m_modSample.imag(0.0f);
}
}
else if (m_settings.m_sampleFormat == UDPSinkSettings::FormatNFM)
else if (m_settings.m_sampleFormat == UDPSourceSettings::FormatNFM)
{
qint16 t;
readMonoSample(t);
@ -196,7 +196,7 @@ void UDPSink::modulateSample()
m_modSample.imag(0.0f);
}
}
else if (m_settings.m_sampleFormat == UDPSinkSettings::FormatAM)
else if (m_settings.m_sampleFormat == UDPSourceSettings::FormatAM)
{
qint16 t;
readMonoSample(t);
@ -217,7 +217,7 @@ void UDPSink::modulateSample()
m_modSample.imag(0.0f);
}
}
else if ((m_settings.m_sampleFormat == UDPSinkSettings::FormatLSB) || (m_settings.m_sampleFormat == UDPSinkSettings::FormatUSB))
else if ((m_settings.m_sampleFormat == UDPSourceSettings::FormatLSB) || (m_settings.m_sampleFormat == UDPSourceSettings::FormatUSB))
{
qint16 t;
Complex c, ci;
@ -235,7 +235,7 @@ void UDPSink::modulateSample()
ci.real((t / SDR_TX_SCALEF) * m_settings.m_gainOut);
ci.imag(0.0f);
n_out = m_SSBFilter->runSSB(ci, &filtered, (m_settings.m_sampleFormat == UDPSinkSettings::FormatUSB));
n_out = m_SSBFilter->runSSB(ci, &filtered, (m_settings.m_sampleFormat == UDPSourceSettings::FormatUSB));
if (n_out > 0)
{
@ -279,7 +279,7 @@ void UDPSink::modulateSample()
}
}
void UDPSink::calculateLevel(Real sample)
void UDPSource::calculateLevel(Real sample)
{
if (m_levelCalcCount < m_levelNbSamples)
{
@ -298,7 +298,7 @@ void UDPSink::calculateLevel(Real sample)
}
}
void UDPSink::calculateLevel(Complex sample)
void UDPSource::calculateLevel(Complex sample)
{
Real t = std::abs(sample);
@ -318,12 +318,12 @@ void UDPSink::calculateLevel(Complex sample)
}
}
bool UDPSink::handleMessage(const Message& cmd)
bool UDPSource::handleMessage(const Message& cmd)
{
if (UpChannelizer::MsgChannelizerNotification::match(cmd))
{
UpChannelizer::MsgChannelizerNotification& notif = (UpChannelizer::MsgChannelizerNotification&) cmd;
qDebug() << "UDPSink::handleMessage: MsgChannelizerNotification";
qDebug() << "UDPSource::handleMessage: MsgChannelizerNotification";
applyChannelSettings(notif.getBasebandSampleRate(), notif.getSampleRate(), notif.getFrequencyOffset());
@ -332,7 +332,7 @@ bool UDPSink::handleMessage(const Message& cmd)
else if (MsgConfigureChannelizer::match(cmd))
{
MsgConfigureChannelizer& cfg = (MsgConfigureChannelizer&) cmd;
qDebug() << "UDPSink::handleMessage: MsgConfigureChannelizer:"
qDebug() << "UDPSource::handleMessage: MsgConfigureChannelizer:"
<< " sampleRate: " << cfg.getSampleRate()
<< " centerFrequency: " << cfg.getCenterFrequency();
@ -345,15 +345,15 @@ bool UDPSink::handleMessage(const Message& cmd)
else if (MsgConfigureUDPSink::match(cmd))
{
MsgConfigureUDPSink& cfg = (MsgConfigureUDPSink&) cmd;
qDebug() << "UDPSink::handleMessage: MsgConfigureUDPSink";
qDebug() << "UDPSource::handleMessage: MsgConfigureUDPSink";
applySettings(cfg.getSettings(), cfg.getForce());
return true;
}
else if (UDPSinkMessages::MsgSampleRateCorrection::match(cmd))
else if (UDPSourceMessages::MsgSampleRateCorrection::match(cmd))
{
UDPSinkMessages::MsgSampleRateCorrection& cfg = (UDPSinkMessages::MsgSampleRateCorrection&) cmd;
UDPSourceMessages::MsgSampleRateCorrection& cfg = (UDPSourceMessages::MsgSampleRateCorrection&) cmd;
Real newSampleRate = m_actualInputSampleRate + cfg.getCorrectionFactor() * m_actualInputSampleRate;
// exclude values too way out nominal sample rate (20%)
@ -378,7 +378,7 @@ bool UDPSink::handleMessage(const Message& cmd)
if (m_sampleRateAvgCounter == m_sampleRateAverageItems)
{
float avgRate = m_sampleRateSum / m_sampleRateAverageItems;
qDebug("UDPSink::handleMessage: MsgSampleRateCorrection: corr: %+.6f new rate: %.0f: avg rate: %.0f",
qDebug("UDPSource::handleMessage: MsgSampleRateCorrection: corr: %+.6f new rate: %.0f: avg rate: %.0f",
cfg.getCorrectionFactor(),
m_actualInputSampleRate,
avgRate);
@ -388,7 +388,7 @@ bool UDPSink::handleMessage(const Message& cmd)
}
// else
// {
// qDebug("UDPSink::handleMessage: MsgSampleRateCorrection: corr: %+.6f new rate: %.0f",
// qDebug("UDPSource::handleMessage: MsgSampleRateCorrection: corr: %+.6f new rate: %.0f",
// cfg.getCorrectionFactor(),
// m_actualInputSampleRate);
// }
@ -407,7 +407,7 @@ bool UDPSink::handleMessage(const Message& cmd)
{
MsgUDPSinkSpectrum& spc = (MsgUDPSinkSpectrum&) cmd;
m_spectrumEnabled = spc.getEnabled();
qDebug() << "UDPSink::handleMessage: MsgUDPSinkSpectrum: m_spectrumEnabled: " << m_spectrumEnabled;
qDebug() << "UDPSource::handleMessage: MsgUDPSinkSpectrum: m_spectrumEnabled: " << m_spectrumEnabled;
return true;
}
@ -417,7 +417,7 @@ bool UDPSink::handleMessage(const Message& cmd)
m_udpHandler.resetReadIndex();
m_settingsMutex.unlock();
qDebug() << "UDPSink::handleMessage: MsgResetReadIndex";
qDebug() << "UDPSource::handleMessage: MsgResetReadIndex";
return true;
}
@ -438,21 +438,21 @@ bool UDPSink::handleMessage(const Message& cmd)
}
}
void UDPSink::setSpectrum(bool enabled)
void UDPSource::setSpectrum(bool enabled)
{
Message* cmd = MsgUDPSinkSpectrum::create(enabled);
getInputMessageQueue()->push(cmd);
}
void UDPSink::resetReadIndex()
void UDPSource::resetReadIndex()
{
Message* cmd = MsgResetReadIndex::create();
getInputMessageQueue()->push(cmd);
}
void UDPSink::applyChannelSettings(int basebandSampleRate, int outputSampleRate, int inputFrequencyOffset, bool force)
void UDPSource::applyChannelSettings(int basebandSampleRate, int outputSampleRate, int inputFrequencyOffset, bool force)
{
qDebug() << "UDPSink::applyChannelSettings:"
qDebug() << "UDPSource::applyChannelSettings:"
<< " basebandSampleRate: " << basebandSampleRate
<< " outputSampleRate: " << outputSampleRate
<< " inputFrequencyOffset: " << inputFrequencyOffset;
@ -480,9 +480,9 @@ void UDPSink::applyChannelSettings(int basebandSampleRate, int outputSampleRate,
m_inputFrequencyOffset = inputFrequencyOffset;
}
void UDPSink::applySettings(const UDPSinkSettings& settings, bool force)
void UDPSource::applySettings(const UDPSourceSettings& settings, bool force)
{
qDebug() << "UDPSink::applySettings:"
qDebug() << "UDPSource::applySettings:"
<< " m_inputFrequencyOffset: " << settings.m_inputFrequencyOffset
<< " m_sampleFormat: " << settings.m_sampleFormat
<< " m_inputSampleRate: " << settings.m_inputSampleRate
@ -575,12 +575,12 @@ void UDPSink::applySettings(const UDPSinkSettings& settings, bool force)
m_settings = settings;
}
QByteArray UDPSink::serialize() const
QByteArray UDPSource::serialize() const
{
return m_settings.serialize();
}
bool UDPSink::deserialize(const QByteArray& data)
bool UDPSource::deserialize(const QByteArray& data)
{
if (m_settings.deserialize(data))
{
@ -597,7 +597,7 @@ bool UDPSink::deserialize(const QByteArray& data)
}
}
int UDPSink::webapiSettingsGet(
int UDPSource::webapiSettingsGet(
SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage __attribute__((unused)))
{
@ -607,17 +607,17 @@ int UDPSink::webapiSettingsGet(
return 200;
}
int UDPSink::webapiSettingsPutPatch(
int UDPSource::webapiSettingsPutPatch(
bool force,
const QStringList& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage __attribute__((unused)))
{
UDPSinkSettings settings = m_settings;
UDPSourceSettings settings = m_settings;
bool frequencyOffsetChanged = false;
if (channelSettingsKeys.contains("sampleFormat")) {
settings.m_sampleFormat = (UDPSinkSettings::SampleFormat) response.getUdpSinkSettings()->getSampleFormat();
settings.m_sampleFormat = (UDPSourceSettings::SampleFormat) response.getUdpSinkSettings()->getSampleFormat();
}
if (channelSettingsKeys.contains("inputSampleRate")) {
settings.m_inputSampleRate = response.getUdpSinkSettings()->getInputSampleRate();
@ -678,7 +678,7 @@ int UDPSink::webapiSettingsPutPatch(
if (frequencyOffsetChanged)
{
UDPSink::MsgConfigureChannelizer *msgChan = UDPSink::MsgConfigureChannelizer::create(
UDPSource::MsgConfigureChannelizer *msgChan = UDPSource::MsgConfigureChannelizer::create(
settings.m_inputSampleRate,
settings.m_inputFrequencyOffset);
m_inputMessageQueue.push(msgChan);
@ -698,7 +698,7 @@ int UDPSink::webapiSettingsPutPatch(
return 200;
}
int UDPSink::webapiReportGet(
int UDPSource::webapiReportGet(
SWGSDRangel::SWGChannelReport& response,
QString& errorMessage __attribute__((unused)))
{
@ -708,7 +708,7 @@ int UDPSink::webapiReportGet(
return 200;
}
void UDPSink::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& response, const UDPSinkSettings& settings)
void UDPSource::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& response, const UDPSourceSettings& settings)
{
response.getUdpSinkSettings()->setSampleFormat((int) settings.m_sampleFormat);
response.getUdpSinkSettings()->setInputSampleRate(settings.m_inputSampleRate);
@ -742,7 +742,7 @@ void UDPSink::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& respo
}
}
void UDPSink::webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response)
void UDPSource::webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response)
{
response.getUdpSinkReport()->setInputPowerDb(CalcDb::dbPower(getInMagSq()));
response.getUdpSinkReport()->setChannelPowerDb(CalcDb::dbPower(getMagSq()));

View File

@ -14,8 +14,8 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef PLUGINS_CHANNELTX_UDPSINK_UDPSINK_H_
#define PLUGINS_CHANNELTX_UDPSINK_UDPSINK_H_
#ifndef PLUGINS_CHANNELTX_UDPSINK_UDPSOURCE_H_
#define PLUGINS_CHANNELTX_UDPSINK_UDPSOURCE_H_
#include <QObject>
@ -28,14 +28,14 @@
#include "dsp/fftfilt.h"
#include "util/message.h"
#include "udpsinkudphandler.h"
#include "udpsinksettings.h"
#include "udpsourcesettings.h"
#include "udpsourceudphandler.h"
class DeviceSinkAPI;
class ThreadedBasebandSampleSource;
class UpChannelizer;
class UDPSink : public BasebandSampleSource, public ChannelSourceAPI {
class UDPSource : public BasebandSampleSource, public ChannelSourceAPI {
Q_OBJECT
public:
@ -43,19 +43,19 @@ public:
MESSAGE_CLASS_DECLARATION
public:
const UDPSinkSettings& getSettings() const { return m_settings; }
const UDPSourceSettings& getSettings() const { return m_settings; }
bool getForce() const { return m_force; }
static MsgConfigureUDPSink* create(const UDPSinkSettings& settings, bool force)
static MsgConfigureUDPSink* create(const UDPSourceSettings& settings, bool force)
{
return new MsgConfigureUDPSink(settings, force);
}
private:
UDPSinkSettings m_settings;
UDPSourceSettings m_settings;
bool m_force;
MsgConfigureUDPSink(const UDPSinkSettings& settings, bool force) :
MsgConfigureUDPSink(const UDPSourceSettings& settings, bool force) :
Message(),
m_settings(settings),
m_force(force)
@ -86,8 +86,8 @@ public:
{ }
};
UDPSink(DeviceSinkAPI *deviceAPI);
virtual ~UDPSink();
UDPSource(DeviceSinkAPI *deviceAPI);
virtual ~UDPSource();
virtual void destroy() { delete this; }
void setSpectrumSink(BasebandSampleSink* spectrum) { m_spectrum = spectrum; }
@ -183,7 +183,7 @@ private:
int m_basebandSampleRate;
Real m_outputSampleRate;
int m_inputFrequencyOffset;
UDPSinkSettings m_settings;
UDPSourceSettings m_settings;
Real m_squelch;
@ -206,7 +206,7 @@ private:
MovingAverage<double> m_movingAverage;
MovingAverage<double> m_inMovingAverage;
UDPSinkUDPHandler m_udpHandler;
UDPSourceUDPHandler m_udpHandler;
Real m_actualInputSampleRate; //!< sample rate with UDP buffer skew compensation
double m_sampleRateSum;
int m_sampleRateAvgCounter;
@ -232,12 +232,12 @@ private:
static const int m_ssbFftLen = 1024;
void applyChannelSettings(int basebandSampleRate, int outputSampleRate, int inputFrequencyOffset, bool force = false);
void applySettings(const UDPSinkSettings& settings, bool force = false);
void applySettings(const UDPSourceSettings& settings, bool force = false);
void modulateSample();
void calculateLevel(Real sample);
void calculateLevel(Complex sample);
void webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& response, const UDPSinkSettings& settings);
void webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& response, const UDPSourceSettings& settings);
void webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response);
inline void calculateSquelch(double value)
@ -318,4 +318,4 @@ private:
#endif /* PLUGINS_CHANNELTX_UDPSINK_UDPSINK_H_ */
#endif /* PLUGINS_CHANNELTX_UDPSINK_UDPSOURCE_H_ */

View File

@ -14,6 +14,8 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include "udpsourcegui.h"
#include "device/devicesinkapi.h"
#include "device/deviceuiset.h"
#include "dsp/spectrumvis.h"
@ -24,53 +26,52 @@
#include "plugin/pluginapi.h"
#include "mainwindow.h"
#include "udpsinkgui.h"
#include "ui_udpsinkgui.h"
#include "ui_udpsourcegui.h"
UDPSinkGUI* UDPSinkGUI::create(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSource *channelTx)
UDPSourceGUI* UDPSourceGUI::create(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSource *channelTx)
{
UDPSinkGUI* gui = new UDPSinkGUI(pluginAPI, deviceUISet, channelTx);
UDPSourceGUI* gui = new UDPSourceGUI(pluginAPI, deviceUISet, channelTx);
return gui;
}
void UDPSinkGUI::destroy()
void UDPSourceGUI::destroy()
{
delete this;
}
void UDPSinkGUI::setName(const QString& name)
void UDPSourceGUI::setName(const QString& name)
{
setObjectName(name);
}
QString UDPSinkGUI::getName() const
QString UDPSourceGUI::getName() const
{
return objectName();
}
qint64 UDPSinkGUI::getCenterFrequency() const {
qint64 UDPSourceGUI::getCenterFrequency() const {
return m_channelMarker.getCenterFrequency();
}
void UDPSinkGUI::setCenterFrequency(qint64 centerFrequency)
void UDPSourceGUI::setCenterFrequency(qint64 centerFrequency)
{
m_channelMarker.setCenterFrequency(centerFrequency);
applySettings();
}
void UDPSinkGUI::resetToDefaults()
void UDPSourceGUI::resetToDefaults()
{
m_settings.resetToDefaults();
displaySettings();
applySettings(true);
}
QByteArray UDPSinkGUI::serialize() const
QByteArray UDPSourceGUI::serialize() const
{
return m_settings.serialize();
}
bool UDPSinkGUI::deserialize(const QByteArray& data)
bool UDPSourceGUI::deserialize(const QByteArray& data)
{
if(m_settings.deserialize(data))
{
@ -83,11 +84,11 @@ bool UDPSinkGUI::deserialize(const QByteArray& data)
}
}
bool UDPSinkGUI::handleMessage(const Message& message)
bool UDPSourceGUI::handleMessage(const Message& message)
{
if (UDPSink::MsgConfigureUDPSink::match(message))
if (UDPSource::MsgConfigureUDPSink::match(message))
{
const UDPSink::MsgConfigureUDPSink& cfg = (UDPSink::MsgConfigureUDPSink&) message;
const UDPSource::MsgConfigureUDPSink& cfg = (UDPSource::MsgConfigureUDPSink&) message;
m_settings = cfg.getSettings();
blockApplySettings(true);
displaySettings();
@ -100,7 +101,7 @@ bool UDPSinkGUI::handleMessage(const Message& message)
}
}
void UDPSinkGUI::handleSourceMessages()
void UDPSourceGUI::handleSourceMessages()
{
Message* message;
@ -113,9 +114,9 @@ void UDPSinkGUI::handleSourceMessages()
}
}
UDPSinkGUI::UDPSinkGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSource *channelTx, QWidget* parent) :
UDPSourceGUI::UDPSourceGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSource *channelTx, QWidget* parent) :
RollupWidget(parent),
ui(new Ui::UDPSinkGUI),
ui(new Ui::UDPSourceGUI),
m_pluginAPI(pluginAPI),
m_deviceUISet(deviceUISet),
m_tickCount(0),
@ -129,9 +130,9 @@ UDPSinkGUI::UDPSinkGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandS
setAttribute(Qt::WA_DeleteOnClose, true);
m_spectrumVis = new SpectrumVis(SDR_TX_SCALEF, ui->glSpectrum);
m_udpSink = (UDPSink*) channelTx; //new UDPSink(m_deviceUISet->m_deviceSinkAPI);
m_udpSink->setSpectrumSink(m_spectrumVis);
m_udpSink->setMessageQueueToGUI(getInputMessageQueue());
m_udpSource = (UDPSource*) channelTx;
m_udpSource->setSpectrumSink(m_spectrumVis);
m_udpSource->setMessageQueueToGUI(getInputMessageQueue());
ui->fmDeviation->setEnabled(false);
ui->deltaFrequencyLabel->setText(QString("%1f").arg(QChar(0x94, 0x03)));
@ -161,7 +162,7 @@ UDPSinkGUI::UDPSinkGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandS
m_channelMarker.blockSignals(false);
m_channelMarker.setVisible(true); // activate signal on the last setting only
m_deviceUISet->registerTxChannelInstance(UDPSink::m_channelIdURI, this);
m_deviceUISet->registerTxChannelInstance(UDPSource::m_channelIdURI, this);
m_deviceUISet->addChannelMarker(&m_channelMarker);
m_deviceUISet->addRollupWidget(this);
@ -170,43 +171,43 @@ UDPSinkGUI::UDPSinkGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandS
ui->spectrumGUI->setBuddies(m_spectrumVis->getInputMessageQueue(), m_spectrumVis, ui->glSpectrum);
connect(getInputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleSourceMessages()));
connect(m_udpSink, SIGNAL(levelChanged(qreal, qreal, int)), ui->volumeMeter, SLOT(levelChanged(qreal, qreal, int)));
connect(m_udpSource, SIGNAL(levelChanged(qreal, qreal, int)), ui->volumeMeter, SLOT(levelChanged(qreal, qreal, int)));
displaySettings();
applySettings(true);
}
UDPSinkGUI::~UDPSinkGUI()
UDPSourceGUI::~UDPSourceGUI()
{
m_deviceUISet->removeTxChannelInstance(this);
delete m_udpSink; // TODO: check this: when the GUI closes it has to delete the modulator
delete m_udpSource; // TODO: check this: when the GUI closes it has to delete the modulator
delete m_spectrumVis;
delete ui;
}
void UDPSinkGUI::blockApplySettings(bool block)
void UDPSourceGUI::blockApplySettings(bool block)
{
m_doApplySettings = !block;
}
void UDPSinkGUI::applySettings(bool force)
void UDPSourceGUI::applySettings(bool force)
{
if (m_doApplySettings)
{
UDPSink::MsgConfigureChannelizer *msgChan = UDPSink::MsgConfigureChannelizer::create(
UDPSource::MsgConfigureChannelizer *msgChan = UDPSource::MsgConfigureChannelizer::create(
m_settings.m_inputSampleRate,
m_settings.m_inputFrequencyOffset);
m_udpSink->getInputMessageQueue()->push(msgChan);
m_udpSource->getInputMessageQueue()->push(msgChan);
UDPSink::MsgConfigureUDPSink* message = UDPSink::MsgConfigureUDPSink::create( m_settings, force);
m_udpSink->getInputMessageQueue()->push(message);
UDPSource::MsgConfigureUDPSink* message = UDPSource::MsgConfigureUDPSink::create( m_settings, force);
m_udpSource->getInputMessageQueue()->push(message);
ui->applyBtn->setEnabled(false);
ui->applyBtn->setStyleSheet("QPushButton { background:rgb(79,79,79); }");
}
}
void UDPSinkGUI::displaySettings()
void UDPSourceGUI::displaySettings()
{
m_channelMarker.blockSignals(true);
m_channelMarker.setCenterFrequency(m_settings.m_inputFrequencyOffset);
@ -258,29 +259,29 @@ void UDPSinkGUI::displaySettings()
blockApplySettings(false);
}
void UDPSinkGUI::channelMarkerChangedByCursor()
void UDPSourceGUI::channelMarkerChangedByCursor()
{
ui->deltaFrequency->setValue(m_channelMarker.getCenterFrequency());
m_settings.m_inputFrequencyOffset = m_channelMarker.getCenterFrequency();
applySettings();
}
void UDPSinkGUI::on_deltaFrequency_changed(qint64 value)
void UDPSourceGUI::on_deltaFrequency_changed(qint64 value)
{
m_settings.m_inputFrequencyOffset = value;
m_channelMarker.setCenterFrequency(value);
applySettings();
}
void UDPSinkGUI::on_sampleFormat_currentIndexChanged(int index)
void UDPSourceGUI::on_sampleFormat_currentIndexChanged(int index)
{
if (index == (int) UDPSinkSettings::FormatNFM) {
if (index == (int) UDPSourceSettings::FormatNFM) {
ui->fmDeviation->setEnabled(true);
} else {
ui->fmDeviation->setEnabled(false);
}
if (index == (int) UDPSinkSettings::FormatAM) {
if (index == (int) UDPSourceSettings::FormatAM) {
ui->amModPercent->setEnabled(true);
} else {
ui->amModPercent->setEnabled(false);
@ -292,14 +293,14 @@ void UDPSinkGUI::on_sampleFormat_currentIndexChanged(int index)
ui->applyBtn->setStyleSheet("QPushButton { background-color : green; }");
}
void UDPSinkGUI::on_localUDPAddress_editingFinished()
void UDPSourceGUI::on_localUDPAddress_editingFinished()
{
m_settings.m_udpAddress = ui->localUDPAddress->text();
ui->applyBtn->setEnabled(true);
ui->applyBtn->setStyleSheet("QPushButton { background-color : green; }");
}
void UDPSinkGUI::on_localUDPPort_editingFinished()
void UDPSourceGUI::on_localUDPPort_editingFinished()
{
bool ok;
quint16 udpPort = ui->localUDPPort->text().toInt(&ok);
@ -315,7 +316,7 @@ void UDPSinkGUI::on_localUDPPort_editingFinished()
ui->applyBtn->setStyleSheet("QPushButton { background-color : green; }");
}
void UDPSinkGUI::on_sampleRate_textEdited(const QString& arg1 __attribute__((unused)))
void UDPSourceGUI::on_sampleRate_textEdited(const QString& arg1 __attribute__((unused)))
{
bool ok;
Real inputSampleRate = ui->sampleRate->text().toDouble(&ok);
@ -331,7 +332,7 @@ void UDPSinkGUI::on_sampleRate_textEdited(const QString& arg1 __attribute__((unu
ui->applyBtn->setStyleSheet("QPushButton { background-color : green; }");
}
void UDPSinkGUI::on_rfBandwidth_textEdited(const QString& arg1 __attribute__((unused)))
void UDPSourceGUI::on_rfBandwidth_textEdited(const QString& arg1 __attribute__((unused)))
{
bool ok;
Real rfBandwidth = ui->rfBandwidth->text().toDouble(&ok);
@ -352,7 +353,7 @@ void UDPSinkGUI::on_rfBandwidth_textEdited(const QString& arg1 __attribute__((un
ui->applyBtn->setStyleSheet("QPushButton { background-color : green; }");
}
void UDPSinkGUI::on_fmDeviation_textEdited(const QString& arg1 __attribute__((unused)))
void UDPSourceGUI::on_fmDeviation_textEdited(const QString& arg1 __attribute__((unused)))
{
bool ok;
int fmDeviation = ui->fmDeviation->text().toInt(&ok);
@ -368,7 +369,7 @@ void UDPSinkGUI::on_fmDeviation_textEdited(const QString& arg1 __attribute__((un
ui->applyBtn->setStyleSheet("QPushButton { background-color : green; }");
}
void UDPSinkGUI::on_amModPercent_textEdited(const QString& arg1 __attribute__((unused)))
void UDPSourceGUI::on_amModPercent_textEdited(const QString& arg1 __attribute__((unused)))
{
bool ok;
int amModPercent = ui->amModPercent->text().toInt(&ok);
@ -385,21 +386,21 @@ void UDPSinkGUI::on_amModPercent_textEdited(const QString& arg1 __attribute__((u
ui->applyBtn->setStyleSheet("QPushButton { background-color : green; }");
}
void UDPSinkGUI::on_gainIn_valueChanged(int value)
void UDPSourceGUI::on_gainIn_valueChanged(int value)
{
m_settings.m_gainIn = value / 10.0;
ui->gainInText->setText(tr("%1").arg(m_settings.m_gainIn, 0, 'f', 1));
applySettings();
}
void UDPSinkGUI::on_gainOut_valueChanged(int value)
void UDPSourceGUI::on_gainOut_valueChanged(int value)
{
m_settings.m_gainOut = value / 10.0;
ui->gainOutText->setText(tr("%1").arg(m_settings.m_gainOut, 0, 'f', 1));
applySettings();
}
void UDPSinkGUI::on_squelch_valueChanged(int value)
void UDPSourceGUI::on_squelch_valueChanged(int value)
{
m_settings.m_squelchEnabled = (value != -100);
m_settings.m_squelch = value * 1.0;
@ -413,20 +414,20 @@ void UDPSinkGUI::on_squelch_valueChanged(int value)
applySettings();
}
void UDPSinkGUI::on_squelchGate_valueChanged(int value)
void UDPSourceGUI::on_squelchGate_valueChanged(int value)
{
m_settings.m_squelchGate = value / 100.0;
ui->squelchGateText->setText(tr("%1").arg(roundf(value * 10.0), 0, 'f', 0));
applySettings();
}
void UDPSinkGUI::on_channelMute_toggled(bool checked)
void UDPSourceGUI::on_channelMute_toggled(bool checked)
{
m_settings.m_channelMute = checked;
applySettings();
}
void UDPSinkGUI::on_applyBtn_clicked()
void UDPSourceGUI::on_applyBtn_clicked()
{
if (m_rfBandwidthChanged)
{
@ -439,32 +440,32 @@ void UDPSinkGUI::on_applyBtn_clicked()
applySettings();
}
void UDPSinkGUI::on_resetUDPReadIndex_clicked()
void UDPSourceGUI::on_resetUDPReadIndex_clicked()
{
m_udpSink->resetReadIndex();
m_udpSource->resetReadIndex();
}
void UDPSinkGUI::on_autoRWBalance_toggled(bool checked)
void UDPSourceGUI::on_autoRWBalance_toggled(bool checked)
{
m_settings.m_autoRWBalance = checked;
applySettings();
}
void UDPSinkGUI::on_stereoInput_toggled(bool checked)
void UDPSourceGUI::on_stereoInput_toggled(bool checked)
{
m_settings.m_stereoInput = checked;
applySettings();
}
void UDPSinkGUI::onWidgetRolled(QWidget* widget, bool rollDown)
void UDPSourceGUI::onWidgetRolled(QWidget* widget, bool rollDown)
{
if ((widget == ui->spectrumBox) && (m_udpSink != 0))
if ((widget == ui->spectrumBox) && (m_udpSource != 0))
{
m_udpSink->setSpectrum(rollDown);
m_udpSource->setSpectrum(rollDown);
}
}
void UDPSinkGUI::onMenuDialogCalled(const QPoint &p)
void UDPSourceGUI::onMenuDialogCalled(const QPoint &p)
{
BasicChannelSettingsDialog dialog(&m_channelMarker, this);
dialog.move(p);
@ -479,20 +480,20 @@ void UDPSinkGUI::onMenuDialogCalled(const QPoint &p)
applySettings();
}
void UDPSinkGUI::leaveEvent(QEvent*)
void UDPSourceGUI::leaveEvent(QEvent*)
{
m_channelMarker.setHighlighted(false);
}
void UDPSinkGUI::enterEvent(QEvent*)
void UDPSourceGUI::enterEvent(QEvent*)
{
m_channelMarker.setHighlighted(true);
}
void UDPSinkGUI::tick()
void UDPSourceGUI::tick()
{
m_channelPowerAvg(m_udpSink->getMagSq());
m_inPowerAvg(m_udpSink->getInMagSq());
m_channelPowerAvg(m_udpSource->getMagSq());
m_inPowerAvg(m_udpSource->getInMagSq());
if (m_tickCount % 4 == 0)
{
@ -502,13 +503,13 @@ void UDPSinkGUI::tick()
ui->inputPower->setText(tr("%1").arg(inPowDb, 0, 'f', 1));
}
int32_t bufferGauge = m_udpSink->getBufferGauge();
int32_t bufferGauge = m_udpSource->getBufferGauge();
ui->bufferGaugeNegative->setValue((bufferGauge < 0 ? -bufferGauge : 0));
ui->bufferGaugePositive->setValue((bufferGauge < 0 ? 0 : bufferGauge));
QString s = QString::number(bufferGauge, 'f', 0);
ui->bufferRWBalanceText->setText(tr("%1").arg(s));
if (m_udpSink->getSquelchOpen()) {
if (m_udpSource->getSquelchOpen()) {
ui->channelMute->setStyleSheet("QToolButton { background-color : green; }");
} else {
ui->channelMute->setStyleSheet("QToolButton { background:rgb(79,79,79); }");
@ -517,32 +518,32 @@ void UDPSinkGUI::tick()
m_tickCount++;
}
void UDPSinkGUI::setSampleFormatIndex(const UDPSinkSettings::SampleFormat& sampleFormat)
void UDPSourceGUI::setSampleFormatIndex(const UDPSourceSettings::SampleFormat& sampleFormat)
{
switch(sampleFormat)
{
case UDPSinkSettings::FormatSnLE:
case UDPSourceSettings::FormatSnLE:
ui->sampleFormat->setCurrentIndex(0);
ui->fmDeviation->setEnabled(false);
ui->stereoInput->setChecked(true);
ui->stereoInput->setEnabled(false);
break;
case UDPSinkSettings::FormatNFM:
case UDPSourceSettings::FormatNFM:
ui->sampleFormat->setCurrentIndex(1);
ui->fmDeviation->setEnabled(true);
ui->stereoInput->setEnabled(true);
break;
case UDPSinkSettings::FormatLSB:
case UDPSourceSettings::FormatLSB:
ui->sampleFormat->setCurrentIndex(2);
ui->fmDeviation->setEnabled(false);
ui->stereoInput->setEnabled(true);
break;
case UDPSinkSettings::FormatUSB:
case UDPSourceSettings::FormatUSB:
ui->sampleFormat->setCurrentIndex(3);
ui->fmDeviation->setEnabled(false);
ui->stereoInput->setEnabled(true);
break;
case UDPSinkSettings::FormatAM:
case UDPSourceSettings::FormatAM:
ui->sampleFormat->setCurrentIndex(4);
ui->fmDeviation->setEnabled(false);
ui->stereoInput->setEnabled(true);
@ -556,38 +557,38 @@ void UDPSinkGUI::setSampleFormatIndex(const UDPSinkSettings::SampleFormat& sampl
}
}
void UDPSinkGUI::setSampleFormat(int index)
void UDPSourceGUI::setSampleFormat(int index)
{
switch(index)
{
case 0:
m_settings.m_sampleFormat = UDPSinkSettings::FormatSnLE;
m_settings.m_sampleFormat = UDPSourceSettings::FormatSnLE;
ui->fmDeviation->setEnabled(false);
ui->stereoInput->setChecked(true);
ui->stereoInput->setEnabled(false);
break;
case 1:
m_settings.m_sampleFormat = UDPSinkSettings::FormatNFM;
m_settings.m_sampleFormat = UDPSourceSettings::FormatNFM;
ui->fmDeviation->setEnabled(true);
ui->stereoInput->setEnabled(true);
break;
case 2:
m_settings.m_sampleFormat = UDPSinkSettings::FormatLSB;
m_settings.m_sampleFormat = UDPSourceSettings::FormatLSB;
ui->fmDeviation->setEnabled(false);
ui->stereoInput->setEnabled(true);
break;
case 3:
m_settings.m_sampleFormat = UDPSinkSettings::FormatUSB;
m_settings.m_sampleFormat = UDPSourceSettings::FormatUSB;
ui->fmDeviation->setEnabled(false);
ui->stereoInput->setEnabled(true);
break;
case 4:
m_settings.m_sampleFormat = UDPSinkSettings::FormatAM;
m_settings.m_sampleFormat = UDPSourceSettings::FormatAM;
ui->fmDeviation->setEnabled(false);
ui->stereoInput->setEnabled(true);
break;
default:
m_settings.m_sampleFormat = UDPSinkSettings::FormatSnLE;
m_settings.m_sampleFormat = UDPSourceSettings::FormatSnLE;
ui->fmDeviation->setEnabled(false);
ui->stereoInput->setChecked(true);
ui->stereoInput->setEnabled(false);

View File

@ -14,8 +14,8 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef PLUGINS_CHANNELTX_UDPSINK_UDPSINKGUI_H_
#define PLUGINS_CHANNELTX_UDPSINK_UDPSINKGUI_H_
#ifndef PLUGINS_CHANNELTX_UDPSINK_UDPSOURCEGUI_H_
#define PLUGINS_CHANNELTX_UDPSINK_UDPSOURCEGUI_H_
#include <plugin/plugininstancegui.h>
#include <QObject>
@ -25,8 +25,8 @@
#include "util/messagequeue.h"
#include "util/movingaverage.h"
#include "udpsink.h"
#include "udpsinksettings.h"
#include "udpsource.h"
#include "udpsourcesettings.h"
class PluginAPI;
class DeviceUISet;
@ -34,14 +34,14 @@ class BasebandSampleSource;
class SpectrumVis;
namespace Ui {
class UDPSinkGUI;
class UDPSourceGUI;
}
class UDPSinkGUI : public RollupWidget, public PluginInstanceGUI {
class UDPSourceGUI : public RollupWidget, public PluginInstanceGUI {
Q_OBJECT
public:
static UDPSinkGUI* create(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSource *channelTx);
static UDPSourceGUI* create(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSource *channelTx);
virtual void destroy();
void setName(const QString& name);
@ -58,30 +58,30 @@ public slots:
void channelMarkerChangedByCursor();
private:
Ui::UDPSinkGUI* ui;
Ui::UDPSourceGUI* ui;
PluginAPI* m_pluginAPI;
DeviceUISet* m_deviceUISet;
SpectrumVis* m_spectrumVis;
UDPSink* m_udpSink;
UDPSource* m_udpSource;
MovingAverageUtil<double, double, 4> m_channelPowerAvg;
MovingAverageUtil<double, double, 4> m_inPowerAvg;
uint32_t m_tickCount;
ChannelMarker m_channelMarker;
// settings
UDPSinkSettings m_settings;
UDPSourceSettings m_settings;
bool m_rfBandwidthChanged;
bool m_doApplySettings;
MessageQueue m_inputMessageQueue;
explicit UDPSinkGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSource *channelTx, QWidget* parent = NULL);
virtual ~UDPSinkGUI();
explicit UDPSourceGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSource *channelTx, QWidget* parent = NULL);
virtual ~UDPSourceGUI();
void blockApplySettings(bool block);
void applySettings(bool force = false);
void displaySettings();
void setSampleFormat(int index);
void setSampleFormatIndex(const UDPSinkSettings::SampleFormat& sampleFormat);
void setSampleFormatIndex(const UDPSourceSettings::SampleFormat& sampleFormat);
void leaveEvent(QEvent*);
void enterEvent(QEvent*);
@ -110,4 +110,4 @@ private slots:
void tick();
};
#endif /* PLUGINS_CHANNELTX_UDPSINK_UDPSINKGUI_H_ */
#endif /* PLUGINS_CHANNELTX_UDPSINK_UDPSOURCEGUI_H_ */

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>UDPSinkGUI</class>
<widget class="RollupWidget" name="UDPSinkGUI">
<class>UDPSourceGUI</class>
<widget class="RollupWidget" name="UDPSourceGUI">
<property name="geometry">
<rect>
<x>0</x>
@ -29,13 +29,13 @@
</font>
</property>
<property name="windowTitle">
<string>UDP Sample Sink</string>
<string>UDP Source Sink</string>
</property>
<property name="toolTipDuration">
<number>-1</number>
</property>
<property name="statusTip">
<string>UDP Sample Sink</string>
<string>UDP Source Sink</string>
</property>
<widget class="QWidget" name="widget" native="true">
<property name="geometry">

View File

@ -14,7 +14,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include "udpsinkmsg.h"
#include "udpsourcemsg.h"
MESSAGE_CLASS_DEFINITION(UDPSinkMessages::MsgSampleRateCorrection, Message)
MESSAGE_CLASS_DEFINITION(UDPSourceMessages::MsgSampleRateCorrection, Message)

View File

@ -14,15 +14,15 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef PLUGINS_CHANNELTX_UDPSINK_UDPSINKMSG_H_
#define PLUGINS_CHANNELTX_UDPSINK_UDPSINKMSG_H_
#ifndef PLUGINS_CHANNELTX_UDPSINK_UDPSOURCEMSG_H_
#define PLUGINS_CHANNELTX_UDPSINK_UDPSOURCEMSG_H_
#include "util/message.h"
/**
* Message(s) used to communicate back from UDPSinkUDPHandler to UDPSink
* Message(s) used to communicate back from UDPSinkUDPHandler to UDPSource
*/
class UDPSinkMessages
class UDPSourceMessages
{
public:
class MsgSampleRateCorrection : public Message {
@ -50,4 +50,4 @@ public:
};
#endif /* PLUGINS_CHANNELTX_UDPSINK_UDPSINKMSG_H_ */
#endif /* PLUGINS_CHANNELTX_UDPSINK_UDPSOURCEMSG_H_ */

View File

@ -15,66 +15,66 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include "udpsinkplugin.h"
#include "udpsourceplugin.h"
#include <QtPlugin>
#include "plugin/pluginapi.h"
#ifndef SERVER_MODE
#include "udpsinkgui.h"
#include "udpsourcegui.h"
#endif
#include "udpsink.h"
#include "udpsource.h"
const PluginDescriptor UDPSinkPlugin::m_pluginDescriptor = {
QString("UDP Channel Sink"),
QString("4.0.7"),
const PluginDescriptor UDPSourcePlugin::m_pluginDescriptor = {
QString("UDP Channel Source"),
QString("4.1.0"),
QString("(c) Edouard Griffiths, F4EXB"),
QString("https://github.com/f4exb/sdrangel"),
true,
QString("https://github.com/f4exb/sdrangel")
};
UDPSinkPlugin::UDPSinkPlugin(QObject* parent) :
UDPSourcePlugin::UDPSourcePlugin(QObject* parent) :
QObject(parent),
m_pluginAPI(0)
{
}
const PluginDescriptor& UDPSinkPlugin::getPluginDescriptor() const
const PluginDescriptor& UDPSourcePlugin::getPluginDescriptor() const
{
return m_pluginDescriptor;
}
void UDPSinkPlugin::initPlugin(PluginAPI* pluginAPI)
void UDPSourcePlugin::initPlugin(PluginAPI* pluginAPI)
{
m_pluginAPI = pluginAPI;
// register TCP Channel Source
m_pluginAPI->registerTxChannel(UDPSink::m_channelIdURI, UDPSink::m_channelId, this);
m_pluginAPI->registerTxChannel(UDPSource::m_channelIdURI, UDPSource::m_channelId, this);
}
#ifdef SERVER_MODE
PluginInstanceGUI* UDPSinkPlugin::createTxChannelGUI(
PluginInstanceGUI* UDPSourcePlugin::createTxChannelGUI(
DeviceUISet *deviceUISet __attribute__((unused)),
BasebandSampleSource *txChannel __attribute__((unused)))
{
return 0;
}
#else
PluginInstanceGUI* UDPSinkPlugin::createTxChannelGUI(DeviceUISet *deviceUISet, BasebandSampleSource *txChannel)
PluginInstanceGUI* UDPSourcePlugin::createTxChannelGUI(DeviceUISet *deviceUISet, BasebandSampleSource *txChannel)
{
return UDPSinkGUI::create(m_pluginAPI, deviceUISet, txChannel);
return UDPSourceGUI::create(m_pluginAPI, deviceUISet, txChannel);
}
#endif
BasebandSampleSource* UDPSinkPlugin::createTxChannelBS(DeviceSinkAPI *deviceAPI)
BasebandSampleSource* UDPSourcePlugin::createTxChannelBS(DeviceSinkAPI *deviceAPI)
{
return new UDPSink(deviceAPI);
return new UDPSource(deviceAPI);
}
ChannelSourceAPI* UDPSinkPlugin::createTxChannelCS(DeviceSinkAPI *deviceAPI)
ChannelSourceAPI* UDPSourcePlugin::createTxChannelCS(DeviceSinkAPI *deviceAPI)
{
return new UDPSink(deviceAPI);
return new UDPSource(deviceAPI);
}

View File

@ -24,13 +24,13 @@
class DeviceUISet;
class BasebandSampleSource;
class UDPSinkPlugin : public QObject, PluginInterface {
class UDPSourcePlugin : public QObject, PluginInterface {
Q_OBJECT
Q_INTERFACES(PluginInterface)
Q_PLUGIN_METADATA(IID "sdrangel.channeltx.udpsink")
public:
explicit UDPSinkPlugin(QObject* parent = 0);
explicit UDPSourcePlugin(QObject* parent = 0);
const PluginDescriptor& getPluginDescriptor() const;
void initPlugin(PluginAPI* pluginAPI);

View File

@ -14,21 +14,22 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include "udpsourcesettings.h"
#include <QColor>
#include "dsp/dspengine.h"
#include "util/simpleserializer.h"
#include "settings/serializable.h"
#include "udpsinksettings.h"
UDPSinkSettings::UDPSinkSettings() :
UDPSourceSettings::UDPSourceSettings() :
m_channelMarker(0),
m_spectrumGUI(0)
{
resetToDefaults();
}
void UDPSinkSettings::resetToDefaults()
void UDPSourceSettings::resetToDefaults()
{
m_sampleFormat = FormatSnLE;
m_inputSampleRate = 48000;
@ -51,7 +52,7 @@ void UDPSinkSettings::resetToDefaults()
m_title = "UDP Sample Sink";
}
QByteArray UDPSinkSettings::serialize() const
QByteArray UDPSourceSettings::serialize() const
{
SimpleSerializer s(1);
s.writeS32(2, m_inputFrequencyOffset);
@ -82,7 +83,7 @@ QByteArray UDPSinkSettings::serialize() const
return s.final();
}
bool UDPSinkSettings::deserialize(const QByteArray& data)
bool UDPSourceSettings::deserialize(const QByteArray& data)
{
SimpleDeserializer d(data);

View File

@ -14,16 +14,18 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef PLUGINS_CHANNELTX_UDPSINK_UDPSINKSETTINGS_H_
#define PLUGINS_CHANNELTX_UDPSINK_UDPSINKSETTINGS_H_
#ifndef PLUGINS_CHANNELTX_UDPSINK_UDPSOURCESETTINGS_H_
#define PLUGINS_CHANNELTX_UDPSINK_UDPSOURCESETTINGS_H_
#include <QByteArray>
#include <QString>
#include <stdint.h>
#include "dsp/dsptypes.h"
class Serializable;
struct UDPSinkSettings
struct UDPSourceSettings
{
enum SampleFormat {
FormatSnLE,
@ -59,7 +61,7 @@ struct UDPSinkSettings
Serializable *m_channelMarker;
Serializable *m_spectrumGUI;
UDPSinkSettings();
UDPSourceSettings();
void resetToDefaults();
void setChannelMarker(Serializable *channelMarker) { m_channelMarker = channelMarker; }
void setSpectrumGUI(Serializable *spectrumGUI) { m_spectrumGUI = spectrumGUI; }
@ -70,4 +72,4 @@ struct UDPSinkSettings
#endif /* PLUGINS_CHANNELTX_UDPSINK_UDPSINKSETTINGS_H_ */
#endif /* PLUGINS_CHANNELTX_UDPSINK_UDPSOURCESETTINGS_H_ */

View File

@ -14,16 +14,17 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include "udpsourceudphandler.h"
#include <QDebug>
#include <stdint.h>
#include <algorithm>
#include "udpsinkmsg.h"
#include "udpsinkudphandler.h"
#include "udpsourcemsg.h"
MESSAGE_CLASS_DEFINITION(UDPSinkUDPHandler::MsgUDPAddressAndPort, Message)
MESSAGE_CLASS_DEFINITION(UDPSourceUDPHandler::MsgUDPAddressAndPort, Message)
UDPSinkUDPHandler::UDPSinkUDPHandler() :
UDPSourceUDPHandler::UDPSourceUDPHandler() :
m_dataSocket(0),
m_dataAddress(QHostAddress::LocalHost),
m_remoteAddress(QHostAddress::LocalHost),
@ -46,12 +47,12 @@ UDPSinkUDPHandler::UDPSinkUDPHandler() :
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleMessages()));
}
UDPSinkUDPHandler::~UDPSinkUDPHandler()
UDPSourceUDPHandler::~UDPSourceUDPHandler()
{
delete[] m_udpBuf;
}
void UDPSinkUDPHandler::start()
void UDPSourceUDPHandler::start()
{
qDebug("UDPSinkUDPHandler::start");
@ -77,7 +78,7 @@ void UDPSinkUDPHandler::start()
}
}
void UDPSinkUDPHandler::stop()
void UDPSourceUDPHandler::stop()
{
qDebug("UDPSinkUDPHandler::stop");
@ -94,7 +95,7 @@ void UDPSinkUDPHandler::stop()
}
}
void UDPSinkUDPHandler::dataReadyRead()
void UDPSourceUDPHandler::dataReadyRead()
{
while (m_dataSocket->hasPendingDatagrams() && m_dataConnected)
{
@ -127,7 +128,7 @@ void UDPSinkUDPHandler::dataReadyRead()
}
}
void UDPSinkUDPHandler::moveData(char *blk)
void UDPSourceUDPHandler::moveData(char *blk)
{
memcpy(m_udpBuf[m_writeFrameIndex], blk, m_udpBlockSize);
@ -138,7 +139,7 @@ void UDPSinkUDPHandler::moveData(char *blk)
}
}
void UDPSinkUDPHandler::readSample(qint16 &t)
void UDPSourceUDPHandler::readSample(qint16 &t)
{
if (m_readFrameIndex == m_writeFrameIndex) // block until more writes
{
@ -151,7 +152,7 @@ void UDPSinkUDPHandler::readSample(qint16 &t)
}
}
void UDPSinkUDPHandler::readSample(AudioSample &a)
void UDPSourceUDPHandler::readSample(AudioSample &a)
{
if (m_readFrameIndex == m_writeFrameIndex) // block until more writes
{
@ -165,7 +166,7 @@ void UDPSinkUDPHandler::readSample(AudioSample &a)
}
}
void UDPSinkUDPHandler::readSample(Sample &s)
void UDPSourceUDPHandler::readSample(Sample &s)
{
if (m_readFrameIndex == m_writeFrameIndex) // block until more writes
{
@ -179,7 +180,7 @@ void UDPSinkUDPHandler::readSample(Sample &s)
}
}
void UDPSinkUDPHandler::advanceReadPointer(int nbBytes)
void UDPSourceUDPHandler::advanceReadPointer(int nbBytes)
{
if (m_readIndex < m_udpBlockSize - 2*nbBytes)
{
@ -209,7 +210,7 @@ void UDPSinkUDPHandler::advanceReadPointer(int nbBytes)
float dd = d - m_d; // derivative
float c = (d / 15.0) + (dd / 20.0); // damping and scaling
c = c < -0.05 ? -0.05 : c > 0.05 ? 0.05 : c; // limit
UDPSinkMessages::MsgSampleRateCorrection *msg = UDPSinkMessages::MsgSampleRateCorrection::create(c, d);
UDPSourceMessages::MsgSampleRateCorrection *msg = UDPSourceMessages::MsgSampleRateCorrection::create(c, d);
if (m_autoRWBalance && m_feedbackMessageQueue) {
m_feedbackMessageQueue->push(msg);
@ -222,13 +223,13 @@ void UDPSinkUDPHandler::advanceReadPointer(int nbBytes)
}
}
void UDPSinkUDPHandler::configureUDPLink(const QString& address, quint16 port)
void UDPSourceUDPHandler::configureUDPLink(const QString& address, quint16 port)
{
Message* msg = MsgUDPAddressAndPort::create(address, port);
m_inputMessageQueue.push(msg);
}
void UDPSinkUDPHandler::applyUDPLink(const QString& address, quint16 port)
void UDPSourceUDPHandler::applyUDPLink(const QString& address, quint16 port)
{
qDebug("UDPSinkUDPHandler::configureUDPLink: %s:%d", address.toStdString().c_str(), port);
bool addressOK = m_dataAddress.setAddress(address);
@ -245,7 +246,7 @@ void UDPSinkUDPHandler::applyUDPLink(const QString& address, quint16 port)
start();
}
void UDPSinkUDPHandler::resetReadIndex()
void UDPSourceUDPHandler::resetReadIndex()
{
m_readFrameIndex = (m_writeFrameIndex + (m_nbUDPFrames/2)) % m_nbUDPFrames;
m_rwDelta = m_nbUDPFrames/2;
@ -253,7 +254,7 @@ void UDPSinkUDPHandler::resetReadIndex()
m_d = 0.0f;
}
void UDPSinkUDPHandler::resizeBuffer(float sampleRate)
void UDPSourceUDPHandler::resizeBuffer(float sampleRate)
{
int halfNbFrames = std::max((sampleRate / 375.0), (m_minNbUDPFrames / 2.0));
qDebug("UDPSinkUDPHandler::resizeBuffer: nb_frames: %d", 2*halfNbFrames);
@ -271,7 +272,7 @@ void UDPSinkUDPHandler::resizeBuffer(float sampleRate)
resetReadIndex();
}
void UDPSinkUDPHandler::handleMessages()
void UDPSourceUDPHandler::handleMessages()
{
Message* message;
@ -284,11 +285,11 @@ void UDPSinkUDPHandler::handleMessages()
}
}
bool UDPSinkUDPHandler::handleMessage(const Message& cmd)
bool UDPSourceUDPHandler::handleMessage(const Message& cmd)
{
if (UDPSinkUDPHandler::MsgUDPAddressAndPort::match(cmd))
if (UDPSourceUDPHandler::MsgUDPAddressAndPort::match(cmd))
{
UDPSinkUDPHandler::MsgUDPAddressAndPort& notif = (UDPSinkUDPHandler::MsgUDPAddressAndPort&) cmd;
UDPSourceUDPHandler::MsgUDPAddressAndPort& notif = (UDPSourceUDPHandler::MsgUDPAddressAndPort&) cmd;
applyUDPLink(notif.getAddress(), notif.getPort());
return true;
}

View File

@ -14,8 +14,8 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef PLUGINS_CHANNELTX_UDPSINK_UDPSINKUDPHANDLER_H_
#define PLUGINS_CHANNELTX_UDPSINK_UDPSINKUDPHANDLER_H_
#ifndef PLUGINS_CHANNELTX_UDPSINK_UDPSOURCEUDPHANDLER_H_
#define PLUGINS_CHANNELTX_UDPSINK_UDPSOURCEUDPHANDLER_H_
#include <QObject>
#include <QUdpSocket>
@ -27,12 +27,12 @@
#include "util/message.h"
#include "util/messagequeue.h"
class UDPSinkUDPHandler : public QObject
class UDPSourceUDPHandler : public QObject
{
Q_OBJECT
public:
UDPSinkUDPHandler();
virtual ~UDPSinkUDPHandler();
UDPSourceUDPHandler();
virtual ~UDPSourceUDPHandler();
void start();
void stop();
@ -120,4 +120,4 @@ private slots:
#endif /* PLUGINS_CHANNELTX_UDPSINK_UDPSINKUDPHANDLER_H_ */
#endif /* PLUGINS_CHANNELTX_UDPSINK_UDPSOURCEUDPHANDLER_H_ */

View File

@ -1,22 +1,22 @@
project(udpsink)
project(udpsource)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(PLUGIN_PREFIX "../../../plugins/channeltx/udpsink")
set(udpsink_SOURCES
${PLUGIN_PREFIX}/udpsink.cpp
${PLUGIN_PREFIX}/udpsinkplugin.cpp
${PLUGIN_PREFIX}/udpsinkudphandler.cpp
${PLUGIN_PREFIX}/udpsinkmsg.cpp
${PLUGIN_PREFIX}/udpsinksettings.cpp
set(udpsource_SOURCES
${PLUGIN_PREFIX}/udpsource.cpp
${PLUGIN_PREFIX}/udpsourceplugin.cpp
${PLUGIN_PREFIX}/udpsourceudphandler.cpp
${PLUGIN_PREFIX}/udpsourcemsg.cpp
${PLUGIN_PREFIX}/udpsourcesettings.cpp
)
set(udpsink_HEADERS
${PLUGIN_PREFIX}/udpsink.h
${PLUGIN_PREFIX}/udpsinkplugin.h
${PLUGIN_PREFIX}/udpsinkudphandler.h
${PLUGIN_PREFIX}/udpsinkmsg.h
${PLUGIN_PREFIX}/udpsinksettings.h
set(udpsource_HEADERS
${PLUGIN_PREFIX}/udpsource.h
${PLUGIN_PREFIX}/udpsourceplugin.h
${PLUGIN_PREFIX}/udpsourceudphandler.h
${PLUGIN_PREFIX}/udpsourcemsg.h
${PLUGIN_PREFIX}/udpsourcesettings.h
)
include_directories(
@ -29,17 +29,17 @@ add_definitions(${QT_DEFINITIONS})
add_definitions(-DQT_PLUGIN)
add_definitions(-DQT_SHARED)
add_library(modudpsinksrv SHARED
${udpsink_SOURCES}
${udpsink_HEADERS_MOC}
add_library(udpsourcesrv SHARED
${udpsource_SOURCES}
${udpsource_HEADERS_MOC}
)
target_link_libraries(modudpsinksrv
target_link_libraries(udpsourcesrv
${QT_LIBRARIES}
sdrbase
swagger
)
target_link_libraries(modudpsinksrv Qt5::Core Qt5::Network)
target_link_libraries(udpsourcesrv Qt5::Core Qt5::Network)
install(TARGETS modudpsinksrv DESTINATION lib/pluginssrv/channeltx)
install(TARGETS udpsourcesrv DESTINATION lib/pluginssrv/channeltx)

View File

@ -2208,7 +2208,7 @@ bool WebAPIRequestMapper::validateChannelSettings(
return false;
}
}
else if (*channelType == "UDPSink")
else if (*channelType == "UDPSource")
{
if (channelSettings.getTx() != 0)
{