mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-17 10:55:32 +08:00
Ref T730, style
This commit is contained in:
committed by
Mat Sutcliffe
parent
09b38b4e6d
commit
3ddded423a
@@ -30,7 +30,6 @@ namespace BlackCore
|
|||||||
m_waveFormat.setCodec("audio/pcm");
|
m_waveFormat.setCodec("audio/pcm");
|
||||||
|
|
||||||
m_mixer = new CMixingSampleProvider(this);
|
m_mixer = new CMixingSampleProvider(this);
|
||||||
|
|
||||||
m_receiverIDs = transceiverIDs;
|
m_receiverIDs = transceiverIDs;
|
||||||
|
|
||||||
for (quint16 transceiverID : transceiverIDs)
|
for (quint16 transceiverID : transceiverIDs)
|
||||||
@@ -43,11 +42,6 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QAudioFormat CSoundcardSampleProvider::waveFormat() const
|
|
||||||
{
|
|
||||||
return m_waveFormat;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSoundcardSampleProvider::setBypassEffects(bool value)
|
void CSoundcardSampleProvider::setBypassEffects(bool value)
|
||||||
{
|
{
|
||||||
for (CReceiverSampleProvider *receiverInput : m_receiverInputs)
|
for (CReceiverSampleProvider *receiverInput : m_receiverInputs)
|
||||||
|
|||||||
@@ -33,16 +33,29 @@ namespace BlackCore
|
|||||||
//! Ctor
|
//! Ctor
|
||||||
CSoundcardSampleProvider(int sampleRate, const QVector<quint16> &transceiverIDs, QObject *parent = nullptr);
|
CSoundcardSampleProvider(int sampleRate, const QVector<quint16> &transceiverIDs, QObject *parent = nullptr);
|
||||||
|
|
||||||
QAudioFormat waveFormat() const;
|
//! Wave format
|
||||||
|
const QAudioFormat &waveFormat() const { return m_waveFormat; }
|
||||||
|
|
||||||
|
//! Bypass effects
|
||||||
void setBypassEffects(bool value);
|
void setBypassEffects(bool value);
|
||||||
|
|
||||||
|
//! Update PTT
|
||||||
void pttUpdate(bool active, const QVector<TxTransceiverDto> &txTransceivers);
|
void pttUpdate(bool active, const QVector<TxTransceiverDto> &txTransceivers);
|
||||||
|
|
||||||
|
//! \copydoc ISampleProvider::readSamples
|
||||||
virtual int readSamples(QVector<qint16> &samples, qint64 count) override;
|
virtual int readSamples(QVector<qint16> &samples, qint64 count) override;
|
||||||
|
|
||||||
|
//! Add OPUS samples
|
||||||
void addOpusSamples(const IAudioDto &audioDto, const QVector<RxTransceiverDto> &rxTransceivers);
|
void addOpusSamples(const IAudioDto &audioDto, const QVector<RxTransceiverDto> &rxTransceivers);
|
||||||
|
|
||||||
|
//! Update all tranceivers
|
||||||
void updateRadioTransceivers(const QVector<TransceiverDto> &radioTransceivers);
|
void updateRadioTransceivers(const QVector<TransceiverDto> &radioTransceivers);
|
||||||
|
|
||||||
|
//! Receiving callsign as single string
|
||||||
QString getReceivingCallsigns(quint16 transceiverID);
|
QString getReceivingCallsigns(quint16 transceiverID);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
//! Changed callsigns
|
||||||
void receivingCallsignsChanged(const TransceiverReceivingCallsignsChangedArgs &args);
|
void receivingCallsignsChanged(const TransceiverReceivingCallsignsChangedArgs &args);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -153,17 +153,17 @@ namespace BlackCore
|
|||||||
|
|
||||||
void CClientConnection::handleSocketError(QAbstractSocket::SocketError error)
|
void CClientConnection::handleSocketError(QAbstractSocket::SocketError error)
|
||||||
{
|
{
|
||||||
Q_UNUSED(error);
|
Q_UNUSED(error)
|
||||||
qDebug() << "UDP socket error" << m_udpSocket.errorString();
|
qDebug() << "UDP socket error" << m_udpSocket.errorString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CClientConnection::voiceServerHeartbeat()
|
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();
|
qDebug() << "Sending voice server heartbeat to" << voiceServerUrl.host();
|
||||||
HeartbeatDto keepAlive;
|
HeartbeatDto keepAlive;
|
||||||
keepAlive.callsign = m_connection.m_callsign.toStdString();
|
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<quint16>(voiceServerUrl.port()));
|
m_udpSocket.writeDatagram(dataBytes, QHostAddress(voiceServerUrl.host()), static_cast<quint16>(voiceServerUrl.port()));
|
||||||
}
|
}
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ namespace BlackCore
|
|||||||
void sendToVoiceServer(T dto)
|
void sendToVoiceServer(T dto)
|
||||||
{
|
{
|
||||||
QUrl voiceServerUrl("udp://" + m_connection.m_tokens.VoiceServer.addressIpV4);
|
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<quint16>(voiceServerUrl.port()));
|
m_udpSocket.writeDatagram(dataBytes, QHostAddress(voiceServerUrl.host()), static_cast<quint16>(voiceServerUrl.port()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ namespace BlackCore
|
|||||||
|
|
||||||
//! Serialize a DTO
|
//! Serialize a DTO
|
||||||
template<typename T>
|
template<typename T>
|
||||||
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 };
|
const CryptoDtoHeaderDto header = { channelTag.toStdString(), sequenceToBeSent, mode };
|
||||||
|
|
||||||
@@ -108,17 +108,20 @@ namespace BlackCore
|
|||||||
|
|
||||||
//! Serialize a DTO
|
//! Serialize a DTO
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static QByteArray Serialize(CCryptoDtoChannel &channel, CryptoDtoMode mode, T dto)
|
static QByteArray serialize(CCryptoDtoChannel &channel, CryptoDtoMode mode, T dto)
|
||||||
{
|
{
|
||||||
uint sequenceToSend = 0;
|
uint sequenceToSend = 0;
|
||||||
QByteArray transmitKey = channel.getTransmitKey(mode, sequenceToSend);
|
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
|
struct Deserializer
|
||||||
{
|
{
|
||||||
|
//! Ctor
|
||||||
Deserializer(CCryptoDtoChannel &channel, const QByteArray &bytes, bool loopback);
|
Deserializer(CCryptoDtoChannel &channel, const QByteArray &bytes, bool loopback);
|
||||||
|
|
||||||
|
//! Get DTO
|
||||||
template<typename T>
|
template<typename T>
|
||||||
T getDto()
|
T getDto()
|
||||||
{
|
{
|
||||||
@@ -133,18 +136,25 @@ namespace BlackCore
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Header data @{
|
||||||
quint16 headerLength;
|
quint16 headerLength;
|
||||||
CryptoDtoHeaderDto header;
|
CryptoDtoHeaderDto header;
|
||||||
|
//! @}
|
||||||
|
|
||||||
|
//! Name data @{
|
||||||
quint16 dtoNameLength;
|
quint16 dtoNameLength;
|
||||||
QByteArray dtoNameBuffer;
|
QByteArray dtoNameBuffer;
|
||||||
|
//! @}
|
||||||
|
|
||||||
|
//! Data @{
|
||||||
quint16 dataLength;
|
quint16 dataLength;
|
||||||
QByteArray dataBuffer;
|
QByteArray dataBuffer;
|
||||||
|
//! @}
|
||||||
|
|
||||||
bool verified = false;
|
bool verified = false; //!< is verified
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//! Deserialize
|
||||||
static Deserializer deserialize(CCryptoDtoChannel &channel, const QByteArray &bytes, bool loopback);
|
static Deserializer deserialize(CCryptoDtoChannel &channel, const QByteArray &bytes, bool loopback);
|
||||||
};
|
};
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
Reference in New Issue
Block a user