kopia lustrzana https://gitlab.com/eliggett/wfview
Fix some compile warnings and try to support sharing lan connected rigs
rodzic
bf5f819927
commit
8b958d572c
|
@ -1135,7 +1135,7 @@ void udpAudio::dataReceived()
|
|||
|
||||
void udpBase::init(quint16 lport)
|
||||
{
|
||||
timeStarted.start();
|
||||
//timeStarted.start();
|
||||
udp = new QUdpSocket(this);
|
||||
udp->bind(lport); // Bind to random port.
|
||||
localPort = udp->localPort();
|
||||
|
@ -1517,7 +1517,8 @@ void udpBase::sendPing()
|
|||
p.sentid = myId;
|
||||
p.rcvdid = remoteId;
|
||||
p.seq = pingSendSeq;
|
||||
p.time = timeStarted.msecsSinceStartOfDay();
|
||||
QTime now=QTime::currentTime();
|
||||
p.time = (quint32)now.msecsSinceStartOfDay();
|
||||
lastPingSentTime = QDateTime::currentDateTime();
|
||||
udpMutex.lock();
|
||||
udp->writeDatagram(QByteArray::fromRawData((const char*)p.packet, sizeof(p)), radioIP, port);
|
||||
|
|
|
@ -80,7 +80,7 @@ public:
|
|||
void printHex(const QByteArray& pdata, bool printVert, bool printHoriz);
|
||||
|
||||
|
||||
QTime timeStarted;
|
||||
//QTime timeStarted;
|
||||
|
||||
QUdpSocket* udp=Q_NULLPTR;
|
||||
uint32_t myId = 0;
|
||||
|
|
|
@ -39,7 +39,7 @@ void udpServer::init()
|
|||
;
|
||||
}
|
||||
srand(time(NULL)); // Generate random
|
||||
timeStarted.start();
|
||||
//timeStarted.start();
|
||||
// Convoluted way to find the external IP address, there must be a better way????
|
||||
QString localhostname = QHostInfo::localHostName();
|
||||
QList<QHostAddress> hostList = QHostInfo::fromName(localhostname).addresses();
|
||||
|
@ -357,7 +357,7 @@ void udpServer::controlReceived()
|
|||
audioSetup setup;
|
||||
setup.resampleQuality = config->resampleQuality;
|
||||
for (RIGCONFIG* radio : config->rigs) {
|
||||
if ((!memcmp(radio->guid, current->guid, GUIDLEN) || config->rigs.size()==1) && radio->txaudio == Q_NULLPTR )
|
||||
if ((!memcmp(radio->guid, current->guid, GUIDLEN) || config->rigs.size()==1) && radio->txaudio == Q_NULLPTR && !config->lan)
|
||||
{
|
||||
radio->txAudioSetup.codec = current->txCodec;
|
||||
radio->txAudioSetup.format.setSampleRate(current->txSampleRate);
|
||||
|
@ -392,7 +392,7 @@ void udpServer::controlReceived()
|
|||
connect(this, SIGNAL(haveAudioData(audioPacket)), radio->txaudio, SLOT(incomingAudio(audioPacket)));
|
||||
|
||||
}
|
||||
if ((!memcmp(radio->guid, current->guid, GUIDLEN) || config->rigs.size() == 1) && radio->rxaudio == Q_NULLPTR)
|
||||
if ((!memcmp(radio->guid, current->guid, GUIDLEN) || config->rigs.size() == 1) && radio->rxaudio == Q_NULLPTR && !config->lan)
|
||||
{
|
||||
#if !defined(PORTAUDIO) && !defined(RTAUDIO)
|
||||
qInfo(logUdpServer()) << "Radio" << radio->rigName << "audio input(RX) :" << radio->rxAudioSetup.port.deviceName();
|
||||
|
@ -1072,7 +1072,8 @@ void udpServer::sendPing(QList<CLIENT*>* l, CLIENT* c, quint16 seq, bool reply)
|
|||
pingTime = c->rxPingTime;
|
||||
}
|
||||
else {
|
||||
pingTime = (quint32)timeStarted.msecsSinceStartOfDay();
|
||||
QTime now=QTime::currentTime();
|
||||
pingTime = (quint32)now.msecsSinceStartOfDay();
|
||||
seq = c->pingSeq;
|
||||
// Don't increment pingseq until we receive a reply.
|
||||
}
|
||||
|
|
|
@ -217,7 +217,7 @@ private:
|
|||
QList <CLIENT*> civClients = QList<CLIENT*>();
|
||||
QList <CLIENT*> audioClients = QList<CLIENT*>();
|
||||
|
||||
QTime timeStarted;
|
||||
//QTime timeStarted;
|
||||
|
||||
|
||||
audioSetup outAudio;
|
||||
|
@ -235,4 +235,4 @@ private:
|
|||
};
|
||||
|
||||
|
||||
#endif // UDPSERVER_H
|
||||
#endif // UDPSERVER_H
|
||||
|
|
37
wfmain.cpp
37
wfmain.cpp
|
@ -79,12 +79,7 @@ wfmain::wfmain(const QString serialPortCL, const QString hostCL, const QString s
|
|||
qDebug(logSystem()) << "Running rigConnections()";
|
||||
rigConnections();
|
||||
|
||||
/* if (serverConfig.enabled && udp != Q_NULLPTR) {
|
||||
// Server
|
||||
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)));
|
||||
} */
|
||||
|
||||
|
||||
setServerToPrefs();
|
||||
|
||||
|
@ -997,8 +992,7 @@ void wfmain::setServerToPrefs()
|
|||
|
||||
if (serverConfig.enabled) {
|
||||
serverConfig.lan = prefs.enableLAN;
|
||||
qInfo(logAudio()) << "Audio Input device " << serverConfig.rigs.first()->rxAudioSetup.name;
|
||||
qInfo(logAudio()) << "Audio Output device " << serverConfig.rigs.first()->txAudioSetup.name;
|
||||
|
||||
udp = new udpServer(&serverConfig);
|
||||
|
||||
serverThread = new QThread(this);
|
||||
|
@ -1011,12 +1005,17 @@ void wfmain::setServerToPrefs()
|
|||
|
||||
if (rig != Q_NULLPTR) {
|
||||
connect(rig, SIGNAL(haveAudioData(audioPacket)), udp, SLOT(receiveAudioData(audioPacket)));
|
||||
// Need to add a signal/slot for audio from the client to rig.
|
||||
//connect(udp, SIGNAL(haveAudioData(audioPacket)), rig, SLOT(receiveAudioData(audioPacket)));
|
||||
connect(rig, SIGNAL(haveDataForServer(QByteArray)), udp, SLOT(dataForServer(QByteArray)));
|
||||
connect(udp, SIGNAL(haveDataFromServer(QByteArray)), rig, SLOT(dataFromServer(QByteArray)));
|
||||
}
|
||||
|
||||
if (!prefs.enableLAN) {
|
||||
if (serverConfig.lan) {
|
||||
connect(udp, SIGNAL(haveNetworkStatus(networkStatus)), this, SLOT(receiveStatusUpdate(networkStatus)));
|
||||
} else {
|
||||
qInfo(logAudio()) << "Audio Input device " << serverConfig.rigs.first()->rxAudioSetup.name;
|
||||
qInfo(logAudio()) << "Audio Output device " << serverConfig.rigs.first()->txAudioSetup.name;
|
||||
}
|
||||
|
||||
serverThread->start();
|
||||
|
@ -1435,15 +1434,13 @@ void wfmain::loadSettings()
|
|||
settings->beginGroup("LAN");
|
||||
|
||||
prefs.enableLAN = settings->value("EnableLAN", defPrefs.enableLAN).toBool();
|
||||
if (prefs.enableLAN)
|
||||
{
|
||||
ui->baudRateCombo->setEnabled(false);
|
||||
ui->serialDeviceListCombo->setEnabled(false);
|
||||
}
|
||||
else {
|
||||
ui->baudRateCombo->setEnabled(true);
|
||||
ui->serialDeviceListCombo->setEnabled(true);
|
||||
}
|
||||
|
||||
// If LAN is enabled, server gets its audio straight from the LAN
|
||||
ui->serverRXAudioInputCombo->setEnabled(!prefs.enableLAN);
|
||||
ui->serverTXAudioOutputCombo->setEnabled(!prefs.enableLAN);
|
||||
|
||||
ui->baudRateCombo->setEnabled(!prefs.enableLAN);
|
||||
ui->serialDeviceListCombo->setEnabled(!prefs.enableLAN);
|
||||
|
||||
ui->lanEnableBtn->setChecked(prefs.enableLAN);
|
||||
ui->connectBtn->setEnabled(true);
|
||||
|
@ -4572,6 +4569,8 @@ void wfmain::on_serialEnableBtn_clicked(bool checked)
|
|||
ui->audioInputCombo->setEnabled(!checked);
|
||||
ui->baudRateCombo->setEnabled(checked);
|
||||
ui->serialDeviceListCombo->setEnabled(checked);
|
||||
ui->serverRXAudioInputCombo->setEnabled(checked);
|
||||
ui->serverTXAudioOutputCombo->setEnabled(checked);
|
||||
}
|
||||
|
||||
void wfmain::on_lanEnableBtn_clicked(bool checked)
|
||||
|
@ -4593,6 +4592,8 @@ void wfmain::on_lanEnableBtn_clicked(bool checked)
|
|||
ui->audioInputCombo->setEnabled(checked);
|
||||
ui->baudRateCombo->setEnabled(!checked);
|
||||
ui->serialDeviceListCombo->setEnabled(!checked);
|
||||
ui->serverRXAudioInputCombo->setEnabled(!checked);
|
||||
ui->serverTXAudioOutputCombo->setEnabled(!checked);
|
||||
if(checked)
|
||||
{
|
||||
showStatusBarText("After filling in values, press Save Settings.");
|
||||
|
|
Ładowanie…
Reference in New Issue