From 3ddded423ae968c9dd4115933a0bf634b478ddfe Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Sun, 29 Sep 2019 23:54:34 +0200 Subject: [PATCH] Ref T730, style --- .../afv/audio/soundcardsampleprovider.cpp | 6 ------ .../afv/audio/soundcardsampleprovider.h | 15 ++++++++++++++- .../afv/connection/clientconnection.cpp | 6 +++--- .../afv/connection/clientconnection.h | 2 +- src/blackcore/afv/crypto/cryptodtoserializer.h | 18 ++++++++++++++---- 5 files changed, 32 insertions(+), 15 deletions(-) diff --git a/src/blackcore/afv/audio/soundcardsampleprovider.cpp b/src/blackcore/afv/audio/soundcardsampleprovider.cpp index 1bc345894..c9982d0a6 100644 --- a/src/blackcore/afv/audio/soundcardsampleprovider.cpp +++ b/src/blackcore/afv/audio/soundcardsampleprovider.cpp @@ -30,7 +30,6 @@ namespace BlackCore m_waveFormat.setCodec("audio/pcm"); m_mixer = new CMixingSampleProvider(this); - m_receiverIDs = transceiverIDs; for (quint16 transceiverID : transceiverIDs) @@ -43,11 +42,6 @@ namespace BlackCore } } - QAudioFormat CSoundcardSampleProvider::waveFormat() const - { - return m_waveFormat; - } - void CSoundcardSampleProvider::setBypassEffects(bool value) { for (CReceiverSampleProvider *receiverInput : m_receiverInputs) diff --git a/src/blackcore/afv/audio/soundcardsampleprovider.h b/src/blackcore/afv/audio/soundcardsampleprovider.h index bd5877a4d..0584da472 100644 --- a/src/blackcore/afv/audio/soundcardsampleprovider.h +++ b/src/blackcore/afv/audio/soundcardsampleprovider.h @@ -33,16 +33,29 @@ namespace BlackCore //! Ctor CSoundcardSampleProvider(int sampleRate, const QVector &transceiverIDs, QObject *parent = nullptr); - QAudioFormat waveFormat() const; + //! Wave format + const QAudioFormat &waveFormat() const { return m_waveFormat; } + //! Bypass effects void setBypassEffects(bool value); + + //! Update PTT void pttUpdate(bool active, const QVector &txTransceivers); + + //! \copydoc ISampleProvider::readSamples virtual int readSamples(QVector &samples, qint64 count) override; + + //! Add OPUS samples void addOpusSamples(const IAudioDto &audioDto, const QVector &rxTransceivers); + + //! Update all tranceivers void updateRadioTransceivers(const QVector &radioTransceivers); + + //! Receiving callsign as single string QString getReceivingCallsigns(quint16 transceiverID); signals: + //! Changed callsigns void receivingCallsignsChanged(const TransceiverReceivingCallsignsChangedArgs &args); private: diff --git a/src/blackcore/afv/connection/clientconnection.cpp b/src/blackcore/afv/connection/clientconnection.cpp index 6a2cc9add..220140a38 100644 --- a/src/blackcore/afv/connection/clientconnection.cpp +++ b/src/blackcore/afv/connection/clientconnection.cpp @@ -153,17 +153,17 @@ namespace BlackCore void CClientConnection::handleSocketError(QAbstractSocket::SocketError error) { - Q_UNUSED(error); + Q_UNUSED(error) qDebug() << "UDP socket error" << m_udpSocket.errorString(); } void CClientConnection::voiceServerHeartbeat() { - QUrl voiceServerUrl("udp://" + m_connection.m_tokens.VoiceServer.addressIpV4); + const QUrl voiceServerUrl("udp://" + m_connection.m_tokens.VoiceServer.addressIpV4); qDebug() << "Sending voice server heartbeat to" << voiceServerUrl.host(); HeartbeatDto keepAlive; keepAlive.callsign = m_connection.m_callsign.toStdString(); - QByteArray dataBytes = CryptoDtoSerializer::Serialize(*m_connection.voiceCryptoChannel, CryptoDtoMode::AEAD_ChaCha20Poly1305, keepAlive); + const QByteArray dataBytes = CryptoDtoSerializer::serialize(*m_connection.voiceCryptoChannel, CryptoDtoMode::AEAD_ChaCha20Poly1305, keepAlive); m_udpSocket.writeDatagram(dataBytes, QHostAddress(voiceServerUrl.host()), static_cast(voiceServerUrl.port())); } } // ns diff --git a/src/blackcore/afv/connection/clientconnection.h b/src/blackcore/afv/connection/clientconnection.h index 1dc8deb1d..6192bc463 100644 --- a/src/blackcore/afv/connection/clientconnection.h +++ b/src/blackcore/afv/connection/clientconnection.h @@ -55,7 +55,7 @@ namespace BlackCore void sendToVoiceServer(T dto) { QUrl voiceServerUrl("udp://" + m_connection.m_tokens.VoiceServer.addressIpV4); - QByteArray dataBytes = Crypto::CryptoDtoSerializer::Serialize(*m_connection.voiceCryptoChannel, CryptoDtoMode::AEAD_ChaCha20Poly1305, dto); + QByteArray dataBytes = Crypto::CryptoDtoSerializer::serialize(*m_connection.voiceCryptoChannel, CryptoDtoMode::AEAD_ChaCha20Poly1305, dto); m_udpSocket.writeDatagram(dataBytes, QHostAddress(voiceServerUrl.host()), static_cast(voiceServerUrl.port())); } diff --git a/src/blackcore/afv/crypto/cryptodtoserializer.h b/src/blackcore/afv/crypto/cryptodtoserializer.h index ea38acd4e..eef37e55a 100644 --- a/src/blackcore/afv/crypto/cryptodtoserializer.h +++ b/src/blackcore/afv/crypto/cryptodtoserializer.h @@ -36,7 +36,7 @@ namespace BlackCore //! Serialize a DTO template - static QByteArray Serialize(const QString &channelTag, CryptoDtoMode mode, const QByteArray &transmitKey, uint sequenceToBeSent, T dto) + static QByteArray serialize(const QString &channelTag, CryptoDtoMode mode, const QByteArray &transmitKey, uint sequenceToBeSent, T dto) { const CryptoDtoHeaderDto header = { channelTag.toStdString(), sequenceToBeSent, mode }; @@ -108,17 +108,20 @@ namespace BlackCore //! Serialize a DTO template - static QByteArray Serialize(CCryptoDtoChannel &channel, CryptoDtoMode mode, T dto) + static QByteArray serialize(CCryptoDtoChannel &channel, CryptoDtoMode mode, T dto) { uint sequenceToSend = 0; QByteArray transmitKey = channel.getTransmitKey(mode, sequenceToSend); - return Serialize(channel.getChannelTag(), mode, transmitKey, sequenceToSend++, dto); + return serialize(channel.getChannelTag(), mode, transmitKey, sequenceToSend++, dto); } + //! Deserializer struct Deserializer { + //! Ctor Deserializer(CCryptoDtoChannel &channel, const QByteArray &bytes, bool loopback); + //! Get DTO template T getDto() { @@ -133,18 +136,25 @@ namespace BlackCore return {}; } + //! Header data @{ quint16 headerLength; CryptoDtoHeaderDto header; + //! @} + //! Name data @{ quint16 dtoNameLength; QByteArray dtoNameBuffer; + //! @} + //! Data @{ quint16 dataLength; QByteArray dataBuffer; + //! @} - bool verified = false; + bool verified = false; //!< is verified }; + //! Deserialize static Deserializer deserialize(CCryptoDtoChannel &channel, const QByteArray &bytes, bool loopback); }; } // ns