mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-05-23 18:52:28 -04:00
Web API: /sdrangel/audio (PATCH) implementation
This commit is contained in:
parent
dad604dcf8
commit
72615b188e
@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
TEMPLATE = subdirs
|
TEMPLATE = subdirs
|
||||||
|
|
||||||
|
CONFIG += ordered
|
||||||
|
|
||||||
SUBDIRS = serialdv
|
SUBDIRS = serialdv
|
||||||
SUBDIRS += httpserver
|
SUBDIRS += httpserver
|
||||||
SUBDIRS += logging
|
SUBDIRS += logging
|
||||||
@ -59,5 +61,4 @@ SUBDIRS += plugins/channeltx/modwfm
|
|||||||
SUBDIRS += plugins/channeltx/udpsink
|
SUBDIRS += plugins/channeltx/udpsink
|
||||||
|
|
||||||
# Main app must be last
|
# Main app must be last
|
||||||
CONFIG += ordered
|
|
||||||
SUBDIRS += app
|
SUBDIRS += app
|
||||||
|
@ -1,67 +1,84 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
// Copyright (C) 2017 F4EXB //
|
// Copyright (C) 2017 F4EXB //
|
||||||
// written by Edouard Griffiths //
|
// written by Edouard Griffiths //
|
||||||
// //
|
// //
|
||||||
// This program is free software; you can redistribute it and/or modify //
|
// This program is free software; you can redistribute it and/or modify //
|
||||||
// it under the terms of the GNU General Public License as published by //
|
// it under the terms of the GNU General Public License as published by //
|
||||||
// the Free Software Foundation as version 3 of the License, or //
|
// the Free Software Foundation as version 3 of the License, or //
|
||||||
// //
|
// //
|
||||||
// This program is distributed in the hope that it will be useful, //
|
// This program is distributed in the hope that it will be useful, //
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||||
// GNU General Public License V3 for more details. //
|
// GNU General Public License V3 for more details. //
|
||||||
// //
|
// //
|
||||||
// You should have received a copy of the GNU General Public License //
|
// You should have received a copy of the GNU General Public License //
|
||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include "audio/audiodeviceinfo.h"
|
#include "audio/audiodeviceinfo.h"
|
||||||
#include "util/simpleserializer.h"
|
#include "util/simpleserializer.h"
|
||||||
|
|
||||||
AudioDeviceInfo::AudioDeviceInfo() :
|
AudioDeviceInfo::AudioDeviceInfo() :
|
||||||
m_inputDeviceIndex(-1), // default device
|
m_inputDeviceIndex(-1), // default device
|
||||||
m_outputDeviceIndex(-1), // default device
|
m_outputDeviceIndex(-1), // default device
|
||||||
m_inputVolume(1.0f)
|
m_inputVolume(1.0f)
|
||||||
{
|
{
|
||||||
m_inputDevicesInfo = QAudioDeviceInfo::availableDevices(QAudio::AudioInput);
|
m_inputDevicesInfo = QAudioDeviceInfo::availableDevices(QAudio::AudioInput);
|
||||||
m_outputDevicesInfo = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput);
|
m_outputDevicesInfo = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioDeviceInfo::resetToDefaults()
|
void AudioDeviceInfo::resetToDefaults()
|
||||||
{
|
{
|
||||||
m_inputDeviceIndex = -1;
|
m_inputDeviceIndex = -1;
|
||||||
m_outputDeviceIndex = -1;
|
m_outputDeviceIndex = -1;
|
||||||
m_inputVolume = 1.0f;
|
m_inputVolume = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray AudioDeviceInfo::serialize() const
|
QByteArray AudioDeviceInfo::serialize() const
|
||||||
{
|
{
|
||||||
SimpleSerializer s(1);
|
SimpleSerializer s(1);
|
||||||
s.writeS32(1, m_inputDeviceIndex);
|
s.writeS32(1, m_inputDeviceIndex);
|
||||||
s.writeS32(2, m_outputDeviceIndex);
|
s.writeS32(2, m_outputDeviceIndex);
|
||||||
s.writeFloat(3, m_inputVolume);
|
s.writeFloat(3, m_inputVolume);
|
||||||
return s.final();
|
return s.final();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AudioDeviceInfo::deserialize(const QByteArray& data)
|
bool AudioDeviceInfo::deserialize(const QByteArray& data)
|
||||||
{
|
{
|
||||||
SimpleDeserializer d(data);
|
SimpleDeserializer d(data);
|
||||||
|
|
||||||
if(!d.isValid()) {
|
if(!d.isValid()) {
|
||||||
resetToDefaults();
|
resetToDefaults();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(d.getVersion() == 1)
|
if(d.getVersion() == 1)
|
||||||
{
|
{
|
||||||
d.readS32(1, &m_inputDeviceIndex, -1);
|
d.readS32(1, &m_inputDeviceIndex, -1);
|
||||||
d.readS32(2, &m_outputDeviceIndex, -1);
|
d.readS32(2, &m_outputDeviceIndex, -1);
|
||||||
d.readFloat(3, &m_inputVolume, 1.0f);
|
d.readFloat(3, &m_inputVolume, 1.0f);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
resetToDefaults();
|
resetToDefaults();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AudioDeviceInfo::setInputDeviceIndex(int inputDeviceIndex)
|
||||||
|
{
|
||||||
|
int nbDevices = m_inputDevicesInfo.size();
|
||||||
|
m_inputDeviceIndex = inputDeviceIndex < -1 ? -1 : inputDeviceIndex >= nbDevices ? nbDevices-1 : inputDeviceIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AudioDeviceInfo::setOutputDeviceIndex(int outputDeviceIndex)
|
||||||
|
{
|
||||||
|
int nbDevices = m_outputDevicesInfo.size();
|
||||||
|
m_outputDeviceIndex = outputDeviceIndex < -1 ? -1 : outputDeviceIndex >= nbDevices ? nbDevices-1 : outputDeviceIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AudioDeviceInfo::setInputVolume(float inputVolume)
|
||||||
|
{
|
||||||
|
m_inputVolume = inputVolume < 0.0 ? 0.0 : inputVolume > 1.0 ? 1.0 : inputVolume;
|
||||||
|
}
|
||||||
|
@ -1,52 +1,55 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
// Copyright (C) 2017 F4EXB //
|
// Copyright (C) 2017 F4EXB //
|
||||||
// written by Edouard Griffiths //
|
// written by Edouard Griffiths //
|
||||||
// //
|
// //
|
||||||
// This program is free software; you can redistribute it and/or modify //
|
// This program is free software; you can redistribute it and/or modify //
|
||||||
// it under the terms of the GNU General Public License as published by //
|
// it under the terms of the GNU General Public License as published by //
|
||||||
// the Free Software Foundation as version 3 of the License, or //
|
// the Free Software Foundation as version 3 of the License, or //
|
||||||
// //
|
// //
|
||||||
// This program is distributed in the hope that it will be useful, //
|
// This program is distributed in the hope that it will be useful, //
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||||
// GNU General Public License V3 for more details. //
|
// GNU General Public License V3 for more details. //
|
||||||
// //
|
// //
|
||||||
// You should have received a copy of the GNU General Public License //
|
// You should have received a copy of the GNU General Public License //
|
||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifndef INCLUDE_AUDIODEVICEINFO_H
|
#ifndef INCLUDE_AUDIODEVICEINFO_H
|
||||||
#define INCLUDE_AUDIODEVICEINFO_H
|
#define INCLUDE_AUDIODEVICEINFO_H
|
||||||
|
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QAudioDeviceInfo>
|
#include <QAudioDeviceInfo>
|
||||||
|
|
||||||
#include "util/export.h"
|
#include "util/export.h"
|
||||||
|
|
||||||
class SDRANGEL_API AudioDeviceInfo {
|
class SDRANGEL_API AudioDeviceInfo {
|
||||||
public:
|
public:
|
||||||
AudioDeviceInfo();
|
AudioDeviceInfo();
|
||||||
|
|
||||||
const QList<QAudioDeviceInfo>& getInputDevices() const { return m_inputDevicesInfo; }
|
const QList<QAudioDeviceInfo>& getInputDevices() const { return m_inputDevicesInfo; }
|
||||||
const QList<QAudioDeviceInfo>& getOutputDevices() const { return m_outputDevicesInfo; }
|
const QList<QAudioDeviceInfo>& getOutputDevices() const { return m_outputDevicesInfo; }
|
||||||
int getInputDeviceIndex() const { return m_inputDeviceIndex; }
|
int getInputDeviceIndex() const { return m_inputDeviceIndex; }
|
||||||
int getOutputDeviceIndex() const { return m_outputDeviceIndex; }
|
int getOutputDeviceIndex() const { return m_outputDeviceIndex; }
|
||||||
float getInputVolume() const { return m_inputVolume; }
|
float getInputVolume() const { return m_inputVolume; }
|
||||||
|
void setInputDeviceIndex(int inputDeviceIndex);
|
||||||
private:
|
void setOutputDeviceIndex(int inputDeviceIndex);
|
||||||
QList<QAudioDeviceInfo> m_inputDevicesInfo;
|
void setInputVolume(float inputVolume);
|
||||||
QList<QAudioDeviceInfo> m_outputDevicesInfo;
|
|
||||||
int m_inputDeviceIndex;
|
private:
|
||||||
int m_outputDeviceIndex;
|
QList<QAudioDeviceInfo> m_inputDevicesInfo;
|
||||||
float m_inputVolume;
|
QList<QAudioDeviceInfo> m_outputDevicesInfo;
|
||||||
|
int m_inputDeviceIndex;
|
||||||
void resetToDefaults();
|
int m_outputDeviceIndex;
|
||||||
QByteArray serialize() const;
|
float m_inputVolume;
|
||||||
bool deserialize(const QByteArray& data);
|
|
||||||
|
void resetToDefaults();
|
||||||
friend class AudioDialog;
|
QByteArray serialize() const;
|
||||||
friend class MainSettings;
|
bool deserialize(const QByteArray& data);
|
||||||
};
|
|
||||||
|
friend class AudioDialog;
|
||||||
#endif // INCLUDE_AUDIODEVICEINFO_H
|
friend class MainSettings;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // INCLUDE_AUDIODEVICEINFO_H
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -28,6 +28,7 @@ namespace Swagger
|
|||||||
class SWGInstanceChannelsResponse;
|
class SWGInstanceChannelsResponse;
|
||||||
class SWGLoggingInfo;
|
class SWGLoggingInfo;
|
||||||
class SWGAudioDevices;
|
class SWGAudioDevices;
|
||||||
|
class SWGAudioDevicesSelect;
|
||||||
class SWGErrorResponse;
|
class SWGErrorResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,6 +93,15 @@ public:
|
|||||||
Swagger::SWGErrorResponse& error __attribute__((unused)))
|
Swagger::SWGErrorResponse& error __attribute__((unused)))
|
||||||
{ return 501; }
|
{ return 501; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handler of /sdrangel/audio (PATCH) swagger/sdrangel/code/html2/index.html#api-Default-instanceChannels
|
||||||
|
* returns the Http status code (default 501: not implemented)
|
||||||
|
*/
|
||||||
|
virtual int instanceAudioPatch(
|
||||||
|
Swagger::SWGAudioDevicesSelect& response __attribute__((unused)),
|
||||||
|
Swagger::SWGErrorResponse& error __attribute__((unused)))
|
||||||
|
{ return 501; }
|
||||||
|
|
||||||
static QString instanceSummaryURL;
|
static QString instanceSummaryURL;
|
||||||
static QString instanceDevicesURL;
|
static QString instanceDevicesURL;
|
||||||
static QString instanceChannelsURL;
|
static QString instanceChannelsURL;
|
||||||
|
@ -54,165 +54,16 @@ void WebAPIRequestMapper::service(qtwebapp::HttpRequest& request, qtwebapp::Http
|
|||||||
{
|
{
|
||||||
QByteArray path=request.getPath();
|
QByteArray path=request.getPath();
|
||||||
|
|
||||||
if (path == WebAPIAdapterInterface::instanceSummaryURL)
|
if (path == WebAPIAdapterInterface::instanceSummaryURL) {
|
||||||
{
|
instanceSummaryService(request, response);
|
||||||
if (request.getMethod() == "GET")
|
} else if (path == WebAPIAdapterInterface::instanceDevicesURL) {
|
||||||
{
|
instanceDevicesService(request, response);
|
||||||
Swagger::SWGInstanceSummaryResponse normalResponse;
|
} else if (path == WebAPIAdapterInterface::instanceChannelsURL) {
|
||||||
Swagger::SWGErrorResponse errorResponse;
|
instanceChannelsService(request, response);
|
||||||
|
} else if (path == WebAPIAdapterInterface::instanceLoggingURL) {
|
||||||
int status = m_adapter->instanceSummary(normalResponse, errorResponse);
|
instanceLoggingService(request, response);
|
||||||
response.setStatus(status);
|
} else if (path == WebAPIAdapterInterface::instanceAudioURL) {
|
||||||
|
instanceAudioService(request, response);
|
||||||
if (status == 200) {
|
|
||||||
response.write(normalResponse.asJson().toUtf8());
|
|
||||||
} else {
|
|
||||||
response.write(errorResponse.asJson().toUtf8());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
response.setStatus(405,"Invalid HTTP method");
|
|
||||||
response.write("Invalid HTTP method");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (path == WebAPIAdapterInterface::instanceDevicesURL)
|
|
||||||
{
|
|
||||||
Swagger::SWGInstanceDevicesResponse normalResponse;
|
|
||||||
Swagger::SWGErrorResponse errorResponse;
|
|
||||||
|
|
||||||
if (request.getMethod() == "GET")
|
|
||||||
{
|
|
||||||
QByteArray txStr = request.getParameter("tx");
|
|
||||||
bool tx = (txStr == "1");
|
|
||||||
|
|
||||||
int status = m_adapter->instanceDevices(tx, normalResponse, errorResponse);
|
|
||||||
response.setStatus(status);
|
|
||||||
|
|
||||||
if (status == 200) {
|
|
||||||
response.write(normalResponse.asJson().toUtf8());
|
|
||||||
} else {
|
|
||||||
response.write(errorResponse.asJson().toUtf8());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
response.setStatus(405,"Invalid HTTP method");
|
|
||||||
response.write("Invalid HTTP method");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (path == WebAPIAdapterInterface::instanceChannelsURL)
|
|
||||||
{
|
|
||||||
Swagger::SWGInstanceChannelsResponse normalResponse;
|
|
||||||
Swagger::SWGErrorResponse errorResponse;
|
|
||||||
|
|
||||||
if (request.getMethod() == "GET")
|
|
||||||
{
|
|
||||||
QByteArray txStr = request.getParameter("tx");
|
|
||||||
bool tx = (txStr == "1");
|
|
||||||
|
|
||||||
int status = m_adapter->instanceChannels(tx, normalResponse, errorResponse);
|
|
||||||
response.setStatus(status);
|
|
||||||
|
|
||||||
if (status == 200) {
|
|
||||||
response.write(normalResponse.asJson().toUtf8());
|
|
||||||
} else {
|
|
||||||
response.write(errorResponse.asJson().toUtf8());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
response.setStatus(405,"Invalid HTTP method");
|
|
||||||
response.write("Invalid HTTP method");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (path == WebAPIAdapterInterface::instanceLoggingURL)
|
|
||||||
{
|
|
||||||
Swagger::SWGLoggingInfo normalResponse;
|
|
||||||
Swagger::SWGErrorResponse errorResponse;
|
|
||||||
|
|
||||||
if (request.getMethod() == "GET")
|
|
||||||
{
|
|
||||||
int status = m_adapter->instanceLoggingGet(normalResponse, errorResponse);
|
|
||||||
response.setStatus(status);
|
|
||||||
|
|
||||||
if (status == 200) {
|
|
||||||
response.write(normalResponse.asJson().toUtf8());
|
|
||||||
} else {
|
|
||||||
response.write(errorResponse.asJson().toUtf8());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (request.getMethod() == "PUT")
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
QString jsonStr = request.getBody();
|
|
||||||
QByteArray jsonBytes(jsonStr.toStdString().c_str());
|
|
||||||
QJsonParseError error;
|
|
||||||
QJsonDocument doc = QJsonDocument::fromJson(jsonBytes, &error);
|
|
||||||
|
|
||||||
if (error.error == QJsonParseError::NoError)
|
|
||||||
{
|
|
||||||
normalResponse.fromJson(jsonStr);
|
|
||||||
int status = m_adapter->instanceLoggingPut(normalResponse, errorResponse);
|
|
||||||
response.setStatus(status);
|
|
||||||
|
|
||||||
if (status == 200) {
|
|
||||||
response.write(normalResponse.asJson().toUtf8());
|
|
||||||
} else {
|
|
||||||
response.write(errorResponse.asJson().toUtf8());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
QString errorMsg = QString("Input JSON error: ") + error.errorString();
|
|
||||||
errorResponse.init();
|
|
||||||
*errorResponse.getMessage() = errorMsg;
|
|
||||||
response.setStatus(400, errorMsg.toUtf8());
|
|
||||||
response.write(errorResponse.asJson().toUtf8());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (const std::exception& ex)
|
|
||||||
{
|
|
||||||
QString errorMsg = QString("Error parsing request: ") + ex.what();
|
|
||||||
errorResponse.init();
|
|
||||||
*errorResponse.getMessage() = errorMsg;
|
|
||||||
response.setStatus(500, errorMsg.toUtf8());
|
|
||||||
response.write(errorResponse.asJson().toUtf8());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
response.setStatus(405,"Invalid HTTP method");
|
|
||||||
response.write("Invalid HTTP method");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (path == WebAPIAdapterInterface::instanceAudioURL)
|
|
||||||
{
|
|
||||||
Swagger::SWGErrorResponse errorResponse;
|
|
||||||
|
|
||||||
if (request.getMethod() == "GET")
|
|
||||||
{
|
|
||||||
Swagger::SWGAudioDevices normalResponse;
|
|
||||||
|
|
||||||
int status = m_adapter->instanceAudioGet(normalResponse, errorResponse);
|
|
||||||
response.setStatus(status);
|
|
||||||
|
|
||||||
if (status == 200) {
|
|
||||||
response.write(normalResponse.asJson().toUtf8());
|
|
||||||
} else {
|
|
||||||
response.write(errorResponse.asJson().toUtf8());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (request.getMethod() == "PATCH")
|
|
||||||
{
|
|
||||||
Swagger::SWGAudioDevicesSelect normalResponse;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
response.setStatus(405,"Invalid HTTP method");
|
|
||||||
response.write("Invalid HTTP method");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -223,7 +74,197 @@ void WebAPIRequestMapper::service(qtwebapp::HttpRequest& request, qtwebapp::Http
|
|||||||
|
|
||||||
QByteArray path = "/index.html";
|
QByteArray path = "/index.html";
|
||||||
m_staticFileController->service(path, response);
|
m_staticFileController->service(path, response);
|
||||||
//response.setStatus(404,"Not found");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WebAPIRequestMapper::instanceSummaryService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response)
|
||||||
|
{
|
||||||
|
if (request.getMethod() == "GET")
|
||||||
|
{
|
||||||
|
Swagger::SWGInstanceSummaryResponse normalResponse;
|
||||||
|
Swagger::SWGErrorResponse errorResponse;
|
||||||
|
|
||||||
|
int status = m_adapter->instanceSummary(normalResponse, errorResponse);
|
||||||
|
response.setStatus(status);
|
||||||
|
|
||||||
|
if (status == 200) {
|
||||||
|
response.write(normalResponse.asJson().toUtf8());
|
||||||
|
} else {
|
||||||
|
response.write(errorResponse.asJson().toUtf8());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
response.setStatus(405,"Invalid HTTP method");
|
||||||
|
response.write("Invalid HTTP method");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void WebAPIRequestMapper::instanceDevicesService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response)
|
||||||
|
{
|
||||||
|
Swagger::SWGInstanceDevicesResponse normalResponse;
|
||||||
|
Swagger::SWGErrorResponse errorResponse;
|
||||||
|
|
||||||
|
if (request.getMethod() == "GET")
|
||||||
|
{
|
||||||
|
QByteArray txStr = request.getParameter("tx");
|
||||||
|
bool tx = (txStr == "1");
|
||||||
|
|
||||||
|
int status = m_adapter->instanceDevices(tx, normalResponse, errorResponse);
|
||||||
|
response.setStatus(status);
|
||||||
|
|
||||||
|
if (status == 200) {
|
||||||
|
response.write(normalResponse.asJson().toUtf8());
|
||||||
|
} else {
|
||||||
|
response.write(errorResponse.asJson().toUtf8());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
response.setStatus(405,"Invalid HTTP method");
|
||||||
|
response.write("Invalid HTTP method");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void WebAPIRequestMapper::instanceChannelsService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response)
|
||||||
|
{
|
||||||
|
Swagger::SWGInstanceChannelsResponse normalResponse;
|
||||||
|
Swagger::SWGErrorResponse errorResponse;
|
||||||
|
|
||||||
|
if (request.getMethod() == "GET")
|
||||||
|
{
|
||||||
|
QByteArray txStr = request.getParameter("tx");
|
||||||
|
bool tx = (txStr == "1");
|
||||||
|
|
||||||
|
int status = m_adapter->instanceChannels(tx, normalResponse, errorResponse);
|
||||||
|
response.setStatus(status);
|
||||||
|
|
||||||
|
if (status == 200) {
|
||||||
|
response.write(normalResponse.asJson().toUtf8());
|
||||||
|
} else {
|
||||||
|
response.write(errorResponse.asJson().toUtf8());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
response.setStatus(405,"Invalid HTTP method");
|
||||||
|
response.write("Invalid HTTP method");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void WebAPIRequestMapper::instanceLoggingService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response)
|
||||||
|
{
|
||||||
|
Swagger::SWGLoggingInfo normalResponse;
|
||||||
|
Swagger::SWGErrorResponse errorResponse;
|
||||||
|
|
||||||
|
if (request.getMethod() == "GET")
|
||||||
|
{
|
||||||
|
int status = m_adapter->instanceLoggingGet(normalResponse, errorResponse);
|
||||||
|
response.setStatus(status);
|
||||||
|
|
||||||
|
if (status == 200) {
|
||||||
|
response.write(normalResponse.asJson().toUtf8());
|
||||||
|
} else {
|
||||||
|
response.write(errorResponse.asJson().toUtf8());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (request.getMethod() == "PUT")
|
||||||
|
{
|
||||||
|
QString jsonStr = request.getBody();
|
||||||
|
|
||||||
|
if (parseJsonBody(jsonStr, response))
|
||||||
|
{
|
||||||
|
normalResponse.fromJson(jsonStr);
|
||||||
|
int status = m_adapter->instanceLoggingPut(normalResponse, errorResponse);
|
||||||
|
response.setStatus(status);
|
||||||
|
|
||||||
|
if (status == 200) {
|
||||||
|
response.write(normalResponse.asJson().toUtf8());
|
||||||
|
} else {
|
||||||
|
response.write(errorResponse.asJson().toUtf8());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
response.setStatus(405,"Invalid HTTP method");
|
||||||
|
response.write("Invalid HTTP method");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void WebAPIRequestMapper::instanceAudioService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response)
|
||||||
|
{
|
||||||
|
Swagger::SWGErrorResponse errorResponse;
|
||||||
|
|
||||||
|
if (request.getMethod() == "GET")
|
||||||
|
{
|
||||||
|
Swagger::SWGAudioDevices normalResponse;
|
||||||
|
|
||||||
|
int status = m_adapter->instanceAudioGet(normalResponse, errorResponse);
|
||||||
|
response.setStatus(status);
|
||||||
|
|
||||||
|
if (status == 200) {
|
||||||
|
response.write(normalResponse.asJson().toUtf8());
|
||||||
|
} else {
|
||||||
|
response.write(errorResponse.asJson().toUtf8());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (request.getMethod() == "PATCH")
|
||||||
|
{
|
||||||
|
Swagger::SWGAudioDevicesSelect normalResponse;
|
||||||
|
QString jsonStr = request.getBody();
|
||||||
|
|
||||||
|
if (parseJsonBody(jsonStr, response))
|
||||||
|
{
|
||||||
|
normalResponse.fromJson(jsonStr);
|
||||||
|
int status = m_adapter->instanceAudioPatch(normalResponse, errorResponse);
|
||||||
|
response.setStatus(status);
|
||||||
|
|
||||||
|
if (status == 200) {
|
||||||
|
response.write(normalResponse.asJson().toUtf8());
|
||||||
|
} else {
|
||||||
|
response.write(errorResponse.asJson().toUtf8());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
response.setStatus(405,"Invalid HTTP method");
|
||||||
|
response.write("Invalid HTTP method");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool WebAPIRequestMapper::parseJsonBody(QString& jsonStr, qtwebapp::HttpResponse& response)
|
||||||
|
{
|
||||||
|
Swagger::SWGErrorResponse errorResponse;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
QByteArray jsonBytes(jsonStr.toStdString().c_str());
|
||||||
|
QJsonParseError error;
|
||||||
|
QJsonDocument doc = QJsonDocument::fromJson(jsonBytes, &error);
|
||||||
|
|
||||||
|
if (error.error != QJsonParseError::NoError)
|
||||||
|
{
|
||||||
|
QString errorMsg = QString("Input JSON error: ") + error.errorString();
|
||||||
|
errorResponse.init();
|
||||||
|
*errorResponse.getMessage() = errorMsg;
|
||||||
|
response.setStatus(400, errorMsg.toUtf8());
|
||||||
|
response.write(errorResponse.asJson().toUtf8());
|
||||||
|
}
|
||||||
|
|
||||||
|
return (error.error == QJsonParseError::NoError);
|
||||||
|
}
|
||||||
|
catch (const std::exception& ex)
|
||||||
|
{
|
||||||
|
QString errorMsg = QString("Error parsing request: ") + ex.what();
|
||||||
|
errorResponse.init();
|
||||||
|
*errorResponse.getMessage() = errorMsg;
|
||||||
|
response.setStatus(500, errorMsg.toUtf8());
|
||||||
|
response.write(errorResponse.asJson().toUtf8());
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
#ifndef SDRBASE_WEBAPI_WEBAPIREQUESTMAPPER_H_
|
#ifndef SDRBASE_WEBAPI_WEBAPIREQUESTMAPPER_H_
|
||||||
#define SDRBASE_WEBAPI_WEBAPIREQUESTMAPPER_H_
|
#define SDRBASE_WEBAPI_WEBAPIREQUESTMAPPER_H_
|
||||||
|
|
||||||
|
#include <QJsonParseError>
|
||||||
|
|
||||||
#include "httprequesthandler.h"
|
#include "httprequesthandler.h"
|
||||||
#include "httprequest.h"
|
#include "httprequest.h"
|
||||||
#include "httpresponse.h"
|
#include "httpresponse.h"
|
||||||
@ -36,6 +38,14 @@ public:
|
|||||||
private:
|
private:
|
||||||
WebAPIAdapterInterface *m_adapter;
|
WebAPIAdapterInterface *m_adapter;
|
||||||
qtwebapp::StaticFileController *m_staticFileController;
|
qtwebapp::StaticFileController *m_staticFileController;
|
||||||
|
|
||||||
|
void instanceSummaryService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
||||||
|
void instanceDevicesService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
||||||
|
void instanceChannelsService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
||||||
|
void instanceLoggingService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
||||||
|
void instanceAudioService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
||||||
|
|
||||||
|
bool parseJsonBody(QString& jsonStr, qtwebapp::HttpResponse& response);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* SDRBASE_WEBAPI_WEBAPIREQUESTMAPPER_H_ */
|
#endif /* SDRBASE_WEBAPI_WEBAPIREQUESTMAPPER_H_ */
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "device/deviceenumerator.h"
|
#include "device/deviceenumerator.h"
|
||||||
#include "dsp/devicesamplesource.h"
|
#include "dsp/devicesamplesource.h"
|
||||||
#include "dsp/devicesamplesink.h"
|
#include "dsp/devicesamplesink.h"
|
||||||
|
#include "dsp/dspengine.h"
|
||||||
#include "plugin/pluginapi.h"
|
#include "plugin/pluginapi.h"
|
||||||
#include "plugin/pluginmanager.h"
|
#include "plugin/pluginmanager.h"
|
||||||
#include "channel/channelsinkapi.h"
|
#include "channel/channelsinkapi.h"
|
||||||
@ -37,6 +38,7 @@
|
|||||||
#include "SWGInstanceChannelsResponse.h"
|
#include "SWGInstanceChannelsResponse.h"
|
||||||
#include "SWGDeviceListItem.h"
|
#include "SWGDeviceListItem.h"
|
||||||
#include "SWGAudioDevices.h"
|
#include "SWGAudioDevices.h"
|
||||||
|
#include "SWGAudioDevicesSelect.h"
|
||||||
#include "SWGErrorResponse.h"
|
#include "SWGErrorResponse.h"
|
||||||
|
|
||||||
#include "webapiadaptergui.h"
|
#include "webapiadaptergui.h"
|
||||||
@ -264,24 +266,58 @@ int WebAPIAdapterGUI::instanceAudioGet(
|
|||||||
response.setInputDeviceSelectedIndex(m_mainWindow.m_audioDeviceInfo.getInputDeviceIndex());
|
response.setInputDeviceSelectedIndex(m_mainWindow.m_audioDeviceInfo.getInputDeviceIndex());
|
||||||
response.setNbOutputDevices(nbOutputDevices);
|
response.setNbOutputDevices(nbOutputDevices);
|
||||||
response.setOutputDeviceSelectedIndex(m_mainWindow.m_audioDeviceInfo.getOutputDeviceIndex());
|
response.setOutputDeviceSelectedIndex(m_mainWindow.m_audioDeviceInfo.getOutputDeviceIndex());
|
||||||
QList<QString*> *inputDeviceNames = response.getInputDevices();
|
response.setInputVolume(m_mainWindow.m_audioDeviceInfo.getInputVolume());
|
||||||
QList<QString*> *outputDeviceNames = response.getOutputDevices();
|
QList<Swagger::SWGAudioDevice*> *inputDevices = response.getInputDevices();
|
||||||
|
QList<Swagger::SWGAudioDevice*> *outputDevices = response.getOutputDevices();
|
||||||
|
|
||||||
for (int i = 0; i < nbInputDevices; i++)
|
for (int i = 0; i < nbInputDevices; i++)
|
||||||
{
|
{
|
||||||
inputDeviceNames->append(new QString());
|
inputDevices->append(new Swagger::SWGAudioDevice);
|
||||||
*inputDeviceNames->back() = audioInputDevices[i].deviceName();
|
*inputDevices->back()->getName() = audioInputDevices.at(i).deviceName();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < nbOutputDevices; i++)
|
for (int i = 0; i < nbOutputDevices; i++)
|
||||||
{
|
{
|
||||||
outputDeviceNames->append(new QString());
|
outputDevices->append(new Swagger::SWGAudioDevice);
|
||||||
*outputDeviceNames->back() = audioOutputDevices[i].deviceName();
|
*outputDevices->back()->getName() = audioOutputDevices.at(i).deviceName();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 200;
|
return 200;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int WebAPIAdapterGUI::instanceAudioPatch(
|
||||||
|
Swagger::SWGAudioDevicesSelect& response,
|
||||||
|
Swagger::SWGErrorResponse& error)
|
||||||
|
{
|
||||||
|
// response input is the query actually
|
||||||
|
float inputVolume = response.getInputVolume();
|
||||||
|
int inputIndex = response.getInputIndex();
|
||||||
|
int outputIndex = response.getOutputIndex();
|
||||||
|
|
||||||
|
const QList<QAudioDeviceInfo>& audioInputDevices = m_mainWindow.m_audioDeviceInfo.getInputDevices();
|
||||||
|
const QList<QAudioDeviceInfo>& audioOutputDevices = m_mainWindow.m_audioDeviceInfo.getOutputDevices();
|
||||||
|
int nbInputDevices = audioInputDevices.size();
|
||||||
|
int nbOutputDevices = audioOutputDevices.size();
|
||||||
|
|
||||||
|
inputVolume = inputVolume < 0.0 ? 0.0 : inputVolume > 1.0 ? 1.0 : inputVolume;
|
||||||
|
inputIndex = inputIndex < -1 ? -1 : inputIndex > nbInputDevices ? nbInputDevices-1 : inputIndex;
|
||||||
|
outputIndex = outputIndex < -1 ? -1 : outputIndex > nbOutputDevices ? nbOutputDevices-1 : outputIndex;
|
||||||
|
|
||||||
|
m_mainWindow.m_audioDeviceInfo.setInputVolume(inputVolume);
|
||||||
|
m_mainWindow.m_audioDeviceInfo.setInputDeviceIndex(inputIndex);
|
||||||
|
m_mainWindow.m_audioDeviceInfo.setOutputDeviceIndex(outputIndex);
|
||||||
|
|
||||||
|
m_mainWindow.m_dspEngine->setAudioInputVolume(inputVolume);
|
||||||
|
m_mainWindow.m_dspEngine->setAudioInputDeviceIndex(inputIndex);
|
||||||
|
m_mainWindow.m_dspEngine->setAudioOutputDeviceIndex(outputIndex);
|
||||||
|
|
||||||
|
response.setInputVolume(m_mainWindow.m_audioDeviceInfo.getInputVolume());
|
||||||
|
response.setInputIndex(m_mainWindow.m_audioDeviceInfo.getInputDeviceIndex());
|
||||||
|
response.setOutputIndex(m_mainWindow.m_audioDeviceInfo.getOutputDeviceIndex());
|
||||||
|
|
||||||
|
return 200;
|
||||||
|
}
|
||||||
|
|
||||||
QtMsgType WebAPIAdapterGUI::getMsgTypeFromString(const QString& msgTypeString)
|
QtMsgType WebAPIAdapterGUI::getMsgTypeFromString(const QString& msgTypeString)
|
||||||
{
|
{
|
||||||
if (msgTypeString == "debug") {
|
if (msgTypeString == "debug") {
|
||||||
|
@ -57,6 +57,10 @@ public:
|
|||||||
Swagger::SWGAudioDevices& response,
|
Swagger::SWGAudioDevices& response,
|
||||||
Swagger::SWGErrorResponse& error);
|
Swagger::SWGErrorResponse& error);
|
||||||
|
|
||||||
|
virtual int instanceAudioPatch(
|
||||||
|
Swagger::SWGAudioDevicesSelect& response,
|
||||||
|
Swagger::SWGErrorResponse& error);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MainWindow& m_mainWindow;
|
MainWindow& m_mainWindow;
|
||||||
|
|
||||||
|
@ -633,11 +633,16 @@ definitions:
|
|||||||
AudioDevices:
|
AudioDevices:
|
||||||
description: "List of audio devices available in the system"
|
description: "List of audio devices available in the system"
|
||||||
required:
|
required:
|
||||||
|
- inputVolume
|
||||||
- nbInputDevices
|
- nbInputDevices
|
||||||
- inputDeviceSelectedIndex
|
- inputDeviceSelectedIndex
|
||||||
- nbOutputDevices
|
- nbOutputDevices
|
||||||
- outputDeviceSelectedIndex
|
- outputDeviceSelectedIndex
|
||||||
properties:
|
properties:
|
||||||
|
inputVolume:
|
||||||
|
description: "Audio input volume [0.0..1.0]"
|
||||||
|
type: number
|
||||||
|
format: float
|
||||||
nbInputDevices:
|
nbInputDevices:
|
||||||
description: "Number of input audio devices"
|
description: "Number of input audio devices"
|
||||||
type: integer
|
type: integer
|
||||||
@ -645,10 +650,10 @@ definitions:
|
|||||||
description: "Index of selected input audio devices (-1 if default)"
|
description: "Index of selected input audio devices (-1 if default)"
|
||||||
type: integer
|
type: integer
|
||||||
inputDevices:
|
inputDevices:
|
||||||
description: "Names of input devices"
|
description: "List of input devices"
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
type: string
|
$ref: "#/definitions/AudioDevice"
|
||||||
nbOutputDevices:
|
nbOutputDevices:
|
||||||
description: "Number of output audio devices"
|
description: "Number of output audio devices"
|
||||||
type: integer
|
type: integer
|
||||||
@ -656,17 +661,31 @@ definitions:
|
|||||||
description: "Index of selected output audio devices (-1 if default)"
|
description: "Index of selected output audio devices (-1 if default)"
|
||||||
type: integer
|
type: integer
|
||||||
outputDevices:
|
outputDevices:
|
||||||
description: "Names of output devices"
|
description: "List of output devices"
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
type: string
|
$ref: "#/definitions/AudioDevice"
|
||||||
|
AudioDevice:
|
||||||
|
description: "Audio device"
|
||||||
|
properties:
|
||||||
|
name:
|
||||||
|
description: "Displayable name of the device"
|
||||||
|
type: string
|
||||||
AudioDevicesSelect:
|
AudioDevicesSelect:
|
||||||
description: "Audio devices selected"
|
description: "Audio devices selected"
|
||||||
|
required:
|
||||||
|
- inputVolume
|
||||||
|
- inputIndex
|
||||||
|
- outputIndex
|
||||||
properties:
|
properties:
|
||||||
input:
|
inputVolume:
|
||||||
|
description: "Audio input volume [0.0..1.0]"
|
||||||
|
type: number
|
||||||
|
format: float
|
||||||
|
inputIndex:
|
||||||
description: "Index of the audio input device (-1 for default)"
|
description: "Index of the audio input device (-1 for default)"
|
||||||
type: integer
|
type: integer
|
||||||
output:
|
outputIndex:
|
||||||
description: "Index of the audio output device (-1 for default)"
|
description: "Index of the audio output device (-1 for default)"
|
||||||
type: integer
|
type: integer
|
||||||
LocationInformation:
|
LocationInformation:
|
||||||
|
File diff suppressed because it is too large
Load Diff
95
swagger/sdrangel/code/qt5/client/SWGAudioDevice.cpp
Normal file
95
swagger/sdrangel/code/qt5/client/SWGAudioDevice.cpp
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
/**
|
||||||
|
* SDRangel
|
||||||
|
* This is the web API of SDRangel SDR software. SDRangel is an Open Source Qt5/OpenGL 3.0+ GUI and server Software Defined Radio and signal analyzer in software. It supports Airspy, BladeRF, HackRF, LimeSDR, PlutoSDR, RTL-SDR, SDRplay RSP1 and FunCube
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 4.0.0
|
||||||
|
* Contact: f4exb06@gmail.com
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by the swagger code generator program.
|
||||||
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "SWGAudioDevice.h"
|
||||||
|
|
||||||
|
#include "SWGHelpers.h"
|
||||||
|
|
||||||
|
#include <QJsonDocument>
|
||||||
|
#include <QJsonArray>
|
||||||
|
#include <QObject>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
namespace Swagger {
|
||||||
|
|
||||||
|
SWGAudioDevice::SWGAudioDevice(QString* json) {
|
||||||
|
init();
|
||||||
|
this->fromJson(*json);
|
||||||
|
}
|
||||||
|
|
||||||
|
SWGAudioDevice::SWGAudioDevice() {
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
SWGAudioDevice::~SWGAudioDevice() {
|
||||||
|
this->cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SWGAudioDevice::init() {
|
||||||
|
name = new QString("");
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SWGAudioDevice::cleanup() {
|
||||||
|
|
||||||
|
if(name != nullptr) {
|
||||||
|
delete name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SWGAudioDevice*
|
||||||
|
SWGAudioDevice::fromJson(QString &json) {
|
||||||
|
QByteArray array (json.toStdString().c_str());
|
||||||
|
QJsonDocument doc = QJsonDocument::fromJson(array);
|
||||||
|
QJsonObject jsonObject = doc.object();
|
||||||
|
this->fromJsonObject(jsonObject);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SWGAudioDevice::fromJsonObject(QJsonObject &pJson) {
|
||||||
|
::Swagger::setValue(&name, pJson["name"], "QString", "QString");
|
||||||
|
}
|
||||||
|
|
||||||
|
QString
|
||||||
|
SWGAudioDevice::asJson ()
|
||||||
|
{
|
||||||
|
QJsonObject* obj = this->asJsonObject();
|
||||||
|
|
||||||
|
QJsonDocument doc(*obj);
|
||||||
|
QByteArray bytes = doc.toJson();
|
||||||
|
return QString(bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
QJsonObject*
|
||||||
|
SWGAudioDevice::asJsonObject() {
|
||||||
|
QJsonObject* obj = new QJsonObject();
|
||||||
|
|
||||||
|
toJsonValue(QString("name"), name, obj, QString("QString"));
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString*
|
||||||
|
SWGAudioDevice::getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
void
|
||||||
|
SWGAudioDevice::setName(QString* name) {
|
||||||
|
this->name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
55
swagger/sdrangel/code/qt5/client/SWGAudioDevice.h
Normal file
55
swagger/sdrangel/code/qt5/client/SWGAudioDevice.h
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
/**
|
||||||
|
* SDRangel
|
||||||
|
* This is the web API of SDRangel SDR software. SDRangel is an Open Source Qt5/OpenGL 3.0+ GUI and server Software Defined Radio and signal analyzer in software. It supports Airspy, BladeRF, HackRF, LimeSDR, PlutoSDR, RTL-SDR, SDRplay RSP1 and FunCube
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 4.0.0
|
||||||
|
* Contact: f4exb06@gmail.com
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by the swagger code generator program.
|
||||||
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* SWGAudioDevice.h
|
||||||
|
*
|
||||||
|
* Audio device
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SWGAudioDevice_H_
|
||||||
|
#define SWGAudioDevice_H_
|
||||||
|
|
||||||
|
#include <QJsonObject>
|
||||||
|
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
#include "SWGObject.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace Swagger {
|
||||||
|
|
||||||
|
class SWGAudioDevice: public SWGObject {
|
||||||
|
public:
|
||||||
|
SWGAudioDevice();
|
||||||
|
SWGAudioDevice(QString* json);
|
||||||
|
virtual ~SWGAudioDevice();
|
||||||
|
void init();
|
||||||
|
void cleanup();
|
||||||
|
|
||||||
|
QString asJson ();
|
||||||
|
QJsonObject* asJsonObject();
|
||||||
|
void fromJsonObject(QJsonObject &json);
|
||||||
|
SWGAudioDevice* fromJson(QString &jsonString);
|
||||||
|
|
||||||
|
QString* getName();
|
||||||
|
void setName(QString* name);
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString* name;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* SWGAudioDevice_H_ */
|
@ -37,12 +37,13 @@ SWGAudioDevices::~SWGAudioDevices() {
|
|||||||
|
|
||||||
void
|
void
|
||||||
SWGAudioDevices::init() {
|
SWGAudioDevices::init() {
|
||||||
|
input_volume = 0.0f;
|
||||||
nb_input_devices = 0;
|
nb_input_devices = 0;
|
||||||
input_device_selected_index = 0;
|
input_device_selected_index = 0;
|
||||||
input_devices = new QList<QString*>();
|
input_devices = new QList<SWGAudioDevice*>();
|
||||||
nb_output_devices = 0;
|
nb_output_devices = 0;
|
||||||
output_device_selected_index = 0;
|
output_device_selected_index = 0;
|
||||||
output_devices = new QList<QString*>();
|
output_devices = new QList<SWGAudioDevice*>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -50,9 +51,10 @@ SWGAudioDevices::cleanup() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(input_devices != nullptr) {
|
if(input_devices != nullptr) {
|
||||||
QList<QString*>* arr = input_devices;
|
QList<SWGAudioDevice*>* arr = input_devices;
|
||||||
foreach(QString* o, *arr) {
|
foreach(SWGAudioDevice* o, *arr) {
|
||||||
delete o;
|
delete o;
|
||||||
}
|
}
|
||||||
delete input_devices;
|
delete input_devices;
|
||||||
@ -61,8 +63,8 @@ SWGAudioDevices::cleanup() {
|
|||||||
|
|
||||||
|
|
||||||
if(output_devices != nullptr) {
|
if(output_devices != nullptr) {
|
||||||
QList<QString*>* arr = output_devices;
|
QList<SWGAudioDevice*>* arr = output_devices;
|
||||||
foreach(QString* o, *arr) {
|
foreach(SWGAudioDevice* o, *arr) {
|
||||||
delete o;
|
delete o;
|
||||||
}
|
}
|
||||||
delete output_devices;
|
delete output_devices;
|
||||||
@ -80,15 +82,16 @@ SWGAudioDevices::fromJson(QString &json) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
SWGAudioDevices::fromJsonObject(QJsonObject &pJson) {
|
SWGAudioDevices::fromJsonObject(QJsonObject &pJson) {
|
||||||
|
::Swagger::setValue(&input_volume, pJson["inputVolume"], "float", "");
|
||||||
::Swagger::setValue(&nb_input_devices, pJson["nbInputDevices"], "qint32", "");
|
::Swagger::setValue(&nb_input_devices, pJson["nbInputDevices"], "qint32", "");
|
||||||
::Swagger::setValue(&input_device_selected_index, pJson["inputDeviceSelectedIndex"], "qint32", "");
|
::Swagger::setValue(&input_device_selected_index, pJson["inputDeviceSelectedIndex"], "qint32", "");
|
||||||
|
|
||||||
::Swagger::setValue(&input_devices, pJson["inputDevices"], "QList", "QString");
|
::Swagger::setValue(&input_devices, pJson["inputDevices"], "QList", "SWGAudioDevice");
|
||||||
|
|
||||||
::Swagger::setValue(&nb_output_devices, pJson["nbOutputDevices"], "qint32", "");
|
::Swagger::setValue(&nb_output_devices, pJson["nbOutputDevices"], "qint32", "");
|
||||||
::Swagger::setValue(&output_device_selected_index, pJson["outputDeviceSelectedIndex"], "qint32", "");
|
::Swagger::setValue(&output_device_selected_index, pJson["outputDeviceSelectedIndex"], "qint32", "");
|
||||||
|
|
||||||
::Swagger::setValue(&output_devices, pJson["outputDevices"], "QList", "QString");
|
::Swagger::setValue(&output_devices, pJson["outputDevices"], "QList", "SWGAudioDevice");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,12 +109,14 @@ QJsonObject*
|
|||||||
SWGAudioDevices::asJsonObject() {
|
SWGAudioDevices::asJsonObject() {
|
||||||
QJsonObject* obj = new QJsonObject();
|
QJsonObject* obj = new QJsonObject();
|
||||||
|
|
||||||
|
obj->insert("inputVolume", QJsonValue(input_volume));
|
||||||
|
|
||||||
obj->insert("nbInputDevices", QJsonValue(nb_input_devices));
|
obj->insert("nbInputDevices", QJsonValue(nb_input_devices));
|
||||||
|
|
||||||
obj->insert("inputDeviceSelectedIndex", QJsonValue(input_device_selected_index));
|
obj->insert("inputDeviceSelectedIndex", QJsonValue(input_device_selected_index));
|
||||||
|
|
||||||
QJsonArray input_devicesJsonArray;
|
QJsonArray input_devicesJsonArray;
|
||||||
toJsonArray((QList<void*>*)input_devices, &input_devicesJsonArray, "input_devices", "QString");
|
toJsonArray((QList<void*>*)input_devices, &input_devicesJsonArray, "input_devices", "SWGAudioDevice");
|
||||||
obj->insert("inputDevices", input_devicesJsonArray);
|
obj->insert("inputDevices", input_devicesJsonArray);
|
||||||
|
|
||||||
obj->insert("nbOutputDevices", QJsonValue(nb_output_devices));
|
obj->insert("nbOutputDevices", QJsonValue(nb_output_devices));
|
||||||
@ -119,12 +124,21 @@ SWGAudioDevices::asJsonObject() {
|
|||||||
obj->insert("outputDeviceSelectedIndex", QJsonValue(output_device_selected_index));
|
obj->insert("outputDeviceSelectedIndex", QJsonValue(output_device_selected_index));
|
||||||
|
|
||||||
QJsonArray output_devicesJsonArray;
|
QJsonArray output_devicesJsonArray;
|
||||||
toJsonArray((QList<void*>*)output_devices, &output_devicesJsonArray, "output_devices", "QString");
|
toJsonArray((QList<void*>*)output_devices, &output_devicesJsonArray, "output_devices", "SWGAudioDevice");
|
||||||
obj->insert("outputDevices", output_devicesJsonArray);
|
obj->insert("outputDevices", output_devicesJsonArray);
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float
|
||||||
|
SWGAudioDevices::getInputVolume() {
|
||||||
|
return input_volume;
|
||||||
|
}
|
||||||
|
void
|
||||||
|
SWGAudioDevices::setInputVolume(float input_volume) {
|
||||||
|
this->input_volume = input_volume;
|
||||||
|
}
|
||||||
|
|
||||||
qint32
|
qint32
|
||||||
SWGAudioDevices::getNbInputDevices() {
|
SWGAudioDevices::getNbInputDevices() {
|
||||||
return nb_input_devices;
|
return nb_input_devices;
|
||||||
@ -143,12 +157,12 @@ SWGAudioDevices::setInputDeviceSelectedIndex(qint32 input_device_selected_index)
|
|||||||
this->input_device_selected_index = input_device_selected_index;
|
this->input_device_selected_index = input_device_selected_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QString*>*
|
QList<SWGAudioDevice*>*
|
||||||
SWGAudioDevices::getInputDevices() {
|
SWGAudioDevices::getInputDevices() {
|
||||||
return input_devices;
|
return input_devices;
|
||||||
}
|
}
|
||||||
void
|
void
|
||||||
SWGAudioDevices::setInputDevices(QList<QString*>* input_devices) {
|
SWGAudioDevices::setInputDevices(QList<SWGAudioDevice*>* input_devices) {
|
||||||
this->input_devices = input_devices;
|
this->input_devices = input_devices;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,12 +184,12 @@ SWGAudioDevices::setOutputDeviceSelectedIndex(qint32 output_device_selected_inde
|
|||||||
this->output_device_selected_index = output_device_selected_index;
|
this->output_device_selected_index = output_device_selected_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QString*>*
|
QList<SWGAudioDevice*>*
|
||||||
SWGAudioDevices::getOutputDevices() {
|
SWGAudioDevices::getOutputDevices() {
|
||||||
return output_devices;
|
return output_devices;
|
||||||
}
|
}
|
||||||
void
|
void
|
||||||
SWGAudioDevices::setOutputDevices(QList<QString*>* output_devices) {
|
SWGAudioDevices::setOutputDevices(QList<SWGAudioDevice*>* output_devices) {
|
||||||
this->output_devices = output_devices;
|
this->output_devices = output_devices;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,8 +22,8 @@
|
|||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
|
|
||||||
|
|
||||||
|
#include "SWGAudioDevice.h"
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QString>
|
|
||||||
|
|
||||||
#include "SWGObject.h"
|
#include "SWGObject.h"
|
||||||
|
|
||||||
@ -43,14 +43,17 @@ public:
|
|||||||
void fromJsonObject(QJsonObject &json);
|
void fromJsonObject(QJsonObject &json);
|
||||||
SWGAudioDevices* fromJson(QString &jsonString);
|
SWGAudioDevices* fromJson(QString &jsonString);
|
||||||
|
|
||||||
|
float getInputVolume();
|
||||||
|
void setInputVolume(float input_volume);
|
||||||
|
|
||||||
qint32 getNbInputDevices();
|
qint32 getNbInputDevices();
|
||||||
void setNbInputDevices(qint32 nb_input_devices);
|
void setNbInputDevices(qint32 nb_input_devices);
|
||||||
|
|
||||||
qint32 getInputDeviceSelectedIndex();
|
qint32 getInputDeviceSelectedIndex();
|
||||||
void setInputDeviceSelectedIndex(qint32 input_device_selected_index);
|
void setInputDeviceSelectedIndex(qint32 input_device_selected_index);
|
||||||
|
|
||||||
QList<QString*>* getInputDevices();
|
QList<SWGAudioDevice*>* getInputDevices();
|
||||||
void setInputDevices(QList<QString*>* input_devices);
|
void setInputDevices(QList<SWGAudioDevice*>* input_devices);
|
||||||
|
|
||||||
qint32 getNbOutputDevices();
|
qint32 getNbOutputDevices();
|
||||||
void setNbOutputDevices(qint32 nb_output_devices);
|
void setNbOutputDevices(qint32 nb_output_devices);
|
||||||
@ -58,17 +61,18 @@ public:
|
|||||||
qint32 getOutputDeviceSelectedIndex();
|
qint32 getOutputDeviceSelectedIndex();
|
||||||
void setOutputDeviceSelectedIndex(qint32 output_device_selected_index);
|
void setOutputDeviceSelectedIndex(qint32 output_device_selected_index);
|
||||||
|
|
||||||
QList<QString*>* getOutputDevices();
|
QList<SWGAudioDevice*>* getOutputDevices();
|
||||||
void setOutputDevices(QList<QString*>* output_devices);
|
void setOutputDevices(QList<SWGAudioDevice*>* output_devices);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
float input_volume;
|
||||||
qint32 nb_input_devices;
|
qint32 nb_input_devices;
|
||||||
qint32 input_device_selected_index;
|
qint32 input_device_selected_index;
|
||||||
QList<QString*>* input_devices;
|
QList<SWGAudioDevice*>* input_devices;
|
||||||
qint32 nb_output_devices;
|
qint32 nb_output_devices;
|
||||||
qint32 output_device_selected_index;
|
qint32 output_device_selected_index;
|
||||||
QList<QString*>* output_devices;
|
QList<SWGAudioDevice*>* output_devices;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -37,14 +37,16 @@ SWGAudioDevicesSelect::~SWGAudioDevicesSelect() {
|
|||||||
|
|
||||||
void
|
void
|
||||||
SWGAudioDevicesSelect::init() {
|
SWGAudioDevicesSelect::init() {
|
||||||
input = 0;
|
input_volume = 0.0f;
|
||||||
output = 0;
|
input_index = 0;
|
||||||
|
output_index = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SWGAudioDevicesSelect::cleanup() {
|
SWGAudioDevicesSelect::cleanup() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SWGAudioDevicesSelect*
|
SWGAudioDevicesSelect*
|
||||||
@ -58,8 +60,9 @@ SWGAudioDevicesSelect::fromJson(QString &json) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
SWGAudioDevicesSelect::fromJsonObject(QJsonObject &pJson) {
|
SWGAudioDevicesSelect::fromJsonObject(QJsonObject &pJson) {
|
||||||
::Swagger::setValue(&input, pJson["input"], "qint32", "");
|
::Swagger::setValue(&input_volume, pJson["inputVolume"], "float", "");
|
||||||
::Swagger::setValue(&output, pJson["output"], "qint32", "");
|
::Swagger::setValue(&input_index, pJson["inputIndex"], "qint32", "");
|
||||||
|
::Swagger::setValue(&output_index, pJson["outputIndex"], "qint32", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString
|
QString
|
||||||
@ -76,29 +79,40 @@ QJsonObject*
|
|||||||
SWGAudioDevicesSelect::asJsonObject() {
|
SWGAudioDevicesSelect::asJsonObject() {
|
||||||
QJsonObject* obj = new QJsonObject();
|
QJsonObject* obj = new QJsonObject();
|
||||||
|
|
||||||
obj->insert("input", QJsonValue(input));
|
obj->insert("inputVolume", QJsonValue(input_volume));
|
||||||
|
|
||||||
obj->insert("output", QJsonValue(output));
|
obj->insert("inputIndex", QJsonValue(input_index));
|
||||||
|
|
||||||
|
obj->insert("outputIndex", QJsonValue(output_index));
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
qint32
|
float
|
||||||
SWGAudioDevicesSelect::getInput() {
|
SWGAudioDevicesSelect::getInputVolume() {
|
||||||
return input;
|
return input_volume;
|
||||||
}
|
}
|
||||||
void
|
void
|
||||||
SWGAudioDevicesSelect::setInput(qint32 input) {
|
SWGAudioDevicesSelect::setInputVolume(float input_volume) {
|
||||||
this->input = input;
|
this->input_volume = input_volume;
|
||||||
}
|
}
|
||||||
|
|
||||||
qint32
|
qint32
|
||||||
SWGAudioDevicesSelect::getOutput() {
|
SWGAudioDevicesSelect::getInputIndex() {
|
||||||
return output;
|
return input_index;
|
||||||
}
|
}
|
||||||
void
|
void
|
||||||
SWGAudioDevicesSelect::setOutput(qint32 output) {
|
SWGAudioDevicesSelect::setInputIndex(qint32 input_index) {
|
||||||
this->output = output;
|
this->input_index = input_index;
|
||||||
|
}
|
||||||
|
|
||||||
|
qint32
|
||||||
|
SWGAudioDevicesSelect::getOutputIndex() {
|
||||||
|
return output_index;
|
||||||
|
}
|
||||||
|
void
|
||||||
|
SWGAudioDevicesSelect::setOutputIndex(qint32 output_index) {
|
||||||
|
this->output_index = output_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -41,16 +41,20 @@ public:
|
|||||||
void fromJsonObject(QJsonObject &json);
|
void fromJsonObject(QJsonObject &json);
|
||||||
SWGAudioDevicesSelect* fromJson(QString &jsonString);
|
SWGAudioDevicesSelect* fromJson(QString &jsonString);
|
||||||
|
|
||||||
qint32 getInput();
|
float getInputVolume();
|
||||||
void setInput(qint32 input);
|
void setInputVolume(float input_volume);
|
||||||
|
|
||||||
qint32 getOutput();
|
qint32 getInputIndex();
|
||||||
void setOutput(qint32 output);
|
void setInputIndex(qint32 input_index);
|
||||||
|
|
||||||
|
qint32 getOutputIndex();
|
||||||
|
void setOutputIndex(qint32 output_index);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
qint32 input;
|
float input_volume;
|
||||||
qint32 output;
|
qint32 input_index;
|
||||||
|
qint32 output_index;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#define ModelFactory_H_
|
#define ModelFactory_H_
|
||||||
|
|
||||||
|
|
||||||
|
#include "SWGAudioDevice.h"
|
||||||
#include "SWGAudioDevices.h"
|
#include "SWGAudioDevices.h"
|
||||||
#include "SWGAudioDevicesSelect.h"
|
#include "SWGAudioDevicesSelect.h"
|
||||||
#include "SWGChannel.h"
|
#include "SWGChannel.h"
|
||||||
@ -39,6 +40,9 @@
|
|||||||
namespace Swagger {
|
namespace Swagger {
|
||||||
|
|
||||||
inline void* create(QString type) {
|
inline void* create(QString type) {
|
||||||
|
if(QString("SWGAudioDevice").compare(type) == 0) {
|
||||||
|
return new SWGAudioDevice();
|
||||||
|
}
|
||||||
if(QString("SWGAudioDevices").compare(type) == 0) {
|
if(QString("SWGAudioDevices").compare(type) == 0) {
|
||||||
return new SWGAudioDevices();
|
return new SWGAudioDevices();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user