mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 06:45:37 +08:00
[AFV] First version of threaded CAfvClient
This commit is contained in:
committed by
Mat Sutcliffe
parent
d1006160f8
commit
d3a1eb1d60
15
samples/afvclient/afvclientbridge.cpp
Normal file
15
samples/afvclient/afvclientbridge.cpp
Normal file
@@ -0,0 +1,15 @@
|
||||
#include "afvclientbridge.h"
|
||||
|
||||
using namespace BlackCore::Afv::Clients;
|
||||
|
||||
CAfvClientBridge::CAfvClientBridge(CAfvClient *afvClient, QObject *parent) :
|
||||
QObject(parent),
|
||||
m_afvClient(afvClient)
|
||||
{
|
||||
connect(afvClient, &CAfvClient::receivingCallsignsChanged, this, &CAfvClientBridge::receivingCallsignsChanged);
|
||||
connect(afvClient, &CAfvClient::connectionStatusChanged, this, &CAfvClientBridge::connectionStatusChanged);
|
||||
connect(afvClient, &CAfvClient::updatedFromOwnAircraftCockpit, this, &CAfvClientBridge::updatedFromOwnAircraftCockpit);
|
||||
connect(afvClient, &CAfvClient::ptt, this, &CAfvClientBridge::ptt);
|
||||
connect(afvClient, &CAfvClient::inputVolumePeakVU, this, &CAfvClientBridge::inputVolumePeakVU);
|
||||
connect(afvClient, &CAfvClient::outputVolumePeakVU, this, &CAfvClientBridge::outputVolumePeakVU);
|
||||
}
|
||||
97
samples/afvclient/afvclientbridge.h
Normal file
97
samples/afvclient/afvclientbridge.h
Normal file
@@ -0,0 +1,97 @@
|
||||
#ifndef AFVCLIENTBRIDGE_H
|
||||
#define AFVCLIENTBRIDGE_H
|
||||
|
||||
#include "blackcore/afv/clients/afvclient.h"
|
||||
#include <QObject>
|
||||
|
||||
class CAfvClientBridge : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
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)
|
||||
|
||||
public:
|
||||
CAfvClientBridge(BlackCore::Afv::Clients::CAfvClient *afvClient, QObject *parent = nullptr);
|
||||
|
||||
double getInputVolumePeakVU() const { return m_afvClient->getInputVolumePeakVU(); }
|
||||
double getOutputVolumePeakVU() const { return m_afvClient->getOutputVolumePeakVU(); }
|
||||
|
||||
BlackCore::Afv::Clients::CAfvClient::ConnectionStatus getConnectionStatus() const
|
||||
{
|
||||
return m_afvClient->getConnectionStatus();
|
||||
}
|
||||
|
||||
QString getReceivingCallsignsCom1() { return m_afvClient->getReceivingCallsignsCom1(); }
|
||||
QString getReceivingCallsignsCom2() { return m_afvClient->getReceivingCallsignsCom2(); }
|
||||
|
||||
Q_INVOKABLE void connectTo(const QString &cid, const QString &password, const QString &callsign)
|
||||
{
|
||||
m_afvClient->connectTo(cid, password, callsign);
|
||||
}
|
||||
|
||||
Q_INVOKABLE void disconnectFrom() { m_afvClient->disconnectFrom(); }
|
||||
|
||||
//! Audio devices @{
|
||||
Q_INVOKABLE QStringList availableInputDevices() const { return m_afvClient->availableInputDevices(); }
|
||||
Q_INVOKABLE QStringList availableOutputDevices() const { return m_afvClient->availableOutputDevices(); }
|
||||
//! @}
|
||||
|
||||
//! Enable/disable VHF simulation, true means effects are NOT used
|
||||
Q_INVOKABLE void setBypassEffects(bool value) { /*m_afvClient->setBypassEffects(value);*/ }
|
||||
|
||||
Q_INVOKABLE void startAudio(const QString &inputDeviceName, const QString &outputDeviceName) { m_afvClient->startAudio(inputDeviceName, outputDeviceName); }
|
||||
|
||||
Q_INVOKABLE void enableTransceiver(quint16 id, bool enable) { /*m_afvClient->enableTransceiver(id, enable);*/ }
|
||||
|
||||
Q_INVOKABLE void updateComFrequency(quint16 id, quint32 frequencyHz) { m_afvClient->updateComFrequency(id, frequencyHz); }
|
||||
|
||||
//! Update own aircraft position
|
||||
Q_INVOKABLE void updatePosition(double latitudeDeg, double longitudeDeg, double heightMeters)
|
||||
{
|
||||
m_afvClient->updatePosition(latitudeDeg, longitudeDeg, heightMeters);
|
||||
}
|
||||
|
||||
//! Push to talk @{
|
||||
Q_INVOKABLE void setPtt(bool active) { m_afvClient->setPtt(active); }
|
||||
//! @}
|
||||
|
||||
//! Loopback @{
|
||||
Q_INVOKABLE void setLoopBack(bool on) { m_afvClient->setLoopBack(on); }
|
||||
Q_INVOKABLE bool isLoopback() const { return false; m_afvClient->isLoopback(); }
|
||||
//! @}
|
||||
|
||||
//! Input volume in dB, +-18dB @{
|
||||
Q_INVOKABLE void setInputVolumeDb(double valueDb) { /*m_afvClient->setInputVolumeDb(valueDb);*/ }
|
||||
//! @}
|
||||
|
||||
//! Output volume in dB, +-18dB @{
|
||||
Q_INVOKABLE void setOutputVolumeDb(double valueDb) { /*m_afvClient->setOutputVolumeDb(valueDb);*/ }
|
||||
//! @}
|
||||
|
||||
signals:
|
||||
//! Receiving callsigns have been changed
|
||||
//! \remark callsigns I do receive
|
||||
void receivingCallsignsChanged(const BlackCore::Afv::Audio::TransceiverReceivingCallsignsChangedArgs &args);
|
||||
|
||||
//! Connection status has been changed
|
||||
void connectionStatusChanged(BlackCore::Afv::Clients::CAfvClient::ConnectionStatus status);
|
||||
|
||||
//! Client updated from own aicraft data
|
||||
void updatedFromOwnAircraftCockpit();
|
||||
|
||||
//! PTT status in this particular AFV client
|
||||
void ptt(bool active, BlackMisc::Audio::PTTCOM pttcom, const BlackMisc::CIdentifier &identifier);
|
||||
|
||||
//! VU levels @{
|
||||
void inputVolumePeakVU(double value);
|
||||
void outputVolumePeakVU(double value);
|
||||
//! @}
|
||||
|
||||
private:
|
||||
BlackCore::Afv::Clients::CAfvClient *m_afvClient = nullptr;
|
||||
};
|
||||
|
||||
#endif // CAFVCLIENTBRIDGE_H
|
||||
@@ -1,8 +1,9 @@
|
||||
// #include "voiceclientui.h"
|
||||
|
||||
#include "afvclientbridge.h"
|
||||
#include "blackcore/afv/model/atcstationmodel.h"
|
||||
#include "blackcore/afv/model/afvmapreader.h"
|
||||
#include "blackcore/afv/clients/afvclient.h"
|
||||
#include "blackcore/registermetadata.h"
|
||||
|
||||
#include "blackcore/application.h"
|
||||
#include "blackmisc/network/user.h"
|
||||
#include "blackmisc/obfuscation.h"
|
||||
@@ -27,12 +28,21 @@ int main(int argc, char *argv[])
|
||||
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
QGuiApplication qa(argc, argv);
|
||||
|
||||
CApplication a("sampleafvclient", CApplicationInfo::Sample);
|
||||
BlackCore::registerMetadata();
|
||||
|
||||
BlackCore::CApplication a("sampleafvclient", CApplicationInfo::Sample);
|
||||
|
||||
CAfvMapReader *afvMapReader = new CAfvMapReader(&a);
|
||||
afvMapReader->updateFromMap();
|
||||
|
||||
CAfvClient voiceClient("https://voice1.vatsim.uk");
|
||||
CAfvClient *voiceClient = new CAfvClient("https://voice1.vatsim.uk", &qa);
|
||||
CAfvClientBridge *voiceClientBridge = new CAfvClientBridge(voiceClient, &qa);
|
||||
voiceClient->start(QThread::TimeCriticalPriority);
|
||||
|
||||
QObject::connect(&qa, &QCoreApplication::aboutToQuit, [voiceClient]()
|
||||
{
|
||||
voiceClient->quitAndWait();
|
||||
});
|
||||
|
||||
// default user name
|
||||
QString defaultUserName("1234567");
|
||||
@@ -45,7 +55,7 @@ int main(int argc, char *argv[])
|
||||
QQmlApplicationEngine engine;
|
||||
QQmlContext *ctxt = engine.rootContext();
|
||||
ctxt->setContextProperty("afvMapReader", afvMapReader);
|
||||
ctxt->setContextProperty("voiceClient", &voiceClient);
|
||||
ctxt->setContextProperty("voiceClient", voiceClientBridge);
|
||||
ctxt->setContextProperty("userName", defaultUserName);
|
||||
|
||||
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
|
||||
|
||||
Reference in New Issue
Block a user