2017-10-04 18:55:14 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2017 Edouard Griffiths, F4EXB //
|
|
|
|
// //
|
|
|
|
// This program is free software; you can redistribute it and/or modify //
|
|
|
|
// it under the terms of the GNU General Public License as published by //
|
|
|
|
// the Free Software Foundation as version 3 of the License, or //
|
2019-04-11 00:39:30 -04:00
|
|
|
// (at your option) any later version. //
|
2017-10-04 18:55:14 -04:00
|
|
|
// //
|
|
|
|
// This program is distributed in the hope that it will be useful, //
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
|
|
|
// GNU General Public License V3 for more details. //
|
|
|
|
// //
|
|
|
|
// You should have received a copy of the GNU General Public License //
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2017-10-05 16:11:57 -04:00
|
|
|
#include <QColor>
|
|
|
|
|
2017-10-04 18:55:14 -04:00
|
|
|
#include "dsp/dspengine.h"
|
|
|
|
#include "util/simpleserializer.h"
|
|
|
|
#include "settings/serializable.h"
|
2018-09-11 18:08:47 -04:00
|
|
|
#include "udpsinksettings.h"
|
2017-10-04 18:55:14 -04:00
|
|
|
|
2018-09-11 18:08:47 -04:00
|
|
|
UDPSinkSettings::UDPSinkSettings() :
|
2017-10-04 18:55:14 -04:00
|
|
|
m_channelMarker(0),
|
|
|
|
m_spectrumGUI(0)
|
|
|
|
{
|
|
|
|
resetToDefaults();
|
|
|
|
}
|
|
|
|
|
2018-09-11 18:08:47 -04:00
|
|
|
void UDPSinkSettings::resetToDefaults()
|
2017-10-04 18:55:14 -04:00
|
|
|
{
|
|
|
|
m_outputSampleRate = 48000;
|
2018-04-19 07:34:22 -04:00
|
|
|
m_sampleFormat = FormatIQ16;
|
2017-10-04 18:55:14 -04:00
|
|
|
m_inputFrequencyOffset = 0;
|
|
|
|
m_rfBandwidth = 12500;
|
|
|
|
m_fmDeviation = 2500;
|
|
|
|
m_channelMute = false;
|
|
|
|
m_gain = 1.0;
|
2017-10-06 23:44:43 -04:00
|
|
|
m_squelchdB = -60;
|
2017-10-04 18:55:14 -04:00
|
|
|
m_squelchGate = 0.0;
|
|
|
|
m_squelchEnabled = true;
|
|
|
|
m_agc = false;
|
|
|
|
m_audioActive = false;
|
|
|
|
m_audioStereo = false;
|
|
|
|
m_volume = 20;
|
2019-09-22 19:25:17 -04:00
|
|
|
m_streamIndex = 0;
|
2017-10-05 02:38:06 -04:00
|
|
|
m_udpAddress = "127.0.0.1";
|
2018-04-19 17:03:21 -04:00
|
|
|
m_udpPort = 9998;
|
|
|
|
m_audioPort = 9997;
|
2017-10-05 16:11:57 -04:00
|
|
|
m_rgbColor = QColor(225, 25, 99).rgb();
|
2018-09-11 19:21:51 -04:00
|
|
|
m_title = "UDP Sample Sink";
|
2018-12-24 04:27:35 -05:00
|
|
|
m_useReverseAPI = false;
|
|
|
|
m_reverseAPIAddress = "127.0.0.1";
|
|
|
|
m_reverseAPIPort = 8888;
|
|
|
|
m_reverseAPIDeviceIndex = 0;
|
|
|
|
m_reverseAPIChannelIndex = 0;
|
2017-10-04 18:55:14 -04:00
|
|
|
}
|
|
|
|
|
2018-09-11 18:08:47 -04:00
|
|
|
QByteArray UDPSinkSettings::serialize() const
|
2017-10-04 18:55:14 -04:00
|
|
|
{
|
|
|
|
SimpleSerializer s(1);
|
|
|
|
s.writeS32(2, m_inputFrequencyOffset);
|
2017-10-06 23:44:43 -04:00
|
|
|
s.writeS32(3, (int) m_sampleFormat);
|
2017-10-04 18:55:14 -04:00
|
|
|
s.writeReal(4, m_outputSampleRate);
|
|
|
|
s.writeReal(5, m_rfBandwidth);
|
|
|
|
|
|
|
|
if (m_channelMarker) {
|
|
|
|
s.writeBlob(6, m_channelMarker->serialize());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_spectrumGUI) {
|
|
|
|
s.writeBlob(7, m_spectrumGUI->serialize());
|
|
|
|
}
|
|
|
|
|
|
|
|
s.writeS32(8, m_gain*10.0);
|
2017-10-05 16:11:57 -04:00
|
|
|
s.writeU32(9, m_rgbColor);
|
2017-10-04 18:55:14 -04:00
|
|
|
s.writeBool(11, m_audioActive);
|
|
|
|
s.writeS32(12, m_volume);
|
|
|
|
s.writeBool(14, m_audioStereo);
|
|
|
|
s.writeS32(15, m_fmDeviation);
|
2017-10-06 23:44:43 -04:00
|
|
|
s.writeS32(16, m_squelchdB);
|
|
|
|
s.writeS32(17, m_squelchGate);
|
2017-10-04 18:55:14 -04:00
|
|
|
s.writeBool(18, m_agc);
|
2017-11-19 12:18:17 -05:00
|
|
|
s.writeString(19, m_title);
|
2018-04-19 17:03:21 -04:00
|
|
|
s.writeString(20, m_udpAddress);
|
|
|
|
s.writeU32(21, m_udpPort);
|
|
|
|
s.writeU32(22, m_audioPort);
|
2018-12-24 04:27:35 -05:00
|
|
|
s.writeBool(23, m_useReverseAPI);
|
|
|
|
s.writeString(24, m_reverseAPIAddress);
|
|
|
|
s.writeU32(25, m_reverseAPIPort);
|
|
|
|
s.writeU32(26, m_reverseAPIDeviceIndex);
|
|
|
|
s.writeU32(27, m_reverseAPIChannelIndex);
|
2019-09-22 19:25:17 -04:00
|
|
|
s.writeS32(28, m_streamIndex);
|
2021-11-24 04:50:42 -05:00
|
|
|
s.writeBlob(29, m_rollupState);
|
2017-11-19 12:18:17 -05:00
|
|
|
|
2017-10-04 18:55:14 -04:00
|
|
|
return s.final();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-09-11 18:08:47 -04:00
|
|
|
bool UDPSinkSettings::deserialize(const QByteArray& data)
|
2017-10-04 18:55:14 -04:00
|
|
|
{
|
|
|
|
SimpleDeserializer d(data);
|
|
|
|
|
|
|
|
if (!d.isValid())
|
|
|
|
{
|
|
|
|
resetToDefaults();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (d.getVersion() == 1)
|
|
|
|
{
|
|
|
|
QByteArray bytetmp;
|
|
|
|
QString strtmp;
|
|
|
|
int32_t s32tmp;
|
2018-04-19 17:03:21 -04:00
|
|
|
quint32 u32tmp;
|
2017-10-04 18:55:14 -04:00
|
|
|
|
|
|
|
if (m_channelMarker) {
|
|
|
|
d.readBlob(6, &bytetmp);
|
|
|
|
m_channelMarker->deserialize(bytetmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
d.readS32(2, &s32tmp, 0);
|
|
|
|
m_inputFrequencyOffset = s32tmp;
|
|
|
|
|
2018-04-19 07:34:22 -04:00
|
|
|
d.readS32(3, &s32tmp, FormatIQ16);
|
2017-10-04 18:55:14 -04:00
|
|
|
|
|
|
|
if ((s32tmp >= 0) && (s32tmp < (int) FormatNone)) {
|
|
|
|
m_sampleFormat = (SampleFormat) s32tmp;
|
|
|
|
} else {
|
2018-04-19 07:34:22 -04:00
|
|
|
m_sampleFormat = FormatIQ16;
|
2017-10-04 18:55:14 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
d.readReal(4, &m_outputSampleRate, 48000.0);
|
|
|
|
d.readReal(5, &m_rfBandwidth, 32000.0);
|
|
|
|
|
|
|
|
if (m_spectrumGUI) {
|
|
|
|
d.readBlob(7, &bytetmp);
|
|
|
|
m_spectrumGUI->deserialize(bytetmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
d.readS32(8, &s32tmp, 10);
|
|
|
|
m_gain = s32tmp / 10.0;
|
2017-10-05 16:11:57 -04:00
|
|
|
d.readU32(9, &m_rgbColor);
|
2017-10-04 18:55:14 -04:00
|
|
|
d.readBool(11, &m_audioActive, false);
|
|
|
|
d.readS32(12, &m_volume, 20);
|
|
|
|
d.readBool(14, &m_audioStereo, false);
|
|
|
|
d.readS32(15, &m_fmDeviation, 2500);
|
2017-10-06 23:44:43 -04:00
|
|
|
d.readS32(16, &m_squelchdB, -60);
|
|
|
|
d.readS32(17, &m_squelchGate, 5);
|
2017-10-04 18:55:14 -04:00
|
|
|
d.readBool(18, &m_agc, false);
|
2017-11-19 12:18:17 -05:00
|
|
|
d.readString(19, &m_title, "UDP Sample Source");
|
2018-04-19 17:03:21 -04:00
|
|
|
d.readString(20, &m_udpAddress, "127.0.0.1");
|
|
|
|
|
|
|
|
d.readU32(21, &u32tmp, 9998);
|
|
|
|
|
|
|
|
if ((u32tmp > 1024) & (u32tmp < 65538)) {
|
|
|
|
m_udpPort = u32tmp;
|
|
|
|
} else {
|
|
|
|
m_udpPort = 9998;
|
|
|
|
}
|
|
|
|
|
|
|
|
d.readU32(22, &u32tmp, 9997);
|
|
|
|
|
|
|
|
if ((u32tmp > 1024) & (u32tmp < 65538)) {
|
|
|
|
m_audioPort = u32tmp;
|
|
|
|
} else {
|
|
|
|
m_audioPort = 9997;
|
|
|
|
}
|
2017-11-19 12:18:17 -05:00
|
|
|
|
2018-12-24 04:27:35 -05:00
|
|
|
d.readBool(23, &m_useReverseAPI, false);
|
|
|
|
d.readString(24, &m_reverseAPIAddress, "127.0.0.1");
|
|
|
|
d.readU32(25, &u32tmp, 0);
|
|
|
|
|
|
|
|
if ((u32tmp > 1023) && (u32tmp < 65535)) {
|
|
|
|
m_reverseAPIPort = u32tmp;
|
|
|
|
} else {
|
|
|
|
m_reverseAPIPort = 8888;
|
|
|
|
}
|
|
|
|
|
|
|
|
d.readU32(26, &u32tmp, 0);
|
|
|
|
m_reverseAPIDeviceIndex = u32tmp > 99 ? 99 : u32tmp;
|
|
|
|
d.readU32(27, &u32tmp, 0);
|
|
|
|
m_reverseAPIChannelIndex = u32tmp > 99 ? 99 : u32tmp;
|
2019-09-22 19:25:17 -04:00
|
|
|
d.readS32(28, &m_streamIndex, 0);
|
2021-11-24 04:50:42 -05:00
|
|
|
d.readBlob(29, &m_rollupState);
|
2018-12-24 04:27:35 -05:00
|
|
|
|
2017-10-04 18:55:14 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
resetToDefaults();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|