mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
Added OBS version number in the response fields of GetVersion
This commit is contained in:
parent
3fbc221db0
commit
114ace23f7
@ -105,7 +105,8 @@ Returns the latest version of the plugin and the API.
|
|||||||
__Request fields__ : none
|
__Request fields__ : none
|
||||||
__Response__ : always OK, with these additional fields :
|
__Response__ : always OK, with these additional fields :
|
||||||
- **"version"** (double) : OBSRemote API version. Fixed to 1.1 for retrocompatibility.
|
- **"version"** (double) : OBSRemote API version. Fixed to 1.1 for retrocompatibility.
|
||||||
- **"obs-websocket-version"** (string) : obs-websocket version
|
- **"obs-websocket-version"** (string) : obs-websocket version string
|
||||||
|
- **"obs-studio-version"** (string) : OBS Studio version string
|
||||||
|
|
||||||
#### "GetAuthRequired"
|
#### "GetAuthRequired"
|
||||||
Tells the client if authentication is required. If it is, authentication parameters "challenge" and "salt" are passed in the response fields (see "Authentication").
|
Tells the client if authentication is required. If it is, authentication parameters "challenge" and "salt" are passed in the response fields (see "Authentication").
|
||||||
|
15
Utils.cpp
15
Utils.cpp
@ -148,3 +148,18 @@ obs_data_t* Utils::GetSceneData(obs_source *source) {
|
|||||||
obs_data_array_release(scene_items);
|
obs_data_array_release(scene_items);
|
||||||
return sceneData;
|
return sceneData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* Utils::OBSVersionString() {
|
||||||
|
uint32_t version = obs_get_version();
|
||||||
|
|
||||||
|
uint8_t major, minor, patch;
|
||||||
|
major = (version >> 24) & 0xFF;
|
||||||
|
minor = (version >> 16) & 0xFF;
|
||||||
|
patch = version & 0xFF;
|
||||||
|
|
||||||
|
size_t string_size = sizeof(char) * 12;
|
||||||
|
char *result = (char*)bmalloc(string_size);
|
||||||
|
sprintf_s(result, string_size, "%d.%d.%d", major, minor, patch);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
3
Utils.h
3
Utils.h
@ -19,6 +19,7 @@ with this program. If not, see <https://www.gnu.org/licenses/>
|
|||||||
#ifndef UTILS_H
|
#ifndef UTILS_H
|
||||||
#define UTILS_H
|
#define UTILS_H
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
#include <obs-module.h>
|
#include <obs-module.h>
|
||||||
#include <obs-frontend-api.h>
|
#include <obs-frontend-api.h>
|
||||||
|
|
||||||
@ -32,6 +33,8 @@ class Utils
|
|||||||
|
|
||||||
static obs_data_array_t* GetScenes();
|
static obs_data_array_t* GetScenes();
|
||||||
static obs_data_t* GetSceneData(obs_source *source);
|
static obs_data_t* GetSceneData(obs_source *source);
|
||||||
|
|
||||||
|
static const char* Utils::OBSVersionString();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // UTILS_H
|
#endif // UTILS_H
|
@ -138,14 +138,17 @@ void WSRequestHandler::SendErrorResponse(const char *errorMessage)
|
|||||||
|
|
||||||
void WSRequestHandler::HandleGetVersion(WSRequestHandler *owner)
|
void WSRequestHandler::HandleGetVersion(WSRequestHandler *owner)
|
||||||
{
|
{
|
||||||
|
const char* obs_version = Utils::OBSVersionString();
|
||||||
|
|
||||||
obs_data_t *data = obs_data_create();
|
obs_data_t *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", OBS_VERSION); // Wrong
|
obs_data_set_string(data, "obs-studio-version", obs_version);
|
||||||
|
|
||||||
owner->SendOKResponse(data);
|
owner->SendOKResponse(data);
|
||||||
|
|
||||||
obs_data_release(data);
|
obs_data_release(data);
|
||||||
|
bfree((void*)obs_version);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WSRequestHandler::HandleGetAuthRequired(WSRequestHandler *owner)
|
void WSRequestHandler::HandleGetAuthRequired(WSRequestHandler *owner)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user