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