SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
udpsinksettings.cpp
Go to the documentation of this file.
1 // Copyright (C) 2017 Edouard Griffiths, F4EXB //
3 // //
4 // This program is free software; you can redistribute it and/or modify //
5 // it under the terms of the GNU General Public License as published by //
6 // the Free Software Foundation as version 3 of the License, or //
7 // (at your option) any later version. //
8 // //
9 // This program is distributed in the hope that it will be useful, //
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
12 // GNU General Public License V3 for more details. //
13 // //
14 // You should have received a copy of the GNU General Public License //
15 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
17 
18 #include <QColor>
19 
20 #include "dsp/dspengine.h"
21 #include "util/simpleserializer.h"
22 #include "settings/serializable.h"
23 #include "udpsinksettings.h"
24 
26  m_channelMarker(0),
27  m_spectrumGUI(0)
28 {
30 }
31 
33 {
34  m_outputSampleRate = 48000;
37  m_rfBandwidth = 12500;
38  m_fmDeviation = 2500;
39  m_channelMute = false;
40  m_gain = 1.0;
41  m_squelchdB = -60;
42  m_squelchGate = 0.0;
43  m_squelchEnabled = true;
44  m_agc = false;
45  m_audioActive = false;
46  m_audioStereo = false;
47  m_volume = 20;
48  m_udpAddress = "127.0.0.1";
49  m_udpPort = 9998;
50  m_audioPort = 9997;
51  m_rgbColor = QColor(225, 25, 99).rgb();
52  m_title = "UDP Sample Sink";
53  m_useReverseAPI = false;
54  m_reverseAPIAddress = "127.0.0.1";
55  m_reverseAPIPort = 8888;
58 }
59 
60 QByteArray UDPSinkSettings::serialize() const
61 {
62  SimpleSerializer s(1);
64  s.writeS32(3, (int) m_sampleFormat);
67 
68  if (m_channelMarker) {
70  }
71 
72  if (m_spectrumGUI) {
74  }
75 
76  s.writeS32(8, m_gain*10.0);
77  s.writeU32(9, m_rgbColor);
78  s.writeBool(11, m_audioActive);
79  s.writeS32(12, m_volume);
80  s.writeBool(14, m_audioStereo);
81  s.writeS32(15, m_fmDeviation);
82  s.writeS32(16, m_squelchdB);
83  s.writeS32(17, m_squelchGate);
84  s.writeBool(18, m_agc);
85  s.writeString(19, m_title);
87  s.writeU32(21, m_udpPort);
88  s.writeU32(22, m_audioPort);
94 
95  return s.final();
96 
97 }
98 
99 bool UDPSinkSettings::deserialize(const QByteArray& data)
100 {
101  SimpleDeserializer d(data);
102 
103  if (!d.isValid())
104  {
105  resetToDefaults();
106  return false;
107  }
108 
109  if (d.getVersion() == 1)
110  {
111  QByteArray bytetmp;
112  QString strtmp;
113  int32_t s32tmp;
114  quint32 u32tmp;
115 
116  if (m_channelMarker) {
117  d.readBlob(6, &bytetmp);
118  m_channelMarker->deserialize(bytetmp);
119  }
120 
121  d.readS32(2, &s32tmp, 0);
122  m_inputFrequencyOffset = s32tmp;
123 
124  d.readS32(3, &s32tmp, FormatIQ16);
125 
126  if ((s32tmp >= 0) && (s32tmp < (int) FormatNone)) {
127  m_sampleFormat = (SampleFormat) s32tmp;
128  } else {
130  }
131 
132  d.readReal(4, &m_outputSampleRate, 48000.0);
133  d.readReal(5, &m_rfBandwidth, 32000.0);
134 
135  if (m_spectrumGUI) {
136  d.readBlob(7, &bytetmp);
137  m_spectrumGUI->deserialize(bytetmp);
138  }
139 
140  d.readS32(8, &s32tmp, 10);
141  m_gain = s32tmp / 10.0;
142  d.readU32(9, &m_rgbColor);
143  d.readBool(11, &m_audioActive, false);
144  d.readS32(12, &m_volume, 20);
145  d.readBool(14, &m_audioStereo, false);
146  d.readS32(15, &m_fmDeviation, 2500);
147  d.readS32(16, &m_squelchdB, -60);
148  d.readS32(17, &m_squelchGate, 5);
149  d.readBool(18, &m_agc, false);
150  d.readString(19, &m_title, "UDP Sample Source");
151  d.readString(20, &m_udpAddress, "127.0.0.1");
152 
153  d.readU32(21, &u32tmp, 9998);
154 
155  if ((u32tmp > 1024) & (u32tmp < 65538)) {
156  m_udpPort = u32tmp;
157  } else {
158  m_udpPort = 9998;
159  }
160 
161  d.readU32(22, &u32tmp, 9997);
162 
163  if ((u32tmp > 1024) & (u32tmp < 65538)) {
164  m_audioPort = u32tmp;
165  } else {
166  m_audioPort = 9997;
167  }
168 
169  d.readBool(23, &m_useReverseAPI, false);
170  d.readString(24, &m_reverseAPIAddress, "127.0.0.1");
171  d.readU32(25, &u32tmp, 0);
172 
173  if ((u32tmp > 1023) && (u32tmp < 65535)) {
174  m_reverseAPIPort = u32tmp;
175  } else {
176  m_reverseAPIPort = 8888;
177  }
178 
179  d.readU32(26, &u32tmp, 0);
180  m_reverseAPIDeviceIndex = u32tmp > 99 ? 99 : u32tmp;
181  d.readU32(27, &u32tmp, 0);
182  m_reverseAPIChannelIndex = u32tmp > 99 ? 99 : u32tmp;
183 
184  return true;
185  }
186  else
187  {
188  resetToDefaults();
189  return false;
190  }
191 }
192 
int m_squelchdB
power dB
bool deserialize(const QByteArray &data)
Serializable * m_spectrumGUI
Serializable * m_channelMarker
void writeBlob(quint32 id, const QByteArray &value)
uint16_t m_reverseAPIPort
bool readU32(quint32 id, quint32 *result, quint32 def=0) const
bool readString(quint32 id, QString *result, const QString &def=QString::null) const
bool readBool(quint32 id, bool *result, bool def=false) const
bool isValid() const
int m_squelchGate
100ths seconds
QByteArray serialize() const
bool readS32(quint32 id, qint32 *result, qint32 def=0) const
uint16_t m_reverseAPIDeviceIndex
bool readBlob(quint32 id, QByteArray *result, const QByteArray &def=QByteArray()) const
int int32_t
Definition: rtptypes_win.h:45
void writeS32(quint32 id, qint32 value)
quint32 getVersion() const
virtual bool deserialize(const QByteArray &data)=0
void writeU32(quint32 id, quint32 value)
uint16_t m_reverseAPIChannelIndex
SampleFormat m_sampleFormat
void writeReal(quint32 id, Real value)
bool readReal(quint32 id, Real *result, Real def=0) const
virtual QByteArray serialize() const =0
void writeBool(quint32 id, bool value)
uint16_t m_audioPort
int64_t m_inputFrequencyOffset
void writeString(quint32 id, const QString &value)
const QByteArray & final()
QString m_reverseAPIAddress