mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
Merge pull request #431 from Palakis/feature/list-supported-image-formats
request(GetVersion): add supported image export formats list
This commit is contained in:
commit
d4db0bdfe5
@ -1,10 +1,13 @@
|
|||||||
|
#include "WSRequestHandler.h"
|
||||||
|
|
||||||
|
#include <QtCore/QByteArray>
|
||||||
|
#include <QtGui/QImageWriter>
|
||||||
|
|
||||||
#include "obs-websocket.h"
|
#include "obs-websocket.h"
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
#include "WSEvents.h"
|
#include "WSEvents.h"
|
||||||
|
|
||||||
#include "WSRequestHandler.h"
|
|
||||||
|
|
||||||
#define CASE(x) case x: return #x;
|
#define CASE(x) case x: return #x;
|
||||||
const char *describe_output_format(int format) {
|
const char *describe_output_format(int format) {
|
||||||
switch (format) {
|
switch (format) {
|
||||||
@ -60,6 +63,7 @@ const char *describe_scale_type(int scale) {
|
|||||||
* @return {String} `obs-websocket-version` obs-websocket plugin version.
|
* @return {String} `obs-websocket-version` obs-websocket plugin version.
|
||||||
* @return {String} `obs-studio-version` OBS Studio program version.
|
* @return {String} `obs-studio-version` OBS Studio program version.
|
||||||
* @return {String} `available-requests` List of available request types, formatted as a comma-separated list string (e.g. : "Method1,Method2,Method3").
|
* @return {String} `available-requests` List of available request types, formatted as a comma-separated list string (e.g. : "Method1,Method2,Method3").
|
||||||
|
* @return {String} `supported-image-export-formats` List of supported formats for features that use image export (like the TakeSourceScreenshot request type) formatted as a comma-separated list string
|
||||||
*
|
*
|
||||||
* @api requests
|
* @api requests
|
||||||
* @name GetVersion
|
* @name GetVersion
|
||||||
@ -70,20 +74,28 @@ RpcResponse WSRequestHandler::GetVersion(const RpcRequest& request) {
|
|||||||
QString obsVersion = Utils::OBSVersionString();
|
QString obsVersion = Utils::OBSVersionString();
|
||||||
|
|
||||||
QList<QString> names = messageMap.keys();
|
QList<QString> names = messageMap.keys();
|
||||||
names.sort(Qt::CaseInsensitive);
|
QList<QByteArray> imageWriterFormats = QImageWriter::supportedImageFormats();
|
||||||
|
|
||||||
// (Palakis) OBS' data arrays only support object arrays, so I improvised.
|
// (Palakis) OBS' data arrays only support object arrays, so I improvised.
|
||||||
QString requests;
|
QString requests;
|
||||||
|
names.sort(Qt::CaseInsensitive);
|
||||||
requests += names.takeFirst();
|
requests += names.takeFirst();
|
||||||
for (QString reqName : names) {
|
for (const QString& reqName : names) {
|
||||||
requests += ("," + reqName);
|
requests += ("," + reqName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString supportedImageExportFormats;
|
||||||
|
supportedImageExportFormats += QString::fromUtf8(imageWriterFormats.takeFirst());
|
||||||
|
for (const QByteArray& format : imageWriterFormats) {
|
||||||
|
supportedImageExportFormats += ("," + QString::fromUtf8(format));
|
||||||
|
}
|
||||||
|
|
||||||
OBSDataAutoRelease data = obs_data_create();
|
OBSDataAutoRelease data = obs_data_create();
|
||||||
obs_data_set_double(data, "version", 1.1);
|
obs_data_set_double(data, "version", 1.1);
|
||||||
obs_data_set_string(data, "obs-websocket-version", OBS_WEBSOCKET_VERSION);
|
obs_data_set_string(data, "obs-websocket-version", OBS_WEBSOCKET_VERSION);
|
||||||
obs_data_set_string(data, "obs-studio-version", obsVersion.toUtf8());
|
obs_data_set_string(data, "obs-studio-version", obsVersion.toUtf8());
|
||||||
obs_data_set_string(data, "available-requests", requests.toUtf8());
|
obs_data_set_string(data, "available-requests", requests.toUtf8());
|
||||||
|
obs_data_set_string(data, "supported-image-export-formats", supportedImageExportFormats.toUtf8());
|
||||||
|
|
||||||
return request.success(data);
|
return request.success(data);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user