Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ target_sources(
src/requesthandler/RequestBatchHandler.h
src/requesthandler/RequestHandler.cpp
src/requesthandler/RequestHandler.h
src/requesthandler/RequestHandler_Canvases.cpp
src/requesthandler/RequestHandler_Config.cpp
src/requesthandler/RequestHandler_Filters.cpp
src/requesthandler/RequestHandler_General.cpp
Expand Down
3 changes: 3 additions & 0 deletions src/requesthandler/RequestHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ const std::unordered_map<std::string, RequestMethodHandler> RequestHandler::_han
{"GetRecordDirectory", &RequestHandler::GetRecordDirectory},
{"SetRecordDirectory", &RequestHandler::SetRecordDirectory},

// Canvases
{"GetCanvasList", &RequestHandler::GetCanvasList},

// Sources
{"GetSourceActive", &RequestHandler::GetSourceActive},
{"GetSourceScreenshot", &RequestHandler::GetSourceScreenshot},
Expand Down
3 changes: 3 additions & 0 deletions src/requesthandler/RequestHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ class RequestHandler {
RequestResult GetRecordDirectory(const Request &);
RequestResult SetRecordDirectory(const Request &);

// Canvases
RequestResult GetCanvasList(const Request &);

// Sources
RequestResult GetSourceActive(const Request &);
RequestResult GetSourceScreenshot(const Request &);
Expand Down
61 changes: 61 additions & 0 deletions src/requesthandler/RequestHandler_Canvases.cpp
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);
}
16 changes: 16 additions & 0 deletions src/requesthandler/RequestHandler_Filters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
* @requestField ?sourceName | String | Name of the source
* @requestField ?sourceUuid | String | UUID of the source
*
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/requesthandler/RequestHandler_Inputs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ RequestResult RequestHandler::GetSpecialInputs(const Request &)
/**
* Creates a new input, adding it as a scene item to the specified scene.
*
* @requestField ?canvasName | String | Name of the canvas the scene is in
* @requestField ?canvasUuid | String | UUID of the canvas the scene is in
* @requestField ?sceneName | String | Name of the scene to add the input to as a scene item
* @requestField ?sceneUuid | String | UUID of the scene to add the input to as a scene item
* @requestField inputName | String | Name of the new input to created
Expand Down
42 changes: 38 additions & 4 deletions src/requesthandler/RequestHandler_SceneItems.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ with this program. If not, see <https://www.gnu.org/licenses/>
*
* Scenes only
*
* @requestField ?sceneName | String | Name of the scene to get the items of
* @requestField ?sceneUuid | String | UUID of the scene to get the items of
* @requestField ?canvasName | String | Name of the canvas the scene is in
* @requestField ?canvasUuid | String | UUID of the canvas the scene is in
* @requestField ?sceneName | String | Name of the scene to get the items of
* @requestField ?sceneUuid | String | UUID of the scene to get the items of
*
* @responseField sceneItems | Array<Object> | Array of scene items in the scene
*
Expand Down Expand Up @@ -57,8 +59,10 @@ RequestResult RequestHandler::GetSceneItemList(const Request &request)
*
* Groups only
*
* @requestField ?sceneName | String | Name of the group to get the items of
* @requestField ?sceneUuid | String | UUID of the group to get the items of
* @requestField ?canvasName | String | Name of the canvas the group is in
* @requestField ?canvasUuid | String | UUID of the canvas the group is in
* @requestField ?sceneName | String | Name of the group to get the items of
* @requestField ?sceneUuid | String | UUID of the group to get the items of
*
* @responseField sceneItems | Array<Object> | Array of scene items in the group
*
Expand Down Expand Up @@ -88,6 +92,8 @@ RequestResult RequestHandler::GetGroupSceneItemList(const Request &request)
*
* Scenes and Groups
*
* @requestField ?canvasName | String | Name of the canvas the scene or group is in
* @requestField ?canvasUuid | String | UUID of the canvas the scene or group is in
* @requestField ?sceneName | String | Name of the scene or group to search in
* @requestField ?sceneUuid | String | UUID of the scene or group to search in
* @requestField sourceName | String | Name of the source to find
Expand Down Expand Up @@ -133,6 +139,8 @@ RequestResult RequestHandler::GetSceneItemId(const Request &request)
/**
* Gets the source associated with a scene item.
*
* @requestField ?canvasName | String | Name of the canvas the scene is in
* @requestField ?canvasUuid | String | UUID of the canvas the scene is in
* @requestField ?sceneName | String | Name of the scene the item is in
* @requestField ?sceneUuid | String | UUID of the scene the item is in
* @requestField sceneItemId | Number | Numeric ID of the scene item | >= 0
Expand Down Expand Up @@ -169,6 +177,8 @@ RequestResult RequestHandler::GetSceneItemSource(const Request &request)
*
* Scenes only
*
* @requestField ?canvasName | String | Name of the canvas the scene is in
* @requestField ?canvasUuid | String | UUID of the canvas the scene is in
* @requestField ?sceneName | String | Name of the scene to create the new item in
* @requestField ?sceneUuid | String | UUID of the scene to create the new item in
* @requestField ?sourceName | String | Name of the source to add to the scene
Expand Down Expand Up @@ -223,6 +233,8 @@ RequestResult RequestHandler::CreateSceneItem(const Request &request)
*
* Scenes only
*
* @requestField ?canvasName | String | Name of the canvas the scene is in
* @requestField ?canvasUuid | String | UUID of the canvas the scene is in
* @requestField ?sceneName | String | Name of the scene the item is in
* @requestField ?sceneUuid | String | UUID of the scene the item is in
* @requestField sceneItemId | Number | Numeric ID of the scene item | >= 0
Expand Down Expand Up @@ -253,6 +265,8 @@ RequestResult RequestHandler::RemoveSceneItem(const Request &request)
*
* Scenes only
*
* @requestField ?canvasName | String | Name of the canvas the scene is in
* @requestField ?canvasUuid | String | UUID of the canvas the scene is in
* @requestField ?sceneName | String | Name of the scene the item is in
* @requestField ?sceneUuid | String | UUID of the scene the item is in
* @requestField sceneItemId | Number | Numeric ID of the scene item | >= 0
Expand Down Expand Up @@ -330,6 +344,8 @@ RequestResult RequestHandler::DuplicateSceneItem(const Request &request)
*
* Scenes and Groups
*
* @requestField ?canvasName | String | Name of the canvas the scene is in
* @requestField ?canvasUuid | String | UUID of the canvas the scene is in
* @requestField ?sceneName | String | Name of the scene the item is in
* @requestField ?sceneUuid | String | UUID of the scene the item is in
* @requestField sceneItemId | Number | Numeric ID of the scene item | >= 0
Expand Down Expand Up @@ -361,6 +377,8 @@ RequestResult RequestHandler::GetSceneItemTransform(const Request &request)
/**
* Sets the transform and crop info of a scene item.
*
* @requestField ?canvasName | String | Name of the canvas the scene is in
* @requestField ?canvasUuid | String | UUID of the canvas the scene is in
* @requestField ?sceneName | String | Name of the scene the item is in
* @requestField ?sceneUuid | String | UUID of the scene the item is in
* @requestField sceneItemId | Number | Numeric ID of the scene item | >= 0
Expand Down Expand Up @@ -526,6 +544,8 @@ RequestResult RequestHandler::SetSceneItemTransform(const Request &request)
*
* Scenes and Groups
*
* @requestField ?canvasName | String | Name of the canvas the scene is in
* @requestField ?canvasUuid | String | UUID of the canvas the scene is in
* @requestField ?sceneName | String | Name of the scene the item is in
* @requestField ?sceneUuid | String | UUID of the scene the item is in
* @requestField sceneItemId | Number | Numeric ID of the scene item | >= 0
Expand Down Expand Up @@ -559,6 +579,8 @@ RequestResult RequestHandler::GetSceneItemEnabled(const Request &request)
*
* Scenes and Groups
*
* @requestField ?canvasName | String | Name of the canvas the scene is in
* @requestField ?canvasUuid | String | UUID of the canvas the scene is in
* @requestField ?sceneName | String | Name of the scene the item is in
* @requestField ?sceneUuid | String | UUID of the scene the item is in
* @requestField sceneItemId | Number | Numeric ID of the scene item | >= 0
Expand Down Expand Up @@ -592,6 +614,8 @@ RequestResult RequestHandler::SetSceneItemEnabled(const Request &request)
*
* Scenes and Groups
*
* @requestField ?canvasName | String | Name of the canvas the scene is in
* @requestField ?canvasUuid | String | UUID of the canvas the scene is in
* @requestField ?sceneName | String | Name of the scene the item is in
* @requestField ?sceneUuid | String | UUID of the scene the item is in
* @requestField sceneItemId | Number | Numeric ID of the scene item | >= 0
Expand Down Expand Up @@ -625,6 +649,8 @@ RequestResult RequestHandler::GetSceneItemLocked(const Request &request)
*
* Scenes and Group
*
* @requestField ?canvasName | String | Name of the canvas the scene is in
* @requestField ?canvasUuid | String | UUID of the canvas the scene is in
* @requestField ?sceneName | String | Name of the scene the item is in
* @requestField ?sceneUuid | String | UUID of the scene the item is in
* @requestField sceneItemId | Number | Numeric ID of the scene item | >= 0
Expand Down Expand Up @@ -660,6 +686,8 @@ RequestResult RequestHandler::SetSceneItemLocked(const Request &request)
*
* Scenes and Groups
*
* @requestField ?canvasName | String | Name of the canvas the scene is in
* @requestField ?canvasUuid | String | UUID of the canvas the scene is in
* @requestField ?sceneName | String | Name of the scene the item is in
* @requestField ?sceneUuid | String | UUID of the scene the item is in
* @requestField sceneItemId | Number | Numeric ID of the scene item | >= 0
Expand Down Expand Up @@ -693,6 +721,8 @@ RequestResult RequestHandler::GetSceneItemIndex(const Request &request)
*
* Scenes and Groups
*
* @requestField ?canvasName | String | Name of the canvas the scene is in
* @requestField ?canvasUuid | String | UUID of the canvas the scene is in
* @requestField ?sceneName | String | Name of the scene the item is in
* @requestField ?sceneUuid | String | UUID of the scene the item is in
* @requestField sceneItemId | Number | Numeric ID of the scene item | >= 0
Expand Down Expand Up @@ -736,6 +766,8 @@ RequestResult RequestHandler::SetSceneItemIndex(const Request &request)
*
* Scenes and Groups
*
* @requestField ?canvasName | String | Name of the canvas the scene is in
* @requestField ?canvasUuid | String | UUID of the canvas the scene is in
* @requestField ?sceneName | String | Name of the scene the item is in
* @requestField ?sceneUuid | String | UUID of the scene the item is in
* @requestField sceneItemId | Number | Numeric ID of the scene item | >= 0
Expand Down Expand Up @@ -771,6 +803,8 @@ RequestResult RequestHandler::GetSceneItemBlendMode(const Request &request)
*
* Scenes and Groups
*
* @requestField ?canvasName | String | Name of the canvas the scene is in
* @requestField ?canvasUuid | String | UUID of the canvas the scene is in
* @requestField ?sceneName | String | Name of the scene the item is in
* @requestField ?sceneUuid | String | UUID of the scene the item is in
* @requestField sceneItemId | Number | Numeric ID of the scene item | >= 0
Expand Down
Loading