mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-25 02:05:43 +08:00
[AFV] Ref T739, unified callsign functions in CAfvClient
* improved CallsignSet from QStringList * renamed the functions which just return a string * added functions for CCallsignSet
This commit is contained in:
@@ -43,8 +43,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
//! Callsigns currently received @{
|
//! Callsigns currently received @{
|
||||||
QString getReceivingCallsignsCom1() { return m_afvClient->getReceivingCallsignsCom1(); }
|
QString getReceivingCallsignsCom1() { return m_afvClient->getReceivingCallsignsStringCom1(); }
|
||||||
QString getReceivingCallsignsCom2() { return m_afvClient->getReceivingCallsignsCom2(); }
|
QString getReceivingCallsignsCom2() { return m_afvClient->getReceivingCallsignsStringCom2(); }
|
||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
//! \copydoc BlackCore::Afv::Clients::CAfvClient::connectTo
|
//! \copydoc BlackCore::Afv::Clients::CAfvClient::connectTo
|
||||||
|
|||||||
@@ -62,8 +62,10 @@ namespace BlackCore
|
|||||||
//! Clean
|
//! Clean
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
|
//! Add samples @{
|
||||||
void addOpusSamples(const IAudioDto &audioDto, float distanceRatio);
|
void addOpusSamples(const IAudioDto &audioDto, float distanceRatio);
|
||||||
void addSilentSamples(const IAudioDto &audioDto);
|
void addSilentSamples(const IAudioDto &audioDto);
|
||||||
|
//! @}
|
||||||
|
|
||||||
//! Callsign in use
|
//! Callsign in use
|
||||||
bool inUse() const;
|
bool inUse() const;
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ namespace BlackCore
|
|||||||
//! Arguments
|
//! Arguments
|
||||||
struct TransceiverReceivingCallsignsChangedArgs
|
struct TransceiverReceivingCallsignsChangedArgs
|
||||||
{
|
{
|
||||||
quint16 transceiverID;
|
quint16 transceiverID; //!< transceiver id
|
||||||
QStringList receivingCallsigns;
|
QStringList receivingCallsigns; //!< callsigns
|
||||||
};
|
};
|
||||||
|
|
||||||
//! A sample provider
|
//! A sample provider
|
||||||
|
|||||||
@@ -169,11 +169,16 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CSoundcardSampleProvider::getReceivingCallsigns(quint16 transceiverID) const
|
QString CSoundcardSampleProvider::getReceivingCallsignsString(quint16 transceiverID) const
|
||||||
{
|
{
|
||||||
return m_receiverInputs.at(transceiverID)->getReceivingCallsignsString();
|
return m_receiverInputs.at(transceiverID)->getReceivingCallsignsString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BlackMisc::Aviation::CCallsignSet CSoundcardSampleProvider::getReceivingCallsigns(quint16 transceiverID) const
|
||||||
|
{
|
||||||
|
return m_receiverInputs.at(transceiverID)->getReceivingCallsigns();
|
||||||
|
}
|
||||||
|
|
||||||
} // ns
|
} // ns
|
||||||
} // ns
|
} // ns
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
#include "blacksound/sampleprovider/sampleprovider.h"
|
#include "blacksound/sampleprovider/sampleprovider.h"
|
||||||
#include "blacksound/sampleprovider/mixingsampleprovider.h"
|
#include "blacksound/sampleprovider/mixingsampleprovider.h"
|
||||||
#include "blackcore/afv/audio/receiversampleprovider.h"
|
#include "blackcore/afv/audio/receiversampleprovider.h"
|
||||||
|
#include "blackmisc/aviation/callsignset.h"
|
||||||
|
|
||||||
#include <QAudioFormat>
|
#include <QAudioFormat>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
@@ -52,7 +53,10 @@ namespace BlackCore
|
|||||||
void updateRadioTransceivers(const QVector<TransceiverDto> &radioTransceivers);
|
void updateRadioTransceivers(const QVector<TransceiverDto> &radioTransceivers);
|
||||||
|
|
||||||
//! Receiving callsign as single string
|
//! Receiving callsign as single string
|
||||||
QString getReceivingCallsigns(quint16 transceiverID) const;
|
QString getReceivingCallsignsString(quint16 transceiverID) const;
|
||||||
|
|
||||||
|
//! Receiving callsign as single string
|
||||||
|
BlackMisc::Aviation::CCallsignSet getReceivingCallsigns(quint16 transceiverID) const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
//! Changed callsigns
|
//! Changed callsigns
|
||||||
|
|||||||
@@ -269,7 +269,7 @@ namespace BlackCore
|
|||||||
m_soundcardSampleProvider->deleteLater();
|
m_soundcardSampleProvider->deleteLater();
|
||||||
}
|
}
|
||||||
m_soundcardSampleProvider = new CSoundcardSampleProvider(SampleRate, allTransceiverIds(), this);
|
m_soundcardSampleProvider = new CSoundcardSampleProvider(SampleRate, allTransceiverIds(), this);
|
||||||
connect(m_soundcardSampleProvider, &CSoundcardSampleProvider::receivingCallsignsChanged, this, &CAfvClient::receivingCallsignsChanged);
|
connect(m_soundcardSampleProvider, &CSoundcardSampleProvider::receivingCallsignsChanged, this, &CAfvClient::onReceivingCallsignsChanged);
|
||||||
|
|
||||||
if (m_outputSampleProvider) { m_outputSampleProvider->deleteLater(); }
|
if (m_outputSampleProvider) { m_outputSampleProvider->deleteLater(); }
|
||||||
m_outputSampleProvider = new CVolumeSampleProvider(m_soundcardSampleProvider, this);
|
m_outputSampleProvider = new CVolumeSampleProvider(m_soundcardSampleProvider, this);
|
||||||
@@ -747,27 +747,41 @@ namespace BlackCore
|
|||||||
emit outputVolumePeakVU(args.PeakVU);
|
emit outputVolumePeakVU(args.PeakVU);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CAfvClient::getReceivingCallsignsCom1() const
|
QString CAfvClient::getReceivingCallsignsStringCom1() const
|
||||||
{
|
{
|
||||||
QMutexLocker lock(&m_mutex);
|
QMutexLocker lock(&m_mutex);
|
||||||
if (!m_soundcardSampleProvider) return {};
|
if (!m_soundcardSampleProvider) return {};
|
||||||
return m_soundcardSampleProvider->getReceivingCallsigns(0);
|
return m_soundcardSampleProvider->getReceivingCallsignsString(comUnitToTransceiverId(CComSystem::Com1));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CAfvClient::getReceivingCallsignsCom2() const
|
QString CAfvClient::getReceivingCallsignsStringCom2() const
|
||||||
{
|
{
|
||||||
QMutexLocker lock(&m_mutex);
|
QMutexLocker lock(&m_mutex);
|
||||||
if (!m_soundcardSampleProvider) return {};
|
if (!m_soundcardSampleProvider) return {};
|
||||||
return m_soundcardSampleProvider->getReceivingCallsigns(1);
|
return m_soundcardSampleProvider->getReceivingCallsignsString(comUnitToTransceiverId(CComSystem::Com2));
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList CAfvClient::getReceivingCallsignsCom1Com2() const
|
CCallsignSet CAfvClient::getReceivingCallsignsCom1() const
|
||||||
|
{
|
||||||
|
QMutexLocker lock(&m_mutex);
|
||||||
|
if (!m_soundcardSampleProvider) return {};
|
||||||
|
return m_soundcardSampleProvider->getReceivingCallsigns(comUnitToTransceiverId(CComSystem::Com1));
|
||||||
|
}
|
||||||
|
|
||||||
|
CCallsignSet CAfvClient::getReceivingCallsignsCom2() const
|
||||||
|
{
|
||||||
|
QMutexLocker lock(&m_mutex);
|
||||||
|
if (!m_soundcardSampleProvider) return {};
|
||||||
|
return m_soundcardSampleProvider->getReceivingCallsigns(comUnitToTransceiverId(CComSystem::Com2));
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList CAfvClient::getReceivingCallsignsStringCom1Com2() const
|
||||||
{
|
{
|
||||||
QStringList coms;
|
QStringList coms;
|
||||||
QMutexLocker lock(&m_mutex);
|
QMutexLocker lock(&m_mutex);
|
||||||
if (!m_soundcardSampleProvider) { return {{ QString(), QString()}}; }
|
if (!m_soundcardSampleProvider) { return {{ QString(), QString()}}; }
|
||||||
coms << m_soundcardSampleProvider->getReceivingCallsigns(0);
|
coms << m_soundcardSampleProvider->getReceivingCallsignsString(comUnitToTransceiverId(CComSystem::Com1));
|
||||||
coms << m_soundcardSampleProvider->getReceivingCallsigns(1);
|
coms << m_soundcardSampleProvider->getReceivingCallsignsString(comUnitToTransceiverId(CComSystem::Com2));
|
||||||
return coms;
|
return coms;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -958,6 +972,29 @@ namespace BlackCore
|
|||||||
this->updateFromOwnAircraft(aircraft);
|
this->updateFromOwnAircraft(aircraft);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CAfvClient::onReceivingCallsignsChanged(const TransceiverReceivingCallsignsChangedArgs &args)
|
||||||
|
{
|
||||||
|
const CComSystem::ComUnit unit = transceiverIdToComUnit(args.transceiverID);
|
||||||
|
CCallsignSet callsignsCom1;
|
||||||
|
CCallsignSet callsignsCom2;
|
||||||
|
switch (unit)
|
||||||
|
{
|
||||||
|
case CComSystem::Com1:
|
||||||
|
default:
|
||||||
|
callsignsCom1 = CCallsignSet(args.receivingCallsigns);
|
||||||
|
callsignsCom2 = this->getReceivingCallsignsCom2();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CComSystem::Com2:
|
||||||
|
callsignsCom2 = CCallsignSet(args.receivingCallsigns);
|
||||||
|
callsignsCom1 = this->getReceivingCallsignsCom1();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
emit this->receivedCallsignsChanged(callsignsCom1, callsignsCom2);
|
||||||
|
emit this->receivingCallsignsChanged(args);
|
||||||
|
}
|
||||||
|
|
||||||
QVector<StationDto> CAfvClient::getAliasedStations() const
|
QVector<StationDto> CAfvClient::getAliasedStations() const
|
||||||
{
|
{
|
||||||
QMutexLocker lock(&m_mutex);
|
QMutexLocker lock(&m_mutex);
|
||||||
@@ -1015,8 +1052,8 @@ namespace BlackCore
|
|||||||
QString suffixA;
|
QString suffixA;
|
||||||
QString prefixB;
|
QString prefixB;
|
||||||
QString suffixB;
|
QString suffixB;
|
||||||
getPrefixSuffix(callsign, prefixA, suffixA);
|
this->getPrefixSuffix(callsign, prefixA, suffixA);
|
||||||
getPrefixSuffix(compareTo, prefixB, suffixB);
|
this->getPrefixSuffix(compareTo, prefixB, suffixB);
|
||||||
return (prefixA == prefixB) && (suffixA == suffixB);
|
return (prefixA == prefixB) && (suffixA == suffixB);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,8 +53,8 @@ namespace BlackCore
|
|||||||
Q_PROPERTY(double inputVolumePeakVU READ getInputVolumePeakVU NOTIFY inputVolumePeakVU)
|
Q_PROPERTY(double inputVolumePeakVU READ getInputVolumePeakVU NOTIFY inputVolumePeakVU)
|
||||||
Q_PROPERTY(double outputVolumePeakVU READ getOutputVolumePeakVU NOTIFY outputVolumePeakVU)
|
Q_PROPERTY(double outputVolumePeakVU READ getOutputVolumePeakVU NOTIFY outputVolumePeakVU)
|
||||||
Q_PROPERTY(BlackCore::Afv::Clients::CAfvClient::ConnectionStatus connectionStatus READ getConnectionStatus NOTIFY connectionStatusChanged)
|
Q_PROPERTY(BlackCore::Afv::Clients::CAfvClient::ConnectionStatus connectionStatus READ getConnectionStatus NOTIFY connectionStatusChanged)
|
||||||
Q_PROPERTY(QString receivingCallsignsCom1 READ getReceivingCallsignsCom1 NOTIFY receivingCallsignsChanged)
|
Q_PROPERTY(QString receivingCallsignsCom1 READ getReceivingCallsignsStringCom1 NOTIFY receivingCallsignsChanged)
|
||||||
Q_PROPERTY(QString receivingCallsignsCom2 READ getReceivingCallsignsCom2 NOTIFY receivingCallsignsChanged)
|
Q_PROPERTY(QString receivingCallsignsCom2 READ getReceivingCallsignsStringCom2 NOTIFY receivingCallsignsChanged)
|
||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -232,9 +232,11 @@ namespace BlackCore
|
|||||||
//! Callsigns currently received
|
//! Callsigns currently received
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
//! @{
|
//! @{
|
||||||
QString getReceivingCallsignsCom1() const;
|
QString getReceivingCallsignsStringCom1() const;
|
||||||
QString getReceivingCallsignsCom2() const;
|
QString getReceivingCallsignsStringCom2() const;
|
||||||
QStringList getReceivingCallsignsCom1Com2() const;
|
BlackMisc::Aviation::CCallsignSet getReceivingCallsignsCom1() const;
|
||||||
|
BlackMisc::Aviation::CCallsignSet getReceivingCallsignsCom2() const;
|
||||||
|
QStringList getReceivingCallsignsStringCom1Com2() const;
|
||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
//! Update the voice server URL
|
//! Update the voice server URL
|
||||||
@@ -248,6 +250,10 @@ namespace BlackCore
|
|||||||
//! \remark callsigns I do receive
|
//! \remark callsigns I do receive
|
||||||
void receivingCallsignsChanged(const BlackCore::Afv::Audio::TransceiverReceivingCallsignsChangedArgs &args);
|
void receivingCallsignsChanged(const BlackCore::Afv::Audio::TransceiverReceivingCallsignsChangedArgs &args);
|
||||||
|
|
||||||
|
//! Received callsigns have been changed
|
||||||
|
//! \remark swift style per com units
|
||||||
|
void receivedCallsignsChanged(const BlackMisc::Aviation::CCallsignSet &com1Callsigns, const BlackMisc::Aviation::CCallsignSet &com2Callsigns);
|
||||||
|
|
||||||
//! Connection status has been changed
|
//! Connection status has been changed
|
||||||
void connectionStatusChanged(ConnectionStatus status);
|
void connectionStatusChanged(ConnectionStatus status);
|
||||||
|
|
||||||
@@ -285,6 +291,7 @@ namespace BlackCore
|
|||||||
|
|
||||||
void updateTransceivers(bool updateFrequencies = true);
|
void updateTransceivers(bool updateFrequencies = true);
|
||||||
void onUpdateTransceiversFromContext(const BlackMisc::Simulation::CSimulatedAircraft &aircraft, const BlackMisc::CIdentifier &originator);
|
void onUpdateTransceiversFromContext(const BlackMisc::Simulation::CSimulatedAircraft &aircraft, const BlackMisc::CIdentifier &originator);
|
||||||
|
void onReceivingCallsignsChanged(const BlackCore::Afv::Audio::TransceiverReceivingCallsignsChangedArgs &args);
|
||||||
|
|
||||||
//! All aliased stations
|
//! All aliased stations
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
@@ -333,7 +340,7 @@ namespace BlackCore
|
|||||||
std::atomic_bool m_isStarted { false };
|
std::atomic_bool m_isStarted { false };
|
||||||
std::atomic_bool m_loopbackOn { false };
|
std::atomic_bool m_loopbackOn { false };
|
||||||
std::atomic_bool m_winCoInitialized { false }; //!< Windows only CoInitializeEx
|
std::atomic_bool m_winCoInitialized { false }; //!< Windows only CoInitializeEx
|
||||||
std::atomic_bool m_integratedComUnit {false}; //!< is COM unit sychronized, integrated
|
std::atomic_bool m_integratedComUnit { false }; //!< is COM unit sychronized, integrated
|
||||||
|
|
||||||
QDateTime m_startDateTimeUtc;
|
QDateTime m_startDateTimeUtc;
|
||||||
|
|
||||||
|
|||||||
@@ -189,14 +189,21 @@ namespace BlackCore
|
|||||||
|
|
||||||
bool CContextAudioBase::isEnabledComUnit(CComSystem::ComUnit comUnit) const
|
bool CContextAudioBase::isEnabledComUnit(CComSystem::ComUnit comUnit) const
|
||||||
{
|
{
|
||||||
|
if (!m_voiceClient) { return false; }
|
||||||
return m_voiceClient->isEnabledComUnit(comUnit);
|
return m_voiceClient->isEnabledComUnit(comUnit);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CContextAudioBase::isTransmittingComUnit(CComSystem::ComUnit comUnit) const
|
bool CContextAudioBase::isTransmittingComUnit(CComSystem::ComUnit comUnit) const
|
||||||
{
|
{
|
||||||
|
if (!m_voiceClient) { return false; }
|
||||||
return m_voiceClient->isTransmittingdComUnit(comUnit);
|
return m_voiceClient->isTransmittingdComUnit(comUnit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CContextAudioBase::isAudioConnected() const
|
||||||
|
{
|
||||||
|
return m_voiceClient && m_voiceClient->isConnected();
|
||||||
|
}
|
||||||
|
|
||||||
QString CContextAudioBase::audioRunsWhereInfo() const
|
QString CContextAudioBase::audioRunsWhereInfo() const
|
||||||
{
|
{
|
||||||
static const QString s = QStringLiteral("Audio on '%1', '%2'.").arg(audioRunsWhere().getMachineName(), audioRunsWhere().getProcessName());
|
static const QString s = QStringLiteral("Audio on '%1', '%2'.").arg(audioRunsWhere().getMachineName(), audioRunsWhere().getProcessName());
|
||||||
|
|||||||
@@ -177,6 +177,9 @@ namespace BlackCore
|
|||||||
//! Is COM unit transmitting?
|
//! Is COM unit transmitting?
|
||||||
bool isTransmittingComUnit(BlackMisc::Aviation::CComSystem::ComUnit comUnit) const;
|
bool isTransmittingComUnit(BlackMisc::Aviation::CComSystem::ComUnit comUnit) const;
|
||||||
|
|
||||||
|
//! Is audio started
|
||||||
|
bool isAudioConnected() const;
|
||||||
|
|
||||||
//! \todo WORKAROUND to hide the "local signals"
|
//! \todo WORKAROUND to hide the "local signals"
|
||||||
Afv::Clients::CAfvClient *afvClient() const { return m_voiceClient; }
|
Afv::Clients::CAfvClient *afvClient() const { return m_voiceClient; }
|
||||||
|
|
||||||
|
|||||||
@@ -21,12 +21,12 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
CCallsignSet::CCallsignSet() { }
|
CCallsignSet::CCallsignSet() { }
|
||||||
|
|
||||||
CCallsignSet::CCallsignSet(const QStringList &callsigns)
|
CCallsignSet::CCallsignSet(const QStringList &callsigns, CCallsign::TypeHint typeHint)
|
||||||
{
|
{
|
||||||
for (const QString &c : callsigns)
|
for (const QString &c : callsigns)
|
||||||
{
|
{
|
||||||
if (c.isEmpty()) { continue; }
|
if (c.isEmpty()) { continue; }
|
||||||
const CCallsign cs(c);
|
const CCallsign cs = CCallsign(c, typeHint);
|
||||||
this->push_back(cs);
|
this->push_back(cs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ namespace BlackMisc
|
|||||||
CCallsignSet();
|
CCallsignSet();
|
||||||
|
|
||||||
//! By string list
|
//! By string list
|
||||||
CCallsignSet(const QStringList &callsigns);
|
CCallsignSet(const QStringList &callsigns, CCallsign::TypeHint typeHint = CCallsign::NoHint);
|
||||||
|
|
||||||
//! Construct from single callsign
|
//! Construct from single callsign
|
||||||
CCallsignSet(const CCallsign &callsign);
|
CCallsignSet(const CCallsign &callsign);
|
||||||
|
|||||||
Reference in New Issue
Block a user