6 #ifndef SWIFT_CORE_AFV_CLIENTS_AFVCLIENT_H
7 #define SWIFT_CORE_AFV_CLIENTS_AFVCLIENT_H
30 namespace swift::core::afv::clients
39 Q_PROPERTY(
double inputVolumePeakVU READ getInputVolumePeakVU NOTIFY inputVolumePeakVU)
40 Q_PROPERTY(
double outputVolumePeakVU READ getOutputVolumePeakVU NOTIFY outputVolumePeakVU)
42 NOTIFY connectionStatusChanged)
43 Q_PROPERTY(QString receivingCallsignsCom1 READ getReceivingCallsignsStringCom1 NOTIFY receivingCallsignsChanged)
44 Q_PROPERTY(QString receivingCallsignsCom2 READ getReceivingCallsignsStringCom2 NOTIFY receivingCallsignsChanged)
49 static const QStringList &getLogCategories();
57 Q_ENUM(ConnectionStatus)
60 CAfvClient(
const QString &apiServer, QObject *owner);
80 QString getCallsign()
const;
81 void setCallsign(
const QString &getCallsign);
86 bool isConnected()
const;
95 Q_INVOKABLE
void connectTo(
const QString &cid,
const QString &password,
const QString &callsign,
96 const QString &client);
102 void disconnectFrom(
bool stop);
109 Q_INVOKABLE QStringList availableInputDevices()
const;
110 Q_INVOKABLE QStringList availableOutputDevices()
const;
114 Q_INVOKABLE
void setBypassEffects(
bool value);
122 bool isOutputMuted()
const;
123 void setOutputMuted(
bool mute);
131 Q_INVOKABLE
void startAudio(
const QString &inputDeviceName,
const QString &outputDeviceName);
152 void setReceiveAudio(
bool receive);
157 Q_INVOKABLE
void enableTransceiver(quint16
id,
bool enable);
159 bool isEnabledTransceiver(quint16
id)
const;
166 void setTransmittingTransceiver(quint16 transceiverID);
168 void setTransmittingTransceivers(
const QVector<TxTransceiverDto> &transceivers);
174 bool isTransmittingTransceiver(quint16
id)
const;
181 void setRxTx(
bool rx1,
bool tx1,
bool rx2,
bool tx2);
182 void getRxTx(
bool &rx1,
bool &tx1,
bool &rx2,
bool &tx2)
const;
188 QVector<TransceiverDto> getTransceivers()
const;
189 QVector<TxTransceiverDto> getTransmittingTransceivers()
const;
190 QSet<quint16> getEnabledTransceivers()
const;
196 Q_INVOKABLE
void updateComFrequency(quint16
id, quint32 frequencyHz);
205 Q_INVOKABLE
void updatePosition(
double latitudeDeg,
double longitudeDeg,
double heightMeters);
211 bool withSignals =
true);
215 Q_INVOKABLE
void setPtt(
bool active);
227 double getInputVolumeDb()
const;
228 Q_INVOKABLE
bool setInputVolumeDb(
double valueDb);
245 int getNormalizedInputVolume()
const;
247 int getNormalizedMasterOutputVolume()
const;
248 bool setNormalizedInputVolume(
int volume);
250 bool setNormalizedMasterOutputVolume(
int volume);
256 double getInputVolumePeakVU()
const;
257 double getOutputVolumePeakVU()
const;
272 QString getReceivingCallsignsStringCom1()
const;
273 QString getReceivingCallsignsStringCom2()
const;
276 QStringList getReceivingCallsignsStringCom1Com2()
const;
280 bool updateVoiceServerUrl(
const QString &url);
283 void gracefulShutdown();
325 void initialize()
override;
328 void cleanup()
override;
336 void onTimerUpdate();
337 void onSettingsChanged();
338 void autoLogoffWithoutFsdNetwork();
340 void updateTransceivers(
bool updateFrequencies =
true);
346 void retryConnectTo(
const QString &cid,
const QString &password,
const QString &callsign,
const QString &client,
347 const QString &reason);
350 void reconnectTo(
const QString &cid,
const QString &password,
const QString &callsign,
const QString &client,
355 void toggleTransmissionCapability(
bool disableTransmission);
360 QVector<StationDto> getAliasedStations()
const;
361 void setAliasedStations(
const QVector<StationDto> &stations);
366 quint32 getAliasFrequencyHz(quint32 frequencyHz)
const;
370 bool isVoiceServerAlive()
const;
374 const QString &getVoiceServerUrl()
const;
376 bool fuzzyMatchCallsign(
const QString &callsign,
const QString &compareTo)
const;
377 void getPrefixSuffix(
const QString &callsign, QString &prefix, QString &suffix)
const;
379 static constexpr
int PositionUpdatesMs = 20000;
380 static constexpr
int SampleRate = 48000;
381 static constexpr
int FrameSize =
static_cast<int>(SampleRate * 0.02);
382 static constexpr
double MinDbIn = -18.0;
383 static constexpr
double MaxDbIn = 18.0;
384 static constexpr
double MinDbOut = -60.0;
385 static constexpr
double MaxDbOut = 18.0;
386 static constexpr quint32 UniCom = 122800000;
401 std::atomic_bool m_transmit {
false };
402 std::atomic_bool m_transmitHistory {
false };
403 std::atomic_bool m_disableTransmissionCapability {
false };
404 QVector<TxTransceiverDto> m_transmittingTransceivers;
405 QVector<TransceiverDto> m_transceivers;
406 QSet<quint16> m_enabledTransceivers;
407 static const QVector<quint16> &allTransceiverIds()
409 static const QVector<quint16> transceiverIds { 0, 1 };
410 return transceiverIds;
413 std::atomic_int m_fsdConnectMismatches { 0 };
414 std::atomic_int m_retryConnectAttempt { 0 };
415 std::atomic_int m_heartBeatFailures { 0 };
416 std::atomic_bool m_isStarted {
false };
417 std::atomic_bool m_loopbackOn {
false };
418 std::atomic_bool m_winCoInitialized {
false };
419 std::atomic_bool m_integratedComUnit {
false };
421 double m_inputVolumeDb = 0.0;
422 int m_outputMasterVolumeNormalized = 0;
423 int m_outputVolumeCom1Normalized = 0;
424 int m_outputVolumeCom2Normalized = 0;
425 double m_outputVolumeDbCom1 = 0.0;
426 double m_outputGainRatioCom1 = 1.0;
427 double m_outputVolumeDbCom2 = 0.0;
428 double m_outputGainRatioCom2 = 1.0;
429 double m_maxDbReadingInPTTInterval = -100;
431 QTimer *m_voiceServerTimer =
nullptr;
432 QVector<StationDto> m_aliasedStations;
434 audio::InputVolumeStreamArgs m_inputVolumeStream;
435 audio::OutputVolumeStreamArgs m_outputVolumeStream;
437 void checkServerHeartbeat();
439 void initTransceivers();
440 void connectWithContexts();
441 void fetchSimulatorSettings();
442 static bool hasContexts();
444 std::atomic_bool m_connectedWithContext {
false };
446 mutable QRecursiveMutex m_mutex;
447 mutable QRecursiveMutex m_mutexInputStream;
448 mutable QRecursiveMutex m_mutexOutputStream;
449 mutable QRecursiveMutex m_mutexTransceivers;
450 mutable QRecursiveMutex m_mutexCallsign;
451 mutable QRecursiveMutex m_mutexConnection;
452 mutable QRecursiveMutex m_mutexVolume;
453 mutable QRecursiveMutex m_mutexSampleProviders;
void ptt(bool active, const swift::misc::CIdentifier &identifier)
PTT status in this particular AFV client.
CAfvClient(const CAfvClient &)=delete
Copy operations.
void changedOutputMute(bool muted)
Output mute changed.
ConnectionStatus
Connection status.
CAfvClient & operator=(const CAfvClient &&)=delete
Copy operations.
Q_INVOKABLE bool isLoopback() const
Loopback.
void updatedFromOwnAircraftCockpit()
Client updated from own aicraft data.
void afvConnectionFailure(const swift::misc::CStatusMessage &msg)
Authentication has failed with AFV server.
CAfvClient & operator=(const CAfvClient &)=delete
Copy operations.
void stoppedAudio()
Audio has been stopped.
CAfvClient(const CAfvClient &&)=delete
}@
Q_INVOKABLE void disconnectFrom()
Disconnect from network.
void startedAudio(const swift::misc::audio::CAudioDeviceInfo &inputDevice, const swift::misc::audio::CAudioDeviceInfo &outputDevice)
Started audio with devices.
bool isStarted() const
Client started?
void receivedCallsignsChanged(const swift::misc::aviation::CCallsignSet &com1Callsigns, const swift::misc::aviation::CCallsignSet &com2Callsigns)
Received callsigns have been changed.
void outputVolumePeakVU(double value)
VU levels.
void inputVolumePeakVU(double value)
VU levels.
void connectionStatusChanged(ConnectionStatus status)
Connection status has been changed.
Q_INVOKABLE void setLoopBack(bool on)
Loopback.
void receivingCallsignsChanged(const swift::core::afv::audio::TransceiverReceivingCallsignsChangedArgs &args)
Receiving callsigns have been changed.
bool isComUnitIntegrated() const
Is integrated with COM unit.
void disconnectFromAndStop()
Disconnect from network.
Base class for a long-lived worker object which lives in its own thread.
Base class with a member CIdentifier to be inherited by a class which has an identity in the environm...
Value object encapsulating information identifying a component of a modular distributed swift process...
Streamable status message, e.g.
Value object encapsulating information of a audio device.
Value object for a set of callsigns.
Comprehensive information of an aircraft.
AudioRxOnTransceiversDto.
#define SWIFT_CORE_EXPORT
Export a class or function from the library.