From c5c0046e3a3708b9e7ba54d3f29d1e0cd137fd33 Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Sun, 15 Aug 2021 11:19:34 +0100 Subject: [PATCH] Improve detection of unsupported codec. --- udphandler.cpp | 44 ++++++++++++++++++++++++++------------------ udphandler.h | 2 +- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/udphandler.cpp b/udphandler.cpp index 88ce282..fd25042 100644 --- a/udphandler.cpp +++ b/udphandler.cpp @@ -4,7 +4,7 @@ #include "udphandler.h" #include "logcategories.h" -udpHandler::udpHandler(udpPreferences prefs,audioSetup rx, audioSetup tx) : +udpHandler::udpHandler(udpPreferences prefs, audioSetup rx, audioSetup tx) : controlPort(prefs.controlLANPort), civPort(0), audioPort(0), @@ -237,10 +237,10 @@ void udpHandler::dataReceived() { status_packet_t in = (status_packet_t)r.constData(); if (in->type != 0x01) { - if (in->error == 0x00ffffff && !streamOpened) + if (in->error == 0xffffffff && !streamOpened) { - emit haveNetworkError(radioIP.toString(), "Auth failed, try rebooting the radio."); - qInfo(logUdp()) << this->metaObject()->className() << ": Auth failed, try rebooting the radio."; + emit haveNetworkError(radioIP.toString(), "Connection failed, wait a few minutes or reboot the radio."); + qInfo(logUdp()) << this->metaObject()->className() << ": Connection failed, wait a few minutes or reboot the radio."; } else if (in->error == 0x00000000 && in->disc == 0x01) { @@ -272,6 +272,27 @@ void udpHandler::dataReceived() { login_response_packet_t in = (login_response_packet_t)r.constData(); if (in->type != 0x01) { + + connectionType = in->connection; + qInfo(logUdp()) << "Got connection type:" << connectionType; + if (connectionType == "FTTH") + { + highBandwidthConnection = true; + } + + if (connectionType != "WFVIEW") // NOT WFVIEW + { + if (rxSetup.codec >= 0x40 || txSetup.codec >= 0x40) + { + emit haveNetworkError(QString("UDP"), QString("Opus codec not supported, forcing LPCM16")); + if (rxSetup.codec >= 0x40) + rxSetup.codec = 0x04; + if (txSetup.codec >= 0x40) + txSetup.codec = 0x04; + } + } + + if (in->error == 0xfeffffff) { emit haveNetworkStatus("Invalid Username/Password"); @@ -295,20 +316,6 @@ void udpHandler::dataReceived() } } - if (!strcmp(in->connection, "FTTH")) - { - highBandwidthConnection = true; - } - if (!strcmp(in->connection, "WFVIEW")) - { - } - else { - if (rxSetup.codec >= 0x40 || txSetup.codec >= 0x40) - { - emit haveNetworkError(QString("UDP"),QString("Opus codec not supported")); - } - } - qInfo(logUdp()) << this->metaObject()->className() << ": Detected connection speed " << in->connection; } break; @@ -317,6 +324,7 @@ void udpHandler::dataReceived() { conninfo_packet_t in = (conninfo_packet_t)r.constData(); if (in->type != 0x01) { + devName = in->name; QHostAddress ip = QHostAddress(qToBigEndian(in->ipaddress)); if (!streamOpened && in->busy) diff --git a/udphandler.h b/udphandler.h index fe155bd..c16bc4a 100644 --- a/udphandler.h +++ b/udphandler.h @@ -120,7 +120,7 @@ public: quint32 packetsLost=0; quint16 seqPrefix = 0; - + QString connectionType=""; int congestion = 0;