2018-08-31 21:29:53 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
2019-01-22 23:44:13 +00:00
|
|
|
// Copyright (C) 2018-2019 Edouard Griffiths, F4EXB //
|
2018-08-31 21:29:53 +00:00
|
|
|
// //
|
|
|
|
// 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 04:39:30 +00:00
|
|
|
// (at your option) any later version. //
|
2018-08-31 21:29:53 +00: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/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2019-01-22 23:44:13 +00:00
|
|
|
#include "remotesourcesettings.h"
|
|
|
|
|
2018-08-31 21:29:53 +00:00
|
|
|
#include <QColor>
|
|
|
|
|
|
|
|
#include "util/simpleserializer.h"
|
|
|
|
#include "settings/serializable.h"
|
|
|
|
|
2019-01-22 23:44:13 +00:00
|
|
|
|
|
|
|
RemoteSourceSettings::RemoteSourceSettings()
|
2018-08-31 21:29:53 +00:00
|
|
|
{
|
|
|
|
resetToDefaults();
|
|
|
|
}
|
|
|
|
|
2019-01-22 23:44:13 +00:00
|
|
|
void RemoteSourceSettings::resetToDefaults()
|
2018-08-31 21:29:53 +00:00
|
|
|
{
|
|
|
|
m_dataAddress = "127.0.0.1";
|
|
|
|
m_dataPort = 9090;
|
2018-08-31 22:18:35 +00:00
|
|
|
m_rgbColor = QColor(140, 4, 4).rgb();
|
2019-01-22 23:44:13 +00:00
|
|
|
m_title = "Remote source";
|
2018-11-18 10:06:41 +00:00
|
|
|
m_channelMarker = nullptr;
|
2019-11-17 10:09:07 +00:00
|
|
|
m_streamIndex = 0;
|
2018-12-20 22:20:21 +00:00
|
|
|
m_useReverseAPI = false;
|
|
|
|
m_reverseAPIAddress = "127.0.0.1";
|
|
|
|
m_reverseAPIPort = 8888;
|
|
|
|
m_reverseAPIDeviceIndex = 0;
|
|
|
|
m_reverseAPIChannelIndex = 0;
|
2018-08-31 21:29:53 +00:00
|
|
|
}
|
|
|
|
|
2019-01-22 23:44:13 +00:00
|
|
|
QByteArray RemoteSourceSettings::serialize() const
|
2018-08-31 21:29:53 +00:00
|
|
|
{
|
|
|
|
SimpleSerializer s(1);
|
|
|
|
s.writeString(1, m_dataAddress);
|
|
|
|
s.writeU32(2, m_dataPort);
|
|
|
|
s.writeU32(3, m_rgbColor);
|
|
|
|
s.writeString(4, m_title);
|
2018-12-20 22:20:21 +00:00
|
|
|
s.writeBool(5, m_useReverseAPI);
|
|
|
|
s.writeString(6, m_reverseAPIAddress);
|
|
|
|
s.writeU32(7, m_reverseAPIPort);
|
|
|
|
s.writeU32(8, m_reverseAPIDeviceIndex);
|
|
|
|
s.writeU32(9, m_reverseAPIChannelIndex);
|
2019-11-17 10:09:07 +00:00
|
|
|
s.writeS32(10, m_streamIndex);
|
2021-11-24 09:50:42 +00:00
|
|
|
s.writeBlob(11, m_rollupState);
|
2018-08-31 21:29:53 +00:00
|
|
|
|
|
|
|
return s.final();
|
|
|
|
}
|
|
|
|
|
2019-01-22 23:44:13 +00:00
|
|
|
bool RemoteSourceSettings::deserialize(const QByteArray& data)
|
2018-08-31 21:29:53 +00:00
|
|
|
{
|
|
|
|
SimpleDeserializer d(data);
|
|
|
|
|
|
|
|
if(!d.isValid())
|
|
|
|
{
|
|
|
|
resetToDefaults();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(d.getVersion() == 1)
|
|
|
|
{
|
|
|
|
uint32_t tmp;
|
|
|
|
QString strtmp;
|
|
|
|
|
|
|
|
d.readString(1, &m_dataAddress, "127.0.0.1");
|
|
|
|
d.readU32(2, &tmp, 0);
|
|
|
|
|
|
|
|
if ((tmp > 1023) && (tmp < 65535)) {
|
|
|
|
m_dataPort = tmp;
|
|
|
|
} else {
|
|
|
|
m_dataPort = 9090;
|
|
|
|
}
|
|
|
|
|
|
|
|
d.readU32(3, &m_rgbColor, QColor(0, 255, 255).rgb());
|
2019-01-22 23:44:13 +00:00
|
|
|
d.readString(4, &m_title, "Remote source");
|
2018-12-20 22:20:21 +00:00
|
|
|
d.readBool(5, &m_useReverseAPI, false);
|
|
|
|
d.readString(6, &m_reverseAPIAddress, "127.0.0.1");
|
|
|
|
d.readU32(7, &tmp, 0);
|
2018-08-31 21:29:53 +00:00
|
|
|
|
2018-12-20 22:20:21 +00:00
|
|
|
if ((tmp > 1023) && (tmp < 65535)) {
|
|
|
|
m_reverseAPIPort = tmp;
|
|
|
|
} else {
|
|
|
|
m_reverseAPIPort = 8888;
|
|
|
|
}
|
|
|
|
|
|
|
|
d.readU32(8, &tmp, 0);
|
|
|
|
m_reverseAPIDeviceIndex = tmp > 99 ? 99 : tmp;
|
|
|
|
d.readU32(9, &tmp, 0);
|
|
|
|
m_reverseAPIChannelIndex = tmp > 99 ? 99 : tmp;
|
2019-11-17 10:09:07 +00:00
|
|
|
d.readS32(10, &m_streamIndex, 0);
|
2021-11-24 09:50:42 +00:00
|
|
|
d.readBlob(11, &m_rollupState);
|
2019-11-17 10:09:07 +00:00
|
|
|
|
2018-08-31 21:29:53 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
resetToDefaults();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|