Ref T730, pass PTT key events to client

* currently passing from context to client, so context and client know the state
* PTT enum in own file so it can be reused
This commit is contained in:
Klaus Basan
2019-09-22 17:10:00 +02:00
committed by Mat Sutcliffe
parent acde5e4f01
commit e21fdeb039
6 changed files with 64 additions and 16 deletions

View File

@@ -16,6 +16,7 @@ using namespace BlackCore::Context;
using namespace BlackCore::Afv::Audio;
using namespace BlackCore::Afv::Connection;
using namespace BlackMisc;
using namespace BlackMisc::Audio;
using namespace BlackMisc::PhysicalQuantities;
using namespace BlackMisc::Simulation;
using namespace BlackSound::SampleProvider;
@@ -302,9 +303,14 @@ namespace BlackCore
qDebug() << "PTT:" << active;
}
void CAfvClient::setPttForCom(bool active, PTTCOM com)
{
this->setPtt(active);
}
void CAfvClient::setInputVolumeDb(double value)
{
if (value > 18) { value = 18; }
if (value > 18) { value = 18; }
if (value < -18) { value = -18; }
m_inputVolumeDb = value;
m_input->setVolume(qPow(10, value / 20));

View File

@@ -16,9 +16,11 @@
#include "blackcore/afv/audio/output.h"
#include "blackcore/afv/audio/soundcardsampleprovider.h"
#include "blackcore/afv/dto.h"
#include "blackcore/blackcoreexport.h"
#include "blackcore/context/contextownaircraft.h"
#include "blackcore/blackcoreexport.h"
#include "blackmisc/audio/ptt.h"
#include "blacksound/sampleprovider/volumesampleprovider.h"
#include <QAudioDeviceInfo>
@@ -87,7 +89,12 @@ namespace BlackCore
void setTransmittingTransceivers(quint16 transceiverID);
void setTransmittingTransceivers(const QVector<TxTransceiverDto> &transceivers);
//! Push to talk @{
Q_INVOKABLE void setPtt(bool active);
void setPttForCom(bool active, BlackMisc::Audio::PTTCOM com);
//! @}
Q_INVOKABLE void setLoopBack(bool on) { m_loopbackOn = on; }
//! Input volume in DB, +-18DB @{

View File

@@ -456,7 +456,7 @@ namespace BlackCore
// changed not yet used, but I keep it for debugging
// changedVoiceRooms called by connectionStatusChanged;
Q_UNUSED(changed);
Q_UNUSED(changed)
}
CCallsignSet CContextAudio::getRoomCallsigns(CComSystem::ComUnit comUnitValue) const
@@ -556,7 +556,7 @@ namespace BlackCore
bool CContextAudio::parseCommandLine(const QString &commandLine, const BlackMisc::CIdentifier &originator)
{
Q_UNUSED(originator);
Q_UNUSED(originator)
if (commandLine.isEmpty()) { return false; }
CSimpleCommandParser parser(
{
@@ -585,8 +585,12 @@ namespace BlackCore
return false;
}
void CContextAudio::setVoiceTransmission(bool enable, COM com)
void CContextAudio::setVoiceTransmission(bool enable, PTTCOM com)
{
m_voiceClient.setPttForCom(enable, com);
/**
// first apporach of T609 multiple COM
QSharedPointer<IVoiceChannel> voiceChannelCom = nullptr;
CComSystem::ComUnit usedUnit = CComSystem::Com1;
@@ -614,6 +618,8 @@ namespace BlackCore
m_audioMixer->removeMixerConnection(IAudioMixer::InputMicrophone, mixerOutputPort);
}
**/
/** fixme KB 201908 to be removed if the above works
if (!m_voiceChannelMapping.contains(CComSystem::Com1)) { return; }
QSharedPointer<IVoiceChannel> voiceChannelCom1 = m_voiceChannelMapping.value(CComSystem::Com1);
@@ -650,7 +656,7 @@ namespace BlackCore
IVoiceChannel::ConnectionStatus oldStatus,
IVoiceChannel::ConnectionStatus newStatus)
{
Q_UNUSED(oldStatus);
Q_UNUSED(oldStatus)
switch (newStatus)
{

View File

@@ -23,6 +23,7 @@
#include "blackmisc/audio/audiodeviceinfolist.h"
#include "blackmisc/audio/notificationsounds.h"
#include "blackmisc/audio/voiceroomlist.h"
#include "blackmisc/audio/ptt.h"
#include "blackmisc/input/actionhotkeydefs.h"
#include "blackmisc/aviation/callsignset.h"
#include "blackmisc/aviation/comsystem.h"
@@ -121,15 +122,6 @@ namespace BlackCore
CContextAudio *registerWithDBus(BlackMisc::CDBusServer *server);
private:
//! Voice COM channel
enum COM
{
COM1,
COM2,
COMActive,
COMUnspecified
};
BlackMisc::Audio::CVoiceRoomList getComVoiceRooms() const;
BlackMisc::Audio::CVoiceRoomList getComVoiceRoomsWithAudioStatus() const;
bool canTalk() const;
@@ -146,7 +138,7 @@ namespace BlackCore
void onConnectionStatusChanged(IVoiceChannel::ConnectionStatus oldStatus, IVoiceChannel::ConnectionStatus newStatus);
//! Enable/disable voice transmission, nornally used with hotkey @{
void setVoiceTransmission(bool enable, COM com);
void setVoiceTransmission(bool enable, BlackMisc::Audio::PTTCOM com);
void setVoiceTransmissionCom1(bool enabled);
void setVoiceTransmissionCom2(bool enabled);
void setVoiceTransmissionComActive(bool enabled);

35
src/blackmisc/audio/ptt.h Normal file
View File

@@ -0,0 +1,35 @@
/* Copyright (C) 2019
* swift project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution. No part of swift project, including this file, may be copied, modified, propagated,
* or distributed except according to the terms contained in the LICENSE file.
*/
//! \file
#ifndef BLACKMISC_AUDIO_PTT_H
#define BLACKMISC_AUDIO_PTT_H
#include <QObject>
namespace BlackMisc
{
namespace Audio
{
//! Voice COM channel
enum PTTCOM
{
COM1,
COM2,
COMActive,
COMUnspecified
};
}
}
Q_DECLARE_METATYPE(BlackMisc::Audio::PTTCOM)
#endif // guard

View File

@@ -8,6 +8,7 @@
#include "registermetadataaudio.h"
#include "audio.h"
#include "ptt.h"
#include <QDBusMetaType>
namespace BlackMisc
@@ -25,6 +26,7 @@ namespace BlackMisc
CVoiceSetup::registerMetadata();
// ENUMs
qDBusRegisterMetaType<PTTCOM>();
qDBusRegisterMetaType<CNotificationSounds::PlayMode>();
qDBusRegisterMetaType<CNotificationSounds::NotificationFlag>();
qRegisterMetaTypeStreamOperators<CNotificationSounds::PlayMode>();