mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
Merge pull request #666 from Palakis/feature/RefreshBrowserSource
Requests: Add RefreshBrowserSource
This commit is contained in:
commit
59e6695a5d
@ -120,6 +120,7 @@ const QHash<QString, RpcMethodHandler> WSRequestHandler::messageMap{
|
|||||||
{ "SetAudioMonitorType", &WSRequestHandler::SetAudioMonitorType },
|
{ "SetAudioMonitorType", &WSRequestHandler::SetAudioMonitorType },
|
||||||
{ "GetSourceDefaultSettings", &WSRequestHandler::GetSourceDefaultSettings },
|
{ "GetSourceDefaultSettings", &WSRequestHandler::GetSourceDefaultSettings },
|
||||||
{ "TakeSourceScreenshot", &WSRequestHandler::TakeSourceScreenshot },
|
{ "TakeSourceScreenshot", &WSRequestHandler::TakeSourceScreenshot },
|
||||||
|
{ "RefreshBrowserSource", &WSRequestHandler::RefreshBrowserSource },
|
||||||
|
|
||||||
{ "GetSourceFilters", &WSRequestHandler::GetSourceFilters },
|
{ "GetSourceFilters", &WSRequestHandler::GetSourceFilters },
|
||||||
{ "GetSourceFilterInfo", &WSRequestHandler::GetSourceFilterInfo },
|
{ "GetSourceFilterInfo", &WSRequestHandler::GetSourceFilterInfo },
|
||||||
|
@ -137,6 +137,7 @@ class WSRequestHandler {
|
|||||||
RpcResponse SetAudioMonitorType(const RpcRequest&);
|
RpcResponse SetAudioMonitorType(const RpcRequest&);
|
||||||
RpcResponse GetSourceDefaultSettings(const RpcRequest&);
|
RpcResponse GetSourceDefaultSettings(const RpcRequest&);
|
||||||
RpcResponse TakeSourceScreenshot(const RpcRequest&);
|
RpcResponse TakeSourceScreenshot(const RpcRequest&);
|
||||||
|
RpcResponse RefreshBrowserSource(const RpcRequest&);
|
||||||
|
|
||||||
RpcResponse GetSourceFilters(const RpcRequest&);
|
RpcResponse GetSourceFilters(const RpcRequest&);
|
||||||
RpcResponse GetSourceFilterInfo(const RpcRequest&);
|
RpcResponse GetSourceFilterInfo(const RpcRequest&);
|
||||||
|
@ -1894,3 +1894,38 @@ RpcResponse WSRequestHandler::TakeSourceScreenshot(const RpcRequest& request) {
|
|||||||
obs_data_set_string(response, "sourceName", obs_source_get_name(source));
|
obs_data_set_string(response, "sourceName", obs_source_get_name(source));
|
||||||
return request.success(response);
|
return request.success(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refreshes the specified browser source.
|
||||||
|
*
|
||||||
|
* @param {String} `sourceName` Source name.
|
||||||
|
*
|
||||||
|
* @api requests
|
||||||
|
* @name RefreshBrowserSource
|
||||||
|
* @category sources
|
||||||
|
* @since 4.9.0
|
||||||
|
*/
|
||||||
|
RpcResponse WSRequestHandler::RefreshBrowserSource(const RpcRequest& request)
|
||||||
|
{
|
||||||
|
if (!request.hasField("sourceName")) {
|
||||||
|
return request.failed("missing request parameters");
|
||||||
|
}
|
||||||
|
|
||||||
|
QString sourceName = obs_data_get_string(request.parameters(), "sourceName");
|
||||||
|
|
||||||
|
OBSSourceAutoRelease source = obs_get_source_by_name(sourceName.toUtf8());
|
||||||
|
if (!source) {
|
||||||
|
return request.failed("specified source doesn't exist");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcmp(obs_source_get_id(source), "browser_source") != 0) {
|
||||||
|
return request.failed("specified source is not a browser");
|
||||||
|
}
|
||||||
|
|
||||||
|
obs_properties_t *sourceProperties = obs_source_properties(source);
|
||||||
|
obs_property_t *property = obs_properties_get(sourceProperties, "refreshnocache");
|
||||||
|
obs_property_button_clicked(property, source); // This returns a boolean but we ignore it because the browser plugin always returns `false`.
|
||||||
|
obs_properties_destroy(sourceProperties);
|
||||||
|
|
||||||
|
return request.success();
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user