mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-12 15:25:34 +08:00
Ref T730, code style, adding namespaces
This commit is contained in:
committed by
Mat Sutcliffe
parent
329b1e8c9a
commit
99edc9cb13
@@ -14,6 +14,8 @@
|
||||
#include <QtMath>
|
||||
#include <QDebug>
|
||||
|
||||
using namespace BlackSound::SampleProvider;
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
namespace Afv
|
||||
@@ -27,22 +29,22 @@ namespace BlackCore
|
||||
{
|
||||
Q_ASSERT(audioFormat.channelCount() == 1);
|
||||
|
||||
mixer = new MixingSampleProvider(this);
|
||||
crackleSoundProvider = new ResourceSoundSampleProvider(Samples::instance().crackle(), mixer);
|
||||
mixer = new CMixingSampleProvider(this);
|
||||
crackleSoundProvider = new CResourceSoundSampleProvider(Samples::instance().crackle(), mixer);
|
||||
crackleSoundProvider->setLooping(true);
|
||||
crackleSoundProvider->setGain(0.0);
|
||||
whiteNoise = new ResourceSoundSampleProvider(Samples::instance().whiteNoise(), mixer);
|
||||
whiteNoise = new CResourceSoundSampleProvider(Samples::instance().whiteNoise(), mixer);
|
||||
whiteNoise->setLooping(true);
|
||||
whiteNoise->setGain(0.0);
|
||||
acBusNoise = new SawToothGenerator(400, mixer);
|
||||
audioInput = new BufferedWaveProvider(audioFormat, mixer);
|
||||
acBusNoise = new CSawToothGenerator(400, mixer);
|
||||
audioInput = new CBufferedWaveProvider(audioFormat, mixer);
|
||||
|
||||
// Create the compressor
|
||||
simpleCompressorEffect = new SimpleCompressorEffect(audioInput, mixer);
|
||||
simpleCompressorEffect = new CSimpleCompressorEffect(audioInput, mixer);
|
||||
simpleCompressorEffect->setMakeUpGain(-5.5);
|
||||
|
||||
// Create the voice EQ
|
||||
voiceEq = new EqualizerSampleProvider(simpleCompressorEffect, EqualizerPresets::VHFEmulation, mixer);
|
||||
voiceEq = new CEqualizerSampleProvider(simpleCompressorEffect, EqualizerPresets::VHFEmulation, mixer);
|
||||
|
||||
mixer->addMixerInput(whiteNoise);
|
||||
mixer->addMixerInput(acBusNoise);
|
||||
@@ -80,10 +82,7 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
|
||||
QString CallsignSampleProvider::type() const
|
||||
{
|
||||
return m_type;
|
||||
}
|
||||
|
||||
|
||||
void CallsignSampleProvider::active(const QString &callsign, const QString &aircraftType)
|
||||
{
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef CALLSIGNSAMPLEPROVIDER_H
|
||||
#define CALLSIGNSAMPLEPROVIDER_H
|
||||
#ifndef BLACKCORE_AFV_AUDIO_CALLSIGNSAMPLEPROVIDER_H
|
||||
#define BLACKCORE_AFV_AUDIO_CALLSIGNSAMPLEPROVIDER_H
|
||||
|
||||
#include "blackcore/afv/dto.h"
|
||||
#include "blacksound/sampleprovider/pinknoisegenerator.h"
|
||||
@@ -34,19 +34,20 @@ namespace BlackCore
|
||||
namespace Audio
|
||||
{
|
||||
//! Callsign provide
|
||||
class CallsignSampleProvider : public ISampleProvider
|
||||
class CallsignSampleProvider : public BlackSound::SampleProvider::ISampleProvider
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Ctor
|
||||
CallsignSampleProvider(const QAudioFormat &audioFormat, QObject *parent = nullptr);
|
||||
|
||||
int readSamples(QVector<qint16> &samples, qint64 count) override;
|
||||
|
||||
//! The callsign
|
||||
const QString callsign() const { return m_callsign; }
|
||||
const QString &callsign() const { return m_callsign; }
|
||||
|
||||
QString type() const;
|
||||
const QString &type() const { return m_type; }
|
||||
|
||||
void active(const QString &callsign, const QString &aircraftType);
|
||||
void activeSilent(const QString &callsign, const QString &aircraftType);
|
||||
@@ -69,8 +70,8 @@ namespace BlackCore
|
||||
QAudioFormat m_audioFormat;
|
||||
|
||||
const double whiteNoiseGainMin = 0.15; //0.01;
|
||||
const double acBusGainMin = 0.003; //0.002;
|
||||
const int frameCount = 960;
|
||||
const double acBusGainMin = 0.003; //0.002;
|
||||
const int frameCount = 960;
|
||||
const int idleTimeoutMs = 500;
|
||||
|
||||
QString m_callsign;
|
||||
@@ -81,13 +82,13 @@ namespace BlackCore
|
||||
|
||||
float m_distanceRatio = 1.0;
|
||||
|
||||
MixingSampleProvider *mixer;
|
||||
ResourceSoundSampleProvider *crackleSoundProvider;
|
||||
ResourceSoundSampleProvider *whiteNoise;
|
||||
SawToothGenerator *acBusNoise;
|
||||
SimpleCompressorEffect *simpleCompressorEffect;
|
||||
EqualizerSampleProvider *voiceEq;
|
||||
BufferedWaveProvider *audioInput;
|
||||
BlackSound::SampleProvider::CMixingSampleProvider *mixer = nullptr;
|
||||
BlackSound::SampleProvider::CResourceSoundSampleProvider *crackleSoundProvider = nullptr;
|
||||
BlackSound::SampleProvider::CResourceSoundSampleProvider *whiteNoise = nullptr;
|
||||
BlackSound::SampleProvider::CSawToothGenerator *acBusNoise = nullptr;
|
||||
BlackSound::SampleProvider::CSimpleCompressorEffect *simpleCompressorEffect = nullptr;
|
||||
BlackSound::SampleProvider::CEqualizerSampleProvider *voiceEq = nullptr;
|
||||
BlackSound::SampleProvider::CBufferedWaveProvider *audioInput = nullptr;
|
||||
QTimer m_timer;
|
||||
|
||||
BlackSound::Codecs::COpusDecoder m_decoder;
|
||||
|
||||
@@ -21,17 +21,17 @@ namespace BlackCore
|
||||
{
|
||||
namespace Audio
|
||||
{
|
||||
AudioInputBuffer::AudioInputBuffer(QObject *parent) :
|
||||
CAudioInputBuffer::CAudioInputBuffer(QObject *parent) :
|
||||
QIODevice(parent)
|
||||
{}
|
||||
|
||||
void AudioInputBuffer::start()
|
||||
void CAudioInputBuffer::start()
|
||||
{
|
||||
open(QIODevice::WriteOnly | QIODevice::Unbuffered);
|
||||
m_timerId = startTimer(20, Qt::PreciseTimer);
|
||||
}
|
||||
|
||||
void AudioInputBuffer::stop()
|
||||
void CAudioInputBuffer::stop()
|
||||
{
|
||||
if (m_timerId > 0)
|
||||
{
|
||||
@@ -41,7 +41,7 @@ namespace BlackCore
|
||||
close();
|
||||
}
|
||||
|
||||
qint64 AudioInputBuffer::readData(char *data, qint64 maxlen)
|
||||
qint64 CAudioInputBuffer::readData(char *data, qint64 maxlen)
|
||||
{
|
||||
Q_UNUSED(data)
|
||||
Q_UNUSED(maxlen)
|
||||
@@ -49,14 +49,14 @@ namespace BlackCore
|
||||
return 0;
|
||||
}
|
||||
|
||||
qint64 AudioInputBuffer::writeData(const char *data, qint64 len)
|
||||
qint64 CAudioInputBuffer::writeData(const char *data, qint64 len)
|
||||
{
|
||||
QByteArray buffer(data, static_cast<int>(len));
|
||||
m_buffer.append(buffer);
|
||||
return len;
|
||||
}
|
||||
|
||||
void AudioInputBuffer::timerEvent(QTimerEvent *event)
|
||||
void CAudioInputBuffer::timerEvent(QTimerEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
// 20 ms = 960 samples * 2 bytes = 1920 Bytes
|
||||
@@ -67,7 +67,7 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
|
||||
Input::Input(int sampleRate, QObject *parent) :
|
||||
CInput::CInput(int sampleRate, QObject *parent) :
|
||||
QObject(parent),
|
||||
m_sampleRate(sampleRate),
|
||||
m_encoder(sampleRate, 1, OPUS_APPLICATION_VOIP)
|
||||
@@ -75,32 +75,32 @@ namespace BlackCore
|
||||
m_encoder.setBitRate(16 * 1024);
|
||||
}
|
||||
|
||||
bool Input::started() const
|
||||
bool CInput::started() const
|
||||
{
|
||||
return m_started;
|
||||
}
|
||||
|
||||
int Input::opusBytesEncoded() const
|
||||
int CInput::opusBytesEncoded() const
|
||||
{
|
||||
return m_opusBytesEncoded;
|
||||
}
|
||||
|
||||
void Input::setOpusBytesEncoded(int opusBytesEncoded)
|
||||
void CInput::setOpusBytesEncoded(int opusBytesEncoded)
|
||||
{
|
||||
m_opusBytesEncoded = opusBytesEncoded;
|
||||
}
|
||||
|
||||
double Input::volume() const
|
||||
double CInput::volume() const
|
||||
{
|
||||
return m_volume;
|
||||
}
|
||||
|
||||
void Input::setVolume(double volume)
|
||||
void CInput::setVolume(double volume)
|
||||
{
|
||||
m_volume = volume;
|
||||
}
|
||||
|
||||
void Input::start(const QAudioDeviceInfo &inputDevice)
|
||||
void CInput::start(const QAudioDeviceInfo &inputDevice)
|
||||
{
|
||||
if (m_started) { return; }
|
||||
|
||||
@@ -124,12 +124,12 @@ namespace BlackCore
|
||||
m_audioInputBuffer.start();
|
||||
|
||||
m_audioInput->start(&m_audioInputBuffer);
|
||||
connect(&m_audioInputBuffer, &AudioInputBuffer::frameAvailable, this, &Input::audioInDataAvailable);
|
||||
connect(&m_audioInputBuffer, &CAudioInputBuffer::frameAvailable, this, &CInput::audioInDataAvailable);
|
||||
|
||||
m_started = true;
|
||||
}
|
||||
|
||||
void Input::stop()
|
||||
void CInput::stop()
|
||||
{
|
||||
if (! m_started) { return; }
|
||||
|
||||
@@ -139,7 +139,7 @@ namespace BlackCore
|
||||
m_audioInput.reset();
|
||||
}
|
||||
|
||||
void Input::audioInDataAvailable(const QByteArray &frame)
|
||||
void CInput::audioInDataAvailable(const QByteArray &frame)
|
||||
{
|
||||
QVector<qint16> samples = convertBytesTo16BitPCM(frame);
|
||||
|
||||
|
||||
@@ -27,20 +27,25 @@ namespace BlackCore
|
||||
namespace Audio
|
||||
{
|
||||
//! Input buffer
|
||||
class AudioInputBuffer : public QIODevice
|
||||
class CAudioInputBuffer : public QIODevice
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AudioInputBuffer(QObject *parent = nullptr);
|
||||
//! Inout buffer
|
||||
CAudioInputBuffer(QObject *parent = nullptr);
|
||||
|
||||
void start();
|
||||
void stop();
|
||||
|
||||
qint64 readData(char *data, qint64 maxlen) override;
|
||||
qint64 writeData(const char *data, qint64 len) override;
|
||||
//! \copydoc QIODevice::readData
|
||||
virtual qint64 readData(char *data, qint64 maxlen) override;
|
||||
|
||||
//! \copydoc QIODevice::writeData
|
||||
virtual qint64 writeData(const char *data, qint64 len) override;
|
||||
|
||||
signals:
|
||||
//! Frame is available
|
||||
void frameAvailable(const QByteArray &frame);
|
||||
|
||||
protected:
|
||||
@@ -66,12 +71,14 @@ namespace BlackCore
|
||||
float PeakVU = 0.0;
|
||||
};
|
||||
|
||||
class Input : public QObject
|
||||
//! Input
|
||||
class CInput : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Input(int sampleRate, QObject *parent = nullptr);
|
||||
//! Ctor
|
||||
CInput(int sampleRate, QObject *parent = nullptr);
|
||||
|
||||
bool started() const;
|
||||
|
||||
@@ -109,7 +116,7 @@ namespace BlackCore
|
||||
|
||||
uint m_audioSequenceCounter = 0;
|
||||
|
||||
AudioInputBuffer m_audioInputBuffer;
|
||||
CAudioInputBuffer m_audioInputBuffer;
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -13,22 +13,24 @@
|
||||
#include <QDebug>
|
||||
#include <cmath>
|
||||
|
||||
using namespace BlackSound::SampleProvider;
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
namespace Afv
|
||||
{
|
||||
namespace Audio
|
||||
{
|
||||
AudioOutputBuffer::AudioOutputBuffer(ISampleProvider *sampleProvider, QObject *parent) :
|
||||
CAudioOutputBuffer::CAudioOutputBuffer(ISampleProvider *sampleProvider, QObject *parent) :
|
||||
QIODevice(parent),
|
||||
m_sampleProvider(sampleProvider)
|
||||
{ }
|
||||
|
||||
qint64 AudioOutputBuffer::readData(char *data, qint64 maxlen)
|
||||
qint64 CAudioOutputBuffer::readData(char *data, qint64 maxlen)
|
||||
{
|
||||
int sampleBytes = m_outputFormat.sampleSize() / 8;
|
||||
int sampleBytes = m_outputFormat.sampleSize() / 8;
|
||||
int channelCount = m_outputFormat.channelCount();
|
||||
int count = maxlen / (sampleBytes * channelCount);
|
||||
qint64 count = maxlen / (sampleBytes * channelCount);
|
||||
QVector<qint16> buffer;
|
||||
m_sampleProvider->readSamples(buffer, count);
|
||||
|
||||
@@ -63,10 +65,10 @@ namespace BlackCore
|
||||
return maxlen;
|
||||
}
|
||||
|
||||
qint64 AudioOutputBuffer::writeData(const char *data, qint64 len)
|
||||
qint64 CAudioOutputBuffer::writeData(const char *data, qint64 len)
|
||||
{
|
||||
Q_UNUSED(data);
|
||||
Q_UNUSED(len);
|
||||
Q_UNUSED(data)
|
||||
Q_UNUSED(len)
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -75,8 +77,8 @@ namespace BlackCore
|
||||
|
||||
void Output::start(const QAudioDeviceInfo &device, ISampleProvider *sampleProvider)
|
||||
{
|
||||
m_audioOutputBuffer = new AudioOutputBuffer(sampleProvider, this);
|
||||
connect(m_audioOutputBuffer, &AudioOutputBuffer::outputVolumeStream, this, &Output::outputVolumeStream);
|
||||
m_audioOutputBuffer = new CAudioOutputBuffer(sampleProvider, this);
|
||||
connect(m_audioOutputBuffer, &CAudioOutputBuffer::outputVolumeStream, this, &Output::outputVolumeStream);
|
||||
|
||||
QAudioFormat outputFormat;
|
||||
outputFormat.setSampleRate(48000);
|
||||
|
||||
@@ -32,14 +32,15 @@ namespace BlackCore
|
||||
float PeakVU = 0.0;
|
||||
};
|
||||
|
||||
class AudioOutputBuffer : public QIODevice
|
||||
class CAudioOutputBuffer : public QIODevice
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AudioOutputBuffer(ISampleProvider *sampleProvider, QObject *parent = nullptr);
|
||||
//! Ctor
|
||||
CAudioOutputBuffer(BlackSound::SampleProvider::ISampleProvider *sampleProvider, QObject *parent = nullptr);
|
||||
|
||||
ISampleProvider *m_sampleProvider = nullptr;
|
||||
BlackSound::SampleProvider::ISampleProvider *m_sampleProvider = nullptr;
|
||||
|
||||
void setAudioFormat(const QAudioFormat &format) { m_outputFormat = format; }
|
||||
|
||||
@@ -66,7 +67,7 @@ namespace BlackCore
|
||||
public:
|
||||
Output(QObject *parent = nullptr);
|
||||
|
||||
void start(const QAudioDeviceInfo &device, ISampleProvider *sampleProvider);
|
||||
void start(const QAudioDeviceInfo &device, BlackSound::SampleProvider::ISampleProvider *sampleProvider);
|
||||
void stop();
|
||||
|
||||
signals:
|
||||
@@ -76,7 +77,7 @@ namespace BlackCore
|
||||
bool m_started = false;
|
||||
|
||||
QScopedPointer<QAudioOutput> m_audioOutputCom1;
|
||||
AudioOutputBuffer *m_audioOutputBuffer;
|
||||
CAudioOutputBuffer *m_audioOutputBuffer;
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -14,31 +14,33 @@
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
using namespace BlackSound::SampleProvider;
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
namespace Afv
|
||||
{
|
||||
namespace Audio
|
||||
{
|
||||
ReceiverSampleProvider::ReceiverSampleProvider(const QAudioFormat &audioFormat, quint16 id, int voiceInputNumber, QObject *parent) :
|
||||
CReceiverSampleProvider::CReceiverSampleProvider(const QAudioFormat &audioFormat, quint16 id, int voiceInputNumber, QObject *parent) :
|
||||
ISampleProvider(parent),
|
||||
m_id(id)
|
||||
{
|
||||
m_mixer = new MixingSampleProvider(this);
|
||||
m_mixer = new CMixingSampleProvider(this);
|
||||
|
||||
for (int i = 0; i < voiceInputNumber; i++)
|
||||
{
|
||||
auto voiceInput = new CallsignSampleProvider(audioFormat, m_mixer);
|
||||
m_voiceInputs.push_back(voiceInput);
|
||||
m_mixer->addMixerInput(voiceInput);
|
||||
};
|
||||
}
|
||||
|
||||
// TODO blockTone = new SignalGenerator(WaveFormat.SampleRate, 1) { Gain = 0, Type = SignalGeneratorType.Sin, Frequency = 180 };
|
||||
// TODO mixer.AddMixerInput(blockTone.ToMono());
|
||||
// TODO volume = new VolumeSampleProvider(mixer);
|
||||
}
|
||||
|
||||
void ReceiverSampleProvider::setBypassEffects(bool value)
|
||||
void CReceiverSampleProvider::setBypassEffects(bool value)
|
||||
{
|
||||
for (CallsignSampleProvider *voiceInput : m_voiceInputs)
|
||||
{
|
||||
@@ -46,7 +48,7 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
|
||||
void ReceiverSampleProvider::setFrequency(const uint &frequency)
|
||||
void CReceiverSampleProvider::setFrequency(const uint &frequency)
|
||||
{
|
||||
if (frequency != m_frequency)
|
||||
{
|
||||
@@ -58,26 +60,26 @@ namespace BlackCore
|
||||
m_frequency = frequency;
|
||||
}
|
||||
|
||||
int ReceiverSampleProvider::activeCallsigns() const
|
||||
int CReceiverSampleProvider::activeCallsigns() const
|
||||
{
|
||||
int numberOfCallsigns = std::count_if(m_voiceInputs.begin(), m_voiceInputs.end(), [](const CallsignSampleProvider * p)
|
||||
const int numberOfCallsigns = std::count_if(m_voiceInputs.begin(), m_voiceInputs.end(), [](const CallsignSampleProvider * p)
|
||||
{
|
||||
return p->inUse() == true;
|
||||
});
|
||||
return numberOfCallsigns;
|
||||
}
|
||||
|
||||
float ReceiverSampleProvider::volume() const
|
||||
float CReceiverSampleProvider::volume() const
|
||||
{
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
bool ReceiverSampleProvider::getMute() const
|
||||
bool CReceiverSampleProvider::getMute() const
|
||||
{
|
||||
return m_mute;
|
||||
}
|
||||
|
||||
void ReceiverSampleProvider::setMute(bool value)
|
||||
void CReceiverSampleProvider::setMute(bool value)
|
||||
{
|
||||
m_mute = value;
|
||||
if (value)
|
||||
@@ -89,7 +91,7 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
|
||||
int ReceiverSampleProvider::readSamples(QVector<qint16> &samples, qint64 count)
|
||||
int CReceiverSampleProvider::readSamples(QVector<qint16> &samples, qint64 count)
|
||||
{
|
||||
int numberOfInUseInputs = activeCallsigns();
|
||||
|
||||
@@ -105,7 +107,7 @@ namespace BlackCore
|
||||
|
||||
if (m_doClickWhenAppropriate && numberOfInUseInputs == 0)
|
||||
{
|
||||
ResourceSoundSampleProvider *resourceSound = new ResourceSoundSampleProvider(Samples::instance().click(), m_mixer);
|
||||
CResourceSoundSampleProvider *resourceSound = new CResourceSoundSampleProvider(Samples::instance().click(), m_mixer);
|
||||
m_mixer->addMixerInput(resourceSound);
|
||||
qDebug() << "Click...";
|
||||
m_doClickWhenAppropriate = false;
|
||||
@@ -133,7 +135,7 @@ namespace BlackCore
|
||||
return m_mixer->readSamples(samples, count);
|
||||
}
|
||||
|
||||
void ReceiverSampleProvider::addOpusSamples(const IAudioDto &audioDto, uint frequency, float distanceRatio)
|
||||
void CReceiverSampleProvider::addOpusSamples(const IAudioDto &audioDto, uint frequency, float distanceRatio)
|
||||
{
|
||||
if (m_frequency != frequency) //Lag in the backend means we get the tail end of a transmission
|
||||
return;
|
||||
@@ -167,7 +169,7 @@ namespace BlackCore
|
||||
m_doClickWhenAppropriate = true;
|
||||
}
|
||||
|
||||
void ReceiverSampleProvider::addSilentSamples(const IAudioDto &audioDto, uint frequency, float distanceRatio)
|
||||
void CReceiverSampleProvider::addSilentSamples(const IAudioDto &audioDto, uint frequency, float distanceRatio)
|
||||
{
|
||||
Q_UNUSED(distanceRatio);
|
||||
if (m_frequency != frequency) //Lag in the backend means we get the tail end of a transmission
|
||||
@@ -200,7 +202,7 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
|
||||
QString ReceiverSampleProvider::getReceivingCallsigns() const
|
||||
QString CReceiverSampleProvider::getReceivingCallsigns() const
|
||||
{
|
||||
return m_receivingCallsigns;
|
||||
}
|
||||
|
||||
@@ -31,12 +31,13 @@ namespace BlackCore
|
||||
};
|
||||
|
||||
//! A sample provider
|
||||
class ReceiverSampleProvider : public ISampleProvider
|
||||
class CReceiverSampleProvider : public BlackSound::SampleProvider::ISampleProvider
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ReceiverSampleProvider(const QAudioFormat &audioFormat, quint16 id, int voiceInputNumber, QObject *parent = nullptr);
|
||||
//! Ctor
|
||||
CReceiverSampleProvider(const QAudioFormat &audioFormat, quint16 id, int voiceInputNumber, QObject *parent = nullptr);
|
||||
|
||||
void setBypassEffects(bool value);
|
||||
void setFrequency(const uint &frequency);
|
||||
@@ -67,7 +68,7 @@ namespace BlackCore
|
||||
quint16 m_id;
|
||||
|
||||
// TODO VolumeSampleProvider volume;
|
||||
MixingSampleProvider *m_mixer;
|
||||
BlackSound::SampleProvider::CMixingSampleProvider *m_mixer = nullptr;
|
||||
// TODO SignalGenerator blockTone;
|
||||
QVector<CallsignSampleProvider *> m_voiceInputs;
|
||||
QString m_receivingCallsigns;
|
||||
|
||||
@@ -10,15 +10,17 @@
|
||||
|
||||
#include "soundcardsampleprovider.h"
|
||||
|
||||
using namespace BlackSound::SampleProvider;
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
namespace Afv
|
||||
{
|
||||
namespace Audio
|
||||
{
|
||||
SoundcardSampleProvider::SoundcardSampleProvider(int sampleRate, const QVector<quint16> &transceiverIDs, QObject *parent) :
|
||||
CSoundcardSampleProvider::CSoundcardSampleProvider(int sampleRate, const QVector<quint16> &transceiverIDs, QObject *parent) :
|
||||
ISampleProvider(parent),
|
||||
m_mixer(new MixingSampleProvider())
|
||||
m_mixer(new CMixingSampleProvider())
|
||||
{
|
||||
m_waveFormat.setSampleRate(sampleRate);
|
||||
m_waveFormat.setChannelCount(1);
|
||||
@@ -27,34 +29,34 @@ namespace BlackCore
|
||||
m_waveFormat.setByteOrder(QAudioFormat::LittleEndian);
|
||||
m_waveFormat.setCodec("audio/pcm");
|
||||
|
||||
m_mixer = new MixingSampleProvider(this);
|
||||
m_mixer = new CMixingSampleProvider(this);
|
||||
|
||||
m_receiverIDs = transceiverIDs;
|
||||
|
||||
for (quint16 transceiverID : transceiverIDs)
|
||||
{
|
||||
ReceiverSampleProvider *transceiverInput = new ReceiverSampleProvider(m_waveFormat, transceiverID, 4, m_mixer);
|
||||
connect(transceiverInput, &ReceiverSampleProvider::receivingCallsignsChanged, this, &SoundcardSampleProvider::receivingCallsignsChanged);
|
||||
CReceiverSampleProvider *transceiverInput = new CReceiverSampleProvider(m_waveFormat, transceiverID, 4, m_mixer);
|
||||
connect(transceiverInput, &CReceiverSampleProvider::receivingCallsignsChanged, this, &CSoundcardSampleProvider::receivingCallsignsChanged);
|
||||
m_receiverInputs.push_back(transceiverInput);
|
||||
m_receiverIDs.push_back(transceiverID);
|
||||
m_mixer->addMixerInput(transceiverInput);
|
||||
}
|
||||
}
|
||||
|
||||
QAudioFormat SoundcardSampleProvider::waveFormat() const
|
||||
QAudioFormat CSoundcardSampleProvider::waveFormat() const
|
||||
{
|
||||
return m_waveFormat;
|
||||
}
|
||||
|
||||
void SoundcardSampleProvider::setBypassEffects(bool value)
|
||||
void CSoundcardSampleProvider::setBypassEffects(bool value)
|
||||
{
|
||||
for (ReceiverSampleProvider *receiverInput : m_receiverInputs)
|
||||
for (CReceiverSampleProvider *receiverInput : m_receiverInputs)
|
||||
{
|
||||
receiverInput->setBypassEffects(value);
|
||||
}
|
||||
}
|
||||
|
||||
void SoundcardSampleProvider::pttUpdate(bool active, const QVector<TxTransceiverDto> &txTransceivers)
|
||||
void CSoundcardSampleProvider::pttUpdate(bool active, const QVector<TxTransceiverDto> &txTransceivers)
|
||||
{
|
||||
if (active)
|
||||
{
|
||||
@@ -71,7 +73,7 @@ namespace BlackCore
|
||||
|
||||
for (const TxTransceiverDto &txTransceiver : txTransceiversFiltered)
|
||||
{
|
||||
auto it = std::find_if(m_receiverInputs.begin(), m_receiverInputs.end(), [txTransceiver](const ReceiverSampleProvider * p)
|
||||
auto it = std::find_if(m_receiverInputs.begin(), m_receiverInputs.end(), [txTransceiver](const CReceiverSampleProvider * p)
|
||||
{
|
||||
return p->getId() == txTransceiver.id;
|
||||
});
|
||||
@@ -82,19 +84,19 @@ namespace BlackCore
|
||||
}
|
||||
else
|
||||
{
|
||||
for (ReceiverSampleProvider *receiverInput : m_receiverInputs)
|
||||
for (CReceiverSampleProvider *receiverInput : m_receiverInputs)
|
||||
{
|
||||
receiverInput->setMute(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int SoundcardSampleProvider::readSamples(QVector<qint16> &samples, qint64 count)
|
||||
int CSoundcardSampleProvider::readSamples(QVector<qint16> &samples, qint64 count)
|
||||
{
|
||||
return m_mixer->readSamples(samples, count);
|
||||
}
|
||||
|
||||
void SoundcardSampleProvider::addOpusSamples(const IAudioDto &audioDto, const QVector<RxTransceiverDto> &rxTransceivers)
|
||||
void CSoundcardSampleProvider::addOpusSamples(const IAudioDto &audioDto, const QVector<RxTransceiverDto> &rxTransceivers)
|
||||
{
|
||||
QVector<RxTransceiverDto> rxTransceiversFilteredAndSorted = rxTransceivers;
|
||||
|
||||
@@ -120,8 +122,8 @@ namespace BlackCore
|
||||
{
|
||||
handledTransceiverIDs.push_back(rxTransceiver.id);
|
||||
|
||||
ReceiverSampleProvider *receiverInput = nullptr;
|
||||
auto it = std::find_if(m_receiverInputs.begin(), m_receiverInputs.end(), [rxTransceiver](const ReceiverSampleProvider * p)
|
||||
CReceiverSampleProvider *receiverInput = nullptr;
|
||||
auto it = std::find_if(m_receiverInputs.begin(), m_receiverInputs.end(), [rxTransceiver](const CReceiverSampleProvider * p)
|
||||
{
|
||||
return p->getId() == rxTransceiver.id;
|
||||
});
|
||||
@@ -147,11 +149,11 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
|
||||
void SoundcardSampleProvider::updateRadioTransceivers(const QVector<TransceiverDto> &radioTransceivers)
|
||||
void CSoundcardSampleProvider::updateRadioTransceivers(const QVector<TransceiverDto> &radioTransceivers)
|
||||
{
|
||||
for (const TransceiverDto &radioTransceiver : radioTransceivers)
|
||||
{
|
||||
auto it = std::find_if(m_receiverInputs.begin(), m_receiverInputs.end(), [radioTransceiver](const ReceiverSampleProvider * p)
|
||||
auto it = std::find_if(m_receiverInputs.begin(), m_receiverInputs.end(), [radioTransceiver](const CReceiverSampleProvider * p)
|
||||
{
|
||||
return p->getId() == radioTransceiver.id;
|
||||
});
|
||||
@@ -162,7 +164,7 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
|
||||
for (ReceiverSampleProvider *receiverInput : m_receiverInputs)
|
||||
for (CReceiverSampleProvider *receiverInput : m_receiverInputs)
|
||||
{
|
||||
quint16 transceiverID = receiverInput->getId();
|
||||
bool contains = std::any_of(radioTransceivers.begin(), radioTransceivers.end(), [&](const auto & tx) { return transceiverID == tx.id; });
|
||||
@@ -173,7 +175,7 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
|
||||
QString SoundcardSampleProvider::getReceivingCallsigns(quint16 transceiverID)
|
||||
QString CSoundcardSampleProvider::getReceivingCallsigns(quint16 transceiverID)
|
||||
{
|
||||
return m_receiverInputs.at(transceiverID)->getReceivingCallsigns();
|
||||
}
|
||||
|
||||
@@ -25,13 +25,13 @@ namespace BlackCore
|
||||
namespace Audio
|
||||
{
|
||||
//! Soundcard sample
|
||||
class SoundcardSampleProvider : public ISampleProvider
|
||||
class CSoundcardSampleProvider : public BlackSound::SampleProvider::ISampleProvider
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Ctor
|
||||
SoundcardSampleProvider(int sampleRate, const QVector<quint16> &transceiverIDs, QObject *parent = nullptr);
|
||||
CSoundcardSampleProvider(int sampleRate, const QVector<quint16> &transceiverIDs, QObject *parent = nullptr);
|
||||
|
||||
QAudioFormat waveFormat() const;
|
||||
|
||||
@@ -47,8 +47,8 @@ namespace BlackCore
|
||||
|
||||
private:
|
||||
QAudioFormat m_waveFormat;
|
||||
MixingSampleProvider *m_mixer;
|
||||
QVector<ReceiverSampleProvider *> m_receiverInputs;
|
||||
BlackSound::SampleProvider::CMixingSampleProvider *m_mixer = nullptr;
|
||||
QVector<CReceiverSampleProvider *> m_receiverInputs;
|
||||
QVector<quint16> m_receiverIDs;
|
||||
};
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ using namespace BlackMisc::PhysicalQuantities;
|
||||
using namespace BlackCore::Context;
|
||||
using namespace BlackCore::Afv::Audio;
|
||||
using namespace BlackCore::Afv::Connection;
|
||||
using namespace BlackSound::SampleProvider;
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
@@ -21,22 +22,22 @@ namespace BlackCore
|
||||
{
|
||||
namespace Clients
|
||||
{
|
||||
AFVClient::AFVClient(const QString &apiServer, QObject *parent) :
|
||||
CAfvClient::CAfvClient(const QString &apiServer, QObject *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
m_connection = new ClientConnection(apiServer, this);
|
||||
m_connection = new CClientConnection(apiServer, this);
|
||||
m_connection->setReceiveAudio(false);
|
||||
|
||||
m_input = new Input(c_sampleRate, this);
|
||||
connect(m_input, &Input::opusDataAvailable, this, &AFVClient::opusDataAvailable);
|
||||
connect(m_input, &Input::inputVolumeStream, this, &AFVClient::inputVolumeStream);
|
||||
m_input = new CInput(c_sampleRate, this);
|
||||
connect(m_input, &CInput::opusDataAvailable, this, &CAfvClient::opusDataAvailable);
|
||||
connect(m_input, &CInput::inputVolumeStream, this, &CAfvClient::inputVolumeStream);
|
||||
|
||||
m_output = new Output(this);
|
||||
connect(m_output, &Output::outputVolumeStream, this, &AFVClient::outputVolumeStream);
|
||||
connect(m_output, &Output::outputVolumeStream, this, &CAfvClient::outputVolumeStream);
|
||||
|
||||
connect(m_connection, &ClientConnection::audioReceived, this, &AFVClient::audioOutDataAvailable);
|
||||
connect(m_connection, &CClientConnection::audioReceived, this, &CAfvClient::audioOutDataAvailable);
|
||||
|
||||
connect(&m_voiceServerPositionTimer, &QTimer::timeout, this, qOverload<>(&AFVClient::updateTransceivers));
|
||||
connect(&m_voiceServerPositionTimer, &QTimer::timeout, this, qOverload<>(&CAfvClient::updateTransceivers));
|
||||
|
||||
m_transceivers =
|
||||
{
|
||||
@@ -58,16 +59,16 @@ namespace BlackCore
|
||||
qDebug() << "UserClient instantiated";
|
||||
}
|
||||
|
||||
void AFVClient::setContextOwnAircraft(const IContextOwnAircraft *contextOwnAircraft)
|
||||
void CAfvClient::setContextOwnAircraft(const IContextOwnAircraft *contextOwnAircraft)
|
||||
{
|
||||
m_contextOwnAircraft = contextOwnAircraft;
|
||||
if (m_contextOwnAircraft)
|
||||
{
|
||||
connect(m_contextOwnAircraft, &IContextOwnAircraft::changedAircraftCockpit, this, &AFVClient::updateTransceiversFromContext);
|
||||
connect(m_contextOwnAircraft, &IContextOwnAircraft::changedAircraftCockpit, this, &CAfvClient::updateTransceiversFromContext);
|
||||
}
|
||||
}
|
||||
|
||||
void AFVClient::connectTo(const QString &cid, const QString &password, const QString &callsign)
|
||||
void CAfvClient::connectTo(const QString &cid, const QString &password, const QString &callsign)
|
||||
{
|
||||
m_callsign = callsign;
|
||||
m_connection->connectTo(cid, password, callsign);
|
||||
@@ -79,13 +80,13 @@ namespace BlackCore
|
||||
m_connection->getAllAliasedStations();
|
||||
}
|
||||
|
||||
void AFVClient::disconnectFrom()
|
||||
void CAfvClient::disconnectFrom()
|
||||
{
|
||||
m_connection->disconnectFrom();
|
||||
emit connectionStatusChanged(Disconnected);
|
||||
}
|
||||
|
||||
QStringList AFVClient::availableInputDevices() const
|
||||
QStringList CAfvClient::availableInputDevices() const
|
||||
{
|
||||
const QList<QAudioDeviceInfo> inputDevices = QAudioDeviceInfo::availableDevices(QAudio::AudioInput);
|
||||
|
||||
@@ -97,7 +98,7 @@ namespace BlackCore
|
||||
return deviceNames;
|
||||
}
|
||||
|
||||
QStringList AFVClient::availableOutputDevices() const
|
||||
QStringList CAfvClient::availableOutputDevices() const
|
||||
{
|
||||
const QList<QAudioDeviceInfo> outputDevices = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput);
|
||||
|
||||
@@ -109,7 +110,7 @@ namespace BlackCore
|
||||
return deviceNames;
|
||||
}
|
||||
|
||||
void AFVClient::setBypassEffects(bool value)
|
||||
void CAfvClient::setBypassEffects(bool value)
|
||||
{
|
||||
if (soundcardSampleProvider)
|
||||
{
|
||||
@@ -117,7 +118,7 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
|
||||
void AFVClient::start(const QAudioDeviceInfo &inputDevice, const QAudioDeviceInfo &outputDevice, const QVector<quint16> &transceiverIDs)
|
||||
void CAfvClient::start(const QAudioDeviceInfo &inputDevice, const QAudioDeviceInfo &outputDevice, const QVector<quint16> &transceiverIDs)
|
||||
{
|
||||
if (m_isStarted)
|
||||
{
|
||||
@@ -125,9 +126,9 @@ namespace BlackCore
|
||||
return;
|
||||
}
|
||||
|
||||
soundcardSampleProvider = new SoundcardSampleProvider(c_sampleRate, transceiverIDs, this);
|
||||
connect(soundcardSampleProvider, &SoundcardSampleProvider::receivingCallsignsChanged, this, &AFVClient::receivingCallsignsChanged);
|
||||
outputSampleProvider = new VolumeSampleProvider(soundcardSampleProvider, this);
|
||||
soundcardSampleProvider = new CSoundcardSampleProvider(c_sampleRate, transceiverIDs, this);
|
||||
connect(soundcardSampleProvider, &CSoundcardSampleProvider::receivingCallsignsChanged, this, &CAfvClient::receivingCallsignsChanged);
|
||||
outputSampleProvider = new CVolumeSampleProvider(soundcardSampleProvider, this);
|
||||
outputSampleProvider->setVolume(m_outputVolume);
|
||||
|
||||
m_output->start(outputDevice, outputSampleProvider);
|
||||
@@ -140,13 +141,13 @@ namespace BlackCore
|
||||
qDebug() << ("Started [Input: " + inputDevice.deviceName() + "] [Output: " + outputDevice.deviceName() + "]");
|
||||
}
|
||||
|
||||
void AFVClient::start(const QString &inputDeviceName, const QString &outputDeviceName)
|
||||
void CAfvClient::start(const QString &inputDeviceName, const QString &outputDeviceName)
|
||||
{
|
||||
if (m_isStarted) { return; }
|
||||
|
||||
soundcardSampleProvider = new SoundcardSampleProvider(c_sampleRate, { 0, 1 }, this);
|
||||
connect(soundcardSampleProvider, &SoundcardSampleProvider::receivingCallsignsChanged, this, &AFVClient::receivingCallsignsChanged);
|
||||
outputSampleProvider = new VolumeSampleProvider(soundcardSampleProvider, this);
|
||||
soundcardSampleProvider = new CSoundcardSampleProvider(c_sampleRate, { 0, 1 }, this);
|
||||
connect(soundcardSampleProvider, &CSoundcardSampleProvider::receivingCallsignsChanged, this, &CAfvClient::receivingCallsignsChanged);
|
||||
outputSampleProvider = new CVolumeSampleProvider(soundcardSampleProvider, this);
|
||||
outputSampleProvider->setVolume(m_outputVolume);
|
||||
|
||||
QAudioDeviceInfo inputDevice = QAudioDeviceInfo::defaultInputDevice();
|
||||
@@ -178,7 +179,7 @@ namespace BlackCore
|
||||
m_isStarted = true;
|
||||
}
|
||||
|
||||
void AFVClient::stop()
|
||||
void CAfvClient::stop()
|
||||
{
|
||||
if (! m_isStarted)
|
||||
{
|
||||
@@ -196,7 +197,7 @@ namespace BlackCore
|
||||
m_output->stop();
|
||||
}
|
||||
|
||||
void AFVClient::enableTransceiver(quint16 id, bool enable)
|
||||
void CAfvClient::enableTransceiver(quint16 id, bool enable)
|
||||
{
|
||||
if (enable) { m_enabledTransceivers.insert(id); }
|
||||
else { m_enabledTransceivers.remove(id); }
|
||||
@@ -204,7 +205,7 @@ namespace BlackCore
|
||||
updateTransceivers();
|
||||
}
|
||||
|
||||
void AFVClient::updateComFrequency(quint16 id, quint32 frequency)
|
||||
void CAfvClient::updateComFrequency(quint16 id, quint32 frequency)
|
||||
{
|
||||
if (id != 0 && id != 1) { return; }
|
||||
|
||||
@@ -221,7 +222,7 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
|
||||
void AFVClient::updatePosition(double latitude, double longitude, double height)
|
||||
void CAfvClient::updatePosition(double latitude, double longitude, double height)
|
||||
{
|
||||
for (TransceiverDto &transceiver : m_transceivers)
|
||||
{
|
||||
@@ -232,7 +233,7 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
|
||||
void AFVClient::updateTransceivers()
|
||||
void CAfvClient::updateTransceivers()
|
||||
{
|
||||
if (! m_connection->isConnected()) { return; }
|
||||
|
||||
@@ -262,18 +263,18 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
|
||||
void AFVClient::setTransmittingTransceivers(quint16 transceiverID)
|
||||
void CAfvClient::setTransmittingTransceivers(quint16 transceiverID)
|
||||
{
|
||||
TxTransceiverDto tx = { transceiverID };
|
||||
setTransmittingTransceivers({ tx });
|
||||
}
|
||||
|
||||
void AFVClient::setTransmittingTransceivers(const QVector<TxTransceiverDto> &transceivers)
|
||||
void CAfvClient::setTransmittingTransceivers(const QVector<TxTransceiverDto> &transceivers)
|
||||
{
|
||||
m_transmittingTransceivers = transceivers;
|
||||
}
|
||||
|
||||
void AFVClient::setPtt(bool active)
|
||||
void CAfvClient::setPtt(bool active)
|
||||
{
|
||||
if (! m_isStarted)
|
||||
{
|
||||
@@ -303,7 +304,7 @@ namespace BlackCore
|
||||
qDebug() << "PTT:" << active;
|
||||
}
|
||||
|
||||
void AFVClient::setInputVolumeDb(double value)
|
||||
void CAfvClient::setInputVolumeDb(double value)
|
||||
{
|
||||
if (value > 18) { value = 18; }
|
||||
if (value < -18) { value = -18; }
|
||||
@@ -311,7 +312,7 @@ namespace BlackCore
|
||||
m_input->setVolume(qPow(10, value / 20));
|
||||
}
|
||||
|
||||
void AFVClient::opusDataAvailable(const OpusDataAvailableArgs &args)
|
||||
void CAfvClient::opusDataAvailable(const OpusDataAvailableArgs &args)
|
||||
{
|
||||
if (m_loopbackOn && m_transmit)
|
||||
{
|
||||
@@ -360,7 +361,7 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
|
||||
void AFVClient::audioOutDataAvailable(const AudioRxOnTransceiversDto &dto)
|
||||
void CAfvClient::audioOutDataAvailable(const AudioRxOnTransceiversDto &dto)
|
||||
{
|
||||
IAudioDto audioData;
|
||||
audioData.audio = QByteArray(dto.audio.data(), static_cast<int>(dto.audio.size()));
|
||||
@@ -370,19 +371,19 @@ namespace BlackCore
|
||||
soundcardSampleProvider->addOpusSamples(audioData, QVector<RxTransceiverDto>::fromStdVector(dto.transceivers));
|
||||
}
|
||||
|
||||
void AFVClient::inputVolumeStream(const InputVolumeStreamArgs &args)
|
||||
void CAfvClient::inputVolumeStream(const InputVolumeStreamArgs &args)
|
||||
{
|
||||
m_inputVolumeStream = args;
|
||||
emit inputVolumePeakVU(m_inputVolumeStream.PeakVU);
|
||||
}
|
||||
|
||||
void AFVClient::outputVolumeStream(const OutputVolumeStreamArgs &args)
|
||||
void CAfvClient::outputVolumeStream(const OutputVolumeStreamArgs &args)
|
||||
{
|
||||
m_outputVolumeStream = args;
|
||||
emit outputVolumePeakVU(m_outputVolumeStream.PeakVU);
|
||||
}
|
||||
|
||||
QString AFVClient::getReceivingCallsignsCom1()
|
||||
QString CAfvClient::getReceivingCallsignsCom1()
|
||||
{
|
||||
if (soundcardSampleProvider)
|
||||
{
|
||||
@@ -391,7 +392,7 @@ namespace BlackCore
|
||||
return {};
|
||||
}
|
||||
|
||||
QString AFVClient::getReceivingCallsignsCom2()
|
||||
QString CAfvClient::getReceivingCallsignsCom2()
|
||||
{
|
||||
if (soundcardSampleProvider)
|
||||
{
|
||||
@@ -400,7 +401,7 @@ namespace BlackCore
|
||||
return {};
|
||||
}
|
||||
|
||||
void AFVClient::updateTransceiversFromContext(const BlackMisc::Simulation::CSimulatedAircraft &aircraft, const BlackMisc::CIdentifier &originator)
|
||||
void CAfvClient::updateTransceiversFromContext(const BlackMisc::Simulation::CSimulatedAircraft &aircraft, const BlackMisc::CIdentifier &originator)
|
||||
{
|
||||
Q_UNUSED(originator);
|
||||
updatePosition(aircraft.latitude().value(CAngleUnit::deg()),
|
||||
@@ -411,12 +412,12 @@ namespace BlackCore
|
||||
updateTransceivers();
|
||||
}
|
||||
|
||||
double AFVClient::getOutputVolumeDb() const
|
||||
double CAfvClient::getOutputVolumeDb() const
|
||||
{
|
||||
return m_outputVolume;
|
||||
}
|
||||
|
||||
void AFVClient::setOutputVolumeDb(double outputVolume)
|
||||
void CAfvClient::setOutputVolumeDb(double outputVolume)
|
||||
{
|
||||
if (outputVolume > 18) { m_outputVolume = 18; }
|
||||
if (outputVolume < -60) { m_outputVolume = -60; }
|
||||
@@ -427,7 +428,7 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
|
||||
AFVClient::ConnectionStatus AFVClient::getConnectionStatus() const
|
||||
CAfvClient::ConnectionStatus CAfvClient::getConnectionStatus() const
|
||||
{
|
||||
return m_connection->isConnected() ? Connected : Disconnected;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace BlackCore
|
||||
namespace Clients
|
||||
{
|
||||
//! AFV client
|
||||
class BLACKCORE_EXPORT AFVClient final : public QObject
|
||||
class BLACKCORE_EXPORT CAfvClient final : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(float inputVolumePeakVU READ getInputVolumePeakVU NOTIFY inputVolumePeakVU)
|
||||
@@ -50,10 +50,10 @@ namespace BlackCore
|
||||
Q_ENUM(ConnectionStatus)
|
||||
|
||||
//! Ctor
|
||||
AFVClient(const QString &apiServer, QObject *parent = nullptr);
|
||||
CAfvClient(const QString &apiServer, QObject *parent = nullptr);
|
||||
|
||||
//! Dtor
|
||||
virtual ~AFVClient()
|
||||
virtual ~CAfvClient() override
|
||||
{
|
||||
stop();
|
||||
}
|
||||
@@ -125,19 +125,19 @@ namespace BlackCore
|
||||
void updateTransceiversFromContext(const BlackMisc::Simulation::CSimulatedAircraft &aircraft, const BlackMisc::CIdentifier &originator);
|
||||
|
||||
static constexpr int c_sampleRate = 48000;
|
||||
static constexpr int frameSize = 960; //20ms
|
||||
static constexpr int frameSize = 960; // 20ms
|
||||
|
||||
// Connection
|
||||
Connection::ClientConnection *m_connection = nullptr;
|
||||
Connection::CClientConnection *m_connection = nullptr;
|
||||
|
||||
// Properties
|
||||
QString m_callsign;
|
||||
|
||||
Audio::Input *m_input = nullptr;
|
||||
Audio::CInput *m_input = nullptr;
|
||||
Audio::Output *m_output = nullptr;
|
||||
|
||||
Audio::SoundcardSampleProvider *soundcardSampleProvider = nullptr;
|
||||
VolumeSampleProvider *outputSampleProvider = nullptr;
|
||||
Audio::CSoundcardSampleProvider *soundcardSampleProvider = nullptr;
|
||||
BlackSound::SampleProvider::CVolumeSampleProvider *outputSampleProvider = nullptr;
|
||||
|
||||
bool m_transmit = false;
|
||||
bool m_transmitHistory = false;
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace BlackCore
|
||||
{
|
||||
namespace Connection
|
||||
{
|
||||
ClientConnection::ClientConnection(const QString &apiServer, QObject *parent) :
|
||||
CClientConnection::CClientConnection(const QString &apiServer, QObject *parent) :
|
||||
QObject(parent),
|
||||
m_apiServerConnection(apiServer, this)
|
||||
{
|
||||
@@ -27,13 +27,13 @@ namespace BlackCore
|
||||
// connect(&m_apiServerConnection, &ApiServerConnection::addCallsignFinished, this, &ClientConnection::addCallsignFinished);
|
||||
// connect(&m_apiServerConnection, &ApiServerConnection::removeCallsignFinished, this, &ClientConnection::removeCallsignFinished);
|
||||
|
||||
connect(&m_voiceServerTimer, &QTimer::timeout, this, &ClientConnection::voiceServerHeartbeat);
|
||||
connect(&m_voiceServerTimer, &QTimer::timeout, this, &CClientConnection::voiceServerHeartbeat);
|
||||
|
||||
connect(&m_udpSocket, &QUdpSocket::readyRead, this, &ClientConnection::readPendingDatagrams);
|
||||
connect(&m_udpSocket, qOverload<QAbstractSocket::SocketError>(&QUdpSocket::error), this, &ClientConnection::handleSocketError);
|
||||
connect(&m_udpSocket, &QUdpSocket::readyRead, this, &CClientConnection::readPendingDatagrams);
|
||||
connect(&m_udpSocket, qOverload<QAbstractSocket::SocketError>(&QUdpSocket::error), this, &CClientConnection::handleSocketError);
|
||||
}
|
||||
|
||||
void ClientConnection::connectTo(const QString &userName, const QString &password, const QString &callsign)
|
||||
void CClientConnection::connectTo(const QString &userName, const QString &password, const QString &callsign)
|
||||
{
|
||||
if (m_connection.m_connected)
|
||||
{
|
||||
@@ -57,7 +57,7 @@ namespace BlackCore
|
||||
qDebug() << "Connected:" << callsign;
|
||||
}
|
||||
|
||||
void ClientConnection::disconnectFrom(const QString &reason)
|
||||
void CClientConnection::disconnectFrom(const QString &reason)
|
||||
{
|
||||
if (! m_connection.m_connected)
|
||||
{
|
||||
@@ -82,27 +82,27 @@ namespace BlackCore
|
||||
qDebug() << "Disconnection complete";
|
||||
}
|
||||
|
||||
bool ClientConnection::receiveAudioDto() const
|
||||
bool CClientConnection::receiveAudioDto() const
|
||||
{
|
||||
return m_receiveAudioDto;
|
||||
}
|
||||
|
||||
void ClientConnection::setReceiveAudioDto(bool receiveAudioDto)
|
||||
void CClientConnection::setReceiveAudioDto(bool receiveAudioDto)
|
||||
{
|
||||
m_receiveAudioDto = receiveAudioDto;
|
||||
}
|
||||
|
||||
void ClientConnection::updateTransceivers(const QString &callsign, const QVector<TransceiverDto> &transceivers)
|
||||
void CClientConnection::updateTransceivers(const QString &callsign, const QVector<TransceiverDto> &transceivers)
|
||||
{
|
||||
m_apiServerConnection.updateTransceivers(callsign, transceivers);
|
||||
}
|
||||
|
||||
QVector<StationDto> ClientConnection::getAllAliasedStations()
|
||||
QVector<StationDto> CClientConnection::getAllAliasedStations()
|
||||
{
|
||||
return m_apiServerConnection.getAllAliasedStations();
|
||||
}
|
||||
|
||||
void ClientConnection::connectToVoiceServer()
|
||||
void CClientConnection::connectToVoiceServer()
|
||||
{
|
||||
QHostAddress localAddress(QHostAddress::AnyIPv4);
|
||||
m_udpSocket.bind(localAddress);
|
||||
@@ -111,14 +111,14 @@ namespace BlackCore
|
||||
qDebug() << "Connected to voice server (" + m_connection.m_tokens.VoiceServer.addressIpV4 << ")";
|
||||
}
|
||||
|
||||
void ClientConnection::disconnectFromVoiceServer()
|
||||
void CClientConnection::disconnectFromVoiceServer()
|
||||
{
|
||||
m_voiceServerTimer.stop();
|
||||
m_udpSocket.disconnectFromHost();
|
||||
qDebug() << "All TaskVoiceServer tasks stopped";
|
||||
}
|
||||
|
||||
void ClientConnection::readPendingDatagrams()
|
||||
void CClientConnection::readPendingDatagrams()
|
||||
{
|
||||
while (m_udpSocket.hasPendingDatagrams())
|
||||
{
|
||||
@@ -127,7 +127,7 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
|
||||
void ClientConnection::processMessage(const QByteArray &messageDdata, bool loopback)
|
||||
void CClientConnection::processMessage(const QByteArray &messageDdata, bool loopback)
|
||||
{
|
||||
CryptoDtoSerializer::Deserializer deserializer = CryptoDtoSerializer::deserialize(*m_connection.voiceCryptoChannel, messageDdata, loopback);
|
||||
|
||||
@@ -151,13 +151,13 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
|
||||
void ClientConnection::handleSocketError(QAbstractSocket::SocketError error)
|
||||
void CClientConnection::handleSocketError(QAbstractSocket::SocketError error)
|
||||
{
|
||||
Q_UNUSED(error);
|
||||
qDebug() << "UDP socket error" << m_udpSocket.errorString();
|
||||
}
|
||||
|
||||
void ClientConnection::voiceServerHeartbeat()
|
||||
void CClientConnection::voiceServerHeartbeat()
|
||||
{
|
||||
QUrl voiceServerUrl("udp://" + m_connection.m_tokens.VoiceServer.addressIpV4);
|
||||
qDebug() << "Sending voice server heartbeat to" << voiceServerUrl.host();
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace BlackCore
|
||||
namespace Connection
|
||||
{
|
||||
//! Client connection
|
||||
class ClientConnection : public QObject
|
||||
class CClientConnection : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace BlackCore
|
||||
};
|
||||
Q_ENUM(ConnectionStatus)
|
||||
|
||||
ClientConnection(const QString &apiServer, QObject *parent = nullptr);
|
||||
CClientConnection(const QString &apiServer, QObject *parent = nullptr);
|
||||
|
||||
void connectTo(const QString &userName, const QString &password, const QString &callsign);
|
||||
void disconnectFrom(const QString &reason = {});
|
||||
@@ -82,7 +82,7 @@ namespace BlackCore
|
||||
const QUuid m_networkVersion = QUuid("3a5ddc6d-cf5d-4319-bd0e-d184f772db80");
|
||||
|
||||
//Data
|
||||
ClientConnectionData m_connection;
|
||||
CClientConnectionData m_connection;
|
||||
|
||||
// Voice server
|
||||
QUdpSocket m_udpSocket;
|
||||
|
||||
@@ -17,27 +17,27 @@ namespace BlackCore
|
||||
{
|
||||
namespace Connection
|
||||
{
|
||||
qint64 ClientConnectionData::secondsSinceAuthentication() const
|
||||
qint64 CClientConnectionData::secondsSinceAuthentication() const
|
||||
{
|
||||
return m_authenticatedDateTimeUtc.secsTo(QDateTime::currentDateTimeUtc());
|
||||
}
|
||||
|
||||
bool ClientConnectionData::isVoiceServerAlive() const
|
||||
bool CClientConnectionData::isVoiceServerAlive() const
|
||||
{
|
||||
return m_lastVoiceServerHeartbeatAckUtc.secsTo(QDateTime::currentDateTimeUtc()) > serverTimeout;
|
||||
}
|
||||
|
||||
void ClientConnectionData::createCryptoChannels()
|
||||
void CClientConnectionData::createCryptoChannels()
|
||||
{
|
||||
if (! m_tokens.isValid)
|
||||
{
|
||||
qWarning() << "Tokens not set";
|
||||
}
|
||||
voiceCryptoChannel.reset(new CryptoDtoChannel(m_tokens.VoiceServer.channelConfig));
|
||||
voiceCryptoChannel.reset(new CCryptoDtoChannel(m_tokens.VoiceServer.channelConfig));
|
||||
// dataCryptoChannel.reset(new CryptoDtoChannel(m_tokens.DataServer.channelConfig));
|
||||
}
|
||||
|
||||
bool ClientConnectionData::voiceServerAlive() const
|
||||
bool CClientConnectionData::voiceServerAlive() const
|
||||
{
|
||||
return timeSinceAuthentication() < serverTimeout ||
|
||||
m_lastVoiceServerHeartbeatAckUtc.secsTo(QDateTime::currentDateTimeUtc()) < serverTimeout;
|
||||
|
||||
@@ -27,9 +27,9 @@ namespace BlackCore
|
||||
namespace Connection
|
||||
{
|
||||
//! Client connection data
|
||||
struct ClientConnectionData
|
||||
struct CClientConnectionData
|
||||
{
|
||||
ClientConnectionData() = default;
|
||||
CClientConnectionData() = default;
|
||||
|
||||
qint64 secondsSinceAuthentication() const;
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace BlackCore
|
||||
|
||||
PostCallsignResponseDto m_tokens;
|
||||
|
||||
QScopedPointer<Crypto::CryptoDtoChannel> voiceCryptoChannel;
|
||||
QScopedPointer<Crypto::CCryptoDtoChannel> voiceCryptoChannel;
|
||||
|
||||
QDateTime m_authenticatedDateTimeUtc;
|
||||
QDateTime m_lastVoiceServerHeartbeatAckUtc;
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace BlackCore
|
||||
{
|
||||
namespace Crypto
|
||||
{
|
||||
CryptoDtoChannel::CryptoDtoChannel(QString channelTag, const QByteArray &aeadReceiveKey, const QByteArray &aeadTransmitKey, int receiveSequenceHistorySize)
|
||||
CCryptoDtoChannel::CCryptoDtoChannel(QString channelTag, const QByteArray &aeadReceiveKey, const QByteArray &aeadTransmitKey, int receiveSequenceHistorySize)
|
||||
{
|
||||
ChannelTag = channelTag;
|
||||
m_aeadReceiveKey = aeadReceiveKey;
|
||||
@@ -27,7 +27,7 @@ namespace BlackCore
|
||||
receiveSequenceHistoryDepth = 0;
|
||||
}
|
||||
|
||||
CryptoDtoChannel::CryptoDtoChannel(CryptoDtoChannelConfigDto channelConfig, int receiveSequenceHistorySize)
|
||||
CCryptoDtoChannel::CCryptoDtoChannel(CryptoDtoChannelConfigDto channelConfig, int receiveSequenceHistorySize)
|
||||
{
|
||||
ChannelTag = channelConfig.channelTag;
|
||||
m_aeadReceiveKey = channelConfig.aeadReceiveKey;
|
||||
@@ -41,7 +41,7 @@ namespace BlackCore
|
||||
receiveSequenceHistoryDepth = 0;
|
||||
}
|
||||
|
||||
QByteArray CryptoDtoChannel::getTransmitKey(CryptoDtoMode mode)
|
||||
QByteArray CCryptoDtoChannel::getTransmitKey(CryptoDtoMode mode)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
@@ -54,7 +54,7 @@ namespace BlackCore
|
||||
return {};
|
||||
}
|
||||
|
||||
QByteArray CryptoDtoChannel::getTransmitKey(CryptoDtoMode mode, uint &sequenceToSend)
|
||||
QByteArray CCryptoDtoChannel::getTransmitKey(CryptoDtoMode mode, uint &sequenceToSend)
|
||||
{
|
||||
sequenceToSend = transmitSequence;
|
||||
transmitSequence++;
|
||||
@@ -71,12 +71,12 @@ namespace BlackCore
|
||||
return {};
|
||||
}
|
||||
|
||||
QString CryptoDtoChannel::getChannelTag() const
|
||||
QString CCryptoDtoChannel::getChannelTag() const
|
||||
{
|
||||
return ChannelTag;
|
||||
}
|
||||
|
||||
QByteArray CryptoDtoChannel::getReceiveKey(CryptoDtoMode mode)
|
||||
QByteArray CCryptoDtoChannel::getReceiveKey(CryptoDtoMode mode)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
@@ -89,7 +89,7 @@ namespace BlackCore
|
||||
return {};
|
||||
}
|
||||
|
||||
bool CryptoDtoChannel::checkReceivedSequence(uint sequenceReceived)
|
||||
bool CCryptoDtoChannel::checkReceivedSequence(uint sequenceReceived)
|
||||
{
|
||||
if (contains(sequenceReceived))
|
||||
{
|
||||
@@ -113,7 +113,7 @@ namespace BlackCore
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CryptoDtoChannel::contains(uint sequence)
|
||||
bool CCryptoDtoChannel::contains(uint sequence)
|
||||
{
|
||||
for (int i = 0; i < receiveSequenceHistoryDepth; i++)
|
||||
{
|
||||
@@ -123,7 +123,7 @@ namespace BlackCore
|
||||
return false;
|
||||
}
|
||||
|
||||
uint CryptoDtoChannel::getMin(int &minIndex)
|
||||
uint CCryptoDtoChannel::getMin(int &minIndex)
|
||||
{
|
||||
uint minValue = std::numeric_limits<uint>::max();
|
||||
minIndex = -1;
|
||||
|
||||
@@ -26,14 +26,14 @@ namespace BlackCore
|
||||
namespace Crypto
|
||||
{
|
||||
//! Crypto channel
|
||||
class CryptoDtoChannel
|
||||
class CCryptoDtoChannel
|
||||
{
|
||||
public:
|
||||
//! Ctor
|
||||
CryptoDtoChannel(QString channelTag, const QByteArray &aeadReceiveKey, const QByteArray &aeadTransmitKey, int receiveSequenceHistorySize = 10);
|
||||
CCryptoDtoChannel(QString channelTag, const QByteArray &aeadReceiveKey, const QByteArray &aeadTransmitKey, int receiveSequenceHistorySize = 10);
|
||||
|
||||
//! Ctor
|
||||
CryptoDtoChannel(CryptoDtoChannelConfigDto channelConfig, int receiveSequenceHistorySize = 10);
|
||||
CCryptoDtoChannel(CryptoDtoChannelConfigDto channelConfig, int receiveSequenceHistorySize = 10);
|
||||
|
||||
QByteArray getTransmitKey(CryptoDtoMode mode);
|
||||
QByteArray getTransmitKey(CryptoDtoMode mode, uint &sequenceToSend);
|
||||
|
||||
@@ -17,12 +17,12 @@ namespace BlackCore
|
||||
{
|
||||
CryptoDtoSerializer::CryptoDtoSerializer() { }
|
||||
|
||||
CryptoDtoSerializer::Deserializer CryptoDtoSerializer::deserialize(CryptoDtoChannel &channel, const QByteArray &bytes, bool loopback)
|
||||
CryptoDtoSerializer::Deserializer CryptoDtoSerializer::deserialize(CCryptoDtoChannel &channel, const QByteArray &bytes, bool loopback)
|
||||
{
|
||||
return Deserializer(channel, bytes, loopback);
|
||||
}
|
||||
|
||||
CryptoDtoSerializer::Deserializer::Deserializer(CryptoDtoChannel &channel, const QByteArray &bytes, bool loopback)
|
||||
CryptoDtoSerializer::Deserializer::Deserializer(CCryptoDtoChannel &channel, const QByteArray &bytes, bool loopback)
|
||||
{
|
||||
QByteArray data(bytes);
|
||||
QBuffer buffer(&data);
|
||||
|
||||
@@ -34,6 +34,7 @@ namespace BlackCore
|
||||
public:
|
||||
CryptoDtoSerializer();
|
||||
|
||||
//! Serialize a DTO
|
||||
template<typename T>
|
||||
static QByteArray Serialize(const QString &channelTag, CryptoDtoMode mode, const QByteArray &transmitKey, uint sequenceToBeSent, T dto)
|
||||
{
|
||||
@@ -105,8 +106,9 @@ namespace BlackCore
|
||||
return {};
|
||||
}
|
||||
|
||||
//! Serialize a DTO
|
||||
template<typename T>
|
||||
static QByteArray Serialize(CryptoDtoChannel &channel, CryptoDtoMode mode, T dto)
|
||||
static QByteArray Serialize(CCryptoDtoChannel &channel, CryptoDtoMode mode, T dto)
|
||||
{
|
||||
uint sequenceToSend = 0;
|
||||
QByteArray transmitKey = channel.getTransmitKey(mode, sequenceToSend);
|
||||
@@ -115,7 +117,7 @@ namespace BlackCore
|
||||
|
||||
struct Deserializer
|
||||
{
|
||||
Deserializer(CryptoDtoChannel &channel, const QByteArray &bytes, bool loopback);
|
||||
Deserializer(CCryptoDtoChannel &channel, const QByteArray &bytes, bool loopback);
|
||||
|
||||
template<typename T>
|
||||
T getDto()
|
||||
@@ -143,7 +145,7 @@ namespace BlackCore
|
||||
bool verified = false;
|
||||
};
|
||||
|
||||
static Deserializer deserialize(CryptoDtoChannel &channel, const QByteArray &bytes, bool loopback);
|
||||
static Deserializer deserialize(CCryptoDtoChannel &channel, const QByteArray &bytes, bool loopback);
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -22,16 +22,19 @@ namespace BlackCore
|
||||
{
|
||||
namespace Afv
|
||||
{
|
||||
struct IMsgPack
|
||||
{ };
|
||||
// struct IMsgPack { };
|
||||
|
||||
//! Channel config DTO
|
||||
struct CryptoDtoChannelConfigDto
|
||||
{
|
||||
//! Properties @{
|
||||
QString channelTag;
|
||||
QByteArray aeadReceiveKey;
|
||||
QByteArray aeadTransmitKey;
|
||||
QByteArray hmacKey;
|
||||
//! @}
|
||||
|
||||
//! To JSON
|
||||
QJsonObject toJson() const
|
||||
{
|
||||
QJsonObject json;
|
||||
@@ -42,6 +45,7 @@ namespace BlackCore
|
||||
return json;
|
||||
}
|
||||
|
||||
//! From JSON
|
||||
static CryptoDtoChannelConfigDto fromJson(const QJsonObject &json)
|
||||
{
|
||||
CryptoDtoChannelConfigDto dto;
|
||||
@@ -54,12 +58,16 @@ namespace BlackCore
|
||||
}
|
||||
};
|
||||
|
||||
//! Voice server DTO
|
||||
struct VoiceServerConnectionDataDto
|
||||
{
|
||||
//! Properties @{
|
||||
QString addressIpV4; // Example: 123.123.123.123:50000
|
||||
QString addressIpV6; // Example: 123.123.123.123:50000
|
||||
CryptoDtoChannelConfigDto channelConfig;
|
||||
//! @}
|
||||
|
||||
//! To JSON
|
||||
QJsonObject toJson() const
|
||||
{
|
||||
QJsonObject json;
|
||||
@@ -69,6 +77,7 @@ namespace BlackCore
|
||||
return json;
|
||||
}
|
||||
|
||||
//! From JSON
|
||||
static VoiceServerConnectionDataDto fromJson(const QJsonObject &json)
|
||||
{
|
||||
VoiceServerConnectionDataDto dto;
|
||||
@@ -79,12 +88,16 @@ namespace BlackCore
|
||||
}
|
||||
};
|
||||
|
||||
//! Callsign DTO
|
||||
struct PostCallsignResponseDto
|
||||
{
|
||||
VoiceServerConnectionDataDto VoiceServer;
|
||||
//! Properties @{
|
||||
// DataServerConnectionDataDto DataServer;
|
||||
VoiceServerConnectionDataDto VoiceServer;
|
||||
bool isValid = false;
|
||||
//! @}
|
||||
|
||||
//! To JSON
|
||||
QJsonObject toJson() const
|
||||
{
|
||||
QJsonObject json;
|
||||
@@ -93,6 +106,7 @@ namespace BlackCore
|
||||
return json;
|
||||
}
|
||||
|
||||
//! From JSON
|
||||
static PostCallsignResponseDto fromJson(const QJsonObject &json)
|
||||
{
|
||||
PostCallsignResponseDto dto;
|
||||
@@ -103,16 +117,20 @@ namespace BlackCore
|
||||
}
|
||||
};
|
||||
|
||||
//! Transceiver DTO
|
||||
struct TransceiverDto
|
||||
{
|
||||
//! Properties @{
|
||||
quint16 id;
|
||||
quint32 frequency;
|
||||
double LatDeg = 0.0;
|
||||
double LonDeg = 0.0;
|
||||
double HeightMslM = 0.0;
|
||||
double HeightAglM = 0.0;
|
||||
//! @}
|
||||
MSGPACK_DEFINE(id, frequency, LatDeg, LonDeg, HeightMslM, HeightAglM)
|
||||
|
||||
//! To JSON
|
||||
QJsonObject toJson() const
|
||||
{
|
||||
QJsonObject json;
|
||||
@@ -125,11 +143,12 @@ namespace BlackCore
|
||||
return json;
|
||||
}
|
||||
|
||||
//! From JSON
|
||||
static TransceiverDto fromJson(const QJsonObject &json)
|
||||
{
|
||||
TransceiverDto dto;
|
||||
dto.id = json.value("id").toInt();
|
||||
dto.frequency = json.value("frequency").toInt();
|
||||
dto.id = static_cast<quint16>(json.value("id").toInt());
|
||||
dto.frequency = static_cast<quint32>(json.value("frequency").toInt());
|
||||
dto.LatDeg = json.value("latDeg").toDouble();
|
||||
dto.LonDeg = json.value("lonDeg").toDouble();
|
||||
dto.HeightMslM = json.value("heightMslM").toDouble();
|
||||
@@ -138,33 +157,39 @@ namespace BlackCore
|
||||
}
|
||||
};
|
||||
|
||||
//! Station DTO
|
||||
struct StationDto
|
||||
{
|
||||
//! Properties @{
|
||||
QUuid id;
|
||||
QString name;
|
||||
quint32 frequency;
|
||||
quint32 frequencyAlias;
|
||||
//! @}
|
||||
|
||||
//! From JSON
|
||||
static StationDto fromJson(const QJsonObject &json)
|
||||
{
|
||||
StationDto dto;
|
||||
dto.id = json.value("id").toString();
|
||||
dto.name = json.value("name").toString();
|
||||
dto.frequency = json.value("frequency").toInt();
|
||||
dto.frequencyAlias = json.value("frequencyAlias").toInt();
|
||||
dto.frequency = static_cast<quint32>(json.value("frequency").toInt());
|
||||
dto.frequencyAlias = static_cast<quint32>(json.value("frequencyAlias").toInt());
|
||||
return dto;
|
||||
}
|
||||
};
|
||||
|
||||
//! Heartbeat DTO
|
||||
struct HeartbeatDto
|
||||
{
|
||||
static QByteArray getDtoName() { return "HeartbeatDto"; }
|
||||
static QByteArray getShortDtoName() { return "H"; }
|
||||
|
||||
std::string callsign;
|
||||
std::string callsign; //!< callsign
|
||||
MSGPACK_DEFINE(callsign)
|
||||
};
|
||||
|
||||
//! Heartbeat DTO
|
||||
struct HeartbeatAckDto
|
||||
{
|
||||
static QByteArray getDtoName() { return "HeartbeatAckDto"; }
|
||||
@@ -172,20 +197,22 @@ namespace BlackCore
|
||||
MSGPACK_DEFINE()
|
||||
};
|
||||
|
||||
//! Receive transceiver DTO
|
||||
struct RxTransceiverDto
|
||||
{
|
||||
//! Properties @{
|
||||
uint16_t id;
|
||||
uint32_t frequency;
|
||||
float distanceRatio;
|
||||
// std::string RelayCallsign;
|
||||
|
||||
//! @}
|
||||
MSGPACK_DEFINE(id, frequency, distanceRatio/*, RelayCallsign*/)
|
||||
};
|
||||
|
||||
//! Transmit transceiver DTO
|
||||
struct TxTransceiverDto
|
||||
{
|
||||
uint16_t id;
|
||||
|
||||
uint16_t id; //!< id
|
||||
MSGPACK_DEFINE(id)
|
||||
};
|
||||
|
||||
@@ -194,11 +221,13 @@ namespace BlackCore
|
||||
static QByteArray getDtoName() { return "AudioTxOnTransceiversDto"; }
|
||||
static QByteArray getShortDtoName() { return "AT"; }
|
||||
|
||||
//! Properties @{
|
||||
std::string callsign;
|
||||
uint sequenceCounter;
|
||||
std::vector<char> audio;
|
||||
bool lastPacket;
|
||||
std::vector<TxTransceiverDto> transceivers;
|
||||
//! @}
|
||||
MSGPACK_DEFINE(callsign, sequenceCounter, audio, lastPacket, transceivers)
|
||||
};
|
||||
|
||||
@@ -207,20 +236,23 @@ namespace BlackCore
|
||||
static QByteArray getDtoName() { return "AudioRxOnTransceiversDto"; }
|
||||
static QByteArray getShortDtoName() { return "AR"; }
|
||||
|
||||
//! Properties @{
|
||||
std::string callsign;
|
||||
uint sequenceCounter;
|
||||
std::vector<char> audio;
|
||||
bool lastPacket;
|
||||
std::vector<RxTransceiverDto> transceivers;
|
||||
//! @}
|
||||
MSGPACK_DEFINE(callsign, sequenceCounter, audio, lastPacket, transceivers)
|
||||
};
|
||||
|
||||
//! Audio DTO
|
||||
struct IAudioDto
|
||||
{
|
||||
QString callsign; // Callsign that audio originates from
|
||||
uint sequenceCounter; // Receiver optionally uses this in reordering algorithm/gap detection
|
||||
QByteArray audio; // Opus compressed audio
|
||||
bool lastPacket; // Used to indicate to receiver that the sender has stopped sending
|
||||
QString callsign; //!< Callsign that audio originates from
|
||||
uint sequenceCounter; //!< Receiver optionally uses this in reordering algorithm/gap detection
|
||||
QByteArray audio; //!< Opus compressed audio
|
||||
bool lastPacket; //!< Used to indicate to receiver that the sender has stopped sending
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
Reference in New Issue
Block a user