1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2025-08-16 04:32:30 -04:00

Multiple audio support: Web API: new GET and PATCHes to set input and output parameters

This commit is contained in:
f4exb 2018-03-29 00:38:01 +02:00
parent 231cb45aa6
commit 249ea735c8
21 changed files with 2748 additions and 491 deletions

File diff suppressed because it is too large Load Diff

View File

@ -182,9 +182,11 @@ paths:
$ref: "#/responses/Response_500" $ref: "#/responses/Response_500"
"501": "501":
$ref: "#/responses/Response_501" $ref: "#/responses/Response_501"
/sdrangel/audio/input/set:
x-swagger-router-controller: instance
patch: patch:
description: Set audio devices description: Set audio input device paramaters
operationId: instanceAudioPatch operationId: instanceAudioInputSetPatch
tags: tags:
- Instance - Instance
consumes: consumes:
@ -192,15 +194,49 @@ paths:
parameters: parameters:
- name: body - name: body
in: body in: body
description: Select audio devices to use for this instance description: Audio input parameters. Index is used to identify the device. Only settable fields are considered.
required: true required: true
schema: schema:
$ref: "#/definitions/AudioDevicesSelect" $ref: "#/definitions/AudioInputDevice"
responses: responses:
"200": "200":
description: Success description: Success. Returns actual data in particular the actual sample rate.
schema: schema:
$ref: "#/definitions/AudioDevicesSelect" $ref: "#/definitions/AudioInputDevice"
"404":
description: Audio input device not found
schema:
$ref: "#/definitions/ErrorResponse"
"500":
$ref: "#/responses/Response_500"
"501":
$ref: "#/responses/Response_501"
/sdrangel/audio/output/set:
x-swagger-router-controller: instance
patch:
description: Set audio output device parameters
operationId: instanceAudioOutputSetPatch
tags:
- Instance
consumes:
- application/json
parameters:
- name: body
in: body
description: Audio output parameters. Index is used to identify the device. Only settable fields are considered.
required: true
schema:
$ref: "#/definitions/AudioOutputDevice"
responses:
"200":
description: Success. Returns actual data in particular the actual sample rate.
schema:
$ref: "#/definitions/AudioOutputDevice"
"404":
description: Audio output device not found
schema:
$ref: "#/definitions/ErrorResponse"
"500": "500":
$ref: "#/responses/Response_500" $ref: "#/responses/Response_500"
"501": "501":
@ -1355,62 +1391,81 @@ 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
- nbOutputDevices - nbOutputDevices
- 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
inputDeviceSelectedIndex:
description: "Index of selected input audio devices (-1 if default)"
type: integer
inputDevices: inputDevices:
description: "List of input devices" description: "List of input devices"
type: array type: array
items: items:
$ref: "#/definitions/AudioDevice" $ref: "#/definitions/AudioInputDevice"
nbOutputDevices: nbOutputDevices:
description: "Number of output audio devices" description: "Number of output audio devices"
type: integer type: integer
outputDeviceSelectedIndex:
description: "Index of selected output audio devices (-1 if default)"
type: integer
outputDevices: outputDevices:
description: "List of output devices" description: "List of output devices"
type: array type: array
items: items:
$ref: "#/definitions/AudioDevice" $ref: "#/definitions/AudioOutputDevice"
AudioDevice: AudioInputDevice:
description: "Audio device" description: "Audio input device"
properties: properties:
name: name:
description: "Displayable name of the device" description: "Displayable name of the device"
type: string type: string
index:
AudioDevicesSelect: description: "Index in attached devices list. -1 for system default"
description: "Audio devices selected" type: integer
required: sampleRate:
- inputVolume description: "Device sample rate in S/s"
- inputIndex type: integer
- outputIndex isSystemDefault:
properties: description: "1 if this device is the system default else 0"
inputVolume: type: integer
defaultUnregistered:
description: "1 if this device is unregistered and therefore will inherit default values else 0"
type: integer
volume:
description: "Audio input volume [0.0..1.0]" description: "Audio input volume [0.0..1.0]"
type: number type: number
format: float format: float
inputIndex:
description: "Index of the audio input device (-1 for default)" AudioOutputDevice:
description: "Audio output device"
properties:
name:
description: "Displayable name of the device"
type: string
index:
description: "Index in attached devices list. -1 for system default"
type: integer type: integer
outputIndex: sampleRate:
description: "Index of the audio output device (-1 for default)" description: "Device sample rate in S/s"
type: integer
isSystemDefault:
description: "1 if this device is the system default else 0"
type: integer
defaultUnregistered:
description: "1 if this device is unregistered and therefore will inherit default values else 0"
type: integer
copyToUDP:
description: '1 if audio is copied to UDP else 0'
type: integer
udpUsesRTP:
description: '1 if RTP protocol is used over UDP else 0'
type: integer
udpChannelMode:
description: 'How audio data is copied to UDP: 0: left 1: right 2: mixed 3: stereo'
type: integer
udpAddress:
description: "UDP destination address"
type: string
udpPort:
description: "UDP destination port"
type: integer type: integer
LocationInformation: LocationInformation:

View File

@ -23,6 +23,10 @@ QString WebAPIAdapterInterface::instanceDevicesURL = "/sdrangel/devices";
QString WebAPIAdapterInterface::instanceChannelsURL = "/sdrangel/channels"; QString WebAPIAdapterInterface::instanceChannelsURL = "/sdrangel/channels";
QString WebAPIAdapterInterface::instanceLoggingURL = "/sdrangel/logging"; QString WebAPIAdapterInterface::instanceLoggingURL = "/sdrangel/logging";
QString WebAPIAdapterInterface::instanceAudioURL = "/sdrangel/audio"; QString WebAPIAdapterInterface::instanceAudioURL = "/sdrangel/audio";
QString WebAPIAdapterInterface::instanceAudioInputSetURL = "/sdrangel/audio/input/set";
QString WebAPIAdapterInterface::instanceAudioOutputSetURL = "/sdrangel/audio/output/set";
QString WebAPIAdapterInterface::instanceAudioInputUnsetURL = "/sdrangel/audio/input/unset";
QString WebAPIAdapterInterface::instanceAudioOutputUnsetURL = "/sdrangel/audio/output/unset";
QString WebAPIAdapterInterface::instanceLocationURL = "/sdrangel/location"; QString WebAPIAdapterInterface::instanceLocationURL = "/sdrangel/location";
QString WebAPIAdapterInterface::instanceDVSerialURL = "/sdrangel/dvserial"; QString WebAPIAdapterInterface::instanceDVSerialURL = "/sdrangel/dvserial";
QString WebAPIAdapterInterface::instancePresetsURL = "/sdrangel/presets"; QString WebAPIAdapterInterface::instancePresetsURL = "/sdrangel/presets";

View File

