kopia lustrzana https://gitlab.com/eliggett/wfview
Create udpPreferences struct and remove civPort and audioPort from UI
rodzic
7491c10c4d
commit
91a60bf918
|
@ -1002,20 +1002,20 @@ qint64 audioHandler::writeData(const char* data, qint64 len)
|
|||
qint64 sentlen = 0;
|
||||
int tosend = 0;
|
||||
QMutexLocker locker(&mutex);
|
||||
AUDIOPACKET *current;
|
||||
audioPacket *current;
|
||||
|
||||
while (sentlen < len) {
|
||||
if (!audioBuffer.isEmpty())
|
||||
{
|
||||
if (audioBuffer.last().sent == chunkSize)
|
||||
{
|
||||
audioBuffer.append(AUDIOPACKET());
|
||||
audioBuffer.append(audioPacket());
|
||||
audioBuffer.last().sent = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
audioBuffer.append(AUDIOPACKET());
|
||||
audioBuffer.append(audioPacket());
|
||||
audioBuffer.last().sent = 0;
|
||||
}
|
||||
current = &audioBuffer.last();
|
||||
|
@ -1091,7 +1091,7 @@ void audioHandler::stateChanged(QAudio::State state)
|
|||
|
||||
|
||||
|
||||
void audioHandler::incomingAudio(const AUDIOPACKET data)
|
||||
void audioHandler::incomingAudio(const audioPacket data)
|
||||
{
|
||||
if (audioOutput != Q_NULLPTR && audioOutput->state() != QAudio::StoppedState) {
|
||||
QMutexLocker locker(&mutex);
|
||||
|
@ -1106,7 +1106,7 @@ void audioHandler::incomingAudio(const AUDIOPACKET data)
|
|||
|
||||
// Sort the buffer by seq number. This is important and audio packets may have arrived out-of-order
|
||||
std::sort(audioBuffer.begin(), audioBuffer.end(),
|
||||
[](const AUDIOPACKET& a, const AUDIOPACKET& b) -> bool
|
||||
[](const audioPacket& a, const audioPacket& b) -> bool
|
||||
{
|
||||
return a.seq < b.seq;
|
||||
});
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
//#define BUFFER_SIZE (32*1024)
|
||||
|
||||
|
||||
struct AUDIOPACKET {
|
||||
struct audioPacket {
|
||||
quint16 seq;
|
||||
QTime time;
|
||||
quint16 sent;
|
||||
|
@ -55,7 +55,7 @@ public:
|
|||
bool isChunkAvailable();
|
||||
public slots:
|
||||
bool init(const quint8 bits, const quint8 channels, const quint16 samplerate, const quint16 latency, const bool isulaw, const bool isinput);
|
||||
void incomingAudio(const AUDIOPACKET data);
|
||||
void incomingAudio(const audioPacket data);
|
||||
void changeLatency(const quint16 newSize);
|
||||
|
||||
private slots:
|
||||
|
@ -87,7 +87,7 @@ private:
|
|||
QAudioDeviceInfo deviceInfo;
|
||||
quint16 radioSampleRate;
|
||||
quint8 radioSampleBits;
|
||||
QVector<AUDIOPACKET> audioBuffer;
|
||||
QVector<audioPacket> audioBuffer;
|
||||
};
|
||||
|
||||
#endif // AUDIOHANDLER_H
|
||||
|
|
|
@ -63,8 +63,7 @@ void rigCommander::commSetup(unsigned char rigCivAddr, QString rigSerialPort, qu
|
|||
|
||||
}
|
||||
|
||||
void rigCommander::commSetup(unsigned char rigCivAddr, QString ip, quint16 cport, quint16 sport, quint16 aport,
|
||||
QString username, QString password, quint16 rxlatency, quint16 txlatency, quint16 rxsample, quint8 rxcodec, quint16 txsample, quint8 txcodec)
|
||||
void rigCommander::commSetup(unsigned char rigCivAddr, udpPreferences prefs)
|
||||
{
|
||||
// construct
|
||||
// TODO: Bring this parameter and the comm port from the UI.
|
||||
|
@ -88,7 +87,7 @@ void rigCommander::commSetup(unsigned char rigCivAddr, QString ip, quint16 cport
|
|||
*/
|
||||
if (udp == Q_NULLPTR) {
|
||||
|
||||
udp = new udpHandler(ip, cport, sport, aport, username, password, rxlatency, txlatency, rxsample, rxcodec, txsample, txcodec);
|
||||
udp = new udpHandler(prefs);
|
||||
|
||||
udpHandlerThread = new QThread(this);
|
||||
|
||||
|
@ -104,7 +103,7 @@ void rigCommander::commSetup(unsigned char rigCivAddr, QString ip, quint16 cport
|
|||
|
||||
|
||||
connect(udp, SIGNAL(haveDataFromPort(QByteArray)), this, SLOT(handleNewData(QByteArray)));
|
||||
connect(udp, SIGNAL(haveAudioData(AUDIOPACKET)), this, SLOT(receiveAudioData(AUDIOPACKET)));
|
||||
connect(udp, SIGNAL(haveAudioData(audioPacket)), this, SLOT(receiveAudioData(audioPacket)));
|
||||
|
||||
// data from the program to the comm port:
|
||||
connect(this, SIGNAL(dataForComm(QByteArray)), udp, SLOT(receiveDataFromUserToRig(QByteArray)));
|
||||
|
@ -641,7 +640,7 @@ void rigCommander::handleNewData(const QByteArray& data)
|
|||
parseData(data);
|
||||
}
|
||||
|
||||
void rigCommander::receiveAudioData(const AUDIOPACKET& data)
|
||||
void rigCommander::receiveAudioData(const audioPacket& data)
|
||||
{
|
||||
emit haveAudioData(data);
|
||||
}
|
||||
|
|
|
@ -55,8 +55,7 @@ public:
|
|||
public slots:
|
||||
void process();
|
||||
void commSetup(unsigned char rigCivAddr, QString rigSerialPort, quint32 rigBaudRate);
|
||||
void commSetup(unsigned char rigCivAddr, QString ip, quint16 cport, quint16 sport, quint16 aport,
|
||||
QString username, QString password, quint16 rxlatency,quint16 txlatency, quint16 rxsample, quint8 rxcodec,quint16 txsample, quint8 txcodec);
|
||||
void commSetup(unsigned char rigCivAddr, udpPreferences prefs);
|
||||
void closeComm();
|
||||
|
||||
void enableSpectOutput();
|
||||
|
@ -146,7 +145,7 @@ public slots:
|
|||
void setRefAdjustCourse(unsigned char level);
|
||||
void setRefAdjustFine(unsigned char level);
|
||||
void handleNewData(const QByteArray& data);
|
||||
void receiveAudioData(const AUDIOPACKET& data);
|
||||
void receiveAudioData(const audioPacket& data);
|
||||
void handleSerialPortError(const QString port, const QString errorText);
|
||||
void handleStatusUpdate(const QString text);
|
||||
void changeLatency(const quint16 value);
|
||||
|
@ -209,7 +208,7 @@ signals:
|
|||
void haveATUStatus(unsigned char status);
|
||||
void haveChangeLatency(quint16 value);
|
||||
void haveDataForServer(QByteArray outData);
|
||||
void haveAudioData(AUDIOPACKET data);
|
||||
void haveAudioData(audioPacket data);
|
||||
void initUdpHandler();
|
||||
|
||||
private:
|
||||
|
|
|
@ -3,41 +3,38 @@
|
|||
|
||||
#include "udphandler.h"
|
||||
#include "logcategories.h"
|
||||
udpHandler::udpHandler(QString ip, quint16 controlPort, quint16 civPort, quint16 audioPort, QString username, QString password,
|
||||
quint16 rxlatency, quint16 txlatency, quint16 rxsample, quint8 rxcodec, quint16 txsample, quint8 txcodec) :
|
||||
controlPort(controlPort),
|
||||
civPort(civPort),
|
||||
audioPort(audioPort)
|
||||
|
||||
udpHandler::udpHandler(udpPreferences prefs) :
|
||||
controlPort(prefs.controlLANPort)
|
||||
{
|
||||
|
||||
this->port = this->controlPort;
|
||||
this->username = username;
|
||||
this->password = password;
|
||||
this->rxLatency = rxlatency;
|
||||
this->txLatency = txlatency;
|
||||
this->rxSampleRate = rxsample;
|
||||
this->txSampleRate = txsample;
|
||||
this->rxCodec = rxcodec;
|
||||
this->txCodec = txcodec;
|
||||
this->username = prefs.username;
|
||||
this->password = prefs.password;
|
||||
this->rxLatency = prefs.audioRXLatency;
|
||||
this->txLatency = prefs.audioTXLatency;
|
||||
this->rxSampleRate = prefs.audioRXSampleRate;
|
||||
this->txSampleRate = prefs.audioTXSampleRate;
|
||||
this->rxCodec = prefs.audioRXCodec;
|
||||
this->txCodec = prefs.audioTXCodec;
|
||||
|
||||
qDebug(logUdp()) << "Starting udpHandler user:" << username << " rx latency:" << rxLatency << " tx latency:" << txLatency << " rx sample rate: " << rxsample <<
|
||||
" rx codec: " << rxcodec << " tx sample rate: " << txsample << " tx codec: " << txcodec;
|
||||
qDebug(logUdp()) << "Starting udpHandler user:" << username << " rx latency:" << rxLatency << " tx latency:" << txLatency << " rx sample rate: " << rxSampleRate <<
|
||||
" rx codec: " << rxCodec << " tx sample rate: " << txSampleRate << " tx codec: " << txCodec;
|
||||
|
||||
// Try to set the IP address, if it is a hostname then perform a DNS lookup.
|
||||
if (!radioIP.setAddress(ip))
|
||||
if (!radioIP.setAddress(prefs.ipAddress))
|
||||
{
|
||||
QHostInfo remote = QHostInfo::fromName(ip);
|
||||
QHostInfo remote = QHostInfo::fromName(prefs.ipAddress);
|
||||
foreach(QHostAddress addr, remote.addresses())
|
||||
{
|
||||
if (addr.protocol() == QAbstractSocket::IPv4Protocol) {
|
||||
radioIP = addr;
|
||||
qDebug(logUdp()) << "Got IP Address :" << ip << ": " << addr.toString();
|
||||
qDebug(logUdp()) << "Got IP Address :" << prefs.ipAddress << ": " << addr.toString();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (radioIP.isNull())
|
||||
{
|
||||
qDebug(logUdp()) << "Error obtaining IP Address for :" << ip << ": " << remote.errorString();
|
||||
qDebug(logUdp()) << "Error obtaining IP Address for :" << prefs.ipAddress << ": " << remote.errorString();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -121,7 +118,7 @@ void udpHandler::receiveFromCivStream(QByteArray data)
|
|||
emit haveDataFromPort(data);
|
||||
}
|
||||
|
||||
void udpHandler::receiveAudioData(const AUDIOPACKET &data)
|
||||
void udpHandler::receiveAudioData(const audioPacket &data)
|
||||
{
|
||||
emit haveAudioData(data);
|
||||
}
|
||||
|
@ -243,6 +240,10 @@ void udpHandler::dataReceived()
|
|||
streamOpened = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
civPort = qFromBigEndian(in->civport);
|
||||
audioPort = qFromBigEndian(in->audioport);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -300,7 +301,7 @@ void udpHandler::dataReceived()
|
|||
audio = new udpAudio(localIP, radioIP, audioPort, rxLatency, txLatency, rxSampleRate, rxCodec, txSampleRate, txCodec);
|
||||
|
||||
QObject::connect(civ, SIGNAL(receive(QByteArray)), this, SLOT(receiveFromCivStream(QByteArray)));
|
||||
QObject::connect(audio, SIGNAL(haveAudioData(AUDIOPACKET)), this, SLOT(receiveAudioData(AUDIOPACKET)));
|
||||
QObject::connect(audio, SIGNAL(haveAudioData(audioPacket)), this, SLOT(receiveAudioData(audioPacket)));
|
||||
QObject::connect(this, SIGNAL(haveChangeLatency(quint16)), audio, SLOT(changeLatency(quint16)));
|
||||
|
||||
|
||||
|
@ -684,8 +685,8 @@ udpAudio::udpAudio(QHostAddress local, QHostAddress ip, quint16 audioPort, quint
|
|||
|
||||
connect(this, SIGNAL(setupRxAudio(quint8, quint8, quint16, quint16, bool, bool)), rxaudio, SLOT(init(quint8, quint8, quint16, quint16, bool, bool)));
|
||||
|
||||
qRegisterMetaType<AUDIOPACKET>();
|
||||
connect(this, SIGNAL(haveAudioData(AUDIOPACKET)), rxaudio, SLOT(incomingAudio(AUDIOPACKET)));
|
||||
qRegisterMetaType<audioPacket>();
|
||||
connect(this, SIGNAL(haveAudioData(audioPacket)), rxaudio, SLOT(incomingAudio(audioPacket)));
|
||||
connect(this, SIGNAL(haveChangeLatency(quint16)), rxaudio, SLOT(changeLatency(quint16)));
|
||||
connect(rxAudioThread, SIGNAL(finished()), rxaudio, SLOT(deleteLater()));
|
||||
|
||||
|
@ -842,7 +843,7 @@ void udpAudio::dataReceived()
|
|||
r.mid(0, 2) == QByteArrayLiteral("\x70\x04"))
|
||||
{
|
||||
lastReceived = QTime::currentTime();
|
||||
AUDIOPACKET tempAudio;
|
||||
audioPacket tempAudio;
|
||||
tempAudio.seq = in->seq;
|
||||
tempAudio.time = lastReceived;
|
||||
tempAudio.sent = 0;
|
||||
|
|
27
udphandler.h
27
udphandler.h
|
@ -33,7 +33,22 @@
|
|||
#define WATCHDOG_PERIOD 500
|
||||
#define RETRANSMIT_PERIOD 100
|
||||
|
||||
Q_DECLARE_METATYPE(AUDIOPACKET)
|
||||
struct udpPreferences {
|
||||
QString ipAddress;
|
||||
quint16 controlLANPort;
|
||||
quint16 serialLANPort;
|
||||
quint16 audioLANPort;
|
||||
QString username;
|
||||
QString password;
|
||||
QString audioOutput;
|
||||
QString audioInput;
|
||||
quint16 audioRXLatency;
|
||||
quint16 audioTXLatency;
|
||||
quint16 audioRXSampleRate;
|
||||
quint8 audioRXCodec;
|
||||
quint16 audioTXSampleRate;
|
||||
quint8 audioTXCodec;
|
||||
};
|
||||
|
||||
void passcode(QString in, QByteArray& out);
|
||||
QByteArray parseNullTerminatedString(QByteArray c, int s);
|
||||
|
@ -153,7 +168,7 @@ public:
|
|||
~udpAudio();
|
||||
|
||||
signals:
|
||||
void haveAudioData(AUDIOPACKET data);
|
||||
void haveAudioData(audioPacket data);
|
||||
|
||||
void setupTxAudio(const quint8 samples, const quint8 channels, const quint16 samplerate, const quint16 latency, const bool isUlaw, const bool isInput);
|
||||
void setupRxAudio(const quint8 samples, const quint8 channels, const quint16 samplerate, const quint16 latency, const bool isUlaw, const bool isInput);
|
||||
|
@ -204,8 +219,7 @@ class udpHandler: public udpBase
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
udpHandler(QString ip, quint16 cport, quint16 sport, quint16 aport, QString username, QString password,
|
||||
quint16 rxlatency, quint16 txlatency, quint16 rxsample, quint8 rxcodec, quint16 txsample, quint8 txcodec);
|
||||
udpHandler(udpPreferences prefs);
|
||||
~udpHandler();
|
||||
|
||||
bool streamOpened = false;
|
||||
|
@ -217,13 +231,13 @@ public:
|
|||
public slots:
|
||||
void receiveDataFromUserToRig(QByteArray); // This slot will send data on to
|
||||
void receiveFromCivStream(QByteArray);
|
||||
void receiveAudioData(const AUDIOPACKET &data);
|
||||
void receiveAudioData(const audioPacket &data);
|
||||
void changeLatency(quint16 value);
|
||||
void init();
|
||||
|
||||
signals:
|
||||
void haveDataFromPort(QByteArray data); // emit this when we have data, connect to rigcommander
|
||||
void haveAudioData(AUDIOPACKET data); // emit this when we have data, connect to rigcommander
|
||||
void haveAudioData(audioPacket data); // emit this when we have data, connect to rigcommander
|
||||
void haveNetworkError(QString, QString);
|
||||
void haveNetworkStatus(QString);
|
||||
void haveChangeLatency(quint16 value);
|
||||
|
@ -278,5 +292,6 @@ private:
|
|||
bool highBandwidthConnection = false;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(struct audioPacket)
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1054,7 +1054,7 @@ void udpServer::dataForServer(QByteArray d)
|
|||
return;
|
||||
}
|
||||
|
||||
void udpServer::receiveAudioData(const AUDIOPACKET &d)
|
||||
void udpServer::receiveAudioData(const audioPacket &d)
|
||||
{
|
||||
//qDebug(logUdpServer()) << "Server got:" << d.data.length();
|
||||
foreach(CLIENT * client, audioClients)
|
||||
|
|
|
@ -44,7 +44,7 @@ public:
|
|||
public slots:
|
||||
void init();
|
||||
void dataForServer(QByteArray);
|
||||
void receiveAudioData(const AUDIOPACKET &data);
|
||||
void receiveAudioData(const audioPacket &data);
|
||||
void receiveRigCaps(rigCapabilities caps);
|
||||
|
||||
signals:
|
||||
|
|
152
wfmain.cpp
152
wfmain.cpp
|
@ -31,6 +31,7 @@ wfmain::wfmain(const QString serialPortCL, const QString hostCL, QWidget *parent
|
|||
connect(this, SIGNAL(sendServerConfig(SERVERCONFIG)), srv, SLOT(receiveServerConfig(SERVERCONFIG)));
|
||||
connect(srv, SIGNAL(serverConfig(SERVERCONFIG, bool)), this, SLOT(serverConfigRequested(SERVERCONFIG, bool)));
|
||||
|
||||
qRegisterMetaType<udpPreferences>(); // Needs to be registered early.
|
||||
|
||||
haveRigCaps = false;
|
||||
|
||||
|
@ -420,7 +421,7 @@ wfmain::wfmain(const QString serialPortCL, const QString hostCL, QWidget *parent
|
|||
|
||||
if (serverConfig.enabled && udp != Q_NULLPTR) {
|
||||
// Server
|
||||
connect(rig, SIGNAL(haveAudioData(AUDIOPACKET)), udp, SLOT(receiveAudioData(AUDIOPACKET)));
|
||||
connect(rig, SIGNAL(haveAudioData(audioPacket)), udp, SLOT(receiveAudioData(audioPacket)));
|
||||
connect(rig, SIGNAL(haveDataForServer(QByteArray)), udp, SLOT(dataForServer(QByteArray)));
|
||||
connect(udp, SIGNAL(haveDataFromServer(QByteArray)), rig, SLOT(dataFromServer(QByteArray)));
|
||||
}
|
||||
|
@ -455,8 +456,6 @@ wfmain::wfmain(const QString serialPortCL, const QString hostCL, QWidget *parent
|
|||
|
||||
|
||||
ui->freqMhzLineEdit->setValidator( new QDoubleValidator(0, 100, 6, this));
|
||||
ui->audioPortTxt->setValidator(new QIntValidator(this));
|
||||
ui->serialPortTxt->setValidator(new QIntValidator(this));
|
||||
ui->controlPortTxt->setValidator(new QIntValidator(this));
|
||||
|
||||
pttTimer = new QTimer(this);
|
||||
|
@ -560,7 +559,7 @@ void wfmain::openRig()
|
|||
connect(rig, SIGNAL(haveSerialPortError(QString, QString)), this, SLOT(receiveSerialPortError(QString, QString)));
|
||||
connect(rig, SIGNAL(haveStatusUpdate(QString)), this, SLOT(receiveStatusUpdate(QString)));
|
||||
|
||||
connect(this, SIGNAL(sendCommSetup(unsigned char, QString, quint16, quint16, quint16, QString, QString,quint16,quint16,quint16,quint8,quint16,quint8)), rig, SLOT(commSetup(unsigned char, QString, quint16, quint16, quint16, QString, QString,quint16,quint16,quint16,quint8,quint16,quint8)));
|
||||
connect(this, SIGNAL(sendCommSetup(unsigned char, udpPreferences)), rig, SLOT(commSetup(unsigned char, udpPreferences)));
|
||||
connect(this, SIGNAL(sendCommSetup(unsigned char, QString, quint32)), rig, SLOT(commSetup(unsigned char, QString, quint32)));
|
||||
|
||||
connect(this, SIGNAL(sendCloseComm()), rig, SLOT(closeComm()));
|
||||
|
@ -572,8 +571,7 @@ void wfmain::openRig()
|
|||
|
||||
if (prefs.enableLAN)
|
||||
{
|
||||
emit sendCommSetup(prefs.radioCIVAddr, prefs.ipAddress, prefs.controlLANPort,
|
||||
prefs.serialLANPort, prefs.audioLANPort, prefs.username, prefs.password,prefs.audioRXLatency,prefs.audioTXLatency,prefs.audioRXSampleRate,prefs.audioRXCodec,prefs.audioTXSampleRate,prefs.audioTXCodec);
|
||||
emit sendCommSetup(prefs.radioCIVAddr, udpPrefs);
|
||||
} else {
|
||||
|
||||
if( (prefs.serialPortRadio == QString("auto")) && (serialPortCL.isEmpty()))
|
||||
|
@ -717,21 +715,20 @@ void wfmain::setDefPrefs()
|
|||
defPrefs.enablePTT = false;
|
||||
defPrefs.niceTS = true;
|
||||
|
||||
defPrefs.enableLAN = false;
|
||||
defPrefs.ipAddress = QString("");
|
||||
defPrefs.controlLANPort = 50001;
|
||||
defPrefs.serialLANPort = 50002;
|
||||
defPrefs.audioLANPort = 50003;
|
||||
defPrefs.username = QString("");
|
||||
defPrefs.password = QString("");
|
||||
defPrefs.audioOutput = QAudioDeviceInfo::defaultOutputDevice().deviceName();
|
||||
defPrefs.audioInput = QAudioDeviceInfo::defaultInputDevice().deviceName();
|
||||
defPrefs.audioRXLatency = 150;
|
||||
defPrefs.audioTXLatency = 150;
|
||||
defPrefs.audioRXSampleRate = 48000;
|
||||
defPrefs.audioRXCodec = 4;
|
||||
defPrefs.audioTXSampleRate = 48000;
|
||||
defPrefs.audioTXCodec = 4;
|
||||
udpDefPrefs.ipAddress = QString("");
|
||||
udpDefPrefs.controlLANPort = 50001;
|
||||
udpDefPrefs.serialLANPort = 50002;
|
||||
udpDefPrefs.audioLANPort = 50003;
|
||||
udpDefPrefs.username = QString("");
|
||||
udpDefPrefs.password = QString("");
|
||||
udpDefPrefs.audioOutput = QAudioDeviceInfo::defaultOutputDevice().deviceName();
|
||||
udpDefPrefs.audioInput = QAudioDeviceInfo::defaultInputDevice().deviceName();
|
||||
udpDefPrefs.audioRXLatency = 150;
|
||||
udpDefPrefs.audioTXLatency = 150;
|
||||
udpDefPrefs.audioRXSampleRate = 48000;
|
||||
udpDefPrefs.audioRXCodec = 4;
|
||||
udpDefPrefs.audioTXSampleRate = 48000;
|
||||
udpDefPrefs.audioTXCodec = 4;
|
||||
|
||||
|
||||
}
|
||||
|
@ -770,47 +767,40 @@ void wfmain::loadSettings()
|
|||
settings.endGroup();
|
||||
|
||||
settings.beginGroup("LAN");
|
||||
|
||||
prefs.enableLAN = settings.value("EnableLAN", defPrefs.enableLAN).toBool();
|
||||
ui->lanEnableChk->setChecked(prefs.enableLAN);
|
||||
|
||||
prefs.ipAddress = settings.value("IPAddress", defPrefs.ipAddress).toString();
|
||||
udpPrefs.ipAddress = settings.value("IPAddress", udpDefPrefs.ipAddress).toString();
|
||||
ui->ipAddressTxt->setEnabled(ui->lanEnableChk->isChecked());
|
||||
ui->ipAddressTxt->setText(prefs.ipAddress);
|
||||
ui->ipAddressTxt->setText(udpPrefs.ipAddress);
|
||||
|
||||
prefs.controlLANPort = settings.value("ControlLANPort", defPrefs.controlLANPort).toInt();
|
||||
udpPrefs.controlLANPort = settings.value("ControlLANPort", udpDefPrefs.controlLANPort).toInt();
|
||||
ui->controlPortTxt->setEnabled(ui->lanEnableChk->isChecked());
|
||||
ui->controlPortTxt->setText(QString("%1").arg(prefs.controlLANPort));
|
||||
ui->controlPortTxt->setText(QString("%1").arg(udpPrefs.controlLANPort));
|
||||
|
||||
prefs.serialLANPort = settings.value("SerialLANPort", defPrefs.serialLANPort).toInt();
|
||||
ui->serialPortTxt->setEnabled(ui->lanEnableChk->isChecked());
|
||||
ui->serialPortTxt->setText(QString("%1").arg(prefs.serialLANPort));
|
||||
|
||||
prefs.audioLANPort = settings.value("AudioLANPort", defPrefs.audioLANPort).toInt();
|
||||
ui->audioPortTxt->setEnabled(ui->lanEnableChk->isChecked());
|
||||
ui->audioPortTxt->setText(QString("%1").arg(prefs.audioLANPort));
|
||||
|
||||
prefs.username = settings.value("Username", defPrefs.username).toString();
|
||||
udpPrefs.username = settings.value("Username", udpDefPrefs.username).toString();
|
||||
ui->usernameTxt->setEnabled(ui->lanEnableChk->isChecked());
|
||||
ui->usernameTxt->setText(QString("%1").arg(prefs.username));
|
||||
ui->usernameTxt->setText(QString("%1").arg(udpPrefs.username));
|
||||
|
||||
prefs.password = settings.value("Password", defPrefs.password).toString();
|
||||
udpPrefs.password = settings.value("Password", udpDefPrefs.password).toString();
|
||||
ui->passwordTxt->setEnabled(ui->lanEnableChk->isChecked());
|
||||
ui->passwordTxt->setText(QString("%1").arg(prefs.password));
|
||||
ui->passwordTxt->setText(QString("%1").arg(udpPrefs.password));
|
||||
|
||||
prefs.audioRXLatency = settings.value("AudioRXLatency", defPrefs.audioRXLatency).toInt();
|
||||
udpPrefs.audioRXLatency = settings.value("AudioRXLatency", udpDefPrefs.audioRXLatency).toInt();
|
||||
ui->rxLatencySlider->setEnabled(ui->lanEnableChk->isChecked());
|
||||
ui->rxLatencySlider->setValue(prefs.audioRXLatency);
|
||||
ui->rxLatencySlider->setValue(udpPrefs.audioRXLatency);
|
||||
ui->rxLatencySlider->setTracking(false); // Stop it sending value on every change.
|
||||
|
||||
prefs.audioTXLatency = settings.value("AudioTXLatency", defPrefs.audioTXLatency).toInt();
|
||||
udpPrefs.audioTXLatency = settings.value("AudioTXLatency", udpDefPrefs.audioTXLatency).toInt();
|
||||
ui->txLatencySlider->setEnabled(ui->lanEnableChk->isChecked());
|
||||
ui->txLatencySlider->setValue(prefs.audioTXLatency);
|
||||
ui->txLatencySlider->setValue(udpPrefs.audioTXLatency);
|
||||
ui->txLatencySlider->setTracking(false); // Stop it sending value on every change.
|
||||
|
||||
prefs.audioRXSampleRate = settings.value("AudioRXSampleRate", defPrefs.audioRXSampleRate).toInt();
|
||||
prefs.audioTXSampleRate = settings.value("AudioTXSampleRate", defPrefs.audioTXSampleRate).toInt();
|
||||
udpPrefs.audioRXSampleRate = settings.value("AudioRXSampleRate", udpDefPrefs.audioRXSampleRate).toInt();
|
||||
udpPrefs.audioTXSampleRate = settings.value("AudioTXSampleRate",udpDefPrefs.audioTXSampleRate).toInt();
|
||||
ui->audioSampleRateCombo->setEnabled(ui->lanEnableChk->isChecked());
|
||||
int audioSampleRateIndex = ui->audioSampleRateCombo->findText(QString::number(prefs.audioRXSampleRate));
|
||||
int audioSampleRateIndex = ui->audioSampleRateCombo->findText(QString::number(udpDefPrefs.audioRXSampleRate));
|
||||
if (audioSampleRateIndex != -1) {
|
||||
ui->audioOutputCombo->setCurrentIndex(audioSampleRateIndex);
|
||||
}
|
||||
|
@ -823,31 +813,31 @@ void wfmain::loadSettings()
|
|||
ui->audioRXCodecCombo->addItem("uLaw 2ch 8bit", 32);
|
||||
ui->audioRXCodecCombo->addItem("PCM 2ch 8bit", 8);
|
||||
|
||||
prefs.audioRXCodec = settings.value("AudioRXCodec", defPrefs.audioRXCodec).toInt();
|
||||
udpPrefs.audioRXCodec = settings.value("AudioRXCodec", udpDefPrefs.audioRXCodec).toInt();
|
||||
ui->audioRXCodecCombo->setEnabled(ui->lanEnableChk->isChecked());
|
||||
for (int f = 0; f < ui->audioRXCodecCombo->count(); f++)
|
||||
if (ui->audioRXCodecCombo->itemData(f).toInt() == prefs.audioRXCodec)
|
||||
if (ui->audioRXCodecCombo->itemData(f).toInt() == udpPrefs.audioRXCodec)
|
||||
ui->audioRXCodecCombo->setCurrentIndex(f);
|
||||
|
||||
ui->audioTXCodecCombo->addItem("LPCM 1ch 16bit", 4);
|
||||
ui->audioTXCodecCombo->addItem("LPCM 1ch 8bit", 2);
|
||||
ui->audioTXCodecCombo->addItem("uLaw 1ch 8bit", 1);
|
||||
|
||||
prefs.audioTXCodec = settings.value("AudioTXCodec", defPrefs.audioTXCodec).toInt();
|
||||
udpPrefs.audioTXCodec = settings.value("AudioTXCodec", udpDefPrefs.audioTXCodec).toInt();
|
||||
ui->audioTXCodecCombo->setEnabled(ui->lanEnableChk->isChecked());
|
||||
for (int f = 0; f < ui->audioTXCodecCombo->count(); f++)
|
||||
if (ui->audioTXCodecCombo->itemData(f).toInt() == prefs.audioTXCodec)
|
||||
if (ui->audioTXCodecCombo->itemData(f).toInt() == udpPrefs.audioTXCodec)
|
||||
ui->audioTXCodecCombo->setCurrentIndex(f);
|
||||
|
||||
prefs.audioOutput = settings.value("AudioOutput", defPrefs.audioOutput).toString();
|
||||
udpPrefs.audioOutput = settings.value("AudioOutput", udpDefPrefs.audioOutput).toString();
|
||||
ui->audioOutputCombo->setEnabled(ui->lanEnableChk->isChecked());
|
||||
int audioOutputIndex = ui->audioOutputCombo->findText(prefs.audioOutput);
|
||||
int audioOutputIndex = ui->audioOutputCombo->findText(udpPrefs.audioOutput);
|
||||
if (audioOutputIndex != -1)
|
||||
ui->audioOutputCombo->setCurrentIndex(audioOutputIndex);
|
||||
|
||||
prefs.audioInput = settings.value("AudioInput", defPrefs.audioInput).toString();
|
||||
udpPrefs.audioInput = settings.value("AudioInput", udpDefPrefs.audioInput).toString();
|
||||
ui->audioInputCombo->setEnabled(ui->lanEnableChk->isChecked());
|
||||
int audioInputIndex = ui->audioInputCombo->findText(prefs.audioInput);
|
||||
int audioInputIndex = ui->audioInputCombo->findText(udpPrefs.audioInput);
|
||||
if (audioInputIndex != - 1)
|
||||
ui->audioOutputCombo->setCurrentIndex(audioInputIndex);
|
||||
|
||||
|
@ -944,20 +934,20 @@ void wfmain::saveSettings()
|
|||
|
||||
settings.beginGroup("LAN");
|
||||
settings.setValue("EnableLAN", prefs.enableLAN);
|
||||
settings.setValue("IPAddress", prefs.ipAddress);
|
||||
settings.setValue("ControlLANPort", prefs.controlLANPort);
|
||||
settings.setValue("SerialLANPort", prefs.serialLANPort);
|
||||
settings.setValue("AudioLANPort", prefs.audioLANPort);
|
||||
settings.setValue("Username", prefs.username);
|
||||
settings.setValue("Password", prefs.password);
|
||||
settings.setValue("AudioRXLatency", prefs.audioRXLatency);
|
||||
settings.setValue("AudioTXLatency", prefs.audioTXLatency);
|
||||
settings.setValue("AudioRXSampleRate", prefs.audioRXSampleRate);
|
||||
settings.setValue("AudioRXCodec", prefs.audioRXCodec);
|
||||
settings.setValue("AudioTXSampleRate", prefs.audioRXSampleRate);
|
||||
settings.setValue("AudioTXCodec", prefs.audioTXCodec);
|
||||
settings.setValue("AudioOutput", prefs.audioOutput);
|
||||
settings.setValue("AudioInput", prefs.audioInput);
|
||||
settings.setValue("IPAddress", udpPrefs.ipAddress);
|
||||
settings.setValue("ControlLANPort", udpPrefs.controlLANPort);
|
||||
settings.setValue("SerialLANPort", udpPrefs.serialLANPort);
|
||||
settings.setValue("AudioLANPort", udpPrefs.audioLANPort);
|
||||
settings.setValue("Username", udpPrefs.username);
|
||||
settings.setValue("Password", udpPrefs.password);
|
||||
settings.setValue("AudioRXLatency", udpPrefs.audioRXLatency);
|
||||
settings.setValue("AudioTXLatency", udpPrefs.audioTXLatency);
|
||||
settings.setValue("AudioRXSampleRate", udpPrefs.audioRXSampleRate);
|
||||
settings.setValue("AudioRXCodec", udpPrefs.audioRXCodec);
|
||||
settings.setValue("AudioTXSampleRate", udpPrefs.audioRXSampleRate);
|
||||
settings.setValue("AudioTXCodec", udpPrefs.audioTXCodec);
|
||||
settings.setValue("AudioOutput", udpPrefs.audioOutput);
|
||||
settings.setValue("AudioInput", udpPrefs.audioInput);
|
||||
settings.endGroup();
|
||||
|
||||
// Memory channels
|
||||
|
@ -2868,8 +2858,6 @@ void wfmain::on_lanEnableChk_clicked(bool checked)
|
|||
prefs.enableLAN = checked;
|
||||
ui->ipAddressTxt->setEnabled(checked);
|
||||
ui->controlPortTxt->setEnabled(checked);
|
||||
ui->serialPortTxt->setEnabled(checked);
|
||||
ui->audioPortTxt->setEnabled(checked);
|
||||
ui->usernameTxt->setEnabled(checked);
|
||||
ui->passwordTxt->setEnabled(checked);
|
||||
if(checked)
|
||||
|
@ -2880,70 +2868,70 @@ void wfmain::on_lanEnableChk_clicked(bool checked)
|
|||
|
||||
void wfmain::on_ipAddressTxt_textChanged(QString text)
|
||||
{
|
||||
prefs.ipAddress = text;
|
||||
udpPrefs.ipAddress = text;
|
||||
}
|
||||
|
||||
void wfmain::on_controlPortTxt_textChanged(QString text)
|
||||
{
|
||||
prefs.controlLANPort = text.toUInt();
|
||||
udpPrefs.controlLANPort = text.toUInt();
|
||||
}
|
||||
|
||||
void wfmain::on_serialPortTxt_textChanged(QString text)
|
||||
{
|
||||
prefs.serialLANPort = text.toUInt();
|
||||
udpPrefs.serialLANPort = text.toUInt();
|
||||
}
|
||||
|
||||
void wfmain::on_audioPortTxt_textChanged(QString text)
|
||||
{
|
||||
prefs.audioLANPort = text.toUInt();
|
||||
udpPrefs.audioLANPort = text.toUInt();
|
||||
}
|
||||
|
||||
void wfmain::on_usernameTxt_textChanged(QString text)
|
||||
{
|
||||
prefs.username = text;
|
||||
udpPrefs.username = text;
|
||||
}
|
||||
|
||||
void wfmain::on_passwordTxt_textChanged(QString text)
|
||||
{
|
||||
prefs.password = text;
|
||||
udpPrefs.password = text;
|
||||
}
|
||||
|
||||
void wfmain::on_audioOutputCombo_currentIndexChanged(QString text)
|
||||
{
|
||||
prefs.audioOutput = text;
|
||||
udpPrefs.audioOutput = text;
|
||||
}
|
||||
|
||||
void wfmain::on_audioInputCombo_currentIndexChanged(QString text)
|
||||
{
|
||||
prefs.audioInput = text;
|
||||
udpPrefs.audioInput = text;
|
||||
}
|
||||
|
||||
void wfmain::on_audioSampleRateCombo_currentIndexChanged(QString text)
|
||||
{
|
||||
prefs.audioRXSampleRate = text.toInt();
|
||||
prefs.audioTXSampleRate = text.toInt();
|
||||
udpPrefs.audioRXSampleRate = text.toInt();
|
||||
udpPrefs.audioTXSampleRate = text.toInt();
|
||||
}
|
||||
|
||||
void wfmain::on_audioRXCodecCombo_currentIndexChanged(int value)
|
||||
{
|
||||
prefs.audioRXCodec = ui->audioRXCodecCombo->itemData(value).toInt();
|
||||
udpPrefs.audioRXCodec = ui->audioRXCodecCombo->itemData(value).toInt();
|
||||
}
|
||||
|
||||
void wfmain::on_audioTXCodecCombo_currentIndexChanged(int value)
|
||||
{
|
||||
prefs.audioTXCodec = ui->audioTXCodecCombo->itemData(value).toInt();
|
||||
udpPrefs.audioTXCodec = ui->audioTXCodecCombo->itemData(value).toInt();
|
||||
}
|
||||
|
||||
void wfmain::on_rxLatencySlider_valueChanged(int value)
|
||||
{
|
||||
prefs.audioRXLatency = value;
|
||||
udpPrefs.audioRXLatency = value;
|
||||
ui->rxLatencyValue->setText(QString::number(value));
|
||||
emit sendChangeLatency(value);
|
||||
}
|
||||
|
||||
void wfmain::on_txLatencySlider_valueChanged(int value)
|
||||
{
|
||||
prefs.audioTXLatency = value;
|
||||
udpPrefs.audioTXLatency = value;
|
||||
ui->txLatencyValue->setText(QString::number(value));
|
||||
}
|
||||
|
||||
|
|
20
wfmain.h
20
wfmain.h
|
@ -108,8 +108,7 @@ signals:
|
|||
void sayMode();
|
||||
void sayAll();
|
||||
void sendCommSetup(unsigned char rigCivAddr, QString rigSerialPort, quint32 rigBaudRate);
|
||||
void sendCommSetup(unsigned char rigCivAddr, QString ip, quint16 cport, quint16 sport, quint16 aport,
|
||||
QString username, QString password, quint16 rxlatency, quint16 txlatency, quint16 rxsample, quint8 rxcodec, quint16 txsample, quint8 txcodec);
|
||||
void sendCommSetup(unsigned char rigCivAddr, udpPreferences prefs);
|
||||
void sendCloseComm();
|
||||
void sendChangeLatency(quint16 latency);
|
||||
void initServer();
|
||||
|
@ -525,23 +524,11 @@ private:
|
|||
bool enablePTT;
|
||||
bool niceTS;
|
||||
bool enableLAN;
|
||||
QString ipAddress;
|
||||
quint16 controlLANPort;
|
||||
quint16 serialLANPort;
|
||||
quint16 audioLANPort;
|
||||
QString username;
|
||||
QString password;
|
||||
QString audioOutput;
|
||||
QString audioInput;
|
||||
quint16 audioRXLatency;
|
||||
quint16 audioTXLatency;
|
||||
quint16 audioRXSampleRate;
|
||||
quint8 audioRXCodec;
|
||||
quint16 audioTXSampleRate;
|
||||
quint8 audioTXCodec;
|
||||
} prefs;
|
||||
|
||||
preferences defPrefs;
|
||||
udpPreferences udpPrefs;
|
||||
udpPreferences udpDefPrefs;
|
||||
colors defaultColors;
|
||||
|
||||
void setDefaultColors(); // populate with default values
|
||||
|
@ -617,6 +604,7 @@ private:
|
|||
};
|
||||
|
||||
Q_DECLARE_METATYPE(struct rigCapabilities)
|
||||
Q_DECLARE_METATYPE(struct udpPreferences)
|
||||
Q_DECLARE_METATYPE(enum rigInput)
|
||||
Q_DECLARE_METATYPE(enum duplexMode)
|
||||
Q_DECLARE_METATYPE(enum meterKind)
|
||||
|
|
32
wfmain.ui
32
wfmain.ui
|
@ -18,7 +18,7 @@
|
|||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>3</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="mainTab">
|
||||
<attribute name="title">
|
||||
|
@ -1721,34 +1721,6 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="text">
|
||||
<string>Radio Serial Port</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="serialPortTxt">
|
||||
<property name="placeholderText">
|
||||
<string>50002</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_12">
|
||||
<property name="text">
|
||||
<string>Radio Audio Port</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="audioPortTxt">
|
||||
<property name="placeholderText">
|
||||
<string>50003</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
@ -2000,7 +1972,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>810</width>
|
||||
<height>22</height>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
|
|
Ładowanie…
Reference in New Issue