6 #ifndef SWIFT_CORE_CONTEXT_CONTEXTAUDIO_H
7 #define SWIFT_CORE_CONTEXT_CONTEXTAUDIO_H
9 #include <QCommandLineOption>
39 #define SWIFT_CORE_CONTEXTAUDIO_INTERFACENAME "org.swift_project.swift_core.contextaudio"
43 #define SWIFT_CORE_CONTEXTAUDIO_OBJECTPATH "/audio"
45 class QDBusConnection;
53 namespace afv::clients
156 void setRxTx(
bool rx1,
bool tx1,
bool rx2,
bool tx2);
157 void getRxTx(
bool &rx1,
bool &tx1,
bool &rx2,
bool &tx2)
const;
192 bool considerSettings,
int volume = -1);
293 void initVoiceClient();
296 void terminateVoiceClient();
299 void setVoiceTransmission(
bool enable);
302 void changeDeviceSettings();
305 void onChangedAudioSettings();
309 void audioIncreaseVolume(
bool enabled);
310 void audioDecreaseVolume(
bool enabled);
311 void audioIncreaseVolumeCom1(
bool enabled);
312 void audioDecreaseVolumeCom1(
bool enabled);
313 void audioIncreaseVolumeCom2(
bool enabled);
314 void audioDecreaseVolumeCom2(
bool enabled);
322 void onAfvConnectionStatusChanged(
int status);
327 CActionBind m_actionPtt { swift::misc::input::pttHotkeyAction(), swift::misc::input::pttHotkeyIcon(),
this,
328 &CContextAudioBase::setVoiceTransmission };
329 CActionBind m_actionAudioVolumeIncrease { swift::misc::input::audioVolumeIncreaseHotkeyAction(),
330 swift::misc::input::audioVolumeIncreaseHotkeyIcon(),
this,
331 &CContextAudioBase::audioIncreaseVolume };
332 CActionBind m_actionAudioVolumeDecrease { swift::misc::input::audioVolumeDecreaseHotkeyAction(),
333 swift::misc::input::audioVolumeDecreaseHotkeyIcon(),
this,
334 &CContextAudioBase::audioDecreaseVolume };
335 CActionBind m_actionAudioVolumeIncreaseCom1 { swift::misc::input::audioVolumeIncreaseCom1HotkeyAction(),
336 swift::misc::input::audioVolumeIncreaseHotkeyIcon(),
this,
337 &CContextAudioBase::audioIncreaseVolumeCom1 };
338 CActionBind m_actionAudioVolumeDecreaseCom1 { swift::misc::input::audioVolumeDecreaseCom1HotkeyAction(),
339 swift::misc::input::audioVolumeDecreaseHotkeyIcon(),
this,
340 &CContextAudioBase::audioDecreaseVolumeCom1 };
341 CActionBind m_actionAudioVolumeIncreaseCom2 { swift::misc::input::audioVolumeIncreaseCom2HotkeyAction(),
342 swift::misc::input::audioVolumeIncreaseHotkeyIcon(),
this,
343 &CContextAudioBase::audioIncreaseVolumeCom2 };
344 CActionBind m_actionAudioVolumeDecreaseCom2 { swift::misc::input::audioVolumeDecreaseCom2HotkeyAction(),
345 swift::misc::input::audioVolumeDecreaseHotkeyIcon(),
this,
346 &CContextAudioBase::audioDecreaseVolumeCom2 };
348 int m_outMasterVolumeBeforeMute = 50;
349 static constexpr
int MinUnmuteVolume = 20;
352 static bool isRunningWithLocalCore();
356 this, &CContextAudioBase::onChangedAudioSettings
360 this, &CContextAudioBase::changeDeviceSettings
363 this, &CContextAudioBase::changeDeviceSettings
367 afv::clients::CAfvClient *m_voiceClient =
nullptr;
368 bool m_winCoInitialized =
false;
CActionBind binds a member function to an action.
ContextMode
How to handle a given context.
The class providing facades (the contexts) for all DBus relevant operations.
bool parseCommandLine(const QString &commandLine, const swift::misc::CIdentifier &originator)
Parse command line in all contexts.
Audio context base class.
bool isAudioLoopbackEnabled() const
Loopback.
void ptt(bool active, const swift::misc::CIdentifier &identifier)
PTT in voice client received.
bool isAudioConnected() const
Is audio connected?
void enableAudioLoopback(bool enable=true)
Loopback.
bool isOutputMuted() const
Volume.
void gracefulShutdown()
Graceful shutdown.
bool connectAudioWithNetworkCredentials()
Connect to audio with network credentials.
swift::misc::audio::CAudioDeviceInfoList getAudioOutputDevices() const
Audio devices.
bool isAudioStarted() const
Is audio started?
static void registerHelp()
Register the commands.
void setComOutputVolume(swift::misc::aviation::CComSystem::ComUnit comUnit, int volume)
Volume.
bool isTransmittingComUnit(swift::misc::aviation::CComSystem::ComUnit comUnit) const
Is COM unit transmitting?
void changedLocalAudioDevices(const swift::misc::audio::CAudioDeviceInfoList &devices)
Changed audio devices (e.g. device enabled/disable)
swift::misc::audio::CAudioDeviceInfoList getAudioDevices() const
Audio devices.
void changedOutputMute(bool muted)
Output mute changed.
void setCurrentAudioDevices(const swift::misc::audio::CAudioDeviceInfo &inputDevice, const swift::misc::audio::CAudioDeviceInfo &outputDevice)
Set current audio devices.
void setMasterOutputVolume(int volume)
Volume.
QString audioRunsWhereInfo() const
Info string about audio.
void startedAudio(const swift::misc::audio::CAudioDeviceInfo &input, const swift::misc::audio::CAudioDeviceInfo &output)
Audio started with devices.
bool isComUnitIntegrated() const
Integrated with COM unit?
void playSelcalTone(const swift::misc::aviation::CSelcal &selcal)
SELCAL.
swift::misc::audio::CAudioDeviceInfoList getCurrentAudioDevices() const
Get current audio device.
CContextAudioBase(CCoreFacadeConfig::ContextMode mode, CCoreFacade *runtime)
Constructor.
int getComOutputVolume(swift::misc::aviation::CComSystem::ComUnit comUnit) const
Volume.
void stoppedAudio()
Audio stopped.
~CContextAudioBase()
Destructor.
void changedAudioVolume(int volume)
Audio volume changed.
int getMasterOutputVolume() const
Volume.
void setOutputMute(bool muted)
Volume.
bool isAudioEnabled() const
Is audio enabled?
static const QList< QCommandLineOption > & getCmdLineOptions()
Cmd.line arguments.
CContextAudioBase & operator=(CContextAudioBase &&)=delete
Move operations.
CContextAudioBase(CContextAudioBase &&)=delete
Move operations.
bool isEnabledComUnit(swift::misc::aviation::CComSystem::ComUnit comUnit) const
Is COM unit enabled?
void setRxTx(bool rx1, bool tx1, bool rx2, bool tx2)
Receive/transmit.
void getRxTx(bool &rx1, bool &tx1, bool &rx2, bool &tx2) const
Receive/transmit.
static bool isNoAudioSet()
No audio?
CContextAudioBase & operator=(const CContextAudioBase &)=delete
Copy operations.
CContextAudioBase(const CContextAudioBase &)=delete
Copy operations.
void playNotification(swift::misc::audio::CNotificationSounds::NotificationFlag notification, bool considerSettings, int volume=-1)
Notification sounds.
const swift::misc::CIdentifier & audioRunsWhere() const
Audio runs where.
afv::clients::CAfvClient * afvClient() const
swift::misc::audio::CAudioDeviceInfoList getAudioInputDevices() const
Audio devices.
virtual swift::misc::audio::CAudioDeviceInfoList getRegisteredDevices() const =0
All registered devices.
void onChangedLocalDevices(const swift::misc::audio::CAudioDeviceInfoList &devices)
Devices have been changed.
static const QString & InterfaceName()
Interface name.
virtual void unRegisterAudioCallsign(const swift::misc::aviation::CCallsign &callsign, const swift::misc::CIdentifier &identifier)=0
Un-register an audio callsign (used with AFV)
IContextAudio(CCoreFacadeConfig::ContextMode mode, CCoreFacade *runtime)
Constructor.
static IContextAudio * create(CCoreFacade *runtime, CCoreFacadeConfig::ContextMode mode, swift::misc::CDBusServer *server, QDBusConnection &connection)
Factory method.
static const QString & ObjectPath()
Object path.
virtual void registerDevices(const swift::misc::audio::CAudioDeviceInfoList &devices)=0
Register a device on a machine (for core/GUI it will return all known devices on all machines)
virtual void unRegisterDevices(const swift::misc::audio::CAudioDeviceInfoList &devices)=0
Unregister devices.
QString getPathAndContextId() const
Id and path name for round trip protection.
virtual void registerAudioCallsign(const swift::misc::aviation::CCallsign &callsign, const swift::misc::CIdentifier &identifier)=0
Register an audio callsign (used with AFV)
virtual void unRegisterDevicesFor(const swift::misc::CIdentifier &identifier)=0
Remove all devices for identifier (i.e. "a machine")
void voiceClientFailure(const swift::misc::CStatusMessage &msg)
Authentication failed, ....
virtual bool hasRegisteredAudioCallsign(const swift::misc::aviation::CCallsign &callsign) const =0
Un-register an audio callsign (used with AFV)
Base for all context classes.
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...
static void registerCommand(const CommandHtmlHelp &command)
Register a command.
static bool registered(const QString &helpContext)
Help already registered.
Streamable status message, e.g.
Value object encapsulating information of a audio device.
Value object encapsulating a list of audio devices.
Value object encapsulating information of a callsign.
Value object encapsulating information about a connection status.
Player for notification sounds.
#define SWIFT_CORE_CONTEXTAUDIO_INTERFACENAME
DBus interface for context.
Backend services of the swift project, like dealing with the network or the simulators.
Free functions in swift::misc.
NotificationFlag
Play notification.
#define SWIFT_CORE_EXPORT
Export a class or function from the library.