@ -33,7 +33,8 @@ namespace SWGSDRangel
class SWGInstanceChannelsResponse; class SWGInstanceChannelsResponse;
class SWGLoggingInfo; class SWGLoggingInfo;
class SWGAudioDevices; class SWGAudioDevices;
class SWGAudioDevicesSelect; class SWGAudioInputDevice;
class SWGAudioOutputDevice;
class SWGLocationInformation; class SWGLocationInformation;
class SWGDVSeralDevices; class SWGDVSeralDevices;
class SWGPresets; class SWGPresets;
@ -152,11 +153,26 @@ public:
} }
/** /**
* Handler of /sdrangel/audio (PATCH) swagger/sdrangel/code/html2/index.html#api-Default-instanceChannels * Handler of /sdrangel/audio/input (PATCH) swagger/sdrangel/code/html2/index.html#api-Default-instanceChannels
* returns the Http status code (default 501: not implemented) * returns the Http status code (default 501: not implemented)
*/ */
virtual int instanceAudioPatch( virtual int instanceAudioInputPatch(
SWGSDRangel::SWGAudioDevicesSelect& response __attribute__((unused)), SWGSDRangel::SWGAudioInputDevice& response __attribute__((unused)),
const QStringList& audioInputKeys __attribute__((unused)),
SWGSDRangel::SWGErrorResponse& error)
{
error.init();
*error.getMessage() = QString("Function not implemented");
return 501;
}
/**
* Handler of /sdrangel/audio/output (PATCH) swagger/sdrangel/code/html2/index.html#api-Default-instanceChannels
* returns the Http status code (default 501: not implemented)
*/
virtual int instanceAudioOutputPatch(
SWGSDRangel::SWGAudioOutputDevice& response __attribute__((unused)),
const QStringList& audioOutputKeys __attribute__((unused)),
SWGSDRangel::SWGErrorResponse& error) SWGSDRangel::SWGErrorResponse& error)
{ {
error.init(); error.init();
@ -552,6 +568,10 @@ public:
static QString instanceChannelsURL; static QString instanceChannelsURL;
static QString instanceLoggingURL; static QString instanceLoggingURL;
static QString instanceAudioURL; static QString instanceAudioURL;
static QString instanceAudioInputSetURL;
static QString instanceAudioOutputSetURL;
static QString instanceAudioInputUnsetURL;
static QString instanceAudioOutputUnsetURL;
static QString instanceLocationURL; static QString instanceLocationURL;
static QString instanceDVSerialURL; static QString instanceDVSerialURL;
static QString instancePresetsURL; static QString instancePresetsURL;

View File

@ -84,6 +84,10 @@ void WebAPIRequestMapper::service(qtwebapp::HttpRequest& request, qtwebapp::Http
instanceLoggingService(request, response); instanceLoggingService(request, response);
} else if (path == WebAPIAdapterInterface::instanceAudioURL) { } else if (path == WebAPIAdapterInterface::instanceAudioURL) {
instanceAudioService(request, response); instanceAudioService(request, response);
} else if (path == WebAPIAdapterInterface::instanceAudioInputSetURL) {
instanceAudioInputSetService(request, response);
} else if (path == WebAPIAdapterInterface::instanceAudioOutputSetURL) {
instanceAudioOutputSetService(request, response);
} else if (path == WebAPIAdapterInterface::instanceLocationURL) { } else if (path == WebAPIAdapterInterface::instanceLocationURL) {
instanceLocationService(request, response); instanceLocationService(request, response);
} else if (path == WebAPIAdapterInterface::instanceDVSerialURL) { } else if (path == WebAPIAdapterInterface::instanceDVSerialURL) {
@ -315,16 +319,38 @@ void WebAPIRequestMapper::instanceAudioService(qtwebapp::HttpRequest& request, q
response.write(errorResponse.asJson().toUtf8()); response.write(errorResponse.asJson().toUtf8());
} }
} }
else if (request.getMethod() == "PATCH") else
{
response.setStatus(405,"Invalid HTTP method");
errorResponse.init();
*errorResponse.getMessage() = "Invalid HTTP method";
response.write(errorResponse.asJson().toUtf8());
}
}
void WebAPIRequestMapper::instanceAudioInputSetService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response)
{
// TODO
SWGSDRangel::SWGErrorResponse errorResponse;
response.setHeader("Content-Type", "application/json");
if (request.getMethod() == "PATCH")
{ {
SWGSDRangel::SWGAudioDevicesSelect normalResponse;
QString jsonStr = request.getBody(); QString jsonStr = request.getBody();
QJsonObject jsonObject; QJsonObject jsonObject;
if (parseJsonBody(jsonStr, jsonObject, response)) if (parseJsonBody(jsonStr, jsonObject, response))
{ {
normalResponse.fromJson(jsonStr); SWGSDRangel::SWGAudioInputDevice normalResponse;
int status = m_adapter->instanceAudioPatch(normalResponse, errorResponse); resetAudioInputDevice(normalResponse);
QStringList audioInputDeviceKeys;
if (validateAudioInputDevice(normalResponse, jsonObject, audioInputDeviceKeys))
{
int status = m_adapter->instanceAudioInputPatch(
normalResponse,
audioInputDeviceKeys,
errorResponse);
response.setStatus(status); response.setStatus(status);
if (status/100 == 2) { if (status/100 == 2) {
@ -334,6 +360,69 @@ void WebAPIRequestMapper::instanceAudioService(qtwebapp::HttpRequest& request, q
} }
} }
else else
{
response.setStatus(400,"Invalid JSON request");
errorResponse.init();
*errorResponse.getMessage() = "Invalid JSON request";
response.write(errorResponse.asJson().toUtf8());
}
}
else
{
response.setStatus(400,"Invalid JSON format");
errorResponse.init();
*errorResponse.getMessage() = "Invalid JSON format";
response.write(errorResponse.asJson().toUtf8());
}
}
else
{
response.setStatus(405,"Invalid HTTP method");
errorResponse.init();
*errorResponse.getMessage() = "Invalid HTTP method";
response.write(errorResponse.asJson().toUtf8());
}
}
void WebAPIRequestMapper::instanceAudioOutputSetService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response)
{
SWGSDRangel::SWGErrorResponse errorResponse;
response.setHeader("Content-Type", "application/json");
if (request.getMethod() == "PATCH")
{
QString jsonStr = request.getBody();
QJsonObject jsonObject;
if (parseJsonBody(jsonStr, jsonObject, response))
{
SWGSDRangel::SWGAudioOutputDevice normalResponse;
resetAudioOutputDevice(normalResponse);
QStringList audioOutputDeviceKeys;
if (validateAudioOutputDevice(normalResponse, jsonObject, audioOutputDeviceKeys))
{
int status = m_adapter->instanceAudioOutputPatch(
normalResponse,
audioOutputDeviceKeys,
errorResponse);
response.setStatus(status);
if (status/100 == 2) {
response.write(normalResponse.asJson().toUtf8());
} else {
response.write(errorResponse.asJson().toUtf8());
}
}
else
{
response.setStatus(400,"Invalid JSON request");
errorResponse.init();
*errorResponse.getMessage() = "Invalid JSON request";
response.write(errorResponse.asJson().toUtf8());
}
}
else
{ {
response.setStatus(400,"Invalid JSON format"); response.setStatus(400,"Invalid JSON format");
errorResponse.init(); errorResponse.init();
@ -1745,6 +1834,72 @@ bool WebAPIRequestMapper::validateChannelReport(
} }
} }
bool WebAPIRequestMapper::validateAudioInputDevice(
SWGSDRangel::SWGAudioInputDevice& audioInputDevice,
QJsonObject& jsonObject,
QStringList& audioInputDeviceKeys)
{
if (jsonObject.contains("index")) {
audioInputDevice.setIndex(jsonObject["index"].toInt());
} else {
audioInputDevice.setIndex(-1); // assume systam default
}
if (jsonObject.contains("sampleRate"))
{
audioInputDevice.setSampleRate(jsonObject["sampleRate"].toInt());
audioInputDeviceKeys.append("sampleRate");
}
if (jsonObject.contains("volume"))
{
audioInputDevice.setVolume(jsonObject["volume"].toDouble());
audioInputDeviceKeys.append("volume");
}
return true;
}
bool WebAPIRequestMapper::validateAudioOutputDevice(
SWGSDRangel::SWGAudioOutputDevice& audioOutputDevice,
QJsonObject& jsonObject,
QStringList& audioOutputDeviceKeys)
{
if (jsonObject.contains("index")) {
audioOutputDevice.setIndex(jsonObject["index"].toInt());
} else {
audioOutputDevice.setIndex(-1); // assume systam default
}
if (jsonObject.contains("sampleRate"))
{
audioOutputDevice.setSampleRate(jsonObject["sampleRate"].toInt());
audioOutputDeviceKeys.append("sampleRate");
}
if (jsonObject.contains("copyToUDP"))
{
audioOutputDevice.setCopyToUdp(jsonObject["copyToUDP"].toInt() == 0 ? 0 : 1);
audioOutputDeviceKeys.append("copyToUDP");
}
if (jsonObject.contains("udpUsesRTP"))
{
audioOutputDevice.setUdpUsesRtp(jsonObject["udpUsesRTP"].toInt() == 0 ? 0 : 1);
audioOutputDeviceKeys.append("udpUsesRTP");
}
if (jsonObject.contains("udpChannelMode"))
{
audioOutputDevice.setUdpChannelMode(jsonObject["udpChannelMode"].toInt());
audioOutputDeviceKeys.append("udpChannelMode");
}
if (jsonObject.contains("udpAddress"))
{
audioOutputDevice.setUdpAddress(new QString(jsonObject["udpAddress"].toString()));
audioOutputDeviceKeys.append("udpAddress");
}
if (jsonObject.contains("udpPort"))
{
audioOutputDevice.setUdpPort(jsonObject["udpPort"].toInt());
audioOutputDeviceKeys.append("udpPort");
}
return true;
}
void WebAPIRequestMapper::appendSettingsSubKeys( void WebAPIRequestMapper::appendSettingsSubKeys(
const QJsonObject& parentSettingsJsonObject, const QJsonObject& parentSettingsJsonObject,
QJsonObject& childSettingsJsonObject, QJsonObject& childSettingsJsonObject,
@ -1786,3 +1941,16 @@ void WebAPIRequestMapper::resetChannelReport(SWGSDRangel::SWGChannelReport& chan
channelReport.setNfmDemodReport(0); channelReport.setNfmDemodReport(0);
channelReport.setNfmModReport(0); channelReport.setNfmModReport(0);
} }
void WebAPIRequestMapper::resetAudioInputDevice(SWGSDRangel::SWGAudioInputDevice& audioInputDevice)
{
audioInputDevice.cleanup();
audioInputDevice.setName(0);
}
void WebAPIRequestMapper::resetAudioOutputDevice(SWGSDRangel::SWGAudioOutputDevice& audioOutputDevice)
{
audioOutputDevice.cleanup();
audioOutputDevice.setName(0);
audioOutputDevice.setUdpAddress(0);
}

View File

@ -52,6 +52,8 @@ private:
void instanceChannelsService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response); void instanceChannelsService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
void instanceLoggingService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response); void instanceLoggingService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
void instanceAudioService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response); void instanceAudioService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
void instanceAudioInputSetService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
void instanceAudioOutputSetService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
void instanceLocationService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response); void instanceLocationService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
void instanceDVSerialService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response); void instanceDVSerialService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
void instancePresetsService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response); void instancePresetsService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
@ -78,6 +80,8 @@ private:
bool validateDeviceSettings(SWGSDRangel::SWGDeviceSettings& deviceSettings, QJsonObject& jsonObject, QStringList& deviceSettingsKeys); bool validateDeviceSettings(SWGSDRangel::SWGDeviceSettings& deviceSettings, QJsonObject& jsonObject, QStringList& deviceSettingsKeys);
bool validateChannelSettings(SWGSDRangel::SWGChannelSettings& deviceSettings, QJsonObject& jsonObject, QStringList& channelSettingsKeys); bool validateChannelSettings(SWGSDRangel::SWGChannelSettings& deviceSettings, QJsonObject& jsonObject, QStringList& channelSettingsKeys);
bool validateChannelReport(SWGSDRangel::SWGChannelReport& deviceReport, QJsonObject& jsonObject, QStringList& channelReportKeys); bool validateChannelReport(SWGSDRangel::SWGChannelReport& deviceReport, QJsonObject& jsonObject, QStringList& channelReportKeys);
bool validateAudioInputDevice(SWGSDRangel::SWGAudioInputDevice& audioInputDevice, QJsonObject& jsonObject, QStringList& audioInputDeviceKeys);
bool validateAudioOutputDevice(SWGSDRangel::SWGAudioOutputDevice& audioOutputDevice, QJsonObject& jsonObject, QStringList& audioOutputDeviceKeys);
void appendSettingsSubKeys( void appendSettingsSubKeys(
const QJsonObject& parentSettingsJsonObject, const QJsonObject& parentSettingsJsonObject,
@ -90,6 +94,8 @@ private:
void resetDeviceSettings(SWGSDRangel::SWGDeviceSettings& deviceSettings); void resetDeviceSettings(SWGSDRangel::SWGDeviceSettings& deviceSettings);
void resetChannelSettings(SWGSDRangel::SWGChannelSettings& deviceSettings); void resetChannelSettings(SWGSDRangel::SWGChannelSettings& deviceSettings);
void resetChannelReport(SWGSDRangel::SWGChannelReport& deviceSettings); void resetChannelReport(SWGSDRangel::SWGChannelReport& deviceSettings);
void resetAudioInputDevice(SWGSDRangel::SWGAudioInputDevice& audioInputDevice);
void resetAudioOutputDevice(SWGSDRangel::SWGAudioOutputDevice& audioOutputDevice);
}; };
#endif /* SDRBASE_WEBAPI_WEBAPIREQUESTMAPPER_H_ */ #endif /* SDRBASE_WEBAPI_WEBAPIREQUESTMAPPER_H_ */

View File

