-
-
Notifications
You must be signed in to change notification settings - Fork 734
requesthandler: Add Canvas support #1314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| /* | ||
| obs-websocket | ||
| Copyright (C) 2016-2021 Stephane Lepin <[email protected]> | ||
| Copyright (C) 2020-2021 Kyle Manning <[email protected]> | ||
| This program is free software; you can redistribute it and/or modify | ||
| it under the terms of the GNU General Public License as published by | ||
| the Free Software Foundation; either version 2 of the License, or | ||
| (at your option) any later version. | ||
| This program is distributed in the hope that it will be useful, | ||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| GNU General Public License for more details. | ||
| You should have received a copy of the GNU General Public License along | ||
| with this program. If not, see <https://www.gnu.org/licenses/> | ||
| */ | ||
|
|
||
| #include "RequestHandler.h" | ||
|
|
||
| /** | ||
| * Gets an array of canvases in OBS. | ||
| * | ||
| * @responseField canvases | Array<Object> | Array of canvases | ||
| * | ||
| * @requestType GetCanvasList | ||
| * @complexity 2 | ||
| * @rpcVersion -1 | ||
| * @initialVersion 5.0.0 | ||
| * @api requests | ||
| * @category scenes | ||
| */ | ||
| RequestResult RequestHandler::GetCanvasList(const Request &request) | ||
| { | ||
| json responseData; | ||
| std::vector<json> ret; | ||
|
|
||
| obs_enum_canvases( | ||
| [](void *param, obs_canvas_t *canvas) { | ||
| auto ret = static_cast<std::vector<json> *>(param); | ||
| json canvasJson; | ||
| canvasJson["canvasName"] = obs_canvas_get_name(canvas); | ||
| canvasJson["canvasUuid"] = obs_canvas_get_uuid(canvas); | ||
| struct obs_video_info ovi; | ||
| if (obs_canvas_get_video_info(canvas, &ovi)) { | ||
| canvasJson["fpsNumerator"] = ovi.fps_num; | ||
| canvasJson["fpsDenominator"] = ovi.fps_den; | ||
| canvasJson["baseWidth"] = ovi.base_width; | ||
| canvasJson["baseHeight"] = ovi.base_height; | ||
| canvasJson["outputWidth"] = ovi.output_width; | ||
| canvasJson["outputHeight"] = ovi.output_height; | ||
| } | ||
| ret->push_back(canvasJson); | ||
| return true; | ||
| }, | ||
| &ret); | ||
| responseData["canvases"] = ret; | ||
|
|
||
| return RequestResult::Success(responseData); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,6 +43,8 @@ RequestResult RequestHandler::GetSourceFilterKindList(const Request &) | |
| /** | ||
| * Gets an array of all of a source's filters. | ||
| * | ||
| * @requestField ?canvasName | String | Name of the canvas the source is in | ||
| * @requestField ?canvasUuid | String | UUID of the canvas the source is in | ||
|
Comment on lines
+46
to
+47
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the reason for this addition? I was under the impression source names and uuids are globally unique, and not unique per canvas. Am I wrong on that?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Discussed off thread. Scene and Group names are only unique per canvas, not globally. |
||
| * @requestField ?sourceName | String | Name of the source | ||
| * @requestField ?sourceUuid | String | UUID of the source | ||
| * | ||
|
|
@@ -107,6 +109,8 @@ RequestResult RequestHandler::GetSourceFilterDefaultSettings(const Request &requ | |
| /** | ||
| * Creates a new filter, adding it to the specified source. | ||
| * | ||
| * @requestField ?canvasName | String | Name of the canvas the source is in | ||
| * @requestField ?canvasUuid | String | UUID of the canvas the source is in | ||
| * @requestField ?sourceName | String | Name of the source to add the filter to | ||
| * @requestField ?sourceUuid | String | UUID of the source to add the filter to | ||
| * @requestField filterName | String | Name of the new filter to be created | ||
|
|
@@ -161,6 +165,8 @@ RequestResult RequestHandler::CreateSourceFilter(const Request &request) | |
| /** | ||
| * Removes a filter from a source. | ||
| * | ||
| * @requestField ?canvasName | String | Name of the canvas the source is in | ||
| * @requestField ?canvasUuid | String | UUID of the canvas the source is in | ||
| * @requestField ?sourceName | String | Name of the source the filter is on | ||
| * @requestField ?sourceUuid | String | UUID of the source the filter is on | ||
| * @requestField filterName | String | Name of the filter to remove | ||
|
|
@@ -188,6 +194,8 @@ RequestResult RequestHandler::RemoveSourceFilter(const Request &request) | |
| /** | ||
| * Sets the name of a source filter (rename). | ||
| * | ||
| * @requestField ?canvasName | String | Name of the canvas the source is in | ||
| * @requestField ?canvasUuid | String | UUID of the canvas the source is in | ||
| * @requestField ?sourceName | String | Name of the source the filter is on | ||
| * @requestField ?sourceUuid | String | UUID of the source the filter is on | ||
| * @requestField filterName | String | Current name of the filter | ||
|
|
@@ -222,6 +230,8 @@ RequestResult RequestHandler::SetSourceFilterName(const Request &request) | |
| /** | ||
| * Gets the info for a specific source filter. | ||
| * | ||
| * @requestField ?canvasName | String | Name of the canvas the source is in | ||
| * @requestField ?canvasUuid | String | UUID of the canvas the source is in | ||
| * @requestField ?sourceName | String | Name of the source | ||
| * @requestField ?sourceUuid | String | UUID of the source | ||
| * @requestField filterName | String | Name of the filter | ||
|
|
@@ -262,6 +272,8 @@ RequestResult RequestHandler::GetSourceFilter(const Request &request) | |
| /** | ||
| * Sets the index position of a filter on a source. | ||
| * | ||
| * @requestField ?canvasName | String | Name of the canvas the source is in | ||
| * @requestField ?canvasUuid | String | UUID of the canvas the source is in | ||
| * @requestField ?sourceName | String | Name of the source the filter is on | ||
| * @requestField ?sourceUuid | String | UUID of the source the filter is on | ||
| * @requestField filterName | String | Name of the filter | ||
|
|
@@ -292,6 +304,8 @@ RequestResult RequestHandler::SetSourceFilterIndex(const Request &request) | |
| /** | ||
| * Sets the settings of a source filter. | ||
| * | ||
| * @requestField ?canvasName | String | Name of the canvas the source is in | ||
| * @requestField ?canvasUuid | String | UUID of the canvas the source is in | ||
| * @requestField ?sourceName | String | Name of the source the filter is on | ||
| * @requestField ?sourceUuid | String | UUID of the source the filter is on | ||
| * @requestField filterName | String | Name of the filter to set the settings of | ||
|
|
@@ -341,6 +355,8 @@ RequestResult RequestHandler::SetSourceFilterSettings(const Request &request) | |
| /** | ||
| * Sets the enable state of a source filter. | ||
| * | ||
| * @requestField ?canvasName | String | Name of the canvas the source is in | ||
| * @requestField ?canvasUuid | String | UUID of the canvas the source is in | ||
| * @requestField ?sourceName | String | Name of the source the filter is on | ||
| * @requestField ?sourceUuid | String | UUID of the source the filter is on | ||
| * @requestField filterName | String | Name of the filter | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think Canvas stuff should have it's own category, especially as more management functionality gets added to the frontend in the future.