This commit is contained in:
tt2468 2021-02-02 08:28:41 -08:00
commit 47b84f7316
5 changed files with 99 additions and 0 deletions

View File

@ -7412,6 +7412,47 @@
"lead": "Takes a picture snapshot of a source and then can either or both: \t- Send it over as a Data URI (base64-encoded data) in the response (by specifying `embedPictureFormat` in the request) \t- Save it to disk (by specifying `saveToFilePath` in the request)",
"type": "class",
"examples": []
},
{
"subheads": [],
"description": "Refreshes the specified browser source.",
"param": "{String} `sourceName` Source name.",
"api": "requests",
"name": "RefreshBrowserSource",
"category": "sources",
"since": "4.9.0",
"params": [
{
"type": "String",
"name": "sourceName",
"description": "Source name."
}
],
"names": [
{
"name": "",
"description": "RefreshBrowserSource"
}
],
"categories": [
{
"name": "",
"description": "sources"
}
],
"sinces": [
{
"name": "",
"description": "4.9.0"
}
],
"heading": {
"level": 2,
"text": "RefreshBrowserSource"
},
"lead": "",
"type": "class",
"examples": []
}
],
"outputs": [

View File

@ -185,6 +185,7 @@ You can also refer to any of the client libraries listed on the [README](README.
+ [SetAudioMonitorType](#setaudiomonitortype)
+ [GetSourceDefaultSettings](#getsourcedefaultsettings)
+ [TakeSourceScreenshot](#takesourcescreenshot)
+ [RefreshBrowserSource](#refreshbrowsersource)
* [Outputs](#outputs)
+ [ListOutputs](#listoutputs)
+ [GetOutputInfo](#getoutputinfo)
@ -2871,6 +2872,26 @@ preserved if only one of these two parameters is specified.
| `imageFile` | _String_ | Absolute path to the saved image file (if `saveToFilePath` was specified in the request) |
---
### RefreshBrowserSource
- Added in v4.9.0
Refreshes the specified browser source.
**Request Fields:**
| Name | Type | Description |
| ---- | :---: | ------------|
| `sourceName` | _String_ | Source name. |
**Response Items:**
_No additional response items._
---
## Outputs

View File

@ -144,6 +144,7 @@ const QHash<QString, RpcMethodHandler> WSRequestHandler::messageMap{
{ "SetAudioMonitorType", &WSRequestHandler::SetAudioMonitorType },
{ "GetSourceDefaultSettings", &WSRequestHandler::GetSourceDefaultSettings },
{ "TakeSourceScreenshot", &WSRequestHandler::TakeSourceScreenshot },
{ "RefreshBrowserSource", &WSRequestHandler::RefreshBrowserSource },
// Category: Streaming
{ "GetStreamingStatus", &WSRequestHandler::GetStreamingStatus },

View File

@ -161,6 +161,7 @@ class WSRequestHandler {
RpcResponse SetAudioMonitorType(const RpcRequest&);
RpcResponse GetSourceDefaultSettings(const RpcRequest&);
RpcResponse TakeSourceScreenshot(const RpcRequest&);
RpcResponse RefreshBrowserSource(const RpcRequest&);
// Category: Streaming
RpcResponse GetStreamingStatus(const RpcRequest&);

View File

@ -1894,3 +1894,38 @@ RpcResponse WSRequestHandler::TakeSourceScreenshot(const RpcRequest& request) {
obs_data_set_string(response, "sourceName", obs_source_get_name(source));
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();
}