From f9e2a95f5f0179b9ce42281beb85006421714b42 Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Thu, 15 Oct 2026 14:18:09 -0700 Subject: [PATCH] requesthandler: Report GPU acceleration status in GetStats Adds the additive response field gpuAcceleration: the JSON object the frontend's get_gpu_status proc returns (state green/yellow/red, adapter, detectedGpus, summary, causes), or null when no frontend provides it. Refs obs-rust/obs-studio#846 --- docs/generated/protocol.json | 5 +++++ docs/generated/protocol.md | 1 + src/requesthandler/RequestHandler_General.cpp | 1 + src/utils/Obs_ObjectHelper.cpp | 14 ++++++++++++++ 4 files changed, 21 insertions(+) diff --git a/docs/generated/protocol.json b/docs/generated/protocol.json index e64d216a..83eedde5 100644 --- a/docs/generated/protocol.json +++ b/docs/generated/protocol.json @@ -1856,6 +1856,11 @@ "valueType": "Number", "valueDescription": "Total number of frames outputted by the output thread" }, + { + "valueName": "gpuAcceleration", + "valueType": "Object", + "valueDescription": "GPU acceleration status (`state` green/yellow/red, `adapter`, `detectedGpus`, `summary`, `causes`), or null when the frontend does not report it" + }, { "valueName": "webSocketSessionIncomingMessages", "valueType": "Number", diff --git a/docs/generated/protocol.md b/docs/generated/protocol.md index ebff6d64..ae5a14b3 100644 --- a/docs/generated/protocol.md +++ b/docs/generated/protocol.md @@ -2870,6 +2870,7 @@ Gets statistics about OBS, obs-websocket, and the current session. | renderTotalFrames | Number | Total number of frames outputted by the render thread | | outputSkippedFrames | Number | Number of frames skipped by OBS in the output thread | | outputTotalFrames | Number | Total number of frames outputted by the output thread | +| gpuAcceleration | Object | GPU acceleration status (`state` green/yellow/red, `adapter`, `detectedGpus`, `summary`, `causes`), or null when the frontend does not report it | | webSocketSessionIncomingMessages | Number | Total number of messages received by obs-websocket from the client | | webSocketSessionOutgoingMessages | Number | Total number of messages sent by obs-websocket to the client | diff --git a/src/requesthandler/RequestHandler_General.cpp b/src/requesthandler/RequestHandler_General.cpp index 0bd5436d..bf70d9fa 100644 --- a/src/requesthandler/RequestHandler_General.cpp +++ b/src/requesthandler/RequestHandler_General.cpp @@ -77,6 +77,7 @@ RequestResult RequestHandler::GetVersion(const Request &) * @responseField renderTotalFrames | Number | Total number of frames outputted by the render thread * @responseField outputSkippedFrames | Number | Number of frames skipped by OBS in the output thread * @responseField outputTotalFrames | Number | Total number of frames outputted by the output thread + * @responseField gpuAcceleration | Object | GPU acceleration status (`state` green/yellow/red, `adapter`, `detectedGpus`, `summary`, `causes`), or null when the frontend does not report it * @responseField webSocketSessionIncomingMessages | Number | Total number of messages received by obs-websocket from the client * @responseField webSocketSessionOutgoingMessages | Number | Total number of messages sent by obs-websocket to the client * diff --git a/src/utils/Obs_ObjectHelper.cpp b/src/utils/Obs_ObjectHelper.cpp index 8956893f..5d897bdb 100644 --- a/src/utils/Obs_ObjectHelper.cpp +++ b/src/utils/Obs_ObjectHelper.cpp @@ -45,6 +45,20 @@ json Utils::Obs::ObjectHelper::GetStats() ret["outputSkippedFrames"] = outputSkippedFrames; ret["outputTotalFrames"] = outputTotalFrames; + /* GPU acceleration status from the frontend (obs-rust/obs-studio#846): + * null when the frontend does not provide it. */ + ret["gpuAcceleration"] = nullptr; + calldata_t cd = {0}; + if (proc_handler_call(obs_get_proc_handler(), "get_gpu_status", &cd)) { + const char *status = calldata_string(&cd, "json"); + if (status) { + json parsed = json::parse(status, nullptr, false); + if (!parsed.is_discarded()) + ret["gpuAcceleration"] = parsed; + } + } + calldata_free(&cd); + return ret; }