@ -234,51 +234,162 @@ int WebAPIAdapterGUI::instanceAudioGet(
response.init(); response.init();
response.setNbInputDevices(nbInputDevices); response.setNbInputDevices(nbInputDevices);
response.setInputDeviceSelectedIndex(-1); // FIXME: remove
response.setNbOutputDevices(nbOutputDevices); response.setNbOutputDevices(nbOutputDevices);
response.setOutputDeviceSelectedIndex(-1); // FIXME: remove QList<SWGSDRangel::SWGAudioInputDevice*> *inputDevices = response.getInputDevices();
response.setInputVolume(1.0f); // FIXME: remove QList<SWGSDRangel::SWGAudioOutputDevice*> *outputDevices = response.getOutputDevices();
QList<SWGSDRangel::SWGAudioDevice*> *inputDevices = response.getInputDevices(); AudioDeviceManager::InputDeviceInfo inputDeviceInfo;
QList<SWGSDRangel::SWGAudioDevice*> *outputDevices = response.getOutputDevices(); AudioDeviceManager::OutputDeviceInfo outputDeviceInfo;
// system default input device
inputDevices->append(new SWGSDRangel::SWGAudioInputDevice);
inputDevices->back()->init();
bool found = m_mainWindow.m_dspEngine->getAudioDeviceManager()->getInputDeviceInfo(AudioDeviceManager::m_defaultDeviceName, inputDeviceInfo);
*inputDevices->back()->getName() = AudioDeviceManager::m_defaultDeviceName;
inputDevices->back()->setIndex(-1);
inputDevices->back()->setSampleRate(inputDeviceInfo.sampleRate);
inputDevices->back()->setIsSystemDefault(0);
inputDevices->back()->setDefaultUnregistered(found ? 0 : 1);
inputDevices->back()->setVolume(inputDeviceInfo.volume);
// real input devices
for (int i = 0; i < nbInputDevices; i++) for (int i = 0; i < nbInputDevices; i++)
{ {
inputDevices->append(new SWGSDRangel::SWGAudioDevice); inputDevices->append(new SWGSDRangel::SWGAudioInputDevice);
inputDevices->back()->init(); inputDevices->back()->init();
inputDeviceInfo.resetToDefaults();
found = m_mainWindow.m_dspEngine->getAudioDeviceManager()->getInputDeviceInfo(audioInputDevices.at(i).deviceName(), inputDeviceInfo);
*inputDevices->back()->getName() = audioInputDevices.at(i).deviceName(); *inputDevices->back()->getName() = audioInputDevices.at(i).deviceName();
inputDevices->back()->setIndex(i);
inputDevices->back()->setSampleRate(inputDeviceInfo.sampleRate);
inputDevices->back()->setIsSystemDefault(audioInputDevices.at(i).deviceName() == QAudioDeviceInfo::defaultInputDevice().deviceName() ? 1 : 0);
inputDevices->back()->setDefaultUnregistered(found ? 0 : 1);
inputDevices->back()->setVolume(inputDeviceInfo.volume);
} }
// system default output device
outputDevices->append(new SWGSDRangel::SWGAudioOutputDevice);
outputDevices->back()->init();
found = m_mainWindow.m_dspEngine->getAudioDeviceManager()->getOutputDeviceInfo(AudioDeviceManager::m_defaultDeviceName, outputDeviceInfo);
*outputDevices->back()->getName() = AudioDeviceManager::m_defaultDeviceName;
outputDevices->back()->setIndex(-1);
outputDevices->back()->setSampleRate(outputDeviceInfo.sampleRate);
inputDevices->back()->setIsSystemDefault(0);
outputDevices->back()->setDefaultUnregistered(found ? 0 : 1);
outputDevices->back()->setCopyToUdp(outputDeviceInfo.copyToUDP ? 1 : 0);
outputDevices->back()->setUdpUsesRtp(outputDeviceInfo.udpUseRTP ? 1 : 0);
outputDevices->back()->setUdpChannelMode((int) outputDeviceInfo.udpChannelMode);
*outputDevices->back()->getUdpAddress() = outputDeviceInfo.udpAddress;
outputDevices->back()->setUdpPort(outputDeviceInfo.udpPort);
// real output devices
for (int i = 0; i < nbOutputDevices; i++) for (int i = 0; i < nbOutputDevices; i++)
{ {
outputDevices->append(new SWGSDRangel::SWGAudioDevice); outputDevices->append(new SWGSDRangel::SWGAudioOutputDevice);
outputDevices->back()->init(); outputDevices->back()->init();
outputDeviceInfo.resetToDefaults();
found = m_mainWindow.m_dspEngine->getAudioDeviceManager()->getOutputDeviceInfo(audioOutputDevices.at(i).deviceName(), outputDeviceInfo);
*outputDevices->back()->getName() = audioOutputDevices.at(i).deviceName(); *outputDevices->back()->getName() = audioOutputDevices.at(i).deviceName();
outputDevices->back()->setIndex(i);
outputDevices->back()->setSampleRate(outputDeviceInfo.sampleRate);
outputDevices->back()->setIsSystemDefault(audioOutputDevices.at(i).deviceName() == QAudioDeviceInfo::defaultOutputDevice().deviceName() ? 1 : 0);
outputDevices->back()->setDefaultUnregistered(found ? 0 : 1);
outputDevices->back()->setCopyToUdp(outputDeviceInfo.copyToUDP ? 1 : 0);
outputDevices->back()->setUdpUsesRtp(outputDeviceInfo.udpUseRTP ? 1 : 0);
outputDevices->back()->setUdpChannelMode((int) outputDeviceInfo.udpChannelMode);
*outputDevices->back()->getUdpAddress() = outputDeviceInfo.udpAddress;
outputDevices->back()->setUdpPort(outputDeviceInfo.udpPort);
} }
return 200; return 200;
} }
int WebAPIAdapterGUI::instanceAudioPatch( int WebAPIAdapterGUI::instanceAudioInputPatch(
SWGSDRangel::SWGAudioDevicesSelect& response, SWGSDRangel::SWGAudioInputDevice& response,
SWGSDRangel::SWGErrorResponse& error __attribute__((unused))) const QStringList& audioInputKeys,
SWGSDRangel::SWGErrorResponse& error)
{ {
// response input is the query actually // TODO
float inputVolume = response.getInputVolume(); AudioDeviceManager::InputDeviceInfo inputDeviceInfo;
int inputIndex = response.getInputIndex(); QString deviceName;
int outputIndex = response.getOutputIndex(); int deviceIndex = response.getIndex();
const QList<QAudioDeviceInfo>& audioInputDevices = m_mainWindow.m_dspEngine->getAudioDeviceManager()->getInputDevices(); if (!m_mainWindow.m_dspEngine->getAudioDeviceManager()->getInputDeviceName(deviceIndex, deviceName))
const QList<QAudioDeviceInfo>& audioOutputDevices = m_mainWindow.m_dspEngine->getAudioDeviceManager()->getOutputDevices(); {
int nbInputDevices = audioInputDevices.size(); error.init();
int nbOutputDevices = audioOutputDevices.size(); *error.getMessage() = QString("There is no audio input device at index %1").arg(deviceIndex);
return 404;
}
inputVolume = inputVolume < 0.0 ? 0.0 : inputVolume > 1.0 ? 1.0 : inputVolume; m_mainWindow.m_dspEngine->getAudioDeviceManager()->getInputDeviceInfo(deviceName, inputDeviceInfo);
inputIndex = inputIndex < -1 ? -1 : inputIndex > nbInputDevices ? nbInputDevices-1 : inputIndex;
outputIndex = outputIndex < -1 ? -1 : outputIndex > nbOutputDevices ? nbOutputDevices-1 : outputIndex;
response.setInputVolume(1.0f); // FIXME: remove if (audioInputKeys.contains("sampleRate")) {
response.setInputIndex(-1); // FIXME: remove inputDeviceInfo.sampleRate = response.getSampleRate();
response.setOutputIndex(-1); // FIXME: remove }
if (audioInputKeys.contains("volume")) {
inputDeviceInfo.volume = response.getVolume();
}
m_mainWindow.m_dspEngine->getAudioDeviceManager()->setInputDeviceInfo(deviceIndex, inputDeviceInfo);
m_mainWindow.m_dspEngine->getAudioDeviceManager()->getInputDeviceInfo(deviceName, inputDeviceInfo);
response.setSampleRate(inputDeviceInfo.sampleRate);
response.setVolume(inputDeviceInfo.volume);
return 200;
}
int WebAPIAdapterGUI::instanceAudioOutputPatch(
SWGSDRangel::SWGAudioOutputDevice& response,
const QStringList& audioOutputKeys,
SWGSDRangel::SWGErrorResponse& error)
{
AudioDeviceManager::OutputDeviceInfo outputDeviceInfo;
QString deviceName;
int deviceIndex = response.getIndex();
if (!m_mainWindow.m_dspEngine->getAudioDeviceManager()->getOutputDeviceName(deviceIndex, deviceName))
{
error.init();
*error.getMessage() = QString("There is no audio output device at index %1").arg(deviceIndex);
return 404;
}
m_mainWindow.m_dspEngine->getAudioDeviceManager()->getOutputDeviceInfo(deviceName, outputDeviceInfo);
if (audioOutputKeys.contains("sampleRate")) {
outputDeviceInfo.sampleRate = response.getSampleRate();
}
if (audioOutputKeys.contains("copyToUDP")) {
outputDeviceInfo.copyToUDP = response.getCopyToUdp() == 0 ? 0 : 1;
}
if (audioOutputKeys.contains("udpUsesRTP")) {
outputDeviceInfo.udpUseRTP = response.getUdpUsesRtp() == 0 ? 0 : 1;
}
if (audioOutputKeys.contains("udpChannelMode")) {
outputDeviceInfo.udpChannelMode = static_cast<AudioOutput::UDPChannelMode>(response.getUdpChannelMode() % 4);
}
if (audioOutputKeys.contains("udpAddress")) {
outputDeviceInfo.udpAddress = *response.getUdpAddress();
}
if (audioOutputKeys.contains("udpPort")) {
outputDeviceInfo.udpPort = response.getUdpPort() % (1<<16);
}
m_mainWindow.m_dspEngine->getAudioDeviceManager()->setOutputDeviceInfo(deviceIndex, outputDeviceInfo);
m_mainWindow.m_dspEngine->getAudioDeviceManager()->getOutputDeviceInfo(deviceName, outputDeviceInfo);
response.setSampleRate(outputDeviceInfo.sampleRate);
response.setCopyToUdp(outputDeviceInfo.copyToUDP == 0 ? 0 : 1);
response.setUdpUsesRtp(outputDeviceInfo.udpUseRTP == 0 ? 0 : 1);
response.setUdpChannelMode(outputDeviceInfo.udpChannelMode % 4);
if (response.getUdpAddress()) {
*response.getUdpAddress() = outputDeviceInfo.udpAddress;
} else {
response.setUdpAddress(new QString(outputDeviceInfo.udpAddress));
}
response.setUdpPort(outputDeviceInfo.udpPort % (1<<16));
return 200; return 200;
} }

View File

