mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +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 @{
|
||||
QString getReceivingCallsignsCom1() { return m_afvClient->getReceivingCallsignsCom1(); }
|
||||
QString getReceivingCallsignsCom2() { return m_afvClient->getReceivingCallsignsCom2(); }
|
||||
QString getReceivingCallsignsCom1() { return m_afvClient->getReceivingCallsignsStringCom1(); }
|
||||
QString getReceivingCallsignsCom2() { return m_afvClient->getReceivingCallsignsStringCom2(); }
|
||||
//! @}
|
||||
|
||||
//! \copydoc BlackCore::Afv::Clients::CAfvClient::connectTo
|
||||
|
||||
@@ -62,8 +62,10 @@ namespace BlackCore
|
||||
//! Clean
|
||||
void clear();
|
||||
|
||||
//! Add samples @{
|
||||
void addOpusSamples(const IAudioDto &audioDto, float distanceRatio);
|
||||
void addSilentSamples(const IAudioDto &audioDto);
|
||||
//! @}
|
||||
|
||||
//! Callsign in use
|
||||
bool inUse() const;
|
||||
|
||||
@@ -32,8 +32,8 @@ namespace BlackCore
|
||||
//! Arguments
|
||||
struct TransceiverReceivingCallsignsChangedArgs
|
||||
{
|
||||
quint16 transceiverID;
|
||||
QStringList receivingCallsigns;
|
||||
quint16 transceiverID; //!< transceiver id
|
||||
QStringList receivingCallsigns; //!< callsigns
|
||||
};
|
||||
|
||||
//! 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();
|
||||
}
|
||||
|
||||
BlackMisc::Aviation::CCallsignSet CSoundcardSampleProvider::getReceivingCallsigns(quint16 transceiverID) const
|
||||
{
|
||||
return m_receiverInputs.at(transceiverID)->getReceivingCallsigns();
|
||||
}
|
||||
|
||||
} // ns
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "blacksound/sampleprovider/sampleprovider.h"
|
||||
#include "blacksound/sampleprovider/mixingsampleprovider.h"
|
||||
#include "blackcore/afv/audio/receiversampleprovider.h"
|
||||
#include "blackmisc/aviation/callsignset.h"
|
||||
|
||||
#include <QAudioFormat>
|
||||
#include <QObject>
|
||||
@@ -52,7 +53,10 @@ namespace BlackCore
|
||||
void updateRadioTransceivers(const QVector<TransceiverDto> &radioTransceivers);
|
||||
|
||||
//! 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:
|
||||
//! Changed callsigns
|
||||
|
||||
@@ -269,7 +269,7 @@ namespace BlackCore
|
||||
m_soundcardSampleProvider->deleteLater();
|
||||
}
|
||||
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(); }
|
||||
m_outputSampleProvider = new CVolumeSampleProvider(m_soundcardSampleProvider, this);
|
||||
@@ -747,27 +747,41 @@ namespace BlackCore
|
||||
emit outputVolumePeakVU(args.PeakVU);
|
||||
}
|
||||
|
||||
QString CAfvClient::getReceivingCallsignsCom1() const
|
||||
QString CAfvClient::getReceivingCallsignsStringCom1() const
|
||||
{
|
||||
QMutexLocker lock(&m_mutex);
|
||||
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);
|
||||
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;
|
||||
QMutexLocker lock(&m_mutex);
|
||||
if (!m_soundcardSampleProvider) { return {{ QString(), QString()}}; }
|
||||
coms << m_soundcardSampleProvider->getReceivingCallsigns(0);
|
||||
coms << m_soundcardSampleProvider->getReceivingCallsigns(1);
|
||||
coms << m_soundcardSampleProvider->getReceivingCallsignsString(comUnitToTransceiverId(CComSystem::Com1));
|
||||
coms << m_soundcardSampleProvider->getReceivingCallsignsString(comUnitToTransceiverId(CComSystem::Com2));
|
||||
return coms;
|
||||
}
|
||||
|
||||
@@ -958,6 +972,29 @@ namespace BlackCore
|
||||
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
|
||||
{
|
||||
QMutexLocker lock(&m_mutex);
|
||||
@@ -1015,8 +1052,8 @@ namespace BlackCore
|
||||
QString suffixA;
|
||||
QString prefixB;
|
||||
QString suffixB;
|
||||
getPrefixSuffix(callsign, prefixA, suffixA);
|
||||
getPrefixSuffix(compareTo, prefixB, suffixB);
|
||||
this->getPrefixSuffix(callsign, prefixA, suffixA);
|
||||
this->getPrefixSuffix(compareTo, prefixB, suffixB);
|
||||
return (prefixA == prefixB) && (suffixA == suffixB);
|
||||
}
|
||||
|
||||
|
||||
@@ -53,8 +53,8 @@ namespace BlackCore
|
||||
Q_PROPERTY(double inputVolumePeakVU READ getInputVolumePeakVU NOTIFY inputVolumePeakVU)
|
||||
Q_PROPERTY(double outputVolumePeakVU READ getOutputVolumePeakVU NOTIFY outputVolumePeakVU)
|
||||
Q_PROPERTY(BlackCore::Afv::Clients::CAfvClient::ConnectionStatus connectionStatus READ getConnectionStatus NOTIFY connectionStatusChanged)
|
||||
Q_PROPERTY(QString receivingCallsignsCom1 READ getReceivingCallsignsCom1 NOTIFY receivingCallsignsChanged)
|
||||
Q_PROPERTY(QString receivingCallsignsCom2 READ getReceivingCallsignsCom2 NOTIFY receivingCallsignsChanged)
|
||||
Q_PROPERTY(QString receivingCallsignsCom1 READ getReceivingCallsignsStringCom1 NOTIFY receivingCallsignsChanged)
|
||||
Q_PROPERTY(QString receivingCallsignsCom2 READ getReceivingCallsignsStringCom2 NOTIFY receivingCallsignsChanged)
|
||||
//! @}
|
||||
|
||||
public:
|
||||
@@ -232,9 +232,11 @@ namespace BlackCore
|
||||
//! Callsigns currently received
|
||||
//! \threadsafe
|
||||
//! @{
|
||||
QString getReceivingCallsignsCom1() const;
|
||||
QString getReceivingCallsignsCom2() const;
|
||||
QStringList getReceivingCallsignsCom1Com2() const;
|
||||
QString getReceivingCallsignsStringCom1() const;
|
||||
QString getReceivingCallsignsStringCom2() const;
|
||||
BlackMisc::Aviation::CCallsignSet getReceivingCallsignsCom1() const;
|
||||
BlackMisc::Aviation::CCallsignSet getReceivingCallsignsCom2() const;
|
||||
QStringList getReceivingCallsignsStringCom1Com2() const;
|
||||
//! @}
|
||||
|
||||
//! Update the voice server URL
|
||||
@@ -248,6 +250,10 @@ namespace BlackCore
|
||||
//! \remark callsigns I do receive
|
||||
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
|
||||
void connectionStatusChanged(ConnectionStatus status);
|
||||
|
||||
@@ -285,6 +291,7 @@ namespace BlackCore
|
||||
|
||||
void updateTransceivers(bool updateFrequencies = true);
|
||||
void onUpdateTransceiversFromContext(const BlackMisc::Simulation::CSimulatedAircraft &aircraft, const BlackMisc::CIdentifier &originator);
|
||||
void onReceivingCallsignsChanged(const BlackCore::Afv::Audio::TransceiverReceivingCallsignsChangedArgs &args);
|
||||
|
||||
//! All aliased stations
|
||||
//! \threadsafe
|
||||
@@ -333,7 +340,7 @@ namespace BlackCore
|
||||
std::atomic_bool m_isStarted { false };
|
||||
std::atomic_bool m_loopbackOn { false };
|
||||
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;
|
||||
|
||||
|
||||
@@ -189,14 +189,21 @@ namespace BlackCore
|
||||
|
||||
bool CContextAudioBase::isEnabledComUnit(CComSystem::ComUnit comUnit) const
|
||||
{
|
||||
if (!m_voiceClient) { return false; }
|
||||
return m_voiceClient->isEnabledComUnit(comUnit);
|
||||
}
|
||||
|
||||
bool CContextAudioBase::isTransmittingComUnit(CComSystem::ComUnit comUnit) const
|
||||
{
|
||||
if (!m_voiceClient) { return false; }
|
||||
return m_voiceClient->isTransmittingdComUnit(comUnit);
|
||||
}
|
||||
|
||||
bool CContextAudioBase::isAudioConnected() const
|
||||
{
|
||||
return m_voiceClient && m_voiceClient->isConnected();
|
||||
}
|
||||
|
||||
QString CContextAudioBase::audioRunsWhereInfo() const
|
||||
{
|
||||
static const QString s = QStringLiteral("Audio on '%1', '%2'.").arg(audioRunsWhere().getMachineName(), audioRunsWhere().getProcessName());
|
||||
|
||||
@@ -177,6 +177,9 @@ namespace BlackCore
|
||||
//! Is COM unit transmitting?
|
||||
bool isTransmittingComUnit(BlackMisc::Aviation::CComSystem::ComUnit comUnit) const;
|
||||
|
||||
//! Is audio started
|
||||
bool isAudioConnected() const;
|
||||
|
||||
//! \todo WORKAROUND to hide the "local signals"
|
||||
Afv::Clients::CAfvClient *afvClient() const { return m_voiceClient; }
|
||||
|
||||
|
||||
@@ -21,12 +21,12 @@ namespace BlackMisc
|
||||
{
|
||||
CCallsignSet::CCallsignSet() { }
|
||||
|
||||
CCallsignSet::CCallsignSet(const QStringList &callsigns)
|
||||
CCallsignSet::CCallsignSet(const QStringList &callsigns, CCallsign::TypeHint typeHint)
|
||||
{
|
||||
for (const QString &c : callsigns)
|
||||
{
|
||||
if (c.isEmpty()) { continue; }
|
||||
const CCallsign cs(c);
|
||||
const CCallsign cs = CCallsign(c, typeHint);
|
||||
this->push_back(cs);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace BlackMisc
|
||||
CCallsignSet();
|
||||
|
||||
//! By string list
|
||||
CCallsignSet(const QStringList &callsigns);
|
||||
CCallsignSet(const QStringList &callsigns, CCallsign::TypeHint typeHint = CCallsign::NoHint);
|
||||
|
||||
//! Construct from single callsign
|
||||
CCallsignSet(const CCallsign &callsign);
|
||||
|
||||
Reference in New Issue
Block a user