diff --git a/samples/voiceclient/client.cpp b/samples/voiceclient/client.cpp index e9cf8357e..41e2648dd 100644 --- a/samples/voiceclient/client.cpp +++ b/samples/voiceclient/client.cpp @@ -13,19 +13,19 @@ Client::Client(QObject *parent) : connect(m_voiceClient, &IVoiceClient::squelchTestFinished, this, &Client::onSquelchTestFinished); connect(m_voiceClient, &IVoiceClient::micTestFinished, this, &Client::onMicTestFinished); connect(m_voiceClient, &IVoiceClient::connected, this, &Client::connectionStatusConnected); - - - + connect(m_voiceClient, &IVoiceClient::disconnected, this, &Client::connectionStatusDisconnected); using namespace std::placeholders; m_commands["help"] = std::bind(&Client::help, this, _1); m_commands["echo"] = std::bind(&Client::echo, this, _1); m_commands["exit"] = std::bind(&Client::exit, this, _1); - m_commands["squelchtest"] = std::bind(&Client::runSquelchTest, this, _1); - m_commands["mictest"] = std::bind(&Client::runMicTest, this, _1); + m_commands["squelchtest"] = std::bind(&Client::squelchTestCmd, this, _1); + m_commands["mictest"] = std::bind(&Client::micTestCmd, this, _1); m_commands["setcallsign"] = std::bind(&Client::setCallsignCmd, this, _1); m_commands["initconnect"] = std::bind(&Client::initiateConnectionCmd, this, _1); m_commands["termconnect"] = std::bind(&Client::terminateConnectionCmd, this, _1); + m_commands["inputdevices"] = std::bind(&Client::inputDevicesCmd, this, _1); + m_commands["outputdevices"] = std::bind(&Client::outputDevicesCmd, this, _1); } @@ -80,14 +80,14 @@ void Client::exit(QTextStream &) emit quit(); } -void Client::runSquelchTest(QTextStream &args) +void Client::squelchTestCmd(QTextStream &args) { std::cout << "Running squelch test. Please be quiet for 5 seconds..." << std::endl; printLinePrefix(); m_voiceClient->runSquelchTest(); } -void Client::runMicTest(QTextStream &args) +void Client::micTestCmd(QTextStream &args) { std::cout << "Running mic test. Speak normally for 5 seconds..." << std::endl; printLinePrefix(); @@ -118,6 +118,26 @@ void Client::terminateConnectionCmd(QTextStream &args) printLinePrefix(); } +void Client::inputDevicesCmd(QTextStream &args) +{ + QList devices = m_voiceClient->audioInputDevices(); + foreach (BlackMisc::Voice::CInputAudioDevice device, devices) + { + std::cout << device.name().toStdString() << std::endl; + } + printLinePrefix(); +} + +void Client::outputDevicesCmd(QTextStream &args) +{ + QList devices = m_voiceClient->audioOutputDevices(); + foreach (BlackMisc::Voice::COutputAudioDevice device, devices) + { + std::cout << " " << device.name().toStdString() << std::endl; + } + printLinePrefix(); +} + void Client::onSquelchTestFinished() { std::cout << "Input squelch: " << m_voiceClient->inputSquelch() << std::endl; diff --git a/samples/voiceclient/client.h b/samples/voiceclient/client.h index f7e7a5b4c..b2c38d5a7 100644 --- a/samples/voiceclient/client.h +++ b/samples/voiceclient/client.h @@ -9,6 +9,7 @@ #include "blackcore/voiceclient.h" #include +#include #include class Client : public QObject @@ -27,11 +28,13 @@ private: //commands void help(QTextStream &args); void echo(QTextStream &args); void exit(QTextStream &args); - void runSquelchTest(QTextStream &args); - void runMicTest(QTextStream &args); + void squelchTestCmd(QTextStream &args); + void micTestCmd(QTextStream &args); void setCallsignCmd(QTextStream &args); void initiateConnectionCmd(QTextStream &args); void terminateConnectionCmd(QTextStream &args); + void inputDevicesCmd(QTextStream &args); + void outputDevicesCmd(QTextStream &args); void printLinePrefix(); diff --git a/samples/voiceclient/sample_voice_client.pro b/samples/voiceclient/sample_voice_client.pro index df8fee6ac..ddd23a14c 100644 --- a/samples/voiceclient/sample_voice_client.pro +++ b/samples/voiceclient/sample_voice_client.pro @@ -13,9 +13,7 @@ DEPENDPATH += . ../../src INCLUDEPATH += . ../../src SOURCES += *.cpp -HEADERS += *.h \ - client.h \ - reader.h +HEADERS += *.h LIBS += -L../../lib -lblackcore -lblackmisc LIBS += -lvatlib diff --git a/src/blackcore/voiceclient_vatlib.cpp b/src/blackcore/voiceclient_vatlib.cpp index bed914cc8..45cba2c77 100644 --- a/src/blackcore/voiceclient_vatlib.cpp +++ b/src/blackcore/voiceclient_vatlib.cpp @@ -12,7 +12,7 @@ namespace BlackCore { CVoiceClientVatlib::CVoiceClientVatlib(QObject *parent) : IVoiceClient(parent), - m_voice(Create_Cvatlib_Voice_Simple()), + m_voice(Cvatlib_Voice_Simple::Create()), m_inputSquelch(-1), m_queryUserRoomIndex(-1) { @@ -139,7 +139,7 @@ namespace BlackCore try { Q_ASSERT_X (m_voice->IsValid() && m_voice->IsSetup(), "CVoiceClientVatlib", "Cvatlib_Voice_Simple invalid or not setup!"); - m_voice->IsRoomConnected(comUnit); + return m_voice->IsRoomConnected(comUnit); } catch (...) { this->exceptionDispatcher(Q_FUNC_INFO); } } @@ -259,7 +259,7 @@ namespace BlackCore const BlackMisc::Voice::CVoiceRoom &CVoiceClientVatlib::voiceRoom(const uint32_t comUnit) { - + return BlackMisc::Voice::CVoiceRoom(); } void CVoiceClientVatlib::timerEvent(QTimerEvent *) diff --git a/src/blackmisc/vaudiodevice.h b/src/blackmisc/vaudiodevice.h index 6926d45b7..94c4e2e36 100644 --- a/src/blackmisc/vaudiodevice.h +++ b/src/blackmisc/vaudiodevice.h @@ -3,6 +3,9 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifndef BLACKMISC_AUDIODEVICE_H +#define BLACKMISC_AUDIODEVICE_H + /*! \file */ @@ -11,8 +14,10 @@ #include -#ifndef BLACKMISC_AUDIODEVICE_H -#define BLACKMISC_AUDIODEVICE_H +#ifdef Q_OS_WIN +typedef short int16_t; +#endif + namespace BlackMisc { @@ -30,7 +35,7 @@ namespace BlackMisc /*! * Default constructor. */ - CAudioDevice() : m_deviceIndex(-1), m_deviceName("") {} + CAudioDevice() : m_deviceIndex(0), m_deviceName("") {} /*!