@ -63,8 +63,14 @@ public:
SWGSDRangel::SWGAudioDevices& response, SWGSDRangel::SWGAudioDevices& response,
SWGSDRangel::SWGErrorResponse& error); SWGSDRangel::SWGErrorResponse& error);
virtual int instanceAudioPatch( virtual int instanceAudioInputPatch(
SWGSDRangel::SWGAudioDevicesSelect& response, SWGSDRangel::SWGAudioInputDevice& response,
const QStringList& audioInputKeys,
SWGSDRangel::SWGErrorResponse& error);
virtual int instanceAudioOutputPatch(
SWGSDRangel::SWGAudioOutputDevice& response,
const QStringList& audioOutputKeys,
SWGSDRangel::SWGErrorResponse& error); SWGSDRangel::SWGErrorResponse& error);
virtual int instanceLocationGet( virtual int instanceLocationGet(

View File

@ -235,51 +235,162 @@ int WebAPIAdapterSrv::instanceAudioGet(
response.init(); response.init();
response.setNbInputDevices(nbInputDevices); response.setNbInputDevices(nbInputDevices);
response.setInputDeviceSelectedIndex(-1); // FIXME: remove
response.setNbOutputDevices(nbOutputDevices); response.setNbOutputDevices(nbOutputDevices);
response.setOutputDeviceSelectedIndex(-1); // FIXME: remove QList<SWGSDRangel::SWGAudioInputDevice*> *inputDevices = response.getInputDevices();
response.setInputVolume(1.0f); // FIXME: remove QList<SWGSDRangel::SWGAudioOutputDevice*> *outputDevices = response.getOutputDevices();
QList<SWGSDRangel::SWGAudioDevice*> *inputDevices = response.getInputDevices(); AudioDeviceManager::InputDeviceInfo inputDeviceInfo;
QList<SWGSDRangel::SWGAudioDevice*> *outputDevices = response.getOutputDevices(); AudioDeviceManager::OutputDeviceInfo outputDeviceInfo;
// system default input device
inputDevices->append(new SWGSDRangel::SWGAudioInputDevice);
inputDevices->back()->init();
bool found = m_mainCore.m_dspEngine->getAudioDeviceManager()->getInputDeviceInfo(AudioDeviceManager::m_defaultDeviceName, inputDeviceInfo);
*inputDevices->back()->getName() = AudioDeviceManager::m_defaultDeviceName;
inputDevices->back()->setIndex(-1);
inputDevices->back()->setSampleRate(inputDeviceInfo.sampleRate);
inputDevices->back()->setIsSystemDefault(0);
inputDevices->back()->setDefaultUnregistered(found ? 0 : 1);
inputDevices->back()->setVolume(inputDeviceInfo.volume);
// real input devices
for (int i = 0; i < nbInputDevices; i++) for (int i = 0; i < nbInputDevices; i++)
{ {
inputDevices->append(new SWGSDRangel::SWGAudioDevice); inputDevices->append(new SWGSDRangel::SWGAudioInputDevice);
inputDevices->back()->init(); inputDevices->back()->init();
inputDeviceInfo.resetToDefaults();
found = m_mainCore.m_dspEngine->getAudioDeviceManager()->getInputDeviceInfo(audioInputDevices.at(i).deviceName(), inputDeviceInfo);
*inputDevices->back()->getName() = audioInputDevices.at(i).deviceName(); *inputDevices->back()->getName() = audioInputDevices.at(i).deviceName();
inputDevices->back()->setIndex(i);
inputDevices->back()->setSampleRate(inputDeviceInfo.sampleRate);
inputDevices->back()->setIsSystemDefault(audioInputDevices.at(i).deviceName() == QAudioDeviceInfo::defaultInputDevice().deviceName() ? 1 : 0);
inputDevices->back()->setDefaultUnregistered(found ? 0 : 1);
inputDevices->back()->setVolume(inputDeviceInfo.volume);
} }
// system default output device
outputDevices->append(new SWGSDRangel::SWGAudioOutputDevice);
outputDevices->back()->init();
found = m_mainCore.m_dspEngine->getAudioDeviceManager()->getOutputDeviceInfo(AudioDeviceManager::m_defaultDeviceName, outputDeviceInfo);
*outputDevices->back()->getName() = AudioDeviceManager::m_defaultDeviceName;
outputDevices->back()->setIndex(-1);
outputDevices->back()->setSampleRate(outputDeviceInfo.sampleRate);
inputDevices->back()->setIsSystemDefault(0);
outputDevices->back()->setDefaultUnregistered(found ? 0 : 1);
outputDevices->back()->setCopyToUdp(outputDeviceInfo.copyToUDP ? 1 : 0);
outputDevices->back()->setUdpUsesRtp(outputDeviceInfo.udpUseRTP ? 1 : 0);
outputDevices->back()->setUdpChannelMode((int) outputDeviceInfo.udpChannelMode);
*outputDevices->back()->getUdpAddress() = outputDeviceInfo.udpAddress;
outputDevices->back()->setUdpPort(outputDeviceInfo.udpPort);
// real output devices
for (int i = 0; i < nbOutputDevices; i++) for (int i = 0; i < nbOutputDevices; i++)
{ {
outputDevices->append(new SWGSDRangel::SWGAudioDevice); outputDevices->append(new SWGSDRangel::SWGAudioOutputDevice);
outputDevices->back()->init(); outputDevices->back()->init();
outputDeviceInfo.resetToDefaults();
found = m_mainCore.m_dspEngine->getAudioDeviceManager()->getOutputDeviceInfo(audioOutputDevices.at(i).deviceName(), outputDeviceInfo);
*outputDevices->back()->getName() = audioOutputDevices.at(i).deviceName(); *outputDevices->back()->getName() = audioOutputDevices.at(i).deviceName();
outputDevices->back()->setIndex(i);
outputDevices->back()->setSampleRate(outputDeviceInfo.sampleRate);
outputDevices->back()->setIsSystemDefault(audioOutputDevices.at(i).deviceName() == QAudioDeviceInfo::defaultOutputDevice().deviceName() ? 1 : 0);
outputDevices->back()->setDefaultUnregistered(found ? 0 : 1);
outputDevices->back()->setCopyToUdp(outputDeviceInfo.copyToUDP ? 1 : 0);
outputDevices->back()->setUdpUsesRtp(outputDeviceInfo.udpUseRTP ? 1 : 0);
outputDevices->back()->setUdpChannelMode((int) outputDeviceInfo.udpChannelMode);
*outputDevices->back()->getUdpAddress() = outputDeviceInfo.udpAddress;
outputDevices->back()->setUdpPort(outputDeviceInfo.udpPort);
} }
return 200; return 200;
} }
int WebAPIAdapterSrv::instanceAudioPatch( int WebAPIAdapterSrv::instanceAudioInputPatch(
SWGSDRangel::SWGAudioDevicesSelect& response, SWGSDRangel::SWGAudioInputDevice& response,
SWGSDRangel::SWGErrorResponse& error __attribute__((unused))) const QStringList& audioInputKeys,
SWGSDRangel::SWGErrorResponse& error)
{ {
// response input is the query actually // TODO
float inputVolume = response.getInputVolume(); AudioDeviceManager::InputDeviceInfo inputDeviceInfo;
int inputIndex = response.getInputIndex(); QString deviceName;
int outputIndex = response.getOutputIndex(); int deviceIndex = response.getIndex();
const QList<QAudioDeviceInfo>& audioInputDevices = m_mainCore.m_dspEngine->getAudioDeviceManager()->getInputDevices(); if (!m_mainCore.m_dspEngine->getAudioDeviceManager()->getInputDeviceName(deviceIndex, deviceName))
const QList<QAudioDeviceInfo>& audioOutputDevices = m_mainCore.m_dspEngine->getAudioDeviceManager()->getOutputDevices(); {
int nbInputDevices = audioInputDevices.size(); error.init();
int nbOutputDevices = audioOutputDevices.size(); *error.getMessage() = QString("There is no input audio device at index %1").arg(deviceIndex);
return 404;
}
inputVolume = inputVolume < 0.0 ? 0.0 : inputVolume > 1.0 ? 1.0 : inputVolume; m_mainCore.m_dspEngine->getAudioDeviceManager()->getInputDeviceInfo(deviceName, inputDeviceInfo);
inputIndex = inputIndex < -1 ? -1 : inputIndex > nbInputDevices ? nbInputDevices-1 : inputIndex;
outputIndex = outputIndex < -1 ? -1 : outputIndex > nbOutputDevices ? nbOutputDevices-1 : outputIndex;
response.setInputVolume(1.0f); // FIXME: remove if (audioInputKeys.contains("sampleRate")) {
response.setInputIndex(-1); // FIXME: remove inputDeviceInfo.sampleRate = response.getSampleRate();
response.setOutputIndex(-1); // FIXME: remove }
if (audioInputKeys.contains("volume")) {
inputDeviceInfo.volume = response.getVolume();
}
m_mainCore.m_dspEngine->getAudioDeviceManager()->setInputDeviceInfo(deviceIndex, inputDeviceInfo);
m_mainCore.m_dspEngine->getAudioDeviceManager()->getInputDeviceInfo(deviceName, inputDeviceInfo);
response.setSampleRate(inputDeviceInfo.sampleRate);
response.setVolume(inputDeviceInfo.volume);
return 200;
}
int WebAPIAdapterSrv::instanceAudioOutputPatch(
SWGSDRangel::SWGAudioOutputDevice& response,
const QStringList& audioOutputKeys,
SWGSDRangel::SWGErrorResponse& error)
{
AudioDeviceManager::OutputDeviceInfo outputDeviceInfo;
QString deviceName;
int deviceIndex = response.getIndex();
if (!m_mainCore.m_dspEngine->getAudioDeviceManager()->getOutputDeviceName(deviceIndex, deviceName))
{
error.init();
*error.getMessage() = QString("There is no output audio device at index %1").arg(deviceIndex);
return 404;
}
m_mainCore.m_dspEngine->getAudioDeviceManager()->getOutputDeviceInfo(deviceName, outputDeviceInfo);
if (audioOutputKeys.contains("sampleRate")) {
outputDeviceInfo.sampleRate = response.getSampleRate();
}
if (audioOutputKeys.contains("copyToUDP")) {
outputDeviceInfo.copyToUDP = response.getCopyToUdp() == 0 ? 0 : 1;
}
if (audioOutputKeys.contains("udpUsesRTP")) {
outputDeviceInfo.udpUseRTP = response.getUdpUsesRtp() == 0 ? 0 : 1;
}
if (audioOutputKeys.contains("udpChannelMode")) {
outputDeviceInfo.udpChannelMode = static_cast<AudioOutput::UDPChannelMode>(response.getUdpChannelMode() % 4);
}
if (audioOutputKeys.contains("udpAddress")) {
outputDeviceInfo.udpAddress = *response.getUdpAddress();
}
if (audioOutputKeys.contains("udpPort")) {
outputDeviceInfo.udpPort = response.getUdpPort() % (1<<16);
}
m_mainCore.m_dspEngine->getAudioDeviceManager()->setOutputDeviceInfo(deviceIndex, outputDeviceInfo);
m_mainCore.m_dspEngine->getAudioDeviceManager()->getOutputDeviceInfo(deviceName, outputDeviceInfo);
response.setSampleRate(outputDeviceInfo.sampleRate);
response.setCopyToUdp(outputDeviceInfo.copyToUDP == 0 ? 0 : 1);
response.setUdpUsesRtp(outputDeviceInfo.udpUseRTP == 0 ? 0 : 1);
response.setUdpChannelMode(outputDeviceInfo.udpChannelMode % 4);
if (response.getUdpAddress()) {
*response.getUdpAddress() = outputDeviceInfo.udpAddress;
} else {
response.setUdpAddress(new QString(outputDeviceInfo.udpAddress));
}
response.setUdpPort(outputDeviceInfo.udpPort % (1<<16));
return 200; return 200;
} }

View File

@ -63,8 +63,14 @@ public:
SWGSDRangel::SWGAudioDevices& response, SWGSDRangel::SWGAudioDevices& response,
SWGSDRangel::SWGErrorResponse& error); SWGSDRangel::SWGErrorResponse& error);
virtual int instanceAudioPatch( virtual int instanceAudioInputPatch(
SWGSDRangel::SWGAudioDevicesSelect& response, SWGSDRangel::SWGAudioInputDevice& response,
const QStringList& audioInputKeys,
SWGSDRangel::SWGErrorResponse& error);
virtual int instanceAudioOutputPatch(
SWGSDRangel::SWGAudioOutputDevice& response,
const QStringList& audioOutputKeys,
SWGSDRangel::SWGErrorResponse& error); SWGSDRangel::SWGErrorResponse& error);
virtual int instanceLocationGet( virtual int instanceLocationGet(

View File

@ -182,9 +182,11 @@ paths:
$ref: "#/responses/Response_500" $ref: "#/responses/Response_500"
"501": "501":
$ref: "#/responses/Response_501" $ref: "#/responses/Response_501"
/sdrangel/audio/input/set:
x-swagger-router-controller: instance
patch: patch:
description: Set audio devices description: Set audio input device paramaters
operationId: instanceAudioPatch operationId: instanceAudioInputSetPatch
tags: tags:
- Instance - Instance
consumes: consumes:
@ -192,15 +194,49 @@ paths:
parameters: parameters:
- name: body - name: body
in: body in: body
description: Select audio devices to use for this instance description: Audio input parameters. Index is used to identify the device. Only settable fields are considered.
required: true required: true
schema: schema:
$ref: "#/definitions/AudioDevicesSelect" $ref: "#/definitions/AudioInputDevice"
responses: responses:
"200": "200":
description: Success description: Success. Returns actual data in particular the actual sample rate.
schema: schema:
$ref: "#/definitions/AudioDevicesSelect" $ref: "#/definitions/AudioInputDevice"
"404":
description: Audio input device not found
schema:
$ref: "#/definitions/ErrorResponse"
"500":
$ref: "#/responses/Response_500"
"501":
$ref: "#/responses/Response_501"
/sdrangel/audio/output/set:
x-swagger-router-controller: instance
patch:
description: Set audio output device parameters
operationId: instanceAudioOutputSetPatch
tags:
- Instance
consumes:
- application/json
parameters:
- name: body
in: body
description: Audio output parameters. Index is used to identify the device. Only settable fields are considered.
required: true
schema:
$ref: "#/definitions/AudioOutputDevice"
responses:
"200":
description: Success. Returns actual data in particular the actual sample rate.
schema:
$ref: "#/definitions/AudioOutputDevice"
"404":
description: Audio output device not found
schema:
$ref: "#/definitions/ErrorResponse"
"500": "500":
$ref: "#/responses/Response_500" $ref: "#/responses/Response_500"
"501": "501":
@ -1355,62 +1391,81 @@ 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
- nbOutputDevices - nbOutputDevices
- 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
inputDeviceSelectedIndex:
description: "Index of selected input audio devices (-1 if default)"
type: integer
inputDevices: inputDevices:
description: "List of input devices" description: "List of input devices"
type: array type: array
items: items:
$ref: "#/definitions/AudioDevice" $ref: "#/definitions/AudioInputDevice"
nbOutputDevices: nbOutputDevices:
description: "Number of output audio devices" description: "Number of output audio devices"
type: integer type: integer
outputDeviceSelectedIndex:
description: "Index of selected output audio devices (-1 if default)"
type: integer
outputDevices: outputDevices:
description: "List of output devices" description: "List of output devices"
type: array type: array
items: items:
$ref: "#/definitions/AudioDevice" $ref: "#/definitions/AudioOutputDevice"
AudioDevice: AudioInputDevice:
description: "Audio device" description: "Audio input device"
properties: properties:
name: name:
description: "Displayable name of the device" description: "Displayable name of the device"
type: string type: string
index:
AudioDevicesSelect: description: "Index in attached devices list. -1 for system default"
description: "Audio devices selected" type: integer
required: sampleRate:
- inputVolume description: "Device sample rate in S/s"
- inputIndex type: integer
- outputIndex isSystemDefault:
properties: description: "1 if this device is the system default else 0"
inputVolume: type: integer
defaultUnregistered:
description: "1 if this device is unregistered and therefore will inherit default values else 0"
type: integer
volume:
description: "Audio input volume [0.0..1.0]" description: "Audio input volume [0.0..1.0]"
type: number type: number
format: float format: float
inputIndex:
description: "Index of the audio input device (-1 for default)" AudioOutputDevice:
description: "Audio output device"
properties:
name:
description: "Displayable name of the device"
type: string
index:
description: "Index in attached devices list. -1 for system default"
type: integer type: integer
outputIndex: sampleRate:
description: "Index of the audio output device (-1 for default)" description: "Device sample rate in S/s"
type: integer
isSystemDefault:
description: "1 if this device is the system default else 0"
type: integer
defaultUnregistered:
description: "1 if this device is unregistered and therefore will inherit default values else 0"
type: integer
copyToUDP:
description: '1 if audio is copied to UDP else 0'
type: integer
udpUsesRTP:
description: '1 if RTP protocol is used over UDP else 0'
type: integer
udpChannelMode:
description: 'How audio data is copied to UDP: 0: left 1: right 2: mixed 3: stereo'
type: integer
udpAddress:
description: "UDP destination address"
type: string
udpPort:
description: "UDP destination port"
type: integer type: integer
LocationInformation: LocationInformation:

File diff suppressed because it is too large Load Diff

View File

@ -28,18 +28,12 @@ SWGAudioDevices::SWGAudioDevices(QString* json) {
} }
SWGAudioDevices::SWGAudioDevices() { SWGAudioDevices::SWGAudioDevices() {
input_volume = 0.0f;
m_input_volume_isSet = false;
nb_input_devices = 0; nb_input_devices = 0;
m_nb_input_devices_isSet = false; m_nb_input_devices_isSet = false;
input_device_selected_index = 0;
m_input_device_selected_index_isSet = false;
input_devices = nullptr; input_devices = nullptr;
m_input_devices_isSet = false; m_input_devices_isSet = false;
nb_output_devices = 0; nb_output_devices = 0;
m_nb_output_devices_isSet = false; m_nb_output_devices_isSet = false;
output_device_selected_index = 0;
m_output_device_selected_index_isSet = false;
output_devices = nullptr; output_devices = nullptr;
m_output_devices_isSet = false; m_output_devices_isSet = false;
} }
@ -50,27 +44,19 @@ SWGAudioDevices::~SWGAudioDevices() {
void void
SWGAudioDevices::init() { SWGAudioDevices::init() {
input_volume = 0.0f;
m_input_volume_isSet = false;
nb_input_devices = 0; nb_input_devices = 0;
m_nb_input_devices_isSet = false; m_nb_input_devices_isSet = false;
input_device_selected_index = 0; input_devices = new QList<SWGAudioInputDevice*>();
m_input_device_selected_index_isSet = false;
input_devices = new QList<SWGAudioDevice*>();
m_input_devices_isSet = false; m_input_devices_isSet = false;
nb_output_devices = 0; nb_output_devices = 0;
m_nb_output_devices_isSet = false; m_nb_output_devices_isSet = false;
output_device_selected_index = 0; output_devices = new QList<SWGAudioOutputDevice*>();
m_output_device_selected_index_isSet = false;
output_devices = new QList<SWGAudioDevice*>();
m_output_devices_isSet = false; m_output_devices_isSet = false;
} }
void void
SWGAudioDevices::cleanup() { SWGAudioDevices::cleanup() {
if(input_devices != nullptr) { if(input_devices != nullptr) {
auto arr = input_devices; auto arr = input_devices;
for(auto o: *arr) { for(auto o: *arr) {
@ -79,7 +65,6 @@ SWGAudioDevices::cleanup() {
delete input_devices; delete input_devices;
} }
if(output_devices != nullptr) { if(output_devices != nullptr) {
auto arr = output_devices; auto arr = output_devices;
for(auto o: *arr) { for(auto o: *arr) {
@ -100,20 +85,14 @@ SWGAudioDevices::fromJson(QString &json) {
void void
SWGAudioDevices::fromJsonObject(QJsonObject &pJson) { SWGAudioDevices::fromJsonObject(QJsonObject &pJson) {
::SWGSDRangel::setValue(&input_volume, pJson["inputVolume"], "float", "");
::SWGSDRangel::setValue(&nb_input_devices, pJson["nbInputDevices"], "qint32", ""); ::SWGSDRangel::setValue(&nb_input_devices, pJson["nbInputDevices"], "qint32", "");
::SWGSDRangel::setValue(&input_device_selected_index, pJson["inputDeviceSelectedIndex"], "qint32", "");
::SWGSDRangel::setValue(&input_devices, pJson["inputDevices"], "QList", "SWGAudioInputDevice");
::SWGSDRangel::setValue(&input_devices, pJson["inputDevices"], "QList", "SWGAudioDevice");
::SWGSDRangel::setValue(&nb_output_devices, pJson["nbOutputDevices"], "qint32", ""); ::SWGSDRangel::setValue(&nb_output_devices, pJson["nbOutputDevices"], "qint32", "");
::SWGSDRangel::setValue(&output_device_selected_index, pJson["outputDeviceSelectedIndex"], "qint32", "");
::SWGSDRangel::setValue(&output_devices, pJson["outputDevices"], "QList", "SWGAudioOutputDevice");
::SWGSDRangel::setValue(&output_devices, pJson["outputDevices"], "QList", "SWGAudioDevice");
} }
QString QString
@ -130,41 +109,22 @@ SWGAudioDevices::asJson ()
QJsonObject* QJsonObject*
SWGAudioDevices::asJsonObject() { SWGAudioDevices::asJsonObject() {
QJsonObject* obj = new QJsonObject(); QJsonObject* obj = new QJsonObject();
if(m_input_volume_isSet){
obj->insert("inputVolume", QJsonValue(input_volume));
}
if(m_nb_input_devices_isSet){ if(m_nb_input_devices_isSet){
obj->insert("nbInputDevices", QJsonValue(nb_input_devices)); obj->insert("nbInputDevices", QJsonValue(nb_input_devices));
} }
if(m_input_device_selected_index_isSet){
obj->insert("inputDeviceSelectedIndex", QJsonValue(input_device_selected_index));
}
if(input_devices->size() > 0){ if(input_devices->size() > 0){
toJsonArray((QList<void*>*)input_devices, obj, "inputDevices", "SWGAudioDevice"); toJsonArray((QList<void*>*)input_devices, obj, "inputDevices", "SWGAudioInputDevice");
} }
if(m_nb_output_devices_isSet){ if(m_nb_output_devices_isSet){
obj->insert("nbOutputDevices", QJsonValue(nb_output_devices)); obj->insert("nbOutputDevices", QJsonValue(nb_output_devices));
} }
if(m_output_device_selected_index_isSet){
obj->insert("outputDeviceSelectedIndex", QJsonValue(output_device_selected_index));
}
if(output_devices->size() > 0){ if(output_devices->size() > 0){
toJsonArray((QList<void*>*)output_devices, obj, "outputDevices", "SWGAudioDevice"); toJsonArray((QList<void*>*)output_devices, obj, "outputDevices", "SWGAudioOutputDevice");
} }
return obj; return obj;
} }
float
SWGAudioDevices::getInputVolume() {
return input_volume;
}
void
SWGAudioDevices::setInputVolume(float input_volume) {
this->input_volume = input_volume;
this->m_input_volume_isSet = true;
}
qint32 qint32
SWGAudioDevices::getNbInputDevices() { SWGAudioDevices::getNbInputDevices() {
return nb_input_devices; return nb_input_devices;
@ -175,22 +135,12 @@ SWGAudioDevices::setNbInputDevices(qint32 nb_input_devices) {
this->m_nb_input_devices_isSet = true; this->m_nb_input_devices_isSet = true;
} }
qint32 QList<SWGAudioInputDevice*>*
SWGAudioDevices::getInputDeviceSelectedIndex() {
return input_device_selected_index;
}
void
SWGAudioDevices::setInputDeviceSelectedIndex(qint32 input_device_selected_index) {
this->input_device_selected_index = input_device_selected_index;
this->m_input_device_selected_index_isSet = true;
}
QList<SWGAudioDevice*>*
SWGAudioDevices::getInputDevices() { SWGAudioDevices::getInputDevices() {
return input_devices; return input_devices;
} }
void void
SWGAudioDevices::setInputDevices(QList<SWGAudioDevice*>* input_devices) { SWGAudioDevices::setInputDevices(QList<SWGAudioInputDevice*>* input_devices) {
this->input_devices = input_devices; this->input_devices = input_devices;
this->m_input_devices_isSet = true; this->m_input_devices_isSet = true;
} }
@ -205,22 +155,12 @@ SWGAudioDevices::setNbOutputDevices(qint32 nb_output_devices) {
this->m_nb_output_devices_isSet = true; this->m_nb_output_devices_isSet = true;
} }
qint32 QList<SWGAudioOutputDevice*>*
SWGAudioDevices::getOutputDeviceSelectedIndex() {
return output_device_selected_index;
}
void
SWGAudioDevices::setOutputDeviceSelectedIndex(qint32 output_device_selected_index) {
this->output_device_selected_index = output_device_selected_index;
this->m_output_device_selected_index_isSet = true;
}
QList<SWGAudioDevice*>*
SWGAudioDevices::getOutputDevices() { SWGAudioDevices::getOutputDevices() {
return output_devices; return output_devices;
} }
void void
SWGAudioDevices::setOutputDevices(QList<SWGAudioDevice*>* output_devices) { SWGAudioDevices::setOutputDevices(QList<SWGAudioOutputDevice*>* output_devices) {
this->output_devices = output_devices; this->output_devices = output_devices;
this->m_output_devices_isSet = true; this->m_output_devices_isSet = true;
} }
@ -230,12 +170,9 @@ bool
SWGAudioDevices::isSet(){ SWGAudioDevices::isSet(){
bool isObjectUpdated = false; bool isObjectUpdated = false;
do{ do{
if(m_input_volume_isSet){ isObjectUpdated = true; break;}
if(m_nb_input_devices_isSet){ isObjectUpdated = true; break;} if(m_nb_input_devices_isSet){ isObjectUpdated = true; break;}
if(m_input_device_selected_index_isSet){ isObjectUpdated = true; break;}
if(input_devices->size() > 0){ isObjectUpdated = true; break;} if(input_devices->size() > 0){ isObjectUpdated = true; break;}
if(m_nb_output_devices_isSet){ isObjectUpdated = true; break;} if(m_nb_output_devices_isSet){ isObjectUpdated = true; break;}
if(m_output_device_selected_index_isSet){ isObjectUpdated = true; break;}
if(output_devices->size() > 0){ isObjectUpdated = true; break;} if(output_devices->size() > 0){ isObjectUpdated = true; break;}
}while(false); }while(false);
return isObjectUpdated; return isObjectUpdated;

View File

@ -22,7 +22,8 @@
#include <QJsonObject> #include <QJsonObject>
#include "SWGAudioDevice.h" #include "SWGAudioInputDevice.h"
#include "SWGAudioOutputDevice.h"
#include <QList> #include <QList>
#include "SWGObject.h" #include "SWGObject.h"
@ -43,50 +44,32 @@ public:
virtual void fromJsonObject(QJsonObject &json) override; virtual void fromJsonObject(QJsonObject &json) override;
virtual SWGAudioDevices* fromJson(QString &jsonString) override; virtual SWGAudioDevices* fromJson(QString &jsonString) override;
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(); QList<SWGAudioInputDevice*>* getInputDevices();
void setInputDeviceSelectedIndex(qint32 input_device_selected_index); void setInputDevices(QList<SWGAudioInputDevice*>* input_devices);
QList<SWGAudioDevice*>* getInputDevices();
void setInputDevices(QList<SWGAudioDevice*>* input_devices);
qint32 getNbOutputDevices(); qint32 getNbOutputDevices();
void setNbOutputDevices(qint32 nb_output_devices); void setNbOutputDevices(qint32 nb_output_devices);
qint32 getOutputDeviceSelectedIndex(); QList<SWGAudioOutputDevice*>* getOutputDevices();
void setOutputDeviceSelectedIndex(qint32 output_device_selected_index); void setOutputDevices(QList<SWGAudioOutputDevice*>* output_devices);
QList<SWGAudioDevice*>* getOutputDevices();
void setOutputDevices(QList<SWGAudioDevice*>* output_devices);
virtual bool isSet() override; virtual bool isSet() override;
private: private:
float input_volume;
bool m_input_volume_isSet;
qint32 nb_input_devices; qint32 nb_input_devices;
bool m_nb_input_devices_isSet; bool m_nb_input_devices_isSet;
qint32 input_device_selected_index; QList<SWGAudioInputDevice*>* input_devices;
bool m_input_device_selected_index_isSet;
QList<SWGAudioDevice*>* input_devices;
bool m_input_devices_isSet; bool m_input_devices_isSet;
qint32 nb_output_devices; qint32 nb_output_devices;
bool m_nb_output_devices_isSet; bool m_nb_output_devices_isSet;
qint32 output_device_selected_index; QList<SWGAudioOutputDevice*>* output_devices;
bool m_output_device_selected_index_isSet;
QList<SWGAudioDevice*>* output_devices;
bool m_output_devices_isSet; bool m_output_devices_isSet;
}; };

View File

@ -0,0 +1,213 @@
/**
* SDRangel
* This is the web REST/JSON API of SDRangel SDR software. SDRangel is an Open Source Qt5/OpenGL 3.0+ (4.3+ in Windows) GUI and server Software Defined Radio and signal analyzer in software. It supports Airspy, BladeRF, HackRF, LimeSDR, PlutoSDR, RTL-SDR, SDRplay RSP1 and FunCube --- Limitations and specifcities: * In SDRangel GUI the first Rx device set cannot be deleted. Conversely the server starts with no device sets and its number of device sets can be reduced to zero by as many calls as necessary to /sdrangel/deviceset with DELETE method. * Stopping instance i.e. /sdrangel with DELETE method is a server only feature. It allows stopping the instance nicely. * Preset import and export from/to file is a server only feature. * Device set focus is a GUI only feature. * The following channels are not implemented (status 501 is returned): ATV demodulator, Channel Analyzer, Channel Analyzer NG, LoRa demodulator, TCP source * The content type returned is always application/json except in the following cases: * An incorrect URL was specified: this document is returned as text/html with a status 400 ---
*
* 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 "SWGAudioInputDevice.h"
#include "SWGHelpers.h"
#include <QJsonDocument>
#include <QJsonArray>
#include <QObject>
#include <QDebug>
namespace SWGSDRangel {
SWGAudioInputDevice::SWGAudioInputDevice(QString* json) {
init();
this->fromJson(*json);
}
SWGAudioInputDevice::SWGAudioInputDevice() {
name = nullptr;
m_name_isSet = false;
index = 0;
m_index_isSet = false;
sample_rate = 0;
m_sample_rate_isSet = false;
is_system_default = 0;
m_is_system_default_isSet = false;
default_unregistered = 0;
m_default_unregistered_isSet = false;
volume = 0.0f;
m_volume_isSet = false;
}
SWGAudioInputDevice::~SWGAudioInputDevice() {
this->cleanup();
}
void
SWGAudioInputDevice::init() {
name = new QString("");
m_name_isSet = false;
index = 0;
m_index_isSet = false;
sample_rate = 0;
m_sample_rate_isSet = false;
is_system_default = 0;
m_is_system_default_isSet = false;
default_unregistered = 0;
m_default_unregistered_isSet = false;
volume = 0.0f;
m_volume_isSet = false;
}
void
SWGAudioInputDevice::cleanup() {
if(name != nullptr) {
delete name;
}
}
SWGAudioInputDevice*
SWGAudioInputDevice::fromJson(QString &json) {
QByteArray array (json.toStdString().c_str());
QJsonDocument doc = QJsonDocument::fromJson(array);
QJsonObject jsonObject = doc.object();
this->fromJsonObject(jsonObject);
return this;
}
void
SWGAudioInputDevice::fromJsonObject(QJsonObject &pJson) {
::SWGSDRangel::setValue(&name, pJson["name"], "QString", "QString");
::SWGSDRangel::setValue(&index, pJson["index"], "qint32", "");
::SWGSDRangel::setValue(&sample_rate, pJson["sampleRate"], "qint32", "");
::SWGSDRangel::setValue(&is_system_default, pJson["isSystemDefault"], "qint32", "");
::SWGSDRangel::setValue(&default_unregistered, pJson["defaultUnregistered"], "qint32", "");
::SWGSDRangel::setValue(&volume, pJson["volume"], "float", "");
}
QString
SWGAudioInputDevice::asJson ()
{
QJsonObject* obj = this->asJsonObject();
QJsonDocument doc(*obj);
QByteArray bytes = doc.toJson();
delete obj;
return QString(bytes);
}
QJsonObject*
SWGAudioInputDevice::asJsonObject() {
QJsonObject* obj = new QJsonObject();
if(name != nullptr && *name != QString("")){
toJsonValue(QString("name"), name, obj, QString("QString"));
}
if(m_index_isSet){
obj->insert("index", QJsonValue(index));
}
if(m_sample_rate_isSet){
obj->insert("sampleRate", QJsonValue(sample_rate));
}
if(m_is_system_default_isSet){
obj->insert("isSystemDefault", QJsonValue(is_system_default));
}
if(m_default_unregistered_isSet){
obj->insert("defaultUnregistered", QJsonValue(default_unregistered));
}
if(m_volume_isSet){
obj->insert("volume", QJsonValue(volume));
}
return obj;
}
QString*
SWGAudioInputDevice::getName() {
return name;
}
void
SWGAudioInputDevice::setName(QString* name) {
this->name = name;
this->m_name_isSet = true;
}
qint32
SWGAudioInputDevice::getIndex() {
return index;
}
void
SWGAudioInputDevice::setIndex(qint32 index) {
this->index = index;
this->m_index_isSet = true;
}
qint32
SWGAudioInputDevice::getSampleRate() {
return sample_rate;
}
void
SWGAudioInputDevice::setSampleRate(qint32 sample_rate) {
this->sample_rate = sample_rate;
this->m_sample_rate_isSet = true;
}
qint32
SWGAudioInputDevice::getIsSystemDefault() {
return is_system_default;
}
void
SWGAudioInputDevice::setIsSystemDefault(qint32 is_system_default) {
this->is_system_default = is_system_default;
this->m_is_system_default_isSet = true;
}
qint32
SWGAudioInputDevice::getDefaultUnregistered() {
return default_unregistered;
}
void
SWGAudioInputDevice::setDefaultUnregistered(qint32 default_unregistered) {
this->default_unregistered = default_unregistered;
this->m_default_unregistered_isSet = true;
}
float
SWGAudioInputDevice::getVolume() {
return volume;
}
void
SWGAudioInputDevice::setVolume(float volume) {
this->volume = volume;
this->m_volume_isSet = true;
}
bool
SWGAudioInputDevice::isSet(){
bool isObjectUpdated = false;
do{
if(name != nullptr && *name != QString("")){ isObjectUpdated = true; break;}
if(m_index_isSet){ isObjectUpdated = true; break;}
if(m_sample_rate_isSet){ isObjectUpdated = true; break;}
if(m_is_system_default_isSet){ isObjectUpdated = true; break;}
if(m_default_unregistered_isSet){ isObjectUpdated = true; break;}
if(m_volume_isSet){ isObjectUpdated = true; break;}
}while(false);
return isObjectUpdated;
}
}

View File

@ -0,0 +1,89 @@
/**
* SDRangel
* This is the web REST/JSON API of SDRangel SDR software. SDRangel is an Open Source Qt5/OpenGL 3.0+ (4.3+ in Windows) GUI and server Software Defined Radio and signal analyzer in software. It supports Airspy, BladeRF, HackRF, LimeSDR, PlutoSDR, RTL-SDR, SDRplay RSP1 and FunCube --- Limitations and specifcities: * In SDRangel GUI the first Rx device set cannot be deleted. Conversely the server starts with no device sets and its number of device sets can be reduced to zero by as many calls as necessary to /sdrangel/deviceset with DELETE method. * Stopping instance i.e. /sdrangel with DELETE method is a server only feature. It allows stopping the instance nicely. * Preset import and export from/to file is a server only feature. * Device set focus is a GUI only feature. * The following channels are not implemented (status 501 is returned): ATV demodulator, Channel Analyzer, Channel Analyzer NG, LoRa demodulator, TCP source * The content type returned is always application/json except in the following cases: * An incorrect URL was specified: this document is returned as text/html with a status 400 ---
*
* 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.
*/
/*
* SWGAudioInputDevice.h
*
* Audio input device
*/
#ifndef SWGAudioInputDevice_H_
#define SWGAudioInputDevice_H_
#include <QJsonObject>
#include <QString>
#include "SWGObject.h"
#include "export.h"
namespace SWGSDRangel {
class SWG_API SWGAudioInputDevice: public SWGObject {
public:
SWGAudioInputDevice();
SWGAudioInputDevice(QString* json);
virtual ~SWGAudioInputDevice();
void init();
void cleanup();
virtual QString asJson () override;
virtual QJsonObject* asJsonObject() override;
virtual void fromJsonObject(QJsonObject &json) override;
virtual SWGAudioInputDevice* fromJson(QString &jsonString) override;
QString* getName();
void setName(QString* name);
qint32 getIndex();
void setIndex(qint32 index);
qint32 getSampleRate();
void setSampleRate(qint32 sample_rate);
qint32 getIsSystemDefault();
void setIsSystemDefault(qint32 is_system_default);
qint32 getDefaultUnregistered();
void setDefaultUnregistered(qint32 default_unregistered);
float getVolume();
void setVolume(float volume);
virtual bool isSet() override;
private:
QString* name;
bool m_name_isSet;
qint32 index;
bool m_index_isSet;
qint32 sample_rate;
bool m_sample_rate_isSet;
qint32 is_system_default;
bool m_is_system_default_isSet;
qint32 default_unregistered;
bool m_default_unregistered_isSet;
float volume;
bool m_volume_isSet;
};
}
#endif /* SWGAudioInputDevice_H_ */

View File

@ -0,0 +1,299 @@
/**
* SDRangel
* This is the web REST/JSON API of SDRangel SDR software. SDRangel is an Open Source Qt5/OpenGL 3.0+ (4.3+ in Windows) GUI and server Software Defined Radio and signal analyzer in software. It supports Airspy, BladeRF, HackRF, LimeSDR, PlutoSDR, RTL-SDR, SDRplay RSP1 and FunCube --- Limitations and specifcities: * In SDRangel GUI the first Rx device set cannot be deleted. Conversely the server starts with no device sets and its number of device sets can be reduced to zero by as many calls as necessary to /sdrangel/deviceset with DELETE method. * Stopping instance i.e. /sdrangel with DELETE method is a server only feature. It allows stopping the instance nicely. * Preset import and export from/to file is a server only feature. * Device set focus is a GUI only feature. * The following channels are not implemented (status 501 is returned): ATV demodulator, Channel Analyzer, Channel Analyzer NG, LoRa demodulator, TCP source * The content type returned is always application/json except in the following cases: * An incorrect URL was specified: this document is returned as text/html with a status 400 ---
*
* 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 "SWGAudioOutputDevice.h"
#include "SWGHelpers.h"
#include <QJsonDocument>
#include <QJsonArray>
#include <QObject>
#include <QDebug>
namespace SWGSDRangel {
SWGAudioOutputDevice::SWGAudioOutputDevice(QString* json) {
init();
this->fromJson(*json);
}
SWGAudioOutputDevice::SWGAudioOutputDevice() {
name = nullptr;
m_name_isSet = false;
index = 0;
m_index_isSet = false;
sample_rate = 0;
m_sample_rate_isSet = false;
is_system_default = 0;
m_is_system_default_isSet = false;
default_unregistered = 0;
m_default_unregistered_isSet = false;
copy_to_udp = 0;
m_copy_to_udp_isSet = false;
udp_uses_rtp = 0;
m_udp_uses_rtp_isSet = false;
udp_channel_mode = 0;
m_udp_channel_mode_isSet = false;
udp_address = nullptr;
m_udp_address_isSet = false;
udp_port = 0;
m_udp_port_isSet = false;
}
SWGAudioOutputDevice::~SWGAudioOutputDevice() {
this->cleanup();
}
void
SWGAudioOutputDevice::init() {
name = new QString("");
m_name_isSet = false;
index = 0;
m_index_isSet = false;
sample_rate = 0;
m_sample_rate_isSet = false;
is_system_default = 0;
m_is_system_default_isSet = false;
default_unregistered = 0;
m_default_unregistered_isSet = false;
copy_to_udp = 0;
m_copy_to_udp_isSet = false;
udp_uses_rtp = 0;
m_udp_uses_rtp_isSet = false;
udp_channel_mode = 0;
m_udp_channel_mode_isSet = false;
udp_address = new QString("");
m_udp_address_isSet = false;
udp_port = 0;
m_udp_port_isSet = false;
}
void
SWGAudioOutputDevice::cleanup() {
if(name != nullptr) {
delete name;
}
if(udp_address != nullptr) {
delete udp_address;
}
}
SWGAudioOutputDevice*
SWGAudioOutputDevice::fromJson(QString &json) {
QByteArray array (json.toStdString().c_str());
QJsonDocument doc = QJsonDocument::fromJson(array);
QJsonObject jsonObject = doc.object();
this->fromJsonObject(jsonObject);
return this;
}
void
SWGAudioOutputDevice::fromJsonObject(QJsonObject &pJson) {
::SWGSDRangel::setValue(&name, pJson["name"], "QString", "QString");
::SWGSDRangel::setValue(&index, pJson["index"], "qint32", "");
::SWGSDRangel::setValue(&sample_rate, pJson["sampleRate"], "qint32", "");
::SWGSDRangel::setValue(&is_system_default, pJson["isSystemDefault"], "qint32", "");
::SWGSDRangel::setValue(&default_unregistered, pJson["defaultUnregistered"], "qint32", "");
::SWGSDRangel::setValue(&copy_to_udp, pJson["copyToUDP"], "qint32", "");
::SWGSDRangel::setValue(&udp_uses_rtp, pJson["udpUsesRTP"], "qint32", "");
::SWGSDRangel::setValue(&udp_channel_mode, pJson["udpChannelMode"], "qint32", "");
::SWGSDRangel::setValue(&udp_address, pJson["udpAddress"], "QString", "QString");
::SWGSDRangel::setValue(&udp_port, pJson["udpPort"], "qint32", "");
}
QString
SWGAudioOutputDevice::asJson ()
{
QJsonObject* obj = this->asJsonObject();
QJsonDocument doc(*obj);
QByteArray bytes = doc.toJson();
delete obj;
return QString(bytes);
}
QJsonObject*
SWGAudioOutputDevice::asJsonObject() {
QJsonObject* obj = new QJsonObject();
if(name != nullptr && *name != QString("")){
toJsonValue(QString("name"), name, obj, QString("QString"));
}
if(m_index_isSet){
obj->insert("index", QJsonValue(index));
}
if(m_sample_rate_isSet){
obj->insert("sampleRate", QJsonValue(sample_rate));
}
if(m_is_system_default_isSet){
obj->insert("isSystemDefault", QJsonValue(is_system_default));
}
if(m_default_unregistered_isSet){
obj->insert("defaultUnregistered", QJsonValue(default_unregistered));
}
if(m_copy_to_udp_isSet){
obj->insert("copyToUDP", QJsonValue(copy_to_udp));
}
if(m_udp_uses_rtp_isSet){
obj->insert("udpUsesRTP", QJsonValue(udp_uses_rtp));
}
if(m_udp_channel_mode_isSet){
obj->insert("udpChannelMode", QJsonValue(udp_channel_mode));
}
if(udp_address != nullptr && *udp_address != QString("")){
toJsonValue(QString("udpAddress"), udp_address, obj, QString("QString"));
}
if(m_udp_port_isSet){
obj->insert("udpPort", QJsonValue(udp_port));
}
return obj;
}
QString*
SWGAudioOutputDevice::getName() {
return name;
}
void
SWGAudioOutputDevice::setName(QString* name) {
this->name = name;
this->m_name_isSet = true;
}
qint32
SWGAudioOutputDevice::getIndex() {
return index;
}
void
SWGAudioOutputDevice::setIndex(qint32 index) {
this->index = index;
this->m_index_isSet = true;
}
qint32
SWGAudioOutputDevice::getSampleRate() {
return sample_rate;
}
void
SWGAudioOutputDevice::setSampleRate(qint32 sample_rate) {
this->sample_rate = sample_rate;
this->m_sample_rate_isSet = true;
}
qint32
SWGAudioOutputDevice::getIsSystemDefault() {
return is_system_default;
}
void
SWGAudioOutputDevice::setIsSystemDefault(qint32 is_system_default) {
this->is_system_default = is_system_default;
this->m_is_system_default_isSet = true;
}
qint32
SWGAudioOutputDevice::getDefaultUnregistered() {
return default_unregistered;
}
void
SWGAudioOutputDevice::setDefaultUnregistered(qint32 default_unregistered) {
this->default_unregistered = default_unregistered;
this->m_default_unregistered_isSet = true;
}
qint32
SWGAudioOutputDevice::getCopyToUdp() {
return copy_to_udp;
}
void
SWGAudioOutputDevice::setCopyToUdp(qint32 copy_to_udp) {
this->copy_to_udp = copy_to_udp;
this->m_copy_to_udp_isSet = true;
}
qint32
SWGAudioOutputDevice::getUdpUsesRtp() {
return udp_uses_rtp;
}
void
SWGAudioOutputDevice::setUdpUsesRtp(qint32 udp_uses_rtp) {
this->udp_uses_rtp = udp_uses_rtp;
this->m_udp_uses_rtp_isSet = true;
}
qint32
SWGAudioOutputDevice::getUdpChannelMode() {
return udp_channel_mode;
}
void
SWGAudioOutputDevice::setUdpChannelMode(qint32 udp_channel_mode) {
this->udp_channel_mode = udp_channel_mode;
this->m_udp_channel_mode_isSet = true;
}
QString*
SWGAudioOutputDevice::getUdpAddress() {
return udp_address;
}
void
SWGAudioOutputDevice::setUdpAddress(QString* udp_address) {
this->udp_address = udp_address;
this->m_udp_address_isSet = true;
}
qint32
SWGAudioOutputDevice::getUdpPort() {
return udp_port;
}
void
SWGAudioOutputDevice::setUdpPort(qint32 udp_port) {
this->udp_port = udp_port;
this->m_udp_port_isSet = true;
}
bool
SWGAudioOutputDevice::isSet(){
bool isObjectUpdated = false;
do{
if(name != nullptr && *name != QString("")){ isObjectUpdated = true; break;}
if(m_index_isSet){ isObjectUpdated = true; break;}
if(m_sample_rate_isSet){ isObjectUpdated = true; break;}
if(m_is_system_default_isSet){ isObjectUpdated = true; break;}
if(m_default_unregistered_isSet){ isObjectUpdated = true; break;}
if(m_copy_to_udp_isSet){ isObjectUpdated = true; break;}
if(m_udp_uses_rtp_isSet){ isObjectUpdated = true; break;}
if(m_udp_channel_mode_isSet){ isObjectUpdated = true; break;}
if(udp_address != nullptr && *udp_address != QString("")){ isObjectUpdated = true; break;}
if(m_udp_port_isSet){ isObjectUpdated = true; break;}
}while(false);
return isObjectUpdated;
}
}

View File

@ -0,0 +1,113 @@
/**
* SDRangel
* This is the web REST/JSON API of SDRangel SDR software. SDRangel is an Open Source Qt5/OpenGL 3.0+ (4.3+ in Windows) GUI and server Software Defined Radio and signal analyzer in software. It supports Airspy, BladeRF, HackRF, LimeSDR, PlutoSDR, RTL-SDR, SDRplay RSP1 and FunCube --- Limitations and specifcities: * In SDRangel GUI the first Rx device set cannot be deleted. Conversely the server starts with no device sets and its number of device sets can be reduced to zero by as many calls as necessary to /sdrangel/deviceset with DELETE method. * Stopping instance i.e. /sdrangel with DELETE method is a server only feature. It allows stopping the instance nicely. * Preset import and export from/to file is a server only feature. * Device set focus is a GUI only feature. * The following channels are not implemented (status 501 is returned): ATV demodulator, Channel Analyzer, Channel Analyzer NG, LoRa demodulator, TCP source * The content type returned is always application/json except in the following cases: * An incorrect URL was specified: this document is returned as text/html with a status 400 ---
*
* 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.
*/
/*
* SWGAudioOutputDevice.h
*
* Audio output device
*/
#ifndef SWGAudioOutputDevice_H_
#define SWGAudioOutputDevice_H_
#include <QJsonObject>
#include <QString>
#include "SWGObject.h"
#include "export.h"
namespace SWGSDRangel {
class SWG_API SWGAudioOutputDevice: public SWGObject {
public:
SWGAudioOutputDevice();
SWGAudioOutputDevice(QString* json);
virtual ~SWGAudioOutputDevice();
void init();
void cleanup();
virtual QString asJson () override;
virtual QJsonObject* asJsonObject() override;
virtual void fromJsonObject(QJsonObject &json) override;
virtual SWGAudioOutputDevice* fromJson(QString &jsonString) override;
QString* getName();
void setName(QString* name);
qint32 getIndex();
void setIndex(qint32 index);
qint32 getSampleRate();
void setSampleRate(qint32 sample_rate);
qint32 getIsSystemDefault();
void setIsSystemDefault(qint32 is_system_default);
qint32 getDefaultUnregistered();
void setDefaultUnregistered(qint32 default_unregistered);
qint32 getCopyToUdp();
void setCopyToUdp(qint32 copy_to_udp);
qint32 getUdpUsesRtp();
void setUdpUsesRtp(qint32 udp_uses_rtp);
qint32 getUdpChannelMode();
void setUdpChannelMode(qint32 udp_channel_mode);
QString* getUdpAddress();
void setUdpAddress(QString* udp_address);
qint32 getUdpPort();
void setUdpPort(qint32 udp_port);
virtual bool isSet() override;
private:
QString* name;
bool m_name_isSet;
qint32 index;
bool m_index_isSet;
qint32 sample_rate;
bool m_sample_rate_isSet;
qint32 is_system_default;
bool m_is_system_default_isSet;
qint32 default_unregistered;
bool m_default_unregistered_isSet;
qint32 copy_to_udp;
bool m_copy_to_udp_isSet;
qint32 udp_uses_rtp;
bool m_udp_uses_rtp_isSet;
qint32 udp_channel_mode;
bool m_udp_channel_mode_isSet;
QString* udp_address;
bool m_udp_address_isSet;
qint32 udp_port;
bool m_udp_port_isSet;
};
}
#endif /* SWGAudioOutputDevice_H_ */

View File

@ -81,9 +81,9 @@ SWGInstanceApi::instanceAudioGetCallback(SWGHttpRequestWorker * worker) {
} }
void void
SWGInstanceApi::instanceAudioPatch(SWGAudioDevicesSelect& body) { SWGInstanceApi::instanceAudioInputSetPatch(SWGAudioInputDevice& body) {
QString fullPath; QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/sdrangel/audio"); fullPath.append(this->host).append(this->basePath).append("/sdrangel/audio/input/set");
@ -104,13 +104,13 @@ SWGInstanceApi::instanceAudioPatch(SWGAudioDevicesSelect& body) {
connect(worker, connect(worker,
&SWGHttpRequestWorker::on_execution_finished, &SWGHttpRequestWorker::on_execution_finished,
this, this,
&SWGInstanceApi::instanceAudioPatchCallback); &SWGInstanceApi::instanceAudioInputSetPatchCallback);
worker->execute(&input); worker->execute(&input);
} }
void void
SWGInstanceApi::instanceAudioPatchCallback(SWGHttpRequestWorker * worker) { SWGInstanceApi::instanceAudioInputSetPatchCallback(SWGHttpRequestWorker * worker) {
QString msg; QString msg;
QString error_str = worker->error_str; QString error_str = worker->error_str;
QNetworkReply::NetworkError error_type = worker->error_type; QNetworkReply::NetworkError error_type = worker->error_type;
@ -124,14 +124,69 @@ SWGInstanceApi::instanceAudioPatchCallback(SWGHttpRequestWorker * worker) {
QString json(worker->response); QString json(worker->response);
SWGAudioDevicesSelect* output = static_cast<SWGAudioDevicesSelect*>(create(json, QString("SWGAudioDevicesSelect"))); SWGAudioInputDevice* output = static_cast<SWGAudioInputDevice*>(create(json, QString("SWGAudioInputDevice")));
worker->deleteLater(); worker->deleteLater();
if (worker->error_type == QNetworkReply::NoError) { if (worker->error_type == QNetworkReply::NoError) {
emit instanceAudioPatchSignal(output); emit instanceAudioInputSetPatchSignal(output);
} else { } else {
emit instanceAudioPatchSignalE(output, error_type, error_str); emit instanceAudioInputSetPatchSignalE(output, error_type, error_str);
emit instanceAudioPatchSignalEFull(worker, error_type, error_str); emit instanceAudioInputSetPatchSignalEFull(worker, error_type, error_str);
}
}
void
SWGInstanceApi::instanceAudioOutputSetPatch(SWGAudioOutputDevice& body) {
QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/sdrangel/audio/output/set");
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
SWGHttpRequestInput input(fullPath, "PATCH");
QString output = body.asJson();
input.request_body.append(output);
foreach(QString key, this->defaultHeaders.keys()) {
input.headers.insert(key, this->defaultHeaders.value(key));
}
connect(worker,
&SWGHttpRequestWorker::on_execution_finished,
this,
&SWGInstanceApi::instanceAudioOutputSetPatchCallback);
worker->execute(&input);
}
void
SWGInstanceApi::instanceAudioOutputSetPatchCallback(SWGHttpRequestWorker * worker) {
QString msg;
QString error_str = worker->error_str;
QNetworkReply::NetworkError error_type = worker->error_type;
if (worker->error_type == QNetworkReply::NoError) {
msg = QString("Success! %1 bytes").arg(worker->response.length());
}
else {
msg = "Error: " + worker->error_str;
}
QString json(worker->response);
SWGAudioOutputDevice* output = static_cast<SWGAudioOutputDevice*>(create(json, QString("SWGAudioOutputDevice")));
worker->deleteLater();
if (worker->error_type == QNetworkReply::NoError) {
emit instanceAudioOutputSetPatchSignal(output);
} else {
emit instanceAudioOutputSetPatchSignalE(output, error_type, error_str);
emit instanceAudioOutputSetPatchSignalEFull(worker, error_type, error_str);
} }
} }

View File

@ -16,7 +16,8 @@
#include "SWGHttpRequest.h" #include "SWGHttpRequest.h"
#include "SWGAudioDevices.h" #include "SWGAudioDevices.h"
#include "SWGAudioDevicesSelect.h" #include "SWGAudioInputDevice.h"
#include "SWGAudioOutputDevice.h"
#include "SWGDVSeralDevices.h" #include "SWGDVSeralDevices.h"
#include "SWGDeviceSetList.h" #include "SWGDeviceSetList.h"
#include "SWGErrorResponse.h" #include "SWGErrorResponse.h"
@ -48,7 +49,8 @@ public:
QMap<QString, QString> defaultHeaders; QMap<QString, QString> defaultHeaders;
void instanceAudioGet(); void instanceAudioGet();
void instanceAudioPatch(SWGAudioDevicesSelect& body); void instanceAudioInputSetPatch(SWGAudioInputDevice& body);
void instanceAudioOutputSetPatch(SWGAudioOutputDevice& body);
void instanceChannels(qint32 tx); void instanceChannels(qint32 tx);
void instanceDVSerialPatch(qint32 dvserial); void instanceDVSerialPatch(qint32 dvserial);
void instanceDelete(); void instanceDelete();
@ -69,7 +71,8 @@ public:
private: private:
void instanceAudioGetCallback (SWGHttpRequestWorker * worker); void instanceAudioGetCallback (SWGHttpRequestWorker * worker);
void instanceAudioPatchCallback (SWGHttpRequestWorker * worker); void instanceAudioInputSetPatchCallback (SWGHttpRequestWorker * worker);
void instanceAudioOutputSetPatchCallback (SWGHttpRequestWorker * worker);
void instanceChannelsCallback (SWGHttpRequestWorker * worker); void instanceChannelsCallback (SWGHttpRequestWorker * worker);
void instanceDVSerialPatchCallback (SWGHttpRequestWorker * worker); void instanceDVSerialPatchCallback (SWGHttpRequestWorker * worker);
void instanceDeleteCallback (SWGHttpRequestWorker * worker); void instanceDeleteCallback (SWGHttpRequestWorker * worker);
@ -90,7 +93,8 @@ private:
signals: signals:
void instanceAudioGetSignal(SWGAudioDevices* summary); void instanceAudioGetSignal(SWGAudioDevices* summary);
void instanceAudioPatchSignal(SWGAudioDevicesSelect* summary); void instanceAudioInputSetPatchSignal(SWGAudioInputDevice* summary);
void instanceAudioOutputSetPatchSignal(SWGAudioOutputDevice* summary);
void instanceChannelsSignal(SWGInstanceChannelsResponse* summary); void instanceChannelsSignal(SWGInstanceChannelsResponse* summary);
void instanceDVSerialPatchSignal(SWGDVSeralDevices* summary); void instanceDVSerialPatchSignal(SWGDVSeralDevices* summary);
void instanceDeleteSignal(SWGInstanceSummaryResponse* summary); void instanceDeleteSignal(SWGInstanceSummaryResponse* summary);
@ -110,7 +114,8 @@ signals:
void instanceSummarySignal(SWGInstanceSummaryResponse* summary); void instanceSummarySignal(SWGInstanceSummaryResponse* summary);
void instanceAudioGetSignalE(SWGAudioDevices* summary, QNetworkReply::NetworkError error_type, QString& error_str); void instanceAudioGetSignalE(SWGAudioDevices* summary, QNetworkReply::NetworkError error_type, QString& error_str);
void instanceAudioPatchSignalE(SWGAudioDevicesSelect* summary, QNetworkReply::NetworkError error_type, QString& error_str); void instanceAudioInputSetPatchSignalE(SWGAudioInputDevice* summary, QNetworkReply::NetworkError error_type, QString& error_str);
void instanceAudioOutputSetPatchSignalE(SWGAudioOutputDevice* summary, QNetworkReply::NetworkError error_type, QString& error_str);
void instanceChannelsSignalE(SWGInstanceChannelsResponse* summary, QNetworkReply::NetworkError error_type, QString& error_str); void instanceChannelsSignalE(SWGInstanceChannelsResponse* summary, QNetworkReply::NetworkError error_type, QString& error_str);
void instanceDVSerialPatchSignalE(SWGDVSeralDevices* summary, QNetworkReply::NetworkError error_type, QString& error_str); void instanceDVSerialPatchSignalE(SWGDVSeralDevices* summary, QNetworkReply::NetworkError error_type, QString& error_str);
void instanceDeleteSignalE(SWGInstanceSummaryResponse* summary, QNetworkReply::NetworkError error_type, QString& error_str); void instanceDeleteSignalE(SWGInstanceSummaryResponse* summary, QNetworkReply::NetworkError error_type, QString& error_str);
@ -130,7 +135,8 @@ signals:
void instanceSummarySignalE(SWGInstanceSummaryResponse* summary, QNetworkReply::NetworkError error_type, QString& error_str); void instanceSummarySignalE(SWGInstanceSummaryResponse* summary, QNetworkReply::NetworkError error_type, QString& error_str);
void instanceAudioGetSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str); void instanceAudioGetSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void instanceAudioPatchSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str); void instanceAudioInputSetPatchSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void instanceAudioOutputSetPatchSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void instanceChannelsSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str); void instanceChannelsSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void instanceDVSerialPatchSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str); void instanceDVSerialPatchSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void instanceDeleteSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str); void instanceDeleteSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);

View File

@ -17,9 +17,9 @@
#include "SWGAMDemodReport.h" #include "SWGAMDemodReport.h"
#include "SWGAMDemodSettings.h" #include "SWGAMDemodSettings.h"
#include "SWGAirspyHFSettings.h" #include "SWGAirspyHFSettings.h"
#include "SWGAudioDevice.h"
#include "SWGAudioDevices.h" #include "SWGAudioDevices.h"
#include "SWGAudioDevicesSelect.h" #include "SWGAudioInputDevice.h"
#include "SWGAudioOutputDevice.h"
#include "SWGCWKeyerSettings.h" #include "SWGCWKeyerSettings.h"
#include "SWGChannel.h" #include "SWGChannel.h"
#include "SWGChannelListItem.h" #include "SWGChannelListItem.h"
@ -71,14 +71,14 @@ namespace SWGSDRangel {
if(QString("SWGAirspyHFSettings").compare(type) == 0) { if(QString("SWGAirspyHFSettings").compare(type) == 0) {
return new SWGAirspyHFSettings(); return new SWGAirspyHFSettings();
} }
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();
} }
if(QString("SWGAudioDevicesSelect").compare(type) == 0) { if(QString("SWGAudioInputDevice").compare(type) == 0) {
return new SWGAudioDevicesSelect(); return new SWGAudioInputDevice();
}
if(QString("SWGAudioOutputDevice").compare(type) == 0) {
return new SWGAudioOutputDevice();
} }
if(QString("SWGCWKeyerSettings").compare(type) == 0) { if(QString("SWGCWKeyerSettings").compare(type) == 0) {
return new SWGCWKeyerSettings(); return new SWGCWKeyerSettings();